DESERT 3.5.1
Loading...
Searching...
No Matches
uwvbr-module.h
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
44#ifndef UWVBR_MODULE_H
45#define UWVBR_MODULE_H
46
47#include <uwip-module.h>
48#include <uwudp-module.h>
49
50#include <module.h>
51#include <iostream>
52#include <string>
53#include <sstream>
54#include <climits>
55
56#define UWVBR_DROP_REASON_UNKNOWN_TYPE \
57 "UKT"
58#define UWVBR_DROP_REASON_OUT_OF_SEQUENCE \
59 "OOS"
60#define UWVBR_DROP_REASON_DUPLICATED_PACKET \
61 "DPK"
63#define HDR_UWVBR(P) (hdr_uwvbr::access(P))
64
65
66
67extern packet_t PT_UWVBR;
68
72typedef struct hdr_uwvbr {
73 u_int16_t sn_;
74 float rftt_;
77 static int offset_;
82 inline static int &
84 {
85 return offset_;
86 }
87
88 inline static struct hdr_uwvbr *
89 access(const Packet *p)
90 {
91 return (struct hdr_uwvbr *) p->access(offset_);
92 }
93
97 inline u_int16_t &
99 {
100 return sn_;
101 }
102
106 inline bool &
108 {
109 return rftt_valid_;
110 }
111
115 inline float &
117 {
118 return (rftt_);
119 }
121
122class UwVbrModule;
123
128class UwVbrSendTimer : public TimerHandler
129{
130public:
132 : TimerHandler()
133 {
134 module = m;
135 }
136
137protected:
138 virtual void expire(Event *e);
139 UwVbrModule *module;
140};
141
146class UwVbrPeriodSwitcher : public TimerHandler
147{
148public:
150 : TimerHandler()
151 {
152 module = m;
153 }
154
155protected:
156 virtual void expire(Event *e);
157 UwVbrModule *module;
158};
159
164class UwVbrModule : public Module
165{
166 friend class UwVbrSendTimer;
168
169public:
173 UwVbrModule();
174
178 virtual ~UwVbrModule();
179
185 virtual void recv(Packet *);
186
193 virtual void recv(Packet *p, Handler *h);
194
205 virtual int command(int argc, const char *const *argv);
206
207 virtual int crLayCommand(ClMessage *m);
208
213 virtual double GetRTT() const;
214
219 virtual double GetFTT() const;
220
225 virtual double GetPER() const;
226
231 virtual double GetTHR() const;
232
237 virtual double GetRTTstd() const;
238
243 virtual double GetFTTstd() const;
244
248 virtual void resetStats();
249
250protected:
251 static int uidcnt_;
252 u_int16_t dstPort_;
253 nsaddr_t dstAddr_;
255 bool *sn_check;
259 int debug_;
263 int txsn;
264 int hrsn;
265 int
269 int
277 double rftt;
278 double srtt;
279 double sftt;
280 double lrtime;
281 double sthr;
285 double period1_;
287 double period2_;
299 /* Cumulative statistics */
300 double sumrtt;
301 double sumrtt2;
304 double sumftt;
305 double sumftt2;
308 double sumbytes;
309 double sumdt;
311 uint32_t esn;
319 virtual void initPkt(Packet *p);
320
326 virtual void sendPkt();
327
333 virtual void transmit();
334
338 virtual void start();
339
343 virtual void stop();
344
350 virtual void updateRTT(const double &);
351
357 virtual void updateFTT(const double &);
358
365 virtual void updateThroughput(const int &, const double &);
366
372 virtual void incrPktLost(const int &);
373
377 virtual void incrPktRecv();
378
382 virtual void incrPktOoseq();
383
387 virtual void incrPktInvalid();
388
396 virtual double getTimeBeforeNextPkt();
397
401 virtual void switchPeriod();
402
408 static inline const int
410 {
411 return sizeof(hdr_uwvbr);
412 }
413};
414
415#endif // UWVBR_MODULE_H
UwVbrModule class is used to manage UWVBR packets, and to collect statistics about them.
int debug_
Flag to enable or disable dirrefent levels of debug.
nsaddr_t dstAddr_
IP of the destination.
double sumftt2
Sum of (FTT^2).
double timer_switch_2_
Period in witch the node tramsmits with a packet every period2_ seconds.
virtual double getTimeBeforeNextPkt()
Returns the amount of time to wait before the next transmission.
double sumbytes
Sum of bytes received.
double rftt
Forward Trip Time seen for last received packet.
int pkts_invalid
Total number of invalid packets received.
double sumdt
Sum of the delays.
int rttsamples
Number of RTT samples.
virtual double GetPER() const
Returns the mean Packet Error Rate.
virtual double GetRTTstd() const
Returns the Round Trip Time Standard Deviation.
int fttsamples
Number of FTT samples.
virtual void start()
Start to send packets.
virtual double GetRTT() const
Returns the mean Round Trip Time.
int PoissonTraffic_
1 if the traffic is generated according to a poissonian distribution.
virtual void initPkt(Packet *p)
Initializes a data packet passed as argument with the default values.
virtual double GetFTTstd() const
Returns the mean Forward Trip Time Standard Deviation.
int pkts_last_reset
for error checking after stats are reset.
double srtt
Smoothed Round Trip Time, calculated as for TCP.
virtual int crLayCommand(ClMessage *m)
bool * sn_check
Used to keep track of the packets already received.
double sumrtt2
Sum of (RTT^2).
virtual double GetTHR() const
Returns the mean Throughput.
int drop_out_of_order_
Flag to enable or disable the check for out of order packets.
UwVbrPeriodSwitcher period_switcher_
Timer which schedules the switch between different sending periods.
double period2_
period between two consecutive packet transmissions (mode 2).
u_int16_t dstPort_
Destination port.
uint32_t esn
Expected serial number.
static int uidcnt_
Unique id of the packet generated.
static const int getVbrHeaderSize()
Returns the size in byte of a hdr_uwvbr packet header.
int pktSize_
Packet size.
virtual void updateThroughput(const int &, const double &)
Updates the Throughput.
double sumftt
Sum of FTT samples.
int pkts_ooseq
Total number of packets received out of sequence.
virtual void stop()
Stop to send packets.
UwVbrSendTimer sendTmr_
Timer which schedules packet transmissions.
double timer_switch_1_
Period in witch the node tramsmits with a packet every period1_ seconds.
virtual void incrPktLost(const int &)
Increases the number of packets lost.
virtual void updateRTT(const double &)
Updates the Round Trip Time.
double sumrtt
Sum of RTT samples.
UwVbrModule()
Constructor of UwVbrModule class.
virtual void incrPktInvalid()
Increases by one the number of invalid packets.
virtual void incrPktOoseq()
Increases by one the number of out of sequence packets received.
int pkts_recv
Total number of received packets.
int period_identifier_
Flag used to identify in which one of the period the vbr module is.
int txsn
Sequence number of next new packet to be transmitted.
virtual void updateFTT(const double &)
Updates the Forward Trip Time.
double period1_
period between two consecutive packet transmissions (mode 1).
virtual void sendPkt()
Allocates, initialize and sends a packet.
virtual void incrPktRecv()
Increases by one the number of received packets.
virtual double GetFTT() const
Returns the mean Forward Trip Time.
double sftt
Smoothed Forward Trip Time, calculated as srtt.
double sthr
Smoothed throughput calculation.
int pkts_lost
Total number of lost packets, including packets received out of sequence.
int hrsn
Highest received sequence number.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
virtual void resetStats()
Resets all the statistics of the UWVBR module.
virtual void transmit()
Creates and transmits a packet and schedules a new transmission.
virtual ~UwVbrModule()
Destructor of UwVbrModule class.
double lrtime
Time of last packet reception.
virtual void switchPeriod()
Switches between the two different states in which UWVBR can operate.
UwVbrPeriodSwitcher class is used to handle the switch between different period used by a UwVbrModule...
UwVbrPeriodSwitcher(UwVbrModule *m)
virtual void expire(Event *e)
UwVbrSendTimer class is used to handle the scheduling period of UWVBR packets.
virtual void expire(Event *e)
UwVbrSendTimer(UwVbrModule *m)
hdr_uwvbr describes UWVBR packets.
static struct hdr_uwvbr * access(const Packet *p)
float & rftt()
Reference to the rftt_ variable.
bool & rftt_valid()
Reference to the rftt_valid_ variable.
float rftt_
Forward Trip Time of the packet.
u_int16_t & sn()
Reference to the sn_ variable.
static int offset_
Required by the PacketHeaderManager.
u_int16_t sn_
Serial number of the packet.
bool rftt_valid_
Flag used to set the validity of the fft field.
static int & offset()
Reference to the offset_ variable.
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.