57 : PacketHeaderClass(
"PacketHeader/UWVBR", sizeof(
hdr_uwvbr))
71 : TclClass(
"Module/UW/VBR")
91 module->switchPeriod();
113 , drop_out_of_order_(0)
114 , period_identifier_(1)
115 , timer_switch_1_(1000)
116 , timer_switch_2_(500)
118 , period_switcher_(this)
134 bind(
"destPort_", (
int *) &
dstPort_);
135 bind(
"destAddr_", (
int *) &
dstAddr_);
141 for (
int i = 0; i < USHRT_MAX; i++) {
155 Tcl &tcl = Tcl::instance();
157 if (strcasecmp(argv[1],
"start") == 0) {
162 }
else if (strcasecmp(argv[1],
"stop") ==
166 }
else if (strcasecmp(argv[1],
"getrtt") == 0) {
167 tcl.resultf(
"%f",
GetRTT());
169 }
else if (strcasecmp(argv[1],
"getftt") == 0) {
170 tcl.resultf(
"%f",
GetFTT());
172 }
else if (strcasecmp(argv[1],
"getper") == 0) {
173 tcl.resultf(
"%f",
GetPER());
175 }
else if (strcasecmp(argv[1],
"getthr") == 0) {
176 tcl.resultf(
"%f",
GetTHR());
178 }
else if (strcasecmp(argv[1],
"getvbrheadersize") == 0) {
181 }
else if (strcasecmp(argv[1],
"getrttstd") == 0) {
184 }
else if (strcasecmp(argv[1],
"getfttstd") == 0) {
187 }
else if (strcasecmp(argv[1],
"getsentpkts") == 0) {
188 tcl.resultf(
"%d",
txsn - 1);
190 }
else if (strcasecmp(argv[1],
"getrecvpkts") == 0) {
193 }
else if (strcasecmp(argv[1],
"sendPkt") == 0) {
196 }
else if (strcasecmp(argv[1],
"resetStats") == 0) {
199 "VbrModule::command() resetStats %s, pkts_last_reset=%d, "
200 "hrsn=%d, txsn=%d\n",
208 return Module::command(argc, argv);
216 return Module::crLayCommand(m);
223 hdr_cmn *ch = hdr_cmn::access(p);
236 ch->timestamp() = Scheduler::instance().clock();
257 Packet *p = Packet::alloc();
259 hdr_cmn *ch = hdr_cmn::access(p);
262 printf(
"VbrModule(%d)::sendPkt, send a pkt (%d) with sn: %d\n",
304 hdr_cmn *ch = hdr_cmn::access(p);
306 printf(
"VbrModule(%d)::recv(Packet*p,Handler*) pktId %d\n",
335 printf(
"VbrModule::recv() Pkt out of sequence! "
336 "vbrh->sn=%d\thrsn=%d\tesn=%d\n",
346 rftt = Scheduler::instance().clock() - ch->timestamp();
360 if (uwvbrh->
sn() >
esn) {
365 double dt = Scheduler::instance().clock() -
lrtime;
368 lrtime = Scheduler::instance().clock();
375 "ERROR VbrModule::recv() pkts_lost=%d pkts_recv=%d "
470 cerr <<
"bytes=" << bytes <<
" dt=" << dt << endl;
524 fprintf(stderr,
"%s : Error : period <= 0", __PRETTY_FUNCTION__);
535 double u = RNG::defaultrng()->uniform_double();
536 double lambda = 1 / period_;
537 return (-log(u) / lambda);
Adds the module for UwVbrModuleClass in ns2.
TclObject * create(int, const char *const *)
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.
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.
virtual void expire(Event *e)
Adds the header for hdr_uwvbr packets in ns2.
virtual void expire(Event *e)
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
static hdr_uwip * access(const Packet *p)
hdr_uwudp describes UWUDP packets.
static struct hdr_uwudp * access(const Packet *p)
uint8_t & dport()
Reference to the dport_ variable.
hdr_uwvbr describes UWVBR packets.
float & rftt()
Reference to the rftt_ variable.
bool & rftt_valid()
Reference to the rftt_valid_ variable.
u_int16_t & sn()
Reference to the sn_ variable.
static int offset_
Required by the PacketHeaderManager.
UwVbrModuleClass class_module_uwvbr
UwVbrPktClass class_uwvbr_pkt
Provides the UWVBR packets header description and the definition of the class UWVBR.
#define UWVBR_DROP_REASON_OUT_OF_SEQUENCE
Reason for a drop in a UWVBR module.
#define UWVBR_DROP_REASON_DUPLICATED_PACKET
Reason for a drop in a UWVBR module.
#define UWVBR_DROP_REASON_UNKNOWN_TYPE
Reason for a drop in a UWVBR module.