41#ifndef UWAPPLICATION_MODULE_H
42#define UWAPPLICATION_MODULE_H
49#include <netinet/in.h>
50#include <sys/socket.h>
59#define UWAPPLICATION_DROP_REASON_UNKNOWN_TYPE \
61#define UWAPPLICATION_DROP_REASON_DUPLICATED_PACKET \
63#define UWAPPLICATION_DROP_REASON_OUT_OF_SEQUENCE \
82 virtual void expire(Event *e);
111 virtual int command(
int argc,
const char *
const *argv)
override;
118 virtual void recv(Packet *)
override;
120 virtual double GetFTT()
const;
134 virtual double GetPER()
const;
141 virtual double GetTHR()
const;
148 virtual double GetRTT()
const;
241 unsigned long int timestamp =
242 (
unsigned long int) (std::chrono::duration_cast<
243 std::chrono::milliseconds>(
244 std::chrono::system_clock::now().time_since_epoch())
247 return to_string(timestamp);
262 const std::string &message)
const override
267 "[" +
getEpoch() +
"]::" + module +
"(" +
268 to_string(
node_id) +
")::" + message);
270 PlugIn::printOnLog(
log_level, module, message);
virtual void updateThroughput(int bytes, double dt)
Update the Throughput after the reception of a new packet.
virtual int getPktsInvalidRx() const
return the number of DATA packets received with error by the server
virtual bool withoutSocket()
Check if the communication take place without socket.
int pkts_push_queue
Counter of DATA packets received by server and not yet passed to the below levels of ISO/OSI stack pr...
virtual void stop()
Close the socket connection in the case the communication take place with socket, otherwise stop the ...
virtual void readFromTCP(int clnSock)
Method that reads a TCP byte stream from external application and converts it to a Packet.
int rttsamples
Number of RTT samples.
std::atomic< bool > receiving
virtual int getPktsPushQueue() const
Return the number of DATA packets sorted in the server queue.
double sumftt2
Sum of (FTT^2).
int hrsn
Highest received sequence number.
std::thread socket_thread
Object with the socket rx thread.
virtual void incrPktOoseq()
Increase the number of DATA packets received out of order by the server.
virtual double getTimeBeforeNextPkt()
Compute the DATA generation rate, that can be constant and equal to the period established by the use...
int node_id
Node id to be print in log output.
int pkts_last_reset
Used for error checking after stats are reset.
virtual int getPktLost() const
return the number of DATA packets lost by the server
double sumftt
Sum of FTT samples.
virtual int getPktRecv() const
return the number of DATA packet correctly received by the server
uint32_t esn
Expected serial number.
virtual double getPeriod() const
Return period generation time.
int pkts_ooseq
Counter of the packets received out of order by the server.
int pkts_recv
Counter of the packets correctly received by the server.
virtual void readFromUDP()
Method that waits for UDP packets from external application and converts it to a Packet.
int drop_out_of_order
Ordering of data packet received 1 enabled 0 not enabled.
virtual bool openConnectionUDP()
When socket communication is used, this method establish a connection between client and server.
int servSockDescr
Socket descriptor for server.
double sumrtt
Sum of RTT samples.
int rftt
Forward round trip time.
virtual void incrPktLost(int npkts)
Increase the number of DATA packets lost by the server.
bool socket_tcp
Flag set to true if packets are received from external application.
std::queue< Packet * > queuePckReadUDP
Queue that store the DATA packets recevied from the client by the server using a UDP protocol.
virtual void incrPktSent()
Increase the sequence number and so the number of packets sent by the server.
virtual ~uwApplicationModule()
Destructor of uwApplicationModule class.
virtual double GetRTT() const
Returns the average Round Trip Time.
double sumdt
Sum of the delays.
virtual int getPktSent() const
return the number of packets sent by the server
virtual double GetPER() const
Rerturn the Packet Error Rate calculated.
int fttsamples
Number of FTT samples.
virtual bool useDropOutOfOrder()
If the communication take place without sockets verify if the data packets received by the server is ...
virtual void recv(Packet *) override
Performs the reception of packets from upper and lower layers.
virtual double GetFTT() const
int servPort
Socket server port.
virtual double GetTHR() const
Return the Throughput calculated [bps].
virtual void incrPktsPushQueue()
Increase the number of DATA packets stored in the Server queue.
virtual void updateFTT(double ftt)
Returns the average Forward Trip Time.
virtual void transmit()
Set all the field of the DATA packet that must be send down after the creation to the below level.
virtual int command(int argc, const char *const *argv) override
TCL command interpreter.
int uidcnt
Identifier counter that identify uniquely the DATA packet generated.
double sumbytes
Sum of bytes received.
int sea_trial
Set to 1 to enable epoch time in log output.
std::mutex socket_mutex
Mutex associated with the socket rx thread.
double sumrtt2
Sum of (RTT^2).
virtual bool usePoissonTraffic()
If the communication take place without sockets verify if the data generation period is constant or a...
virtual bool listenTCP()
Method that binds the listening TCP socket.
int pkts_lost
Counter of the packet lost during the transmission.
virtual void acceptTCP()
Method that puts in place a listening TCP socket.
int clnSockDescr
Socket descriptor for client.
int pkts_invalid
Counter of the packets received with errors by the server.
uwSendTimerAppl * chkTimerPeriod
Timer that schedule the period between successive generation of DATA packets.
bool * sn_check
Flag set to true if the external application is connected via a TCP socket, false if UDP.
int payloadsize
Size of each data packet payaload generated.
struct sockaddr_in servAddr
Server address.
virtual void incrPktInvalid()
Increse the number of DATA packets received with error by the server.
virtual double GetRTTstd() const
Return the standard deviation of the Round Trip Time calculated.
uwApplicationModule()
Constructor of uwApplicationModule class.
std::string getEpoch() const
Calculate the epoch of the event.
static uint MAX_READ_LEN
Maximum size (bytes) of a single read of the socket.
int poisson_traffic
Poisson process for generation of data packets 1 enabled 0 not enabled.
virtual int getPktsOOSequence() const
return the number of DATA packets received out of order by the server
int port_num
Destination port number.
struct sockaddr_in clnAddr
Client address.
uint8_t dst_addr
Destination IP address.
double period
Time between successive generation data packets.
virtual void printOnLog(Logger::LogLevel log_level, const std::string &module, const std::string &message) const override
Method to send the log message to the logger.
virtual bool useTCP()
Check if the socket protocol is TCP or UDP.
std::queue< Packet * > queuePckReadTCP
Atomic boolean variable that controls the socket rx looping thread.
int txsn
Transmission sequence number of DATA packet.
virtual void incrPktRecv()
Increase the number of DATA packet correctly received by the server.
virtual double GetFTTstd() const
Return the standard deviation of the Forward Trip Time calculated.
double lrtime
Time of last packet reception.
virtual void updateRTT(double rtt)
Update the RTT after the reception of a new packet.
uwSendTimerAppl is used to handle the scheduling period of uwApplicationModule packets.
virtual void expire(Event *e)
uwSendTimerAppl(uwApplicationModule *m)