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

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Socket() [1/2]

NetSim::Socket::Socket ( )
default

Default constructor.

◆ Socket() [2/2]

Socket::Socket ( const Port sourcePort,
const Port destinationPort 
)

Parameterized constructor.

Parameters
sourcePortThe source port of the socket.
destinationPortThe destination port to which this socket is communicating.

Member Function Documentation

◆ addTCPHeader()

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.

Parameters
dataThe package that will have the TCP header added.
srcAddressThe source IP address for the TCP header.
destAddressThe destination IP address for the TCP header.
ackTCP ACK flag.
pshTCP PSH flag.
synTCP SYN flag.
finTCP FIN flag.

This function calls the functionality of the TCP class to init the TCP header and adds the header to the given package.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addUDPHeader()

void Socket::addUDPHeader ( Package data)

Adds a UDP header to the provided data package.

Parameters
dataThe package that will have the UDP header added.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ amountReceivedData()

quint32 Socket::amountReceivedData ( ) const

Simple Getter for amount of received data.

◆ destinationPort()

Port Socket::destinationPort ( ) const

Simple Getter for destination port.

Here is the caller graph for this function:

◆ serverSeq()

quint32 Socket::serverSeq ( ) const

Simple Getter for server sequence.

◆ setDestinationPort()

void Socket::setDestinationPort ( const Port destinationPort)

Setter for the destination port.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSourcePort()

void Socket::setSourcePort ( const Port sourcePort)

Setter for the source port.

Here is the call graph for this function:

◆ sourcePort()

Port Socket::sourcePort ( ) const

Simple Getter for source port.

Here is the caller graph for this function:

◆ startSeq()

quint32 Socket::startSeq ( ) const

Simple Getter for start sequence.


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