61 : TclClass(
"Module/UW/POLLING/AUV")
82std::map<Uwpolling_AUV::UWPOLLING_AUV_STATUS, std::string>
84std::map<Uwpolling_AUV::UWPOLLING_AUV_REASON, std::string>
86std::map<Uwpolling_AUV::UWPOLLING_PKT_TYPE, std::string>
98 , curr_trigger_packet(0)
100 , curr_data_packet(0)
101 , curr_probe_packet(0)
102 , curr_tx_data_packet(0)
107 , modem_data_bit_rate(900)
108 , DATA_POLL_guard_time_(0)
110 , curr_state(UWPOLLING_AUV_STATUS_IDLE)
111 , prev_state(UWPOLLING_AUV_STATUS_IDLE)
112 , RxDataEnabled(false)
113 , RxProbeEnabled(false)
117 , curr_polled_node_address(0)
122 , wrong_node_data_sent(0)
134 , N_dropped_probe_pkts(0)
135 , n_dropped_ack_pkts(0)
136 , N_dropped_probe_wrong_state(0)
138 , max_buffer_size(50)
140 , curr_is_sink(false)
148 , enable_adaptive_backoff(false)
149 , backoff_LUT_file(
"")
150 , lut_token_separator(
',')
153 , full_knowledge(false)
158 bind(
"T_min_", (
double *) &
T_min);
159 bind(
"T_max_", (
double *) &
T_max);
160 bind(
"T_guard_", (
double *) &
T_guard);
166 bind(
"n_run_", (
int *) &
n_run);
173 mac2phy_delay_ = 5e-3;
187 Tcl &tcl = Tcl::instance();
189 if (strcasecmp(argv[1],
"initialize") == 0) {
193 }
else if (strcasecmp(argv[1],
"run") == 0) {
196 }
else if (strcasecmp(argv[1],
"stop_count_time") == 0) {
199 }
else if (strcasecmp(argv[1],
"GetTotalReceivingTime") == 0) {
202 }
else if (strcasecmp(argv[1],
"getTriggerSent") == 0) {
205 }
else if (strcasecmp(argv[1],
"getWrongNodeDataSent") == 0) {
208 }
else if (strcasecmp(argv[1],
"getProbeReceived") == 0) {
211 }
else if (strcasecmp(argv[1],
"getPollSent") == 0) {
214 }
else if (strcasecmp(argv[1],
"getDroppedProbePkts") == 0) {
217 }
else if (strcasecmp(argv[1],
"getDroppedProbeWrongState") == 0) {
221 }
else if (argc == 3) {
222 if (strcasecmp(argv[1],
"setMacAddr") == 0) {
223 addr = atoi(argv[2]);
225 std::cout <<
"UWPOLLING MAC address of the AUV is " << addr
228 }
else if (strcasecmp(argv[1],
"getRxFromNode") == 0) {
229 tcl.resultf(
"%d",
getRxPkts(atoi(argv[2])));
231 }
else if (strcasecmp(argv[1],
"set_adaptive_backoff_LUT") == 0) {
236 fprintf(stderr,
"Uwpolling_AUV::LUT file not opened");
239 }
else if (strcasecmp(argv[1],
"setLUTSeparator") == 0) {
244 return MMac::command(argc, argv);
249 ifstream input_file_;
254 if (input_file_.is_open()) {
257 while (std::getline(input_file_, line_)) {
258 ::std::stringstream line_stream(line_);
308 if (it->first == n_n) {
314 double n_low = it->first;
315 double b_low = it->second;
316 double n_up = (++it)->first;
317 double b_up = it->second;
319 n_n, n_low, n_up, b_low, b_up);
320 T_max = optimal_backoff;
328 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
329 <<
")::getMaxBackoffTime::N_probe_rx="
332 <<
"::estimate_N_neighbor:" << n_n
333 <<
"::optimal_backoff:" <<
T_max
340 double x,
double x1,
double x2,
double y1,
double y2)
342 double m = (y1 - y2) / (x1 - x2);
343 double q = y1 - m * x1;
352 return MMac::crLayCommand(m);
360 std::cout <<
module->getEpoch() << "::" << NOW << "::Uwpolling_AUV(" << module->addr
361 << ")::DATA_TIMER::EXPIRED::Packet_received:"
362 << module->packet_index
363 << "::TOT_PACKET_EXPECTED:" << module->N_expected_pkt
366 module->DataTOExpired();
374 std::cout <<
module->getEpoch() << "::" << NOW << "::Uwpolling_AUV(" << module->addr
375 << ")::PROBE_TIMER::EXPIRED" << std::endl;
376 module->ProbeTOExpired();
383 std::cout <<
module->getEpoch() << "::" << NOW << "::Uwpolling_AUV(" << module->addr
384 << ")::ACK_TIMER::EXPIRED" << std::endl;
385 module->ackTOExpired();
393 std::cout <<
module->getEpoch() << "::" << NOW << "::Uwpolling_AUV(" << module->addr
394 << ")::POLL_TIMER::EXPIRED" << std::endl;
395 module->ChangeNodePolled();
416 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
417 <<
")::PROBE_TIMER::NO_PROBE_RX" << std::endl;
434 MMac::Mac2PhyStartTx(p);
442 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
443 <<
")::TX_TRIGGER::T_max= " <<
T_max <<
" T_min = " <<
T_min
445 Packet *p = Packet::alloc();
446 hdr_cmn *cmh = hdr_cmn::access(p);
447 hdr_mac *mach = HDR_MAC(p);
450 mach->set(MF_CONTROL, addr, MAC_BROADCAST);
451 mach->macSA() = addr;
452 mach->macDA() = MAC_BROADCAST;
460 <<
"::Uwpolling_AUV(" << addr <<
")::TX_TRIGGER_ID_"
473 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV (" << addr <<
")::TX_TRIGGER"
483 hdr_cmn *cmh = hdr_cmn::access(p);
487 }
else if (cmh->ptype() ==
PT_POLL) {
495 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
496 <<
")::LAST_DATA_PKTS_TX" << std::endl;
514 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
515 <<
")::scheduling_PROBE_TIMER_T= " <<
T_probe << std::endl;
518 cerr <<
"Scheduling PROBE timer ----> negative value " <<
T_probe
532 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
533 <<
")STATE_WAIT_DATA::Data_Timer = " << data_timer_value
543 double timer_value = 0;
551 if (timer_value <= 0) {
554 cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
555 <<
")::WARNING::Data Timer Value <= 0. Setting to 20 sec"
565 hdr_cmn *cmh = hdr_cmn::access(p);
568 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
569 <<
")::PHY2MACSTARTRX::PROBE_PACKET" << std::endl;
572 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
573 <<
")::PHY2MACSTARTRX::ACK_PACKET" << std::endl;
576 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
577 <<
")::PHY2MACSTARTRX::DATA_PACKET" << std::endl;
584 hdr_cmn *cmh = hdr_cmn::access(p);
585 hdr_mac *mach = HDR_MAC(p);
586 hdr_MPhy *ph = hdr_MPhy::access(p);
587 int dest_mac = mach->macDA();
588 double gen_time = ph->txtime;
589 double received_time = ph->rxtime;
590 double diff_time = received_time - gen_time;
595 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
596 <<
")::PHY2MACENDRX_DROP_POLL" << endl;
599 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
600 <<
")::PHY2MACENDRX_DROP_PROBE_FROM_" << mach->macSA()
604 << NOW <<
"::Uwpolling_AUV(" << addr
605 <<
")::PHY2MACENDRX::DROP_PROBE_FROM_NODE_"
606 << mach->macSA() << endl;
611 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
612 <<
")::PHY2MACENDRX_DROP_ACK" << endl;
616 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
617 <<
")::PHY2MACENDRX_DROP_TRIGGER" << endl;
620 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
621 <<
")::PHY2MACENDRX::DROP_DATA_FROM_NODE_"
622 << mach->macSA() << endl;
625 << NOW <<
"Uwpolling_AUV(" << addr
626 <<
")::PHY2MACENDRX::DROP_DATA_FROM_NODE_"
627 << mach->macSA() << endl;
633 if ((dest_mac == addr) || (dest_mac == (
int) MAC_BROADCAST)) {
642 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
643 <<
")::PHY2MACENDRX::PROBE, probe rtt"<< 2*
probe_rtt << std::endl;
669 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
670 <<
")::PHY2MACENDRX::DROP_DATA_WRONG_DEST_"
671 << mach->macDA() << endl;
675 <<
"::Uwpolling_AUV(" << addr
676 <<
")::PHY2MACENDRX::DROP_DATA_WRONG_DEST_"
677 << mach->macDA() << endl;
688 fuzzy_pkt = Packet::alloc();
691 hdr_cmn *cmh = HDR_CMN(fuzzy_pkt);
692 hdr_mac *mach = HDR_MAC(fuzzy_pkt);
693 mach->macSA() = addr;
695 Tpoll = Mac2PhyTxDuration(fuzzy_pkt);
698 hdr_cmn *cmh = HDR_CMN(fuzzy_pkt);
699 hdr_mac *mach = HDR_MAC(fuzzy_pkt);
700 mach->macSA() = addr;
702 Tprobe = Mac2PhyTxDuration(fuzzy_pkt);
705 hdr_cmn *cmh = HDR_CMN(fuzzy_pkt);
707 hdr_mac *mach = HDR_MAC(fuzzy_pkt);
708 mach->macSA() = addr;
710 Ttrigger = Mac2PhyTxDuration(fuzzy_pkt);
713 hdr_cmn *cmh = HDR_CMN(fuzzy_pkt);
714 hdr_mac *mach = HDR_MAC(fuzzy_pkt);
715 mach->macDA() = addr;
717 Tdata = Mac2PhyTxDuration(fuzzy_pkt);
720 Packet::free(fuzzy_pkt);
728 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
729 <<
")::UPDATE_RTT--->RTT = " <<
curr_RTT << std::endl;
739 int mac_sa = mach->macSA();
742 <<
"::Uwpolling_AUV(" << addr
743 <<
")::STATE_RX_DATA::RX_DATA_ID_" << cbrh->
sn_
744 <<
"_FROM_NODE_" << mach->macSA() << endl;
747 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
748 <<
")::STATE_RX_DATA::RX_DATA_ID_" << cbrh->
sn_
749 <<
"_FROM_NODE_" << mach->macSA() << endl;
764 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
766 <<
"_FROM_NODE_" << mac_sa << endl;
772 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
773 <<
")::STATE_RX_DATA::DROP_DATA_WRONG_NODE_"
774 << mach->macSA_ << std::endl;
777 <<
"::Uwpolling_AUV(" << addr
778 <<
")::STATE_RX_DATA::DROP_DATA_FROM_NODE_"
779 << mach->macDA() <<
"_NOT_POLLED" << endl;
786 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
787 <<
")::STATE_RX_DATA::DROP_DATA_WRONG_STATE="
791 <<
"::Uwpolling_AUV(" << addr
792 <<
")::STATE_RX_DATA::DROP_DATA_FROM_NODE_"
793 << mac->macDA() <<
"_NOT_POLLED" << endl;
803 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
804 <<
")::CHANGE_NODE_POLLED::" << std::endl;
833 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
834 <<
")::STATE_RX_PROBE"
835 <<
"::N_packet_expected=" << probeh->
n_pkts_
842 <<
"::Uwpolling_AUV(" << addr <<
")::RX_PROBE_ID_"
844 << mach->macSA() << endl;
857 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
858 <<
")::STATE_RX_PROBE_SINK"
860 <<
"::ACK_ID=" << probeh->
id_ack_
865 <<
"::Uwpolling_AUV(" << addr <<
")::RX_PROBE_ID_"
867 << mach->macSA() << endl;
871 std::cerr <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
872 <<
"wrong packet type" << std::endl;
887 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
888 <<
"):: dropping Probe Wrong State "
900 Packet *p = Packet::alloc();
901 hdr_cmn *cmh = hdr_cmn::access(p);
902 hdr_mac *mach = HDR_MAC(p);
905 mach->set(MF_CONTROL, addr, MAC_BROADCAST);
906 mach->macSA() = addr;
907 mach->macDA() = MAC_BROADCAST;
917 <<
"::Uwpolling_AUV(" << addr <<
")::TX_POLL_ID_"
921 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
922 <<
")::STATE_TX_POLL::Node polled = " << pollh->
id_
927 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
928 <<
")::STATE_TX_POLL--->IDLE--->No node to POLL"
934 std::cerr <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
935 <<
")---> going in stateTxPoll from WRONG STATE---> "
945 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr <<
")::TX_POLL"
956 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr <<
")::SORT_NODE_TO_POLL "
965 n_pkts += (*it).n_pkts;
987 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr <<
")::IDLE STATE "
1003 std::stringstream stat_file;
1004 stat_file <<
"./Uwpolling_AUV_" << addr <<
"_" <<
n_run <<
".out";
1005 out_file_stats.open(stat_file.str().c_str(), std::ios_base::app);
1007 <<
"::Uwpolling_AUV(" << addr <<
")::NS_START" << endl;
1015 "Transmitting a TRIGGER Packet";
1028 "Received a PROBE packet";
1033 "Last Packet Received from the Node";
1035 "Last Node from the list Polled";
1037 "Maximum Number of Probe Received";
1040 "Receiving PROBE Time-Out";
1046 std::string response;
1047 std::cout <<
"Press Enter to continue";
1048 std::getline(std::cin, response);
1069 std::cout <<
getEpoch() <<
"::" << NOW <<
"::UWPOLLING_AUV(" << addr
1070 <<
")::RECV_FROM_U_LAYERS_ID_" << cbrh->
sn_
1074 <<
"::Uwpolling_AUV(" << addr
1075 <<
")::RECV_FROM_U_LAYERS_ID_" << cbrh->
sn_ << endl;
1078 hdr_cmn* ch = HDR_CMN(p);
1084 <<
"::Uwpolling_AUV(" << addr <<
")::DROP_FULL_QUEUE"
1087 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1088 <<
")::DROP_FULL_QUEUE" << std::endl;
1089 incrDiscardedPktsTx();
1104 std::cout <<
getEpoch() <<
"::" << NOW <<
"::UWPOLLING_AUV(" << addr
1105 <<
")::NO_PKTS_TO_TX, TX BUFFER IS EMPTY" << std::endl;
1109 std::deque<Packet*>::iterator it =
tx_buffer.begin();
1116 std::cout <<
getEpoch() <<
"::" << NOW <<
"::UWPOLLING_AUV(" << addr
1128 std::cout <<
getEpoch() <<
"::" << NOW <<
"::UWPOLLING_AUV(" << addr
1129 <<
")::NO_PKTS_TO_TX, TX BUFFER IS EMPTY" << std::endl;
1136 std::deque<Packet*>::iterator it =
tx_buffer.begin();
1144 std::cout <<
getEpoch() <<
"::" << NOW <<
"::UWPOLLING_AUV(" << addr
1158 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1160 <<
" Est_rtt= " << est_rtt_ack << std::endl;
1194 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr <<
")::TX_DATA"
1207 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1208 <<
")::stateWaitAck"<< std::endl;
1216 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1217 <<
")::stateAckRx()ACK received" << std::endl;
1233 std::vector<uint16_t> & ack_list = ackh->
id_ack();
1237 if (ack_list.front() == auvh_tmp->
pkt_uid()+1) {
1239 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1240 <<
")::handleAck()::NO_ERROR" << std::endl;
1252 if(std::find(ack_list.begin(),ack_list.end(),auvh->
pkt_uid())
1253 != ack_list.end()) {
1255 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1256 <<
")::handleAck()::RX_ACK,PKT_ID"
1257 << auvh->
pkt_uid()<< std::endl;
1270 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1271 <<
")::handleNoAck()::reinsert pkts in tx buffer" << std::endl;
1289 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1290 <<
")::handleProbeAck()::rx ACK in probe pkt,no error"
1299 std::cout <<
getEpoch() <<
"::" << NOW <<
"::Uwpolling_AUV(" << addr
1300 <<
")::handleProbeAck()::rx ACK in probe pkt,ack_id = "
1301 << probeh->
id_ack() << std::endl;
1364 double poll_time = 0;
1372 poll_time += (std::min((uint)
tx_buffer.size()+
1380 return (uint16_t)(std::ceil(poll_time));
1386 std::map<int,uint>::iterator it =
rx_pkts_map.find(mac_addr);
ClMsgUwPhyGetLostPkts should be used by a layer to ask the phy how many packets it discarded from the...
uint getLostPkts()
method to return the number of packets lost by the phy.
Class that represents the binding with the tcl configuration script.
TclObject * create(int, const char *const *)
Creates the TCL object needed for the tcl language interpretation.
UwpollingModule_AUV_Class()
Constructor of the class.
virtual void expire(Event *e)
Method call when the timer expire.
virtual void expire(Event *e)
Method called when the timer expire.
virtual void expire(Event *e)
Method call when the timer expire.
virtual void expire(Event *e)
Method call when the timer expire.
Uwpolling_AUV *UWPOLLING_TIMER_STATUS timer_status
< Pointer to an object of type Uwpolling_AUV
virtual void schedule(double val)
Schedules a timer.
Class used to represent the UWPOLLING MAC layer of the AUV.
std::deque< Packet * > tx_buffer
Queue of DATA in number of packets.
virtual void initInfo()
Prints a file with every state change for debug purposes.
virtual void Phy2MacStartRx(const Packet *p)
Method called when the Phy Layer start to receive a Packet.
PollTimer poll_timer
POLL Timer.
virtual void refreshState(UWPOLLING_AUV_STATUS state)
Refresh the state of the protocol.
Packet * curr_data_packet
Pointer to the current DATA packet.
virtual void ChangeNodePolled()
The first element of the list of nodes is trimmed and the next node is polled.
Packet * curr_tx_data_packet
Pointer to the current DATA packet.
Packet * curr_probe_packet
Pointer to the current PROBE packet.
probbed_node probbed_sink
Element with sink probe data.
void incrPollTx()
Incrase the number of POLL transmitted.
virtual uint16_t getPollTime()
Estimate the time needed by the AUV to POLL all the remaining node in the probbed node list.
int full_knowledge
Set to a number != 0 means we have full_knowledge about the estimate of neighbors.
void incrTriggerTx()
Increases the number of TRIGGER packets sent.
std::vector< probbed_node > list_probbed_node
list of nodes that have sent correctly the PROBE
virtual void handleNoAck()
Handle case with no ack received.
double Ttrigger
Time needed to transmit a TRIGGER packet.
virtual void Mac2PhyStartTx(Packet *p)
Pass the packet to the PHY layer.
int modem_data_bit_rate
Bit rate of the modem used.
virtual void TxTrigger()
Transmission of the TRIGGER packet.
uint n_tx_pkts
Number of packets transmitted by the AUV during a TxData session.
virtual void stop_count_time()
Informs the protocol to stop counting the time in which the AUV receive DATA packets from the nodes I...
std::string backoff_LUT_file
File name of the backoff LUT.
virtual void stateIdle()
IDLE state.
virtual void waitForUser()
Used for debug purposes.
uint POLL_uid
POLL Unique ID.
uint TRIGGER_uid
TRIGGER Unique ID.
double Tdata
Time needed to transmit a DATA packet.
static std::map< UWPOLLING_AUV_REASON, std::string > reason_info
Map the UWPOLLING_AUV_STATUS to the description of each state.
@ UWPOLLING_AUV_REASON_PACKET_ERROR
@ UWPOLLING_AUV_REASON_RX_DATA_TO
@ UWPOLLING_AUV_REASON_PROBE_TO_EXPIRED
@ UWPOLLING_AUV_REASON_PROBE_RECEIVED
@ UWPOLLING_AUV_REASON_TX_POLL
@ UWPOLLING_AUV_REASON_MAX_PROBE_RECEIVED
@ UWPOLLING_AUV_REASON_LAST_POLLED_NODE
@ UWPOLLING_AUV_REASON_LAST_PACKET_RECEIVED
@ UWPOLLING_AUV_REASON_DATA_RX
@ UWPOLLING_AUV_REASON_TX_TRIGGER
virtual void SortNode2Poll()
Method in which the node that has sent correctly the PROBE packet is sorted in order to give the prio...
virtual void stateRxProbe()
State of the protocol in which there's a reception of a PROBE packet.
double curr_Tmeasured
Time elapsed between the transmission of the TRIGGER and the reception of the PROBE packet by the pol...
AckTimer ack_timer
ACK Timer.
int sea_trial_
Sea Trial flag: To activate if the protocol is going to be tested at the sea.
virtual void DataTOExpired()
DATA TIMER is Expired.
static bool initialized
Map the UWPOLLING_AUV_REASON to the description of each reason.
double T_probe
Duration of PROBE TIMER.
virtual double linearInterpolator(double x, double x1, double x2, double y1, double y2)
Calculate the linear interpolation between two 2-D points.
double total_time
Total time in which the AUV has received data packets.
Packet * curr_ack_packet
Pointer to the current ACK packet.
int getDroppedProbeWrongState()
Return the number of PROBE packets discarded because sent after the maximum time allowed.
void incrDroppedAckPkts()
Increases the number of wrong ACK packet received.
virtual void UpdateRTT()
Update the RTT between a node and the AUV based on the time elapsed between the transmisison of the T...
int getProbeRx()
Returns the number of PROBE received during the simulation.
int getWrongNodeDataSent()
Returns the number of Data Packet sent by Nodes not polled (used for debug purposes)
int DATA_POLL_guard_time_
Guard time between the reception of the last data and the transmission of the following POLL.
uint max_buffer_size
Temp buffer where packets are insert waiting for an ACK.
double T_guard
Guard time added to the calculation of the RTT.
int getPollSent()
Return the number of POLL packets sent during the simulation.
uint16_t uid_tx_pkt
Unique ID of the transmitted packets.
uint curr_node_id
ID of the node polled.
uint n_pkts_to_tx
Number of packets to transmit during a TxData session.
virtual void computeTxTime(UWPOLLING_PKT_TYPE pkt)
Compute the Transmission Time for various type of packet using a CrossLayer Message to ask the PHY to...
virtual void Phy2MacEndRx(Packet *p)
Method called when the Phy Layer finish to receive a Packet.
virtual void stateTxData()
Handle the data transmission after poll reception.
int max_polled_node
Maximum number of node that the AUV can poll each time.
int ack_enabled
True if ack is enabled, false if disabled, default true.
bool curr_is_sink
True if the current node of the list is a sink.
virtual void ackTOExpired()
ACK TIMER is Expired.
void incrDroppedProbePkts()
Increases the number of wrong PROBE packet received.
bool RxProbeEnabled
true if the AUV is enabled to receive PROBE packets, false otherwise
double probe_rtt
RTT calculation between AUV and NODE based on the time of PROBE transmission and reception.
double Tpoll
Time needed to transmit a POLL packet.
double T_max
Maximum value in which the node can choose his backoff time.
bool enableAckRx
True if the ack reception is enabled.
int getTriggerTx()
Returns the number of TRIGGER sent during the simulation.
static std::map< UWPOLLING_PKT_TYPE, std::string > pkt_type_info
Map the UWPOLLING_PKT_TYPE to the description of each type of packet.
double T_min
Minimum value in which the node can choose his backoff time.
ProbeTimer probe_timer
PROBE Timer.
virtual void refreshReason(UWPOLLING_AUV_REASON reason)
Refresh the reason for the changing of the state.
std::map< int, uint > rx_pkts_map
Map (mac_addr,rx_pkts) with the received packets for each node.
int print_stats_
Print protocol's statistics of the protocol.
void incrWrongNodeDataSent()
Increases the number of DATA packets received from node that are not POLLED anymore (i....
static std::map< UWPOLLING_AUV_STATUS, std::string > status_info
probe_cicle_counters probe_counters
Number of probe detected in a round (i.e., prehamble received)
virtual void handleAck()
Handle a received ack, reinserting in the buffer the packet not received by the sink.
virtual void addNode2List()
Add a node to the list of probbed nodes.
virtual void stateWaitData()
State of the protocol in which the DATA timer is set up.
virtual void stateTxPoll()
State of the protocol in which a POLL packet is initialized.
virtual void stateWaitAck()
State of the protcol in which the ACK timer is set up.
void incrAckRx()
Increases the number of Ack packets received.
void incrDroppedProbeWrongState()
Increase the number of PROBEs packets dropped because the AUV was not in the RX_PROBE state.
virtual void stateTxTrigger()
State of the protocol in which a TRIGGER packet is initialized.
virtual void handleProbeAck()
Handle the ack received in the probe packet tx by the sink.
int getDroppedProbePkts()
Return the number of PROBE packets discarded because of wrong CRC.
virtual uint getRxPkts(int mac_addr)
Get the packets received from the node with the given mac address.
double pkt_time
Time needed to transmit a data packet.
Packet * curr_trigger_packet
true if the sink has been inserted in the list
bool RxDataEnabled
true if the AUV is enabled to receive DATA packets, false otherwise
virtual void stateAckRx()
Handle the recption of an ACK from the sink.
void incrProbeRx()
Increases the number of PROBE packets received.
uint16_t last_pkt_uid
ID of the last packet transmitted in the round.
DataTimer data_timer
Data timer.
virtual void recvFromUpperLayers(Packet *p)
Handle a packet coming from upper layers.
double stop_time
Time stamp in which the AUV finish to receive data packets.
uint max_tx_pkts
Max number of packets can be transmitted by the AUV during a TxData session.
double T_probe_guard
Guard time for PROBE packet: T_probe=T_max+T_probe_guard.
std::ofstream out_file_stats
Variable that handle the file in which the protocol write the statistics.
virtual void addSink2List()
Add a sink node to the list of probbed nodes.
UWPOLLING_AUV_STATUS curr_state
int max_payload
Duration of ACK_TIMER.
std::deque< Packet * > temp_buffer
double Tprobe
Time needed to transmit a PROBE packet.
int N_expected_pkt
Number of packets that the node polled wish to transmit to the AUV.
double initial_time
Timestamp in which the AUV receive the first data packet.
virtual void TxPoll()
Transmisssion of the POLL packet.
virtual void stateWaitProbe()
State of the protocol in which the PROBE timer is set up.
std::map< double, double > backoff_LUT
Map with the backoff LUT.
int packet_index
Variable that indicate the number of the packet that has been just received by the AUV.
virtual ~Uwpolling_AUV()
Destructor of the Uwpolling_AUV class.
virtual void ProbeTOExpired()
PROBE TIMER is Expired.
double GetTotalReceivingTime()
Permits to retrieve the total time in which the AUV has received DATA packets.
virtual double GetDataTimerValue()
Calculation of DATA TIMER value based on the number of packet that a node need to transmit,...
virtual void Phy2MacEndTx(const Packet *p)
Method called when the PHY layer finish to transmit the packet.
bool initBackoffLUT()
Initialize the backoff LUT.
bool acked
True if an ack has been received.
virtual void txData()
Transmit data transmission after poll reception.
int curr_polled_node_address
MAC address of the node polled.
@ UWPOLLING_AUV_STATUS_RX_DATA
@ UWPOLLING_AUV_STATUS_TX_DATA
@ UWPOLLING_AUV_STATUS_IDLE
@ UWPOLLING_AUV_STATUS_WAIT_ACK
@ UWPOLLING_AUV_STATUS_TX_TRIGGER
@ UWPOLLING_AUV_STATUS_RX_PROBES
@ UWPOLLING_AUV_STATUS_TX_POLL
@ UWPOLLING_AUV_STATUS_WAIT_DATA
@ UWPOLLING_AUV_STATUS_RX_ACK
@ UWPOLLING_AUV_STATUS_WAIT_PROBE
Uwpolling_AUV()
Constructor of the Uwpolling_AUV class.
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
unsigned long int getEpoch()
Calculate the epoch of the event.
int polling_index
Index of the node that the AUV is polling.
bool TxEnabled
true if the AUV is enabled to receive POLL packets, false otherwise
virtual void stateTx()
Handle the transmission after poll reception.
bool enable_adaptive_backoff
Set to true if backoff is chosen adaptively.
char lut_token_separator
LUT token separator.
bool begin
indicate the first PROBE received
virtual void stateRxData()
State of the protocol in which there's a reception of a DATA packet.
Packet * curr_poll_packet
Pointer to the current POLL packet.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
double curr_RTT
Round Trip time of the node polled.
double getMaxBackoffTime()
Reference to the backoff_time variable.
Header of the ACK sent by the SINK.
std::vector< uint16_t > & id_ack()
Reference to the id_ack_ variable.
Header of the data sent from AUV MULE to SINK.
uint16_t & last_pkt_uid()
Reference to the last_pkt_uid_ variable.
uint16_t & pkt_uid()
Reference to the pkt_uid_ variable.
Header of the POLL message.
int id_
ID of the POLLED node.
uint POLL_uid_
POLL packet unique ID.
Header of the PROBE message.
uint id_sink_
ID of the sink.
uint16_t & id_ack()
Reference to id_ack_ variable.
uint16_t id_ack_
ID used for ack purpose.
uint & id_sink()
Reference to id_sink variable.
uint PROBE_uid_
Unique ID of the PROBE packet.
Header of the PROBE message.
uint PROBE_uid_
Unique ID of the PROBE packet.
uint & id_node()
Reference to id_node variable.
uint16_t & ts()
Reference to timestamp variable.
int & n_pkts()
Reference to backoff_time variable.
uint id_node_
ID of the node.
int n_pkts_
Number of packets that the node wish to transmit to the AUV.
Header of the TRIGGER message.
uint TRIGGER_uid_
TRIGGER packet unique ID.
uint16_t & t_in()
Reference to the t_in variable.
uint16_t & t_fin()
Reference to the t_fin variable.
hdr_uwcbr describes UWCBR packets.
uint16_t sn_
Serial number of the packet.
Internal structure where the AUV store the informations about the node to POLL.
int n_pkts
Number of packets that the node transmit when he's polled.
double time_stamp
Timestamp of the most recent data packet generated by the node.
uint id_node
Id of the node.
double Tmeasured
Time elapsed between the transmisssion of the TRIGGER and the reception of the PROBE.
bool is_sink_
Ture if the probe comes from a sink.
uint16_t id_ack
Id used for ack purpose is the proebbed node is a sink.
double policy_weight
Weigth used to choose the order to poll the nodes.
int mac_address
Mac Address of the node.
uint n_probe_received
Number of probe received in a round (i.e., prehamble received)
uint n_probe_detected
Number of probe (prehamble) detected in a round by the MAC.
void incrementCounters()
Increment both counters.
void resetCounters()
Reset both counters.
uint getNumberOfNeighbors()
Get estimate number of neighbors.
Provides the UWCBR packets header description and the definition of the class UWCBR.
Definition of ClMsgUwMmac class.
UwpollingModule_AUV_Class class_module_uwpolling_auv
Class that represents the AUV of UWPOLLING.
#define UWPOLLING_AUV_DROP_REASON_WRONG_RECEIVER
Packet for another node.
#define UWPOLLING_AUV_DROP_REASON_BUFFER_FULL
#define UWPOLLING_AUV_DROP_REASON_WRONG_STATE
The AUV cannot receive this kind of packet in this state.
#define UWPOLLING_AUV_DROP_REASON_ERROR
Packet corrupted.
Common structures and variables in the protocol.
#define HDR_PROBE_SINK(p)
alias defined to access the ACK SINK HEADER
static const int MAX_POLLED_NODE
Maximum number of node to POLL.
#define HDR_ACK_SINK(p)
alias defined to access the ACK SINK HEADER
#define HDR_POLL(p)
alias defined to access the POLL HEADER
struct POLL_ID id_poll
Single location of the POLL vector.
#define HDR_AUV_MULE(p)
alias defined to access the AUV MULE HEADER
#define HDR_TRIGGER(p)
alias defined to access the TRIGGER HEADER \
#define HDR_PROBE(p)
alias defined to access the PROBE HEADER