NetSim 1.0.0
An educational network simulation software for students
|
Represents a Server entity in the simulation. More...
#include <server.h>
Public Member Functions | |
Server ()=default | |
Default constructor. | |
Server (const NetworkCard &networkCard, const QString &domain, const QString &html) | |
Parameterized constructor to initialize server attributes. | |
QString | domain () const |
Retrieves the domain associated with the server. | |
void | receivePackage (Package data) override |
Processes an incoming data package. | |
QString | htmlFile () const |
Retrieves the HTML content associated with the server. | |
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, Process > | processTable () const |
Retrieve the process table. | |
QMap< IPAddress, MACAddress > | hostTable () const |
Retrieve the host table. | |
QMap< QString, IPAddress > | domainTable () const |
Retrieve the domain table. | |
QMap< MACAddress, Router * > | cables () const |
Retrieve the cables table. | |
NetworkCard | networkCard () const |
Retrieve the network card. | |
Router * | getRouterByMACAddress (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. | |
PackageTableModel * | packages () const |
Get all the packages associated with this host. | |
void | setPackages (PackageTableModel *packages) |
Set the packages for this host. | |
Process & | getProcessByName (const QString &name) |
Retrieves a process by its name. | |
void | setHostOfProcesses (Host *host) |
Set the host for all processes. | |
Represents a Server entity in the simulation.
The Server class extends the Host class, introducing the capability to serve HTML content, handle DNS requests, and participate in HTTP and TCP interactions.
|
default |
Default constructor.
Creates a default instance of the Server.
Server::Server | ( | const NetworkCard & | networkCard, |
const QString & | domain, | ||
const QString & | html | ||
) |
Parameterized constructor to initialize server attributes.
networkCard | The network card configuration for the server. |
domain | The domain associated with the server. |
html | The HTML content that this server can serve. |
QString Server::domain | ( | ) | const |
Retrieves the domain associated with the server.
QString | The domain of the server. |
QString Server::htmlFile | ( | ) | const |
Retrieves the HTML content associated with the server.
QString | The HTML content that this server can serve. |
|
overridevirtual |
Processes an incoming data package.
data | The package that the server has received. |
This function checks the type of the incoming package, determines the appropriate strategy to process it, and delegates the processing to that strategy. Strategies can include DNS response, HTTP response, etc.
Implements NetSim::Host.