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

Represents a Server entity in the simulation. More...

#include <server.h>

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

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, 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 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.

Constructor & Destructor Documentation

◆ Server() [1/2]

NetSim::Server::Server ( )
default

Default constructor.

Creates a default instance of the Server.

◆ Server() [2/2]

Server::Server ( const NetworkCard networkCard,
const QString &  domain,
const QString &  html 
)

Parameterized constructor to initialize server attributes.

Parameters
networkCardThe network card configuration for the server.
domainThe domain associated with the server.
htmlThe HTML content that this server can serve.

Member Function Documentation

◆ domain()

QString Server::domain ( ) const

Retrieves the domain associated with the server.

Return values
QStringThe domain of the server.

◆ htmlFile()

QString Server::htmlFile ( ) const

Retrieves the HTML content associated with the server.

Return values
QStringThe HTML content that this server can serve.

◆ receivePackage()

void Server::receivePackage ( Package  data)
overridevirtual

Processes an incoming data package.

Parameters
dataThe 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.

Here is the call graph for this function:

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