DESERT 3.5.1
Loading...
Searching...
No Matches
uwApplication_module.cpp
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
39#include <rng.h>
40#include <sstream>
41#include <time.h>
44
46
47static class uwApplicationModuleClass : public TclClass
48{
49public:
54 : TclClass("Module/UW/APPLICATION")
55 {
56 }
57
63 TclObject *
64 create(int, const char *const *)
65 {
66 return (new uwApplicationModule());
67 }
69
71 : servSockDescr(0)
72 , clnSockDescr(0)
73 , servAddr()
74 , clnAddr()
75 , servPort(0)
76 , queuePckReadTCP()
77 , queuePckReadUDP()
78 , out_log()
79 , logging(false)
80 , node_id(0)
81 , exp_id(0)
82 , debug_(0)
83 , PERIOD(5)
84 , poisson_traffic(0)
85 , payloadsize(16)
86 , port_num(55550)
87 , drop_out_of_order(0)
88 , dst_addr(0)
89 , chkTimerPeriod(this)
90 , socket_active(false)
91 , socket_protocol("")
92 , tcp_udp(-1)
93 , sn_check()
94 , uidcnt(0)
95 , txsn(1)
96 , rftt(0)
97 , pkts_lost(0)
98 , pkts_recv(0)
99 , pkts_ooseq(0)
100 , pkts_invalid(0)
101 , pkts_last_reset(0)
102 , lrtime(0)
103 , sumrtt(0)
104 , sumrtt2(0)
105 , rttsamples(0)
106 , sumftt(0)
107 , sumftt2(0)
108 , fttsamples(0)
109 , esn(0)
110 , sumbytes(0)
111 , sumdt(0)
112 , hrsn(0)
113{
114 bind("debug_", (int *) &debug_);
115 bind("period_", (double *) &PERIOD);
116 bind("node_ID_", (int *) &node_id);
117 bind("EXP_ID_", (int *) &exp_id);
118 bind("PoissonTraffic_", (int *) &poisson_traffic);
119 bind("Payload_size_", (int *) &payloadsize);
120 bind("destAddr_", (int *) &dst_addr);
121 bind("destPort_", (int *) &port_num);
122 bind("Socket_Port_", (int *) &servPort);
123 bind("drop_out_of_order_", (int *) &drop_out_of_order);
124 bind("max_read_length", (uint *) &uwApplicationModule::MAX_READ_LEN);
125
126 sn_check = new bool[USHRT_MAX];
127 for (int i = 0; i < USHRT_MAX; i++) {
128 sn_check[i] = false;
129 }
131} // end uwApplicationModule() Method
132
136
137int
138uwApplicationModule::command(int argc, const char *const *argv)
139{
140 Tcl &tcl = Tcl::instance();
141
142 if (argc == 2) {
143 if (strcasecmp(argv[1], "start") == 0) {
144 if (withoutSocket()) {
145 // Generate DATA packets without the use of sockets
147 } else {
148 // The communication take place with the use of sockets
149 if (useTCP()) {
150 // Generate DATA packets using TCP connection
152 } else {
153 // Generate DATA packets using UDP connection
155 }
156 }
157 return TCL_OK;
158 } else if (strcasecmp(argv[1], "stop") == 0) {
159 stop();
160 return TCL_OK;
161 } else if (strcasecmp(argv[1], "getsentpkts") == 0) {
162 tcl.resultf("%d", getPktSent());
163 return TCL_OK;
164 } else if (strcasecmp(argv[1], "lostpkts") == 0) {
165 tcl.resultf("%f", getPktLost());
166 return TCL_OK;
167 } else if (strcasecmp(argv[1], "getrecvpkts") == 0) {
168 tcl.resultf("%d", getPktRecv());
169 return TCL_OK;
170 } else if (strcasecmp(argv[1], "outofsequencepkts") == 0) {
171 tcl.resultf("%f", getPktsOOSequence());
172 return TCL_OK;
173 } else if (strcasecmp(argv[1], "notknownpktrx") == 0) {
174 tcl.resultf("%f", getPktsInvalidRx());
175 return TCL_OK;
176 } else if (strcasecmp(argv[1], "getrecvpktsqueue") == 0) {
177 tcl.resultf("%d", getPktsPushQueue());
178 return TCL_OK;
179 } else if (strcasecmp(argv[1], "getrtt") == 0) {
180 tcl.resultf("%f", GetRTT());
181 return TCL_OK;
182 } else if (strcasecmp(argv[1], "getrttstd") == 0) {
183 tcl.resultf("%f", GetRTTstd());
184 return TCL_OK;
185 } else if (strcasecmp(argv[1], "getftt") == 0) {
186 tcl.resultf("%f", GetFTT());
187 return TCL_OK;
188 } else if (strcasecmp(argv[1], "getfttstd") == 0) {
189 tcl.resultf("%f", GetFTTstd());
190 return TCL_OK;
191 } else if (strcasecmp(argv[1], "getper") == 0) {
192 tcl.resultf("%f", GetPER());
193 return TCL_OK;
194 } else if (strcasecmp(argv[1], "getthr") == 0) {
195 tcl.resultf("%f", GetTHR());
196 return TCL_OK;
197 } else if (strcasecmp(argv[1], "print_log") == 0) {
198 std::stringstream stat_file;
199 stat_file << "UWAPPLICATION_LOG_NODE_ID_" << node_id << "_EXP_ID_"
200 << exp_id << ".out";
201 out_log.open(stat_file.str().c_str(), std::ios_base::app);
202 out_log << left << "[" << getEpoch() << "]::" << NOW
203 << "::UWAPPLICATION::FILE_CREATED" << endl;
204 logging = true;
205 return TCL_OK;
206 }
207 } else if (argc == 3) {
208 if (strcasecmp(argv[1], "SetSocketProtocol") == 0) {
209 string protocol = argv[2];
210 if (strcasecmp(protocol.c_str(), "UDP") == 0) {
211 socket_active = true;
212 tcp_udp = 0;
213 } else if (strcasecmp(protocol.c_str(), "TCP") == 0) {
214 socket_active = true;
215 tcp_udp = 1;
216 } else {
217 socket_active = false;
218 tcp_udp = -1;
219 }
220 return TCL_OK;
221 }
222 }
223 return Module::command(argc, argv);
224} // end command() Method
225
226int
228{
229 switch (m->type()) {
230 default:
231 return Module::crLayCommand(m);
232 }
233} // end crLayCommand() Method
234
235void
237{
238 if (withoutSocket()) {
239 if (debug_ >= 1)
240 std::cout << "[" << getEpoch() << "]::" << NOW
241 << "::UWAPPLICATION::RECV_PACKET_WITHOUT_SOCKET_MODE"
242 << endl;
243 if (logging)
244 out_log << left << "[" << getEpoch() << "]::" << NOW
245 << "::UWAPPLICATION::RECV_PACKET_WITHOUT_SOCKET_MODE"
246 << endl;
247 statistics(p);
248 } else {
249 // Communication take place with sockets
250 if (useTCP()) {
251 if (debug_ >= 1)
252 std::cout << "[" << getEpoch() << "]::" << NOW
253 << "::UWAPPLICATION::RECV_PACKET_USING_TCP" << endl;
254 if (logging)
255 out_log << left << "[" << getEpoch() << "]::" << NOW
256 << "::UWAPPLICATION::RECV_PACKET_USING_TCP" << endl;
257 statistics(p);
258 } else {
259 if (debug_ >= 1)
260 std::cout << "[" << getEpoch() << "]::" << NOW
261 << "::UWAPPLICATION::RECV_PACKET_USING_UDP" << endl;
262 if (logging)
263 out_log << left << "[" << getEpoch() << "]::" << NOW
264 << "::UWAPPLICATION::RECV_PACKET_USING_UDP" << endl;
265 statistics(p);
266 }
267 }
268}; // end recv() Method
269
270void
272{
273 hdr_cmn *ch = hdr_cmn::access(p);
275
276 if (ch->ptype_ != PT_DATA_APPLICATION) {
277 if (debug_ >= 0)
278 std::cout << "[" << getEpoch() << "]::" << NOW
279 << "::UWAPPLICATION::DROP_PACKET_NOT_APPLICATION_TYPE"
280 << endl;
281 if (logging)
282 out_log << left << "[" << getEpoch() << "]::" << NOW
283 << "::UWAPPLICATION::DROP_PACKET_NOT_APPLICATION_TYPE"
284 << endl;
286 incrPktInvalid(); // Increment the number of packet received invalid
287 return;
288 }
289 esn = hrsn + 1; // Increase the expected sequence number
290
291 // Verify if the data packet is already processed.
292 if (useDropOutOfOrder()) {
293 if (sn_check[uwApph->sn_ &
294 0x00ffffff]) { // Packet already processed: drop it
295 if (debug_ >= 0)
296 std::cout << "[" << getEpoch() << "]::" << NOW
297 << "::UWAPPLICATION::DROP_PACKET_PACKET_ALREADY_"
298 "PROCESSED_ID_"
299 << (int) uwApph->sn_ << endl;
300 if (logging)
301 out_log << left << "[" << getEpoch() << "]::" << NOW
302 << "::UWAPPLICATION::DROP_PACKET_PACKET_ALREADY_"
303 "PROCESSED_ID_"
304 << (int) uwApph->sn_ << endl;
307 return;
308 }
309 }
310 // The data packet with this particular SN is not already processed
311 // Set true sn_check. In this way we assume that these sn are already
312 // processed by the node
313 sn_check[uwApph->sn_ & 0x00ffffff] = true;
314
315 // The data packet received is out of order
316 if (useDropOutOfOrder()) {
317 if (uwApph->sn_ <
318 esn) { // packet is out of sequence and is to be discarded
319 incrPktOoseq(); // Increase the number of data packets receive out
320 // of
321 // sequence.
322 if (debug_ >= 0)
323 std::cout << "[" << getEpoch() << "]::" << NOW
324 << "::UWAPPLICATION::DROP_PACKET_PACKET_OOS_ID_"
325 << (int) uwApph->sn_ << "_LAST_SN_" << hrsn << endl;
326 if (logging)
327 out_log << left << "[" << getEpoch() << "]::" << NOW
328 << "::UWAPPLICATION::DROP_PACKET_PACKET_OOS_ID_"
329 << (int) uwApph->sn_ << "_LAST_SN_" << hrsn << endl;
331 return;
332 }
333 }
334
335 // Compute the Forward Trip time
336 rftt = Scheduler::instance().clock() - ch->timestamp();
337 if ((uwApph->rftt_valid_) / 10000) {
338 double rtt = rftt + uwApph->rftt();
339 updateRTT(rtt);
340 }
341
342 updateFTT(rftt); // Update the forward trip time
343
344 hrsn = uwApph->sn_; // Update the highest sequence number received
345
346 // Verify if a packet is lost
347 if (useDropOutOfOrder()) {
348 if (uwApph->sn_ > esn) {
349 if (debug_ >= 0)
350 std::cout << "[" << getEpoch() << "]::" << NOW
351 << "::UWAPPLICATION::PACKET_LOST_ID_RECEIVED"
352 << (int) uwApph->sn_ << "_ID_EXPECTED_" << esn
353 << endl;
354 if (logging)
355 out_log << left << "[" << getEpoch() << "]::" << NOW
356 << "::UWAPPLICATION::PACKET_LOST_ID_RECEIVED"
357 << (int) uwApph->sn_ << "_ID_EXPECTED_" << esn << endl;
358 incrPktLost(uwApph->sn_ - (esn));
359 }
360 }
361
362 double dt = Scheduler::instance().clock() - lrtime;
363 // updateThroughput(ch->size(), dt); //Update Throughput
364 updateThroughput(uwApph->payload_size(), dt);
365 incrPktRecv(); // Increase the number of data packets received
366
367 lrtime = Scheduler::instance().clock(); // Update the time in which the last
368 // packet is received.
369 if (debug_ >= 0 && socket_active) {
370 std::cout << "[" << getEpoch() << "]::" << NOW
371 << "::UWAPPLICATION::PAYLOAD_RECEIVED--> ";
372 for (int i = 0; i < uwApph->payload_size(); i++) {
373 cout << uwApph->payload_msg[i];
374 }
375 }
376 if (debug_ >= 0)
377 std::cout << "[" << getEpoch() << "]::" << NOW
378 << "::UWAPPLICATION::SN_RECEIVED_" << (int) uwApph->sn_
379 << endl;
380 if (debug_ >= 0)
381 std::cout << "[" << getEpoch() << "]::" << NOW
382 << "::UWAPPLICATION::PAYLOAD_SIZE_RECEIVED_"
383 << (int) uwApph->payload_size() << endl;
384 if (debug_ >= 1 && !withoutSocket())
385 std::cout << "[" << getEpoch() << "]::" << NOW
386 << "::UWAPPLICATION::PAYLOAD_RECEIVED_" << uwApph->payload_msg
387 << endl;
388
389 if (logging)
390 out_log << left << "[" << getEpoch() << "]::" << NOW
391 << "::UWAPPLICATION::PAYLOAD_SIZE_RECEIVED_"
392 << (int) uwApph->payload_size() << endl;
393 if (logging)
394 out_log << left << "[" << getEpoch() << "]::" << NOW
395 << "::UWAPPLICATION::SN_RECEIVED_" << (int) uwApph->sn_ << endl;
396
397 if (logging && !withoutSocket()) {
398 out_log << left << "::" << NOW
399 << "::UWAPPLICATION::PAYLOAD_RECEIVED--> ";
400 for (int i = 0; i < uwApph->payload_size(); i++) {
401 out_log << uwApph->payload_msg[i];
402 }
403 out_log << std::endl;
404 }
405 if (clnSockDescr) {
406 write(clnSockDescr, uwApph->payload_msg, (size_t)uwApph->payload_size());
407 }
408 Packet::free(p);
409} // end statistics method
410
411void
413{
414 if (debug_ >= 1)
415 std::cout << "[" << getEpoch() << "]::" << NOW
416 << "::UWAPPLICATION::START_GENERATION_DATA" << endl;
417 if (logging)
418 out_log << "[" << getEpoch() << "]::" << NOW
419 << "::UWAPPLICATION::START_GENERATION_DATA" << endl;
421} // end start_generation() method
422
423void
425{
426 Packet *p = Packet::alloc();
427
428 double delay = 0;
429
430 hdr_cmn *ch = hdr_cmn::access(p);
431 hdr_uwudp *uwudp = hdr_uwudp::access(p);
432 hdr_uwip *uwiph = hdr_uwip::access(p);
434
435 // Common header fields
436 ch->uid() = uidcnt++; // Increase the id of data packet
437 ch->ptype_ = PT_DATA_APPLICATION; // Assign the type of packet that is being
438 // created
439 ch->size() = payloadsize; // Assign the size of data payload
440 uwApph->payload_size() = payloadsize;
441 ch->direction() = hdr_cmn::DOWN; // The packet must be forward at the level
442 // above of him
443
444 // Transport header fields
445 uwudp->dport() = port_num; // Set the destination port
446
447 // IP header fields
448 uwiph->daddr() = dst_addr; // Set the IP destination address
449
450 // Application header fields
451 incrPktSent();
452 uwApph->sn_ = txsn; // Sequence number to the data packet
453
454 if (rftt >= 0) {
455 uwApph->rftt_ = (int) (rftt * 10000); // Forward Trip Time
456 uwApph->rftt_valid_ = true;
457 } else {
458 uwApph->rftt_valid_ = false;
459 }
460 uwApph->priority_ = 0; // Priority of the message
461
462 // Create the payload message
464 for (int i = 0; i < getpayloadsize(); i++) {
465 (*uwApph).payload_msg[i] = RNG::defaultrng()->uniform(26) + 'a';
466 }
467 for (int i = getpayloadsize(); i < MAX_LENGTH_PAYLOAD; i++) {
468 (*uwApph).payload_msg[i] = '0';
469 }
470 } else {
471 for (int i = 0; i < MAX_LENGTH_PAYLOAD; i++) {
472 (*uwApph).payload_msg[i] = RNG::defaultrng()->uniform(26) + 'a';
473 }
474 }
475
476 // Show the DATA payload generated
477 ch->timestamp() = Scheduler::instance().clock();
478
479 // Show some DATA packet information
480 if (debug_ >= 2)
481 std::cout << "[" << getEpoch() << "]::" << NOW
482 << "::UWAPPLICATION::INIT_PACKET::UID_" << ch->uid_ << endl;
483 if (debug_ >= 0)
484 std::cout << "[" << getEpoch() << "]::" << NOW
485 << "::UWAPPLICATION::INIT_PACKET::DEST_"
486 << (int) uwiph->daddr() << endl;
487 if (debug_ >= 0)
488 std::cout << "[" << getEpoch() << "]::" << NOW
489 << "::UWAPPLICATION::INIT_PACKET::SIZE_"
490 << (int) uwApph->payload_size() << endl;
491 if (debug_ >= 0)
492 std::cout << "[" << getEpoch() << "]::" << NOW
493 << "::UWAPPLICATION::INIT_PACKET::SN_" << (int) uwApph->sn_
494 << endl;
495 if (debug_ >= 0)
496 std::cout << "[" << getEpoch() << "]::" << NOW
497 << "::UWAPPLICATION::INIT_PACKET::SEND_DOWN_PACKET" << endl;
498
499 if (logging)
500 out_log << left << "[" << getEpoch() << "]::" << NOW
501 << "::UWAPPLICATION::INIT_PACKET::UID_" << ch->uid_ << endl;
502 if (logging)
503 out_log << left << "[" << getEpoch() << "]::" << NOW
504 << "::UWAPPLICATION::INIT_PACKET::DEST_" << (int) uwiph->daddr()
505 << endl;
506 if (logging)
507 out_log << left << "[" << getEpoch() << "]::" << NOW
508 << "::UWAPPLICATION::INIT_PACKET::SIZE_"
509 << (int) uwApph->payload_size() << endl;
510 if (logging)
511 out_log << left << "[" << getEpoch() << "]::" << NOW
512 << "::UWAPPLICATION::INIT_PACKET::SN_" << (int) uwApph->sn_
513 << endl;
514 if (logging)
515 out_log << left << "[" << getEpoch() << "]::" << NOW
516 << "::UWAPPLICATION::INIT_PACKET::SEND_DOWN_PACKET" << endl;
517 sendDown(p, delay);
518 chkTimerPeriod.resched(
519 getTimeBeforeNextPkt()); // schedule next transmission
520} // end init_Packet() method
521
522void
524{
525 if (withoutSocket()) {
526 chkTimerPeriod.force_cancel();
527 } else {
528 // Close the connection
529 if (useTCP()) {
530 chkTimerPeriod.force_cancel();
531 close(servSockDescr);
532 }
533 }
534} // end stop() method
535
536double
538{
539 if (getPeriod() < 0) {
540 if (debug_ >= 0)
541 std::cout << "[" << getEpoch() << "]::" << NOW
542 << "::UWAPPLICATION::ERROR_TIMER SET TO NEGATIVE VALUE"
543 << endl;
544 exit(1);
545 }
546 if (usePoissonTraffic()) {
547 // Data packets are generated with a Poisson process
548 double u = RNG::defaultrng()->uniform_double();
549 double lambda = 1.0 / PERIOD;
550 if (debug_ >= 2)
551 std::cout
552 << "[" << getEpoch() << "]::" << NOW
553 << "::UWAPPLICATION::PACKET_GENERATED_WITH_POISSON_PERIOD_"
554 << PERIOD << endl;
555 if (logging)
556 out_log << left << "[" << getEpoch() << "]::" << NOW
557 << "::UWAPPLICATION::PACKET_GENERATED_WITH_POISSON_PERIOD_"
558 << PERIOD << endl;
559 return (-log(u) / lambda);
560 } else {
561 // Data packets are generated wit a costant bit rate
562 if (debug_ >= 2)
563 std::cout << "[" << getEpoch() << "]::" << NOW
564 << "::UWAPPLICATION::PACKET_GENERATED_WITH_FIXED_PERIOD_"
565 << PERIOD << endl;
566 if (logging)
567 out_log << left << "[" << getEpoch() << "]::" << NOW
568 << "::UWAPPLICATION::PACKET_GENERATED_WITH_FIXED_PERIOD_"
569 << PERIOD << endl;
570 return PERIOD;
571 }
572} // end getTimeBeforeNextPkt() Method
573
574double
576{
577 return (rttsamples > 0) ? sumrtt / rttsamples : 0;
578} // end GetRTT() method
579
580double
582{
583 if (rttsamples > 1) {
584 double var =
585 (sumrtt2 - (sumrtt * sumrtt / rttsamples)) / (rttsamples - 1);
586 return (sqrt(var));
587 } else
588 return 0;
589} // end GetRTTstd() method
590
591void
593{
594 sumrtt += rtt;
595 sumrtt2 += rtt * rtt;
596 rttsamples++;
597} // end updateRTT() method
598
599double
601{
602 return (fttsamples > 0) ? sumftt / fttsamples : 0;
603} // end getFTT() method
604
605double
607{
608 if (fttsamples > 1) {
609 double var = 0;
610 var = (sumftt2 - (sumftt * sumftt / fttsamples)) / (fttsamples - 1);
611 if (var > 0)
612 return (sqrt(var));
613 else
614 return 0;
615 } else {
616 return 0;
617 }
618} // end getFTT() method
619
620double
622{
623 if (drop_out_of_order) {
624 if ((pkts_recv + pkts_lost) > 0) {
625 return ((double) pkts_lost / (double) (pkts_recv + pkts_lost));
626 } else {
627 return 0;
628 }
629 } else {
630 if (esn > 1)
631 return (1 - (double) pkts_recv / (double) (esn - 1));
632 else
633 return 0;
634 }
635} // end getPER() method
636
637double
639{
640 return ((sumdt != 0) ? sumbytes * 8 / sumdt : 0);
641} // end GetTHR() method
642
643void
645{
646 sumftt += ftt;
647 sumftt2 += ftt * ftt;
648 fttsamples++;
649} // end updateFTT() method
650
651void
652uwApplicationModule::updateThroughput(const int &bytes, const double &dt)
653{
654 sumbytes += bytes;
655 sumdt += dt;
656} // end updateThroughput() method
657
658void
660{
661 if (m_->withoutSocket()) {
662 // Using a random sequence for data payload
663 m_->init_Packet();
664 } else {
665 // Communication take placing with sockets
666 if (m_->useTCP()) {
667 // The protocol that the system is using is TCP
669 m_->chkTimerPeriod.resched(m_->PERIOD);
670 } else {
671 // The protocol that the system is using is UDP
673 m_->chkTimerPeriod.resched(m_->PERIOD);
674 }
675 }
676} // end expire();
TclObject * create(int, const char *const *)
Creates the TCL object needed for the TCL language interpretation.
uwApplicationModuleClass()
Constructor of uwApplicationModuleClass class.
virtual bool withoutSocket()
Verify if the communication take place with socket or the data payload is generated in a randomly way...
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.
double sumftt2
Sum of (FTT^2).
int hrsn
Highest received sequence number.
virtual void incrPktOoseq()
Increase the number of DATA packets received out of order by the server.
virtual void init_Packet()
Set all the field of the DATA packet that must be send down after the creation to the below level.
virtual void updateRTT(const double &rtt)
Update the RTT after the reception of a new packet.
virtual double getTimeBeforeNextPkt()
Compute the DATA generation rate, that can be constant and equal to the PERIOD established by the use...
virtual void recv(Packet *)
Handle the transmission of DATA packets between CBR layer and the below level.
double sumftt
Sum of FTT samples.
uwSendTimerAppl chkTimerPeriod
Timer that schedule the period between two successive generation of DATA packets.
uint32_t esn
Expected serial number.
int pkts_recv
Counter of the packets correctly received by the server.
int drop_out_of_order
Enable or not the ordering of data packet received 1 enabled 0 not enabled.
int servSockDescr
socket descriptor for server
double sumrtt
Sum of RTT samples.
virtual void start_generation()
Start the process to generate DATA packets without sockets.
int rftt
Forward trip time.
int debug_
Used for debug purposes 1 debug activated 0 debug not activated.
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 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 int getPktsOOSequence()
return the number of DATA packets received out of order by the server
virtual int openConnectionUDP()
When socket communication is used, this method establish a connection between client and server.
virtual int getPktRecv()
return the number of DATA packet correctly received by the server
virtual void updateFTT(const double &ftt)
Update the FTT after the reception of a new packet.
virtual void init_Packet_UDP()
Set all the field of DATA packet and take from the specific queue the payload of DATA packet that wil...
virtual double GetFTT() const
Returns the average Forward Trip Time.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
double PERIOD
Interval time between two successive generation data packets.
virtual double GetTHR() const
Return the Throughput calculated [bps].
int uidcnt
Identifier counter that identify uniquely the DATA packet generated.
double sumbytes
Sum of bytes received.
virtual int openConnectionTCP()
When socket communication is used, this method establish a connection between client and server.
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 i...
int pkts_lost
Counter of the packet lost during the transmission.
virtual int getPktSent()
return the number of packets sent by the server
int clnSockDescr
*socket descriptor for client
unsigned long int getEpoch()
Calculate the epoch of the event.
bool * sn_check
Used to keep track of the packets already received.
int payloadsize
Size of each data packet payaload generated.
virtual int getPktsPushQueue()
return the number of DATA packets sotred in the server queue
virtual int getPktLost()
return the number of DATA packets lost by the server
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.
virtual int getpayloadsize()
return the size of DATA packet payload
virtual void incrPktLost(const int &npkts)
Increase the number of DATA packets lost by the server.
std::ofstream out_log
Variable that handle the file in which the protocol write the statistics.
virtual void statistics(Packet *p)
Comupte some statistics as the number of packets sent and receive between two layer,...
static uint MAX_READ_LEN
Maximum size (bytes) of a single read of the socket.
int poisson_traffic
Enable or not the Poisson process for generation of data packets 1 enabled 0 not enabled.
int port_num
Number of the port in which the server provide the service.
uint8_t dst_addr
IP destination address.
virtual double getPeriod()
return period generation time
virtual bool useTCP()
If the communication take place using sockets verify if the protocol used is TCP or UDP.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
virtual void init_Packet_TCP()
Set all the field of DATA packet and take from the specific queue the payload of DATA packet that wil...
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.
virtual void updateThroughput(const int &bytes, const double &dt)
Update the Throughput after the reception of a new packet.
double lrtime
Time of last packet reception.
virtual int getPktsInvalidRx()
return the number of DATA packets received with error by the server
Content header of TRIGGER packet.
int rftt_
Forward Trip Time of the packet.
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.
uint8_t priority_
Priority flag: 1 means high priority, 0 normal priority.
hdr_uwip describes UWIP packets.
Definition uwip-module.h:70
uint8_t & daddr()
Reference to the daddr_ variable.
static hdr_uwip * access(const Packet *p)
Definition uwip-module.h:86
hdr_uwudp describes UWUDP packets.
static struct hdr_uwudp * access(const Packet *p)
uint8_t & dport()
Reference to the dport_ variable.
Provides the headers of the data packet.
#define MAX_LENGTH_PAYLOAD
#define HDR_DATA_APPLICATION(p)
alias defined to access the TRIGGER HEADER
uwApplicationModuleClass class_module_uwapplicationmodule
packet_t PT_DATA_APPLICATION
Trigger packet type for UFetch protocol.
#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.