DESERT 3.5.1
Loading...
Searching...
No Matches
uw-smart-ofdm.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
42#ifndef UWSMARTOFDM_H_
43#define UWSMARTOFDM_H_
44
45#include <mmac.h>
46#include <iostream>
47#include <string>
48#include <map>
49#include <set>
50#include <queue>
51#include <fstream>
52#include <mutex>
53#include <array>
54#include <mphy.h>
55#include "uwofdmphy_hdr.h"
56#include "uwofdmphy.h"
57#include "uwofdmmac_hdr.h"
58#include <clmessage.h>
59#include <atomic>
60
61
62#include "msg-display.h"
63
64#define UWSMARTOFDM_DROP_REASON_WRONG_STATE "WST"
65#define UWSMARTOFDM_DROP_REASON_WRONG_RECEIVER "WRCV"
66#define UWSMARTOFDM_DROP_REASON_UNKNOWN_TYPE "UPT"
67#define UWSMARTOFDM_DROP_REASON_BUFFER_FULL "DBF"
68#define UWSMARTOFDM_DROP_REASON_ERROR "ERR"
69
70extern packet_t PT_MMAC_ACK;
71extern packet_t PT_MMAC_CTS;
72extern packet_t PT_MMAC_DATA;
73extern packet_t PT_MMAC_RTS;
74
75// Types of MAC frames that can be used
76// enum MacFrameType {
77// MF_BEACON = 0x0008, // beaconing
78// MF_CONTROL = 0x0010, // used as mask for control frame
79// MF_SLOTS = 0x001a, // announce slots open for contention
80// MF_RTS = 0x001b, // request to send
81// MF_CTS = 0x001c, // clear to send, grant
82// MF_ACK = 0x001d, // acknowledgement
83// MF_CF_END = 0x001e, // contention free period end
84// MF_POLL = 0x001f, // polling
85// MF_DATA = 0x0020, // also used as mask for data frame
86// MF_DATA_ACK = 0x0021 // ack for data frames
87// };
88
89typedef int pktSeqNum;
90enum criticalLevel {LOW = 0, HIGH=1};
91
97class UWSmartOFDM : public MMac
98{
99
100public:
104 UWSmartOFDM();
105
109 virtual ~UWSmartOFDM();
110
119 virtual int command(int argc, const char *const *argv);
120
121 //Initialize subCarriers parameters inside a node, default all carriers are used
122 void init_macofdm_node(int subCarNum, double carSize, int ctrl_subCar, std::string modulation);
123
124protected:
155
191
204
212
223
228 class UWSmartOFDMTimer : public TimerHandler
229 {
230
231 public:
236 : TimerHandler()
237 , start_time(0.0)
238 , left_duration(0.0)
239 , counter(0)
240 , module(m)
242 {
243 assert(m != NULL);
244 }
245
250 {
251 }
252
253 virtual double
255 {
256 return start_time;
257 }
258
266 virtual void
268 {
270 left_duration -= (NOW - start_time);
271 if (left_duration <= 0.0)
272 left_duration = module->mac2phy_delay_;
273 force_cancel();
275 }
280 virtual void
282 {
284 start_time = NOW;
285 assert(left_duration > 0);
286 sched(left_duration);
288 }
289
293 virtual void
295 {
297 force_cancel();
298 }
299
304 virtual void
305 schedule(double val)
306 {
307 start_time = NOW;
308 left_duration = val;
310 resched(val);
311 }
312
313
314
315
320 bool
322 {
323 return (timer_status == UWSMARTOFDM_IDLE);
324 }
325
330 bool
332 {
334 }
335
340 bool
342 {
344 }
345
350 bool
352 {
354 }
355
360 bool
366
370 void
372 {
373 counter = 0;
374 }
375
380 void
382 {
383 ++counter;
384 }
385
390 int
392 {
393 return counter;
394 }
395
400 double
402 {
403 return left_duration;
404 }
405
406 protected:
407 double start_time;
413 UWSmartOFDM *module;
416 };
417
422 {
423
424 public:
430 {
431 }
432
436 virtual ~AckTimer()
437 {
438 }
439
440 protected:
445 virtual void expire(Event *e);
446 };
447
452 {
453
454 public:
460 {
461 }
462
467 {
468 }
469
470 protected:
475 virtual void expire(Event *e);
476 };
477
482 {
483
484 public:
490 {
491 }
492
496 virtual ~CTSTimer()
497 {
498 }
499
500 protected:
505 virtual void expire(Event *e);
506 };
511 {
512
513 public:
519 {
520 }
521
525 virtual ~RTSTimer()
526 {
527 }
528
529 protected:
534 virtual void expire(Event *e);
535 };
536
537
542 {
543
544 public:
552
557 {
558 }
559
560 protected:
565 virtual void expire(Event *e);
566 };
567
573 {
574
575 public:
583
588 {
589 }
590
591 protected:
596 virtual void expire(Event *e);
597 };
598
599 /* Base class of DATATimer. It is derived class of UWSmartOFDMTimer.
600 * waits for DATA after CTS
601 */
603 {
604
605 public:
611 {
612 }
613
617 virtual ~DATATimer()
618 {
619 }
620
621 protected:
626 virtual void expire(Event *e);
627 };
628
634 virtual void recvFromUpperLayers(Packet *p);
635
640 virtual void Mac2PhyStartTx(Packet *p);
641
646 virtual void Phy2MacEndTx(const Packet *p);
647
652 virtual void Phy2MacStartRx(const Packet *p);
653
658 virtual void Phy2MacEndRx(Packet *p);
659
666 virtual double computeTxTime(UWSMARTOFDM_PKT_TYPE type);
667
678 virtual void initPkt(
679 Packet *p, UWSMARTOFDM_PKT_TYPE pkt_type, int dest_addr = 0);
680
686 virtual double getBackoffTime();
687
691 virtual void txData();
692
697 virtual void txAck(int dest_addr);
698
703 virtual void txRTS();
704
711 virtual void txCTS(int dest_addr, int* rcv_car, int bytesToSend);
712
717 virtual void stateIdle();
718
723 virtual void stateSendRTS();
724
728 virtual void stateSendCTS(Packet* p);
729
733 virtual void stateWaitCTS();
734
738 virtual void stateBackoffCTS();
739
743 virtual void stateRxIdle();
744
749 virtual void stateTxData();
750
755 virtual void stateTxAck(int dest_addr);
756
761 virtual void stateWaitAck();
762
769 virtual void stateRxWaitAck();
770
775 virtual void stateBackoff(double bt=0);
776
782 virtual void stateRxBackoff();
783
788 virtual void stateCheckAckExpired();
789
794 virtual void stateCheckBackoffExpired();
795
800 virtual void stateCheckCTSBackoffExpired();
801
807 virtual void stateRxData(Packet *p);
808
814 virtual void stateRxAck(Packet *p);
815
816 /* The node comes to this state if it receives an <i>RTS</i> packet */
817 virtual void stateRxRTS(Packet *p);
818
819 /* The node comes to this state if it receives an <i>CTS</i> packet */
820 virtual void stateRxCTS(Packet *p);
821
822 /* Node comes here after sending a CTS. Waits for data before doing other stuff */
823 virtual void stateWaitData(double t);
824
828 virtual void exitBackoff();
829
833 virtual void exitCTSBackoff();
834
839 virtual void printStateInfo(double delay = 0);
840
844 virtual void initInfo();
845
852 virtual void
859
864 virtual void
866 {
867 last_reason = reason;
868 }
869
874 virtual void
876 {
878 }
879
883 virtual void
885 {
886 curr_tx_rounds = 0;
887 }
888
894 virtual void updateRTT(double rtt);
895
900 virtual double
902 {
903 return (rttsamples > 0) ? sumrtt / rttsamples : 0;
904 }
905
909 virtual double
911 {
912 return RTSsent;
913 }
914
918 virtual double
920 {
921 return CTSsent;
922 }
923
927 virtual void updateAckTimeout(double rtt);
928
933 virtual void
935 {
936 last_data_id_rx = id;
937 }
938 virtual void waitForUser();
939
945 inline int
946 getPktSeqNum(Packet *p)
947 {
948 int seq_num;
949 hdr_cmn *ch = hdr_cmn::access(p);
950 seq_num = ch->uid();
951 return seq_num;
952 }
953
959 inline void
960 putPktInQueue(Packet *p)
961 {
962 mapPacket.insert(pair<pktSeqNum, Packet *>(getPktSeqNum(p), p));
963 }
964
969 inline void
971 {
972 map<pktSeqNum, Packet *>::iterator it_p;
973 it_p = mapPacket.find(seq_num);
974 if (it_p != mapPacket.end()){
975 Packet::free((*it_p).second);
976 mapPacket.erase((*it_p).first);
977
978 }
979 else
980 std::cout << "ATTENTION PACKET NOT FOUND IN PKTQUEUE" << std::endl;
981 }
982
987 inline void
988 putAckTimerInMap(int seq_num)
989 {
990 mapAckTimer.insert(pair<pktSeqNum, AckTimer>(seq_num, ack_timer));
991 }
992
997 inline void
999 {
1000 map<pktSeqNum, AckTimer>::iterator it_a;
1001 it_a = mapAckTimer.find(seq_num);
1002 mapAckTimer.erase((*it_a).first);
1003 }
1004
1010 virtual int
1012 {
1013 return (up_data_pkts_rx - mapPacket.size());
1014 }
1015
1019 virtual void
1021 {
1022 up_data_pkts_rx++;
1023 }
1024
1025 inline int
1027 {
1028 return up_data_pkts_rx;
1029 }
1030
1031 //returns the number of high priority packets sent
1032 inline int
1034 {
1035 return high_prio_pkt_sent;
1036 }
1037
1038 //returns the number of high priority packets received
1039 inline int
1041 {
1042 return high_prio_pkt_recv;
1043 }
1044
1045 //returns the current free carriers that can be given to a node
1051 void carToBeUsed(criticalLevel c, int& top, int& bottom, int& avoid_top, int& avoid_bottom);
1052
1059 int pickFreeCarriers(int* freeC);
1060
1069 int matchCarriers(int* myFree, int* otherFree, int* matching);
1070
1076 void updateOccupancy(int* busyCar, int ntslots);
1077
1082 void clearOccTable();
1083
1087 void resetAssignment();
1088
1092 void printOccTable();
1093
1094 // Sends a msg to Mac to tell if tx is happening
1095 void Mac2PhySetTxBusy(int, int get=0);
1096
1097 //True if the conditions for a batch sending are verified, false otherwise
1098 bool batchSending();
1099
1100 //add to the list of carriers that shouldn't be used
1101 inline void
1103 nouse_carriers.push_back(c);
1104 }
1105
1106 //Remove Invalid Carrier c from nouse_carriers - if it's back to valid
1107 void removeInvalidCarrier(int c);
1108
1109 //update InterfTable with new unrecognized packet
1110 //also cleans the old samples
1111 void updateInterfTable(Packet* p);
1112
1125 double bitrateCar; // Bitrate per carrier
1127 double alpha_;
1133
1135 std::vector<string> mac_carMod; // Vector with carriers modulations
1136 std::vector<int> mac_carVec; // Vector with carriers used/not used
1137 std::vector<char> mac_prioVec; // Vector with node's priorities H/L
1138 int mac_ncarriers; // number of subcarriers
1140 int ctrl_car; //number of control subcarriers
1141 int data_car; // number of carriers used for data
1142 bool coordinator; // if this node is a coordinator
1145 int nodeNum; //number of nodes in the network
1146 std::atomic<int> current_rcvs; // Number of current Receptions
1148
1149 int oTableIndex; // index in the occupancy table of the current point
1150 int max_aval_car; //number of free carriers that tx can tell rx
1151
1152
1153 static bool initialized;
1161 bool
1166 double srtt;
1167 double sumrtt;
1168 double sumrtt2;
1170 int RTSsent = 0;
1171 int CTSsent = 0;
1172
1179
1181
1184 int txsn;
1186 static const double prop_speed;
1212 static map<UWSMARTOFDM_STATUS, string> status_info;
1215 static map<UWSMARTOFDM_REASON_STATUS, string>
1218 static map<UWSMARTOFDM_PKT_TYPE, string>
1221 static map<criticalLevel, string>
1225 map<pktSeqNum, Packet *>
1227 map<pktSeqNum, AckTimer> mapAckTimer;
1230 ofstream fout;
1232
1233 std::vector<std::vector<int>> occupancy_table; //table with future usage of subcarriers
1234 std::mutex otabmtx; // mutex for occupancy table
1235 int timeslots; // how many timeslots will be kept
1236 double timeslot_length; // length in seconds of each timeslot
1237 int max_car_reserved; // max num of carriers reserved for each exchange
1238 int req_tslots; // how many tslots reserved for an interaction
1239
1240 int current_timeslot; //index in the occupancy table of the current timeslot
1241
1242 int max_rts_tries; // max num of times that rts will be sent for a specific packet
1243 int curr_rts_tries; // current num of rts sent for a specific packet
1244 int max_burst_size; // number of packets that will be sent consecutively
1246 bool batch_sending; // true if sending a batch, false otherwise
1247
1248 bool RTSvalid; //true if allowed to send an RTS
1249
1250 double nextFreeTime; //When in time the bw will become free
1251 bool ackToSend; //Packets have been received, need to send ack
1252 Packet* pkt_to_ack;
1254 //variables to save heard RTS
1255 Packet* nextRTS;
1258 std::vector<int> nouse_carriers;
1259 std::vector<std::vector<double>> interf_table; //table with future usage of subcarriers
1260};
1261
1262#endif /* UWUWSMARTOFDM_H_ */
Base class of AckTimer, which is a derived class of UWSmartOFDMTimer.
virtual ~AckTimer()
Destructor of AckTimer Class.
AckTimer(UWSmartOFDM *m)
Constructor of AckTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
Base class of AssignmentTimer.
AssignmentTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~AssignmentTimer()
Destructor of BackOffTimer.
Base class of AssignmentValidTimer.
virtual ~AssignmentValidTimer()
Destructor of BackOffTimer.
AssignmentValidTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
Base class of BackoffTimer.
BackOffTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual ~BackOffTimer()
Destructor of BackOffTimer.
Base class of CTSTimer.
CTSTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual ~CTSTimer()
Destructor of BackOffTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
DATATimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
virtual ~DATATimer()
Destructor of BackOffTimer.
Base class of RTSTimer.
virtual ~RTSTimer()
Destructor of BackOffTimer.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
RTSTimer(UWSmartOFDM *m)
Constructor of BackOffTimer Class.
Base class of all the timer used in this protocol.
double left_duration
How long a timer is going to run more.
virtual void stop()
Stop the timer any way.
UWSmartOFDM *UWSMARTOFDM_TIMER_STATUS timer_status
< Pointer of UWSmartOFDM module.
void resetCounter()
Reset the timer counter.
double getDuration()
This methods provide the duration of a timer.
void incrCounter()
Increment the timer counter.
int getCounter()
It provides, how many times a timer ran.
bool isActive()
It tells whether the timer is active or not.
virtual ~UWSmartOFDMTimer()
Destructor of UWSmartOFDMTimer Class.
double start_time
Start time of a timer.
int counter
How many times a timer ran.
bool isFrozen()
It tells whether the timer is in freeze mode or not.
bool isExpired()
Tells whether the timer is expired or not.
bool isRunning()
This method tells whether the timer is in Running state or not.
bool isIdle()
It tells whether the timer is in Idle state or not.
virtual void schedule(double val)
Schedule the time, i.e., how long a timer is going to run.
virtual void freeze()
It freezes or in another word, it stops the timer for some time.
UWSmartOFDMTimer(UWSmartOFDM *m)
Constructor of UWSmartOFDMTimer Class.
virtual void unFreeze()
It starts the timer from where it was stopped.
This is the base class of UWSmartOFDM protocol, which is a derived class of MMac.
virtual double getCTSsent()
This method is used to get the total number of sent CTS messages.
virtual void stateWaitCTS()
Node is in waitCTS state.
void eraseItemFromPktQueue(int seq_num)
It erases the packet from the container.
virtual void stateTxData()
If a node has packet to transmits.
virtual ~UWSmartOFDM()
Destructor of UWSmartOFDM Class.
double wait_constant
This fixed time is used to componsate different time variations.
int recv_data_id
The sequence number of the packet which is received.
virtual void stateRxBackoff()
If a node start receiving a packet when it is in backoff state.
bool print_transitions
Whether to print the state of the nodes.
virtual void Phy2MacEndTx(const Packet *p)
It infroms that a packet transmission end.
void putAckTimerInMap(int seq_num)
Put acknowledgement timer in the container.
virtual double computeTxTime(UWSMARTOFDM_PKT_TYPE type)
Compute the transmission time of a packet.
virtual void recvFromUpperLayers(Packet *p)
This function receives the packet from upper layer and save it in the queue.
virtual void stateRxRTS(Packet *p)
int getHighPrioPktsSent()
std::vector< int > mac_carVec
virtual void incrCurrTxRounds()
Increments the current transmission round of a packet.
void init_macofdm_node(int subCarNum, double carSize, int ctrl_subCar, std::string modulation)
int txsn
Sequence number of the packet which is transmitted.
virtual void txAck(int dest_addr)
This methods transmits ACK packet from MAC layer to PHY layer.
bool has_buffer_queue
Whether the node has buffer to store data or not.
AssignmentValidTimer assignment_valid_timer
An object of the assignment valid timer class.
virtual void stateBackoffCTS()
Node is in BackoffCTS state.
int max_payload
Maximum number of payload in a packet.
void clearOccTable()
clears the carriers used in the past moves the index for the current time to the next slot
CTSTimer CTS_timer
An object of the CTS timer class.
Packet * pkt_to_ack
int HDR_size
Size of the HDR if any.
int uwsmartofdm_debug
Debuging Flag.
void printOccTable()
prints on terminal the table
static map< criticalLevel, string > clevel_info
Container which stores all the packet type information of UWSmartOFDM.
void addInvalidCarriers(int c)
void carToBeUsed(criticalLevel c, int &top, int &bottom, int &avoid_top, int &avoid_bottom)
returns the current free carriers that can be given to a node top and bottom give the range avoid_top...
virtual double getBackoffTime()
This function calculates the backoff duration and return the backoff time.It employs the exponential ...
Packet * curr_data_pkt
Pointer of the latest selected data packet.
double mac_carrierSize
int RTS_size
Size of the ACK, if the node uses SMARTOFDM.
void updateOccupancy(int *busyCar, int ntslots)
updates occupancy table
UWSmartOFDM()
Constructor of UWSmartOFDM Class.
std::vector< std::vector< int > > occupancy_table
virtual void resetCurrTxRounds()
If a node is going to transmit a new packet, it resets the tx counter.
void putPktInQueue(Packet *p)
A node receives packet(s) from upper layer and store them in the container.
virtual void updateRTT(double rtt)
Update the Round Trip Time (RTT) which is necessary to compute the acknowledgement duration as well a...
AssignmentTimer assignment_timer
An object of the assignment timer class.
static map< UWSMARTOFDM_REASON_STATUS, string > reason_info
Container which stores all the reason information.
virtual void stateRxData(Packet *p)
It process the packet which is received.
virtual void incrUpperDataRx()
Increment the number of Data packet receive for the upper layer.
virtual void txCTS(int dest_addr, int *rcv_car, int bytesToSend)
This methods transmits CTS packet from MAC layer to PHY layer.
std::vector< std::vector< double > > interf_table
AckTimer ack_timer
An object of the AckTimer class.
DATATimer DATA_timer
An object of the DATA timer class.
int last_data_id_rx
The sequence number of last received packet.
UWSMARTOFDM_ACK_MODES
Enumeration class of UWSmartOFDM acknowledgement mode.
void removeInvalidCarrier(int c)
virtual void stateRxAck(Packet *p)
The node comes to this state if it receives an ACK packet.
criticalLevel cLevel
void updateInterfTable(Packet *p)
virtual void stateWaitData(double t)
UWSMARTOFDM_STATUS
Enumeration class of UWSmartOFDM status.
@ UWSMARTOFDM_STATE_BACKOFF
@ UWSMARTOFDM_STATE_NOT_SET
@ UWSMARTOFDM_STATE_RX_IDLE
@ UWSMARTOFDM_STATE_DATA_RX
@ UWSMARTOFDM_STATE_CHK_CTS_BACKOFF_TIMEOUT
@ UWSMARTOFDM_STATE_CHK_BACKOFF_TIMEOUT
@ UWSMARTOFDM_STATE_CHK_ACK_TIMEOUT
@ UWSMARTOFDM_STATE_WAIT_ACK
@ UWSMARTOFDM_STATE_RX_BACKOFF
@ UWSMARTOFDM_STATE_CTRL_BACKOFF
@ UWSMARTOFDM_STATE_TX_DATA
@ UWSMARTOFDM_STATE_TX_ACTIVE
@ UWSMARTOFDM_STATE_WRONG_PKT_RX
@ UWSMARTOFDM_STATE_WAIT_CTS
@ UWSMARTOFDM_STATE_RX_WAIT_ACK
@ UWSMARTOFDM_STATE_RX_ACTIVE
@ UWSMARTOFDM_STATE_WAIT_DATA
ofstream fout
An object of ofstream class.
int getPktSeqNum(Packet *p)
This method is used to get the sequence number from a packet.
virtual double getRTSsent()
This method is used to get the total number of sent RTS messages.
int rttsamples
Number of RTT samples.
virtual void updateAckTimeout(double rtt)
Like updateRTT() function.
double max_backoff_counter
Maximum number of backoff it will consider while it increases the backoff exponentially.
static map< UWSMARTOFDM_STATUS, string > status_info
Container which stores all the status information.
virtual void stateBackoff(double bt=0)
If ACK packet is not received within the acknowledgement expire time.
virtual void Phy2MacEndRx(Packet *p)
PHY layer informs the MAC layer that the reception of the packet is over.
double start_tx_time
Time when a packet start transmitting.
UWSMARTOFDM_STATUS curr_state
Enum variable.
virtual void Phy2MacStartRx(const Packet *p)
PHY layer informs the MAC layer that it is receiving a packet.
virtual void stateSendCTS(Packet *p)
Node is in sendRTS state.
virtual void initInfo()
This function is used to initialize the UWSmartOFDM protocol.
virtual void stateCheckCTSBackoffExpired()
It checks whether the CTS backoff timer is already expired while it was busy with other activities.
double sumrtt2
Sum of (RTT^2)
UWSMARTOFDM_STATUS prev_state
Enum variable.
virtual int getRemainingPkts()
Number of packets which MAC layer receives form upper layer(s) but were not transmitted.
std::vector< string > mac_carMod
int matchCarriers(int *myFree, int *otherFree, int *matching)
Returns free Carriers matching between itself and the sender to be used when an RTS is received to fi...
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
static bool initialized
It checks whether UWSmartOFDM protocol is initialized or not.
virtual void stateIdle()
Node is in Idle state.
BackOffTimer backoff_timer
An object of the backoff timer class.
double nextAssignment
double srtt
Smoothed Round Trip Time, calculated as for TCP.
virtual void Mac2PhyStartTx(Packet *p)
It informs that a packet transmission started.
void eraseItemFrommapAckTimer(int seq_num)
Erase an item from acknowledgement stored container.
virtual void refreshReason(UWSMARTOFDM_REASON_STATUS reason)
To know the reason why a node is in this current state.
static const double prop_speed
Speed of the sound signal.
double timeslot_length
map< pktSeqNum, Packet * > mapPacket
Container where Data packets are stored.
void resetAssignment()
resets value of car_assigned to FALSE
std::mutex otabmtx
std::atomic< int > current_rcvs
double alpha_
This variable is used to tune the RTT.
int getHighPrioPktsRecv()
double ACK_timeout
ACK timeout for the initial packet.
double sumrtt
Sum of RTT samples.
int ACK_size
Size of the ACK, if the node uses ARQ technique.
virtual void updateLastDataIdRx(int id)
It updates the sequence number of the last data packet rx.
int buffer_pkts
Number of packets a node can store in the container.
int last_sent_data_id
sequence number of the last sent packet
virtual void txData()
This method transmits Data packets from MAC layer to PHY layer.
double nextFreeTime
virtual void initPkt(Packet *p, UWSMARTOFDM_PKT_TYPE pkt_type, int dest_addr=0)
This method, initialize the packet.
virtual void stateTxAck(int dest_addr)
If the protocl uses ARQ technique, in that case, after receiving a Data packet the node sends an ACK ...
UWSMARTOFDM_TIMER_STATUS
Enumeration class of UWSmartOFDM timer status.
UWSMARTOFDM_STATUS prev_prev_state
Enum variable.
int CTS_size
Size of the ACK, if the node uses SMARTOFDM.
virtual void stateRxCTS(Packet *p)
int DATA_size
Size of the DATA packet, if the node uses SMARTOFDM.
std::vector< char > mac_prioVec
virtual void stateCheckAckExpired()
It checks whether the ack timer is already expired while it was busy with other activities.
UWSMARTOFDM_REASON_STATUS
Enumeration class which tells the nodes the reason why it is in this state.
@ UWSMARTOFDM_REASON_DATA_EMPTY
@ UWSMARTOFDM_REASON_ACK_RX
@ UWSMARTOFDM_REASON_ACK_TX
@ UWSMARTOFDM_REASON_START_RX
@ UWSMARTOFDM_REASON_RTS_RX
@ UWSMARTOFDM_REASON_ACK_TIMEOUT
@ UWSMARTOFDM_REASON_PKT_NOT_FOR_ME
@ UWSMARTOFDM_REASON_CTS_BACKOFF_TIMEOUT
@ UWSMARTOFDM_REASON_WAIT_DATA
@ UWSMARTOFDM_REASON_BACKOFF_TIMEOUT
@ UWSMARTOFDM_REASON_DATA_PENDING
@ UWSMARTOFDM_REASON_PHY_LAYER_SENDING
@ UWSMARTOFDM_REASON_MAX_RTS_TRIES
@ UWSMARTOFDM_REASON_DATAT_EXPIRED
@ UWSMARTOFDM_REASON_CTS_TX
@ UWSMARTOFDM_REASON_MAX_TX_TRIES
@ UWSMARTOFDM_REASON_BACKOFF_PENDING
@ UWSMARTOFDM_REASON_DATA_RX
@ UWSMARTOFDM_REASON_WAIT_CTS_PENDING
@ UWSMARTOFDM_REASON_PHY_LAYER_RECEIVING
@ UWSMARTOFDM_REASON_NOT_SET
@ UWSMARTOFDM_REASON_RTS_TX
@ UWSMARTOFDM_REASON_CTS_RX
@ UWSMARTOFDM_REASON_DATA_TX
@ UWSMARTOFDM_REASON_WAIT_ACK_PENDING
@ UWSMARTOFDM_REASON_PKT_ERROR
@ UWSMARTOFDM_REASON_PREVIOUS_RTS
@ UWSMARTOFDM_REASON_DATA_NOCAR
@ UWSMARTOFDM_REASON_DATA_CARASSIGNED
virtual void refreshState(UWSMARTOFDM_STATUS state)
Refreshes the states of the node.
map< pktSeqNum, AckTimer > mapAckTimer
Container where acknowledgement timer(s) is stored.
virtual void stateWaitAck()
After transmitting a Data packet, a node waits for the ACK packet.
std::vector< int > nouse_carriers
virtual void exitBackoff()
It stops the backoff timer.
int curr_tx_rounds
How many times a packet is transmitted.
virtual double getRTT()
This method is used to get the average RTT over all the receives RTT.
virtual void waitForUser()
virtual void stateCheckBackoffExpired()
It checks whether the backoff timer is already expired while it was busy with other activities.
double backoff_tuner
Tunes the backoff duration.
MsgDisplayer msgDisp
virtual void printStateInfo(double delay=0)
This methods print the state information of the nodes.
int pickFreeCarriers(int *freeC)
Returns max 5 carriers that are free in the next n time slots from occupancy table.
virtual void stateSendRTS()
Node is in sendRTS state.
virtual void stateRxIdle()
If a node start receiving a packet in Idle state.
static map< UWSMARTOFDM_PKT_TYPE, string > pkt_type_info
Container which stores all the packet type information of UWSmartOFDM.
UWSMARTOFDM_ACK_MODES ack_mode
Enum variable.
void Mac2PhySetTxBusy(int, int get=0)
RTSTimer RTS_timer
An object of the RTS timer class.
virtual void exitCTSBackoff()
It stops the CTS backoff timer.
Packet * nextRTS
UWSMARTOFDM_PKT_TYPE
Enumeration class of UWSmartOFDM packet type.
virtual void stateRxWaitAck()
If a node receives any packet while it was waiting for ACK packet, it moves to this state.
UWSMARTOFDM_REASON_STATUS last_reason
Enum variable which stores the last reason why a node changes its state.
int getUpLayersDataPktsRx()
int max_tx_tries
Maximum number of retransmissions attempt.
virtual void txRTS()
This methods transmits RTS packet from MAC layer to PHY layer.
Class that provide the implementation of an object to display messages.
int pktSeqNum
criticalLevel
@ HIGH
@ LOW
std::pair< int, int > counter
counter of collisions
Common necessary fields for smart-ofdm.
Definition of UwOFDMPhy class. Your can find the brief description of this physical layer in the pape...
Common structures and variables in the protocol.