51 hdr_cmn *cmh = hdr_cmn::access(p);
52 hdr_mac *mach = HDR_MAC(p);
53 int src_mac_addr = mach->macSA();
54 int dest_mac_addr = mach->macDA();
58 std::cout << NOW <<
"uwUFetch_NODE(" << addr
59 <<
")::Phy2MacEndRx()______________________dest_mac_addr "
60 << dest_mac_addr << std::endl;
63 if ((dest_mac_addr == addr) || (dest_mac_addr == MAC_BROADCAST)) {
69 std::cout << NOW <<
" uwUFetch_NODE (" << addr
70 <<
") ::Phy2MacEndRx() ---->HN has finished to "
72 <<
" TRIGGER packet from the AUV with MAC address: "
73 << src_mac_addr << std::endl;
77 <<
")::Phy2MacEndRx()______________________"
78 "Finished_to_rx_TRIGGER_pck"
79 <<
"_from_AUV(" << src_mac_addr <<
")."
93 while ((!
Q_data.empty()) &&
110 <<
")::Phy2MacEndRx()_________________"
111 "_______DATA_pck_tx:_source("
112 << mach->macSA() <<
")_"
113 <<
"destination(" << mach->macDA()
114 <<
")_id_pck:" << cbrh->
sn() <<
""
120 if ((cmh->error()) || (
Q_data_HN.empty())) {
124 std::cout << NOW <<
" uwUFetch_NODE (" << addr
125 <<
") ::Phy2MacEndRx() ---->TRIGGER packet "
127 <<
" is corrupted: DROP IT" << std::endl;
131 <<
")::Phy2MacEndRx()_________________"
132 "_______TRIGGER_rx_from_AUV("
134 <<
")_It_s_in_ERROR:IGNORE_It."
149 std::cout << NOW <<
" uwUFetch_NODE (" << addr
150 <<
") ::Phy2MacEndRx() ---->HN reset the "
164 std::cout << NOW <<
" uwUFetch_NODE (" << addr
165 <<
") ::Phy2MacEndRx() ---->HN is not "
167 <<
" the TRIGGER packet: DROP IT."
172 std::cout << NOW <<
" uwUFetch_NODE (" << addr
173 <<
") ::Phy2MacEndRx() ---->TRIGGER packet "
175 <<
" is not corrupted, but the HN has 0 DATA "
176 "packet enabled to tx to the AUV: DROP IT"
181 <<
")::Phy2MacEndRx()_________________"
182 "_______TRIGGER_rx_It_s_CORRECT_"
183 "but_0_DATA_to_tx:IGNORE_It."
197 std::cout << NOW <<
" uwUFetch_NODE (" << addr
198 <<
") ::Phy2MacEndRx() ---->HN reset the "
211 std::cout << NOW <<
" uwUFetch_NODE (" << addr
212 <<
") ::Phy2MacEndRx() ---->HN is not "
214 <<
" the TRIGGER packet: DROP IT."
221 std::cout << NOW <<
" uwUFetch_NODE (" << addr
222 <<
") ::Phy2MacEndRx() ---->Physical layer of HN "
224 <<
" address: " << dest_mac_addr
225 <<
" has finished to receive a TRIGGER packet"
226 <<
" from the AUV with MAC address: "
227 << src_mac_addr << std::endl;
231 << NOW <<
"uwUFetch_HEAD_NODE(" << addr
232 <<
")::Phy2MacEndRx()________________________"
233 "TRIGGER_rx_It_s_CORRECT_>=1_DATA_to_tx."
252 std::cout << NOW <<
" uwUFetch_NODE (" << addr
253 <<
") ::Phy2MacEndRx() ---->HN has finished to "
255 <<
" DATA packet from the NODE with MAC address: "
256 << src_mac_addr << std::endl;
262 <<
")::Phy2MacEndRx()________________________"
263 "End_to_rx_DATA_pck_"
264 <<
"from_SN(" << src_mac_addr <<
")."
270 std::cout << NOW <<
" uwUFetch_NODE( " << addr
271 <<
") ::Phy2MacEndRx() ---->DATA packet received "
273 <<
" is corrupted: DROP IT" << std::endl;
287 <<
")::Phy2MacEndRx()_____________________"
288 "___DATA_pck_rx_by_HN("
289 << addr <<
")_from_SN(" << src_mac_addr
290 <<
")_id_pck:" << cbrh->
sn() <<
""
291 <<
"_It_s_in_ERROR." << std::endl;
300 std::cout << NOW <<
" uwUFetch_NODE (" << addr
301 <<
") ::Phy2MacEndRx() ---->Physical layer of HN "
303 <<
" address: " << dest_mac_addr
304 <<
" has finished to receive a DATA packet"
306 <<
" from the NODE with MAC address: "
307 << src_mac_addr << std::endl;
326 std::cout << NOW <<
" uwUFetch_NODE (" << addr
327 <<
") ::Phy2MacEndRx() ---->The packet received is not "
329 <<
" DROP IT." << std::endl;
334 std::cout << NOW <<
" uwUFetch_NODE (" << addr
335 <<
") ::Phy2MacEndRx() ---->HN has finished to "
337 <<
" POLL packet from the HN with MAC address: "
338 << src_mac_addr <<
" .DROP IT" << std::endl;
345 std::cout << NOW <<
" uwUFetch_NODE (" << addr
346 <<
") ::Phy2MacEndRx() ---->HN has finished to "
348 <<
" PROBE packet from the SENSOR NODE with MAC "
350 << src_mac_addr <<
" .DROP IT" << std::endl;
354 <<
")::Phy2MacEndRx()________________________"
355 "Finished_to_rx_PROBE"
356 <<
"_pck_from_SN(" << src_mac_addr
357 <<
").Not_addressed_to_me:_IGNORE_IT."
365 std::cout << NOW <<
" uwUFetch_NODE (" << addr
366 <<
") ::Phy2MacEndRx() ---->HN has finished to "
368 <<
" TRIGGER packet from the AUV with MAC address ("
369 << src_mac_addr <<
").DROP IT" << std::endl;
373 <<
")::Phy2MacEndRx()________________________"
374 "Finished_to_rx_TRIGGER"
375 <<
"_pck_from_AUV(" << src_mac_addr
376 <<
")._Not_addressed_to_me:_IGNORE_IT."
384 std::cout << NOW <<
" uwUFetch_NODE (" << addr
385 <<
") ::Phy2MacEndRx() ---->HN has finished to "
387 <<
" DATA packet from the SENSOR NODE with MAC "
389 << src_mac_addr <<
" .DROP IT" << std::endl;
393 <<
")::Phy2MacEndRx()________________________"
394 "End_to_rx_DATA_pck_"
395 <<
"from_SN(" << src_mac_addr
396 <<
")._Not_addressed_to_me:_IGNORE_IT."
415 std::cout << NOW <<
" uwUFetch_NODE (" << addr
416 <<
") ::TRIGGER_rx() ---->HN reset the TRIGGER timer"
421 << NOW <<
"uwUFetch_HEAD_NODE(" << addr
422 <<
")::TRIGGER_rx()_________________________TRIGGER_rx_It_"
423 "s_CORRECT_and_>= 1_DATA_to_tx_and_enabled_to_rx_It."
459 <<
")::TRIGGER_rx()__________________________"
460 "PARAMETERS_of_TRIGGER_PACKET: "
464 <<
")::TRIGGER_rx()__________________________"
466 << mach->macSA() <<
"." << std::endl;
467 if (mach->macDA() == -1) {
470 <<
")::TRIGGER_rx()__________________________"
471 "Destination_Address:_BROADCAST."
476 <<
")::TRIGGER_rx()__________________________"
477 "Destination_Address:_"
478 << mach->macDA() << std::endl;
482 <<
")::TRIGGER_rx()__________________________MIN_"
483 "backoff_time_DATA_pck:_"
487 <<
")::TRIGGER_rx()__________________________MAX_"
488 "backoff_time_DATA_pck:_"
492 <<
")::TRIGGER_rx()__________________________MAX_"
493 "DATA_pck_want_rx_from_HN:_"
497 <<
")::TRIGGER_rx()__________________________DATA_"
498 "pck_would_like_to_tx_to_the_AUV:_"
499 <<
Q_data_HN.size() <<
"[pck]." << std::endl;
507 <<
")::TRIGGER_rx()__________________________"
508 "Backoff_timeout_choice:_"
516 std::cout << NOW <<
" uwUFetch_NODE (" << addr
517 <<
") ::TRIGGER_rx() ---->HN is not enabled to receive"
518 <<
" the TRIGGER packet: DROP IT." << std::endl;
522 << NOW <<
"uwUFetch_HEAD_NODE(" << addr
523 <<
")::TRIGGER_rx()_________________________TRIGGER_rx_It_"
525 "1_DATA_to_tx_and_not_enabled_to_rx_It:IGNORE_It."
530 << NOW <<
"uwUFetch_HEAD_NODE(" << addr
531 <<
")::TRIGGER_rx()__________________________Not_ENABLED"
532 <<
"_to_rx_TRIGGER_pck." << std::endl;
542 std::cout << NOW <<
" uwUFetch_NODE (" << addr
543 <<
") ::BCKTOExpired() ---->Back-off timeout is expired:"
544 <<
" so the first DATA packet can be transmitted by the HN "
550 <<
")::BCKTOExpired()________________________Backoff_"
570 std::cout << NOW <<
" uwUFetch_NODE (" << addr
571 <<
") ::state_DATA_HN_first_tx() ---->HN will be transmit "
573 <<
" DATA packets to the AUV with MAC address: "
578 << NOW <<
"uwUFetch_HEAD_NODE(" << addr
579 <<
")::state_DATA_HN_first_tx()______________DATA_pck_to_tx_"
584 std::cout << NOW <<
" uwUFetch_NODE (" << addr
585 <<
") ::state_DATA_HN_first_tx() ---->HN is starting "
586 "transmission of the"
587 <<
" FIRST DATA packet to the AUV with MAC address: "
600 mach->macSA() = addr;
617 int old_sn = cbrh->
sn();
623 <<
")::state_DATA_HN_first_tx()______________DATA_"
626 << mach->macSA() <<
")_"
627 <<
"destination(" << mach->macDA()
628 <<
")_id_pck_original:" << old_sn
629 <<
"_new_id_pck:" << cbrh->
sn()
630 <<
"_size:" << cmh->size() <<
"[byte]"
638 int old_sn = cbrh->
sn();
644 <<
")::state_DATA_HN_first_tx()______________DATA_"
647 << mach->macSA() <<
")_"
648 <<
"destination(" << mach->macDA()
649 <<
")_id_pck_original:" << old_sn
650 <<
"_new_id_pck:" << cbrh->
sn()
651 <<
"_size:" << cmh->size() <<
"[byte]"
664 std::cout << NOW <<
" uwUFetch_NODE (" << addr
665 <<
") ::DATA_HN_tx() ---->HN is transmitting a DATA packet "
681 std::cout << NOW <<
" uwUFetch_NODE (" << addr
682 <<
") ::state_DATA_HN_tx() ---->HN is starting transmission "
685 <<
" to the AUV with"
698 mach->macSA() = addr;
715 int old_sn = cbrh->
sn();
721 <<
")::state_DATA_HN_tx()____________________DATA_"
724 << mach->macSA() <<
")_"
725 <<
"destination(" << mach->macDA()
726 <<
")_id_pck_original:" << old_sn
727 <<
"_new_id_pck:" << cbrh->
sn()
728 <<
"_size:" << cmh->size() <<
"[byte]"
736 int old_sn = cbrh->
sn();
742 <<
")::state_DATA_HN_tx()_____________________"
743 "DATA_pck_tx:_source_SN("
745 << mach->macSA() <<
")_"
746 <<
"destination(" << mach->macDA()
747 <<
")_id_pck_original:" << old_sn
748 <<
"_new_id_pck:" << cbrh->
sn()
749 <<
"_size:" << cmh->size() <<
"[byte]"
763 <<
")::state_DATA_HN_finish_tx()_____________End_tx_"
764 "DATA_pcks_to_the_AUV."
771 std::cout << NOW <<
" uwUFetch_NODE (" << addr
772 <<
") ::state_DATA_HN_finish_tx() ---->HN has "
773 "transmitted all his DATA"
774 <<
" packets to the AUV with MAC address: "
776 <<
", so return in STATE_CBEACON_TX()." << std::endl;
793 std::cout << NOW <<
" uwUFetch_NODE (" << addr
794 <<
") ::state_DATA_HN_finish_tx() ---->HN has "
795 "transmitted all his DATA"
796 <<
" packets to the AUV with MAC address: "
virtual void schedule(double val)
schedule a timer
void incrTotalDataPckRx_by_HN()
Increase total number of DATA packets correctly or not received by the HN during an entire simulation...
double T_max_bck_DATA
Upper bound time interval from which the HN choice its backoff timer before to transmit a DATA packet...
virtual void state_DATA_HN_first_tx_without()
HN initialize the FIRST DATA packet that will be forwarded to the AUV node.
virtual bool burstDATA()
Indicate whether the transmission of DATA packets to the AUV take place with or without burst data.
virtual void state_DATA_HN_finish_tx_without()
HN has finished to transmit the sequence of DATA packets to the AUV.
bool txDATAEnabledHN
true if HN is enabled to transmit a DATA packet to the AUV
virtual double choiceBackOffTimer_HN()
Choose the backoff timeout used by HN before to transmit a RTS packet.
int getDataPckRx_by_HN()
Number of DATA packets transmitted by the HN during a single cycle BEACON-PROBE-POLL-DATA-CBEACON of ...
double bck_before_tx_data
Time value chosen by the HN and used by It for transmit a DATA packet to the AUV.
virtual void stateIdle_HN()
Idle state for HN.
uwUFetch_BackOffTimer BCK_timer_data
Interval time before that the HN transmit his DATA packet to the AUV.
virtual void state_DATA_HN_first_tx()
HN initialize the FIRST DATA packet that will be forwarded to the AUV node.
virtual void DATA_rx()
HN has received a BEACON packet from SN.
virtual void printStateInfo(double delay=0)
Prints a file with every state change for debug purposes.
std::ofstream out_file_logging
Variable that handle the file in which the protocol write the statistics.
virtual void Phy2MacEndRx_HN_without(Packet *p)
Handle the end-of-PHY-reception event for HEAD NODE in the case that the communication don't use RTS-...
virtual void BCKTOExpired_HN_without()
Backoff timeout is expired.
virtual void DATA_HN_tx_without()
HN transmit a DATA packet to the AUV.
double rx_DATA_finish_HN_time
Indicates when HN finished the reception of DATA packet from the SNs.
void incrTotalTriggerPckRx_HN()
Increase the total number of TRIGGER packets correctly or not received by the HN during an entire sim...
int debugMio_
Used if we want to create the logging file.
void incrTotalDataPckRx_corrupted_by_HN()
Increase total number of corrupted DATA packets received by the HN during an entire simulation.
bool sectionCBeacon
true HN has started the transmission of RTS packet when It was in the CBEACON section.
virtual void refreshReason(UWUFETCH_NODE_STATUS_CHANGE reason)
Refresh the reason for the changing of the state.
Packet * curr_TRIGGER_HN_pck_rx
Pointer to the TRIGGER packet that is being received by HN.
bool txBEACONEnabled
true if HN is enabled to transmit a BEACON packet to the SN
int mac_addr_AUV_in_trigger
AUV-MAC address contained in the TRIGGER packet received by the HN.
std::queue< Packet * > Q_data_HN
Queue of DATA packets stored by the HNs and received from SN.
Packet * curr_DATA_NODE_pck_tx_HN
Pointer to the DATA packet that is being transmitted by HN.
void incrDataPckRx_by_HN()
Increase the number of DATA packets transmitted by the HN during a single cycle BEACON-PROBE-POLL-DAT...
int pck_number_id
Unique identifier of the DATA packet received.
virtual void Mac2PhyStartTx(Packet *p)
This method must be called by the SN-MAC to instruct the PHY to start the transmission of a packet.
bool rxTRIGGEREnabled
true if HN is enabled to receive a TRIGGER packet from the AUV
virtual void state_DATA_HN_tx_without()
HN initialize the second and successive DATA packets that will be forwarded to the AUV node.
void incrTotalTriggerPckRx_corrupted_HN()
Increase the total number of corrupted TRIGGER packets received by the HN during an entire simulation...
int getDataPckTx_by_HN()
Number of DATA packets transmitted by the HN during a single cycle TRIGGER-RTS-CTS-DATA of the simula...
double T_min_bck_DATA
Lower bound time interval from which the HN choice its backoff timer before to transmit a DATA packet...
virtual void DATA_HN_tx()
HN transmit a DATA packet to the AUV.
int max_pck_HN_can_tx
Maximum number of DATA packets that AUV want to receive from HN.
virtual void state_CBEACON_tx()
HN initialize the CBEACON packet that will be forwarded in broadcast at all SNs of the network.
void incrTriggerPckRx_HN()
Increase the number of TRIGGER packets received by the HN during a single cycle TRIGGER-RTS-CTS-DATA ...
int n_TRIGGER_pck_rx_by_HN
Number of TRIGGER packet received by the HN during a single cycle TRIGGER-RTS-CTS-DATA of the simulat...
virtual void TRIGGER_rx_without()
HN has received a TRIGGER packet from AUV.
uwUFetch_BEACON_timer BeaconBeforeTx_timer
Schedule the BEACON timeout timer.
void incrTotalDataPckTx_by_NODE()
Increase the total number of DATA packets transmitted by SN during an entire duration of simulation.
virtual void TRIGGER_rx()
HN has received a TRIGGER packet from AUV.
@ UWUFETCH_NODE_STATUS_CHANGE_DATA_PCK_TX
@ UWUFETCH_NODE_STATUS_CHANGE_TRIGGER_RX
@ UWUFETCH_NODE_STATUS_CHANGE_DATA_RX
@ UWUFETCH_NODE_STATUS_CHANGE_HN_RX_TRIGGER_FROM_AUV_CORRUPTED
@ UWFETCH_NODE_STATUS_CHANGE_PACKET_ERROR
@ UWUFETCH_NODE_STATUS_CHANGE_HN_FINISH_TX_DATA_PCK_TO_AUV_RETURN_CBEACON_TX
@ UWUFETCH_NODE_STATUS_CHANGE_HN_TX_ALL_DATA_TO_AUV
double rx_TRIGGER_finish_HN_time
Indicates when HN finished the reception of TRIGGER packet from the AUV.
int MAX_PCK_HN_WANT_RX_FROM_NODE
Packet * curr_DATA_HN_pck_tx
Pointer to the DATA packet that is being transmitted by HN to the AUV.
std::queue< int > Q_data_source_SN
Queue that contain the MAC address from which the HN has received the DATA packet.
std::queue< Packet * > Q_data
Queue of DATA packets stored by the SN.
int max_data_HN_can_tx
Maximum number of DATA packets that the HN must transmit to the AUV.
int n_DATA_pck_tx_by_HN
Number of DATA packet transmitted by the HN during a single cycle TRIGGER-RTS-CTS-DATA of the simulat...
Packet * curr_DATA_HN_pck_rx
Pointer to the DATA packet that is being received by HN from SN.
bool print_transitions
true if the writing of state transitions in the file is enabled.
virtual void refreshState(UWUFETCH_NODE_STATUS state)
@ UWUFETCH_NODE_STATUS_TRIGGER_RECEIVE
Content header of TRIGGER packet.
int & t_min()
Reference to the t_min variable.
int & t_max()
Reference to the t_max variable.
int & max_pck_want_rx()
Reference to the max_pck_want_rx variable.
hdr_uwcbr describes UWCBR packets.
uint16_t & sn()
Reference to the sn_ variable.
Declaration of uwUFetch_NODE class.
packet_t PT_POLL_UFETCH
POLL packet type for UFetch protocol.
#define UWFETCH_NODE_DROP_REASON_ERROR
Packet dropped: packet is corrupted.
packet_t PT_TRIGGER_UFETCH
TRIGGER packet type for UFetch protocol.
#define UWUFETCH_NODE_DROP_CAN_NOT_RX_THIS_PCK
Packet dropped: node can not receive this type of node.
packet_t PT_PROBE_UFETCH
PROBE packet type for UFetch protocol.
#define UWUFETCH_NODE_DROP_REASON_NOT_ENABLE
Packet dropped: node is not enabled to receive this type of \ packet.
Common structures and variables in the protocol.
#define HDR_TRIGGER_UFETCH(p)
alias defined to access the TRIGGER HEADER
Provides the UWCBR packets header description and the definition of the class UWCBR.