DESERT 3.5.1
Loading...
Searching...
No Matches
uwUFetch_AUV_mod_1.cpp
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//
29
39#include "mac.h"
40#include "mmac.h"
41#include "uwUFetch_AUV.h"
42#include "uwUFetch_cmn_hdr.h"
43#include "uwcbr-module.h"
44#include <sstream>
45#include <time.h>
46
50static class uwUFetchAUVModuleClass : public TclClass
51{
52public:
57 : TclClass("Module/UW/UFETCH/AUV")
58 {
59 }
60
66 TclObject *
67 create(int, const char *const *)
68 {
69 return (new uwUFetch_AUV());
70 }
72
77{
78}
79
80bool uwUFetch_AUV::initialized = false;
81
82std::map<uwUFetch_AUV::UWUFETCH_AUV_STATUS, std::string>
84std::map<uwUFetch_AUV::UWUFETCH_AUV_STATUS_CHANGE, std::string>
86std::map<uwUFetch_AUV::UWUFETCH_AUV_PACKET_TYPE, std::string>
88std::map<uwUFetch_AUV::UWUFETCH_TIMER_STATUS, std::string>
90
95 : // TIMERS
96 Trigger_timer(this)
97 , RTS_timer(this)
98 , DATA_timer(this)
99 , DATA_timer_first_pck(this)
100 ,
101 // GLOBAL VARIABLES THAT SHOULD BE NEVER RESET
102 MAX_PAYLOAD(0)
103 , NUM_MAX_DATA_AUV_WANT_RX(0)
104 , T_START_PROC_TRIGGER(0)
105 , N_RUN(0)
106 , HEAD_NODE_1(0)
107 , HEAD_NODE_2(0)
108 , HEAD_NODE_3(0)
109 , HEAD_NODE_4(0)
110 , tx_TRIGGER_start_time(0)
111 , tx_TRIGGER_finish_time(0)
112 , rx_RTS_start_time(0)
113 , rx_RTS_finish_time(0)
114 , tx_CTS_start_time(0)
115 , tx_CTS_finish_time(0)
116 , rx_DATA_start_time(0)
117 , rx_DATA_finish_time(0)
118 , n_tot_TRIGGER_tx_by_AUV(0)
119 , n_tot_RTS_rx_by_AUV(0)
120 , n_tot_RTS_rx_corr_by_AUV(0)
121 , n_tot_CTS_tx_by_AUV(0)
122 , n_tot_DATA_rx_by_AUV(0)
123 , n_tot_DATA_rx_corr_by_AUV(0)
124 , number_data_pck_AUV_rx_exact(0)
125 , mac_addr_HN_ctsed(0)
126 , data_timeout(0)
127 , T_tx_TRIGGER(0)
128 , Tdata(0)
129 , RTT(0)
130 , mac_addr_HN_in_data(0)
131 , hn_trigg(0)
132 , index(0)
133 , mac_addr_hn_triggered(0)
134 , num_pck_hn_1(0)
135 , num_pck_hn_2(0)
136 , num_pck_hn_3(0)
137 , num_pck_hn_4(0)
138 ,
139 // VARIABLES THAT ENABLES OR NOT AN OPERATION
140 txTRIGGEREnabled(false)
141 , rxRTSEnabled(false)
142 , txCTSEnabled(false)
143 , rxDATAEnabled(false)
144 ,
145 // VARIABLES THAT SHOULD BE RESETED WHEN A CYCLE IS ENDED
146 n_TRIGGER_tx_by_AUV(0)
147 , n_RTS_rx_by_AUV(0)
148 , n_CTS_tx_by_AUV(0)
149 , n_DATA_rx_by_AUV(0)
150 ,
151 // PACKETS CREATED
152 curr_TRIGGER_pck_tx(NULL)
153 , curr_RTS_pck_rx(NULL)
154 , curr_CTS_pck_tx(NULL)
155 , curr_DATA_pck_rx(NULL)
156{
157 mac2phy_delay_ = 1e-19;
158 bind("T_min_RTS_", (double *) &T_MIN_RTS);
159 bind("T_max_RTS_", (double *) &T_MAX_RTS);
160 bind("T_guard_", (double *) &T_GUARD);
161 bind("t_RTS_", (double *) &T_RTS);
162 bind("MAX_PAYLOAD", (double *) &MAX_PAYLOAD);
163 bind("num_max_DATA_AUV_want_receive_", (int *) &NUM_MAX_DATA_AUV_WANT_RX);
164 bind("TIME_BEFORE_TX_TRIGGER_PCK_", (double *) &T_START_PROC_TRIGGER);
165 bind("MY_DEBUG_", (int *) &debugMio_);
166 bind("NUMBER_OF_RUN_", (int *) &N_RUN);
167 bind("HEAD_NODE_1_", (int *) &HEAD_NODE_1);
168 bind("HEAD_NODE_2_", (int *) &HEAD_NODE_2);
169 bind("HEAD_NODE_3_", (int *) &HEAD_NODE_3);
170 bind("HEAD_NODE_4_", (int *) &HEAD_NODE_4);
171 bind("MODE_COMM_", (int *) &mode_comm_hn_auv);
172 bind("NUM_HN_NETWORK_", (int *) &NUM_HN_NET);
173
174} // end uwUFetch_AUV()
175
176int
177uwUFetch_AUV::command(int argc, const char *const *argv)
178{
179 Tcl &tcl = Tcl::instance();
180
181 if (argc == 2) {
182 if (strcasecmp(argv[1], "initialize") == 0) {
183 if (initialized == false)
184 initInfo();
185 if (debug_)
186 fout.open("/tmp/uwUFetch_AUV_stateTransitions.txt",
187 std::ios_base::app);
188
189 if (debugMio_) {
190 std::stringstream file_logging;
191 file_logging << "uwUFetch_AUV_" << addr << "_N_RUN_" << N_RUN
192 << ".out";
193 out_file_logging.open(
194 file_logging.str().c_str(), std::ios_base::app);
195 }
196
197 return TCL_OK;
198 } else if (strcasecmp(argv[1], "printTransitions") == 0) {
199 print_transitions = true;
200
201 return TCL_OK;
202 } else if (strcasecmp(argv[1], "getTRIGGERtxByAUV") == 0) {
203 tcl.resultf("%d", getTotalTrigger_Tx_by_AUV());
204
205 return TCL_OK;
206 } else if (strcasecmp(argv[1], "getRTSrxByAUV") == 0) {
207 tcl.resultf("%d", getTotalRts_Rx_by_AUV());
208
209 return TCL_OK;
210 } else if (strcasecmp(argv[1], "getRTSCorruptedRxByAUV") == 0) {
211 tcl.resultf("%d", getTotalRts_Rx_corrupted_by_AUV());
212
213 return TCL_OK;
214 } else if (strcasecmp(argv[1], "getCTStxByAUV") == 0) {
215 tcl.resultf("%d", getTotalCts_Tx_by_AUV());
216
217 return TCL_OK;
218 } else if (strcasecmp(argv[1], "getDataRxByAUV") == 0) {
219 tcl.resultf("%d", getTotal_Data_Rx_by_AUV());
220
221 return TCL_OK;
222 } else if (strcasecmp(argv[1], "getDataCorruptedRxByAUV") == 0) {
223 tcl.resultf("%d", getTotal_Data_Rx_corrupted_by_AUV());
224
225 return TCL_OK;
226 } else if (strcasecmp(argv[1], "AUVNodeStart") == 0) {
228 return TCL_OK;
229 }
230 } else if (argc == 3) {
231 if (strcasecmp(argv[1], "setMacAddr") == 0) {
232 addr = atoi(argv[2]);
233 if (debug_)
234 std::cout << "UWFETCH_AUV MAC address is:" << addr << std::endl;
235
236 return TCL_OK;
237 }
238 }
239
240 return MMac::command(argc, argv);
241} // end command
242
243int
244uwUFetch_AUV::crLayCommand(ClMessage *m)
245{
246 switch (m->type()) {
247 default:
248 return MMac::crLayCommand(m);
249 }
250} // end crLCommand()
251
252/******************************************************************************
253 * TX/RX METHODS *
254 ******************************************************************************/
255void
257{
258
259 hdr_cmn *cmh = hdr_cmn::access(p);
260 hdr_mac *mach = HDR_MAC(p);
261
262 if (cmh->ptype() == PT_TRIGGER_UFETCH) {
263 // TRIGGER section
264 if (debug_)
265 std::cout << NOW << " uwUFetch_AUV (" << addr
266 << ") ::Mac2PhyStartTx() ---->MAC layer of the AUV "
267 "passes the TRIGGER"
268 << " packet to his physical layer." << std::endl;
269
270 if (mach->macDA() == -1) {
271 if (debugMio_)
272 out_file_logging << NOW << "uwUFetch_AUV(" << addr
273 << ")::Mac2PhyStartTx()______________________"
274 "Start_tx_of_TRIGGER_pck_in_BROADCAST."
275 << std::endl;
276 } else {
277 if (debugMio_)
278 out_file_logging << NOW << "uwUFetch_AUV(" << addr
279 << ")::Mac2PhyStartTx()______________________"
280 "Start_tx_of_TRIGGER_pck_to_HN("
281 << mach->macDA() << ")." << std::endl;
282 }
283 // Compute the time required for transmission of the TRIGGER pck.
285
286 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" << addr
287 // << ")::Mac2PhyStartTx()______________________Time required for the
288 // tx: " << T_tx_TRIGGER << "[s]" << std::endl;
289
291
292 MMac::Mac2PhyStartTx(p);
293 } else if (cmh->ptype() == PT_CTS_UFETCH) {
294 // CTS section
295 if (debug_)
296 std::cout << NOW << " uwUFetch_AUV (" << addr
297 << ") ::Mac2PhyStartTx() ---->MAC layer of the AUV "
298 "passes the CTS"
299 << " packet to his physical layer." << std::endl;
300
301 if (debugMio_)
302 out_file_logging << NOW << "uwUFetch_AUV(" << addr
303 << ")::Mac2PhyStartTx()______________________"
304 "Start_tx_of_CTS_pck_to_HN("
305 << mach->macDA() << ")." << std::endl;
306
307 tx_CTS_start_time = NOW;
308
309 MMac::Mac2PhyStartTx(p);
310 }
311} // end Mac2PhyStartTx()
312
313void
314uwUFetch_AUV::Phy2MacEndTx(const Packet *p)
315{
316
317 hdr_cmn *cmh = hdr_cmn::access(p);
318 hdr_mac *mach = HDR_MAC(p);
319
320 if (cmh->ptype() == PT_TRIGGER_UFETCH) {
321
322 if (typeCommunication()) {
323 // Communication between HN & AUV without RTS and CTS packets
325
326 } else {
327 // Communication between HN & AUV with RTS and CTS packets
328 if (debug_)
329 std::cout << NOW << " uwUFetch_AUV (" << addr
330 << ") ::Phy2MacEndTx() ---->Physical layer of AUV "
331 "has finished"
332 << " to transmit a TRIGGER packet to the AUVs in "
333 "broadcast, now the AUV is waiting for"
334 << " the reception of RTS packets from the HNs."
335 << std::endl;
336
337 if (mach->macDA() == -1) {
338 if (debugMio_)
339 out_file_logging << NOW << "uwUFetch_AUV(" << addr
340 << ")::Phy2MacEndTx()_____________________"
341 "___End_tx_of_TRIGGER_pck_in_BROADCAST."
342 << std::endl;
343 } else {
344 if (debugMio_)
345 out_file_logging << NOW << "uwUFetch_AUV(" << addr
346 << ")::Phy2MacEndTx()_____________________"
347 "___End_tx_of_TRIGGER_pck_to_the_HN("
348 << mach->macDA() << ")." << std::endl;
349 }
351
354
355 txTRIGGEREnabled = false;
356
359 }
360
361 } else if (cmh->ptype() == PT_CTS_UFETCH) {
362 // CTS section
363
364 if (debug_)
365 std::cout
366 << NOW << " uwUFetch_AUV (" << addr
367 << ") ::Phy2MacEndTx() ---->Physical layer of the AUV has "
368 "finished"
369 << " to transmit a CTS packet to the AUV with MAC address: "
370 << mac_addr_HN_ctsed << "so wait"
371 << " the DATA packets from the HN and disable the "
372 "reception of other CTS"
373 << std::endl;
374
375 if (debugMio_)
376 out_file_logging << NOW << "uwUFetch_AUV(" << addr
377 << ")::Phy2MacEndTx()________________________End_"
378 "tx_of_CTS_pck_to_the_HN("
379 << mach->macDA() << ")." << std::endl;
380
381 tx_CTS_finish_time = NOW;
382
385
386 txCTSEnabled = false;
387
390 }
391} // end Phy2MacEndTx()
392
393void
394uwUFetch_AUV::Phy2MacStartRx(const Packet *p)
395{
396
397 if (typeCommunication()) {
398 // Communication between HN & AUV without RTS and CTS packets
400
401 } else {
402 // Communication between HN & AUV with RTS and CTS packets
403 hdr_cmn *cmh = hdr_cmn::access(p);
404 hdr_mac *mach = HDR_MAC(p);
405 int src_mac_addr = mach->macSA();
406
407 if (cmh->ptype() == PT_BEACON_UFETCH) {
408 // BEACON section
409 if (debug_)
410 std::cout << NOW << " uwUFetch_AUV (" << addr
411 << ") ::Phy2MacStartRx() ---->AUV is starting to "
412 "receive a"
413 << " BEACON packet from the HN with MAC address: "
414 << src_mac_addr << std::endl;
415 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" << addr
416 // << ")::Phy2MacStartRx()______________________Start to rx BEACON
417 // pck"
418 // << " from HN(" << src_mac_addr << ")." << std::endl;
419
420 } else if (cmh->ptype() == PT_POLL_UFETCH) {
421 // POLL section
422 if (debug_)
423 std::cout << NOW << " uwUFetch_AUV (" << addr
424 << ") ::Phy2MacStartRx() ---->AUV is starting to "
425 "receive a"
426 << " POLL packet from the HN with MAC address: "
427 << src_mac_addr << std::endl;
428 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" << addr
429 // << ")::Phy2MacStartRx()______________________Start to rx POLL
430 // pck"
431 // << " from HN(" << src_mac_addr << ")." << std::endl;
432
433 } else if (cmh->ptype() == PT_CBEACON_UFETCH) {
434 // CBEACON section
435 if (debug_)
436 std::cout << NOW << " uwUFetch_AUV (" << addr
437 << ") ::Phy2MacStartRx() ---->AUV is starting to "
438 "receive a"
439 << " CBEACON packet from the HN with MAC address: "
440 << src_mac_addr << std::endl;
441 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" << addr
442 // << ")::Phy2MacStartRx()______________________Start to rx CBEACON
443 // pck"
444 // << " from HN(" << src_mac_addr << ")." << std::endl;
445
446 } else if (cmh->ptype() == PT_PROBE_UFETCH) {
447 // PROBE section
448 if (debug_)
449 std::cout << NOW << " uwUFetch_AUV (" << addr
450 << ") ::Phy2MacStartRx() ---->AUV is starting to "
451 "receive a"
452 << " PROBE packet from the NODE with MAC address: "
453 << src_mac_addr << std::endl;
454 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" <<
455 // addr << ")::Phy2MacStartRx()______________________Start to rx
456 // PROBE pck"
457 // << " from NODE(" << src_mac_addr << ")." << std::endl;
458
459 } else if (cmh->ptype() == PT_TRIGGER_UFETCH) {
460 // TRIGGER section
461 if (debug_)
462 std::cout << NOW << " uwUFetch_AUV (" << addr
463 << ") ::Phy2MacStartRx() ---->AUV is starting to "
464 "receive a"
465 << " TRIGGER packet from the AUV with MAC address: "
466 << src_mac_addr << std::endl;
467 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" <<
468 // addr << ")::Phy2MacStartRx()______________________Start to rx
469 // TRIGGER pck"
470 // << " from AUV(" << src_mac_addr << ")." << std::endl;
471
472 } else if (cmh->ptype() == PT_RTS_UFETCH) {
473 // RTS section
474 if (debug_)
475 std::cout << NOW << " uwUFetch_AUV (" << addr
476 << ") ::Phy2MacStartRx() ---->AUV is starting to "
477 "receive a"
478 << " RTS packet from the HN with MAC address: "
479 << src_mac_addr << std::endl;
480 if (debugMio_)
481 out_file_logging << NOW << "uwUFetch_AUV(" << addr
482 << ")::Phy2MacStartRx()______________________"
483 "Start_to_rx_RTS_pck"
484 << "_from_HN(" << src_mac_addr << ")."
485 << std::endl;
486
487 rx_RTS_start_time = NOW;
488
489 } else {
490 // DATA section
491 if (debug_)
492 std::cout << NOW << " uwUFetch_AUV (" << addr
493 << ") ::Phy2MacStartRx() ---->AUV is starting to "
494 "receive a"
495 << " DATA packet from the HN with MAC address: "
496 << src_mac_addr << std::endl;
497 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" << addr
498 // <<
499 // ")::Phy2MacStartRx()______________________DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
500 // << std::endl;
501
502 if (debugMio_)
503 out_file_logging << NOW << "uwUFetch_AUV(" << addr
504 << ")::Phy2MacStartRx()______________________"
505 "Start_to_rx_DATA_pck"
506 << "_from_HN(" << src_mac_addr << ")."
507 << std::endl;
508
509 rx_DATA_start_time = NOW;
510 }
511 }
512} // Phy2MacStartRx();
513
514void
516{
517
518 if (typeCommunication()) {
519 // Communication between HN & AUV without RTS and CTS packets
521
522 } else {
523 // Communication between HN & AUV with RTS and CTS packets
524 hdr_cmn *cmh = hdr_cmn::access(p);
525 hdr_mac *mach = HDR_MAC(p);
526 int src_mac_addr = mach->macSA();
527 int dest_mac_addr = mach->macDA(); // Destination MAC address, the
528 // address to which the packet is
529 // addressed
530
531 // Control if the packet that the HN has received is really for him
532 if ((dest_mac_addr == addr) || (dest_mac_addr == MAC_BROADCAST)) {
533
534 if (cmh->ptype() == PT_BEACON_UFETCH) {
535 // BEACON section
536 if (debug_)
537 std::cout << NOW << " uwUFetch_AUV (" << addr
538 << ") ::Phy2MacEndRx() ---->AUV has finished to "
539 "receive a"
540 << " BEACON packet from the HN with MAC address: "
541 << src_mac_addr << " .IGNORE IT" << std::endl;
542
543 } else if (cmh->ptype() == PT_POLL_UFETCH) {
544 // POLL section
545 if (debug_)
546 std::cout << NOW << " uwUFetch_AUV (" << addr
547 << ") ::Phy2MacEndRx() ---->AUV has finished to "
548 "receive a"
549 << " POLL packet from the HN with MAC address: "
550 << src_mac_addr << " .IGNORE IT" << std::endl;
551
552 } else if (cmh->ptype() == PT_CBEACON_UFETCH) {
553 // CBEACON section
554 if (debug_)
555 std::cout
556 << NOW << " uwUFetch_AUV (" << addr
557 << ") ::Phy2MacEndRx() ---->AUV has finished to "
558 "receive a"
559 << " CBEACON packet from the HN with MAC address: "
560 << src_mac_addr << " .IGNORE IT." << std::endl;
561
562 } else if (cmh->ptype() == PT_PROBE_UFETCH) {
563 // PROBE section
564 if (debug_)
565 std::cout
566 << NOW << " uwUFetch_AUV (" << addr
567 << ") ::Phy2MacEndRx() ---->AUV has finished to "
568 "receive a"
569 << " PROBE packet from the NODE with MAC address: "
570 << src_mac_addr << " .IGNORE IT." << std::endl;
571
572 } else if (cmh->ptype() == PT_TRIGGER_UFETCH) {
573 // TRIGGER section
574 if (debug_)
575 std::cout
576 << NOW << " uwUFetch_AUV (" << addr
577 << ") ::Phy2MacEndRx() ---->AUV has finished to "
578 "receive a"
579 << " TRIGGER packet from the AUV with MAC address: "
580 << src_mac_addr << " .IGNORE IT." << std::endl;
581
582 } else if (cmh->ptype() == PT_RTS_UFETCH) {
583 // RTS section
584 rx_RTS_finish_time = NOW;
585
586 if (debugMio_)
587 out_file_logging << NOW << "uwUFetch_AUV(" << addr
588 << ")::Phy2MacEndRx()_____________________"
589 "___Finished_to_rx_RTS_pck"
590 << "_from_HN(" << src_mac_addr << ")."
591 << std::endl;
593
594 if ((cmh->error()) || (!rxRTSEnabled)) {
595 if (cmh->error()) {
596 // Packet it's in error
597 if (debug_)
598 std::cout << NOW << " uwUFetch_AUV (" << addr
599 << ") ::Phy2MacEndRx() ---->RTS packet "
600 "received by the AUV"
601 << " is corrupted: DROP IT, and continue "
602 "with the processing."
603 << std::endl;
604 if (debugMio_)
605 out_file_logging << NOW << "uwUFetch_AUV(" << addr
606 << ")::Phy2MacEndRx()_____________"
607 "___________RTS_pck_rx"
608 << "_from HN(" << src_mac_addr
609 << ")_It_s_in_ERROR." << std::endl;
610
612
613 drop(p, 1, UWFETCH_AUV_DROP_REASON_ERROR); // drop the
614 // packet
615
616 } else {
617 // AUV is not enabled to receive RTS
618 if (debug_)
619 std::cout << NOW << " uwUFetch_AUV (" << addr
620 << ") ::Phy2MacEndRx() ---->AUV has "
621 "finished to receive a"
622 << " RTS packet from the HN with MAC "
623 "address: "
624 << src_mac_addr << ", but it's not "
625 << " enabled to receive It, so DROP the "
626 "packet and continue the processing."
627 << std::endl;
628 if (debugMio_)
629 out_file_logging << NOW << "uwUFetch_AUV(" << addr
630 << ")::Phy2MacEndRx()_____________"
631 "___________RTS_pck_rx"
632 << "_from_HN(" << src_mac_addr
633 << ")_NOT_ENABLED_to_rx_It."
634 << std::endl;
635
637 }
638 } else {
639 // AUV is enabled to receive RTS
640 if (debug_)
641 std::cout
642 << NOW << " uwUFetch_AUV (" << addr
643 << ") ::Phy2MacEndRx() ---->AUV has finished "
644 "to receive a"
645 << " RTS packet from the HN with MAC address: "
646 << src_mac_addr << "." << std::endl;
647
648 if (debugMio_)
649 out_file_logging << NOW << "uwUFetch_AUV(" << addr
650 << ")::Phy2MacEndRx()_________________"
651 "_______RTS_pck_rx"
652 << "_from_HN(" << src_mac_addr
653 << ")_It_s_CORRECT." << std::endl;
654
655 if (getTrigger_Tx_by_AUV() == 1) {
656 // The RTS is received after a transmission of TRIGGER
657 // packet
659
660 curr_RTS_pck_rx = p->copy();
661
662 Packet::free(p);
663
666 RTS_rx();
667
668 } else {
669 // The RTS is received without sending previous TRIGGER
670 // packets
672
673 curr_RTS_pck_rx = p->copy();
674
675 Packet::free(p);
676
679 RTS_rx();
680 }
681 }
682 } else {
683 // DATA section
684 if (debug_)
685 std::cout << NOW << " uwUFetch_AUV (" << addr
686 << ") ::Phy2MacEndRx() ---->AUV has finished to "
687 "receive a"
688 << " DATA packet from the HEAD NODE with MAC "
689 "address: "
690 << src_mac_addr << std::endl;
691
692 if (debugMio_)
693 out_file_logging << NOW << "uwUFetch_AUV(" << addr
694 << ")::Phy2MacEndRx()_____________________"
695 "___Finished_to_rx_DATA_pck"
696 << "_from_HN(" << src_mac_addr << ")."
697 << std::endl;
698
700
702
703 if ((cmh->error()) || (!rxDATAEnabled)) {
704 if (cmh->error()) {
705 // Packet it's in error
706 if (debug_)
707 std::cout << NOW << " uwUFetch_AUV (" << addr
708 << ") ::Phy2MacEndRx() ---->DATA packet "
709 "received by the AUV"
710 << " is corrupted: DROP IT and continue "
711 "with the actual processing."
712 << std::endl;
713
716
717 curr_DATA_pck_rx = p->copy();
718
720
721 if (debugMio_)
722 out_file_logging << NOW << "uwUFetch_AUV(" << addr
723 << ")::Phy2MacEndRx()_____________"
724 "___________DATA_pck_rx_by_AUV("
725 << addr << ")_from_HN("
726 << mach->macSA()
727 << ")_id_pck:" << cbrh->sn() << ""
728 << "_It_s_in_ERROR." << std::endl;
729
730 drop(p, 1, UWFETCH_AUV_DROP_REASON_ERROR); // drop the
731 // packet
732
734 } else {
735 // AUV is not enabled to receive a DATA packet
736 if (debug_)
737 std::cout << NOW << " uwUFetch_AUV (" << addr
738 << ") ::Phy2MacEndRx() ---->AUV is not "
739 "enabled to receive the DATA"
740 << " packet from HN(" << mach->macSA()
741 << "): DROP IT." << std::endl;
742
743 curr_DATA_pck_rx = p->copy();
744
746
747 if (debugMio_)
749 << NOW << "uwUFetch_AUV(" << addr
750 << ")::Phy2MacEndRx()______________________"
751 "__DATA_pck_rx_by_AUV("
752 << addr << ")_from_HN(" << mach->macSA()
753 << ")_id_pck:" << cbrh->sn() << ""
754 << "_NOT_ENABLED_TO_RX_IT." << std::endl;
755
757 }
758 } else {
759 // Packet it's not in error
760 if (debug_)
761 std::cout << NOW << " uwUFetch_AUV (" << addr
762 << ") ::Phy2MacEndRx() ---->Physical layer "
763 "of AUV with MAC"
764 << " address: " << dest_mac_addr
765 << " has finished to receive a DATA packet"
766 << " number: " << (getData_Rx_by_AUV() + 1)
767 << " from the HEAD NODE with MAC address: "
768 << src_mac_addr << std::endl;
769
771
772 curr_DATA_pck_rx = p->copy();
773
775
776 if (debugMio_)
777 out_file_logging << NOW << "uwUFetch_AUV(" << addr
778 << ")::Phy2MacEndRx()_________________"
779 "_______DATA_pck_rx_by_AUV("
780 << addr << ")_from_HN("
781 << mach->macSA()
782 << ")_id_pck:" << cbrh->sn() << ""
783 << "_IT_S_CORRECT." << std::endl;
784
785 Packet::free(p);
786
789 DATA_rx();
790 }
791 }
792 } else {
793 // Packet is not addressed to me AUV
794 if (debug_)
795 std::cout << NOW << " uwUFetch_AUV (" << addr
796 << ") ::Phy2MacEndRx() ---->The packet received is "
797 "not for me AUV:"
798 << " DROP IT" << std::endl;
799
800 if (cmh->ptype() == PT_BEACON_UFETCH) {
804
805 } else if (cmh->ptype() == PT_POLL_UFETCH) {
809
810 } else if (cmh->ptype() == PT_CBEACON_UFETCH) {
814
815 } else if (cmh->ptype() == PT_PROBE_UFETCH) {
819
820 } else if (cmh->ptype() == PT_TRIGGER_UFETCH) {
824
825 } else if (cmh->ptype() == PT_RTS_UFETCH) {
829
830 } else if (cmh->ptype() == PT_CTS_UFETCH) {
834
835 } else {
839 }
840 }
841 }
842} // end Phy2MacEndRx()
843
844/******************************************************************************
845 * AUV METHODS *
846 ******************************************************************************/
847void
849{
850
851 if (debug_)
852 std::cout << NOW << " uwUFetch_AUV (" << addr
853 << ") ::stateIdle_AUV() ---->AUV is in IDLE state."
854 << std::endl;
855
856 if (debugMio_)
857 out_file_logging << NOW << "uwUFetch_AUV(" << addr
858 << ")::stateIdle_AUV()_______________________AUV_is_"
859 "in_IDLE_STATE."
860 << std::endl;
861
862 txTRIGGEREnabled = false;
863
867
869 if (debug_)
870 std::cout << NOW << " uwUFetch_AUV (" << addr
871 << ") ::stateIdle_AUV() ---->AUV start immediately the "
872 "transmission of TRIGGER packet"
873 << " to a specific HN." << std::endl;
874
875 if (debugMio_)
876 out_file_logging << NOW << "uwUFetch_AUV(" << addr
877 << ")::stateIdle_AUV()_______________________"
878 "Start_immediately_the_tx_of_TRIGGER_pck."
879 << std::endl;
880
881 txTRIGGEREnabled = true;
883
884 } else {
885 if (debug_)
886 std::cout << NOW << " uwUFetch_AUV (" << addr
887 << ") ::stateIdle_AUV() ---->AUV before to transmit a "
888 "TRIGGER packet"
889 << " to a specific HNs waits an interval time equal to: "
890 << T_START_PROC_TRIGGER << "[s]." << std::endl;
891
892 if (debugMio_)
893 out_file_logging << NOW << "uwUFetch_AUV(" << addr
894 << ")::stateIdle_AUV()_______________________Wait_"
895 "an_interval_time_equal_to:_"
897 << "_before_to_tx_TRIGGER_pck." << std::endl;
898 if (debugMio_)
900 << NOW << "uwUFetch_AUV(" << addr
901 << ")::stateIdle_AUV()_______________________.......Waiting"
902 << std::endl;
903 if (debugMio_)
905 << NOW << "uwUFetch_AUV(" << addr
906 << ")::stateIdle_AUV()_______________________.......Waiting"
907 << std::endl;
908 if (debugMio_)
910 << NOW << "uwUFetch_AUV(" << addr
911 << ")::stateIdle_AUV()_______________________.......Waiting"
912 << std::endl;
913
915 }
916} // end stateIdle_AUV()
917
918void
920{
921 // The timeout is expired, so now the AUV node can transmit a TRIGGER
922 // packet. Before to transmit a TRIGGER packet, AUV
923 // must be created It.
924 if (debug_)
925 std::cout << NOW << " uwUFetch_AUV (" << addr
926 << ") ::TriggerTOExpired() --->AUV now can start the "
927 "transmission of the"
928 << " TRIGGER packet in broadcast to the HNs." << std::endl;
929
930 if (debugMio_)
931 out_file_logging << NOW << "uwUFetch_AUV(" << addr
932 << ")::TriggerTOExpired()____________________Start_"
933 "the_communication_with_HNs."
934 << std::endl;
935
936 txTRIGGEREnabled = true;
937 rxRTSEnabled = false;
938
941
942} // end TRIGGERTOExpired()
943
944void
946{
947
948 if (typeCommunication()) {
949 // Communication between HN & AUV without RTS and CTS packets
951
952 } else {
953 // Communication between HN & AUV with RTS and CTS packets
957
958 if (debug_)
959 std::cout << NOW << " uwUFetch_AUV (" << addr
960 << ") ::state_TRIGGER_tx() ---->AUV is initializing the "
961 "TRIGGER packet that"
962 << " will then transmitted to the HNs in broadcast. Only "
963 "after the end of transmission of TRIGGER"
964 << " the AUV will enabled to receive a RTS packet."
965 << std::endl;
966
967 Packet *p = Packet::alloc(); // allocate the memory for the packet
968 hdr_cmn *cmh = hdr_cmn::access(p);
969 hdr_mac *mach = HDR_MAC(p);
971
972 cmh->ptype() = PT_TRIGGER_UFETCH; // assign the type of the packet
973
974 mach->set(MF_CONTROL, addr, MAC_BROADCAST); // set the information of
975 // the packet (type,source
976 // address,destination
977 // address)
978 mach->macSA() = addr; // set the source address as AUV MAC address
979 mach->macDA() = MAC_BROADCAST; // set the destination address as
980 // BROADCAST address
981
982 // Filling the header of TRIGGER packet e determine the size of the
983 // TRIGGER packet
984 triggerh->t_min() = (int) (T_MIN_RTS * 1000); // minimum value for to
985 // choose the back-off
986 // time for tx RTS pck
987 triggerh->t_max() = (int) (T_MAX_RTS * 1000); // maximum value for to
988 // choose the back-off
989 // time for tx RTS pck
990 triggerh->max_pck_want_rx() =
991 NUM_MAX_DATA_AUV_WANT_RX; // maximum number of DATA packets that
992 // the AUV want to receive from the HN
993 cmh->size() = sizeof(
994 hdr_TRIGGER_UFETCH); // set the size of TRIGGER header packet
995
996 if (debugMio_)
997 out_file_logging << NOW << "uwUFetch_AUV(" << addr
998 << ")::state_TRIGGER_tx()____________________"
999 "PARAMETERS_of_TRIGGER_PACKET."
1000 << std::endl;
1001 if (debugMio_)
1002 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1003 << ")::state_TRIGGER_tx()____________________"
1004 "Source_address:_"
1005 << mach->macSA() << std::endl;
1006 if (mach->macDA() == -1) {
1007 if (debugMio_)
1008 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1009 << ")::state_TRIGGER_tx()____________________"
1010 "Destination_Address:_BROADCAST."
1011 << std::endl;
1012 } else {
1013 if (debugMio_)
1014 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1015 << ")::state_TRIGGER_tx()____________________"
1016 "Destination_Address:_"
1017 << mach->macDA() << std::endl;
1018 }
1019 if (debugMio_)
1020 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1021 << ")::state_TRIGGER_tx()____________________MIN_"
1022 "backoff_time_DATA_pck:_"
1023 << T_MIN_RTS << "[s]." << std::endl;
1024 if (debugMio_)
1025 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1026 << ")::state_TRIGGER_tx()____________________MAX_"
1027 "backoff_time_DATA_pck:_"
1028 << T_MAX_RTS << "[s]." << std::endl;
1029 if (debugMio_)
1030 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1031 << ")::state_TRIGGER_tx()____________________MAX_"
1032 "DATA_pck_want_rx_from_HN:_"
1033 << triggerh->max_pck_want_rx() << "[pck]."
1034 << std::endl;
1035 if (debugMio_)
1036 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1037 << ")::state_TRIGGER_tx()____________________Size_"
1038 "of_TRIGGER_pck:_"
1039 << cmh->size() << "[byte]." << std::endl;
1040
1041 // Create a copy f the TRIGGER packet
1042 curr_TRIGGER_pck_tx = p->copy();
1043
1044 // DE-allocate the memory occupied by TRIGGER packet
1045 Packet::free(p);
1046
1047 // Recall the function that simulate the transmission of the trigger
1049 TRIGGER_tx();
1050 }
1051
1052} // end state_TRIGGER_tx()
1053
1054void
1056{
1057 if (typeCommunication()) {
1058 // Communication between HN & AUV without RTS and CTS packets
1060
1061 } else {
1062 // Communication between HN & AUV with RTS and CTS packets
1064 }
1065} // end TRIGGER_tx()
1066
1067void
1069{
1070 if (T_RTS < 0) {
1071 if (debug_)
1072 std::cout << NOW << " uwUFetch_AUV (" << addr
1073 << ") ::state_wait_RTS() ---->The waiting time for RTS "
1074 "packets is negative"
1075 << " so set the default value: 10[s]." << std::endl;
1076 T_RTS = 10;
1077 }
1078
1079 if (debug_)
1080 std::cout << NOW << " uwUFetch_AUV (" << addr
1081 << ") ::state_wait_RTS() ---->AUV is scheduling RTS TIMER T= "
1082 << T_RTS
1083 << "[s]. In this interval AUV waiting the RTS packets."
1084 << std::endl;
1085
1089
1090 if (debugMio_)
1092 << NOW << "uwUFetch_AUV(" << addr
1093 << ")::state_wait_RTS()______________________Waiting_RTS_pck."
1094 << std::endl;
1095 if (debugMio_)
1096 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1097 << ")::state_wait_RTS()______________________Timeout_"
1098 "within_rx_RTS_pck:_"
1099 << T_RTS << "[s]." << std::endl;
1100 if (debugMio_)
1101 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1102 << ")::state_wait_RTS()______________________........"
1103 "Waiting_RTS."
1104 << std::endl;
1105 if (debugMio_)
1106 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1107 << ")::state_wait_RTS()______________________........"
1108 "Waiting_RTS."
1109 << std::endl;
1110 if (debugMio_)
1111 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1112 << ")::state_wait_RTS()______________________........"
1113 "Waiting_RTS."
1114 << std::endl;
1115
1116 rxRTSEnabled = true;
1117
1119
1120} // end state_wait_RTS();
1121
1122void
1124{
1125
1126 hdr_mac *mach = HDR_MAC(curr_RTS_pck_rx);
1128
1137 double bck_time_choice_rts_by_HN = (double) rtsh->backoff_time_RTS() / 1000;
1138
1139 Q_rts_mac_HN.push(mach->macSA()); // store the MAC address of the HN that
1140 // has sent the RTS packet to the AUV
1141 Q_rts_n_pcks_HN_want_tx_AUV.push(rtsh->num_DATA_pcks()); // store the number
1142 // of DATA packets
1143 // that the HN want
1144 // to tx to
1145 // the AUV
1146 Q_rts_backoff_time.push(bck_time_choice_rts_by_HN); // store the back-off
1147 // time choice by the HN
1148 // before to transmit
1149 // a RTS packet
1150
1151 if (debugMio_)
1152 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1153 << ")::RTS_rx()______________________________"
1154 "PARAMETERS_of_RTS_PACKET."
1155 << std::endl;
1156 if (debugMio_)
1158 << NOW << "uwUFetch_AUV(" << addr
1159 << ")::RTS_rx()______________________________Source_address:_"
1160 << mach->macSA() << "." << std::endl;
1161 if (debugMio_)
1162 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1163 << ")::RTS_rx()______________________________"
1164 "Destination_address:_"
1165 << mach->macDA() << "." << std::endl;
1166 if (debugMio_)
1167 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1168 << ")::RTS_rx()______________________________RTS_"
1169 "backoff_time_choice_by_HN:_"
1170 << bck_time_choice_rts_by_HN << "[s]." << std::endl;
1171 if (debugMio_)
1172 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1173 << ")::RTS_rx()______________________________Number_"
1174 "of_pck_HN_would_like_to_tx: "
1175 << rtsh->num_DATA_pcks() << "[pck]." << std::endl;
1176
1177 Packet::free(curr_RTS_pck_rx);
1178
1179 if (getTrigger_Tx_by_AUV() == 1) {
1180 // This mean that the AUV has received the RTS after the sending of
1181 // trigger,
1182 // so AUV before proceeding with the transmission of CTS it must reset
1183 // the RTS timer.
1184 if (debugMio_)
1185 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1186 << ")::RTS_rx()______________________________"
1187 "RESET_RTS_timeout."
1188 << std::endl;
1189 RTS_timer.force_cancel();
1190 rxRTSEnabled = false;
1191 txCTSEnabled = true;
1192
1194 state_CTS_tx();
1195 } else {
1196 // This mean that the AUV has received the RTS without the sending of
1197 // trigger,
1198 // so AUV before proceeding with the transmission of CTS it must reset
1199 // the RTS timer and Trigger timer.
1200 Trigger_timer.force_cancel();
1201 if (debugMio_)
1202 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1203 << ")::RTS_rx()______________________________"
1204 "RESET_RTS_timeout."
1205 << std::endl;
1206 RTS_timer.force_cancel();
1207 rxRTSEnabled = false;
1208 txCTSEnabled = true;
1209
1211 state_CTS_tx();
1212 }
1213} // end RTS_rx();
1214
1215void
1217{
1218
1219 if (debug_)
1220 std::cout << NOW << " uwUFetch_AUV (" << addr
1221 << ") ::RtsTOExpired() ---->RTS timeout is expired: other"
1222 << " RTS packets can not be received by the AUV."
1223 << std::endl;
1224
1225 if (debugMio_)
1226 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1227 << ")::RtsTOExpired()________________________RTS_"
1228 "timeout_is_expired."
1229 << std::endl;
1230
1231 if (debug_)
1232 std::cout << NOW << " uwUFetch_AUV (" << addr
1233 << ") ::RtsTOExpired() ---->AUV has received 0 RTS packets "
1234 "within the interval"
1235 << " time pre-established, so return in IDLE STATE."
1236 << std::endl;
1237
1239 n_RTS_rx_by_AUV = 0;
1240 n_CTS_tx_by_AUV = 0;
1241 n_DATA_rx_by_AUV = 0;
1242
1243 txTRIGGEREnabled = true;
1244 rxRTSEnabled = false;
1245
1247 stateIdle_AUV(); // AUV return in IDLE state
1248
1249} // end RtsTOExpired
1250
1251void
1253{
1254
1255 if (debug_)
1256 std::cout << NOW << " uwUFetch_AUV (" << addr
1257 << ") ::state_CTS_tx() ---->AUV is creating a CTS packet that"
1258 << " will then transmit at the first node of the queue that "
1259 "contain the RTS'received."
1260 << std::endl;
1261
1265
1266 Packet *p = Packet::alloc();
1267 hdr_cmn *cmh = hdr_cmn::access(p);
1268 hdr_mac *mach = HDR_MAC(p);
1269 hdr_CTS_UFETCH *ctsh = HDR_CTS_UFETCH(p);
1270
1271 cmh->ptype() = PT_CTS_UFETCH;
1272 cmh->size() = sizeof(hdr_CTS_UFETCH);
1273
1274 mach->set(MF_CONTROL, addr, Q_rts_mac_HN.front());
1275 mach->macSA() = addr;
1276 mach->macDA() = Q_rts_mac_HN.front();
1277
1278 // Filling the HEADER of the CTS packet
1280 ctsh->num_DATA_pcks_MAX_rx() =
1281 Q_rts_n_pcks_HN_want_tx_AUV.front(); // Maximum number of DATA
1282 // packets that the AUV
1283 // want to
1284 // receive from the HN that is being to cts
1285 } else {
1286 ctsh->num_DATA_pcks_MAX_rx() =
1287 NUM_MAX_DATA_AUV_WANT_RX; // Maximum number of DATA packets that
1288 // the AUV want to
1289 // receive from the HN that is being to cts
1290 }
1291
1293 ctsh->mac_addr_HN_ctsed() = Q_rts_mac_HN.front(); // Mac address of the HN
1294 // that the AUV is being
1295 // to cts
1296 mac_addr_HN_ctsed = Q_rts_mac_HN.front(); // Store the mac address of the HN
1297 // that the AUV is being to cts
1298
1299 curr_CTS_pck_tx = p->copy();
1300
1301 if (debugMio_)
1302 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1303 << ")::state_CTS_tx()________________________"
1304 "PARAMETERS_OF_CTS_PCK."
1305 << std::endl;
1306 if (debugMio_)
1308 << NOW << "uwUFetch_AUV(" << addr
1309 << ")::state_CTS_tx()________________________Source_address:_"
1310 << mach->macSA() << std::endl;
1311 if (debugMio_)
1312 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1313 << ")::state_CTS_tx()________________________"
1314 "Destination_address:_"
1315 << mach->macDA() << std::endl;
1316 if (debugMio_)
1317 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1318 << ")::state_CTS_tx()________________________DATA_pck_"
1319 "want_rx_from_HN:_"
1320 << number_data_pck_AUV_rx_exact << "[pck]."
1321 << std::endl;
1322 if (debugMio_)
1324 << NOW << "uwUFetch_AUV(" << addr
1325 << ")::state_CTS_tx()________________________Size_of_CTS_pck:_"
1326 << cmh->size() << "[byte]." << std::endl;
1327
1328 Packet::free(p); // de-allocate the memory
1329
1330 txCTSEnabled = true;
1331
1333 CTS_tx();
1334} // end state_CTS_tx();
1335
1336void
1338{
1339
1341
1342} // end state_CTS_tx();
1343
1344void
1346{
1347
1348 if (typeCommunication()) {
1349 // Communication between HN & AUV without RTS and CTS packets
1351
1352 } else {
1353 // Communication between HN & AUV with RTS and CTS packets
1354 if (debugMio_)
1356 << NOW << "uwUFetch_AUV(" << addr
1357 << ")::state_wait_first_DATA()_______________Waiting_DATA"
1358 << "_pck_number_" << (getData_Rx_by_AUV() + 1)
1359 << "_from_HN(" << mac_addr_HN_ctsed << ")" << std::endl;
1360
1364
1365 data_timeout = getDataTimerValue(); // Compute the timeout interval
1366 // within AUV want to receive all
1367 // DATA packets from HN
1368 if (debug_)
1369 std::cout << NOW << " uwUFetch_AUV (" << addr
1370 << ") ::state_wait_first_DATA() ---->AUV want to receive "
1371 "all the DATA packets"
1372 << " from the HN (" << mac_addr_hn_triggered
1373 << ") within an interval time: " << data_timeout
1374 << " [s]." << std::endl;
1375
1376 if (debugMio_)
1377 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1378 << ")::state_wait_first_DATA()_______________"
1379 "Timeout_within_rx_all_DATA"
1380 << "_pcks_" << data_timeout << "[s]." << std::endl;
1381
1382 if (debugMio_)
1383 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1384 << ")::state_wait_first_DATA()_______________....."
1385 "..Waiting_DATA"
1386 << std::endl;
1387 if (debugMio_)
1388 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1389 << ")::state_wait_first_DATA()_______________....."
1390 "..Waiting_DATA"
1391 << std::endl;
1392 if (debugMio_)
1393 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1394 << ")::state_wait_first_DATA()_______________....."
1395 "..Waiting_DATA"
1396 << std::endl;
1397
1398 rxDATAEnabled = true;
1399
1401 }
1402
1403} // end state_wait_first_DATA();
1404
1405void
1407{
1408
1412
1413 hdr_mac *mach = HDR_MAC(curr_DATA_pck_rx);
1414
1419 mac_addr_HN_in_data = mach->macSA(); // Source MAC address of the HN that
1420 // has transmitted the DATA packet to
1421 // the AUV
1422
1423 if (debug_)
1424 std::cout << NOW << " uwUFetch_AUV (" << addr
1425 << ") ::DATA_Rx() ---->AUV has received the DATA packet"
1426 << " number: " << getData_Rx_by_AUV() << " from the HN with"
1427 << " MAC address: " << mac_addr_HN_in_data << "."
1428 << std::endl;
1429
1434 Q_data_AUV.push(
1436 ->copy()); // Save the data packets in the QUEUE of the AUV
1437 sendUp(curr_DATA_pck_rx->copy()); // Pass the DATA packets received from the
1438 // AUV at the CBR level
1439 Q_data_AUV.pop();
1440
1442
1443 if (debugMio_)
1445 << NOW << "uwUFetch_AUV(" << addr
1446 << ")::DATA_RX()____________________________DATA_pck_rx_by_AUV("
1447 << addr << ")_from_HN(" << mac_addr_HN_in_data
1448 << ")_id_pck:" << cbrh->sn() << ""
1449 << "_IS_PASSED_TO_APP_LAYER." << std::endl;
1450
1451 Packet::free(curr_DATA_pck_rx);
1452
1453 if (debug_)
1454 std::cout << NOW << " uwUFetch_AUV (" << addr
1455 << ") ::DATA_Rx() ----> The DATA packet is passed to the "
1456 "APPLICATION"
1457 << " layer of the AUV." << std::endl;
1458
1460 num_pck_hn_1++;
1461
1462 } else if (mac_addr_HN_in_data == HEAD_NODE_2) {
1463 num_pck_hn_2++;
1464
1465 } else if (mac_addr_HN_in_data == HEAD_NODE_3) {
1466 num_pck_hn_3++;
1467
1468 } else if (mac_addr_HN_in_data == HEAD_NODE_4) {
1469 num_pck_hn_4++;
1470 }
1471
1473} // end DATA_rx();
1474
1475void
1477{
1478
1482
1483 if (debug_)
1484 std::cout << NOW << " uwUFetch_AUV (" << addr
1485 << ") ::state_Wait_DATA() ---->AUV is waiting to receive the "
1486 "DATA packet"
1487 << " number: " << (getData_Rx_by_AUV() + 1)
1488 << " from HN with MAC address: " << mac_addr_HN_ctsed
1489 << std::endl;
1490
1491 if (debugMio_)
1493 << NOW << "uwUFetch_AUV(" << addr
1494 << ")::state_wait_DATA()____________________Waiting_DATA"
1495 << "_pck_number_" << (getData_Rx_by_AUV() + 1) << "_from_HN("
1496 << mac_addr_HN_ctsed << ")" << std::endl;
1497
1498 if (debugMio_)
1500 << NOW << "uwUFetch_AUV(" << addr
1501 << ")::state_wait_DATA()____________________.......Waiting_DATA"
1502 << std::endl;
1503 if (debugMio_)
1505 << NOW << "uwUFetch_AUV(" << addr
1506 << ")::state_wait_DATA()____________________.......Waiting_DATA"
1507 << std::endl;
1508 if (debugMio_)
1510 << NOW << "uwUFetch_AUV(" << addr
1511 << ")::state_wait_DATA()____________________.......Waiting_DATA"
1512 << std::endl;
1513
1514} // end state_wait_DATA();
1515
1516void
1518{
1519
1520 if (debug_)
1521 std::cout << NOW << " uwUFetch_AUV (" << addr
1522 << ") ::DataTOExpired() ---->AUV has not received the first "
1523 "DATA packet"
1524 << " within the time interval pre-established, so return in "
1525 "IDLE STATE."
1526 << std::endl;
1527
1528 if (debugMio_)
1529 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1530 << ")::DataTOExpired_first()_______________________"
1531 "DATA_timeout_expired."
1532 << std::endl;
1533 if (debugMio_)
1534 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1535 << ")::DataTOExpired_first()_______________________"
1536 "Total_DATA_pck_rx_from_HN("
1537 << mac_addr_HN_in_data << ")_is_are_"
1538 << getData_Rx_by_AUV() << std::endl;
1539
1540 DATA_timer.force_cancel();
1542
1544 n_RTS_rx_by_AUV = 0;
1545 n_CTS_tx_by_AUV = 0;
1546 n_DATA_rx_by_AUV = 0;
1547
1548 txTRIGGEREnabled = true;
1549 rxDATAEnabled = false;
1550
1553 // reason for the
1554 // changing of the
1555 // state
1556 stateIdle_AUV(); // AUV return in IDLE state
1557
1558} // end DataTOExpired();
1559
1560void
1562{
1563
1564 if (debug_)
1565 std::cout << NOW << " uwUFetch_AUV (" << addr
1566 << ") ::DataTOExpired() ---->AUV has not received all the "
1567 "DATA packets"
1568 << " within the time interval pre-established, so return in "
1569 "IDLE STATE."
1570 << std::endl;
1571
1572 if (debugMio_)
1573 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1574 << ")::DataTOExpired()_______________________DATA_"
1575 "timeout_expired."
1576 << std::endl;
1577 if (debugMio_)
1578 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1579 << ")::DataTOExpired()_______________________Total_"
1580 "DATA_pck_rx_from_HN("
1581 << mac_addr_HN_in_data << ")_is_are "
1582 << getData_Rx_by_AUV() << std::endl;
1583
1585
1587 n_RTS_rx_by_AUV = 0;
1588 n_CTS_tx_by_AUV = 0;
1589 n_DATA_rx_by_AUV = 0;
1590
1591 txTRIGGEREnabled = true;
1592 rxDATAEnabled = false;
1593
1596 // reason for the
1597 // changing of the
1598 // state
1599 stateIdle_AUV(); // AUV return in IDLE state
1600
1601} // end DataTOExpired();
1602
1603/******************************************************************************
1604 * METODI AUSILIARI *
1605 ******************************************************************************/
1606bool
1608{
1609 if (mode_comm_hn_auv == 1) {
1610 return true;
1611 } else {
1612 return false;
1613 }
1614}
1615
1616double
1618{
1619 if (typeCommunication()) {
1620 // Communication between HN & AUV without RTS and CTS packets
1621 // uwUFetch_AUV::getDataTimerValue_without();
1622 if (debug_)
1623 std::cout << NOW << " uwUFetch_AUV (" << addr
1624 << ") ::getDataTimerValue() ----> AUV is computing the "
1625 "time interval"
1626 << " within it want to receive all DATA packets from the "
1627 "HN."
1628 << std::endl;
1629
1630 RTT = 0;
1632 RTT = getRTT();
1633
1641 double data_timeout_cnt =
1643
1644 return data_timeout_cnt;
1645 } else {
1646 // Communication between HN & AUV with RTS and CTS packets
1647 if (debug_)
1648 std::cout << NOW << " uwUFetch_AUV (" << addr
1649 << ") ::getDataTimerValue() ----> AUV is computing the "
1650 "time interval"
1651 << " within it want to receive all DATA packets from the "
1652 "HN."
1653 << std::endl;
1654
1655 RTT = 0;
1657 RTT = getRTT();
1658
1666 double data_timeout_cnt =
1668
1669 return data_timeout_cnt;
1670 }
1671} // end getDataTimerValue()
1672
1673void
1674uwUFetch_AUV::computeTxTime(UWUFETCH_AUV_PACKET_TYPE tp)
1675{
1676
1677 int size_pck = 0;
1679 size_pck = sizeof(hdr_TRIGGER_UFETCH);
1680 T_tx_TRIGGER = size_pck / BIT_RATE_SERVICE;
1681 } else {
1682 size_pck = MAX_PAYLOAD;
1683 Tdata = size_pck / BIT_RATE_INSTANT;
1684 }
1685} // end computeTxTime()
1686
1687double
1689{
1690 RTT = 4000 / v_speed_sound; // 4000 because is the maximum distance between
1691 // AUV and HN.
1692 // The exactly distance is 3500 but I have floor this distance at 4000[m]
1693 return RTT;
1694} // end getRTT();
1695
1696void
1698{
1699 if (debug_)
1700 std::cout << NOW << " uwUFetch_AUV (" << addr
1701 << ") ::updateQueueRTS() ---->AUV remove the HN from the "
1702 "list of queue"
1703 << " node from which it has received the RTS packets."
1704 << std::endl;
1705 while (!Q_rts_mac_HN.empty()) {
1706 Q_rts_mac_HN.pop();
1708 Q_rts_backoff_time.pop();
1709 }
1710}
1711
1712void
1714{
1719 // Other data packet can not be received by the AUV
1720 if (debug_)
1721 std::cout << NOW << " uwUFetch_AUV (" << addr
1722 << ") ::another_DATA_received() ---->AUV has received "
1723 "all the DATA packets from HN"
1724 << " with MAC address: " << mac_addr_HN_in_data
1725 << ", so return in IDLE STATE." << std::endl;
1726
1727 if (debugMio_)
1728 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1729 << ")::another_DATA_received()_______________ALL_"
1730 "DATA_pck_rx"
1731 << "_from_HN(" << mac_addr_HN_in_data << ")."
1732 << std::endl;
1733
1735
1736 if (debug_)
1737 std::cout << NOW << " uwUFetch_AUV (" << addr
1738 << ") ::another_DATA_received() ---->AUV reset DATA "
1739 "timeout."
1740 << std::endl;
1741 if (debugMio_)
1742 out_file_logging << NOW << "uwUFetch_AUV(" << addr
1743 << ")::another_DATA_received()_______________"
1744 "Reset_DATA_timeout."
1745 << std::endl;
1746
1747 DATA_timer.force_cancel(); // reset the DATA timer
1748
1750 n_RTS_rx_by_AUV = 0;
1751 n_CTS_tx_by_AUV = 0;
1752 n_DATA_rx_by_AUV = 0;
1753
1754 txTRIGGEREnabled = true;
1755 rxDATAEnabled = false;
1756
1758 stateIdle_AUV();
1759
1760 } else {
1761 // Another data packet can be received
1762 if (debug_)
1763 std::cout << NOW << " uwUFetch_AUV (" << addr
1764 << ") ::another_DATA_received() ---->AUV can receive "
1765 "another DATA packet from the "
1766 << " HN with MAC address: " << mac_addr_HN_in_data << ". "
1767 << " The DATA packet number: "
1768 << (getData_Rx_by_AUV() + 1) << std::endl;
1769
1770 // if (debugMio_) out_file_logging << NOW << "uwUFetch_AUV(" << addr <<
1771 // ")::another_DATA_received()_______________Another_DATA_pck_can_rx._Number
1772 // " << (getData_Rx_by_AUV() + 1) << "." << std::endl;
1773 rxDATAEnabled = true;
1774
1777 }
1778} // end another_DATA_received();
1779
1780/******************************************************************************
1781 * METODI EXTRA *
1782 ******************************************************************************/
1783
1784void
1786{
1787 if (module->debug_)
1788 std::cout << NOW << " uwUFetch_AUV (" << module->addr
1789 << ")::UWUFetch_TRIGGER_timer::expire() ---->TRIGGER timeout "
1790 "expired."
1791 << std::endl;
1793
1794 module->TriggerTOExpired();
1795} // end UWUFetch_TRIGGER_timer::expire()
1796
1797void
1799{
1800 if (module->debug_)
1801 std::cout
1802 << NOW << " uwUFetch_AUV (" << module->addr
1803 << ") ::UWUFetch_RTS_timer::expire() ---->RTS timeout expired."
1804 << std::endl;
1805 timer_status = UWUFETCH_TIMER_STATUS_EXPIRED;
1806
1807 module->RtsTOExpired();
1808} // end uwUFetch_RTS_timer::expire()
1809
1810void
1812{
1813 if (module->debug_)
1814 std::cout
1815 << NOW << " uwUFetch_AUV (" << module->addr
1816 << ")::UWUFetch_DATA_timer::expire() ---->DATA timeout expired"
1817 << std::endl;
1818 timer_status = UWUFETCH_TIMER_STATUS_EXPIRED;
1819
1820 module->DataTOExpired();
1821} // end UWUFetch_DATA_timer::expire()
1822
1823void
1825{
1826 if (module->debug_)
1827 std::cout << NOW << " uwUFetch_AUV (" << module->addr
1828 << ")::UWUFetch_FIRST_DATA_timer::expire() ---->FIRST DATA "
1829 "timeout expired"
1830 << std::endl;
1831 timer_status = UWUFETCH_TIMER_STATUS_EXPIRED;
1832
1833 module->DataTOExpired_first();
1834} // end UWUFetch_DATA_timer::expire()
1835
1836void
1837uwUFetch_AUV::printStateInfo(double delay)
1838{
1839 fout << NOW << "uwUFetch(" << addr << ")::printStateInfo() "
1840 << "from " << statusInfo[prev_state] << " to "
1841 << statusInfo[curr_state] << ". Reason: " << statusChange[last_reason]
1842 << std::endl;
1843} // end printStateInfo()
1844
1845void
1847{
1848 initialized = true;
1849
1850 if ((print_transitions) && (system(NULL))) {
1851 system("rm -f /tmp/uwUFetch_AUV_stateTransitions.txt");
1852 system("touch /tmp/uwUFetch_AUV_stateTransitions.txt");
1853 }
1854
1855 statusInfo[UWUFETCH_AUV_STATUS_IDLE] = "AUV is in IDLE state ";
1857 "AUV is transmitting a TRIGGER packet ";
1859 "AUV is waiting a RTS packet from HN ";
1861 "AUV has received a RTS packet ";
1863 "AUV is transmitting a CTS packet ";
1865 "AUV is waiting DATA packet from HN ";
1867 "AUV has receive a DATA packet from HN ";
1868
1870 "Trigger TO is expired, so the AUV start the transmission of "
1871 "TRIGGER packet";
1873 "AUV has finished to initialize the TRIGGER packet, so pass "
1874 "the packet to the physical layer";
1876 "AUV has finished to transmit a TRIGGER packet, so enter in the "
1877 "state in"
1878 " which it wait a RTS packet";
1880 "AUV has finishe to receive a RTS packet, so go to the state in "
1881 "which"
1882 " the RTS is analyzed.";
1884 "AUV has finished to store the information of the RTS packet, so "
1885 "go to"
1886 " the state in which initiale the CTS packet";
1889 "RTS timeout is expired and another RTS can not be "
1890 "received, "
1891 "but at least one RTS has been received, so go to the state"
1892 " in which initialize the CTS packet";
1894 "RTS timeout is expired and another RTS can not be received, "
1895 "but zero RTS has been received, so go to the state idle";
1897 "AUV has finished to initialize the CTS packet, so go to the state"
1898 " in which AUV recall the physical layer";
1900 "AUV has finished to transmit a CTS packet, so go to the state in "
1901 "which the"
1902 " the AUV wait a DATA packets from the HN";
1904 "AUV has finished to receive the DATA packet, so go to the DATA "
1905 "receive method and analyzed it";
1907 "AUV has received the LAST DATA packet from HN, so go to the IDLE "
1908 "state";
1910 "AUV has received a DATA packet, and another DATA packet can be "
1911 "received by It, so go to the waiting state in which it wait "
1912 "another"
1913 " DATA packet.";
1915 "DATA timeout expired, all the packets are not received by the HN, "
1916 "so"
1917 "go to the IDLE stae";
1919 "AUV has received a packet that is not addressed to It";
1920
1922 packetType[UWUFETCH_AUV_PACKET_TYPE_TRIGGER] = "TRIGGER packet";
1925
1926 statusTimer[UWUFETCH_TIMER_STATUS_IDLE] = "AUV is in Idle";
1927 statusTimer[UWUFETCH_TIMER_STATUS_RUNNING] = "AUV is running";
1928 statusTimer[UWUFETCH_TIMER_STATUS_FROZEN] = "AUV is Freezing";
1929 statusTimer[UWUFETCH_TIMER_STATUS_EXPIRED] = "AUV timeout expired";
1930
1931} // end initInfo()
1932
1933void
1935{
1936 std::string response;
1937 std::cout << "Press Enter to continue";
1938 std::getline(std::cin, response);
1939}
Class that represents the binding with the TCL configuration script.
uwUFetchAUVModuleClass()
Constructor of the class uwUFetchAUVModuleClass.
TclObject * create(int, const char *const *)
Creates the TCL object needed for the TCL language interpretation.
virtual void expire(Event *e)
Method called when the timer expire.
virtual void expire(Event *e)
Method called when the timer expire.
virtual void expire(Event *e)
Method called when the timer expire.
virtual void expire(Event *e)
Method called when the timer expire.
virtual void schedule(double val)
Schedule a timer.
uwUFetch_AUV *UWUFETCH_TIMER_STATUS timer_status
< Pointer to an object of type uwUFetch_AUV
Class that represent the UFetch mac layer for AUV node.
@ UWUFETCH_AUV_PACKET_TYPE_CTS
@ UWUFETCH_AUV_PACKET_TYPE_TRIGGER
@ UWUFETCH_AUV_PACKET_TYPE_DATA
@ UWUFETCH_AUV_PACKET_TYPE_RTS
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
int num_pck_hn_1
Counter of the correct DATA packets received by HN 1 from SNs.
double tx_CTS_start_time
Indicates when AUV start a transmission of CTS packet.
virtual double getDataTimerValue()
Compute the length of time interval within AUV want to receive all DATA packet from specifical HN.
int getTrigger_Tx_by_AUV()
Number of TRIGGER packets transmitted during the simulation during the single cycle.
int n_DATA_rx_by_AUV
Counter of the number of DATA packets transmitted by AUV during a single cycle of simulation.
int n_RTS_rx_by_AUV
Counter of the number of RTS packets received by AUV during a single cycle of simulation.
int getTotal_Data_Rx_by_AUV()
Total number of DATA packets received by AUV from all HNs of the netwrok during the simulation.
uwUFetch_RTS_timer RTS_timer
Interval time in which the AUV wait a RTS packets from the HNs.
int HEAD_NODE_4
Id number of HN 4.
virtual void Phy2MacEndTx(const Packet *p)
Handle the end-of-PHY-transmission event.
double MAX_PAYLOAD
Maximum size of DATA PAYLOAD packet.
int num_pck_hn_3
Counter of the correct DATA packets received by HN 3 from SNs.
int number_data_pck_AUV_rx_exact
Number of DATA packets that AUV want exactly received from the HN.
double rx_RTS_start_time
Indicates when AUV start the reception of RTS packet.
UWUFETCH_AUV_STATUS prev_state
Previous state in which the node it was located.
virtual void state_TRIGGER_tx_without()
Initialization of TRIGGER packet that will be forwarded in broadcast to the HNs.
double data_timeout
Interval time within AUV want to receive all DATA packets from the HN.
void incrData_Rx_by_AUV()
Increase of 1 the number of DATA packets received by AUV.
double tx_TRIGGER_finish_time
Indicates when AUV end the transmission of TRIGGER packet.
int HEAD_NODE_2
Id number of HN 2.
int NUM_MAX_DATA_AUV_WANT_RX
Maximum number of data packet that AUV want to receive from the HN in a single cycle of TRIGGER-RTS-C...
uwUFetch_AUV()
Constructor of the class UWUFetch.
bool txTRIGGEREnabled
true if AUV is enabled to transmit a TRIGGER packet
UWUFETCH_AUV_STATUS_CHANGE last_reason
Last reason because the NODE change his state.
std::queue< int > Q_rts_n_pcks_HN_want_tx_AUV
Queue that store the number of DATA packets that the single HN want to tx to the AUV.
int debugMio_
Used if we want to create the logging file.
virtual double getRTT()
Compute the Round Trip Time.
UWUFETCH_AUV_STATUS curr_state
Current state in which the node is located.
std::ofstream out_file_logging
Variable that handle the file in which the protocol write the statistics.
int mac_addr_HN_ctsed
Mac address of the HN from which the AUV want to receive the DATA packets.
int n_TRIGGER_tx_by_AUV
Counter of the number of TRIGGER packets transmitted by AUV during a single cycle of simulation.
double Tdata
Time needed to transmit a DATA packet.
void incrTotal_Data_Rx_by_AUV()
Increase of 1 the number of DATA packets received by AUV.
virtual void state_CTS_tx()
Initialization of CTS packet that will be forwarded to the specifical HN.
virtual void DataTOExpired_first()
Timeout within received the FIRST DATA packet from HN that it has sent a CTS packet is expired.
double RTT
Round Trip Time.
double rx_RTS_finish_time
Indicates when AUV end the reception of RTS packet.
virtual void refreshReason(UWUFETCH_AUV_STATUS_CHANGE reason)
Refresh the reason for the changing of the state.
int HEAD_NODE_1
Id number of HN 1.
std::ofstream fout
Variable that handle the file in which the protocol write the state transition for debug purposes.
virtual void updateQueueRTS()
Remove the information relative to the HN from which AUV wanted and it has finished to receive DATA p...
void incrTotalRts_Rx_corrupted_by_AUV()
Increase of 1 the number of corrupted RTS packets received by AUV.
@ UWUFETCH_AUV_STATUS_CHANGE_PACKET_FOR_ANOTHER_NODE
@ UWUFETCH_AUV_STATUS_CHANGE_RTS_TO_EXPIRED_0_RTS_RX
@ UWUFETCH_AUV_STATUS_CHANGE_TRIGGER_TO_EXPIRED
@ UWUFETCH_AUV_STATUS_CHANGE_TRIGGER_INITIALIZE_TX_TRIGGER
@ UWUFETCH_AUV_STATUS_CHANGE_RTS_TO_EXPIRED_AT_LEAST_ONE_RTS_RX
@ UWUFETCH_AUV_STATUS_CHANGE_CTS_INITIALIZED_TX_CTS
@ UWUFETCH_AUV_STATUS_CHANGE_RTS_FINISHED_TO_RX
@ UWUFETCH_AUV_STATUS_CHANGE_TRIGGER_TX_WAIT_RTS
@ UWUFETCH_AUV_STATUS_CHANGE_DATA_PCK_FINISHED_TO_RX
@ UWUFETCH_AUV_STATUS_CHANGE_RTS_FINSHED_TO_STORE
@ UWUFETCH_AUV_STATUS_CHANGE_TO_WAIT_DATA_EXPIRED
@ UWUFETCH_AUV_STATUS_CHANGE_ANOTHER_DATA_PCK_RX
@ UWUFETCH_AUV_STATUS_CHANGE_CTS_TX_WAIT_DATA
@ UWUFETCH_AUV_STATUS_CHANGE_LAST_DATA_PCK_RX
int mode_comm_hn_auv
Indicate how the communication takes place with or without RTS-CTS packets.
int getTotalCts_Tx_by_AUV()
Total number of CTS packets transmitted by AUV during the simulation.
virtual void Phy2MacStartRx_without(const Packet *p)
Handle the detected-start-of-PHY-reception event in the case protocol doesn't use RTS and CTS packets...
virtual void Mac2PhyStartTx(Packet *p)
This method must be called by the MAC to instruct the PHY to start the transmission of a packet.
virtual void DataTOExpired()
Timeout within received DATA packets is expired.
int num_pck_hn_2
Counter of the correct DATA packets received by HN 2 from SNs.
virtual void computeTxTime(UWUFETCH_AUV_PACKET_TYPE tp)
Compute the transmission time for a specifical type of packet.
int HEAD_NODE_3
Id number of HN 3.
int N_RUN
Number of run in execution
void incrTotalRts_Rx_by_AUV()
Increase of 1 the number of RTS packets received by AUV.
std::queue< double > Q_rts_backoff_time
Queue that stored the backoff time choice by the single HN before to transmit RTS packet.
double T_MAX_RTS
Upper bound of the interval in which HN choice the back-off time to tx RTS pck.
void incrTotalCts_Tx_by_AUV()
Increase of 1 the number of CTS packets transmitted by AUV.
double T_MIN_RTS
Lower bound of the interval in which HN choice the back-off time to tx RTS pck.
double tx_TRIGGER_start_time
Indicates when AUV start a transmission of TRIGGER packet.
virtual void state_TRIGGER_tx()
Initialization of TRIGGER packet that will be forwarded in broadcast to the HNs.
virtual void state_wait_DATA()
AUV is waiting the SECOND and successive DATA packets from HN.
static std::map< UWUFETCH_AUV_PACKET_TYPE, std::string > packetType
Map the UWUFETCH_AUV_PACKET_TYPE to the description of packet type.
bool rxRTSEnabled
true if AUV is enabled to receive a RTS packet
Packet * curr_CTS_pck_tx
Pointer to the CTS packet that is being transmitted by AUV.
uwUFetch_TRIGGER_timer Trigger_timer
Interval time.
virtual void another_DATA_received()
Verify whether AUV must to receive another DATA packet from the HN to whome It has transmitted the TR...
void incrCts_Tx_by_AUV()
Increase of 1 the number of CTS packets transmitted by AUV.
void incrTotalTrigger_Tx_by_AUV()
Increase of 1 the number of TRIGGER packets transmitted by AUV.
double T_START_PROC_TRIGGER
Time before that the AUV start the procedure to transmit a TRIGGER packet.
int getTotal_Data_Rx_corrupted_by_AUV()
Total number of corrupted DATA packets received by the AUV from all HNs of the network.
std::queue< int > Q_rts_mac_HN
Queue of HN MAC address from which AUV has received correctly the RTS packet.
int mac_addr_hn_triggered
MAC address of the HN triggered by the AUV.
virtual void Mac2PhyStartTx_without(Packet *p)
This method must be called by the MAC to instruct the PHY to start the transmission of a packet in th...
int getTotalRts_Rx_by_AUV()
Total number of RTS received by AUV during the simulation from all HNs of the network.
virtual void state_wait_first_DATA_without()
AUV is waiting the FIRST DATA packet from the HN to whom It has sent only RTS packet.
int n_CTS_tx_by_AUV
Counter of the number of CTS packets transmitted by AUV during a single cycle of simulation.
static std::map< UWUFETCH_TIMER_STATUS, std::string > statusTimer
Map the UWUFETCH_TIMER_STATUS to the description of the timers.
void incrTrigger_Tx_by_AUV()
Increment by 1 the number of TRIGGER packets transmitted by AUV during a single cycle TRIGGER-RTS-CTS...
static bool initialized
Indicate if the protocol has been initialized or not.
double T_GUARD
Guard time interval used between two consecutive transmissions of data packets.
Packet * curr_DATA_pck_rx
Pointer to the DATA packet that is being received by AUV.
@ UWUFETCH_AUV_STATUS_RECEIVE_RTS_PACKET
@ UWUFETCH_AUV_STATUS_TRANSMIT_CTS_PACKET
@ UWUFETCH_AUV_STATUS_WAIT_RTS_PACKET
@ UWUFETCH_AUV_STATUS_RECEIVE_DATA_PACKET
@ UWUFETCH_AUV_STATUS_WAIT_DATA_HN
@ UWUFETCH_AUV_STATUS_TRANSMIT_TRIGGER
virtual void waitForUser()
Method used for debug.
int getData_Rx_by_AUV()
Number of DATA packets received by AUV after the transmission of TRIGGER-RTS-CTS packets from a speci...
virtual ~uwUFetch_AUV()
Destructor of the class UWUFetch.
uwUFetch_DATA_timer DATA_timer
Interval time in which the AUV want to receive all DATA packets from the HN.
virtual void Phy2MacEndRx_without(Packet *p)
Handle the end-of-PHY-reception event in the case protocol doesn't use RTS and CTS packets.
double T_RTS
Interval time in which the AUV want to receive an RTS packet in answer to the trigger.
virtual void Phy2MacEndTx_without(const Packet *p)
Handle the end-of-PHY-transmission event in the case protocol doesn't use RTS and CTS packets.
virtual void RTS_rx()
AUV has received RTS packet.
bool rxDATAEnabled
true if AUV is enabled to receive a DATA packet
std::queue< Packet * > Q_data_AUV
Queue of DATA packets stored by the AUV and received from HNs.
double rx_DATA_finish_time
Indicates when AUV end the reception of DATA packet.
int num_pck_hn_4
Counter of the correct DATA packets received by HN 4 from SNs.
virtual void DATA_rx()
AUV has received a DATA packet from HN.
virtual void refreshState(UWUFETCH_AUV_STATUS state)
Refresh the state of the protocol.
virtual void initInfo()
Initialize the protocol at the beginning of the simulation.
double rx_DATA_start_time
Indicates when AUV start the reception of DATA packet.
static std::map< UWUFETCH_AUV_STATUS_CHANGE, std::string > statusChange
Map the UWUFETCH_AUV_STATUS_CHANGE to the description the reason of changing state.
Packet * curr_RTS_pck_rx
Pointer to the RTS packet that is being received by AUV.
int getTotalRts_Rx_corrupted_by_AUV()
Total number of corrupted RTS packets received by AUV from all HNs of the network.
int mac_addr_HN_in_data
MAC address of the HN from which the AUV has received the DATA packet
virtual void state_wait_first_DATA()
AUV is waiting the FIRST DATA packet from the HN to whom It has sent a RTS and CTS packet.
double T_tx_TRIGGER
Time required to transimt a single TRIGGER packet.
virtual void printStateInfo(double delay=0)
Prints a file with every state change for debug purposes.
virtual void stateIdle_AUV()
Idle state.
void incrTotal_Data_Rx_corrupted_by_AUV()
Increase of 1 the number of corrupted DATA packets received by AUV.
virtual void TriggerTOExpired()
Timeout trigger is expired.
virtual void Phy2MacEndRx(Packet *p)
Handle the end-of-PHY-reception event.
Packet * curr_TRIGGER_pck_tx
Pointer to the TRIGGER packet that is being transmitted by AUV.
virtual void Phy2MacStartRx(const Packet *p)
Handle the detected-start-of-PHY-reception event.
bool txCTSEnabled
true if AUV is enabled to transmit a CTS packet
virtual void state_wait_RTS()
AUV is wait a RTS packet from HNs.
virtual void RtsTOExpired()
Timeout within AUV is enabled to receive RTS packet is expired.
virtual void CTS_tx()
Transmission of CTS packet.
void incrRts_Rx_by_AUV()
Increase of 1 the number of RTS packets received by AUV.
virtual void TRIGGER_tx()
Trasmission of TRIGGER packet.
@ UWUFETCH_TIMER_STATUS_IDLE
@ UWUFETCH_TIMER_STATUS_EXPIRED
@ UWUFETCH_TIMER_STATUS_FROZEN
@ UWUFETCH_TIMER_STATUS_RUNNING
virtual bool typeCommunication()
Establish whether the communication between SN and AUV take place with RTS and CTS or only using TRIG...
virtual int crLayCommand(ClMessage *m)
Cross-Layer messages interpreter.
bool print_transitions
true if the writing of state transitions in the file is enabled.
int getTotalTrigger_Tx_by_AUV()
Total number of TRIGGER packets transmitted by the AUV during the simulation.
static std::map< UWUFETCH_AUV_STATUS, std::string > statusInfo
Map the UWUFETCH_AUV_STATUS to the description of each state.
double tx_CTS_finish_time
Indicates when AUV end the transmission of CTS packet.
Content header of CTS packet.
int & mac_addr_HN_ctsed()
Reference to the mac_addr_HN_ctsed_ variable.
int & num_DATA_pcks_MAX_rx()
Reference to the num_DATA_pcks_MAX_rx_ variable.
Content header of RTS packet.
int & backoff_time_RTS()
Reference to the backoff_Time_RTS_ variable.
int & num_DATA_pcks()
Reference to the num_Data_pcks_ variable.
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 class that implement AUV for UFetch protocol.
packet_t PT_POLL_UFETCH
POLL packet type for UFetch protocol.
packet_t PT_CBEACON_UFETCH
CBEACON packet type for UFetch protocol.
#define UWFETCH_AUV_DROP_REASON_ERROR
Packet dropped: Packet corrupted.
#define UWFETCH_AUV_DROP_REASON_WRONG_RECEIVER
Packet dropped: Packet is addressed to another node of the.
packet_t PT_CTS_UFETCH
CTS packet type for UFetch protocol.
packet_t PT_TRIGGER_UFETCH
Trigger packet type for UFetch protocol.
packet_t PT_BEACON_UFETCH
BEACON packet type for UFetch protocol.
packet_t PT_PROBE_UFETCH
PROBE packet type for UFetch protocol.
#define UUFETCH_AUV_DROP_REASON_NOT_ENABLE
Packet dropped: AUV is not enabled to transmit or receive this \ type of packet.
packet_t PT_RTS_UFETCH
RTS packet type for UFetch protocol.
uwUFetchAUVModuleClass class_module_uwufetchauv
Common structures and variables in the protocol.
#define HDR_CTS_UFETCH(p)
alias defined to access the CTS HEADER
static const int BIT_RATE_INSTANT
#define HDR_TRIGGER_UFETCH(p)
alias defined to access the TRIGGER HEADER
static const int v_speed_sound
Underwater sound propagation speed.
static const int BIT_RATE_SERVICE
#define HDR_RTS_UFETCH(p)
alias defined to access the RTS HEADER
Provides the UWCBR packets header description and the definition of the class UWCBR.
#define HDR_UWCBR(p)