59 : PacketHeaderClass(
"PacketHeader/UWCBR", sizeof(
hdr_uwcbr))
73 : TclClass(
"Module/UW/CBR")
99 , drop_out_of_order_(0)
126 , tracefile_enabler_(0)
129 bind(
"destPort_", (
int *) &
dstPort_);
130 bind(
"destAddr_", (
int *) &
dstAddr_);
138 for (
int i = 0; i < USHRT_MAX; i++) {
146 Tcl &tcl = Tcl::instance();
148 if (strcasecmp(argv[1],
"start") == 0) {
151 }
else if (strcasecmp(argv[1],
"stop") == 0) {
154 }
else if (strcasecmp(argv[1],
"getrtt") == 0) {
155 tcl.resultf(
"%f",
GetRTT());
157 }
else if (strcasecmp(argv[1],
"getftt") == 0) {
158 tcl.resultf(
"%f",
GetFTT());
160 }
else if (strcasecmp(argv[1],
"gettxtime") == 0) {
163 }
else if (strcasecmp(argv[1],
"getper") == 0) {
164 tcl.resultf(
"%f",
GetPER());
166 }
else if (strcasecmp(argv[1],
"getthr") == 0) {
167 tcl.resultf(
"%f",
GetTHR());
169 }
else if (strcasecmp(argv[1],
"getcbrheadersize") == 0) {
172 }
else if (strcasecmp(argv[1],
"getrttstd") == 0) {
175 }
else if (strcasecmp(argv[1],
"getfttstd") == 0) {
178 }
else if (strcasecmp(argv[1],
"getsentpkts") == 0) {
179 tcl.resultf(
"%d",
txsn - 1);
181 }
else if (strcasecmp(argv[1],
"getrecvpkts") == 0) {
184 }
else if (strcasecmp(argv[1],
"setprioritylow") == 0) {
187 }
else if (strcasecmp(argv[1],
"setpriorityhigh") == 0) {
190 }
else if (strcasecmp(argv[1],
"sendPkt") == 0) {
193 }
else if (strcasecmp(argv[1],
"sendPktLowPriority") == 0) {
196 }
else if (strcasecmp(argv[1],
"sendPktHighPriority") == 0) {
199 }
else if (strcasecmp(argv[1],
"resetStats") == 0) {
202 "CbrModule::command() resetStats %s, pkts_last_reset=%d, "
203 "hrsn=%d, txsn=%d\n",
209 }
else if (strcasecmp(argv[1],
"printidspkts") == 0) {
213 }
else if (argc == 3) {
214 if (strcasecmp(argv[1],
"setLogSuffix") == 0) {
215 string tmp_ = (
char *) argv[2];
220 std::ios_base::out | std::ios_base::app);
224 }
else if (argc == 4) {
225 if (strcasecmp(argv[1],
"setLogSuffix") == 0) {
226 string tmp_ = (
char *) argv[2];
227 int precision = std::atoi(argv[3]);
232 std::ios_base::out | std::ios_base::app);
240 return Module::command(argc, argv);
246 hdr_cmn *ch = hdr_cmn::access(p);
261 ch->timestamp() = Scheduler::instance().clock();
281 Packet *p = Packet::alloc();
283 hdr_cmn *ch = hdr_cmn::access(p);
286 printOnLog(Logger::LogLevel::DEBUG,
288 "sendPkt()::send a packet (" + to_string(ch->uid()) +
289 ") with sn: " + to_string(uwcbrh->
sn()));
298 Packet *p = Packet::alloc();
300 hdr_cmn *ch = hdr_cmn::access(p);
304 printOnLog(Logger::LogLevel::DEBUG,
306 "sendPktLowPriority()::send a packet (" + to_string(ch->uid()) +
307 ") with sn: " + to_string(uwcbrh->
sn()));
316 Packet *p = Packet::alloc();
318 hdr_cmn *ch = hdr_cmn::access(p);
322 printOnLog(Logger::LogLevel::DEBUG,
324 "sendPktHighPriority()::send a packet (" + to_string(ch->uid()) +
325 ") with sn: " + to_string(uwcbrh->
sn()));
352 hdr_cmn *ch = hdr_cmn::access(p);
354 printOnLog(Logger::LogLevel::DEBUG,
356 "recv(Packet *)::received packet with id " + to_string(ch->uid()));
379 if (uwcbrh->
sn() <
esn) {
383 printOnLog(Logger::LogLevel::ERROR,
385 "recv(Packet *)::packet out of sequence sn = " +
386 to_string(uwcbrh->
sn()) +
" hrsn = " +
387 to_string(
hrsn) +
" esn = " + to_string(
esn));
394 rftt = NOW - ch->timestamp();
411 if (uwcbrh->
sn() >
esn) {
426 printOnLog(Logger::LogLevel::ERROR,
428 "recv(Packet *)::pkts_lost = " + to_string(
pkts_lost) +
430 " hrsn = " + to_string(
hrsn));
570 fprintf(stderr,
"%s : Error : period <= 0", __PRETTY_FUNCTION__);
575 double u = RNG::defaultrng()->uniform_double();
577 return (-log(u) / lambda);
587 hdr_cmn *ch = hdr_cmn::access(p);
590 tracefile << NOW <<
" " << ch->timestamp() <<
" " << uwcbrh->
sn() <<
" "
591 << (int) uwiph->
saddr() <<
" " << (int) uwiph->
daddr() <<
" "
592 << 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 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 int command(int argc, const char *const *argv) override
TCL command interpreter.
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.
virtual void recv(Packet *) override
Performs the reception of packets from upper and lower layers.
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 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).
int fttsamples
Number of FTT samples.
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.