DESERT 4.0.0
uwApplicationModule Class Reference

#include <uwApplication_module.h>

Inheritance diagram for uwApplicationModule:
Inheritance graph
Collaboration diagram for uwApplicationModule:
Collaboration graph

Public Member Functions

 uwApplicationModule ()
 
virtual ~uwApplicationModule ()
 
virtual int command (int argc, const char *const *argv) override
 
virtual void recv (Packet *) override
 
virtual double GetFTT () const
 
virtual double GetFTTstd () const
 
virtual double GetPER () const
 
virtual double GetTHR () const
 
virtual double GetRTT () const
 
virtual double GetRTTstd () const
 
virtual int getPktSent () const
 
virtual int getPktLost () const
 
virtual int getPktRecv () const
 
virtual int getPktsOOSequence () const
 
virtual int getPktsInvalidRx () const
 
virtual int getPktsPushQueue () const
 
virtual double getPeriod () const
 
std::string getEpoch () const
 
virtual void printOnLog (LogLev log_level, const std::string &module, const std::string &message) const override
 

Protected Member Functions

virtual void transmit ()
 
virtual bool listenTCP ()
 
virtual void acceptTCP ()
 
virtual void readFromTCP (int clnSock)
 
virtual bool openConnectionUDP ()
 
virtual void readFromUDP ()
 
virtual void stop ()
 
virtual bool withoutSocket ()
 
virtual bool useTCP ()
 
virtual bool usePoissonTraffic ()
 
virtual bool useDropOutOfOrder ()
 
virtual void incrPktSent ()
 
virtual void incrPktLost (int npkts)
 
virtual void incrPktRecv ()
 
virtual void incrPktOoseq ()
 
virtual void incrPktInvalid ()
 
virtual void incrPktsPushQueue ()
 
virtual double getTimeBeforeNextPkt ()
 
virtual void updateRTT (double rtt)
 
virtual void updateFTT (double ftt)
 
virtual void updateThroughput (int bytes, double dt)
 

Protected Attributes

bool socket_active
 
bool socket_tcp
 
bool * sn_check
 
uint8_t dst_addr
 
int poisson_traffic
 
int payloadsize
 
int port_num
 
int drop_out_of_order
 
int uidcnt
 
int hrsn
 
int txsn
 
int rftt
 
int pkts_lost
 
int pkts_recv
 
int pkts_ooseq
 
int pkts_invalid
 
int pkts_push_queue
 
int pkts_last_reset
 
int sea_trial
 
int node_id
 
int servSockDescr
 
int clnSockDescr
 
int servPort
 
uint32_t esn
 
int rttsamples
 
int fttsamples
 
double period
 
double lrtime
 
double sumrtt
 
double sumrtt2
 
double sumftt
 
double sumftt2
 
double sumbytes
 
double sumdt
 
struct sockaddr_in servAddr
 
struct sockaddr_in clnAddr
 
std::thread socket_thread
 
std::mutex socket_mutex
 
std::atomic< bool > receiving
 
std::queue< Packet * > queuePckReadTCP
 
std::queue< Packet * > queuePckReadUDP
 
uwSendTimerApplchkTimerPeriod
 

Static Protected Attributes

static uint MAX_READ_LEN = 64
 

Friends

class uwSendTimerAppl
 

Constructor & Destructor Documentation

◆ uwApplicationModule()

uwApplicationModule::uwApplicationModule ( )

◆ ~uwApplicationModule()

uwApplicationModule::~uwApplicationModule ( )
virtual

Destructor of uwApplicationModule class

References stop().

Here is the call graph for this function:

Member Function Documentation

◆ acceptTCP()

void uwApplicationModule::acceptTCP ( )
protectedvirtual

Method that puts in place a listening TCP socket.

References clnAddr, clnSockDescr, printOnLog(), readFromTCP(), receiving, and servSockDescr.

Referenced by command().

Here is the call graph for this function:

◆ command()

int uwApplicationModule::command ( int  argc,
const char *const *  argv 
)
overridevirtual

TCL command interpreter. It implements the following OTCL methods:

Parameters
argcNumber of arguments in argv.
argvArray of strings which are the command parameters (Note that argv[0] is the name of the object).
Returns
TCL_OK or TCL_ERROR whether the command has been dispatched successfully or not.

References acceptTCP(), chkTimerPeriod, GetFTT(), GetFTTstd(), GetPER(), getPktLost(), getPktRecv(), getPktSent(), getPktsInvalidRx(), getPktsOOSequence(), getPktsPushQueue(), GetRTT(), GetRTTstd(), GetTHR(), getTimeBeforeNextPkt(), listenTCP(), openConnectionUDP(), readFromUDP(), receiving, socket_active, socket_tcp, socket_thread, stop(), useTCP(), uwSendTimerAppl, and withoutSocket().

Here is the call graph for this function:

◆ getEpoch()

std::string uwApplicationModule::getEpoch ( ) const
inline

Calculate the epoch of the event. Used in sea-trial mode.

Returns
the epoch of the system.

Referenced by printOnLog().

◆ GetFTT()

double uwApplicationModule::GetFTT ( ) const
virtual

References fttsamples, and sumftt.

Referenced by command().

◆ GetFTTstd()

double uwApplicationModule::GetFTTstd ( ) const
virtual

Return the standard deviation of the Forward Trip Time calculated

Returns
the standard deviation of the Forward Trip Time calculated

References fttsamples, sumftt, and sumftt2.

Referenced by command().

◆ GetPER()

double uwApplicationModule::GetPER ( ) const
virtual

Rerturn the Packet Error Rate calculated

Returns
the Packet Error Rate calculated

References drop_out_of_order, esn, pkts_lost, and pkts_recv.

Referenced by command().

◆ getPeriod()

virtual double uwApplicationModule::getPeriod ( ) const
inlinevirtual

Return period generation time.

Returns
period

References period.

◆ getPktLost()

virtual int uwApplicationModule::getPktLost ( ) const
inlinevirtual

return the number of DATA packets lost by the server

Returns
pkts_lost

References pkts_lost.

Referenced by command().

◆ getPktRecv()

virtual int uwApplicationModule::getPktRecv ( ) const
inlinevirtual

return the number of DATA packet correctly received by the server

Returns
pkts_recv

References pkts_recv.

Referenced by command().

◆ getPktSent()

virtual int uwApplicationModule::getPktSent ( ) const
inlinevirtual

return the number of packets sent by the server

Returns
txsn

References txsn.

Referenced by command().

◆ getPktsInvalidRx()

virtual int uwApplicationModule::getPktsInvalidRx ( ) const
inlinevirtual

return the number of DATA packets received with error by the server

Returns
pkts_invalid

References pkts_invalid.

Referenced by command().

◆ getPktsOOSequence()

virtual int uwApplicationModule::getPktsOOSequence ( ) const
inlinevirtual

return the number of DATA packets received out of order by the server

Returns
pkts_ooseq

References pkts_ooseq.

Referenced by command().

◆ getPktsPushQueue()

virtual int uwApplicationModule::getPktsPushQueue ( ) const
inlinevirtual

Return the number of DATA packets sorted in the server queue.

Returns
pkts_push_queue

References pkts_push_queue.

Referenced by command().

◆ GetRTT()

double uwApplicationModule::GetRTT ( ) const
virtual

Returns the average Round Trip Time

Returns
the average Round Trip Time

References rttsamples, and sumrtt.

Referenced by command().

◆ GetRTTstd()

double uwApplicationModule::GetRTTstd ( ) const
virtual

Return the standard deviation of the Round Trip Time calculated

Returns
the standard deviation of the Round Trip Time calculated

References rttsamples, sumrtt, and sumrtt2.

Referenced by command().

◆ GetTHR()

double uwApplicationModule::GetTHR ( ) const
virtual

Return the Throughput calculated [bps]

Returns
Throughput [bps]

References sumbytes, and sumdt.

Referenced by command().

◆ getTimeBeforeNextPkt()

double uwApplicationModule::getTimeBeforeNextPkt ( )
protectedvirtual

Compute the DATA generation rate, that can be constant and equal to the period established by the user, or can occur with a Poisson process (only without socket).

Returns
generation period for DATA packets

References period, usePoissonTraffic(), and withoutSocket().

Referenced by command(), and transmit().

Here is the call graph for this function:

◆ incrPktInvalid()

virtual void uwApplicationModule::incrPktInvalid ( )
inlineprotectedvirtual

Increse the number of DATA packets received with error by the server

References pkts_invalid.

Referenced by recv().

◆ incrPktLost()

virtual void uwApplicationModule::incrPktLost ( int  npkts)
inlineprotectedvirtual

Increase the number of DATA packets lost by the server

References pkts_lost.

Referenced by recv().

◆ incrPktOoseq()

virtual void uwApplicationModule::incrPktOoseq ( )
inlineprotectedvirtual

Increase the number of DATA packets received out of order by the server

References pkts_ooseq.

Referenced by recv().

◆ incrPktRecv()

virtual void uwApplicationModule::incrPktRecv ( )
inlineprotectedvirtual

Increase the number of DATA packet correctly received by the server

References pkts_recv.

Referenced by recv().

◆ incrPktSent()

virtual void uwApplicationModule::incrPktSent ( )
inlineprotectedvirtual

Increase the sequence number and so the number of packets sent by the server

References txsn.

Referenced by transmit().

◆ incrPktsPushQueue()

virtual void uwApplicationModule::incrPktsPushQueue ( )
inlineprotectedvirtual

Increase the number of DATA packets stored in the Server queue. This DATA packets will be sent to the below levels of ISO/OSI stack protocol.

References pkts_push_queue.

Referenced by readFromTCP(), and readFromUDP().

◆ listenTCP()

bool uwApplicationModule::listenTCP ( )
protectedvirtual

Method that binds the listening TCP socket.

Returns
true if the listening socket is bind and open.

References printOnLog(), servAddr, servPort, and servSockDescr.

Referenced by command().

Here is the call graph for this function:

◆ openConnectionUDP()

bool uwApplicationModule::openConnectionUDP ( )
protectedvirtual

When socket communication is used, this method establish a connection between client and server. This is required because a UDP protocol is used.

Returns
true if the socket is bind.

References printOnLog(), servAddr, servPort, and servSockDescr.

Referenced by command().

Here is the call graph for this function:

◆ printOnLog()

virtual void uwApplicationModule::printOnLog ( LogLev  log_level,
const std::string &  module,
const std::string &  message 
) const
inlineoverridevirtual

Method to send the log message to the logger. If sea_trial enabled add epoch of the event to the message and use node_id passed via tcl.

Parameters
log_levelLogLevel representing the amout of logs.
moduleString name of the plugin/module.
messageString log message.

References getEpoch(), node_id, and sea_trial.

Referenced by acceptTCP(), listenTCP(), openConnectionUDP(), readFromTCP(), readFromUDP(), recv(), and transmit().

Here is the call graph for this function:

◆ readFromTCP()

void uwApplicationModule::readFromTCP ( int  clnSock)
protectedvirtual

Method that reads a TCP byte stream from external application and converts it to a Packet.

Parameters
clnSockint client file descriptor.

References incrPktsPushQueue(), MAX_READ_LEN, hdr_DATA_APPLICATION::payload_msg, hdr_DATA_APPLICATION::payload_size(), printOnLog(), queuePckReadTCP, and socket_mutex.

Referenced by acceptTCP().

Here is the call graph for this function:

◆ readFromUDP()

void uwApplicationModule::readFromUDP ( )
protectedvirtual

Method that waits for UDP packets from external application and converts it to a Packet.

References clnAddr, incrPktsPushQueue(), hdr_DATA_APPLICATION::payload_msg, hdr_DATA_APPLICATION::payload_size(), printOnLog(), queuePckReadUDP, receiving, servSockDescr, and socket_mutex.

Referenced by command().

Here is the call graph for this function:

◆ recv()

void uwApplicationModule::recv ( Packet *  p)
overridevirtual

◆ stop()

void uwApplicationModule::stop ( )
protectedvirtual

Close the socket connection in the case the communication take place with socket, otherwise stop the execution of the process, so force the cancellation of period time generation.

References chkTimerPeriod, clnSockDescr, receiving, servSockDescr, socket_thread, and withoutSocket().

Referenced by command(), and ~uwApplicationModule().

Here is the call graph for this function:

◆ transmit()

void uwApplicationModule::transmit ( )
protectedvirtual

Set all the field of the DATA packet that must be send down after the creation to the below level. In this case the payload of DATA packet are generated in a random way.

References chkTimerPeriod, hdr_uwip::daddr(), hdr_uwudp::dport(), dst_addr, getTimeBeforeNextPkt(), incrPktSent(), hdr_DATA_APPLICATION::payload_size(), payloadsize, port_num, printOnLog(), hdr_DATA_APPLICATION::priority(), PT_DATA_APPLICATION, queuePckReadTCP, queuePckReadUDP, hdr_DATA_APPLICATION::rftt(), rftt, hdr_DATA_APPLICATION::rftt_valid(), hdr_DATA_APPLICATION::sn(), txsn, uidcnt, useTCP(), and withoutSocket().

Here is the call graph for this function:

◆ updateFTT()

void uwApplicationModule::updateFTT ( double  ftt)
protectedvirtual

Update the FTT after the reception of a new packet

Parameters
FTTof the current packet received

References fttsamples, sumftt, and sumftt2.

Referenced by recv().

◆ updateRTT()

void uwApplicationModule::updateRTT ( double  rtt)
protectedvirtual

Update the RTT after the reception of a new packet

Parameters
RTTof the current packet received

References rttsamples, sumrtt, and sumrtt2.

Referenced by recv().

◆ updateThroughput()

void uwApplicationModule::updateThroughput ( int  bytes,
double  dt 
)
protectedvirtual

Update the Throughput after the reception of a new packet

Parameters
bytesof the current packet received
dttime since last rx of a packet

References sumbytes, and sumdt.

Referenced by recv().

◆ useDropOutOfOrder()

virtual bool uwApplicationModule::useDropOutOfOrder ( )
inlineprotectedvirtual

If the communication take place without sockets verify if the data packets received by the server is out of order or not. In the first case discard the data packet.

Returns
true if enable drop out of order false otherwise.

References drop_out_of_order.

Referenced by recv().

◆ usePoissonTraffic()

virtual bool uwApplicationModule::usePoissonTraffic ( )
inlineprotectedvirtual

If the communication take place without sockets verify if the data generation period is constant or a poisson random process

Returns
true if use a Poisson process false if use a constant period data generation

References poisson_traffic.

Referenced by getTimeBeforeNextPkt().

◆ useTCP()

virtual bool uwApplicationModule::useTCP ( )
inlineprotectedvirtual

Check if the socket protocol is TCP or UDP.

Returns
true if socket uses TCP protocol false if uses UDP.

References socket_tcp.

Referenced by command(), and transmit().

◆ withoutSocket()

virtual bool uwApplicationModule::withoutSocket ( )
inlineprotectedvirtual

Check if the communication take place without socket.

Returns
true if communication without socket false otherwise.

References socket_active.

Referenced by command(), getTimeBeforeNextPkt(), recv(), stop(), and transmit().

Friends And Related Symbol Documentation

◆ uwSendTimerAppl

friend class uwSendTimerAppl
friend

Referenced by command().

Member Data Documentation

◆ chkTimerPeriod

uwSendTimerAppl* uwApplicationModule::chkTimerPeriod
protected

Timer that schedule the period between successive generation of DATA packets.

Referenced by command(), stop(), and transmit().

◆ clnAddr

struct sockaddr_in uwApplicationModule::clnAddr
protected

Client address.

Referenced by acceptTCP(), and readFromUDP().

◆ clnSockDescr

int uwApplicationModule::clnSockDescr
protected

Socket descriptor for client.

Referenced by acceptTCP(), recv(), and stop().

◆ drop_out_of_order

int uwApplicationModule::drop_out_of_order
protected

Ordering of data packet received 1 enabled 0 not enabled.

Referenced by GetPER(), useDropOutOfOrder(), and uwApplicationModule().

◆ dst_addr

uint8_t uwApplicationModule::dst_addr
protected

Destination IP address.

Referenced by transmit(), and uwApplicationModule().

◆ esn

uint32_t uwApplicationModule::esn
protected

Expected serial number.

Referenced by GetPER(), and recv().

◆ fttsamples

int uwApplicationModule::fttsamples
protected

Number of FTT samples.

Referenced by GetFTT(), GetFTTstd(), and updateFTT().

◆ hrsn

int uwApplicationModule::hrsn
protected

Highest received sequence number.

Referenced by recv().

◆ lrtime

double uwApplicationModule::lrtime
protected

Time of last packet reception.

Referenced by recv().

◆ MAX_READ_LEN

uint uwApplicationModule::MAX_READ_LEN = 64
staticprotected

Maximum size (bytes) of a single read of the socket

Referenced by readFromTCP(), and uwApplicationModule().

◆ node_id

int uwApplicationModule::node_id
protected

Node id to be print in log output.

Referenced by printOnLog(), and uwApplicationModule().

◆ payloadsize

int uwApplicationModule::payloadsize
protected

Size of each data packet payaload generated.

Referenced by transmit(), and uwApplicationModule().

◆ period

double uwApplicationModule::period
protected

Time between successive generation data packets.

Referenced by getPeriod(), getTimeBeforeNextPkt(), and uwApplicationModule().

◆ pkts_invalid

int uwApplicationModule::pkts_invalid
protected

Counter of the packets received with errors by the server.

Referenced by getPktsInvalidRx(), and incrPktInvalid().

◆ pkts_last_reset

int uwApplicationModule::pkts_last_reset
protected

Used for error checking after stats are reset. Set to pkts_lost+pkts_recv each time resetStats is called.

◆ pkts_lost

int uwApplicationModule::pkts_lost
protected

Counter of the packet lost during the transmission.

Referenced by GetPER(), getPktLost(), and incrPktLost().

◆ pkts_ooseq

int uwApplicationModule::pkts_ooseq
protected

Counter of the packets received out of order by the server.

Referenced by getPktsOOSequence(), and incrPktOoseq().

◆ pkts_push_queue

int uwApplicationModule::pkts_push_queue
protected

Counter of DATA packets received by server and not yet passed to the below levels of ISO/OSI stack protocol.

Referenced by getPktsPushQueue(), and incrPktsPushQueue().

◆ pkts_recv

int uwApplicationModule::pkts_recv
protected

Counter of the packets correctly received by the server.

Referenced by GetPER(), getPktRecv(), and incrPktRecv().

◆ poisson_traffic

int uwApplicationModule::poisson_traffic
protected

Poisson process for generation of data packets 1 enabled 0 not enabled.

Referenced by usePoissonTraffic(), and uwApplicationModule().

◆ port_num

int uwApplicationModule::port_num
protected

Destination port number.

Referenced by transmit(), and uwApplicationModule().

◆ queuePckReadTCP

std::queue<Packet *> uwApplicationModule::queuePckReadTCP
protected

Atomic boolean variable that controls the socket rx looping thread Queue that store the DATA packets recevied from the client by the server using a TCP protocol.

Referenced by readFromTCP(), and transmit().

◆ queuePckReadUDP

std::queue<Packet *> uwApplicationModule::queuePckReadUDP
protected

Queue that store the DATA packets recevied from the client by the server using a UDP protocol.

Referenced by readFromUDP(), and transmit().

◆ receiving

std::atomic<bool> uwApplicationModule::receiving
protected

Referenced by acceptTCP(), command(), readFromUDP(), and stop().

◆ rftt

int uwApplicationModule::rftt
protected

Forward round trip time.

Referenced by recv(), and transmit().

◆ rttsamples

int uwApplicationModule::rttsamples
protected

Number of RTT samples.

Referenced by GetRTT(), GetRTTstd(), and updateRTT().

◆ sea_trial

int uwApplicationModule::sea_trial
protected

Set to 1 to enable epoch time in log output.

Referenced by printOnLog(), and uwApplicationModule().

◆ servAddr

struct sockaddr_in uwApplicationModule::servAddr
protected

Server address.

Referenced by listenTCP(), and openConnectionUDP().

◆ servPort

int uwApplicationModule::servPort
protected

Socket server port.

Referenced by listenTCP(), openConnectionUDP(), and uwApplicationModule().

◆ servSockDescr

int uwApplicationModule::servSockDescr
protected

Socket descriptor for server.

Referenced by acceptTCP(), listenTCP(), openConnectionUDP(), readFromUDP(), and stop().

◆ sn_check

bool* uwApplicationModule::sn_check
protected

Flag set to true if the external application is connected via a TCP socket, false if UDP. Used to keep track of the packets already received.

Referenced by recv(), and uwApplicationModule().

◆ socket_active

bool uwApplicationModule::socket_active
protected

Referenced by command(), and withoutSocket().

◆ socket_mutex

std::mutex uwApplicationModule::socket_mutex
protected

Mutex associated with the socket rx thread

Referenced by readFromTCP(), and readFromUDP().

◆ socket_tcp

bool uwApplicationModule::socket_tcp
protected

Flag set to true if packets are received from external application.

Referenced by command(), and useTCP().

◆ socket_thread

std::thread uwApplicationModule::socket_thread
protected

Object with the socket rx thread

Referenced by command(), and stop().

◆ sumbytes

double uwApplicationModule::sumbytes
protected

Sum of bytes received.

Referenced by GetTHR(), and updateThroughput().

◆ sumdt

double uwApplicationModule::sumdt
protected

Sum of the delays.

Referenced by GetTHR(), and updateThroughput().

◆ sumftt

double uwApplicationModule::sumftt
protected

Sum of FTT samples.

Referenced by GetFTT(), GetFTTstd(), and updateFTT().

◆ sumftt2

double uwApplicationModule::sumftt2
protected

Sum of (FTT^2).

Referenced by GetFTTstd(), and updateFTT().

◆ sumrtt

double uwApplicationModule::sumrtt
protected

Sum of RTT samples.

Referenced by GetRTT(), GetRTTstd(), and updateRTT().

◆ sumrtt2

double uwApplicationModule::sumrtt2
protected

Sum of (RTT^2).

Referenced by GetRTTstd(), and updateRTT().

◆ txsn

int uwApplicationModule::txsn
protected

Transmission sequence number of DATA packet.

Referenced by getPktSent(), incrPktSent(), and transmit().

◆ uidcnt

int uwApplicationModule::uidcnt
protected

Identifier counter that identify uniquely the DATA packet generated.

Referenced by transmit().


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