NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
Public Member Functions | List of all members
NetSim::Client Class Reference

Represents a client in the network simulation. More...

#include <client.h>

Inheritance diagram for NetSim::Client:
Inheritance graph
[legend]
Collaboration diagram for NetSim::Client:
Collaboration graph
[legend]

Public Member Functions

 Client ()=default
 Default constructor.
 
 Client (const NetworkCard &networkCard)
 Constructs a client with the provided network card.
 
void execDomainResolution (const QString &domain)
 Initiates a domain name resolution.
 
void execHandShake (const IPAddress &address)
 Initiates a TCP handshake to the specified IP address.
 
void execHTTPRequest (const IPAddress &address, const QString &uri)
 Sends an HTTP request to the specified IP address and URI.
 
void execCloseConnection (const IPAddress &address)
 Closes the connection to the specified IP address.
 
void receivePackage (Package data) override
 Receives a package and processes based on its type.
 
- Public Member Functions inherited from NetSim::Host
 Host ()=default
 The default constructor.
 
 Host (const NetworkCard &networkCard)
 Constructor that initializes a host with a network card.
 
QMap< Port, ProcessprocessTable () const
 Retrieve the process table.
 
QMap< IPAddress, MACAddresshostTable () const
 Retrieve the host table.
 
QMap< QString, IPAddressdomainTable () const
 Retrieve the domain table.
 
QMap< MACAddress, Router * > cables () const
 Retrieve the cables table.
 
NetworkCard networkCard () const
 Retrieve the network card.
 
RoutergetRouterByMACAddress (const MACAddress &destinationAddress)
 Retrieves the router by its MAC address.
 
void sendPackage (Package &data, const MACAddress &destinationAddress)
 Send a package to a destination MAC address.
 
virtual void receivePackage (Package data)=0
 Pure virtual function to receive a package. Must be implemented in derived classes.
 
void addProcess (const Process &process)
 Adds a process to the process table.
 
void addIPAddress (const IPAddress &ipAddress, const MACAddress &macAddress)
 Adds an IP address to MAC address resolution to the ARP table.
 
void addMACAddress (const MACAddress &macAddress, Router *router)
 Adds a MAC address to router pointer to the cables table.
 
void addDomain (const QString &domain, const IPAddress &ipAddress)
 Adds a domain to IP address resolution to the DNS table.
 
PackageTableModelpackages () const
 Get all the packages associated with this host.
 
void setPackages (PackageTableModel *packages)
 Set the packages for this host.
 
ProcessgetProcessByName (const QString &name)
 Retrieves a process by its name.
 
void setHostOfProcesses (Host *host)
 Set the host for all processes.
 

Detailed Description

Represents a client in the network simulation.

The Client class is responsible for initiating network requests such as DNS resolution, establishing TCP handshakes, making HTTP requests, and closing connections.

Constructor & Destructor Documentation

◆ Client() [1/2]

NetSim::Client::Client ( )
default

Default constructor.

◆ Client() [2/2]

Client::Client ( const NetworkCard networkCard)

Constructs a client with the provided network card.

Parameters
networkCardNetwork interface card of the client.

Member Function Documentation

◆ execCloseConnection()

void Client::execCloseConnection ( const IPAddress address)

Closes the connection to the specified IP address.

Parameters
addressIP address to close the connection.
Here is the call graph for this function:

◆ execDomainResolution()

void Client::execDomainResolution ( const QString &  domain)

Initiates a domain name resolution.

Parameters
domainDomain name to be resolved.
Here is the call graph for this function:

◆ execHandShake()

void Client::execHandShake ( const IPAddress address)

Initiates a TCP handshake to the specified IP address.

Parameters
addressIP address to establish a connection.
Here is the call graph for this function:

◆ execHTTPRequest()

void Client::execHTTPRequest ( const IPAddress address,
const QString &  uri 
)

Sends an HTTP request to the specified IP address and URI.

Parameters
addressIP address of the server to send the request.
uriRequested Uniform Resource Identifier.
Here is the call graph for this function:

◆ receivePackage()

void Client::receivePackage ( Package  data)
overridevirtual

Receives a package and processes based on its type.

The client can receive and process DNS Response, TCP Handshake, and TCP closing packages.

Parameters
dataPackage data received by the client.

Implements NetSim::Host.

Here is the call graph for this function:

The documentation for this class was generated from the following files: