A Discrete-Event Network Simulator
API
lr-wpan-mac.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 The Boeing Company
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors:
19 * Gary Pei <guangyu.pei@boeing.com>
20 * kwong yin <kwong-sang.yin@boeing.com>
21 * Tom Henderson <thomas.r.henderson@boeing.com>
22 * Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
23 * Erwan Livolant <erwan.livolant@inria.fr>
24 * Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
25 */
26#include "lr-wpan-mac.h"
27#include "lr-wpan-csmaca.h"
28#include "lr-wpan-mac-header.h"
30#include "lr-wpan-mac-trailer.h"
31#include <ns3/simulator.h>
32#include <ns3/log.h>
33#include <ns3/uinteger.h>
34#include <ns3/node.h>
35#include <ns3/packet.h>
36#include <ns3/random-variable-stream.h>
37#include <ns3/double.h>
38
39
40
41#undef NS_LOG_APPEND_CONTEXT
42#define NS_LOG_APPEND_CONTEXT \
43 std::clog << "[address " << m_shortAddress << "] ";
44
45namespace ns3 {
46
47NS_LOG_COMPONENT_DEFINE ("LrWpanMac");
49
50
51TypeId
53{
54 static TypeId tid = TypeId ("ns3::LrWpanMac")
55 .SetParent<Object> ()
56 .SetGroupName ("LrWpan")
57 .AddConstructor<LrWpanMac> ()
58 .AddAttribute ("PanId", "16-bit identifier of the associated PAN",
61 MakeUintegerChecker<uint16_t> ())
62 .AddTraceSource ("MacTxEnqueue",
63 "Trace source indicating a packet has been "
64 "enqueued in the transaction queue",
66 "ns3::Packet::TracedCallback")
67 .AddTraceSource ("MacTxDequeue",
68 "Trace source indicating a packet has was "
69 "dequeued from the transaction queue",
71 "ns3::Packet::TracedCallback")
72 .AddTraceSource ("MacTx",
73 "Trace source indicating a packet has "
74 "arrived for transmission by this device",
76 "ns3::Packet::TracedCallback")
77 .AddTraceSource ("MacTxOk",
78 "Trace source indicating a packet has been "
79 "successfully sent",
81 "ns3::Packet::TracedCallback")
82 .AddTraceSource ("MacTxDrop",
83 "Trace source indicating a packet has been "
84 "dropped during transmission",
86 "ns3::Packet::TracedCallback")
87 .AddTraceSource ("MacPromiscRx",
88 "A packet has been received by this device, "
89 "has been passed up from the physical layer "
90 "and is being forwarded up the local protocol stack. "
91 "This is a promiscuous trace,",
93 "ns3::Packet::TracedCallback")
94 .AddTraceSource ("MacRx",
95 "A packet has been received by this device, "
96 "has been passed up from the physical layer "
97 "and is being forwarded up the local protocol stack. "
98 "This is a non-promiscuous trace,",
100 "ns3::Packet::TracedCallback")
101 .AddTraceSource ("MacRxDrop",
102 "Trace source indicating a packet was received, "
103 "but dropped before being forwarded up the stack",
105 "ns3::Packet::TracedCallback")
106 .AddTraceSource ("Sniffer",
107 "Trace source simulating a non-promiscuous "
108 "packet sniffer attached to the device",
110 "ns3::Packet::TracedCallback")
111 .AddTraceSource ("PromiscSniffer",
112 "Trace source simulating a promiscuous "
113 "packet sniffer attached to the device",
115 "ns3::Packet::TracedCallback")
116 .AddTraceSource ("MacStateValue",
117 "The state of LrWpan Mac",
119 "ns3::TracedValueCallback::LrWpanMacState")
120 .AddTraceSource ("MacIncSuperframeStatus",
121 "The period status of the incoming superframe",
123 "ns3::TracedValueCallback::SuperframeState")
124 .AddTraceSource ("MacOutSuperframeStatus",
125 "The period status of the outgoing superframe",
127 "ns3::TracedValueCallback::SuperframeState")
128 .AddTraceSource ("MacState",
129 "The state of LrWpan Mac",
131 "ns3::LrWpanMac::StateTracedCallback")
132 .AddTraceSource ("MacSentPkt",
133 "Trace source reporting some information about "
134 "the sent packet",
136 "ns3::LrWpanMac::SentTracedCallback")
137 .AddTraceSource ("IfsEnd",
138 "Trace source reporting the end of an "
139 "Interframe space (IFS) ",
141 "ns3::Packet::TracedCallback")
142 ;
143 return tid;
144}
145
147{
148
149 // First set the state to a known value, call ChangeMacState to fire trace source.
151
153
156
157 m_macRxOnWhenIdle = true;
158 m_macPanId = 0xffff;
160 m_macCoordExtendedAddress = Mac64Address ("ff:ff:ff:ff:ff:ff:ff:ed");
164 m_macPromiscuousMode = false;
168 m_txPkt = 0;
169 m_ifs = 0;
170
171 m_macLIFSPeriod = 40;
172 m_macSIFSPeriod = 12;
173
174 m_macBeaconOrder = 15;
176 m_macTransactionPersistenceTime = 500; //0x01F5
177 m_macAutoRequest = true;
178
181 m_beaconTrackingOn = false;
183
187
188
189 Ptr<UniformRandomVariable> uniformVar = CreateObject<UniformRandomVariable> ();
190 uniformVar->SetAttribute ("Min", DoubleValue (0.0));
191 uniformVar->SetAttribute ("Max", DoubleValue (255.0));
192 m_macDsn = SequenceNumber8 (uniformVar->GetValue ());
193 m_macBsn = SequenceNumber8 (uniformVar->GetValue ());
194 m_shortAddress = Mac16Address ("00:00");
195}
196
198{}
199
200void
202{
204 {
205 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
206 }
207 else
208 {
209 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
210 }
211
213}
214
215void
217{
218 if (m_csmaCa != 0)
219 {
220 m_csmaCa->Dispose ();
221 m_csmaCa = 0;
222 }
223 m_txPkt = 0;
224 for (uint32_t i = 0; i < m_txQueue.size (); i++)
225 {
226 m_txQueue[i]->txQPkt = 0;
227 delete m_txQueue[i];
228 }
229 m_txQueue.clear ();
230 m_phy = 0;
231 m_mcpsDataIndicationCallback = MakeNullCallback< void, McpsDataIndicationParams, Ptr<Packet> > ();
232 m_mcpsDataConfirmCallback = MakeNullCallback< void, McpsDataConfirmParams > ();
233
235
237}
238
239bool
241{
242 return m_macRxOnWhenIdle;
243}
244
245void
246LrWpanMac::SetRxOnWhenIdle (bool rxOnWhenIdle)
247{
248 NS_LOG_FUNCTION (this << rxOnWhenIdle);
249 m_macRxOnWhenIdle = rxOnWhenIdle;
250
252 {
254 {
255 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
256 }
257 else
258 {
259 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
260 }
261 }
262}
263
264void
266{
267 //NS_LOG_FUNCTION (this << address);
269}
270
271void
273{
274 //NS_LOG_FUNCTION (this << address);
276}
277
278
281{
282 NS_LOG_FUNCTION (this);
283 return m_shortAddress;
284}
285
288{
289 NS_LOG_FUNCTION (this);
290 return m_selfExt;
291}
292void
294{
295 NS_LOG_FUNCTION (this << p);
296
297 McpsDataConfirmParams confirmParams;
298 confirmParams.m_msduHandle = params.m_msduHandle;
299
300 // TODO: We need a drop trace for the case that the packet is too large or the request parameters are maleformed.
301 // The current tx drop trace is not suitable, because packets dropped using this trace carry the mac header
302 // and footer, while packets being dropped here do not have them.
303
305 m_macDsn++;
306
308 {
309 // Note, this is just testing maximum theoretical frame size per the spec
310 // The frame could still be too large once headers are put on
311 // in which case the phy will reject it instead
312 NS_LOG_ERROR (this << " packet too big: " << p->GetSize ());
315 {
316 m_mcpsDataConfirmCallback (confirmParams);
317 }
318 return;
319 }
320
321 if ((params.m_srcAddrMode == NO_PANID_ADDR)
322 && (params.m_dstAddrMode == NO_PANID_ADDR))
323 {
324 NS_LOG_ERROR (this << " Can not send packet with no Address field" );
327 {
328 m_mcpsDataConfirmCallback (confirmParams);
329 }
330 return;
331 }
332 switch (params.m_srcAddrMode)
333 {
334 case NO_PANID_ADDR:
335 macHdr.SetSrcAddrMode (params.m_srcAddrMode);
336 macHdr.SetNoPanIdComp ();
337 break;
339 NS_ABORT_MSG ("Can not set source address type to ADDR_MODE_RESERVED. Aborting.");
340 break;
341 case SHORT_ADDR:
342 macHdr.SetSrcAddrMode (params.m_srcAddrMode);
344 break;
345 case EXT_ADDR:
346 macHdr.SetSrcAddrMode (params.m_srcAddrMode);
348 break;
349 default:
350 NS_LOG_ERROR (this << " Can not send packet with incorrect Source Address mode = " << params.m_srcAddrMode);
353 {
354 m_mcpsDataConfirmCallback (confirmParams);
355 }
356 return;
357 }
358 switch (params.m_dstAddrMode)
359 {
360 case NO_PANID_ADDR:
361 macHdr.SetDstAddrMode (params.m_dstAddrMode);
362 macHdr.SetNoPanIdComp ();
363 break;
365 NS_ABORT_MSG ("Can not set destination address type to ADDR_MODE_RESERVED. Aborting.");
366 break;
367 case SHORT_ADDR:
368 macHdr.SetDstAddrMode (params.m_dstAddrMode);
369 macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstAddr);
370 break;
371 case EXT_ADDR:
372 macHdr.SetDstAddrMode (params.m_dstAddrMode);
373 macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstExtAddr);
374 break;
375 default:
376 NS_LOG_ERROR (this << " Can not send packet with incorrect Destination Address mode = " << params.m_dstAddrMode);
379 {
380 m_mcpsDataConfirmCallback (confirmParams);
381 }
382 return;
383 }
384
385 macHdr.SetSecDisable ();
386 //extract the first 3 bits in TxOptions
387 int b0 = params.m_txOptions & TX_OPTION_ACK;
388 int b1 = params.m_txOptions & TX_OPTION_GTS;
389 int b2 = params.m_txOptions & TX_OPTION_INDIRECT;
390
391 if (b0 == TX_OPTION_ACK)
392 {
393 // Set AckReq bit only if the destination is not the broadcast address.
394 if (macHdr.GetDstAddrMode () == SHORT_ADDR)
395 {
396 // short address and ACK requested.
397 Mac16Address shortAddr = macHdr.GetShortDstAddr ();
398 if (shortAddr.IsBroadcast () || shortAddr.IsMulticast ())
399 {
400 NS_LOG_LOGIC ("LrWpanMac::McpsDataRequest: requested an ACK on broadcast or multicast destination (" << shortAddr << ") - forcefully removing it.");
401 macHdr.SetNoAckReq ();
402 params.m_txOptions &= ~uint8_t (TX_OPTION_ACK);
403 }
404 else
405 {
406 macHdr.SetAckReq ();
407 }
408 }
409 else
410 {
411 // other address (not short) and ACK requested
412 macHdr.SetAckReq ();
413 }
414 }
415 else
416 {
417 macHdr.SetNoAckReq ();
418 }
419
420
421 if (b1 == TX_OPTION_GTS)
422 {
423 //TODO:GTS Transmission
424 }
425 else if (b2 == TX_OPTION_INDIRECT)
426 {
427 // Indirect Tx
428 // A COORDINATOR will save the packet in the pending queue and await for data
429 // requests from its associated devices. The devices are aware of pending data,
430 // from the pending bit information extracted from the received beacon.
431 // A DEVICE must be tracking beacons (MLME-SYNC.request is running) before attempting
432 // request data from the coordinator.
433
434
435 //TODO: Check if the current device is coordinator or PAN coordinator
436 p->AddHeader (macHdr);
437
438 LrWpanMacTrailer macTrailer;
439 // Calculate FCS if the global attribute ChecksumEnable is set.
441 {
442 macTrailer.EnableFcs (true);
443 macTrailer.SetFcs (p);
444 }
445 p->AddTrailer (macTrailer);
446
447 if (m_txQueue.size () == m_txQueue.max_size ())
448 {
451 {
452 m_mcpsDataConfirmCallback (confirmParams);
453 }
454 }
455 else
456 {
457 NS_LOG_ERROR (this << " Indirect transmissions not currently supported");
458 // Note: The current Pending transaction list should work for indirect transmissions.
459 // However, this is not tested yet. For now, we block the use of indirect transmissions.
460 // TODO: Save packet in the Pending Transaction list.
461 // EnqueueInd (p);
462 }
463 }
464 else
465 {
466 // Direct Tx
467 // From this point the packet will be pushed to a Tx queue and immediately
468 // use a slotted (beacon-enabled) or unslotted (nonbeacon-enabled) version of CSMA/CA
469 // before sending the packet, depending on whether it has previously
470 // received a valid beacon or not.
471
472 p->AddHeader (macHdr);
473
474 LrWpanMacTrailer macTrailer;
475 // Calculate FCS if the global attribute ChecksumEnable is set.
477 {
478 macTrailer.EnableFcs (true);
479 macTrailer.SetFcs (p);
480 }
481 p->AddTrailer (macTrailer);
482
484
485 TxQueueElement *txQElement = new TxQueueElement;
486 txQElement->txQMsduHandle = params.m_msduHandle;
487 txQElement->txQPkt = p;
488 m_txQueue.push_back (txQElement);
489 CheckQueue ();
490 }
491
492}
493
494
495void
497{
498 NS_LOG_FUNCTION (this);
500
501 MlmeStartConfirmParams confirmParams;
502
503 if (GetShortAddress () == Mac16Address ("ff:ff"))
504 {
505 NS_LOG_ERROR (this << " Invalid MAC short address" );
506 confirmParams.m_status = MLMESTART_NO_SHORT_ADDRESS;
508 {
509 m_mlmeStartConfirmCallback (confirmParams);
510 }
511 return;
512 }
513
514 if ((params.m_bcnOrd > 15) || (params.m_sfrmOrd > params.m_bcnOrd))
515 {
518 {
519 m_mlmeStartConfirmCallback (confirmParams);
520 }
521 NS_LOG_ERROR (this << "Incorrect superframe order or beacon order." );
522 return;
523 }
524
525 // Mark primitive as pending and save the start params while the new page and channel is set.
527 m_startParams = params;
528
531 m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentPage,&pibAttr);
532
533}
534
535void
537{
538 NS_LOG_FUNCTION (this);
539
540 MlmeScanConfirmParams confirmParams;
541 confirmParams.m_scanType = params.m_scanType;
542 confirmParams.m_chPage = params.m_chPage;
543
545 {
547 {
548 confirmParams.m_status = MLMESCAN_SCAN_IN_PROGRESS;
549 m_mlmeScanConfirmCallback (confirmParams);
550 }
551 NS_LOG_ERROR (this << " A channel scan is already in progress");
552 return;
553 }
554
555 if (params.m_scanDuration > 14 || params.m_scanType > MLMESCAN_PASSIVE)
556 {
558 {
559 confirmParams.m_status = MLMESCAN_INVALID_PARAMETER;
560 m_mlmeScanConfirmCallback (confirmParams);
561 }
562 NS_LOG_ERROR (this << "Invalid scan duration or unsupported scan type");
563 return;
564 }
565 // Temporary store macPanId and set macPanId to 0xFFFF to accept all beacons.
567 m_macPanId = 0xFFFF;
568
569
570 m_panDescriptorList.clear ();
571 m_energyDetectList.clear ();
572
573 //TODO: stop beacon transmission
574
575 // Cancel any ongoing CSMA/CA operations and set to unslotted mode for scan
576 m_csmaCa->Cancel ();
582 m_csmaCa->SetUnSlottedCsmaCa ();
583
584
586
587 // Mark primitive as pending and save the scan params while the new page and/or channel is set.
588 m_scanParams = params;
590
592 pibAttr.phyCurrentPage = params.m_chPage;
593 m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentPage,&pibAttr);
594
595}
596
597void
599{
600 NS_LOG_FUNCTION (this);
601 NS_ASSERT (params.m_logCh <= 26 && m_macPanId != 0xffff);
602
603 uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
604 //change phy current logical channel
606 pibAttr.phyCurrentChannel = params.m_logCh;
607 m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentChannel,&pibAttr);
608
609 //Enable Phy receiver
610 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
611
612 uint64_t searchSymbols;
613 Time searchBeaconTime;
614
616 {
618 }
619
620 if (params.m_trackBcn)
621 {
623 //search for a beacon for a time = incomingSuperframe symbols + 960 symbols
624 searchSymbols = ((uint64_t) 1 << m_incomingBeaconOrder) + 1 * aBaseSuperframeDuration;
625 searchBeaconTime = Seconds ((double) searchSymbols / symbolRate);
626 m_beaconTrackingOn = true;
628 }
629 else
630 {
631 m_beaconTrackingOn = false;
632 }
633
634}
635
636
637void
639{
640 NS_LOG_FUNCTION (this);
641
643 m_macBsn++;
644
646
647 Ptr<Packet> beaconPacket = Create <Packet> ();
648}
649
650
651void
653{
654 NS_LOG_FUNCTION (this);
656
658 m_macBsn++;
659 BeaconPayloadHeader macPayload;
660 Ptr<Packet> beaconPacket = Create <Packet> ();
661 LrWpanMacTrailer macTrailer;
662
664 macHdr.SetDstAddrFields (GetPanId (),Mac16Address ("ff:ff"));
665
666 //see IEEE 802.15.4-2011 Section 5.1.2.4
667 if (GetShortAddress () == Mac16Address ("ff:fe"))
668 {
671 }
672 else
673 {
676 }
677
678 macHdr.SetSecDisable ();
679 macHdr.SetNoAckReq ();
680
682 macPayload.SetGtsFields (GetGtsFields ());
684
685 beaconPacket->AddHeader (macPayload);
686 beaconPacket->AddHeader (macHdr);
687
688 // Calculate FCS if the global attribute ChecksumEnable is set.
690 {
691 macTrailer.EnableFcs (true);
692 macTrailer.SetFcs (beaconPacket);
693 }
694
695 beaconPacket->AddTrailer (macTrailer);
696
697 //Set the Beacon packet to be transmitted
698 m_txPkt = beaconPacket;
699
700 if (m_csmaCa->IsSlottedCsmaCa ())
701 {
703 NS_LOG_DEBUG ("Outgoing superframe Active Portion (Beacon + CAP + CFP): " << m_superframeDuration << " symbols");
704 }
705
707 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
708
709}
710
711void
713{
714 NS_LOG_FUNCTION (this);
715
717 m_macDsn++;
718 LrWpanMacTrailer macTrailer;
719 Ptr<Packet> commandPacket = Create <Packet> ();
720
721 // Beacon Request Command Mac header values See IEEE 802.15.4-2011 (Section 5.3.7)
722 macHdr.SetNoPanIdComp ();
725
726 macHdr.SetDstAddrFields (0xFFFF, Mac16Address ("FF:FF")); // Not associated PAN, broadcast dst address
727
728 macHdr.SetSecDisable ();
729 macHdr.SetNoAckReq ();
730
731 CommandPayloadHeader macPayload;
733
734 commandPacket->AddHeader (macPayload);
735 commandPacket->AddHeader (macHdr);
736
737
738 // Calculate FCS if the global attribute ChecksumEnable is set.
740 {
741 macTrailer.EnableFcs (true);
742 macTrailer.SetFcs (commandPacket);
743 }
744
745 commandPacket->AddTrailer (macTrailer);
746
747 TxQueueElement *txQElement = new TxQueueElement;
748 txQElement->txQPkt = commandPacket;
749 m_txQueue.push_back (txQElement);
750 CheckQueue ();
751
752}
753
754void
756{
757 NS_LOG_FUNCTION (this);
758 // The primitive is no longer pending (Channel & Page have been set)
760
761 if (m_startParams.m_coorRealgn) //Coordinator Realignment
762 {
763 // TODO: Send realignment request command frame in CSMA/CA
764 return;
765 }
766 else
767 {
769 {
770 m_panCoor = true;
772 }
773
774 NS_ASSERT (m_startParams.m_PanId != 0xffff);
775
777 if (m_macBeaconOrder == 15)
778 {
779 // Non-beacon enabled PAN
780 // Cancel any ongoing events and CSMA-CA process
782 m_fnlCapSlot = 15;
784
785
786 m_csmaCa->Cancel ();
794
795 m_csmaCa->SetUnSlottedCsmaCa ();
796
798 {
799 MlmeStartConfirmParams confirmParams;
800 confirmParams.m_status = MLMESTART_SUCCESS;
801 m_mlmeStartConfirmCallback (confirmParams);
802 }
803
804 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
805
806 }
807 else
808 {
810 m_csmaCa->SetBatteryLifeExtension (m_startParams.m_battLifeExt);
811
812 m_csmaCa->SetSlottedCsmaCa ();
813
814 //TODO: Calculate the real Final CAP slot (requires GTS implementation)
815 // FinalCapSlot = Superframe duration slots - CFP slots.
816 // In the current implementation the value of the final cap slot is equal to
817 // the total number of possible slots in the superframe (15).
818 m_fnlCapSlot = 15;
819
822
823 //TODO: change the beacon sending according to the startTime parameter (if not PAN coordinator)
824
826 }
827 }
828}
829
830void
832{
833 NS_LOG_FUNCTION (this);
834
836
837 bool channelFound = false;
838
839 for (int i = m_channelScanIndex; i <= 26; i++)
840 {
842 {
843 channelFound = true;
844 break;
845 }
847 }
848
849
850 if (channelFound)
851 {
852 // Switch to the next channel in the list and restart scan
855 m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentChannel,&pibAttr);
856 }
857 else
858 {
859 // All scans on the channel list completed
860 // Return to the MAC values previous to start of the first scan.
862 m_macPanIdScan = 0;
863
864 // TODO: restart beacon transmissions that were active before the beginning of the scan
865 // (i.e when a coordinator perform a scan and it was already transmitting beacons)
866
867 // All channels scanned, report success
868 MlmeScanConfirmParams confirmParams;
869 confirmParams.m_status = MLMESCAN_SUCCESS;
870 confirmParams.m_chPage = m_scanParams.m_chPage;
871 confirmParams.m_scanType = m_scanParams.m_scanType;
872 confirmParams.m_energyDetList = {};
873 confirmParams.m_panDescList = m_panDescriptorList;
874
875
877 {
878 m_mlmeScanConfirmCallback (confirmParams);
879 }
880
883 m_scanParams = {};
884 }
885}
886
887void
889{
890 NS_LOG_FUNCTION (this);
891 // Add the results of channel energy scan to the detectList
894
896
897 bool channelFound = false;
898 for (int i = m_channelScanIndex; i <= 26; i++)
899 {
901 {
902 channelFound = true;
903 break;
904 }
906 }
907
908 if (channelFound)
909 {
910 //switch to the next channel in the list and restart scan
913 m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentChannel,&pibAttr);
914 }
915 else
916 {
917 // Scan on all channels on the list completed
918 // Return to the MAC values previous to start of the first scan.
920 m_macPanIdScan = 0;
921
922 // TODO: restart beacon transmissions that were active before the beginning of the scan
923 // (i.e when a coordinator perform a scan and it was already transmitting beacons)
924
925 // All channels scanned, report success
927 {
928 MlmeScanConfirmParams confirmParams;
929 confirmParams.m_status = MLMESCAN_SUCCESS;
930 confirmParams.m_chPage = m_phy->GetCurrentPage ();
931 confirmParams.m_scanType = m_scanParams.m_scanType;
932 confirmParams.m_energyDetList = m_energyDetectList;
933 m_mlmeScanConfirmCallback (confirmParams);
934 }
937 m_scanParams = {};
938
939 }
940}
941
942void
944{
945 uint32_t activeSlot;
946 uint64_t capDuration;
947 Time endCapTime;
948 uint64_t symbolRate;
949
950 symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
951
952 if (superframeType == OUTGOING)
953 {
955 activeSlot = m_superframeDuration / 16;
956 capDuration = activeSlot * (m_fnlCapSlot + 1);
957 endCapTime = Seconds ((double) capDuration / symbolRate);
958 // Obtain the end of the CAP by adjust the time it took to send the beacon
959 endCapTime -= (Simulator::Now () - m_macBeaconTxTime);
960
961 NS_LOG_DEBUG ("Outgoing superframe CAP duration " << (endCapTime.GetSeconds () * symbolRate) << " symbols (" << endCapTime.As (Time::S) << ")");
962 NS_LOG_DEBUG ("Active Slots duration " << activeSlot << " symbols");
963
964 m_capEvent = Simulator::Schedule (endCapTime,
966
967 }
968 else
969 {
971 activeSlot = m_incomingSuperframeDuration / 16;
972 capDuration = activeSlot * (m_incomingFnlCapSlot + 1);
973 endCapTime = Seconds ((double) capDuration / symbolRate);
974 // Obtain the end of the CAP by adjust the time it took to receive the beacon
975 endCapTime -= (Simulator::Now () - m_macBeaconRxTime);
976
977 NS_LOG_DEBUG ("Incoming superframe CAP duration " << (endCapTime.GetSeconds () * symbolRate) << " symbols (" << endCapTime.As (Time::S) << ")");
978 NS_LOG_DEBUG ("Active Slots duration " << activeSlot << " symbols");
979
980 m_capEvent = Simulator::Schedule (endCapTime,
982 }
983
984 CheckQueue ();
985
986}
987
988
989void
991{
992 uint32_t activeSlot;
993 uint64_t cfpDuration;
994 Time endCfpTime;
995 uint64_t symbolRate;
996
997 symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
998
999 if (superframeType == INCOMING)
1000 {
1001 activeSlot = m_incomingSuperframeDuration / 16;
1002 cfpDuration = activeSlot * (15 - m_incomingFnlCapSlot);
1003 endCfpTime = Seconds ((double) cfpDuration / symbolRate);
1004 if (cfpDuration > 0)
1005 {
1007 }
1008
1009 NS_LOG_DEBUG ("Incoming superframe CFP duration " << cfpDuration << " symbols (" << endCfpTime.As (Time::S) << ")");
1010
1011 m_incCfpEvent = Simulator::Schedule (endCfpTime,
1013 }
1014 else
1015 {
1016 activeSlot = m_superframeDuration / 16;
1017 cfpDuration = activeSlot * (15 - m_fnlCapSlot);
1018 endCfpTime = Seconds ((double) cfpDuration / symbolRate);
1019
1020 if (cfpDuration > 0)
1021 {
1023 }
1024
1025 NS_LOG_DEBUG ("Outgoing superframe CFP duration " << cfpDuration << " symbols (" << endCfpTime.As (Time::S) << ")");
1026
1027 m_cfpEvent = Simulator::Schedule (endCfpTime,
1029
1030 }
1031 //TODO: Start transmit or receive GTS here.
1032}
1033
1034
1035void
1037{
1038 uint64_t inactiveDuration;
1039 Time endInactiveTime;
1040 uint64_t symbolRate;
1041
1042 symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
1043
1044 if (superframeType == INCOMING)
1045 {
1047 endInactiveTime = Seconds ((double) inactiveDuration / symbolRate);
1048
1049 if (inactiveDuration > 0)
1050 {
1052 }
1053
1054 NS_LOG_DEBUG ("Incoming superframe Inactive Portion duration " << inactiveDuration << " symbols (" << endInactiveTime.As (Time::S) << ")");
1055 m_beaconEvent = Simulator::Schedule (endInactiveTime, &LrWpanMac::AwaitBeacon, this);
1056 }
1057 else
1058 {
1059 inactiveDuration = m_beaconInterval - m_superframeDuration;
1060 endInactiveTime = Seconds ((double) inactiveDuration / symbolRate);
1061
1062 if (inactiveDuration > 0)
1063 {
1065 }
1066
1067 NS_LOG_DEBUG ("Outgoing superframe Inactive Portion duration " << inactiveDuration << " symbols (" << endInactiveTime.As (Time::S) << ")");
1069 }
1070}
1071
1072void
1074{
1076
1077 //TODO: If the device waits more than the expected time to receive the beacon (wait = 46 symbols for default beacon size)
1078 // it should continue with the start of the incoming CAP even if it did not receive the beacon.
1079 // At the moment, the start of the incoming CAP is only triggered if the beacon is received.
1080 // See MLME-SyncLoss for details.
1081
1082
1083}
1084
1085void
1087{
1088 uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
1089
1091 {
1092 MlmeSyncLossIndicationParams syncLossParams;
1093 //syncLossParams.m_logCh =
1094 syncLossParams.m_lossReason = MLMESYNCLOSS_BEACON_LOST;
1095 syncLossParams.m_panId = m_macPanId;
1096 m_mlmeSyncLossIndicationCallback (syncLossParams);
1097
1098 m_beaconTrackingOn = false;
1099 m_numLostBeacons = 0;
1100 }
1101 else
1102 {
1104
1105 //Search for one more beacon
1106 uint64_t searchSymbols;
1107 Time searchBeaconTime;
1108 searchSymbols = ((uint64_t) 1 << m_incomingBeaconOrder) + 1 * aBaseSuperframeDuration;
1109 searchBeaconTime = Seconds ((double) searchSymbols / symbolRate);
1111
1112 }
1113}
1114
1115
1116void
1118{
1119 NS_LOG_FUNCTION (this);
1120 // Pull a packet from the queue and start sending if we are not already sending.
1121 if (m_lrWpanMacState == MAC_IDLE && !m_txQueue.empty () && !m_setMacState.IsRunning ())
1122 {
1123 //TODO: this should check if the node is a coordinator and using the outcoming superframe not just the PAN coordinator
1124 if (m_csmaCa->IsUnSlottedCsmaCa () || (m_outSuperframeStatus == CAP && m_panCoor) || m_incSuperframeStatus == CAP)
1125 {
1126 // check MAC is not in a IFS
1127 if (!m_ifsEvent.IsRunning ())
1128 {
1129 TxQueueElement *txQElement = m_txQueue.front ();
1130 m_txPkt = txQElement->txQPkt;
1132 }
1133 }
1134 }
1135}
1136
1137
1140{
1141 SuperframeField sfrmSpec;
1142
1145 sfrmSpec.SetFinalCapSlot (m_fnlCapSlot);
1146
1147 if (m_csmaCa->GetBatteryLifeExtension ())
1148 {
1149 sfrmSpec.SetBattLifeExt (true);
1150 }
1151
1152 if (m_panCoor)
1153 {
1154 sfrmSpec.SetPanCoor (true);
1155 }
1156 //TODO: It is possible to do association using Beacons,
1157 // however, the current implementation only support manual association.
1158 // The association permit should be set here.
1159
1160 return sfrmSpec;
1161}
1162
1165{
1166 GtsFields gtsFields;
1167
1168 // TODO: Logic to populate the GTS Fields from local information here
1169
1170 return gtsFields;
1171}
1172
1175{
1176 PendingAddrFields pndAddrFields;
1177
1178 // TODO: Logic to populate the Pending Address Fields from local information here
1179 return pndAddrFields;
1180}
1181
1182
1183void
1185{
1186 m_csmaCa = csmaCa;
1187}
1188
1189void
1191{
1192 m_phy = phy;
1193}
1194
1197{
1198 return m_phy;
1199}
1200
1201void
1203{
1205}
1206
1207void
1209{
1211}
1212
1213void
1215{
1217}
1218
1219void
1221{
1223}
1224
1225void
1227{
1229}
1230
1231void
1233{
1235}
1236
1237void
1239{
1241}
1242
1243void
1245{
1247}
1248
1249void
1251{
1253}
1254
1255void
1257{
1259}
1260
1261void
1263{
1265 NS_LOG_FUNCTION (this << psduLength << p << (uint16_t)lqi);
1266
1267 bool acceptFrame;
1268
1269 // from sec 7.5.6.2 Reception and rejection, Std802.15.4-2006
1270 // level 1 filtering, test FCS field and reject if frame fails
1271 // level 2 filtering if promiscuous mode pass frame to higher layer otherwise perform level 3 filtering
1272 // level 3 filtering accept frame
1273 // if Frame type and version is not reserved, and
1274 // if there is a dstPanId then dstPanId=m_macPanId or broadcastPanId, and
1275 // if there is a shortDstAddr then shortDstAddr =shortMacAddr or broadcastAddr, and
1276 // if beacon frame then srcPanId = m_macPanId
1277 // if only srcAddr field in Data or Command frame,accept frame if srcPanId=m_macPanId
1278
1279 Ptr<Packet> originalPkt = p->Copy (); // because we will strip headers
1280 uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
1281 m_promiscSnifferTrace (originalPkt);
1282
1283 m_macPromiscRxTrace (originalPkt);
1284 // XXX no rejection tracing (to macRxDropTrace) being performed below
1285
1286 LrWpanMacTrailer receivedMacTrailer;
1287 p->RemoveTrailer (receivedMacTrailer);
1288 if (Node::ChecksumEnabled ())
1289 {
1290 receivedMacTrailer.EnableFcs (true);
1291 }
1292
1293 // level 1 filtering
1294 if (!receivedMacTrailer.CheckFcs (p))
1295 {
1296 m_macRxDropTrace (originalPkt);
1297 }
1298 else
1299 {
1300 LrWpanMacHeader receivedMacHdr;
1301 p->RemoveHeader (receivedMacHdr);
1302
1304 params.m_dsn = receivedMacHdr.GetSeqNum ();
1305 params.m_mpduLinkQuality = lqi;
1306 params.m_srcPanId = receivedMacHdr.GetSrcPanId ();
1307 params.m_srcAddrMode = receivedMacHdr.GetSrcAddrMode ();
1308 switch (params.m_srcAddrMode)
1309 {
1310 case SHORT_ADDR:
1311 params.m_srcAddr = receivedMacHdr.GetShortSrcAddr ();
1312 break;
1313 case EXT_ADDR:
1314 params.m_srcExtAddr = receivedMacHdr.GetExtSrcAddr ();
1315 break;
1316 default:
1317 break;
1318 }
1319 params.m_dstPanId = receivedMacHdr.GetDstPanId ();
1320 params.m_dstAddrMode = receivedMacHdr.GetDstAddrMode ();
1321 switch (params.m_dstAddrMode)
1322 {
1323 case SHORT_ADDR:
1324 params.m_dstAddr = receivedMacHdr.GetShortDstAddr ();
1325 break;
1326 case EXT_ADDR:
1327 params.m_dstExtAddr = receivedMacHdr.GetExtDstAddr ();
1328 break;
1329 default:
1330 break;
1331 }
1332
1334 {
1335 //level 2 filtering
1336 if (receivedMacHdr.GetDstAddrMode () == SHORT_ADDR)
1337 {
1338 NS_LOG_DEBUG ("Packet from " << params.m_srcAddr);
1339 NS_LOG_DEBUG ("Packet to " << params.m_dstAddr);
1340 }
1341 else if (receivedMacHdr.GetDstAddrMode () == EXT_ADDR)
1342 {
1343 NS_LOG_DEBUG ("Packet from " << params.m_srcExtAddr);
1344 NS_LOG_DEBUG ("Packet to " << params.m_dstExtAddr);
1345 }
1346
1347 //TODO: Fix here, this should trigger different Indication Callbacks
1348 //depending the type of frame received (data,command, beacon)
1350 {
1351 NS_LOG_DEBUG ("promiscuous mode, forwarding up");
1352 m_mcpsDataIndicationCallback (params, p);
1353 }
1354 else
1355 {
1356 NS_LOG_ERROR (this << " Data Indication Callback not initialized");
1357 }
1358 }
1359 else
1360 {
1361 //level 3 frame filtering
1362 acceptFrame = (receivedMacHdr.GetType () != LrWpanMacHeader::LRWPAN_MAC_RESERVED);
1363
1364 if (acceptFrame)
1365 {
1366 acceptFrame = (receivedMacHdr.GetFrameVer () <= 1);
1367 }
1368
1369 if (acceptFrame
1370 && (receivedMacHdr.GetDstAddrMode () > 1))
1371 {
1372 // Accept frame if:
1373
1374 // 1) Have the same macPanId
1375 // 2) Or is Message to all PANs
1376 // 3) Or Is a beacon and the macPanId is not present (bootstrap)
1377 acceptFrame = (receivedMacHdr.GetDstPanId () == m_macPanId || receivedMacHdr.GetDstPanId () == 0xffff)
1378 || (m_macPanId == 0xffff && receivedMacHdr.IsBeacon ());
1379 }
1380
1381 if (acceptFrame
1382 && (receivedMacHdr.GetShortDstAddr () == Mac16Address ("FF:FF")))
1383 {
1384 // A broadcast message (e.g. beacons) should not be received by the device who issues it.
1385 acceptFrame = (receivedMacHdr.GetShortSrcAddr () != GetShortAddress ());
1386 // TODO: shouldn't this be filtered by the PHY?
1387 }
1388
1389 if (acceptFrame
1390 && (receivedMacHdr.GetDstAddrMode () == SHORT_ADDR))
1391 {
1392 if (receivedMacHdr.GetShortDstAddr () == m_shortAddress)
1393 {
1394 // unicast, for me
1395 acceptFrame = true;
1396 }
1397 else if (receivedMacHdr.GetShortDstAddr ().IsBroadcast () || receivedMacHdr.GetShortDstAddr ().IsMulticast ())
1398 {
1399 // broadcast or multicast
1400 if (receivedMacHdr.IsAckReq ())
1401 {
1402 // discard broadcast/multicast with the ACK bit set
1403 acceptFrame = false;
1404 }
1405 else
1406 {
1407 acceptFrame = true;
1408 }
1409 }
1410 else
1411 {
1412 acceptFrame = false;
1413 }
1414 }
1415
1416 if (acceptFrame
1417 && (receivedMacHdr.GetDstAddrMode () == EXT_ADDR))
1418 {
1419 acceptFrame = (receivedMacHdr.GetExtDstAddr () == m_selfExt);
1420 }
1421
1422
1423 // When PASSIVE or ACTIVE scan is running, reject any frames other than BEACON frames
1424 if (acceptFrame && (!receivedMacHdr.IsBeacon () && m_scanEvent.IsRunning ()))
1425 {
1426 acceptFrame = false;
1427 }
1428
1429 // Energy Scan is running, reject any frames
1431 {
1432 acceptFrame = false;
1433 }
1434
1435 if (acceptFrame
1436 && ((receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_DATA)
1437 || (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_COMMAND))
1438 && (receivedMacHdr.GetSrcAddrMode () > 1))
1439 {
1440 acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId; // TODO: need to check if PAN coord
1441 }
1442
1443 if (acceptFrame)
1444 {
1445 m_macRxTrace (originalPkt);
1446 // \todo: What should we do if we receive a frame while waiting for an ACK?
1447 // Especially if this frame has the ACK request bit set, should we reply with an ACK, possibly missing the pending ACK?
1448
1449 // If the received frame is a frame with the ACK request bit set, we immediately send back an ACK.
1450 // If we are currently waiting for a pending ACK, we assume the ACK was lost and trigger a retransmission after sending the ACK.
1451 if ((receivedMacHdr.IsData () || receivedMacHdr.IsCommand ()) && receivedMacHdr.IsAckReq ()
1452 && !(receivedMacHdr.GetDstAddrMode () == SHORT_ADDR && (receivedMacHdr.GetShortDstAddr ().IsBroadcast () || receivedMacHdr.GetShortDstAddr ().IsMulticast ())))
1453 {
1454 // If this is a data or mac command frame, which is not a broadcast or multicast,
1455 // with ack req set, generate and send an ack frame.
1456 // If there is a CSMA medium access in progress we cancel the medium access
1457 // for sending the ACK frame. A new transmission attempt will be started
1458 // after the ACK was send.
1460 {
1463 }
1464 else if (m_lrWpanMacState == MAC_CSMA)
1465 {
1466 // \todo: If we receive a packet while doing CSMA/CA, should we drop the packet because of channel busy,
1467 // or should we restart CSMA/CA for the packet after sending the ACK?
1468 // Currently we simply restart CSMA/CA after sending the ACK.
1469 m_csmaCa->Cancel ();
1470 }
1471 // Cancel any pending MAC state change, ACKs have higher priority.
1474
1476 }
1477
1478
1479 if (receivedMacHdr.GetDstAddrMode () == SHORT_ADDR)
1480 {
1481 NS_LOG_DEBUG ("Packet from " << params.m_srcAddr);
1482 NS_LOG_DEBUG ("Packet to " << params.m_dstAddr);
1483 }
1484 else if (receivedMacHdr.GetDstAddrMode () == EXT_ADDR)
1485 {
1486 NS_LOG_DEBUG ("Packet from " << params.m_srcExtAddr);
1487 NS_LOG_DEBUG ("Packet to " << params.m_dstExtAddr);
1488 }
1489
1490
1491 if (receivedMacHdr.IsBeacon ())
1492 {
1493
1494
1495 // The received beacon size in symbols
1496 // Beacon = 5 bytes Sync Header (SHR) + 1 byte PHY header (PHR) + PSDU (default 17 bytes)
1497 m_rxBeaconSymbols = m_phy->GetPhySHRDuration () + 1 * m_phy->GetPhySymbolsPerOctet () +
1498 (originalPkt->GetSize () * m_phy->GetPhySymbolsPerOctet ());
1499
1500 // The start of Rx beacon time and start of the Incoming superframe Active Period
1501 m_macBeaconRxTime = Simulator::Now () - Seconds (double(m_rxBeaconSymbols) / symbolRate);
1502
1503 NS_LOG_DEBUG ("Beacon Received; forwarding up (m_macBeaconRxTime: " << m_macBeaconRxTime.As (Time::S) << ")");
1504
1505 BeaconPayloadHeader receivedMacPayload;
1506 p->RemoveHeader (receivedMacPayload);
1507
1508 // Fill the PAN descriptor
1509 PanDescriptor panDescriptor;
1510
1511 if (receivedMacHdr.GetSrcAddrMode () == SHORT_ADDR)
1512 {
1513 panDescriptor.m_coorAddrMode = SHORT_ADDR;
1514 panDescriptor.m_coorShortAddr = receivedMacHdr.GetShortSrcAddr ();
1515 }
1516 else
1517 {
1518 panDescriptor.m_coorAddrMode = EXT_ADDR;
1519 panDescriptor.m_coorExtAddr = receivedMacHdr.GetExtSrcAddr ();
1520 }
1521
1522 panDescriptor.m_coorPanId = receivedMacHdr.GetSrcPanId ();
1523 panDescriptor.m_gtsPermit = receivedMacPayload.GetGtsFields ().GetGtsPermit ();
1524 panDescriptor.m_linkQuality = lqi;
1525 panDescriptor.m_logChPage = m_phy->GetCurrentPage ();
1526 panDescriptor.m_logCh = m_phy->GetCurrentChannelNum ();
1527 panDescriptor.m_superframeSpec = receivedMacPayload.GetSuperframeSpecField ();
1528 panDescriptor.m_timeStamp = m_macBeaconRxTime;
1529
1530 // Process beacon when device belongs to a PAN (associated device)
1531 if (!m_scanEvent.IsRunning () && m_macPanId == receivedMacHdr.GetDstPanId () )
1532 {
1533 SuperframeField incomingSuperframe;
1534 incomingSuperframe = receivedMacPayload.GetSuperframeSpecField ();
1535
1536 m_incomingBeaconOrder = incomingSuperframe.GetBeaconOrder ();
1537 m_incomingSuperframeOrder = incomingSuperframe.GetFrameOrder ();
1538 m_incomingFnlCapSlot = incomingSuperframe.GetFinalCapSlot ();
1539
1542
1543 if (incomingSuperframe.IsBattLifeExt ())
1544 {
1545 m_csmaCa->SetBatteryLifeExtension (true);
1546 }
1547 else
1548 {
1549 m_csmaCa->SetBatteryLifeExtension (false);
1550 }
1551
1552 if (m_incomingBeaconOrder < 15 && !m_csmaCa->IsSlottedCsmaCa ())
1553 {
1554 m_csmaCa->SetSlottedCsmaCa ();
1555 }
1556
1557 //TODO: get Incoming frame GTS Fields here
1558
1559 //Begin CAP on the current device using info from the Incoming superframe
1560 NS_LOG_DEBUG ("Incoming superframe Active Portion (Beacon + CAP + CFP): " << m_incomingSuperframeDuration << " symbols");
1563 }
1564 else if (!m_scanEvent.IsRunning () && m_macPanId == 0xFFFF)
1565 {
1566 NS_LOG_DEBUG (this << " Device not associated, cannot process beacon");
1567 }
1568
1569 if (m_macAutoRequest)
1570 {
1571 if (p->GetSize () > 0)
1572 {
1574 {
1575 // The beacon contains payload, send the beacon notification.
1577 beaconParams.m_bsn = receivedMacHdr.GetSeqNum ();
1578 beaconParams.m_panDescriptor = panDescriptor;
1579 beaconParams.m_sduLength = p->GetSize ();
1580 beaconParams.m_sdu = p;
1581 m_mlmeBeaconNotifyIndicationCallback (beaconParams,originalPkt);
1582 }
1583 }
1584
1585 if (m_scanEvent.IsRunning ())
1586 {
1587 // Channel scanning is taking place, save only unique PAN descriptors
1588 bool descriptorExists = false;
1589
1590 for (const auto &descriptor : m_panDescriptorList)
1591 {
1592 if (descriptor.m_coorAddrMode == SHORT_ADDR)
1593 {
1594 // Found a coordinator in PAN descriptor list with the same registered short address
1595 descriptorExists = (descriptor.m_coorShortAddr == panDescriptor.m_coorShortAddr
1596 && descriptor.m_coorPanId == panDescriptor.m_coorPanId);
1597 }
1598 else
1599 {
1600 // Found a coordinator in PAN descriptor list with the same registered extended address
1601 descriptorExists = (descriptor.m_coorExtAddr == panDescriptor.m_coorExtAddr
1602 && descriptor.m_coorPanId == panDescriptor.m_coorPanId);
1603 }
1604
1605 if (descriptorExists)
1606 {
1607 break;
1608 }
1609 }
1610
1611 if (!descriptorExists)
1612 {
1613 m_panDescriptorList.push_back (panDescriptor);
1614 }
1615 return;
1616 }
1617 else if (m_trackingEvent.IsRunning ())
1618 {
1619 // check if MLME-SYNC.request was previously issued and running
1620 // Sync. is necessary to handle pending messages (indirect transmissions)
1622 m_numLostBeacons = 0;
1623
1625 {
1626 //if tracking option is on keep tracking the next beacon
1627 uint64_t searchSymbols;
1628 Time searchBeaconTime;
1629
1630 searchSymbols = (static_cast<uint64_t> (1 << m_incomingBeaconOrder)) + 1 * aBaseSuperframeDuration;
1631 searchBeaconTime = Seconds (static_cast<double> (searchSymbols / symbolRate));
1633 }
1634
1635 PendingAddrFields pndAddrFields;
1636 pndAddrFields = receivedMacPayload.GetPndAddrFields ();
1637
1638 //TODO: Ignore pending data, and donot send data command request if the address is in the GTS list.
1639 // If the address is not in the GTS list, then check if the address
1640 // is in the short address pending list or in the extended address
1641 // pending list and send a data command request.
1642
1643 }
1644 }
1645 else
1646 {
1647 // m_macAutoRequest is FALSE
1648 // Data command request are not send, only the beacon notification.
1649 // see IEEE 802.15.4-2011 Section 6.2.4.1
1651 {
1653 beaconParams.m_bsn = receivedMacHdr.GetSeqNum ();
1654 beaconParams.m_panDescriptor = panDescriptor;
1655 m_mlmeBeaconNotifyIndicationCallback (beaconParams,originalPkt);
1656 }
1657 }
1658 }
1659 else if (receivedMacHdr.IsCommand ())
1660 {
1661 // Handle the reception of frame commands that do not require ACK (i.e. Beacon Request Command)
1662 CommandPayloadHeader receivedMacPayload;
1663 p->PeekHeader (receivedMacPayload);
1664 if (receivedMacPayload.GetCommandFrameType () == CommandPayloadHeader::BEACON_REQ)
1665 {
1666 // TODO: check that node is any coordinator not just pan coordinator
1667 if (m_csmaCa->IsUnSlottedCsmaCa () && m_panCoor)
1668 {
1669 SendOneBeacon ();
1670 }
1671 else
1672 {
1673 m_macRxDropTrace (originalPkt);
1674 }
1675 }
1676 }
1677 else if (receivedMacHdr.IsData () && !m_mcpsDataIndicationCallback.IsNull ())
1678 {
1679 // If it is a data frame, push it up the stack.
1680 NS_LOG_DEBUG ("Data Packet is for me; forwarding up");
1681 m_mcpsDataIndicationCallback (params, p);
1682 }
1683 else if (receivedMacHdr.IsAcknowledgment () && m_txPkt && m_lrWpanMacState == MAC_ACK_PENDING)
1684 {
1685 LrWpanMacHeader macHdr;
1686 Time ifsWaitTime = Seconds ((double) GetIfsSize () / symbolRate);
1687 m_txPkt->PeekHeader (macHdr);
1688 if (receivedMacHdr.GetSeqNum () == macHdr.GetSeqNum ())
1689 {
1691 // If it is an ACK with the expected sequence number, finish the transmission
1692 // and notify the upper layer.
1695 {
1696 TxQueueElement *txQElement = m_txQueue.front ();
1697 McpsDataConfirmParams confirmParams;
1698 confirmParams.m_msduHandle = txQElement->txQMsduHandle;
1699 confirmParams.m_status = IEEE_802_15_4_SUCCESS;
1700 m_mcpsDataConfirmCallback (confirmParams);
1701 }
1705 // Ack was succesfully received, wait for the Interframe Space (IFS) and then proceed
1706 m_ifsEvent = Simulator::Schedule (ifsWaitTime, &LrWpanMac::IfsWaitTimeout, this, ifsWaitTime);
1707 }
1708 else
1709 {
1710 // If it is an ACK with an unexpected sequence number, mark the current transmission as failed and start a retransmit. (cf 7.5.6.4.3)
1712 if (!PrepareRetransmission ())
1713 {
1716 }
1717 else
1718 {
1721 }
1722 }
1723 }
1724 }
1725 else
1726 {
1727 m_macRxDropTrace (originalPkt);
1728 }
1729 }
1730 }
1731}
1732
1733
1734
1735void
1736LrWpanMac::SendAck (uint8_t seqno)
1737{
1738 NS_LOG_FUNCTION (this << static_cast<uint32_t> (seqno));
1739
1741
1742 // Generate a corresponding ACK Frame.
1744 LrWpanMacTrailer macTrailer;
1745 Ptr<Packet> ackPacket = Create<Packet> (0);
1746 ackPacket->AddHeader (macHdr);
1747 // Calculate FCS if the global attribute ChecksumEnable is set.
1748 if (Node::ChecksumEnabled ())
1749 {
1750 macTrailer.EnableFcs (true);
1751 macTrailer.SetFcs (ackPacket);
1752 }
1753 ackPacket->AddTrailer (macTrailer);
1754
1755 // Enqueue the ACK packet for further processing
1756 // when the transmitter is activated.
1757 m_txPkt = ackPacket;
1758
1759 // Switch transceiver to TX mode. Proceed sending the Ack on confirm.
1761 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
1762
1763}
1764
1765void
1767{
1768 TxQueueElement *txQElement = m_txQueue.front ();
1769 Ptr<const Packet> p = txQElement->txQPkt;
1770 m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
1771
1772 Ptr<Packet> pkt = p->Copy ();
1773 LrWpanMacHeader hdr;
1774 pkt->RemoveHeader (hdr);
1775 if (!hdr.GetShortDstAddr ().IsBroadcast () && !hdr.GetShortDstAddr ().IsMulticast ())
1776 {
1778 }
1779
1780 txQElement->txQPkt = 0;
1781 delete txQElement;
1782 m_txQueue.pop_front ();
1783 m_txPkt = 0;
1784 m_retransmission = 0;
1785 m_numCsmacaRetry = 0;
1787}
1788
1789void
1791{
1792 NS_LOG_FUNCTION (this);
1793
1794 // TODO: If we are a PAN coordinator and this was an indirect transmission,
1795 // we will not initiate a retransmission. Instead we wait for the data
1796 // being extracted after a new data request command.
1797 if (!PrepareRetransmission ())
1798 {
1800 }
1801 else
1802 {
1804 }
1805}
1806
1807void
1809{
1810 uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false);
1811 Time lifsTime = Seconds ((double) m_macLIFSPeriod / symbolRate);
1812 Time sifsTime = Seconds ((double) m_macSIFSPeriod / symbolRate);
1813
1814 if (ifsTime == lifsTime)
1815 {
1816 NS_LOG_DEBUG ("LIFS of " << m_macLIFSPeriod << " symbols (" << ifsTime.As (Time::S) << ") completed ");
1817 }
1818 else if (ifsTime == sifsTime)
1819 {
1820 NS_LOG_DEBUG ("SIFS of " << m_macSIFSPeriod << " symbols (" << ifsTime.As (Time::S) << ") completed ");
1821 }
1822 else
1823 {
1824 NS_LOG_DEBUG ("Unknown IFS size (" << ifsTime.As (Time::S) << ") completed ");
1825 }
1826
1827 m_macIfsEndTrace (ifsTime);
1828 CheckQueue ();
1829}
1830
1831
1832bool
1834{
1835 NS_LOG_FUNCTION (this);
1836
1838 {
1839 // Maximum number of retransmissions has been reached.
1840 // remove the copy of the packet that was just sent
1841 TxQueueElement *txQElement = m_txQueue.front ();
1842 m_macTxDropTrace (txQElement->txQPkt);
1844 {
1845 McpsDataConfirmParams confirmParams;
1846 confirmParams.m_msduHandle = txQElement->txQMsduHandle;
1847 confirmParams.m_status = IEEE_802_15_4_NO_ACK;
1848 m_mcpsDataConfirmCallback (confirmParams);
1849 }
1851 return false;
1852 }
1853 else
1854 {
1856 m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
1857 // Start next CCA process for this packet.
1858 return true;
1859 }
1860}
1861
1862void
1864{
1865 std::unique_ptr <IndTxQueueElement> indTxQElement = std::make_unique <IndTxQueueElement>();
1866 LrWpanMacHeader peekedMacHdr;
1867 p->PeekHeader (peekedMacHdr);
1868
1869 PurgeInd ();
1870
1871 NS_ASSERT (peekedMacHdr.GetDstAddrMode () == SHORT_ADDR || peekedMacHdr.GetDstAddrMode () == EXT_ADDR);
1872
1873 if (peekedMacHdr.GetDstAddrMode () == SHORT_ADDR)
1874 {
1875 indTxQElement->dstShortAddress = peekedMacHdr.GetShortDstAddr ();
1876 }
1877 else
1878 {
1879 indTxQElement->dstExtAddress = peekedMacHdr.GetExtDstAddr ();
1880 }
1881
1882 indTxQElement->seqNum = peekedMacHdr.GetSeqNum ();
1883
1884 // See IEEE 802.15.4-2006, Table 86
1885 uint32_t unit = 0; // The persistence time in symbols
1886 if (m_macBeaconOrder == 15)
1887 {
1888 //Non-beacon enabled mode
1890 }
1891 else
1892 {
1893 //Beacon-enabled mode
1895 }
1896
1897 double symbolRate = m_phy->GetDataOrSymbolRate (false);
1898 Time expireTime = Seconds (unit / symbolRate);
1899 expireTime += Simulator::Now ();
1900
1901 indTxQElement->expireTime = expireTime;
1902 indTxQElement->txQPkt = p;
1903
1904 m_indTxQueue.push_back (std::move(indTxQElement));
1905}
1906
1907bool
1909{
1910 PurgeInd ();
1911
1912 for (uint32_t i = 0; i < m_indTxQueue.size (); i++)
1913 {
1914 if (m_indTxQueue[i]->dstExtAddress == dst)
1915 {
1916 *entry = *m_indTxQueue[i];
1917 return true;
1918 }
1919 }
1920 return false;
1921}
1922
1923void
1925{
1926 for (uint32_t i = 0; i < m_indTxQueue.size (); )
1927 {
1928 if (Simulator::Now () > m_indTxQueue[i]->expireTime)
1929 {
1930 // Transaction expired, remove and send proper confirmation/indication to a higher layer
1931 LrWpanMacHeader peekedMacHdr;
1932 m_indTxQueue[i]->txQPkt->Copy ()->PeekHeader (peekedMacHdr);
1933
1934 if (peekedMacHdr.IsCommand ())
1935 {
1936 // IEEE 802.15.4-2006 (Section 7.1.3.3.3)
1938 {
1939 MlmeCommStatusIndicationParams commStatusParams;
1940 commStatusParams.m_panId = m_macPanId;
1941 commStatusParams.m_srcAddrMode = LrWpanMacHeader::EXTADDR;
1942 commStatusParams.m_srcExtAddr = peekedMacHdr.GetExtSrcAddr ();
1943 commStatusParams.m_dstAddrMode = LrWpanMacHeader::EXTADDR;
1944 commStatusParams.m_dstExtAddr = peekedMacHdr.GetExtDstAddr ();
1946 m_mlmeCommStatusIndicationCallback (commStatusParams);
1947 }
1948 }
1949 else if (peekedMacHdr.IsData())
1950 {
1951 // IEEE 802.15.4-2006 (Section 7.1.1.1.3)
1953 {
1954 McpsDataConfirmParams confParams;
1956 m_mcpsDataConfirmCallback (confParams);
1957 }
1958 }
1959 m_macTxDropTrace (m_indTxQueue[i]->txQPkt);
1960 m_indTxQueue.erase (m_indTxQueue.begin () + i);
1961 }
1962 else
1963 {
1964 i++;
1965 }
1966 }
1967}
1968
1969void
1970LrWpanMac::PrintPendTxQ (std::ostream &os) const
1971{
1972 LrWpanMacHeader peekedMacHdr;
1973
1974 os << "Pending Transaction List ["
1975 << GetShortAddress ()
1976 << " | " << GetExtendedAddress () << "] | CurrentTime: "
1977 << Simulator::Now ().As (Time::S) << "\n"
1978 << " Destination | Sequence Number | Frame type | Expire time\n";
1979
1980 for (uint32_t i = 0; i < m_indTxQueue.size (); i++)
1981 {
1982 m_indTxQueue[i]->txQPkt->PeekHeader (peekedMacHdr);
1983 os << m_indTxQueue[i]->dstExtAddress << " " << static_cast <uint32_t> (m_indTxQueue[i]->seqNum) << " ";
1984
1985 if (peekedMacHdr.IsCommand ())
1986 {
1987 os << "Cmd Frame ";
1988 }
1989 else if (peekedMacHdr.IsData ())
1990 {
1991 os << "Data Frame ";
1992 }
1993 else
1994 {
1995 os << "Unk Frame ";
1996 }
1997
1998 os << m_indTxQueue[i]->expireTime.As (Time::S) << "\n";
1999 }
2000}
2001
2002void
2004{
2005 LrWpanMacHeader peekedMacHdr;
2006 p->PeekHeader (peekedMacHdr);
2007
2008 for (auto it = m_indTxQueue.begin (); it != m_indTxQueue.end (); it++)
2009 {
2010 if (peekedMacHdr.GetDstAddrMode () == EXT_ADDR)
2011 {
2012 if (((*it)->dstExtAddress == peekedMacHdr.GetExtDstAddr ())
2013 && ((*it)->seqNum == peekedMacHdr.GetSeqNum ()))
2014 {
2016 m_indTxQueue.erase (it);
2017 break;
2018 }
2019 }
2020 else if (peekedMacHdr.GetDstAddrMode () == SHORT_ADDR)
2021 {
2022 if (((*it)->dstShortAddress == peekedMacHdr.GetShortDstAddr ())
2023 && ((*it)->seqNum == peekedMacHdr.GetSeqNum ()))
2024 {
2026 m_indTxQueue.erase (it);
2027 break;
2028 }
2029 }
2030 }
2031
2032 p = 0;
2033}
2034
2035void
2037{
2039 NS_LOG_FUNCTION (this << status << m_txQueue.size ());
2040
2041 LrWpanMacHeader macHdr;
2042 Time ifsWaitTime;
2043 uint64_t symbolRate;
2044
2045 symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
2046
2047 m_txPkt->PeekHeader (macHdr);
2048
2049 if (status == IEEE_802_15_4_PHY_SUCCESS)
2050 {
2051 if (!macHdr.IsAcknowledgment ())
2052 {
2053 if (macHdr.IsBeacon ())
2054 {
2055 ifsWaitTime = Seconds (static_cast<double> (GetIfsSize () / symbolRate));
2056
2057 // Start CAP only if we are in beacon mode (i.e. if slotted csma-ca is running)
2058 if (m_csmaCa->IsSlottedCsmaCa ())
2059 {
2060 // The Tx Beacon in symbols
2061 // Beacon = 5 bytes Sync Header (SHR) + 1 byte PHY header (PHR) + PSDU (default 17 bytes)
2062 uint64_t beaconSymbols = m_phy->GetPhySHRDuration () + 1 * m_phy->GetPhySymbolsPerOctet () +
2063 (m_txPkt->GetSize () * m_phy->GetPhySymbolsPerOctet ());
2064
2065 // The beacon Tx time and start of the Outgoing superframe Active Period
2066 m_macBeaconTxTime = Simulator::Now () - Seconds (double(beaconSymbols) / symbolRate);
2067
2068
2069 m_txPkt = 0;
2071 NS_LOG_DEBUG ("Beacon Sent (m_macBeaconTxTime: " << m_macBeaconTxTime.As (Time::S) << ")");
2072
2073 MlmeStartConfirmParams mlmeConfirmParams;
2074 mlmeConfirmParams.m_status = MLMESTART_SUCCESS;
2076 {
2077 m_mlmeStartConfirmCallback (mlmeConfirmParams);
2078 }
2079 }
2080
2081 m_txPkt = 0;
2082 }
2083 else if (macHdr.IsAckReq ()) // We have sent a regular data packet, check if we have to wait for an ACK.
2084 {
2085 // wait for the ack or the next retransmission timeout
2086 // start retransmission timer
2087 Time waitTime = Seconds ((double) GetMacAckWaitDuration () / symbolRate);
2092 return;
2093 }
2094 else if (macHdr.IsCommand ())
2095 {
2096 // We handle commands that do not require ACK (e.g. BeaconReq command)
2097 // other command that require ACK are handle by the previous if statement.
2099 }
2100 else
2101 {
2103 // remove the copy of the packet that was just sent
2105 {
2106 McpsDataConfirmParams confirmParams;
2107 NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
2108 TxQueueElement *txQElement = m_txQueue.front ();
2109 confirmParams.m_msduHandle = txQElement->txQMsduHandle;
2110 confirmParams.m_status = IEEE_802_15_4_SUCCESS;
2111 m_mcpsDataConfirmCallback (confirmParams);
2112 }
2113 ifsWaitTime = Seconds ((double) GetIfsSize () / symbolRate);
2115 }
2116 }
2117 else
2118 {
2119 // We have send an ACK. Clear the packet buffer.
2120 m_txPkt = 0;
2121 }
2122 }
2123 else if (status == IEEE_802_15_4_PHY_UNSPECIFIED)
2124 {
2125
2126 if (!macHdr.IsAcknowledgment ())
2127 {
2128 NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
2129 TxQueueElement *txQElement = m_txQueue.front ();
2130 m_macTxDropTrace (txQElement->txQPkt);
2132 {
2133 McpsDataConfirmParams confirmParams;
2134 confirmParams.m_msduHandle = txQElement->txQMsduHandle;
2135 confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
2136 m_mcpsDataConfirmCallback (confirmParams);
2137 }
2139 }
2140 else
2141 {
2142 NS_LOG_ERROR ("Unable to send ACK");
2143 }
2144 }
2145 else
2146 {
2147 // Something went really wrong. The PHY is not in the correct state for
2148 // data transmission.
2149 NS_FATAL_ERROR ("Transmission attempt failed with PHY status " << status);
2150 }
2151
2152
2153 if (!ifsWaitTime.IsZero ())
2154 {
2155 m_ifsEvent = Simulator::Schedule (ifsWaitTime, &LrWpanMac::IfsWaitTimeout, this, ifsWaitTime);
2156 }
2157
2160
2161
2162}
2163
2164void
2166{
2167 NS_LOG_FUNCTION (this << status);
2168 // Direct this call through the csmaCa object
2169 m_csmaCa->PlmeCcaConfirm (status);
2170}
2171
2172void
2174{
2175 NS_LOG_FUNCTION (this << status << energyLevel);
2176
2177 if (energyLevel > m_maxEnergyLevel)
2178 {
2179 m_maxEnergyLevel = energyLevel;
2180 }
2181
2182 if (Simulator::GetDelayLeft (m_scanEnergyEvent) > Seconds (8.0 / m_phy->GetDataOrSymbolRate (false)))
2183 {
2184 m_phy->PlmeEdRequest ();
2185 }
2186}
2187
2188void
2191 LrWpanPhyPibAttributes* attribute)
2192{
2193 NS_LOG_FUNCTION (this << status << id << attribute);
2194}
2195
2196void
2198{
2199 NS_LOG_FUNCTION (this << status);
2200
2202 {
2204
2205 // Start sending if we are in state SENDING and the PHY transmitter was enabled.
2209 m_phy->PdDataRequest (m_txPkt->GetSize (), m_txPkt);
2210 }
2211 else if (m_lrWpanMacState == MAC_CSMA && (status == IEEE_802_15_4_PHY_RX_ON || status == IEEE_802_15_4_PHY_SUCCESS))
2212 {
2213 // Start the CSMA algorithm as soon as the receiver is enabled.
2214 m_csmaCa->Start ();
2215 }
2216 else if (m_lrWpanMacState == MAC_IDLE)
2217 {
2219
2221 {
2222 // Kick start Energy Detection Scan
2223 m_phy->PlmeEdRequest ();
2224 }
2225 else if (status == IEEE_802_15_4_PHY_RX_ON || status == IEEE_802_15_4_PHY_SUCCESS)
2226 {
2227 // Check if there is not messages to transmit when going idle
2228 CheckQueue ();
2229 }
2230
2231 }
2233 {
2235 }
2236 else
2237 {
2238 // TODO: What to do when we receive an error?
2239 // If we want to transmit a packet, but switching the transceiver on results
2240 // in an error, we have to recover somehow (and start sending again).
2241 NS_FATAL_ERROR ("Error changing transceiver state");
2242 }
2243}
2244
2245void
2248{
2249 NS_LOG_FUNCTION (this << status << id);
2251 {
2253 {
2254 // get the first channel to scan from scan channel list
2255 bool channelFound = false;
2256 for (int i = m_channelScanIndex; i <= 26; i++)
2257 {
2259 {
2260 channelFound = true;
2261 break;
2262 }
2264 }
2265
2266 if (channelFound)
2267 {
2268 LrWpanPhyPibAttributes pibAttr;
2270 m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentChannel,&pibAttr);
2271 }
2272 }
2273 else
2274 {
2276 {
2277 MlmeScanConfirmParams confirmParams;
2278 confirmParams.m_scanType = m_scanParams.m_scanType;
2279 confirmParams.m_chPage = m_scanParams.m_chPage;
2280 confirmParams.m_status = MLMESCAN_INVALID_PARAMETER;
2281 m_mlmeScanConfirmCallback (confirmParams);
2282 }
2283 NS_LOG_ERROR (this << "Channel Scan: Invalid channel page");
2284 }
2285 }
2287 {
2289 {
2290 uint64_t symbolRate = static_cast<uint64_t> (m_phy->GetDataOrSymbolRate (false));
2291 uint64_t scanDuration = aBaseSuperframeDuration * ((static_cast<uint32_t> (1 << m_scanParams.m_scanDuration)) + 1);
2292 Time nextScanTime = Seconds (static_cast<double> (scanDuration / symbolRate));
2293
2294 switch (m_scanParams.m_scanType)
2295 {
2296 case MLMESCAN_ED:
2297 m_maxEnergyLevel = 0;
2299 // set phy to RX_ON and kick start the first PLME-ED.request
2300 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
2301 break;
2302 case MLMESCAN_ACTIVE:
2305 break;
2306 case MLMESCAN_PASSIVE:
2308 // turn back the phy to RX_ON after setting Page/channel
2309 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
2310 break;
2311 case MLMESCAN_ORPHAN:
2312 // TODO: add orphan scan support
2313 break;
2314 }
2315 }
2316 else
2317 {
2319 {
2320 MlmeScanConfirmParams confirmParams;
2321 confirmParams.m_scanType = m_scanParams.m_scanType;
2322 confirmParams.m_chPage = m_scanParams.m_chPage;
2323 confirmParams.m_status = MLMESCAN_INVALID_PARAMETER;
2324 m_mlmeScanConfirmCallback (confirmParams);
2325 }
2326 NS_LOG_ERROR ("Channel " << m_channelScanIndex << " could not be set in the current page");
2327 }
2328 }
2330 {
2332 {
2333 LrWpanPhyPibAttributes pibAttr;
2335 m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentChannel,&pibAttr);
2336 }
2337 else
2338 {
2340 {
2341 MlmeStartConfirmParams confirmParams;
2342 confirmParams.m_status = MLMESTART_INVALID_PARAMETER;
2343 m_mlmeStartConfirmCallback (confirmParams);
2344 }
2345 NS_LOG_ERROR ("Invalid page parameter in MLME-start");
2346 }
2347 }
2349 {
2351 {
2352 EndStartRequest ();
2353 }
2354 else
2355 {
2357 {
2358 MlmeStartConfirmParams confirmParams;
2359 confirmParams.m_status = MLMESTART_INVALID_PARAMETER;
2360 m_mlmeStartConfirmCallback (confirmParams);
2361 }
2362 NS_LOG_ERROR ("Invalid channel parameter in MLME-start");
2363 }
2364 }
2365}
2366
2367void
2369{
2370 NS_LOG_FUNCTION (this << "mac state = " << macState);
2371
2372 McpsDataConfirmParams confirmParams;
2373
2374 if (macState == MAC_IDLE)
2375 {
2377
2379 {
2380 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
2381 }
2382 else
2383 {
2384 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
2385 }
2386
2387
2388 }
2389 else if (macState == MAC_ACK_PENDING)
2390 {
2392 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
2393 }
2394 else if (macState == MAC_CSMA)
2395 {
2397
2399 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
2400 }
2401 else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_IDLE)
2402 {
2403 // Channel is idle, set transmitter to TX_ON
2405 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
2406 }
2407 else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_ACCESS_FAILURE)
2408 {
2410
2411 // cannot find a clear channel, drop the current packet.
2412 NS_LOG_DEBUG ( this << " cannot find clear channel");
2413 confirmParams.m_msduHandle = m_txQueue.front ()->txQMsduHandle;
2417 {
2418 m_mcpsDataConfirmCallback (confirmParams);
2419 }
2420 // remove the copy of the packet that was just sent
2424 {
2425 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
2426 }
2427 else
2428 {
2429 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
2430 }
2431 }
2432 else if (m_lrWpanMacState == MAC_CSMA && macState == MAC_CSMA_DEFERRED)
2433 {
2435 m_txPkt = 0;
2437 {
2438 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
2439 }
2440 else
2441 {
2442 m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
2443 }
2444 NS_LOG_DEBUG ("****** PACKET DEFERRED to the next superframe *****");
2445 }
2446}
2447
2450{
2451 return m_associationStatus;
2452}
2453
2454void
2456{
2457 m_associationStatus = status;
2458}
2459
2460uint16_t
2462{
2463 return m_macPanId;
2464}
2465
2466void
2467LrWpanMac::SetPanId (uint16_t panId)
2468{
2469 m_macPanId = panId;
2470}
2471
2472void
2474{
2475 NS_LOG_LOGIC (this << " change lrwpan mac state from "
2476 << m_lrWpanMacState << " to "
2477 << newState);
2479 m_lrWpanMacState = newState;
2480}
2481
2482uint64_t
2484{
2485 return m_csmaCa->GetUnitBackoffPeriod () + m_phy->aTurnaroundTime + m_phy->GetPhySHRDuration ()
2486 + ceil (6 * m_phy->GetPhySymbolsPerOctet ());
2487}
2488
2489uint8_t
2491{
2492 return m_macMaxFrameRetries;
2493}
2494
2495void
2497{
2498 NS_LOG_DEBUG ("Transmit Queue Size: " << m_txQueue.size ());
2499}
2500
2501void
2503{
2504 m_macMaxFrameRetries = retries;
2505}
2506
2507bool
2509{
2511 LrWpanMacHeader macHdr;
2512 m_txPkt->PeekHeader (macHdr);
2513
2516 {
2517 return true;
2518 }
2519 else
2520 {
2521 std::cout << "ERROR: Packet not for the coordinator!\n";
2522 return false;
2523
2524 }
2525
2526}
2527
2530{
2532
2534 {
2535 return m_macSIFSPeriod;
2536 }
2537 else
2538 {
2539 return m_macLIFSPeriod;
2540 }
2541}
2542
2543void
2545{
2547}
2548
2549void
2551{
2553}
2554
2555
2556uint64_t
2558{
2560 // Sync Header (SHR) + 8 bits PHY header (PHR) + PSDU
2561 return (m_phy->GetPhySHRDuration () + 1 * m_phy->GetPhySymbolsPerOctet () +
2562 (m_txPkt->GetSize () * m_phy->GetPhySymbolsPerOctet ()));
2563}
2564
2565bool
2567{
2569 LrWpanMacHeader macHdr;
2570 m_txPkt->PeekHeader (macHdr);
2571
2572 return macHdr.IsAckReq ();
2573}
2574
2575} // namespace ns3
2576
Implements the header for the MAC payload beacon frame according to the IEEE 802.15....
GtsFields GetGtsFields(void) const
Get the Guaranteed Time Slots (GTS) fields from the beacon payload header.
SuperframeField GetSuperframeSpecField(void) const
Get the superframe specification field from the beacon payload header.
void SetSuperframeSpecField(SuperframeField sfrmField)
Set the superframe specification field to the beacon payload header.
void SetGtsFields(GtsFields gtsFields)
Set the superframe Guaranteed Time Slot (GTS) fields to the beacon payload header.
PendingAddrFields GetPndAddrFields(void) const
Get the pending address fields from the beacon payload header.
void SetPndAddrFields(PendingAddrFields pndAddrFields)
Set the superframe Pending Address fields to the beacon payload header.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
Implements the header for the MAC payload command frame according to the IEEE 802....
@ BEACON_REQ
Beacon Request (RFD true: none )
@ DATA_REQ
Data Request (RFD true: Tx)
void SetCommandFrameType(MacCommand macCmd)
Set the command frame type.
MacCommand GetCommandFrameType(void) const
Get the command frame type ID.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
Represent the GTS information fields.
bool GetGtsPermit(void) const
Get the GTS Specification Permit.
Represent the Mac Header with the Frame Control and Sequence Number fields.
void SetNoAckReq(void)
Set the Frame Control field "Ack. Request" bit to false.
@ LRWPAN_MAC_BEACON
LRWPAN_MAC_BEACON.
@ LRWPAN_MAC_COMMAND
LRWPAN_MAC_COMMAND.
@ LRWPAN_MAC_DATA
LRWPAN_MAC_DATA.
@ LRWPAN_MAC_ACKNOWLEDGMENT
LRWPAN_MAC_ACKNOWLEDGMENT.
@ LRWPAN_MAC_RESERVED
LRWPAN_MAC_RESERVED.
Mac64Address GetExtSrcAddr(void) const
Get the Source Extended address.
void SetAckReq(void)
Set the Frame Control field "Ack. Request" bit to true.
uint8_t GetSrcAddrMode(void) const
Get the Source Addressing Mode of Frame control field.
bool IsBeacon(void) const
Returns true if the header is a beacon.
void SetSrcAddrMode(uint8_t addrMode)
Set the Source address mode.
void SetSrcAddrFields(uint16_t panId, Mac16Address addr)
Set Source address fields.
Mac64Address GetExtDstAddr(void) const
Get the Destination Extended address.
uint8_t GetSeqNum(void) const
Get the frame Sequence number.
uint16_t GetDstPanId(void) const
Get the Destination PAN ID.
enum LrWpanMacType GetType(void) const
Get the header type.
void SetDstAddrFields(uint16_t panId, Mac16Address addr)
Set Destination address fields.
void SetDstAddrMode(uint8_t addrMode)
Set the Destination address mode.
Mac16Address GetShortSrcAddr(void) const
Get the Source Short address.
bool IsData(void) const
Returns true if the header is a data.
uint8_t GetFrameVer(void) const
Get the Frame Version of Frame control field.
Mac16Address GetShortDstAddr(void) const
Get the Destination Short address.
bool IsCommand(void) const
Returns true if the header is a command.
void SetNoPanIdComp(void)
Set the Frame Control field "PAN ID Compression" bit to false.
bool IsAckReq(void) const
Check if Ack.
void SetSecDisable(void)
Set the Frame Control field "Security Enabled" bit to false.
bool IsAcknowledgment(void) const
Returns true if the header is an ack.
uint16_t GetSrcPanId(void) const
Get the Source PAN ID.
uint8_t GetDstAddrMode(void) const
Get the Dest.
Class that implements the LR-WPAN MAC state machine.
Definition: lr-wpan-mac.h:664
uint32_t m_incomingBeaconInterval
Indication of the interval a node should receive a superframe expressed in symbols.
Definition: lr-wpan-mac.h:1216
uint32_t GetIfsSize()
Get the size of the Interframe Space according to MPDU size (m_txPkt).
Ptr< LrWpanCsmaCa > m_csmaCa
The CSMA/CA implementation used by this MAC.
Definition: lr-wpan-mac.h:1673
virtual void DoDispose(void)
Destructor implementation.
Definition: lr-wpan-mac.cc:216
McpsDataConfirmCallback m_mcpsDataConfirmCallback
This callback is used to report data transmission request status to the upper layers.
Definition: lr-wpan-mac.h:1738
Time m_macBeaconRxTime
The time that the device received its last bit of the beacon frame.
Definition: lr-wpan-mac.h:1037
Ptr< LrWpanPhy > GetPhy(void)
Get the underlying PHY of the MAC.
Mac16Address GetShortAddress(void) const
Get the short address of this MAC.
Definition: lr-wpan-mac.cc:280
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
bool m_macRxOnWhenIdle
Indication of whether the MAC sublayer is to enable its receiver during idle periods.
Definition: lr-wpan-mac.h:1162
TracedCallback< Ptr< const Packet > > m_macTxOkTrace
The trace source fired when packets where successfully transmitted, that is an acknowledgment was rec...
Definition: lr-wpan-mac.h:1578
void SetMlmeBeaconNotifyIndicationCallback(MlmeBeaconNotifyIndicationCallback c)
Set the callback for the indication of an incoming beacon packet.
uint64_t m_rxBeaconSymbols
The total size of the received beacon in symbols.
Definition: lr-wpan-mac.h:1092
void SetRxOnWhenIdle(bool rxOnWhenIdle)
Set if the receiver should be enabled when the MAC is idle.
Definition: lr-wpan-mac.cc:246
bool DequeueInd(Mac64Address dst, IndTxQueueElement *entry)
Extracts a packet from pending transactions list (Indirect transmissions).
bool m_panCoor
Indication of whether the current device is the PAN coordinator.
Definition: lr-wpan-mac.h:1198
void BeaconSearchTimeout(void)
Called if the device is unable to locate a beacon in the time set by MLME-SYNC.request.
void SetMlmeAssociateIndicationCallback(MlmeAssociateIndicationCallback c)
Set the callback for the indication of an incoming associate request command.
void PlmeSetTRXStateConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.8 PLME-SET-TRX-STATE.confirm Set PHY state.
uint8_t m_numCsmacaRetry
The number of CSMA/CA retries used for sending the current packet.
Definition: lr-wpan-mac.h:1830
void MlmeSyncRequest(MlmeSyncRequestParams params)
IEEE 802.15.4-2011, section 6.2.13.1 MLME-SYNC.request Request to synchronize with the coordinator by...
Definition: lr-wpan-mac.cc:598
void SendOneBeacon(void)
Called to send a single beacon frame.
Definition: lr-wpan-mac.cc:652
MlmeStartConfirmCallback m_mlmeStartConfirmCallback
This callback is used to report the start of a new PAN or the begin of a new superframe configuration...
Definition: lr-wpan-mac.h:1713
uint64_t GetMacAckWaitDuration(void) const
Get the macAckWaitDuration attribute value.
uint8_t m_deviceCapability
Indication of current device capability (FFD or RFD)
Definition: lr-wpan-mac.h:1227
uint8_t GetMacMaxFrameRetries(void) const
Get the macMaxFrameRetries attribute value.
virtual ~LrWpanMac(void)
Definition: lr-wpan-mac.cc:197
EventId m_trackingEvent
Scheduler event to track the incoming beacons.
Definition: lr-wpan-mac.h:1876
void SetMlmeScanConfirmCallback(MlmeScanConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
void CheckQueue(void)
Check the transmission queue.
void SetMlmePollConfirmCallback(MlmePollConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
void RemoveFirstTxQElement()
Remove the tip of the transmission queue, including clean up related to the last packet transmission.
void PlmeEdConfirm(LrWpanPhyEnumeration status, uint8_t energyLevel)
IEEE 802.15.4-2006 section 6.2.2.4 PLME-ED.confirm status and energy level.
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Definition: lr-wpan-mac.h:1604
bool GetRxOnWhenIdle(void)
Check if the receiver will be enabled when the MAC is idle.
Definition: lr-wpan-mac.cc:240
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
Definition: lr-wpan-mac.h:1653
void SetExtendedAddress(Mac64Address address)
Set the extended address of this MAC.
Definition: lr-wpan-mac.cc:272
void MlmeStartRequest(MlmeStartRequestParams params)
IEEE 802.15.4-2006, section 7.1.14.1 MLME-START.request Request to allow a PAN coordinator to initiat...
Definition: lr-wpan-mac.cc:496
uint16_t GetPanId(void) const
Get the PAN id used by this MAC.
uint32_t m_macLIFSPeriod
The minimum time forming a Long InterFrame Spacing (LIFS) period.
Definition: lr-wpan-mac.h:1168
void StartInactivePeriod(SuperframeType superframeType)
Start the Inactive Period in a beacon-enabled mode.
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
The trace source fired when packets are dropped due to missing ACKs or because of transmission failur...
Definition: lr-wpan-mac.h:1586
void SetMcpsDataIndicationCallback(McpsDataIndicationCallback c)
Set the callback for the indication of an incoming data packet.
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lr-wpan-mac.cc:201
void SetMlmeAssociateConfirmCallback(MlmeAssociateConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
MlmeScanConfirmCallback m_mlmeScanConfirmCallback
This callback is used to report the result of a scan on a group of channels for the selected channel ...
Definition: lr-wpan-mac.h:1692
void SetMlmeStartConfirmCallback(MlmeStartConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
EventId m_cfpEvent
Scheduler event for the end of the outgoing superframe CFP.
Definition: lr-wpan-mac.h:1861
static constexpr uint32_t aBaseSuperframeDuration
Length of a superframe in symbols.
Definition: lr-wpan-mac.h:697
void PrintTransmitQueueSize(void)
Print the number of elements in the packet transmit queue.
uint8_t m_macMaxFrameRetries
The maximum number of retries allowed after a transmission failure.
Definition: lr-wpan-mac.h:1155
Mac64Address m_macCoordExtendedAddress
The extended address of the coordinator through which the device is associated.
Definition: lr-wpan-mac.h:1053
MlmeSyncLossIndicationCallback m_mlmeSyncLossIndicationCallback
This callback is used to indicate the loss of synchronization with a coordinator.
Definition: lr-wpan-mac.h:1685
PendingPrimitiveStatus m_pendPrimitive
Indicates the pending primitive when PLME.SET operation (page or channel switch) is called from withi...
Definition: lr-wpan-mac.h:1819
static TypeId GetTypeId(void)
Get the type ID.
Definition: lr-wpan-mac.cc:52
MlmePollConfirmCallback m_mlmePollConfirmCallback
This callback is used to report the status after a device send data command request to the coordinato...
Definition: lr-wpan-mac.h:1706
void EndStartRequest(void)
Called to end a MLME-START.request after changing the page and channel number.
Definition: lr-wpan-mac.cc:755
uint16_t m_channelScanIndex
The channel list index used to obtain the current scanned channel.
Definition: lr-wpan-mac.h:1813
std::vector< PanDescriptor > m_panDescriptorList
The list of PAN descriptors accumulated during channel scans, used to select a PAN to associate.
Definition: lr-wpan-mac.h:1791
SequenceNumber8 m_macBsn
Sequence number added to transmitted beacon frame, 00-ff.
Definition: lr-wpan-mac.h:1149
LrWpanAssociationStatus m_associationStatus
The current association status of the MAC layer.
Definition: lr-wpan-mac.h:1758
void SetLrWpanMacState(LrWpanMacState macState)
CSMA-CA algorithm calls back the MAC after executing channel assessment.
Mac16Address m_shortAddress
The short address used by this MAC.
Definition: lr-wpan-mac.h:1770
uint8_t m_macSuperframeOrder
Used by a PAN coordinator or coordinator.
Definition: lr-wpan-mac.h:1075
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaCa)
Set the CSMA/CA implementation to be used by the MAC.
std::vector< uint8_t > m_energyDetectList
The list of energy measurements, one for each channel searched during an ED scan.
Definition: lr-wpan-mac.h:1796
void PdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
IEEE 802.15.4-2006 section 6.2.1.3 PD-DATA.indication Indicates the transfer of an MPDU from PHY to M...
Time m_macBeaconTxTime
The time that the device transmitted its last beacon frame.
Definition: lr-wpan-mac.h:1029
SuperframeField GetSuperframeField(void)
Constructs a Superframe specification field from the local information, the superframe Specification ...
MlmeBeaconNotifyIndicationCallback m_mlmeBeaconNotifyIndicationCallback
This callback is used to notify incoming beacon packets to the upper layers.
Definition: lr-wpan-mac.h:1679
TracedCallback< LrWpanMacState, LrWpanMacState > m_macStateLogger
A trace source that fires when the LrWpanMac changes states.
Definition: lr-wpan-mac.h:1663
EventId m_setMacState
Scheduler event for a deferred MAC state change.
Definition: lr-wpan-mac.h:1841
void EnqueueInd(Ptr< Packet > p)
Adds a packet to the pending transactions list (Indirect transmissions).
void StartCFP(SuperframeType superframeType)
Called to begin the Contention Free Period (CFP) in a beacon-enabled mode.
Definition: lr-wpan-mac.cc:990
EventId m_scanEnergyEvent
Scheduler event for the end of a ED channel scan.
Definition: lr-wpan-mac.h:1886
void SetMcpsDataConfirmCallback(McpsDataConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
void SetAssociationStatus(LrWpanAssociationStatus status)
Set the current association status.
static constexpr uint32_t aMaxSIFSFrameSize
The maximum size of an MPDU, in octets, that can be followed by a Short InterFrame Spacing (SIFS) per...
Definition: lr-wpan-mac.h:712
void SetPanId(uint16_t panId)
Set the PAN id used by this MAC.
EventId m_scanEvent
Scheduler event for the end of a channel scan.
Definition: lr-wpan-mac.h:1881
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
Definition: lr-wpan-mac.h:1633
uint8_t m_incomingBeaconOrder
The beaconOrder value of the INCOMING frame.
Definition: lr-wpan-mac.h:1104
SequenceNumber8 m_macDsn
Sequence number added to transmitted data or MAC command frame, 00-ff.
Definition: lr-wpan-mac.h:1143
void SetMlmeSyncLossIndicationCallback(MlmeSyncLossIndicationCallback c)
Set the callback for the loss of synchronization with a coordinator.
uint32_t m_ifs
The value of the necessary InterFrame Space after the transmission of a packet.
Definition: lr-wpan-mac.h:1193
uint16_t m_macTransactionPersistenceTime
The maximum time (in UNIT periods) that a transaction is stored by a coordinator and indicated in its...
Definition: lr-wpan-mac.h:1086
std::deque< TxQueueElement * > m_txQueue
The transmit queue used by the MAC.
Definition: lr-wpan-mac.h:1781
void ChangeMacState(LrWpanMacState newState)
Change the current MAC state to the given new state.
void PlmeGetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttributeIdentifier id, LrWpanPhyPibAttributes *attribute)
IEEE 802.15.4-2006 section 6.2.2.6 PLME-GET.confirm Get attributes per definition from Table 23 in se...
MlmeStartRequestParams m_startParams
The parameters used during a MLME-START.request.
Definition: lr-wpan-mac.h:1808
void MlmeScanRequest(MlmeScanRequestParams params)
IEEE 802.15.4-2011, section 6.2.10.1 MLME-SCAN.request Request primitive used to initiate a channel s...
Definition: lr-wpan-mac.cc:536
uint8_t m_macBeaconOrder
Used by a PAN coordinator or coordinator.
Definition: lr-wpan-mac.h:1067
TracedCallback< Time > m_macIfsEndTrace
The trace source is fired at the end of any Interframe Space (IFS).
Definition: lr-wpan-mac.h:1526
TracedValue< SuperframeStatus > m_outSuperframeStatus
The current period of the outgoing superframe.
Definition: lr-wpan-mac.h:1753
GtsFields GetGtsFields(void)
Constructs the Guaranteed Time Slots (GTS) Fields from local information.
void PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttributeIdentifier id)
IEEE 802.15.4-2006 section 6.2.2.10 PLME-SET.confirm Set attributes per definition from Table 23 in s...
void SetMlmeCommStatusIndicationCallback(MlmeCommStatusIndicationCallback c)
Set the callback for the indication to a response primitive.
void PurgeInd(void)
Purge expired transactions from the pending transactions list.
EventId m_ackWaitTimeout
Scheduler event for the ACK timeout of the currently transmitted data packet.
Definition: lr-wpan-mac.h:1836
MlmeAssociateConfirmCallback m_mlmeAssociateConfirmCallback
This callback is used to report the status after a device request an association with a coordinator.
Definition: lr-wpan-mac.h:1699
bool m_macPromiscuousMode
Indicates if MAC sublayer is in receive all mode.
Definition: lr-wpan-mac.h:1124
uint8_t m_fnlCapSlot
Indication of the Slot where the CAP portion of the OUTGOING Superframe ends.
Definition: lr-wpan-mac.h:1097
uint32_t m_macSIFSPeriod
The minimum time forming a Short InterFrame Spacing (SIFS) period.
Definition: lr-wpan-mac.h:1174
void IfsWaitTimeout(Time ifsTime)
After a successful transmission of a frame (beacon, data) or an ack frame reception,...
bool PrepareRetransmission(void)
Check for remaining retransmissions for the packet currently being sent.
uint32_t m_beaconInterval
Indication of the Interval used by the coordinator to transmit beacon frames expressed in symbols.
Definition: lr-wpan-mac.h:1204
static constexpr uint32_t aMaxLostBeacons
The number of consecutive lost beacons that will cause the MAC sublayer of a receiving device to decl...
Definition: lr-wpan-mac.h:705
void SendBeaconRequestCommand(void)
Called to send a beacon request command.
Definition: lr-wpan-mac.cc:712
TracedValue< LrWpanMacState > m_lrWpanMacState
The current state of the MAC layer.
Definition: lr-wpan-mac.h:1743
TracedCallback< Ptr< const Packet > > m_macTxEnqueueTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
Definition: lr-wpan-mac.h:1546
EventId m_capEvent
Scheduler event for the end of the outgoing superframe CAP.
Definition: lr-wpan-mac.h:1856
Mac64Address GetExtendedAddress(void) const
Get the extended address of this MAC.
Definition: lr-wpan-mac.cc:287
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets are being sent down to L1.
Definition: lr-wpan-mac.h:1569
uint16_t m_macPanId
16 bits id of PAN on which this device is operating.
Definition: lr-wpan-mac.h:1131
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but dropped before being forwa...
Definition: lr-wpan-mac.h:1613
bool m_macAutoRequest
Indication of whether a device automatically sends data request command if its address is listed in t...
Definition: lr-wpan-mac.h:1183
uint8_t m_incomingSuperframeOrder
Used by all devices that have a parent.
Definition: lr-wpan-mac.h:1112
uint16_t m_macPanIdScan
Temporally stores the value of the current m_macPanId when a MLME-SCAN.request is performed.
Definition: lr-wpan-mac.h:1137
TracedCallback< Ptr< const Packet >, uint8_t, uint8_t > m_sentPktTrace
The trace source fired when packets are considered as successfully sent or the transmission has been ...
Definition: lr-wpan-mac.h:1538
TracedCallback< Ptr< const Packet > > m_macPendTxDequeueTrace
The trace source fired when packets are dequeued from the L3/l2 pending transaction list.
Definition: lr-wpan-mac.h:1562
TracedCallback< Ptr< const Packet > > m_macTxDequeueTrace
The trace source fired when packets are dequeued from the L3/l2 transmission queue.
Definition: lr-wpan-mac.h:1554
void PdDataConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.1.2 Confirm the end of transmission of an MPDU to MAC.
uint8_t m_numLostBeacons
The number of consecutive loss beacons in a beacon tracking operation.
Definition: lr-wpan-mac.h:1237
Ptr< Packet > m_txPkt
The packet which is currently being sent by the MAC layer.
Definition: lr-wpan-mac.h:1763
void McpsDataRequest(McpsDataRequestParams params, Ptr< Packet > p)
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
Definition: lr-wpan-mac.cc:293
uint8_t m_maxEnergyLevel
The maximum energy level detected during ED scan on the current channel.
Definition: lr-wpan-mac.h:1188
MlmeScanRequestParams m_scanParams
The parameters used during a MLME-SCAN.request.
Definition: lr-wpan-mac.h:1802
MlmeAssociateIndicationCallback m_mlmeAssociateIndicationCallback
This callback is used to indicate the reception of an association request command.
Definition: lr-wpan-mac.h:1725
static constexpr uint32_t aMinMPDUOverhead
The minimum number of octets added by the MAC sublayer to the PSDU.
Definition: lr-wpan-mac.h:677
void SetPhy(Ptr< LrWpanPhy > phy)
Set the underlying PHY for the MAC.
LrWpanAssociationStatus GetAssociationStatus(void) const
Get the current association status.
void AwaitBeacon(void)
Called after the end of an INCOMING superframe to start the moment a device waits for a new incoming ...
Mac64Address m_selfExt
The extended address used by this MAC.
Definition: lr-wpan-mac.h:1776
EventId m_incCapEvent
Scheduler event for the end of the incoming superframe CAP.
Definition: lr-wpan-mac.h:1866
McpsDataIndicationCallback m_mcpsDataIndicationCallback
This callback is used to notify incoming packets to the upper layers.
Definition: lr-wpan-mac.h:1719
bool m_beaconTrackingOn
Indication of whether the current device is tracking incoming beacons.
Definition: lr-wpan-mac.h:1232
uint32_t m_superframeDuration
Indication of the superframe duration in symbols.
Definition: lr-wpan-mac.h:1210
Mac16Address m_macCoordShortAddress
The short address of the coordinator through which the device is associated.
Definition: lr-wpan-mac.h:1046
void AckWaitTimeout(void)
Handle an ACK timeout with a packet retransmission, if there are retransmission left,...
Ptr< LrWpanPhy > m_phy
The PHY associated with this MAC.
Definition: lr-wpan-mac.h:1668
void EndChannelEnergyScan(void)
Called at the end of one ED channel scan.
Definition: lr-wpan-mac.cc:888
LrWpanMac(void)
Default constructor.
Definition: lr-wpan-mac.cc:146
void EndChannelScan(void)
Called at the end of the current channel scan (Active or Passive) for a given duration.
Definition: lr-wpan-mac.cc:831
bool isTxAckReq(void)
Check if the packet to transmit requires acknowledgment.
void PrintPendTxQ(std::ostream &os) const
Print the Pending transaction list.
uint64_t GetTxPacketSymbols(void)
Obtain the number of symbols in the packet which is currently being sent by the MAC layer.
std::deque< std::unique_ptr< IndTxQueueElement > > m_indTxQueue
The indirect transmit queue used by the MAC pending messages.
Definition: lr-wpan-mac.h:1786
void StartCAP(SuperframeType superframeType)
Called to begin the Contention Access Period (CAP) in a beacon-enabled mode.
Definition: lr-wpan-mac.cc:943
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Definition: lr-wpan-mac.h:1595
void MlmePollRequest(MlmePollRequestParams params)
IEEE 802.15.4-2011, section 6.2.14.2 MLME-POLL.request Prompts the device to request data from the co...
Definition: lr-wpan-mac.cc:638
EventId m_ifsEvent
Scheduler event for Interframe spacing wait time.
Definition: lr-wpan-mac.h:1846
EventId m_beaconEvent
Scheduler event for generation of one beacon.
Definition: lr-wpan-mac.h:1851
uint32_t m_incomingSuperframeDuration
Indication of the superframe duration in symbols (e.g.
Definition: lr-wpan-mac.h:1222
void RemovePendTxQElement(Ptr< Packet > p)
Remove an element from the pending transaction list.
void SetShortAddress(Mac16Address address)
Set the short address of this MAC.
Definition: lr-wpan-mac.cc:265
void SetMacMaxFrameRetries(uint8_t retries)
Set the macMaxFrameRetries attribute value.
uint8_t m_retransmission
The number of already used retransmission for the currently transmitted packet.
Definition: lr-wpan-mac.h:1825
PendingAddrFields GetPendingAddrFields(void)
Constructs Pending Address Fields from the local information, the Pending Address Fields are part of ...
bool isCoordDest(void)
Check if the packet destination is its coordinator.
EventId m_incCfpEvent
Scheduler event for the end of the incoming superframe CFP.
Definition: lr-wpan-mac.h:1871
void SendAck(uint8_t seqno)
Send an acknowledgment packet for the given sequence number.
uint8_t m_incomingFnlCapSlot
Indication of the Slot where the CAP portion of the INCOMING Superframe ends.
Definition: lr-wpan-mac.h:1117
MlmeCommStatusIndicationCallback m_mlmeCommStatusIndicationCallback
This callback is instigated through a response primitive.
Definition: lr-wpan-mac.h:1731
TracedValue< SuperframeStatus > m_incSuperframeStatus
The current period of the incoming superframe.
Definition: lr-wpan-mac.h:1748
void SetAssociatedCoor(Mac16Address mac)
Check if the packet destination is its coordinator.
Represent the Mac Trailer with the Frame Check Sequence field.
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
bool CheckFcs(Ptr< const Packet > p)
Check the FCS of a given packet against the FCS value stored in the trailer.
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
static const uint32_t aMaxPhyPacketSize
The maximum packet size accepted by the PHY.
Definition: lr-wpan-phy.h:264
This class can contain 16 bit addresses.
Definition: mac16-address.h:42
bool IsBroadcast(void) const
Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).
bool IsMulticast(void) const
Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e....
an EUI-64 address
Definition: mac64-address.h:44
static Mac64Address Allocate(void)
Allocate a new Mac64Address.
static bool ChecksumEnabled(void)
Definition: node.cc:278
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
A base class which provides memory management and object aggregation.
Definition: object.h:88
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
uint32_t RemoveTrailer(Trailer &trailer)
Remove a deserialized trailer from the internal buffer.
Definition: packet.cc:318
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
Definition: packet.cc:307
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
Represent the Pending Address Specification field.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:555
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:586
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:204
Represent the Superframe Specification information field.
bool IsBattLifeExt(void) const
Check if the Battery Life Extension bit is enabled.
void SetBattLifeExt(bool battLifeExt)
Set the Superframe Specification Battery Life Extension (BLE).
uint8_t GetFinalCapSlot(void) const
Get the the Final CAP Slot.
void SetFinalCapSlot(uint8_t capSlot)
Set the superframe specification Final CAP slot field.
void SetSuperframeOrder(uint8_t frmOrder)
Set the superframe specification Superframe Order field.
void SetPanCoor(bool panCoor)
Set the Superframe Specification PAN coordinator field.
void SetBeaconOrder(uint8_t bcnOrder)
Set the superframe specification Beacon Order field.
uint8_t GetBeaconOrder(void) const
Get the Superframe Specification Beacon Order field.
uint8_t GetFrameOrder(void) const
Get the Superframe Specification Frame Order field.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
@ S
second
Definition: nstime.h:115
bool IsZero(void) const
Exactly equivalent to t == 0.
Definition: nstime.h:301
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:418
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:257
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
LrWpanMacState
MAC states.
Definition: lr-wpan-mac.h:72
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:108
LrWpanAssociationStatus
table 83 of 802.15.4
Definition: lr-wpan-mac.h:166
SuperframeType
Superframe type.
Definition: lr-wpan-mac.h:104
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:143
@ CHANNEL_ACCESS_FAILURE
CHANNEL_ACCESS_FAILURE.
Definition: lr-wpan-mac.h:77
@ MAC_IDLE
MAC_IDLE.
Definition: lr-wpan-mac.h:73
@ MAC_CSMA_DEFERRED
MAC_CSMA_DEFERRED.
Definition: lr-wpan-mac.h:82
@ MAC_CSMA
MAC_CSMA.
Definition: lr-wpan-mac.h:74
@ CHANNEL_IDLE
CHANNEL_IDLE.
Definition: lr-wpan-mac.h:78
@ MAC_SENDING
MAC_SENDING.
Definition: lr-wpan-mac.h:75
@ MAC_ACK_PENDING
MAC_ACK_PENDING.
Definition: lr-wpan-mac.h:76
@ FFD
Full Functional Device (FFD)
@ MLMESCAN_ED
Definition: lr-wpan-mac.h:181
@ MLMESCAN_PASSIVE
Definition: lr-wpan-mac.h:183
@ MLMESCAN_ORPHAN
Definition: lr-wpan-mac.h:184
@ MLMESCAN_ACTIVE
Definition: lr-wpan-mac.h:182
@ IEEE_802_15_4_TRANSACTION_OVERFLOW
Definition: lr-wpan-mac.h:195
@ IEEE_802_15_4_NO_ACK
Definition: lr-wpan-mac.h:200
@ IEEE_802_15_4_CHANNEL_ACCESS_FAILURE
Definition: lr-wpan-mac.h:197
@ IEEE_802_15_4_INVALID_ADDRESS
Definition: lr-wpan-mac.h:198
@ IEEE_802_15_4_SUCCESS
Definition: lr-wpan-mac.h:194
@ IEEE_802_15_4_FRAME_TOO_LONG
Definition: lr-wpan-mac.h:202
@ IEEE_802_15_4_TRANSACTION_EXPIRED
Definition: lr-wpan-mac.h:196
@ MLMESCAN_SUCCESS
Definition: lr-wpan-mac.h:234
@ MLMESCAN_SCAN_IN_PROGRESS
Definition: lr-wpan-mac.h:237
@ MLMESCAN_INVALID_PARAMETER
Definition: lr-wpan-mac.h:242
@ CFP
Contention Free Period.
Definition: lr-wpan-mac.h:94
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
Definition: lr-wpan-mac.h:95
@ CAP
Contention Access Period.
Definition: lr-wpan-mac.h:93
@ BEACON
The Beacon transmission or reception Period.
Definition: lr-wpan-mac.h:92
@ IEEE_802_15_4_PHY_SUCCESS
Definition: lr-wpan-phy.h:116
@ IEEE_802_15_4_PHY_UNSPECIFIED
Definition: lr-wpan-phy.h:121
@ IEEE_802_15_4_PHY_TRX_OFF
Definition: lr-wpan-phy.h:117
@ IEEE_802_15_4_PHY_RX_ON
Definition: lr-wpan-phy.h:115
@ IEEE_802_15_4_PHY_TX_ON
Definition: lr-wpan-phy.h:118
@ TX_OPTION_ACK
TX_OPTION_ACK.
Definition: lr-wpan-mac.h:61
@ TX_OPTION_INDIRECT
TX_OPTION_INDIRECT.
Definition: lr-wpan-mac.h:63
@ TX_OPTION_GTS
TX_OPTION_GTS.
Definition: lr-wpan-mac.h:62
@ ASSOCIATED
Definition: lr-wpan-mac.h:167
@ MLMESTART_INVALID_PARAMETER
Definition: lr-wpan-mac.h:219
@ MLMESTART_SUCCESS
Definition: lr-wpan-mac.h:215
@ MLMESTART_NO_SHORT_ADDRESS
Definition: lr-wpan-mac.h:216
@ MLME_SCAN_REQ
Pending MLME-SCAN.request primitive.
Definition: lr-wpan-mac.h:118
@ MLME_START_REQ
Pending MLME-START.request primitive.
Definition: lr-wpan-mac.h:117
@ MLME_NONE
No pending primitive.
Definition: lr-wpan-mac.h:116
@ SHORT_ADDR
Definition: lr-wpan-mac.h:156
@ NO_PANID_ADDR
Definition: lr-wpan-mac.h:154
@ EXT_ADDR
Definition: lr-wpan-mac.h:157
@ ADDR_MODE_RESERVED
Definition: lr-wpan-mac.h:155
@ INCOMING
Incoming Superframe.
Definition: lr-wpan-mac.h:106
@ OUTGOING
Outgoing Superframe.
Definition: lr-wpan-mac.h:105
@ MLMECOMMSTATUS_TRANSACTION_EXPIRED
Definition: lr-wpan-mac.h:286
@ phyCurrentChannel
Definition: lr-wpan-phy.h:144
@ phyCurrentPage
Definition: lr-wpan-phy.h:148
@ MLMESYNCLOSS_BEACON_LOST
Definition: lr-wpan-mac.h:273
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
SequenceNumber< uint8_t, int8_t > SequenceNumber8
8 bit Sequence number.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mac
Definition: third.py:87
phy
Definition: third.py:84
Helper structure for managing pending transaction list elements (Indirect transmissions).
Definition: lr-wpan-mac.h:1354
Helper structure for managing transmission queue elements.
Definition: lr-wpan-mac.h:1344
Ptr< Packet > txQPkt
Queued packet.
Definition: lr-wpan-mac.h:1346
uint8_t txQMsduHandle
MSDU Handle.
Definition: lr-wpan-mac.h:1345
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:160
uint8_t phyCurrentPage
Current channel page.
Definition: lr-wpan-phy.h:165
uint8_t phyCurrentChannel
The RF channel to use.
Definition: lr-wpan-phy.h:161
MCPS-DATA.confirm params.
Definition: lr-wpan-mac.h:353
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
Definition: lr-wpan-mac.h:355
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:354
MCPS-DATA.indication params.
Definition: lr-wpan-mac.h:364
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:371
uint8_t m_dstAddrMode
Destination address mode.
Definition: lr-wpan-mac.h:369
uint16_t m_dstPanId
Destination PAN identifier.
Definition: lr-wpan-mac.h:370
uint8_t m_dsn
The DSN of the received data frame.
Definition: lr-wpan-mac.h:374
uint8_t m_mpduLinkQuality
LQI value measured during reception of the MPDU.
Definition: lr-wpan-mac.h:373
uint16_t m_srcPanId
Source PAN identifier.
Definition: lr-wpan-mac.h:366
Mac64Address m_dstExtAddr
Destination extended address.
Definition: lr-wpan-mac.h:372
uint8_t m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:365
Mac64Address m_srcExtAddr
Source extended address.
Definition: lr-wpan-mac.h:368
Mac16Address m_srcAddr
Source address.
Definition: lr-wpan-mac.h:367
MCPS-DATA.request params.
Definition: lr-wpan-mac.h:337
LrWpanAddressMode m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:338
Mac64Address m_dstExtAddr
Destination extended address.
Definition: lr-wpan-mac.h:342
LrWpanAddressMode m_dstAddrMode
Destination address mode.
Definition: lr-wpan-mac.h:339
uint16_t m_dstPanId
Destination PAN identifier.
Definition: lr-wpan-mac.h:340
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:341
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:343
uint8_t m_txOptions
Tx Options (bitfield)
Definition: lr-wpan-mac.h:344
MLME-BEACON-NOTIFY.indication params.
Definition: lr-wpan-mac.h:513
uint32_t m_sduLength
The number of octets contained in the beacon payload.
Definition: lr-wpan-mac.h:517
uint8_t m_bsn
The beacon sequence number.
Definition: lr-wpan-mac.h:514
Ptr< Packet > m_sdu
The set of octets comprising the beacon payload.
Definition: lr-wpan-mac.h:518
PanDescriptor m_panDescriptor
The PAN descriptor for the received beacon.
Definition: lr-wpan-mac.h:515
MLME-COMM-STATUS.indication params.
Definition: lr-wpan-mac.h:539
LrWpanMlmeCommStatus m_status
The communication status.
Definition: lr-wpan-mac.h:547
Mac64Address m_dstExtAddr
The extended address of the device for which the frame was intended.
Definition: lr-wpan-mac.h:546
uint16_t m_panId
The PAN identifier of the device from which the frame was received or to which the frame was being se...
Definition: lr-wpan-mac.h:540
Mac64Address m_srcExtAddr
The extended address of the entity from which the frame causing the error originated.
Definition: lr-wpan-mac.h:543
uint8_t m_dstAddrMode
The destination addressing mode for this primitive.
Definition: lr-wpan-mac.h:544
uint8_t m_srcAddrMode
The source addressing mode for this primitive.
Definition: lr-wpan-mac.h:541
MLME-POLL.request params.
Definition: lr-wpan-mac.h:435
MLME-SCAN.confirm params.
Definition: lr-wpan-mac.h:461
std::vector< PanDescriptor > m_panDescList
A list of PAN descriptor, one for each beacon found (Not valid for ED and Orphan scans).
Definition: lr-wpan-mac.h:467
LrWpanMlmeScanType m_scanType
Indicates the type of scan performed (ED,ACTIVE,PASSIVE,ORPHAN).
Definition: lr-wpan-mac.h:463
uint32_t m_chPage
The channel page on which the scan was performed.
Definition: lr-wpan-mac.h:464
LrWpanMlmeScanConfirmStatus m_status
The status of the scan request.
Definition: lr-wpan-mac.h:462
std::vector< uint8_t > m_energyDetList
A list of energy measurements, one for each channel searched during ED scan (Not valid for Active,...
Definition: lr-wpan-mac.h:466
MLME-SCAN.request params.
Definition: lr-wpan-mac.h:448
uint32_t m_scanChannels
The channel numbers to be scanned.
Definition: lr-wpan-mac.h:450
uint32_t m_chPage
The channel page on which to perform scan.
Definition: lr-wpan-mac.h:452
uint8_t m_scanDuration
A value used to calculate the length of time to spend scanning [aBaseSuperframeDuration * (2^m_scanDu...
Definition: lr-wpan-mac.h:451
LrWpanMlmeScanType m_scanType
Indicates the type of scan performed as described in IEEE 802.15.4-2011 (5.1.2.1).
Definition: lr-wpan-mac.h:449
MLME-START.confirm params.
Definition: lr-wpan-mac.h:503
LrWpanMlmeStartConfirmStatus m_status
The status of a MLME-start.request.
Definition: lr-wpan-mac.h:504
MLME-START.request params.
Definition: lr-wpan-mac.h:406
uint32_t m_logChPage
Logical channel page on which to start using the new superframe configuration.
Definition: lr-wpan-mac.h:409
uint8_t m_logCh
Logical channel on which to start using the new superframe configuration.
Definition: lr-wpan-mac.h:408
bool m_panCoor
On true this device will become coordinator.
Definition: lr-wpan-mac.h:413
bool m_coorRealgn
True if a realignment request command is to be transmitted prior changing the superframe.
Definition: lr-wpan-mac.h:415
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
Definition: lr-wpan-mac.h:411
uint16_t m_PanId
Pan Identifier used by the device.
Definition: lr-wpan-mac.h:407
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
Definition: lr-wpan-mac.h:412
bool m_battLifeExt
Flag indicating whether or not the Battery life extension (BLE) features are used.
Definition: lr-wpan-mac.h:414
MLME-SYNC-LOSS.indication params.
Definition: lr-wpan-mac.h:527
uint16_t m_panId
The PAN identifier with which the device lost synchronization or to which it was realigned.
Definition: lr-wpan-mac.h:529
LrWpanSyncLossReason m_lossReason
The reason for the lost of synchronization.
Definition: lr-wpan-mac.h:528
MLME-SYNC.request params.
Definition: lr-wpan-mac.h:424
bool m_trackBcn
True if the mlme sync with the next beacon and attempts to track future beacons.
Definition: lr-wpan-mac.h:426
uint8_t m_logCh
The channel number on which to attempt coordinator synchronization.
Definition: lr-wpan-mac.h:425
PAN Descriptor, Table 17 IEEE 802.15.4-2011.
Definition: lr-wpan-mac.h:318
LrWpanAddressMode m_coorAddrMode
The coordinator addressing mode corresponding to the received beacon frame.
Definition: lr-wpan-mac.h:319
Mac64Address m_coorExtAddr
The coordinator extended address as specified in the coordinator address mode.
Definition: lr-wpan-mac.h:322
Mac16Address m_coorShortAddr
The coordinator short address as specified in the coordinator address mode.
Definition: lr-wpan-mac.h:321
uint8_t m_logChPage
The current channel page occupied by the network.
Definition: lr-wpan-mac.h:324
uint16_t m_coorPanId
The PAN ID of the coordinator as specified in the received beacon frame.
Definition: lr-wpan-mac.h:320
bool m_gtsPermit
TRUE if the beacon is from the PAN coordinator that is accepting GTS requests.
Definition: lr-wpan-mac.h:326
SuperframeField m_superframeSpec
The superframe specification as specified in the received beacon frame.
Definition: lr-wpan-mac.h:325
uint8_t m_linkQuality
The LQI at which the network beacon was received.
Definition: lr-wpan-mac.h:327
Time m_timeStamp
Beacon frame reception time.
Definition: lr-wpan-mac.h:328
uint8_t m_logCh
The current channel number occupied by the network.
Definition: lr-wpan-mac.h:323