60 : PacketHeaderClass(
"PacketHeader/UWCBR", sizeof(
hdr_uwcbr))
74 : TclClass(
"Module/UW/CBR")
99 , drop_out_of_order_(0)
126 , tracefile_enabler_(0)
130 bind(
"destPort_", (
int *) &
dstPort_);
131 bind(
"destAddr_", (
int *) &
dstAddr_);
139 for (
int i = 0; i < USHRT_MAX; i++) {
147 cout <<
"sdpaosdisaopdisp" << endl;
153 Tcl &tcl = Tcl::instance();
155 if (strcasecmp(argv[1],
"start") == 0) {
158 }
else if (strcasecmp(argv[1],
"stop") == 0) {
161 }
else if (strcasecmp(argv[1],
"getrtt") == 0) {
162 tcl.resultf(
"%f",
GetRTT());
164 }
else if (strcasecmp(argv[1],
"getftt") == 0) {
165 tcl.resultf(
"%f",
GetFTT());
167 }
else if (strcasecmp(argv[1],
"gettxtime") == 0) {
170 }
else if (strcasecmp(argv[1],
"getper") == 0) {
171 tcl.resultf(
"%f",
GetPER());
173 }
else if (strcasecmp(argv[1],
"getthr") == 0) {
174 tcl.resultf(
"%f",
GetTHR());
176 }
else if (strcasecmp(argv[1],
"getcbrheadersize") == 0) {
179 }
else if (strcasecmp(argv[1],
"getrttstd") == 0) {
182 }
else if (strcasecmp(argv[1],
"getfttstd") == 0) {
185 }
else if (strcasecmp(argv[1],
"getsentpkts") == 0) {
186 tcl.resultf(
"%d",
txsn - 1);
188 }
else if (strcasecmp(argv[1],
"getrecvpkts") == 0) {
191 }
else if (strcasecmp(argv[1],
"setprioritylow") == 0) {
194 }
else if (strcasecmp(argv[1],
"setpriorityhigh") == 0) {
197 }
else if (strcasecmp(argv[1],
"sendPkt") == 0) {
200 }
else if (strcasecmp(argv[1],
"sendPktLowPriority") == 0) {
203 }
else if (strcasecmp(argv[1],
"sendPktHighPriority") == 0) {
206 }
else if (strcasecmp(argv[1],
"resetStats") == 0) {
209 "CbrModule::command() resetStats %s, pkts_last_reset=%d, "
210 "hrsn=%d, txsn=%d\n",
216 }
else if (strcasecmp(argv[1],
"printidspkts") == 0) {
220 }
else if (argc == 3) {
221 if (strcasecmp(argv[1],
"setLogSuffix") == 0){
222 string tmp_ = (
char *) argv[2];
230 }
else if (argc == 4) {
231 if (strcasecmp(argv[1],
"setLogSuffix") == 0){
232 string tmp_ = (
char *) argv[2];
233 int precision = std::atoi(argv[3]);
245 return Module::command(argc, argv);
253 return Module::crLayCommand(m);
260 hdr_cmn *ch = hdr_cmn::access(p);
275 ch->timestamp() = Scheduler::instance().clock();
295 Packet *p = Packet::alloc();
297 hdr_cmn *ch = hdr_cmn::access(p);
300 printf(
"CbrModule(%d)::sendPkt, send a pkt (%d) with sn: %d\n",
311 Packet *p = Packet::alloc();
313 hdr_cmn *ch = hdr_cmn::access(p);
317 printf(
"CbrModule(%d)::sendPkt, send a pkt (%d) with sn: %d\n",
328 Packet *p = Packet::alloc();
330 hdr_cmn *ch = hdr_cmn::access(p);
334 printf(
"CbrModule(%d)::sendPkt, send a pkt (%d) with sn: %d\n",
364 hdr_cmn *ch = hdr_cmn::access(p);
368 printf(
"CbrModule(%d)::recv(Packet*p,Handler*) pktId %d\n",
397 printf(
"CbrModule::recv() Pkt out of sequence! "
398 "cbrh->sn=%d\thrsn=%d\tesn=%d\n",
408 rftt = Scheduler::instance().clock() - ch->timestamp();
426 if (uwcbrh->
sn() >
esn) {
431 double dt = Scheduler::instance().clock() -
lrtime;
434 lrtime = Scheduler::instance().clock();
441 "ERROR CbrModule::recv() pkts_lost=%d pkts_recv=%d "
533 cerr <<
"bytes=" << bytes <<
" dt=" << dt << endl;
586 fprintf(stderr,
"%s : Error : period <= 0", __PRETTY_FUNCTION__);
590 double u = RNG::defaultrng()->uniform_double();
592 return (-log(u) / lambda);
603 hdr_cmn *ch = hdr_cmn::access(p);
606 tracefile << NOW <<
" " << ch->timestamp() <<
" " << uwcbrh->
sn() <<
" "
607 << (int) uwiph->
saddr() <<
" " << (int) uwiph->
daddr() <<
" " << ch->size() <<
"\n";
Adds the module for UwCbrModuleClass in ns2.
TclObject * create(int, const char *const *)
UwCbrModule class is used to manage UWCBR packets and to collect statistics about them.
double sumdt
Sum of the delays.
UwCbrModule()
Constructor of UwCbrModule class.
virtual void incrPktRecv()
Increases by one the number of received packets.
virtual int crLayCommand(ClMessage *m)
virtual void initPkt(Packet *p)
Initializes a data packet passed as argument with the default values.
static int getCbrHeaderSize()
Returns the size in byte of a hdr_uwcbr packet header.
std::string tracefilename
static int uidcnt_
Unique id of the packet generated.
virtual void sendPktLowPriority()
Allocates, initialize and sends a packet with the default priority flag set from tcl.
virtual double getTimeBeforeNextPkt()
Returns the amount of time to wait before the next transmission.
double rftt
Forward Trip Time seen for last received packet.
double sumbytes
Sum of bytes received.
int txsn
Sequence number of the next packet to be transmitted.
int pkts_lost
Total number of lost packets, including packets received out of sequence.
virtual double GetRTTstd() const
Returns the Round Trip Time Standard Deviation.
virtual void stop()
Stop to send packets.
virtual void incrPktInvalid()
Increases by one the number of invalid packets.
uint32_t esn
Expected serial number.
double sumftt2
Sum of (FTT^2).
double sthr
Smoothed throughput calculation.
virtual void incrPktLost(const int &)
Increases the number of packets lost.
uint16_t dstPort_
Destination port.
int pkts_ooseq
Total number of packets received out of sequence.
virtual double GetTHR() const
Returns the mean Throughput.
std::string log_suffix
Possibility to insert a log suffix.
int debug_
Flag to enable several levels of debug.
bool * sn_check
Used to keep track of the packets already received.
double sumftt
Sum of FTT samples.
double srtt
Smoothed Round Trip Time, calculated as for TCP.
uint traffic_type_
Traffic type of the packets.
virtual void printReceivedPacket(Packet *p)
Print to tracefile details about a received packet.
void printIdsPkts() const
Prints the IDs of the packet's headers defined by UWCBR.
char priority_
Priority of the data packets.
virtual double GetTxTime() const
Returns the mean transmission time.
int drop_out_of_order_
Flag to enable or disable the check for out of order packets.
double sftt
Smoothed Forward Trip Time, calculated as srtt.
virtual double GetFTTstd() const
Returns the mean Forward Trip Time Standard Deviation.
virtual void incrPktOoseq()
Increases by one the number of out of sequence packets received.
virtual void updateThroughput(const int &, const double &)
Updates the Throughput.
virtual void updateRTT(const double &)
Updates the Round Trip Time.
int tracefile_enabler_
True if enable tracefile of received packets, default disabled.
nsaddr_t dstAddr_
IP of the destination.
int pkts_recv
Total number of received packets.
UwSendTimer sendTmr_
Timer which schedules packet transmissions.
virtual void start()
Start to send packets.
double lrtime
Time of last packet reception.
virtual void sendPktHighPriority()
Allocates, initialize and sends a packet with the default priority flag set from tcl.
double sumrtt
Sum of RTT samples.
virtual double GetFTT() const
Returns the mean Forward Trip Time.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
virtual double GetPER() const
Returns the mean Packet Error Rate.
virtual void transmit()
Creates and transmits a packet and schedules a new transmission.
int pktSize_
UWCBR packets payload size.
int hrsn
Highest received sequence number.
int pkts_invalid
Total number of invalid packets received.
double sumtxtimes
Sum of transmission times
double sumrtt2
Sum of (RTT^2).
virtual ~UwCbrModule()
Destructor of UwCbrModule class.
int fttsamples
Number of FTT samples.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
virtual double GetRTT() const
Returns the mean Round Trip Time.
virtual void updateFTT(const double &)
Updates the Forward Trip Time.
int pkts_last_reset
Used for error checking after stats are reset.
virtual void resetStats()
Resets all the statistics of the UWCBR module.
double period_
Period between two consecutive packet transmissions.
virtual void sendPkt()
Allocates, initialize and sends a packet with the default priority flag set from tcl.
int PoissonTraffic_
1 if the traffic is generated according to a poissonian distribution, 0 otherwise.
int rttsamples
Number of RTT samples.
Adds the header for hdr_uwcbr packets in ns2.
virtual void expire(Event *e)
hdr_uwcbr describes UWCBR packets.
float & rftt()
Reference to the rftt_ variable.
char & priority()
Reference to the priority_ variable.
uint16_t & traffic_type()
Reference to the rftt_ variable.
bool & rftt_valid()
Reference to the rftt_valid_ variable.
uint16_t & sn()
Reference to the sn_ variable.
static int offset_
Required by the PacketHeaderManager.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
uint8_t & saddr()
Reference to the saddr_ 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.
UwCbrModuleClass class_module_uwcbr
UwCbrPktClass class_uwcbr_pkt
Provides the UWCBR packets header description and the definition of the class UWCBR.
#define UWCBR_DROP_REASON_DUPLICATED_PACKET
Reason for a drop in a UWCBR module.
#define UWCBR_DROP_REASON_OUT_OF_SEQUENCE
Reason for a drop in a UWCBR module.
#define UWCBR_DROP_REASON_UNKNOWN_TYPE
Reason for a drop in a UWCBR module.