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

Represents a network host that can communicate through routers. More...

#include <host.h>

Inheritance diagram for NetSim::Host:
Inheritance graph
[legend]

Public Member Functions

 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 network host that can communicate through routers.

A host maintains various tables to map processes to ports, IP addresses to MAC addresses, and domain names to IP addresses. It can also maintain cables connected to routers.

Constructor & Destructor Documentation

◆ Host() [1/2]

NetSim::Host::Host ( )
default

The default constructor.

◆ Host() [2/2]

Host::Host ( const NetworkCard networkCard)

Constructor that initializes a host with a network card.

Parameters
networkCardThe network card associated with this host.
Here is the call graph for this function:

Member Function Documentation

◆ addDomain()

void Host::addDomain ( const QString &  domain,
const IPAddress ipAddress 
)

Adds a domain to IP address resolution to the DNS table.

Parameters
domainThe domain to add.
ipAddressThe IP address to add.
Here is the caller graph for this function:

◆ addIPAddress()

void Host::addIPAddress ( const IPAddress ipAddress,
const MACAddress macAddress 
)

Adds an IP address to MAC address resolution to the ARP table.

Parameters
ipAddressThe IP address to add.
macAddressThe MAC address to add.

◆ addMACAddress()

void Host::addMACAddress ( const MACAddress macAddress,
Router router 
)

Adds a MAC address to router pointer to the cables table.

Parameters
macAddressThe MAC address to add.
routerThe router to add.

◆ addProcess()

void Host::addProcess ( const Process process)

Adds a process to the process table.

Parameters
processThe process to add.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cables()

QMap< MACAddress, Router * > Host::cables ( ) const

Retrieve the cables table.

Return values
QMap<MACAddress,Router*> The table mapping MAC addresses to routers.

◆ domainTable()

QMap< QString, IPAddress > Host::domainTable ( ) const

Retrieve the domain table.

Return values
QMap<QString,IPAddress>The table mapping domain names to IP addresses.
Here is the caller graph for this function:

◆ getProcessByName()

Process & Host::getProcessByName ( const QString &  name)

Retrieves a process by its name.

Parameters
nameThe name of the process to retrieve.
Return values
Process&A reference to the retrieved process.
Exceptions
std::runtime_errorIf no process with the given name is found.
Here is the caller graph for this function:

◆ getRouterByMACAddress()

Router * Host::getRouterByMACAddress ( const MACAddress destinationAddress)

Retrieves the router by its MAC address.

Parameters
destinationAddressThe MAC address of the router to retrieve.
Return values
Router*Pointer to the associated router.
Exceptions
CableNotFoundExceptionIf the MAC address does not map to any router.
Here is the caller graph for this function:

◆ hostTable()

QMap< IPAddress, MACAddress > Host::hostTable ( ) const

Retrieve the host table.

Return values
QMap<IPAddress,MACAddress>The table mapping IP addresses to MAC addresses.
Here is the caller graph for this function:

◆ networkCard()

NetworkCard Host::networkCard ( ) const

Retrieve the network card.

Return values
NetworkCardThe associated network card.
Here is the caller graph for this function:

◆ packages()

PackageTableModel * Host::packages ( ) const

Get all the packages associated with this host.

Return values
PackageTableModel*Pointer to the package table model.
Here is the caller graph for this function:

◆ processTable()

QMap< Port, Process > Host::processTable ( ) const

Retrieve the process table.

Return values
QMap<Port,Process>The table mapping ports to processes.

◆ receivePackage()

virtual void NetSim::Host::receivePackage ( Package  data)
pure virtual

Pure virtual function to receive a package. Must be implemented in derived classes.

Parameters
dataThe received package.

Implemented in NetSim::Client, and NetSim::Server.

Here is the caller graph for this function:

◆ sendPackage()

void Host::sendPackage ( Package data,
const MACAddress destinationAddress 
)

Send a package to a destination MAC address.

Parameters
dataThe package to send.
destinationAddressThe MAC address of the destination.

◆ setHostOfProcesses()

void Host::setHostOfProcesses ( Host host)

Set the host for all processes.

Parameters
hostPointer to the new host.

◆ setPackages()

void Host::setPackages ( PackageTableModel packages)

Set the packages for this host.

Parameters
packagesPointer to the new package table model.
Here is the call graph for this function:

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