DESERT 3.5.1
Loading...
Searching...
No Matches
uwal.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
38#include "uwal.h"
39#include <phymac-clmsg.h>
40
46#define DEFAULT_PSDU 32
47
51static class UwalClass : public TclClass
52{
53public:
55 : TclClass("Module/UW/AL")
56 {
57 }
58 TclObject *
59 create(int, const char *const *)
60 {
61 return (new Uwal());
62 }
64
66 : nodeID(0)
67 , pkt_counter(0)
68 , pPacker(NULL)
69 , PSDU(DEFAULT_PSDU)
70 , dummyStr("")
71 , debug_(0)
72 , sendDownPkts()
73 , sendDownFrames()
74 , sendUpFrameSet()
75 , InterframeTmr(this)
76 , interframe_period(0)
77 , frame_set_validity(0)
78 , frame_padding(0)
79 , force_endTx_(0)
80 , has_tap_clmsg(false)
81{
82 while (dummyStr.size() < PSDU) {
83 dummyStr += " DEFAULT DUMMY STRING ";
84 }
85 dummyStr.resize(PSDU);
86
87 bind("nodeID", (int *) &nodeID);
88 bind("PSDU", (int *) &PSDU);
89 bind("debug_", (int *) &debug_);
90
91 bind("interframe_period", &interframe_period);
92 bind("frame_set_validity", &frame_set_validity);
93 bind("frame_padding", &frame_padding);
94 bind("force_endTx", &force_endTx_);
95}
96
98{
99 InterframeTmr.force_cancel();
100}
101
102int
103Uwal::command(int argc, const char *const *argv)
104{
105 if (argc == 2) {
106 if (strcmp(argv[1], "Reset_PER_List") == 0) {
107 PERList.clear();
108 return TCL_OK;
109 }
110 }
111 if (argc == 3) {
112 if (strcmp(argv[1], "linkPacker") == 0) { // tcl command to link to this
113 // Uwal object a packer object
114 // shadowed as an OTcl object.
115 pPacker = (packer *) TclObject::lookup(argv[2]);
116 return TCL_OK;
117 }
118
119 if (strcmp(argv[1], "setDummyStr") ==
120 0) { // tcl command to set a customized dummy string.
121 dummyStr = "";
122 while (dummyStr.size() < PSDU) {
123 dummyStr += argv[2];
124 }
125 return TCL_OK;
126 }
127 }
128 if (argc >= 3) {
129 if (strcmp(argv[1], "Set_PER_List") == 0) {
130 for (int i = 2; i < argc - 1; i = i + 2) {
131 int id = atoi(argv[i]);
132 double per = atof(argv[i + 1]);
133 pl_element pl;
134 pl.node_ID = id;
135 pl.per = per;
136 for (list<pl_element>::iterator it = PERList.begin();
137 it != PERList.end();
138 ++it) {
139 if (it->node_ID == pl.node_ID) {
140 it = PERList.erase(it);
141 }
142 }
143 PERList.insert(PERList.begin(), pl);
144 }
145 return TCL_OK;
146 }
147 if (strcmp(argv[1], "Clear_PER_List") == 0) {
148 for (int i = 2; i < argc; i++) {
149 int id = atoi(argv[i]);
150 for (list<pl_element>::iterator it = PERList.begin();
151 it != PERList.end();
152 ++it) {
153 if (it->node_ID == id) {
154 it = PERList.erase(it);
155 }
156 }
157 }
158 return TCL_OK;
159 }
160 }
161 return Module::command(argc, argv);
162}
163
164bool
165Uwal::isInPERList(int mac_addr)
166{
167 bool flag = false;
168
169 for (list<PERListElement>::iterator it = PERList.begin();
170 it != PERList.end();
171 ++it) {
172 if (it->node_ID == mac_addr) {
173 flag = true;
174 break;
175 }
176 }
177 return flag;
178}
179
180double
182{
183 double per;
184 for (list<PERListElement>::iterator it = PERList.begin();
185 it != PERList.end();
186 ++it) {
187 if (it->node_ID == mac_addr) {
188 per = it->per;
189 cout << "getPER! " << it->per << endl;
190 break;
191 }
192 }
193 return per;
194}
195
196void
197Uwal::recv(Packet *p)
198{
199 hdr_cmn *ch = HDR_CMN(p);
200
201 if (ch->direction() == hdr_cmn::UP) {
202 if (debug_) {
203 std::cout << NOW << " UW-AL(" << nodeID
204 << ") : received pkt UP ****" << endl;
205 }
206 if (pPacker != NULL) {
207 pPacker->unpackHdr(p);
208 }
209 sendUpFrames.push(p);
210 } else {
211 if (debug_) {
212 std::cout << NOW << " UW-AL(" << nodeID
213 << ") : received pkt DOWN ****" << endl;
214 }
216
217 // initializeHdr(p, ch->uid()); // the uid is also used to
218 // identify the packet at the AL
219
220 has_tap_clmsg = false;
221
222 if (pPacker != NULL) {
223 pPacker->packHdr(p);
225
226 // ch->size_ = pPacker->getHdrBytesLength() +
227 // pPacker->getPayloadBytesLength();
228 }
229
230 sendDownPkts.push(p);
231 }
232
234}
235
236void
238{
239
240 if (!sendDownFrames.empty()) {
241 startTx(sendDownFrames.front());
242 sendDownFrames.pop();
243 } else if (!sendDownPkts.empty()) {
244 fragmentPkt(sendDownPkts.front());
245 sendDownPkts.pop();
246 startTx(sendDownFrames.front());
247 sendDownFrames.pop();
248 } else {
249 while (!sendUpFrames.empty()) {
251 sendUpFrames.pop();
252 }
253
255
256 if (!sendUpPkts.empty()) {
257 startRx(sendUpPkts.front());
258 // if (pPacker != NULL) { // NOTE: with this if, it becomes useless
259 // to pack the size_ field of the common header...
260 // hdr_cmn* ch = HDR_CMN(sendUpPkts.front());
261 // ch->size_ = pPacker->getHdrBytesLength() +
262 // pPacker->getPayloadBytesLength();
263 //}
264 endRx(sendUpPkts.front());
265 sendUpPkts.pop();
266 }
267
268 if (!sendUpPkts.empty()) {
270 }
271 }
272}
273
274void
275Uwal::initializeHdr(Packet *p, unsigned int pkt_counter_)
276{
277
278 hdr_uwal *hal = HDR_UWAL(p);
279
280 hal->srcID() = nodeID;
281 hal->pktID() = pkt_counter_;
282 hal->framePayloadOffset() = 0;
283 hal->Mbit() = 0;
284 memset(hal->dummyStr(), '\0', MAX_DUMMY_STRING_LENGTH);
285 memcpy(hal->dummyStr(), dummyStr.c_str(), dummyStr.size());
286
287 memset(hal->binPkt(), '\0', MAX_BIN_PKT_ARRAY_LENGTH);
288 hal->binPktLength() = 0;
289 hal->binHdrLength() = 0;
290}
291
292void
294{
295
296 hdr_uwal *hal = HDR_UWAL(p);
297 hdr_cmn *ch = HDR_CMN(p);
298
299 if (pPacker == NULL) {
300 if (debug_) {
301 printf("\033[0;0;31m WARNING: \033[0m ");
302 cout << "in Uwal::fragmentPkt -> pPacker set to NULL (i.e., no UW "
303 "AL packer added from tcl with linkPacker). No "
304 "serialization neither fragmentation can be performed! "
305 "(i.e., packet just sent to lower layers)."
306 << endl;
307 }
308 sendDownFrames.push(p);
309 } else {
310 size_t hdr_length = pPacker->getHdrBytesLength();
311 // size_t payload_length = pPacker->getPayloadBytesLength();
312 // size_t pkt_length = hdr_length + payload_length;
313 size_t pkt_length = hal->binPktLength();
314 size_t payload_length =
315 pkt_length - hdr_length; // pPacker->getPayloadBytesLength();
316
317 if (PSDU < hdr_length) {
318 printf("\033[0;0;31m ERROR: \033[0m ");
319 cout << "in packer::ALfragmenter PSDU: " << PSDU
320 << " but hdr_length; " << hdr_length
321 << ". Packet fragmentation is not possible since the hdr "
322 "cannot fit in the PSDU."
323 << endl;
324 return;
325 }
326
327 if (pkt_length <= PSDU) { // !(PSDU < pkt_length)) {
328 if (frame_padding) {
329 hal->binPktLength() = PSDU;
330 ch->size_ = PSDU;
331 }
332 sendDownFrames.push(p);
333 } else {
334 Packet *f_tmp;
335 hdr_uwal *hal_tmp;
336 hdr_cmn *ch_tmp;
337
338 size_t framePayloadLength = PSDU - hdr_length;
339 size_t frameNumber = payload_length / framePayloadLength;
340 // size_t frameNumber = HDR_UWAL(p)->binPktLength() /
341 // framePayloadLength;
342
343 size_t lastFramePayloadLength = hal->binPktLength() -
344 hal->binHdrLength() - frameNumber * framePayloadLength;
345
346 if (debug_) {
347 std::cout << "------ ch->size_: " << ch->size()
348 << " hdr_length: " << hdr_length
349 << ", payload_length: " << payload_length
350 << ", pkt_length: " << pkt_length
351 << ", framePayloadLength: " << framePayloadLength
352 << ", frameNumber: " << frameNumber
353 << " lastFramePayloadLength: "
354 << lastFramePayloadLength << std::endl;
355 }
356
357 for (uint i = 0; i < frameNumber; i++) {
358 f_tmp = p->copy();
359 initializeHdr(f_tmp, hal->pktID());
360
361 hal_tmp = HDR_UWAL(f_tmp);
362 ch_tmp = HDR_CMN(f_tmp);
363
364 // hal_tmp->framePayloadOffset() = i*framePayloadLength;
365 hal_tmp->framePayloadOffset() = i;
366 if (!(i == (frameNumber - 1) && lastFramePayloadLength == 0))
367 hal_tmp->Mbit() = 1;
368
369 pPacker->packHdr(f_tmp);
370
371 // memcpy(hal_tmp->binPkt() + hal_tmp->binHdrLength(),
372 // hal->binPkt() + hal->binHdrLength() +
373 // hal_tmp->framePayloadOffset(), framePayloadLength);
374 memcpy(hal_tmp->binPkt() + hal_tmp->binHdrLength(),
375 hal->binPkt() + hal->binHdrLength() +
376 hal_tmp->framePayloadOffset() *
377 framePayloadLength,
378 framePayloadLength);
379 hal_tmp->binPktLength() += framePayloadLength;
380
381 if (debug_) {
382 if (i == (frameNumber - 1) && lastFramePayloadLength == 0)
383 std::cout << "TX frame (last) num: " << i << endl;
384 else
385 std::cout << "TX frame num: " << i << endl;
386 std::cout << "Header: "
387 << pPacker->hexdump(hal_tmp->binPkt(),
388 hal_tmp->binHdrLength())
389 << endl;
390 std::cout << "Payload: "
391 << pPacker->hexdump(hal_tmp->binPkt() +
392 hal_tmp->binHdrLength(),
393 hal_tmp->binPktLength() -
394 hal_tmp->binHdrLength())
395 << endl;
396 }
397
398 ch_tmp->size_ = PSDU;
399 sendDownFrames.push(f_tmp);
400 }
401
402 if (lastFramePayloadLength > 0) {
403
404 f_tmp = p->copy();
405 initializeHdr(f_tmp, hal->pktID());
406
407 hal_tmp = HDR_UWAL(f_tmp);
408 ch_tmp = HDR_CMN(f_tmp);
409 // hal_tmp->framePayloadOffset() =
410 // frameNumber*framePayloadLength;
411 hal_tmp->framePayloadOffset() = frameNumber;
412
413 pPacker->packHdr(f_tmp);
414
415 if (frame_padding) {
416 memcpy(hal_tmp->binPkt() + hal_tmp->binHdrLength(),
417 hal->binPkt() + hal->binHdrLength() +
418 hal_tmp->framePayloadOffset() *
419 framePayloadLength,
420 PSDU - hal_tmp->binHdrLength());
421 hal_tmp->binPktLength() += (PSDU - hal_tmp->binHdrLength());
422 ch_tmp->size_ = PSDU;
423 } else {
424 memcpy(hal_tmp->binPkt() + hal_tmp->binHdrLength(),
425 hal->binPkt() + hal->binHdrLength() +
426 hal_tmp->framePayloadOffset() *
427 framePayloadLength,
428 lastFramePayloadLength);
429 hal_tmp->binPktLength() += lastFramePayloadLength;
430 ch_tmp->size_ =
431 hal_tmp->binHdrLength() + lastFramePayloadLength;
432 }
433
434 if (debug_) {
435 std::cout << "TX (last) frame num: " << frameNumber << endl;
436 std::cout << "Header: "
437 << pPacker->hexdump(hal_tmp->binPkt(),
438 hal_tmp->binHdrLength())
439 << endl;
440 std::cout << "Payload: "
441 << pPacker->hexdump(hal_tmp->binPkt() +
442 hal_tmp->binHdrLength(),
443 hal_tmp->binPktLength() -
444 hal_tmp->binHdrLength())
445 << endl;
446 }
447
448 sendDownFrames.push(f_tmp);
449 }
450
451 Packet::free(p);
452 }
453 }
454}
455
456void
458{
459 hdr_uwal *hal = HDR_UWAL(p);
460 hdr_cmn *ch = HDR_CMN(p);
461
462 if (pPacker == NULL) {
463 if (debug_) {
464 printf("\033[0;0;31m WARNING: \033[0m ");
465 cout << "in Uwal::fragmentPkt -> pPacker set to NULL (i.e., no UW "
466 "AL packer added from tcl with linkPacker). No "
467 "serialization neither reassembling of fragmented packets "
468 "can be performed! (i.e., frame just sent to upper layers)."
469 << endl;
470 }
471 sendUpPkts.push(p);
472 } else {
473 RxFrameSetKey newKey(hal->srcID(), hal->pktID());
474 std::map<RxFrameSetKey, RxFrameSet>::iterator it =
475 sendUpFrameSet.find(newKey);
476
477 size_t framePayloadOffset =
478 hal->framePayloadOffset() * (PSDU - hal->binHdrLength());
479 // size_t framePayloadOffset = hal->framePayloadOffset()*(ch->size() -
480 // hal->binHdrLength());
481
482 if (it != sendUpFrameSet.end()) {
483 if (hal->Mbit()) { // not the last pkt frame
484 //(it->second).UpdateRxFrameSet(hal->binPkt() +
485 // hal->binHdrLength(), hal->framePayloadOffset(),
486 // hal->binPktLength() - hal->binHdrLength(), -1,
487 // Scheduler::instance().clock());
488 (it->second)
489 .UpdateRxFrameSet(hal->binPkt() + hal->binHdrLength(),
490 framePayloadOffset,
491 hal->binPktLength() - hal->binHdrLength(),
492 -1,
493 Scheduler::instance().clock());
494 } else {
495 //(it->second).UpdateRxFrameSet(hal->binPkt() +
496 // hal->binHdrLength(), hal->framePayloadOffset(),
497 // hal->binPktLength() - hal->binHdrLength(),
498 //(hal->framePayloadOffset() + hal->binPktLength() -
499 // hal->binHdrLength()), Scheduler::instance().clock());
500 (it->second)
501 .UpdateRxFrameSet(hal->binPkt() + hal->binHdrLength(),
502 framePayloadOffset,
503 hal->binPktLength() - hal->binHdrLength(),
504 (framePayloadOffset + hal->binPktLength() -
505 hal->binHdrLength()),
506 Scheduler::instance().clock());
507 }
508
509 if (ch->error()) {
510 if (debug_) {
511 std::cout << NOW << " UW-AL(" << nodeID
512 << ") - Received frame in error" << std::endl;
513 }
514 (it->second).setError();
515 }
516
517 } else {
518 RxFrameSet newSet;
519
520 if (hal->Mbit()) { // not the unique or last pkt frame
521 // newSet.UpdateRxFrameSet(hal->binPkt() + hal->binHdrLength(),
522 // hal->framePayloadOffset(), hal->binPktLength() -
523 // hal->binHdrLength(), -1, Scheduler::instance().clock());
524 newSet.UpdateRxFrameSet(hal->binPkt() + hal->binHdrLength(),
525 framePayloadOffset,
526 hal->binPktLength() - hal->binHdrLength(),
527 -1,
528 Scheduler::instance().clock());
529 } else {
530 // newSet.UpdateRxFrameSet(hal->binPkt() + hal->binHdrLength(),
531 // hal->framePayloadOffset(), hal->binPktLength() -
532 // hal->binHdrLength(), (hal->framePayloadOffset() +
533 // hal->binPktLength() - hal->binHdrLength()),
534 // Scheduler::instance().clock());
535 newSet.UpdateRxFrameSet(hal->binPkt() + hal->binHdrLength(),
536 framePayloadOffset,
537 hal->binPktLength() - hal->binHdrLength(),
538 (hal->framePayloadOffset() + hal->binPktLength() -
539 hal->binHdrLength()),
540 Scheduler::instance().clock());
541 }
542
543 if (ch->error()) {
544 if (debug_) {
545 std::cout << NOW << " UW-AL(" << nodeID
546 << ") - Received frame in error" << std::endl;
547 }
548 newSet.setError();
549 }
550
551 sendUpFrameSet.insert(
552 std::pair<RxFrameSetKey, RxFrameSet>(newKey, newSet));
553 }
554
555 Packet::free(p);
556
557 if (debug_) {
558 std::cout << NOW << " UW-AL(" << nodeID
559 << ") Generated map of RxFrameSets. Number of elements: "
560 << sendUpFrameSet.size() << endl;
561 int i = 1;
562 for (std::map<RxFrameSetKey, RxFrameSet>::iterator it =
563 sendUpFrameSet.begin();
564 it != sendUpFrameSet.end();
565 it++) {
566 std::cout << "Element num: " << i++ << endl;
567 std::cout << "Key: " << it->first.displayKey() << endl;
568 if (debug_ > 5) {
569 std::cout << "Set: " << it->second.displaySet() << endl;
570 }
571 }
572 }
573 }
574}
575
576int
578{
579 if (m->type() == CLMSG_PHY2MAC_ENDTX && !force_endTx_) {
580 hdr_uwal *hal = HDR_UWAL(((ClMsgPhy2MacEndTx *) m)->pkt);
581 if (!hal->Mbit()) {
582 Phy2MacEndTx(((ClMsgPhy2MacEndTx *) m)->pkt);
583 }
584 return 0;
585 } else if (m->type() == CLMSG_MAC2PHY_GETTXDURATION
586 && m->direction() == DOWN) {
587 Packet *p = ((ClMsgMac2PhyGetTxDuration *) m)->pkt;
588 hdr_cmn *ch = HDR_CMN(p);
589
590 if (ch->direction() == hdr_cmn::DOWN) {
591
593
594 if (pPacker != NULL) {
595 pPacker->packHdr(p);
597
598 if (debug_)
599 std::cout << NOW << " UW-AL(" << nodeID
600 << ") : received ClMsg pkt DOWN ****"
601 << std::endl;
602 }
603
604 has_tap_clmsg = true;
605 }
606
607 sendSyncClMsgDown(m);
608 return 0;
609 }
610
611 return Module::recvSyncClMsg(m);
612}
613
614void
616{
617 int fs_size = sendUpFrameSet.size();
618 std::map<RxFrameSetKey, RxFrameSet>::iterator it = sendUpFrameSet.begin();
619
620 for (int i = 0; i < fs_size; i++) {
621 if (it->second.tot_length() == it->second.curr_length()) {
622 if (debug_) {
623 std::cout
624 << NOW << " UW-AL(" << nodeID
625 << ")::checkRxFrameSet() - COMPLETE pkt RECEIVED! ****"
626 << endl;
627 std::cout << "Number of elements in sendUpFrameSet: "
628 << sendUpFrameSet.size() << endl;
629 std::cout << "Key: " << it->first.displayKey() << endl;
630 if (debug_ > 5) {
631 std::cout << "Set: " << it->second.displaySet() << endl;
632 }
633 }
634 Packet *p = Packet::alloc();
635 initializeHdr(p, it->first.pktID());
636
637 hdr_uwal *hal = HDR_UWAL(p);
638 hdr_cmn *ch = HDR_CMN(p);
639
640 hal->srcID() = it->first.srcID();
641
642 // pPacker -> packHdr(p); // (NOTE: it is not necessary to re-pack
643 // the uwal header, since the new allocated packet must be forwarded
644 // to the upper layers)
645
646 memcpy(hal->binPkt() + hal->binHdrLength(),
647 (it->second.binPayload()).c_str(),
648 (it->second.binPayload()).size());
649 hal->binPktLength() += (it->second.binPayload()).size();
650
651 // check if this is right
652 // ch->uid() = hal->pktID();
653 // if (debug_){
654 // std::cout << "Size: " << ch->size() << endl;
655 // std::cout << "Uid : "<< ch->uid() << std::endl;
656 // }
657
658 // Set temporary size as num_frames*payload_lenght
659 ch->size() = it->second.tot_length();
660 if (debug_) {
661 std::cout << "Packet size = " << ch->size() << std::endl;
662 }
663
665
666 hdr_mac *mach = HDR_MAC(p);
667 if (isInPERList(mach->macSA())) {
668 double x = RNG::defaultrng()->uniform_double();
669 cout << "x = " << x << endl;
670 double per = getPERfromID(mach->macSA());
671 cout << "PER = " << per << endl;
672 bool error = x <= per;
673 if (error)
674 ch->error() = 1;
675 }
676
677 if (it->second.getError()) {
678 if (debug_) {
679 std::cout << NOW << " UW-AL(" << nodeID
680 << ") - Packet in error" << std::endl;
681 }
682
683 ch->error() = 1;
684 }
685
686 sendUpPkts.push(p);
687 sendUpFrameSet.erase(it++);
688 } else if (Scheduler::instance().clock() -
689 it->second.t_last_rx_frame() >
691 if (debug_) {
692 printf("\033[0;0;31m WARNING: \033[0m ");
693 std::cout << "**** Uwal::checkRxFrameSet() - INCOMPLETE pkt "
694 "DISCARDED! - frame_set_validity elapsed! ****"
695 << endl;
696 std::cout << "Number of elements in sendUpFrameSet: "
697 << sendUpFrameSet.size() << endl;
698 }
699 sendUpFrameSet.erase(it++);
700 } else {
701 ++it;
702 }
703 }
704}
705
706void
708{
709 InterframeTmr.resched(interframe_period); // + (double)rand() /
710 // (double)RAND_MAX *
711 // interframe_period );
712 hdr_uwal *hal = HDR_UWAL(p);
713
714 if (!hal->Mbit() && force_endTx_) {
715 endTx(p);
716 }
717
718 sendDown(p);
719}
720
721void
722Uwal::endTx(Packet *p)
723{
724 Phy2MacEndTx(p);
725}
726
727void
729{
730 Phy2MacStartRx(p);
731}
732
733void
734Uwal::endRx(Packet *p)
735{
736 sendUp(p);
737}
738
739// TxFrameTimer
740void
742{
744}
void setError()
Definition frame-set.h:147
void UpdateRxFrameSet(char *, size_t, size_t, int, double)
virtual void expire(Event *e)
Method to handle the expiration of a given event.
Definition uwal.cpp:741
Uwal * pUwal_
Pointer to an Uwal object.
Definition uwal.h:102
Class to create the Otcl shadow object for an object of the class Uwal.
Definition uwal.cpp:52
UwalClass()
Definition uwal.cpp:54
TclObject * create(int, const char *const *)
Definition uwal.cpp:59
The main class implementing the module used to implement the adaptation layer between ns2/NS-Miracle ...
Definition uwal.h:112
virtual void endRx(Packet *)
Method to end a packet reception.
Definition uwal.cpp:734
void checkRxFrameSet()
Method responsible to check for errors the received frames.
Definition uwal.cpp:615
std::queue< Packet * > sendUpPkts
queue of the packets to send up to the upper protocols
Definition uwal.h:179
int debug_
String containing dummy characters to be used as padding chars if necessary.
Definition uwal.h:171
virtual int recvSyncClMsg(ClMessage *m)
Method to handle the reception of a synchronous crosslayer message.
Definition uwal.cpp:577
virtual int command(int, const char *const *)
Method to map tcl commands into c++ methods.
Definition uwal.cpp:103
string dummyStr
Definition uwal.h:169
int nodeID
Node ID.
Definition uwal.h:165
Uwal()
Class constructor.
Definition uwal.cpp:65
packer * pPacker
Pointer to the packer of the protocol headers.
Definition uwal.h:167
std::queue< Packet * > sendDownPkts
queue of the packet to send down to the modem
Definition uwal.h:174
virtual void endTx(Packet *)
Method to end a packet transmission.
Definition uwal.cpp:722
double interframe_period
Time period [s] between two successive frame to be sent down.
Definition uwal.h:276
void ALqueueManager()
Method responsible to manage the queueing system of Adaptation Layer.
Definition uwal.cpp:237
void initializeHdr(Packet *, unsigned int)
Method responsible to initialize the headers of the packet.
Definition uwal.cpp:275
TxFrameTimer InterframeTmr
Object of the class TxFrameTimer.
Definition uwal.h:275
unsigned int pkt_counter
Counter for the pktID to set in TX.
Definition uwal.h:166
std::queue< Packet * > sendUpFrames
queue of the frames to send up to the upper protocols
Definition uwal.h:177
bool has_tap_clmsg
True if received a ClMessage from uwTAP.
Definition uwal.h:283
int force_endTx_
0 not force, otherwise force endTx
Definition uwal.h:281
~Uwal()
Class destructor.
Definition uwal.cpp:97
virtual double getPERfromID(int mac_addr)
Method to search for the PER associated with a particular MAC address.
Definition uwal.cpp:181
list< PERListElement > PERList
PER list (couple of ID of the node and Packet Error Rate associated )
Definition uwal.h:181
int frame_padding
Flag to determine if perfoming bit padding up to PSDU size.
Definition uwal.h:279
std::queue< Packet * > sendDownFrames
queue of the frames to send down
Definition uwal.h:176
virtual void recv(Packet *)
Method to handle the reception of packets arriving from the upper layers of the network simulator.
Definition uwal.cpp:197
virtual void startRx(Packet *)
Method to start a packet reception.
Definition uwal.cpp:728
void fragmentPkt(Packet *)
Method responsible to fragment the packet.
Definition uwal.cpp:293
void reassembleFrames(Packet *)
Method responsible to reassemble the various fragments in a unique packets.
Definition uwal.cpp:457
std::map< RxFrameSetKey, RxFrameSet > sendUpFrameSet
map of the frames to send up
Definition uwal.h:184
double frame_set_validity
Time of validity of a frame set.
Definition uwal.h:278
virtual bool isInPERList(int mac_addr)
Method to search a MAC address in the PER List.
Definition uwal.cpp:165
virtual void startTx(Packet *)
Method to start the packet transmission.
Definition uwal.cpp:707
size_t PSDU
size of the PSDU
Definition uwal.h:168
Class exploited by the Uwal module to map an NS-Miracle packet into a bit stream, and vice-versa.
Definition packer.h:57
Packet * unpackHdr(Packet *)
Definition packer.cpp:412
size_t getHdrBytesLength()
Definition packer.h:88
std::string packPayload(Packet *)
Method to map an NS-Miracle packet into a legal modem payload (i.e., a string of binary characters) w...
Definition packer.cpp:292
static std::string hexdump(std::string)
Definition packer.cpp:727
Packet * unpackPayload(Packet *)
Method to de-map a legal modem payload (i.e., a string of binary characters) into an NS-Miracle packe...
Definition packer.cpp:433
std::string packHdr(Packet *)
Definition packer.cpp:234
#define MAX_BIN_PKT_ARRAY_LENGTH
Definition hdr-uwal.h:44
#define MAX_DUMMY_STRING_LENGTH
Definition hdr-uwal.h:45
#define HDR_UWAL(p)
Definition hdr-uwal.h:43
int node_ID
Definition uwal.h:67
double per
Definition uwal.h:68
hdr_uwal describes the packet header used by Uwal objects.
Definition hdr-uwal.h:52
char * dummyStr()
Return the pointer to the dummyStr_ array.
Definition hdr-uwal.h:132
uint8_t & Mbit()
Reference to the Mbit_ variable.
Definition hdr-uwal.h:123
uint32_t & binHdrLength()
Reference to the binHdrLength_ variable.
Definition hdr-uwal.h:159
uint16_t & framePayloadOffset()
Reference to the frameOffset_ variable.
Definition hdr-uwal.h:114
unsigned int & pktID()
Reference to the pktID_ variable.
Definition hdr-uwal.h:105
char * binPkt()
Return to the binPkt_ array pointer.
Definition hdr-uwal.h:141
uint8_t & srcID()
Reference to the srcID_ variable.
Definition hdr-uwal.h:96
uint32_t & binPktLength()
Reference to the binPktLength_ variable.
Definition hdr-uwal.h:150
UwalClass class_module_uwal
#define DEFAULT_PSDU
The size, in bytes, of the default Physical Service Data Unit (i.e., the maximum length of a packet c...
Definition uwal.cpp:46
Header of the main class that implements the adaptation layer between ns2/NS-Miracle and binary data ...