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

Represents a virtual router with capability to forward packages. More...

#include <router.h>

Public Member Functions

 Router ()=default
 Default constructor.
 
void receivePackage (Package data)
 Receives a package and forwards it accordingly.
 
IPAddress globalIpAddress () const
 Returns the global IP address of the router.
 
NetworkCard networkCard () const
 Returns the network card associated with the router.
 
QMap< IPAddress, MACAddressmacTable () const
 Returns the MAC address table mapping IP addresses to MAC addresses.
 
QMap< MACAddress, Router * > routerCable () const
 Returns the mapping between MAC addresses and connected routers.
 
QMap< MACAddress, Host * > hostCable () const
 Returns the mapping between MAC addresses and connected hosts.
 
QMap< Port, NATEntryNAT () const
 Returns the mapping of NAT entries and associated ports.
 
void addIPAddress (const IPAddress &ipAddress, const MACAddress &macaddress)
 Adds an IP address and its associated MAC address to the router's table.
 
void addMACAddress (const MACAddress &macAddress, Router *router)
 Adds a MAC address and its associated router to the router's table.
 
void addMACAddress (const MACAddress &macAddress, Host *host)
 Adds a MAC address and its associated host to the router's table.
 
void addNATEntry (const NATEntry &entry, const Port &port)
 Adds a NAT entry and its associated port to the router's NAT table.
 

Detailed Description

Represents a virtual router with capability to forward packages.

The Router class is responsible for simulating the behavior of a network router. It holds information about connected devices and routes packages accordingly.

Constructor & Destructor Documentation

◆ Router()

NetSim::Router::Router ( )
default

Default constructor.

Member Function Documentation

◆ addIPAddress()

void Router::addIPAddress ( const IPAddress ipAddress,
const MACAddress macaddress 
)

Adds an IP address and its associated MAC address to the router's table.

Parameters
ipAddressThe IP address to be added.
macaddressThe associated MAC address.

◆ addMACAddress() [1/2]

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

Adds a MAC address and its associated host to the router's table.

Parameters
macAddressThe MAC address to be added.
hostThe associated host.

◆ addMACAddress() [2/2]

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

Adds a MAC address and its associated router to the router's table.

Parameters
macAddressThe MAC address to be added.
routerThe associated router.

◆ addNATEntry()

void Router::addNATEntry ( const NATEntry entry,
const Port port 
)

Adds a NAT entry and its associated port to the router's NAT table.

Parameters
entryThe NAT entry to be added.
portThe associated port.

◆ globalIpAddress()

IPAddress Router::globalIpAddress ( ) const

Returns the global IP address of the router.

◆ hostCable()

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

Returns the mapping between MAC addresses and connected hosts.

◆ macTable()

QMap< IPAddress, MACAddress > Router::macTable ( ) const

Returns the MAC address table mapping IP addresses to MAC addresses.

◆ NAT()

QMap< Port, NATEntry > Router::NAT ( ) const

Returns the mapping of NAT entries and associated ports.

◆ networkCard()

NetworkCard Router::networkCard ( ) const

Returns the network card associated with the router.

Here is the caller graph for this function:

◆ receivePackage()

void Router::receivePackage ( Package  data)

Receives a package and forwards it accordingly.

Parameters
dataThe data package to be processed and forwarded.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ routerCable()

QMap< MACAddress, Router * > Router::routerCable ( ) const

Returns the mapping between MAC addresses and connected routers.


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