NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
tcp.h
Go to the documentation of this file.
1#ifndef TCP_H
2#define TCP_H
3
6#include "src/models/port.h"
7#include <QDebug>
8#include <QString>
9#include <QVector>
10
14
15namespace NetSim {
16
19enum TCPFlag {
20 FIN = 0,
21 SYN = 1,
22 RST = 2,
23 PSH = 3,
24 ACK = 4,
25 URG = 5,
26 ECE = 6,
27 CWR = 7,
28 NS = 8
29};
30
33
43class TCP {
44public:
61 static void initHeader(const IPAddress &srcAdress,
62 const IPAddress &destAdress, const Port &sourcePort,
63 const Port &destinationPort, quint32 seqNumber,
64 quint32 ackNumber, bool ack, bool psh, bool syn,
65 bool fin, quint16 window, Package &data);
66
67private:
75 static void setFlag(quint16 *flags, bool set, quint16 position);
76
91 static quint16 getTCPChecksum(const QVector<quint8> &sourceAddress,
92 const QVector<quint8> &destinationAddress,
93 quint16 sourcePort, quint16 destinationPort,
94 quint32 seqNumber, quint32 ackNumber,
95 quint16 flags, const char *data,
96 quint16 dataLength);
97};
98
99} // namespace NetSim
100
101#endif // TCP_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
A static class providing methods for initializing TCP headers and managing TCP flags.
Definition tcp.h:43
static void initHeader(const IPAddress &srcAdress, const IPAddress &destAdress, const Port &sourcePort, const Port &destinationPort, quint32 seqNumber, quint32 ackNumber, bool ack, bool psh, bool syn, bool fin, quint16 window, Package &data)
Initializes a TCP header.
Definition tcp.cpp:6
Contains the IPAddress class definition.
Definition logger.h:12
TCPFlag
TCP Flags used for the TCP header.
Definition tcp.h:19
@ FIN
Definition tcp.h:20
@ RST
Definition tcp.h:22
@ ACK
Definition tcp.h:24
@ NS
Definition tcp.h:28
@ URG
Definition tcp.h:25
@ CWR
Definition tcp.h:27
@ PSH
Definition tcp.h:23
@ ECE
Definition tcp.h:26
@ SYN
Definition tcp.h:21
Contains the Package class definition.
Contains the Port class definition.