NetSim 1.0.0
An educational network simulation software for students
|
Represents a networking socket for transmitting and receiving data. More...
#include <socket.h>
Public Member Functions | |
Socket ()=default | |
Default constructor. | |
Socket (const Port &sourcePort, const Port &destinationPort) | |
Parameterized constructor. | |
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. | |
void | addUDPHeader (Package &data) |
Adds a UDP header to the provided data package. | |
Port | sourcePort () const |
Simple Getter for source port. | |
void | setSourcePort (const Port &sourcePort) |
Setter for the source port. | |
Port | destinationPort () const |
Simple Getter for destination port. | |
void | setDestinationPort (const Port &destinationPort) |
Setter for the destination port. | |
quint32 | startSeq () const |
Simple Getter for start sequence. | |
quint32 | serverSeq () const |
Simple Getter for server sequence. | |
quint32 | amountReceivedData () const |
Simple Getter for amount of received data. | |
Represents a networking socket for transmitting and receiving data.
The Socket class encapsulates the functionality of both TCP and UDP protocols. It provides a way to add respective headers to the packages.
|
default |
Default constructor.
Parameterized constructor.
sourcePort | The source port of the socket. |
destinationPort | The destination port to which this socket is communicating. |
void Socket::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.
data | The package that will have the TCP header added. |
srcAddress | The source IP address for the TCP header. |
destAddress | The destination IP address for the TCP header. |
ack | TCP ACK flag. |
psh | TCP PSH flag. |
syn | TCP SYN flag. |
fin | TCP FIN flag. |
This function calls the functionality of the TCP class to init the TCP header and adds the header to the given package.
void Socket::addUDPHeader | ( | Package & | data | ) |
quint32 Socket::amountReceivedData | ( | ) | const |
Simple Getter for amount of received data.
Port Socket::destinationPort | ( | ) | const |
Simple Getter for destination port.
quint32 Socket::serverSeq | ( | ) | const |
Simple Getter for server sequence.
void Socket::setDestinationPort | ( | const Port & | destinationPort | ) |
Setter for the destination port.
void Socket::setSourcePort | ( | const Port & | sourcePort | ) |
Setter for the source port.
Port Socket::sourcePort | ( | ) | const |
Simple Getter for source port.
quint32 Socket::startSeq | ( | ) | const |
Simple Getter for start sequence.