NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
socket.h
Go to the documentation of this file.
1#ifndef SOCKET_H
2#define SOCKET_H
3
7
10#include "src/models/port.h"
11
12namespace NetSim {
13
16
17class Port;
18
27class Socket {
28public:
30 Socket() = default;
31
40
55 void addTCPHeader(Package &data, const IPAddress &srcAddress,
56 const IPAddress &destAddress, bool ack, bool psh, bool syn,
57 bool fin);
58
64 void addUDPHeader(Package &data);
65
67 Port sourcePort() const;
68
70 void setSourcePort(const Port &sourcePort);
71
73 Port destinationPort() const;
74
77
79 quint32 startSeq() const;
80
82 quint32 serverSeq() const;
83
85 quint32 amountReceivedData() const;
86
87private:
89 Port m_sourcePort;
90
92 Port m_destinationPort;
93
95 quint32 m_startSeq{100};
96
98 quint32 m_serverSeq{0};
99
101 quint32 m_amountReceivedData{0};
102};
103} // namespace NetSim
104
105#endif // SOCKET_H
Represents an IPv4 address.
Definition ipaddress.h:27
Represents a network package.
Definition package.h:28
Represents a network port.
Definition port.h:24
Represents a networking socket for transmitting and receiving data.
Definition socket.h:27
Socket()=default
Default constructor.
void addUDPHeader(Package &data)
Adds a UDP header to the provided data package.
Definition socket.cpp:16
Port sourcePort() const
Simple Getter for source port.
Definition socket.cpp:23
void setSourcePort(const Port &sourcePort)
Setter for the source port.
Definition socket.cpp:24
quint32 serverSeq() const
Simple Getter for server sequence.
Definition socket.cpp:33
Port destinationPort() const
Simple Getter for destination port.
Definition socket.cpp:27
void setDestinationPort(const Port &destinationPort)
Setter for the destination port.
Definition socket.cpp:28
quint32 startSeq() const
Simple Getter for start sequence.
Definition socket.cpp:32
void addTCPHeader(Package &data, const IPAddress &srcAddress, const IPAddress &destAddress, bool ack, bool psh, bool syn, bool fin)
Adds a TCP header to the provided data package.
Definition socket.cpp:7
quint32 amountReceivedData() const
Simple Getter for amount of received data.
Definition socket.cpp:34
Contains the IPAddress class definition.
Definition logger.h:12
Contains the Package class definition.
Contains the Port class definition.