57 : TclClass(
"Module/UW/APPLICATION")
74 : socket_active(false)
81 , drop_out_of_order(0)
114 bind(
"period_", (
double *) &
period);
115 bind(
"Socket_Port_", (
int *) &
servPort);
119 bind(
"node_ID_", (
int *) &
node_id);
122 bind(
"destAddr_", (
int *) &
dst_addr);
123 bind(
"destPort_", (
int *) &
port_num);
126 std::cout <<
"UWAPPLICATION::uwApplicationModule()::Period < 0, "
134 for (
int i = 0; i < USHRT_MAX; i++) {
147 Tcl &tcl = Tcl::instance();
150 if (strcasecmp(argv[1],
"start") == 0) {
172 }
else if (strcasecmp(argv[1],
"stop") == 0) {
176 }
else if (strcasecmp(argv[1],
"getsentpkts") == 0) {
180 }
else if (strcasecmp(argv[1],
"lostpkts") == 0) {
184 }
else if (strcasecmp(argv[1],
"getrecvpkts") == 0) {
188 }
else if (strcasecmp(argv[1],
"outofsequencepkts") == 0) {
192 }
else if (strcasecmp(argv[1],
"notknownpktrx") == 0) {
196 }
else if (strcasecmp(argv[1],
"getrecvpktsqueue") == 0) {
200 }
else if (strcasecmp(argv[1],
"getrtt") == 0) {
201 tcl.resultf(
"%f",
GetRTT());
203 }
else if (strcasecmp(argv[1],
"getrttstd") == 0) {
207 }
else if (strcasecmp(argv[1],
"getftt") == 0) {
208 tcl.resultf(
"%f",
GetFTT());
211 }
else if (strcasecmp(argv[1],
"getfttstd") == 0) {
215 }
else if (strcasecmp(argv[1],
"getper") == 0) {
216 tcl.resultf(
"%f",
GetPER());
219 }
else if (strcasecmp(argv[1],
"getthr") == 0) {
220 tcl.resultf(
"%f",
GetTHR());
224 }
else if (argc == 3) {
225 if (strcasecmp(argv[1],
"SetSocketProtocol") == 0) {
226 std::string protocol = argv[2];
228 if (protocol ==
"TCP") {
230 }
else if (protocol ==
"UDP") {
233 tcl.result(
"Invalid socket protocol.");
242 return Module::command(argc, argv);
248 hdr_cmn *ch = hdr_cmn::access(p);
254 "recv(Packet *)::Drop packet, wrong type");
269 "recv(Packet *)::Drop packet with sn " +
270 to_string((
int) uwApph->
sn_) +
271 ", already processed");
292 "recv(Packet *)::Drop packet with sn " +
293 to_string((
int) uwApph->
sn_) +
", out of sequence");
301 rftt = NOW - ch->timestamp();
315 "recv(Packet *)::Packet lost. Received has sn " +
316 to_string((
int) uwApph->
sn_) +
317 ", expected has sn " + to_string(
esn));
331 "recv(Packet *)::Payload received : " +
336 "recv(Packet *)::Payload size : " +
340 "recv(Packet *)::Sequence number : " +
341 to_string((
int) uwApph->
sn()));
378 hdr_cmn *ch = HDR_CMN(p);
385 ch->direction() = hdr_cmn::DOWN;
386 ch->timestamp() = NOW;
397 (*uwApph).payload_msg[i] = RNG::defaultrng()->uniform(26) +
'a';
400 (*uwApph).payload_msg[i] =
'0';
404 (*uwApph).payload_msg[i] = RNG::defaultrng()->uniform(26) +
'a';
411 uwApph->
rftt() = (int) (
rftt * 10000);
420 "transmit()::Unique id : " + to_string(ch->uid()));
423 "transmit()::Dest addr : " + to_string((
int) uwiph->
daddr()));
426 "transmit()::Payload size : " +
430 "transmit()::Sequence number : " + to_string((
int) uwApph->
sn()));
433 "transmit()::Send down packet");
469 double u = RNG::defaultrng()->uniform_double();
470 double lambda = 1.0 /
period;
472 return (-log(u) / lambda);
517 return (var > 0) ? sqrt(var) : 0;
packet_t PT_DATA_APPLICATION
DATA packet type.
TclObject * create(int, const char *const *)
Creates the TCL object needed for the TCL language interpretation.
uwApplicationModuleClass()
Constructor of uwApplicationModuleClass class.
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.
virtual void stop()
Close the socket connection in the case the communication take place with socket, otherwise stop the ...
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.
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.
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 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.
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.
friend class uwSendTimerAppl
int clnSockDescr
Socket descriptor for client.
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.
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.
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.
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.
virtual void expire(Event *e)
Content header of DATA packet.
uint8_t & priority()
Reference to the priority variable.
char payload_msg[MAX_LENGTH_PAYLOAD]
Message payload.
int & rftt()
Reference to the rftt_ variable.
uint16_t sn_
Serial number of the packet.
bool rftt_valid_
Flag used to set the validity of the fft field.
bool & rftt_valid()
Reference to the rftt_valid_ variable.
uint16_t & payload_size()
uint16_t & sn()
Reference to the sn_ variable.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
hdr_uwudp describes UWUDP packets.
uint8_t & dport()
Reference to the dport_ variable.
uwApplicationModuleClass class_module_uwapplicationmodule
#define UWAPPLICATION_DROP_REASON_OUT_OF_SEQUENCE
Drop the packet.
#define UWAPPLICATION_DROP_REASON_UNKNOWN_TYPE
Drop the packet.
#define UWAPPLICATION_DROP_REASON_DUPLICATED_PACKET
Drop the packet.
Provides the UWIP packets header description. Definition of the class that define the network layer.
Provides the UWUDP packets header description and the definition of the class UWUDP.