NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
host.h
Go to the documentation of this file.
1#ifndef HOST_H
2#define HOST_H
3
9#include <QMap>
10#include <QString>
11
15
16namespace NetSim {
17
20
21class Router;
22
32class Host {
33public:
35 Host() = default;
36
42
47 QMap<Port, Process> processTable() const;
48
54 QMap<IPAddress, MACAddress> hostTable() const;
55
61 QMap<QString, IPAddress> domainTable() const;
62
68 QMap<MACAddress, Router *> cables() const;
69
74
82 Router *getRouterByMACAddress(const MACAddress &destinationAddress);
83
89 void sendPackage(Package &data, const MACAddress &destinationAddress);
90
96 virtual void receivePackage(Package data) = 0;
97
102 void addProcess(const Process &process);
103
109 void addIPAddress(const IPAddress &ipAddress, const MACAddress &macAddress);
110
116 void addMACAddress(const MACAddress &macAddress, Router *router);
117
123 void addDomain(const QString &domain, const IPAddress &ipAddress);
124
130
136
143 Process &getProcessByName(const QString &name);
144
149 void setHostOfProcesses(Host *host);
150
151private:
153 QMap<Port, Process> m_processTable{};
154
156 QMap<IPAddress, MACAddress> m_hostTable{};
157
159 QMap<QString, IPAddress> m_domainTable{};
160
163 QMap<MACAddress, Router *> m_cables{};
164
166 NetworkCard m_networkCard{};
167
169 PackageTableModel *m_packages{nullptr};
170};
171} // namespace NetSim
172
173#endif // HOST_H
Represents a network host that can communicate through routers.
Definition host.h:32
void setPackages(PackageTableModel *packages)
Set the packages for this host.
Definition host.cpp:19
void addMACAddress(const MACAddress &macAddress, Router *router)
Adds a MAC address to router pointer to the cables table.
Definition host.cpp:69
Process & getProcessByName(const QString &name)
Retrieves a process by its name.
Definition host.cpp:23
PackageTableModel * packages() const
Get all the packages associated with this host.
Definition host.cpp:17
Router * getRouterByMACAddress(const MACAddress &destinationAddress)
Retrieves the router by its MAC address.
Definition host.cpp:47
void setHostOfProcesses(Host *host)
Set the host for all processes.
Definition host.cpp:33
void addDomain(const QString &domain, const IPAddress &ipAddress)
Adds a domain to IP address resolution to the DNS table.
Definition host.cpp:73
QMap< MACAddress, Router * > cables() const
Retrieve the cables table.
Definition host.cpp:13
void addIPAddress(const IPAddress &ipAddress, const MACAddress &macAddress)
Adds an IP address to MAC address resolution to the ARP table.
Definition host.cpp:64
void addProcess(const Process &process)
Adds a process to the process table.
Definition host.cpp:60
Host()=default
The default constructor.
void sendPackage(Package &data, const MACAddress &destinationAddress)
Send a package to a destination MAC address.
Definition host.cpp:56
QMap< IPAddress, MACAddress > hostTable() const
Retrieve the host table.
Definition host.cpp:9
QMap< Port, Process > processTable() const
Retrieve the process table.
Definition host.cpp:7
NetworkCard networkCard() const
Retrieve the network card.
Definition host.cpp:15
virtual void receivePackage(Package data)=0
Pure virtual function to receive a package. Must be implemented in derived classes.
QMap< QString, IPAddress > domainTable() const
Retrieve the domain table.
Definition host.cpp:11
Represents an IPv4 address.
Definition ipaddress.h:27
Represents a Media Access Control (MAC) address.
Definition macaddress.h:26
Represents a virtual network card with network and physical address capabilities.
Definition networkcard.h:27
Represents a network package.
Definition package.h:28
Custom table model to represent a list of Package objects.
Definition packagetablemodel.h:25
Represents a network process.
Definition process.h:28
Represents a virtual router with capability to forward packages.
Definition router.h:32
Contains the IPAddress class definition.
Contains the MACAddress class definition.
Definition logger.h:12
Contains the Network Card class definition.
Contains the PackageTableModel class definition.
Contains the Process class definition.