62 : TclClass(
"Module/UW/SMART_OFDM")
79 if (module->uwsmartofdm_debug)
80 cout << NOW <<
" UWSmartOFDM (" <<
module->addr
81 << ") ACK_timer expire() current state = "
82 << module->status_info[module->curr_state]
83 << "; ACK not received, next state =
"
84 << module->status_info[UWSMARTOFDM_STATE_BACKOFF] << endl;
86 module->refreshReason(UWSMARTOFDM_REASON_ACK_TIMEOUT);
87 module->stateBackoff();
91 if (module->uwsmartofdm_debug)
93 << ")::AckTimer::expired()
" << endl;
97void UWSmartOFDM::BackOffTimer::expire(Event *e)
99 timer_status = UWSMARTOFDM_EXPIRED;
100 if (module->curr_state == UWSMARTOFDM_STATE_BACKOFF)
103 if (module->uwsmartofdm_debug)
105 << ") timer
expire() current state = "
107 << "; backoff expired, next state = "
119 if (module->uwsmartofdm_debug)
120 cout << NOW <<
" UWSmartOFDM (" <<
module->addr
121 << ")::BackOffTimer::expired() " << endl;
130 if (module->uwsmartofdm_debug)
131 cout << NOW <<
" UWSmartOFDM (" <<
module->addr
132 << ") CTS TIMER EXPIRED" << endl;
134 module->RTSvalid = true;
135 module->refreshReason(UWSMARTOFDM_REASON_CTS_BACKOFF_TIMEOUT);
136 if (module->current_rcvs == 0)
139 if (module->uwsmartofdm_debug)
140 cout << NOW <<
" UWSmartOFDM (" <<
module->addr
141 << ") CTStimer expire() current state = "
142 << module->status_info[module->curr_state]
143 << "; backoff expired, next state =
"
144 << module->status_info[UWSMARTOFDM_STATE_TX_RTS] << endl;
146 module->exitCTSBackoff();
147 module->Mac2PhySetTxBusy(1);
148 module->stateSendRTS();
152 module->refreshState(UWSMARTOFDM_STATE_IDLE);
153 if (module->uwsmartofdm_debug)
155 << ") CTStimer
expire() current state =
"
156 << module->status_info[module->curr_state]
157 << "; backoff expired, next state =
"
158 << module->status_info[UWSMARTOFDM_STATE_IDLE] << endl;
162// While RTSvalid == false I can't be sending DATA
163// can only send CTS but in that case state is not IDLE
164void UWSmartOFDM::RTSTimer::expire(Event *e)
166 module->RTSvalid = true;
167 timer_status = UWSMARTOFDM_EXPIRED;
168 if (module->curr_state == UWSMARTOFDM_STATE_IDLE && module->current_rcvs == 0)
170 if (module->uwsmartofdm_debug)
172 << ") RTStimer
expire(), stateIDLE, sending RTS again " << std::endl;
178 if (module->uwsmartofdm_debug)
179 cout << NOW <<
" UWSmartOFDM (" <<
module->addr
180 << ") RTStimer expire(), BUT doing other stuff, keep going " << std::endl;
189 module->clearOccTable();
200 module->resetAssignment();
207 module->refreshReason(UWSMARTOFDM_REASON_DATAT_EXPIRED);
208 if (module->uwsmartofdm_debug)
209 cout << NOW <<
" UWSmartOFDM (" <<
module->addr
210 << ") DATATimer expire() " << std::endl;
212 if (module->current_rcvs == 0)
215 module->refreshState(UWSMARTOFDM_STATE_IDLE);
239 bind(
"HDR_size_", (
int *)&
HDR_size);
240 bind(
"ACK_size_", (
int *)&
ACK_size);
241 bind(
"RTS_size_", (
int *)&
RTS_size);
242 bind(
"CTS_size_", (
int *)&
CTS_size);
251 bind(
"alpha_", (
double *)&
alpha_);
255 bind(
"nodenum_", (
int *)&
nodeNum);
260 bind(
"MAC_addr_", (
int *)&addr);
263 bind(
"fullBand_", (
int *)&
fullBand);
281 Tcl &tcl = Tcl::instance();
284 if (strcasecmp(argv[1],
"setAckMode") == 0)
289 else if (strcasecmp(argv[1],
"setNoAckMode") == 0)
294 else if (strcasecmp(argv[1],
"initialize") == 0)
299 fout.open(
"/tmp/SMARTOFDMstateTransitions.txt", ios_base::app);
302 else if (strcasecmp(argv[1],
"printTransitions") == 0)
307 else if (strcasecmp(argv[1],
"getQueueSize") == 0)
312 else if (strcasecmp(argv[1],
"getUpLayersDataRx") == 0)
317 else if (strcasecmp(argv[1],
"getAckPktsTx") == 0)
319 tcl.resultf(
"%d", getAckPktsTx());
322 else if (strcasecmp(argv[1],
"getHighPrioPktsSent") == 0)
327 else if (strcasecmp(argv[1],
"getHighPrioPktsRecv") == 0)
335 if (strcasecmp(argv[1],
"setMacAddr") == 0)
337 addr = atoi(argv[2]);
339 cout <<
"OFDM Aloha MAC address of current node is " << addr << endl;
342 if (strcasecmp(argv[1],
"addInvalidCarriers") == 0)
346 cout <<
"Carrier " << atoi(argv[2]) <<
" not usable " << endl;
352 if (strcasecmp(argv[1],
"init_macofdm_node") == 0)
358 return MMac::command(argc, argv);
368 system(
"rm -f /tmp/SMARTOFDMstateTransitions.txt");
369 system(
"touch /tmp/SMARTOFDMstateTransitions.txt");
407 "DATA dropped due to max tx rounds";
448 std::vector<int> temp;
459 std::vector<double> temp;
487 sumrtt2 += curr_rtt * curr_rtt;
500 cout << NOW <<
" UWSmartOFDM (" << addr
501 <<
")::updateAckTimeout() curr ACK_timeout = " <<
ACK_timeout
519 incrTotalBackoffTimes();
520 double random = RNG::defaultrng()->uniform_double();
527 double backoff_duration =
530 backoffSumDuration(backoff_duration);
534 cout << NOW <<
" UWSmartOFDM (" << addr
535 <<
")::getBackoffTime() backoff time = " << backoff_duration
538 return backoff_duration;
545 Packet *temp_data_pkt;
546 map<pktSeqNum, Packet *>::iterator it_p;
553 temp_data_pkt = ((*it_p).second)->copy();
555 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
560 temp_data_pkt = Packet::alloc();
561 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
567 temp_data_pkt = Packet::alloc();
568 hdr_cmn *ch = HDR_CMN(temp_data_pkt);
571 duration = Mac2PhyTxDuration(temp_data_pkt);
572 Packet::free(temp_data_pkt);
582 hdr_cmn *ch = hdr_cmn::access(p);
584 std::cout << NOW <<
" UWSmartOFDM (" << addr <<
")::recvFromUpperLayers received packet seq_num = " << ch->uid() << std::endl;
594 hdr_mac *mach = HDR_MAC(p);
598 msgDisp.
printStatus(
"car_assigned = FALSE sending RTS",
"recvFromUpperLayers", NOW, addr);
604 msgDisp.
printStatus(
"New data but car_assigned = TRUE",
"recvFromUpperLayers", NOW, addr);
609 msgDisp.
printStatus(
"New data but RTS_valid = FALSE and car_assigned = FALSE",
"recvFromUpperLayers", NOW, addr);
620 incrDiscardedPktsTx();
628 hdr_cmn *ch = hdr_cmn::access(p);
629 hdr_mac *mach = HDR_MAC(p);
630 hdr_MPhy *ph = HDR_MPHY(p);
636 std::cout << NOW <<
" UWSmartOFDM (" << addr <<
")::initPkt() for a " <<
pkt_type_info[type] <<
" packet " << p <<
" seq_num " << ch->uid() <<
" size " << ch->size() << std::endl;
644 int curr_size = ch->size();
652 mach->ftype() = MF_DATA;
662 mach->ftype() = MF_ACK;
663 mach->macSA() = addr;
664 mach->macDA() = dest_addr;
673 mach->ftype() = MF_RTS;
674 mach->macSA() = addr;
675 mach->macDA() = dest_addr;
688 mach->ftype() = MF_CTS;
689 mach->macSA() = addr;
690 mach->macDA() = dest_addr;
698 for (std::size_t i = 0; i <
ctrl_car; ++i)
711 ofdmph->
carMod[i] =
"BPSK";
717 hdr_cmn *ch = hdr_cmn::access(p);
718 hdr_mac *mach = HDR_MAC(p);
721 cout << NOW <<
" UWSmartOFDM (" << addr
722 <<
")::Mac2PhyStartTx() _DBG_ start tx packet type " << ch->ptype()
723 <<
", seq num = " << ch->uid()
724 <<
", source addr = " << mach->macSA()
725 <<
", dest addr = " << mach->macDA()
728 MMac::Mac2PhyStartTx(p);
749 cout << NOW <<
" UWSmartOFDM (" << addr
750 <<
")::Phy2MacEndTx() DATA sent,from "
760 cout << NOW <<
" UWSmartOFDM (" << addr
761 <<
")::Phy2MacEndTx() DATA sent, from "
775 cout << NOW <<
" UWSmartOFDM (" << addr
776 <<
")::Phy2MacEndTx() ack sent, from "
789 cout << NOW <<
" UWSmartOFDM (" << addr
790 <<
")::Phy2MacEndTx() RTS sent, from "
802 cout << NOW <<
" UWSmartOFDM (" << addr
803 <<
")::Phy2MacEndTx() CTS sent, from "
814 cout << NOW <<
" UWSmartOFDM (" << addr
815 <<
")::Phy2MacEndTx() logical error, current state = "
828 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::Phy2MacStartRx() rx Packet. current_rcvs = " <<
current_rcvs << endl;
833 hdr_cmn *ch = HDR_CMN(p);
834 packet_t rx_pkt_type = ch->ptype();
835 hdr_mac *mach = HDR_MAC(p);
836 MacFrameType frame_type = mach->ftype();
837 hdr_MPhy *ph = HDR_MPHY(p);
840 int source_mac = mach->macSA();
841 int dest_mac = mach->macDA();
843 double gen_time = ph->txtime;
844 double received_time = ph->rxtime;
845 double diff_time = received_time - gen_time;
850 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::Phy2MacEndRx() _DBG_ "
852 <<
", received a pkt type = " << ch->ptype()
853 <<
", seq num = " << ch->uid()
854 <<
", src addr = " << mach->macSA()
855 <<
" dest addr = " << mach->macDA()
856 <<
", estimated distance between nodes = " << distance <<
" m. "
872 if (dest_mac == addr || dest_mac == MAC_BROADCAST)
875 if (frame_type == MF_ACK)
880 else if (frame_type == MF_CTS)
901 else if (frame_type == MF_RTS)
926 if (frame_type != MF_RTS && frame_type != MF_CTS && frame_type != MF_ACK && frame_type != MF_DATA)
928 cerr << NOW <<
" UWSmartOFDM (" << addr <<
")::Phy2MacEndRx Unrecognized packet addressed to me" << std::endl;
961 if (frame_type == MF_CTS)
964 msgDisp.
printStatus(
"PKT NOT FOR ME 555x, UPDATING TABLE drop",
"Phy2MacEndRx", NOW, addr);
995 if (frame_type != MF_RTS && frame_type != MF_CTS && frame_type != MF_ACK && frame_type != MF_DATA)
1011 if (frame_type == MF_RTS)
1040 Packet *ack_pkt = Packet::alloc();
1051 Packet *rts_pkt = Packet::alloc();
1072 RTS_Backoff = abs(
nextFreeTime - NOW + ((
double)rand() / (RAND_MAX)) * amp);
1074 RTS_Backoff = abs(((
double)rand() / (RAND_MAX)) * amp);
1076 RTS_Backoff = RTS_Backoff == 0 ? ((double)rand() / (RAND_MAX)) : RTS_Backoff;
1077 msgDisp.
printStatus(
"all carriers unavailable, back to Idle. Next RTS in " + std::to_string(RTS_Backoff),
"txRTS", NOW, addr);
1081 Packet::free(rts_pkt);
1088 int top_car, bot_car;
1089 int top_avoid_car, bot_avoid_car;
1092 Packet *cts_pkt = Packet::alloc();
1101 string myfreecar = std::to_string(NOW) +
" UWSmartOFDM (" + std::to_string(addr) +
")::txCTS() MY FREE CARRIERS: ";
1102 string otherfreecar =
" INCOMING FREE CARRIERS: ";
1103 string matchingcar =
" MATCHING CARRIERS: ";
1109 myfreecar += std::to_string(myFree[i]) +
" ";
1110 otherfreecar += std::to_string(otherFree[i]) +
" ";
1114 std::cout << myfreecar <<
"-" << otherfreecar <<
"-> " << n_match << matchingcar << std::endl;
1121 double ackOffset = 0;
1124 double tneeded = (8 * (double)brequested / (n_match *
bitrateCar)) + ackOffset;
1140 Packet::free(cts_pkt);
1150 map<pktSeqNum, AckTimer>::iterator it_a;
1155 if (((*it_a).second).isActive())
1160 else if (((*it_a).second).isExpired())
1167 cerr << NOW <<
" UWSmartOFDM (" << addr
1168 <<
")::stateCheckAckExpired() ack_timer logical error, current "
1197 cerr << NOW <<
" UWSmartOFDM (" << addr
1198 <<
")::stateCheckBackoffExpired() backoff_timer logical error, "
1199 "current timer state = "
1228 cerr << NOW <<
" UWSmartOFDM (" << addr
1229 <<
")::stateCheckCTSBackoffExpired() CTS_timer logical error, "
1230 "current timer state = "
1253 map<pktSeqNum, Packet *>::iterator it_p;
1255 next_p = (*it_p).second;
1257 hdr_mac *mach = HDR_MAC(next_p);
1297 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::stateSendRTS() max_tries " <<
max_rts_tries <<
" curr_tries " <<
curr_rts_tries << std::endl;
1299 msgDisp.
printStatus(
"Going back to Idle, rts_tries > max",
"stateSendRTS", NOW, addr);
1306 map<pktSeqNum, Packet *>::iterator it_p;
1312 incrDroppedPktsTx();
1333 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::stateRxRTS() Interrupting previous receptions " << endl;
1351 hdr_mac *mach = HDR_MAC(p);
1380 string txcarriers =
"Going to transmit. mac_carVec = ";
1398 msgDisp.
printStatus(
"Other receptions ongoing, just keep doing them",
"stateRxCTS", NOW, addr);
1412 hdr_mac *mach = HDR_MAC(p);
1413 int dst_addr = mach->macSA();
1414 hdr_cmn *ch = hdr_cmn::access(p);
1432 double CTSBackoff = ((double)rand() / (RAND_MAX)) / 1.6 * (
curr_rts_tries);
1433 CTSBackoff = CTSBackoff + 0.16;
1438 msgDisp.
printStatus(
"SCHEDULING CTS BACKOFF of " + std::to_string(CTSBackoff),
"stateBackoffCTS", NOW, addr);
1489 map<pktSeqNum, Packet *>::iterator it_p;
1494 map<pktSeqNum, AckTimer>::iterator it_a;
1502 ((*it_a).second).resetCounter();
1510 for (std::size_t i = 0; i <
mac_carVec.size(); ++i)
1526 ((*it_a).second).resetCounter();
1538 for (std::size_t i = 0; i <
mac_carVec.size(); ++i)
1551 incrDroppedPktsTx();
1574 map<pktSeqNum, AckTimer>::iterator it_a;
1577 ((*it_a).second).stop();
1584 ((*it_a).second).incrCounter();
1601 msgDisp.
printStatus(
"dest_addr = " + std::to_string(dest_addr),
"stateTxAck", NOW, addr);
1613 msgDisp.
printStatus(
"DATA_timer canceled because DATA received",
"stateRxData", NOW, addr);
1619 hdr_mac *mach = HDR_MAC(data_pkt);
1620 int dst_addr = mach->macSA();
1622 hdr_cmn *ch = hdr_cmn::access(data_pkt);
1623 packet_t rx_pkt_type = ch->ptype();
1625 ch->size() = ch->size() -
HDR_size;
1663 map<pktSeqNum, AckTimer>::iterator it_a;
1666 ((*it_a).second).stop();
1699 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::printStateInfo() "
1722 std::string response;
1723 std::cout <<
"Press Enter to continue";
1724 std::getline(std::cin, response);
1738 double old_thr = 10.0;
1740 std::vector<int> new_nouse;
1760 new_nouse.push_back(i);
1761 msgDisp.
printStatus(to_string(i) +
" Added to InterfTable",
"updateInterfTable", NOW, addr);
1765 std::string st =
"nouse_carriers : ";
1784 int assigned_done = 0;
1792 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::carToBeUsed() for HIGH prio " << carToGive << endl;
1800 top = bottom + carToGive - 1;
1808 top = bottom + carToGive - 1;
1817 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::carToBeUsed() for LOW prio " << carToGive << endl;
1825 bottom = top - carToGive + 1;
1833 bottom = top - carToGive + 1;
1837 cout << NOW <<
" UWSmartOFDM (" << addr <<
")::carToBeUsed() end of top_car is " << top <<
" bottom_car is " << bottom << endl;
1840 for (i = bottom; i <= top; i++)
1858 freeCar[nextFree] = i;
1875 if ((myFree[i] == otherFree[j]) && (myFree[i] != -1))
1877 matching[mindex] = myFree[i];
1886 for (
int k = mindex; k <
data_car; k++)
1898 if (busyCar[i] >= 0)
1900 for (
int j = 0; j < ntslots; j++)
1924 std::cout << NOW <<
" UWSmartOFDM (" << addr <<
")::resetAssignment: car_assignment = FALSE " << std::endl;
1938 std::cout << NOW <<
" UWSmartOFDM (" << addr <<
")::Occupancy Table: (current oTableIndex " <<
oTableIndex <<
")" << std::endl;
1939 std::cout << st << std::endl;
ClMsgUwPhyTxBusy should be and used to ask either to set or get the transmitting busy variable of a s...
void setGetOp(int)
method to return the transmitting power
void setTxBusy(int powr)
method to set the transmitting busy variable
void initDisplayer(int n, std::string pn, int pactive)
void printStatus(std::string st, std::string fxName, double now, int addr)
Class that describe the binding with tcl scripting language.
TclObject * create(int, const char *const *)
UWSMARTOFDMModuleClass()
Constructor of the class.
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.
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.
virtual void expire(Event *e)
What a node is going to do when a timer expire.
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.
bool isFrozen()
It tells whether the timer is in freeze mode or not.
bool isExpired()
Tells whether the timer is expired 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.
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 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.
int HDR_size
Size of the HDR if any.
int uwsmartofdm_debug
Debuging Flag.
void printOccTable()
prints on terminal the table
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.
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_NO_ACK_MODE
void removeInvalidCarrier(int c)
virtual void stateRxAck(Packet *p)
The node comes to this state if it receives an ACK packet.
void updateInterfTable(Packet *p)
virtual void stateWaitData(double t)
@ UWSMARTOFDM_STATE_ACK_RX
@ UWSMARTOFDM_STATE_RX_CTS
@ UWSMARTOFDM_STATE_BACKOFF
@ UWSMARTOFDM_STATE_TX_CTS
@ UWSMARTOFDM_STATE_TX_ACK
@ 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_RTS
@ UWSMARTOFDM_STATE_TX_RTS
@ 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.
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.
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 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.
map< pktSeqNum, Packet * > mapPacket
Container where Data packets are stored.
void resetAssignment()
resets value of car_assigned to FALSE
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.
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.
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_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.
virtual void stateCheckAckExpired()
It checks whether the ack timer is already expired while it was busy with other activities.
@ 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 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.
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.
UWSMARTOFDM_PKT_TYPE
Enumeration class of UWSmartOFDM packet type.
@ UWSMARTOFDM_DATAMAX_PKT
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.
Header of the OFDM message with fields to implement a multi carrier system.
int usage_carriers[MAX_AVAL_CAR]
int bytesToSend
Vector with available carriers. fields are -1 if no more carriers are available (1 byte for now)
Header of the OFDM message with fields to implement a multi carrier system.
int carriers[MAX_CARRIERS]
string carMod[MAX_CARRIERS]
UWSMARTOFDMModuleClass class_module_uwsmartofdm
@ SESSION_DISTANCE_NOT_SET
Your can find the description of this protocol in the paper, named "A Reservation-based Adaptive MAC ...
#define UWSMARTOFDM_DROP_REASON_ERROR
#define UWSMARTOFDM_DROP_REASON_BUFFER_FULL
#define UWSMARTOFDM_DROP_REASON_WRONG_RECEIVER
std::pair< int, int > counter
counter of collisions
#define HDR_OFDMMAC(p)
alias defined to access the PROBE HEADER
#define HDR_OFDM(p)
alias defined to access the PROBE HEADER
Definition of ClMsgUwMmac class.