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"
29 #include "lr-wpan-mac-pl-headers.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 #undef NS_LOG_APPEND_CONTEXT
40 #define NS_LOG_APPEND_CONTEXT \
41  std::clog << "[address " << m_shortAddress << "] ";
42 
43 namespace ns3 {
44 
45 NS_LOG_COMPONENT_DEFINE ("LrWpanMac");
46 
47 NS_OBJECT_ENSURE_REGISTERED (LrWpanMac);
48 
49 //IEEE 802.15.4-2011 Table 51
50 const uint32_t LrWpanMac::aMinMPDUOverhead = 9;
51 const uint32_t LrWpanMac::aBaseSlotDuration = 60;
52 const uint32_t LrWpanMac::aNumSuperframeSlots = 16;
53 const uint32_t LrWpanMac::aBaseSuperframeDuration = aBaseSlotDuration * aNumSuperframeSlots;
54 const uint32_t LrWpanMac::aMaxLostBeacons = 4;
55 const uint32_t LrWpanMac::aMaxSIFSFrameSize = 18;
56 
57 TypeId
59 {
60  static TypeId tid = TypeId ("ns3::LrWpanMac")
61  .SetParent<Object> ()
62  .SetGroupName ("LrWpan")
63  .AddConstructor<LrWpanMac> ()
64  .AddAttribute ("PanId", "16-bit identifier of the associated PAN",
65  UintegerValue (),
67  MakeUintegerChecker<uint16_t> ())
68  .AddTraceSource ("MacTxEnqueue",
69  "Trace source indicating a packet has been "
70  "enqueued in the transaction queue",
72  "ns3::Packet::TracedCallback")
73  .AddTraceSource ("MacTxDequeue",
74  "Trace source indicating a packet has was "
75  "dequeued from the transaction queue",
77  "ns3::Packet::TracedCallback")
78  .AddTraceSource ("MacTx",
79  "Trace source indicating a packet has "
80  "arrived for transmission by this device",
82  "ns3::Packet::TracedCallback")
83  .AddTraceSource ("MacTxOk",
84  "Trace source indicating a packet has been "
85  "successfully sent",
87  "ns3::Packet::TracedCallback")
88  .AddTraceSource ("MacTxDrop",
89  "Trace source indicating a packet has been "
90  "dropped during transmission",
92  "ns3::Packet::TracedCallback")
93  .AddTraceSource ("MacPromiscRx",
94  "A packet has been received by this device, "
95  "has been passed up from the physical layer "
96  "and is being forwarded up the local protocol stack. "
97  "This is a promiscuous trace,",
99  "ns3::Packet::TracedCallback")
100  .AddTraceSource ("MacRx",
101  "A packet has been received by this device, "
102  "has been passed up from the physical layer "
103  "and is being forwarded up the local protocol stack. "
104  "This is a non-promiscuous trace,",
106  "ns3::Packet::TracedCallback")
107  .AddTraceSource ("MacRxDrop",
108  "Trace source indicating a packet was received, "
109  "but dropped before being forwarded up the stack",
111  "ns3::Packet::TracedCallback")
112  .AddTraceSource ("Sniffer",
113  "Trace source simulating a non-promiscuous "
114  "packet sniffer attached to the device",
116  "ns3::Packet::TracedCallback")
117  .AddTraceSource ("PromiscSniffer",
118  "Trace source simulating a promiscuous "
119  "packet sniffer attached to the device",
121  "ns3::Packet::TracedCallback")
122  .AddTraceSource ("MacStateValue",
123  "The state of LrWpan Mac",
125  "ns3::TracedValueCallback::LrWpanMacState")
126  .AddTraceSource ("MacIncSuperframeStatus",
127  "The period status of the incoming superframe",
129  "ns3::TracedValueCallback::SuperframeState")
130  .AddTraceSource ("MacOutSuperframeStatus",
131  "The period status of the outgoing superframe",
133  "ns3::TracedValueCallback::SuperframeState")
134  .AddTraceSource ("MacState",
135  "The state of LrWpan Mac",
137  "ns3::LrWpanMac::StateTracedCallback")
138  .AddTraceSource ("MacSentPkt",
139  "Trace source reporting some information about "
140  "the sent packet",
142  "ns3::LrWpanMac::SentTracedCallback")
143  .AddTraceSource ("IfsEnd",
144  "Trace source reporting the end of an "
145  "Interframe space (IFS) ",
147  "ns3::Packet::TracedCallback")
148  ;
149  return tid;
150 }
151 
153 {
154 
155  // First set the state to a known value, call ChangeMacState to fire trace source.
157 
159 
162 
163  m_macRxOnWhenIdle = true;
164  m_macPanId = 0xffff;
168  m_macPromiscuousMode = false;
170  m_retransmission = 0;
171  m_numCsmacaRetry = 0;
172  m_txPkt = 0;
173  m_ifs = 0;
174 
175  m_macLIFSPeriod = 40;
176  m_macSIFSPeriod = 12;
177 
178  m_macBeaconOrder = 15;
180  m_macTransactionPersistanceTime = 500; //0x01F5
181  m_macAutoRequest = true;
182 
185  m_beaconTrackingOn = false;
186  m_numLostBeacons = 0;
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 
200 void
202 {
203  if (m_macRxOnWhenIdle)
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 
215 void
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 
239 bool
241 {
242  return m_macRxOnWhenIdle;
243 }
244 
245 void
246 LrWpanMac::SetRxOnWhenIdle (bool rxOnWhenIdle)
247 {
248  NS_LOG_FUNCTION (this << rxOnWhenIdle);
249  m_macRxOnWhenIdle = rxOnWhenIdle;
250 
251  if (m_lrWpanMacState == MAC_IDLE)
252  {
253  if (m_macRxOnWhenIdle)
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 
264 void
266 {
267  //NS_LOG_FUNCTION (this << address);
269 }
270 
271 void
273 {
274  //NS_LOG_FUNCTION (this << address);
275  m_selfExt = 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 }
292 void
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 ());
313  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
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" );
325  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
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;
338  case ADDR_MODE_RESERVED:
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);
343  macHdr.SetSrcAddrFields (GetPanId (), GetShortAddress ());
344  break;
345  case EXT_ADDR:
346  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
347  macHdr.SetSrcAddrFields (GetPanId (), GetExtendedAddress ());
348  break;
349  default:
350  NS_LOG_ERROR (this << " Can not send packet with incorrect Source Address mode = " << params.m_srcAddrMode);
351  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
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;
364  case ADDR_MODE_RESERVED:
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);
377  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
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.
440  if (Node::ChecksumEnabled ())
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  IndTxQueueElement *indTxQElement = new IndTxQueueElement;
458  uint64_t unitPeriodSymbols;
459  Time expireTime;
460 
461  if (m_macBeaconOrder == 15)
462  {
463  unitPeriodSymbols = aBaseSuperframeDuration;
464  }
465  else
466  {
467  unitPeriodSymbols = ((uint64_t) 1 << m_macBeaconOrder) * aBaseSuperframeDuration;
468  }
469 
470  //TODO: check possible incorrect expire time here.
471 
473  * MicroSeconds (unitPeriodSymbols * 1000 * 1000 / m_phy->GetDataOrSymbolRate (false));
474  indTxQElement->expireTime = expireTime;
475  indTxQElement->txQMsduHandle = params.m_msduHandle;
476  indTxQElement->txQPkt = p;
477 
478  m_indTxQueue.push_back (indTxQElement);
479 
480  std::cout << "Indirect Transmission Pushed | Elements in the queue: " << m_indTxQueue.size ()
481  << " " << "Element to expire in: " << expireTime.GetSeconds () << "secs\n";
482  }
483  }
484  else
485  {
486  // Direct Tx
487  // From this point the packet will be pushed to a Tx queue and immediately
488  // use a slotted (beacon-enabled) or unslotted (nonbeacon-enabled) version of CSMA/CA
489  // before sending the packet, depending on whether it has previously
490  // received a valid beacon or not.
491 
492  p->AddHeader (macHdr);
493 
494  LrWpanMacTrailer macTrailer;
495  // Calculate FCS if the global attribute ChecksumEnable is set.
496  if (Node::ChecksumEnabled ())
497  {
498  macTrailer.EnableFcs (true);
499  macTrailer.SetFcs (p);
500  }
501  p->AddTrailer (macTrailer);
502 
504 
505  TxQueueElement *txQElement = new TxQueueElement;
506  txQElement->txQMsduHandle = params.m_msduHandle;
507  txQElement->txQPkt = p;
508  m_txQueue.push_back (txQElement);
509  CheckQueue ();
510  }
511 
512 }
513 
514 
515 void
517 {
518  NS_LOG_FUNCTION (this);
520 
521  MlmeStartConfirmParams confirmParams;
522 
523 
524  if (GetShortAddress () == Mac16Address ("ff:ff"))
525  {
526  NS_LOG_ERROR (this << " Invalid MAC short address" );
527  confirmParams.m_status = MLMESTART_NO_SHORT_ADDRESS;
529  {
530  m_mlmeStartConfirmCallback (confirmParams);
531  }
532  return;
533  }
534 
535 
536  if ( (params.m_logCh > 26)
537  || (params.m_bcnOrd > 15)
538  || (params.m_sfrmOrd > params.m_bcnOrd))
539  {
540  NS_LOG_ERROR (this << " One or more parameters are invalid" );
541  confirmParams.m_status = MLMESTART_INVALID_PARAMETER;
543  {
544  m_mlmeStartConfirmCallback (confirmParams);
545  }
546  return;
547  }
548 
549 
550  if (params.m_coorRealgn) //Coordinator Realignment
551  {
552  // TODO:: Send realignment request command frame in CSMA/CA
553  return;
554  }
555  else
556  {
557  if (params.m_panCoor)
558  {
559  m_panCoor = true;
560  m_macPanId = params.m_PanId;
561 
562  // Setting Channel and Page in the LrWpanPhy
563  LrWpanPhyPibAttributes pibAttr;
564  pibAttr.phyCurrentChannel = params.m_logCh;
565  pibAttr.phyCurrentPage = params.m_logChPage;
566  m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentChannel,&pibAttr);
567  m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentPage,&pibAttr);
568  }
569 
570  NS_ASSERT (params.m_PanId != 0xffff);
571 
572 
573  m_macBeaconOrder = params.m_bcnOrd;
574  if (m_macBeaconOrder == 15)
575  {
576  //Non-beacon enabled PAN
578  m_beaconInterval = 0;
579  m_csmaCa->SetUnSlottedCsmaCa ();
580 
581  confirmParams.m_status = MLMESTART_SUCCESS;
583  {
584  m_mlmeStartConfirmCallback (confirmParams);
585  }
586  }
587  else
588  {
590  m_csmaCa->SetBatteryLifeExtension (params.m_battLifeExt);
591 
592  m_csmaCa->SetSlottedCsmaCa ();
593 
594  //TODO: Calculate the real Final CAP slot (requires GTS implementation)
595  // FinalCapSlot = Superframe duration slots - CFP slots.
596  // In the current implementation the value of the final cap slot is equal to
597  // the total number of possible slots in the superframe (15).
598  m_fnlCapSlot = 15;
599 
602 
603  //TODO: change the beacon sending according to the startTime parameter (if not PAN coordinator)
604 
606  }
607  }
608 }
609 
610 
611 void
613 {
614  NS_LOG_FUNCTION (this);
615  NS_ASSERT (params.m_logCh <= 26 && m_macPanId != 0xffff);
616 
617  uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
618  //change phy current logical channel
619  LrWpanPhyPibAttributes pibAttr;
620  pibAttr.phyCurrentChannel = params.m_logCh;
621  m_phy->PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier::phyCurrentChannel,&pibAttr);
622 
623  //Enable Phy receiver
624  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
625 
626  uint64_t searchSymbols;
627  Time searchBeaconTime;
628 
629  if (m_trackingEvent.IsRunning ())
630  {
632  }
633 
634  if (params.m_trackBcn)
635  {
636  m_numLostBeacons = 0;
637  //search for a beacon for a time = incomingSuperframe symbols + 960 symbols
638  searchSymbols = ((uint64_t) 1 << m_incomingBeaconOrder) + 1 * aBaseSuperframeDuration;
639  searchBeaconTime = Seconds ((double) searchSymbols / symbolRate);
640  m_beaconTrackingOn = true;
642  }
643  else
644  {
645  m_beaconTrackingOn = false;
646  }
647 
648 }
649 
650 
651 void
653 {
654  NS_LOG_FUNCTION (this);
655 
657  m_macBsn++;
658 
660 
661  Ptr<Packet> beaconPacket = Create <Packet> ();
662 }
663 
664 
665 void
667 {
668  NS_LOG_FUNCTION (this);
670 
672  m_macBsn++;
673  BeaconPayloadHeader macPayload;
674  Ptr<Packet> beaconPacket = Create <Packet> ();
675  LrWpanMacTrailer macTrailer;
676 
677  macHdr.SetDstAddrMode (LrWpanMacHeader::SHORTADDR);
678  macHdr.SetDstAddrFields (GetPanId (),Mac16Address ("ff:ff"));
679 
680  //see IEEE 802.15.4-2011 Section 5.1.2.4
681  if (GetShortAddress () == Mac16Address ("ff:fe"))
682  {
683  macHdr.SetSrcAddrMode (LrWpanMacHeader::EXTADDR);
684  macHdr.SetSrcAddrFields (GetPanId (),GetExtendedAddress ());
685  }
686  else
687  {
688  macHdr.SetSrcAddrMode (LrWpanMacHeader::SHORTADDR);
689  macHdr.SetSrcAddrFields (GetPanId (), GetShortAddress ());
690  }
691 
692  macHdr.SetSecDisable ();
693  macHdr.SetNoAckReq ();
694 
696  macPayload.SetGtsFields (GetGtsFields ());
697  macPayload.SetPndAddrFields (GetPendingAddrFields ());
698 
699  beaconPacket->AddHeader (macPayload);
700  beaconPacket->AddHeader (macHdr);
701 
702  // Calculate FCS if the global attribute ChecksumEnable is set.
703  if (Node::ChecksumEnabled ())
704  {
705  macTrailer.EnableFcs (true);
706  macTrailer.SetFcs (beaconPacket);
707  }
708 
709  beaconPacket->AddTrailer (macTrailer);
710 
711  //Set the Beacon packet to be transmitted
712  m_txPkt = beaconPacket;
713 
715 
716  NS_LOG_DEBUG ("Outgoing superframe Active Portion (Beacon + CAP + CFP): " << m_superframeDuration << " symbols");
717 
719  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
720 }
721 
722 
723 void
725 {
726  uint32_t activeSlot;
727  uint64_t capDuration;
728  Time endCapTime;
729  uint64_t symbolRate;
730 
731  symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
732 
733  if (superframeType == OUTGOING)
734  {
736  activeSlot = m_superframeDuration / 16;
737  capDuration = activeSlot * (m_fnlCapSlot + 1);
738  endCapTime = Seconds ((double) capDuration / symbolRate);
739  // Obtain the end of the CAP by adjust the time it took to send the beacon
740  endCapTime -= (Simulator::Now () - m_macBeaconTxTime);
741 
742  NS_LOG_DEBUG ("Outgoing superframe CAP duration " << (endCapTime.GetSeconds () * symbolRate) << " symbols (" << endCapTime.As (Time::S) << ")");
743  NS_LOG_DEBUG ("Active Slots duration " << activeSlot << " symbols");
744 
745  m_capEvent = Simulator::Schedule (endCapTime,
747 
748  }
749  else
750  {
752  activeSlot = m_incomingSuperframeDuration / 16;
753  capDuration = activeSlot * (m_incomingFnlCapSlot + 1);
754  endCapTime = Seconds ((double) capDuration / symbolRate);
755  // Obtain the end of the CAP by adjust the time it took to receive the beacon
756  endCapTime -= (Simulator::Now () - m_macBeaconRxTime);
757 
758  NS_LOG_DEBUG ("Incoming superframe CAP duration " << (endCapTime.GetSeconds () * symbolRate) << " symbols (" << endCapTime.As (Time::S) << ")");
759  NS_LOG_DEBUG ("Active Slots duration " << activeSlot << " symbols");
760 
761  m_capEvent = Simulator::Schedule (endCapTime,
763  }
764 
765  CheckQueue ();
766 
767 }
768 
769 
770 void
772 {
773  uint32_t activeSlot;
774  uint64_t cfpDuration;
775  Time endCfpTime;
776  uint64_t symbolRate;
777 
778  symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
779 
780  if (superframeType == INCOMING)
781  {
782  activeSlot = m_incomingSuperframeDuration / 16;
783  cfpDuration = activeSlot * (15 - m_incomingFnlCapSlot);
784  endCfpTime = Seconds ((double) cfpDuration / symbolRate);
785  if (cfpDuration > 0)
786  {
788  }
789 
790  NS_LOG_DEBUG ("Incoming superframe CFP duration " << cfpDuration << " symbols (" << endCfpTime.As (Time::S) << ")");
791 
792  m_incCfpEvent = Simulator::Schedule (endCfpTime,
794  }
795  else
796  {
797  activeSlot = m_superframeDuration / 16;
798  cfpDuration = activeSlot * (15 - m_fnlCapSlot);
799  endCfpTime = Seconds ((double) cfpDuration / symbolRate);
800 
801  if (cfpDuration > 0)
802  {
804  }
805 
806  NS_LOG_DEBUG ("Outgoing superframe CFP duration " << cfpDuration << " symbols (" << endCfpTime.As (Time::S) << ")");
807 
808  m_cfpEvent = Simulator::Schedule (endCfpTime,
810 
811  }
812  //TODO: Start transmit or receive GTS here.
813 }
814 
815 
816 void
818 {
819  uint64_t inactiveDuration;
820  Time endInactiveTime;
821  uint64_t symbolRate;
822 
823  symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
824 
825  if (superframeType == INCOMING)
826  {
828  endInactiveTime = Seconds ((double) inactiveDuration / symbolRate);
829 
830  if (inactiveDuration > 0)
831  {
833  }
834 
835  NS_LOG_DEBUG ("Incoming superframe Inactive Portion duration " << inactiveDuration << " symbols (" << endInactiveTime.As (Time::S) << ")");
836  m_beaconEvent = Simulator::Schedule (endInactiveTime, &LrWpanMac::AwaitBeacon, this);
837  }
838  else
839  {
840  inactiveDuration = m_beaconInterval - m_superframeDuration;
841  endInactiveTime = Seconds ((double) inactiveDuration / symbolRate);
842 
843  if (inactiveDuration > 0)
844  {
846  }
847 
848  NS_LOG_DEBUG ("Outgoing superframe Inactive Portion duration " << inactiveDuration << " symbols (" << endInactiveTime.As (Time::S) << ")");
849  m_beaconEvent = Simulator::Schedule (endInactiveTime, &LrWpanMac::SendOneBeacon, this);
850  }
851 }
852 
853 void
855 {
857 
858  //TODO: If the device waits more than the expected time to receive the beacon (wait = 46 symbols for default beacon size)
859  // it should continue with the start of the incoming CAP even if it did not receive the beacon.
860  // At the moment, the start of the incoming CAP is only triggered if the beacon is received.
861  // See MLME-SyncLoss for details.
862 
863 
864 }
865 
866 void
868 {
869  uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
870 
872  {
873  MlmeSyncLossIndicationParams syncLossParams;
874  //syncLossParams.m_logCh =
875  syncLossParams.m_lossReason = MLMESYNCLOSS_BEACON_LOST;
876  syncLossParams.m_panId = m_macPanId;
877  m_mlmeSyncLossIndicationCallback (syncLossParams);
878 
879  m_beaconTrackingOn = false;
880  m_numLostBeacons = 0;
881  }
882  else
883  {
885 
886  //Search for one more beacon
887  uint64_t searchSymbols;
888  Time searchBeaconTime;
889  searchSymbols = ((uint64_t) 1 << m_incomingBeaconOrder) + 1 * aBaseSuperframeDuration;
890  searchBeaconTime = Seconds ((double) searchSymbols / symbolRate);
892 
893  }
894 }
895 
896 
897 void
899 {
900  NS_LOG_FUNCTION (this);
901  // Pull a packet from the queue and start sending if we are not already sending.
902  if (m_lrWpanMacState == MAC_IDLE && !m_txQueue.empty () && !m_setMacState.IsRunning ())
903  {
904  //TODO: this should check if the node is a coordinator and using the outcoming superframe not just the PAN coordinator
905  if (m_csmaCa->IsUnSlottedCsmaCa () || (m_outSuperframeStatus == CAP && m_panCoor) || m_incSuperframeStatus == CAP)
906  {
907  // check MAC is not in a IFS
908  if (!m_ifsEvent.IsRunning ())
909  {
910  TxQueueElement *txQElement = m_txQueue.front ();
911  m_txPkt = txQElement->txQPkt;
913  }
914  }
915  }
916 }
917 
918 
921 {
922  SuperframeField sfrmSpec;
923 
924  sfrmSpec.SetBeaconOrder (m_macBeaconOrder);
926  sfrmSpec.SetFinalCapSlot (m_fnlCapSlot);
927 
928  if (m_csmaCa->GetBatteryLifeExtension ())
929  {
930  sfrmSpec.SetBattLifeExt (true);
931  }
932 
933  if (m_panCoor)
934  {
935  sfrmSpec.SetPanCoor (true);
936  }
937  //TODO: It is possible to do association using Beacons,
938  // however, the current implementation only support manual association.
939  // The association permit should be set here.
940 
941  return sfrmSpec;
942 }
943 
944 GtsFields
946 {
947  GtsFields gtsFields;
948 
949  // TODO: Logic to populate the GTS Fields from local information here
950 
951  return gtsFields;
952 }
953 
956 {
957  PendingAddrFields pndAddrFields;
958 
959  // TODO: Logic to populate the Pending Address Fields from local information here
960  return pndAddrFields;
961 }
962 
963 
964 void
966 {
967  m_csmaCa = csmaCa;
968 }
969 
970 void
972 {
973  m_phy = phy;
974 }
975 
978 {
979  return m_phy;
980 }
981 
982 void
984 {
986 }
987 
988 void
990 {
992 }
993 
994 void
996 {
998 }
999 
1000 void
1002 {
1004 }
1005 
1006 void
1008 {
1010 }
1011 
1012 void
1014 {
1016 }
1017 
1018 void
1019 LrWpanMac::PdDataIndication (uint32_t psduLength, Ptr<Packet> p, uint8_t lqi)
1020 {
1022  NS_LOG_FUNCTION (this << psduLength << p << (uint16_t)lqi);
1023 
1024  bool acceptFrame;
1025 
1026  // from sec 7.5.6.2 Reception and rejection, Std802.15.4-2006
1027  // level 1 filtering, test FCS field and reject if frame fails
1028  // level 2 filtering if promiscuous mode pass frame to higher layer otherwise perform level 3 filtering
1029  // level 3 filtering accept frame
1030  // if Frame type and version is not reserved, and
1031  // if there is a dstPanId then dstPanId=m_macPanId or broadcastPanI, and
1032  // if there is a shortDstAddr then shortDstAddr =shortMacAddr or broadcastAddr, and
1033  // if beacon frame then srcPanId = m_macPanId
1034  // if only srcAddr field in Data or Command frame,accept frame if srcPanId=m_macPanId
1035 
1036  Ptr<Packet> originalPkt = p->Copy (); // because we will strip headers
1037  uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
1038  m_promiscSnifferTrace (originalPkt);
1039 
1040  m_macPromiscRxTrace (originalPkt);
1041  // XXX no rejection tracing (to macRxDropTrace) being performed below
1042 
1043  LrWpanMacTrailer receivedMacTrailer;
1044  p->RemoveTrailer (receivedMacTrailer);
1045  if (Node::ChecksumEnabled ())
1046  {
1047  receivedMacTrailer.EnableFcs (true);
1048  }
1049 
1050  // level 1 filtering
1051  if (!receivedMacTrailer.CheckFcs (p))
1052  {
1053  m_macRxDropTrace (originalPkt);
1054  }
1055  else
1056  {
1057  LrWpanMacHeader receivedMacHdr;
1058  p->RemoveHeader (receivedMacHdr);
1059 
1060  McpsDataIndicationParams params;
1061  params.m_dsn = receivedMacHdr.GetSeqNum ();
1062  params.m_mpduLinkQuality = lqi;
1063  params.m_srcPanId = receivedMacHdr.GetSrcPanId ();
1064  params.m_srcAddrMode = receivedMacHdr.GetSrcAddrMode ();
1065  switch (params.m_srcAddrMode)
1066  {
1067  case SHORT_ADDR:
1068  params.m_srcAddr = receivedMacHdr.GetShortSrcAddr ();
1069  break;
1070  case EXT_ADDR:
1071  params.m_srcExtAddr = receivedMacHdr.GetExtSrcAddr ();
1072  break;
1073  default:
1074  break;
1075  }
1076  params.m_dstPanId = receivedMacHdr.GetDstPanId ();
1077  params.m_dstAddrMode = receivedMacHdr.GetDstAddrMode ();
1078  switch (params.m_dstAddrMode)
1079  {
1080  case SHORT_ADDR:
1081  params.m_dstAddr = receivedMacHdr.GetShortDstAddr ();
1082  break;
1083  case EXT_ADDR:
1084  params.m_dstExtAddr = receivedMacHdr.GetExtDstAddr ();
1085  break;
1086  default:
1087  break;
1088  }
1089 
1091  {
1092  //level 2 filtering
1093  if (receivedMacHdr.GetDstAddrMode () == SHORT_ADDR)
1094  {
1095  NS_LOG_DEBUG ("Packet from " << params.m_srcAddr);
1096  NS_LOG_DEBUG ("Packet to " << params.m_dstAddr);
1097  }
1098  else if (receivedMacHdr.GetDstAddrMode () == EXT_ADDR)
1099  {
1100  NS_LOG_DEBUG ("Packet from " << params.m_srcExtAddr);
1101  NS_LOG_DEBUG ("Packet to " << params.m_dstExtAddr);
1102  }
1103 
1104  //TODO: Fix here, this should trigger different Indication Callbacks
1105  //depending the type of frame received (data,command, beacon)
1107  {
1108  NS_LOG_DEBUG ("promiscuous mode, forwarding up");
1109  m_mcpsDataIndicationCallback (params, p);
1110  }
1111  else
1112  {
1113  NS_LOG_ERROR (this << " Data Indication Callback not initialized");
1114  }
1115  }
1116  else
1117  {
1118  //level 3 frame filtering
1119  acceptFrame = (receivedMacHdr.GetType () != LrWpanMacHeader::LRWPAN_MAC_RESERVED);
1120 
1121  if (acceptFrame)
1122  {
1123  acceptFrame = (receivedMacHdr.GetFrameVer () <= 1);
1124  }
1125 
1126  if (acceptFrame
1127  && (receivedMacHdr.GetDstAddrMode () > 1))
1128  {
1129  acceptFrame = receivedMacHdr.GetDstPanId () == m_macPanId
1130  || receivedMacHdr.GetDstPanId () == 0xffff;
1131  }
1132 
1133  if (acceptFrame
1134  && (receivedMacHdr.GetDstAddrMode () == SHORT_ADDR))
1135  {
1136  if (receivedMacHdr.GetShortDstAddr () == m_shortAddress)
1137  {
1138  // unicast, for me
1139  acceptFrame = true;
1140  }
1141  else if (receivedMacHdr.GetShortDstAddr ().IsBroadcast () || receivedMacHdr.GetShortDstAddr ().IsMulticast ())
1142  {
1143  // broadcast or multicast
1144  if (receivedMacHdr.IsAckReq ())
1145  {
1146  // discard broadcast/multicast with the ACK bit set
1147  acceptFrame = false;
1148  }
1149  else
1150  {
1151  acceptFrame = true;
1152  }
1153  }
1154  else
1155  {
1156  acceptFrame = false;
1157  }
1158  }
1159 
1160  if (acceptFrame
1161  && (receivedMacHdr.GetDstAddrMode () == EXT_ADDR))
1162  {
1163  acceptFrame = (receivedMacHdr.GetExtDstAddr () == m_selfExt);
1164  }
1165 
1166  if (acceptFrame
1167  && (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_BEACON))
1168  {
1169  if (m_macPanId == 0xffff)
1170  {
1171  // TODO: Accept only if the frame version field is valid
1172  acceptFrame = true;
1173  }
1174  else
1175  {
1176  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId;
1177  }
1178  }
1179 
1180  if (acceptFrame
1181  && ((receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_DATA)
1182  || (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_COMMAND))
1183  && (receivedMacHdr.GetSrcAddrMode () > 1))
1184  {
1185  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId; // TODO: need to check if PAN coord
1186  }
1187 
1188  if (acceptFrame)
1189  {
1190  m_macRxTrace (originalPkt);
1191  // \todo: What should we do if we receive a frame while waiting for an ACK?
1192  // Especially if this frame has the ACK request bit set, should we reply with an ACK, possibly missing the pending ACK?
1193 
1194  // If the received frame is a frame with the ACK request bit set, we immediately send back an ACK.
1195  // If we are currently waiting for a pending ACK, we assume the ACK was lost and trigger a retransmission after sending the ACK.
1196  if ((receivedMacHdr.IsData () || receivedMacHdr.IsCommand ()) && receivedMacHdr.IsAckReq ()
1197  && !(receivedMacHdr.GetDstAddrMode () == SHORT_ADDR && (receivedMacHdr.GetShortDstAddr ().IsBroadcast () || receivedMacHdr.GetShortDstAddr ().IsMulticast ())))
1198  {
1199  // If this is a data or mac command frame, which is not a broadcast or multicast,
1200  // with ack req set, generate and send an ack frame.
1201  // If there is a CSMA medium access in progress we cancel the medium access
1202  // for sending the ACK frame. A new transmission attempt will be started
1203  // after the ACK was send.
1205  {
1208  }
1209  else if (m_lrWpanMacState == MAC_CSMA)
1210  {
1211  // \todo: If we receive a packet while doing CSMA/CA, should we drop the packet because of channel busy,
1212  // or should we restart CSMA/CA for the packet after sending the ACK?
1213  // Currently we simply restart CSMA/CA after sending the ACK.
1214  m_csmaCa->Cancel ();
1215  }
1216  // Cancel any pending MAC state change, ACKs have higher priority.
1217  m_setMacState.Cancel ();
1219 
1220  m_setMacState = Simulator::ScheduleNow (&LrWpanMac::SendAck, this, receivedMacHdr.GetSeqNum ());
1221  }
1222 
1223 
1224  if (receivedMacHdr.GetDstAddrMode () == SHORT_ADDR)
1225  {
1226  NS_LOG_DEBUG ("Packet from " << params.m_srcAddr);
1227  NS_LOG_DEBUG ("Packet to " << params.m_dstAddr);
1228  }
1229  else if (receivedMacHdr.GetDstAddrMode () == EXT_ADDR)
1230  {
1231  NS_LOG_DEBUG ("Packet from " << params.m_srcExtAddr);
1232  NS_LOG_DEBUG ("Packet to " << params.m_dstExtAddr);
1233  }
1234 
1235 
1236  if (receivedMacHdr.IsBeacon ())
1237  {
1238 
1239 
1240  // The received beacon size in symbols
1241  // Beacon = 5 bytes Sync Header (SHR) + 1 byte PHY header (PHR) + PSDU (default 17 bytes)
1242  m_rxBeaconSymbols = m_phy->GetPhySHRDuration () + 1 * m_phy->GetPhySymbolsPerOctet () +
1243  (originalPkt->GetSize () * m_phy->GetPhySymbolsPerOctet ());
1244 
1245  // The start of Rx beacon time and start of the Incoming superframe Active Period
1246  m_macBeaconRxTime = Simulator::Now () - Seconds (double(m_rxBeaconSymbols) / symbolRate);
1247 
1248  NS_LOG_DEBUG ("Beacon Received; forwarding up (m_macBeaconRxTime: " << m_macBeaconRxTime.As (Time::S) << ")");
1249 
1250 
1251  //TODO: Handle mlme-scan.request here
1252 
1253  // Device not associated.
1254  if (m_macPanId == 0xffff)
1255  {
1256  //TODO: mlme-associate.request here.
1257  NS_LOG_ERROR (this << "The current device is not associated to any coordinator");
1258  return;
1259  }
1260 
1261 
1262  if (m_macPanId != receivedMacHdr.GetDstPanId ())
1263  {
1264  return;
1265  }
1266 
1267  BeaconPayloadHeader receivedMacPayload;
1268  p->RemoveHeader (receivedMacPayload);
1269 
1270  SuperframeField incomingSuperframe;
1271  incomingSuperframe = receivedMacPayload.GetSuperframeSpecField ();
1272 
1273  m_incomingBeaconOrder = incomingSuperframe.GetBeaconOrder ();
1274  m_incomingSuperframeOrder = incomingSuperframe.GetFrameOrder ();
1275  m_incomingFnlCapSlot = incomingSuperframe.GetFinalCapSlot ();
1276 
1279 
1280  if (incomingSuperframe.IsBattLifeExt ())
1281  {
1282  m_csmaCa->SetBatteryLifeExtension (true);
1283  }
1284  else
1285  {
1286  m_csmaCa->SetBatteryLifeExtension (false);
1287  }
1288 
1289  if (m_incomingBeaconOrder < 15 && !m_csmaCa->IsSlottedCsmaCa ())
1290  {
1291  m_csmaCa->SetSlottedCsmaCa ();
1292  }
1293 
1294  //TODO: get Incoming frame GTS Fields here
1295 
1296  NS_LOG_DEBUG ("Incoming superframe Active Portion (Beacon + CAP + CFP): " << m_incomingSuperframeDuration << " symbols");
1297 
1298  //Begin CAP on the current device using info from the Incoming superframe
1300 
1301 
1302  // Send a Beacon notification only if we are not
1303  // automatically sending data command requests or the beacon contains
1304  // a beacon payload in its MAC payload.
1305  // see IEEE 802.15.4-2011 Section 6.2.4.1
1306  if ((m_macAutoRequest == false) || p->GetSize () > 0)
1307  {
1308  //TODO: Add the rest of the MlmeBeaconNotifyIndication params
1310  {
1311  MlmeBeaconNotifyIndicationParams beaconParams;
1312  beaconParams.m_bsn = receivedMacHdr.GetSeqNum ();
1313  m_mlmeBeaconNotifyIndicationCallback (beaconParams,originalPkt);
1314  }
1315  }
1316 
1317  if (m_macAutoRequest)
1318  {
1319  // check if MLME-SYNC.request was previously issued and running
1320  // Sync. is necessary to handle pending messages (indirect transmissions)
1321  if (m_trackingEvent.IsRunning ())
1322  {
1324  m_numLostBeacons = 0;
1325 
1326  if (m_beaconTrackingOn)
1327  {
1328  //if tracking option is on keep tracking the next beacon
1329  uint64_t searchSymbols;
1330  Time searchBeaconTime;
1331 
1332  searchSymbols = ((uint64_t) 1 << m_incomingBeaconOrder) + 1 * aBaseSuperframeDuration;
1333  searchBeaconTime = Seconds ((double) searchSymbols / symbolRate);
1335  }
1336 
1337  PendingAddrFields pndAddrFields;
1338  pndAddrFields = receivedMacPayload.GetPndAddrFields ();
1339 
1340  //TODO: Ignore pending request if the address is in the GTS list.
1341  // If the address is not in the GTS list, then check if the address
1342  // is in the short address pending list or in the extended address
1343  // pending list.
1344 
1345  }
1346  }
1347  }
1348  else if (receivedMacHdr.IsData () && !m_mcpsDataIndicationCallback.IsNull ())
1349  {
1350  // If it is a data frame, push it up the stack.
1351  NS_LOG_DEBUG ("Data Packet is for me; forwarding up");
1352  m_mcpsDataIndicationCallback (params, p);
1353  }
1354  else if (receivedMacHdr.IsAcknowledgment () && m_txPkt && m_lrWpanMacState == MAC_ACK_PENDING)
1355  {
1356  LrWpanMacHeader macHdr;
1357  Time ifsWaitTime = Seconds ((double) GetIfsSize () / symbolRate);
1358  m_txPkt->PeekHeader (macHdr);
1359  if (receivedMacHdr.GetSeqNum () == macHdr.GetSeqNum ())
1360  {
1362  // If it is an ACK with the expected sequence number, finish the transmission
1363  // and notify the upper layer.
1366  {
1367  TxQueueElement *txQElement = m_txQueue.front ();
1368  McpsDataConfirmParams confirmParams;
1369  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
1370  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
1371  m_mcpsDataConfirmCallback (confirmParams);
1372  }
1374  m_setMacState.Cancel ();
1376  // Ack was succesfully received, wait for the Interframe Space (IFS) and then proceed
1377  m_ifsEvent = Simulator::Schedule (ifsWaitTime, &LrWpanMac::IfsWaitTimeout, this, ifsWaitTime);
1378  }
1379  else
1380  {
1381  // 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)
1383  if (!PrepareRetransmission ())
1384  {
1385  m_setMacState.Cancel ();
1387  }
1388  else
1389  {
1390  m_setMacState.Cancel ();
1392  }
1393  }
1394  }
1395  }
1396  else
1397  {
1398  m_macRxDropTrace (originalPkt);
1399  }
1400  }
1401  }
1402 }
1403 
1404 
1405 
1406 void
1407 LrWpanMac::SendAck (uint8_t seqno)
1408 {
1409  NS_LOG_FUNCTION (this << static_cast<uint32_t> (seqno));
1410 
1412 
1413  // Generate a corresponding ACK Frame.
1415  LrWpanMacTrailer macTrailer;
1416  Ptr<Packet> ackPacket = Create<Packet> (0);
1417  ackPacket->AddHeader (macHdr);
1418  // Calculate FCS if the global attribute ChecksumEnable is set.
1419  if (Node::ChecksumEnabled ())
1420  {
1421  macTrailer.EnableFcs (true);
1422  macTrailer.SetFcs (ackPacket);
1423  }
1424  ackPacket->AddTrailer (macTrailer);
1425 
1426  // Enqueue the ACK packet for further processing
1427  // when the transmitter is activated.
1428  m_txPkt = ackPacket;
1429 
1430  // Switch transceiver to TX mode. Proceed sending the Ack on confirm.
1432  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
1433 
1434 }
1435 
1436 void
1438 {
1439  TxQueueElement *txQElement = m_txQueue.front ();
1440  Ptr<const Packet> p = txQElement->txQPkt;
1441  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
1442 
1443  Ptr<Packet> pkt = p->Copy ();
1444  LrWpanMacHeader hdr;
1445  pkt->RemoveHeader (hdr);
1446  if (!hdr.GetShortDstAddr ().IsBroadcast () && !hdr.GetShortDstAddr ().IsMulticast ())
1447  {
1449  }
1450 
1451  txQElement->txQPkt = 0;
1452  delete txQElement;
1453  m_txQueue.pop_front ();
1454  m_txPkt = 0;
1455  m_retransmission = 0;
1456  m_numCsmacaRetry = 0;
1457  m_macTxDequeueTrace (p);
1458 }
1459 
1460 void
1462 {
1463  NS_LOG_FUNCTION (this);
1464 
1465  // TODO: If we are a PAN coordinator and this was an indirect transmission,
1466  // we will not initiate a retransmission. Instead we wait for the data
1467  // being extracted after a new data request command.
1468  if (!PrepareRetransmission ())
1469  {
1471  }
1472  else
1473  {
1475  }
1476 }
1477 
1478 void
1480 {
1481  uint64_t symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false);
1482  Time lifsTime = Seconds ((double) m_macLIFSPeriod / symbolRate);
1483  Time sifsTime = Seconds ((double) m_macSIFSPeriod / symbolRate);
1484 
1485  if (ifsTime == lifsTime)
1486  {
1487  NS_LOG_DEBUG ("LIFS of " << m_macLIFSPeriod << " symbols (" << ifsTime.As (Time::S) << ") completed ");
1488  }
1489  else if (ifsTime == sifsTime)
1490  {
1491  NS_LOG_DEBUG ("SIFS of " << m_macSIFSPeriod << " symbols (" << ifsTime.As (Time::S) << ") completed ");
1492  }
1493  else
1494  {
1495  NS_LOG_DEBUG ("Unknown IFS size (" << ifsTime.As (Time::S) << ") completed ");
1496  }
1497 
1498  m_macIfsEndTrace (ifsTime);
1499  CheckQueue ();
1500 }
1501 
1502 
1503 bool
1505 {
1506  NS_LOG_FUNCTION (this);
1507 
1509  {
1510  // Maximum number of retransmissions has been reached.
1511  // remove the copy of the packet that was just sent
1512  TxQueueElement *txQElement = m_txQueue.front ();
1513  m_macTxDropTrace (txQElement->txQPkt);
1515  {
1516  McpsDataConfirmParams confirmParams;
1517  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
1518  confirmParams.m_status = IEEE_802_15_4_NO_ACK;
1519  m_mcpsDataConfirmCallback (confirmParams);
1520  }
1522  return false;
1523  }
1524  else
1525  {
1526  m_retransmission++;
1527  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
1528  // Start next CCA process for this packet.
1529  return true;
1530  }
1531 }
1532 
1533 void
1535 {
1537  NS_LOG_FUNCTION (this << status << m_txQueue.size ());
1538 
1539  LrWpanMacHeader macHdr;
1540  Time ifsWaitTime;
1541  uint64_t symbolRate;
1542 
1543  symbolRate = (uint64_t) m_phy->GetDataOrSymbolRate (false); //symbols per second
1544 
1545  m_txPkt->PeekHeader (macHdr);
1546 
1547  if (status == IEEE_802_15_4_PHY_SUCCESS)
1548  {
1549  if (!macHdr.IsAcknowledgment ())
1550  {
1551  if (macHdr.IsBeacon ())
1552  {
1553  ifsWaitTime = Seconds ((double) GetIfsSize () / symbolRate);
1554 
1555  // The Tx Beacon in symbols
1556  // Beacon = 5 bytes Sync Header (SHR) + 1 byte PHY header (PHR) + PSDU (default 17 bytes)
1557  uint64_t beaconSymbols = m_phy->GetPhySHRDuration () + 1 * m_phy->GetPhySymbolsPerOctet () +
1558  (m_txPkt->GetSize () * m_phy->GetPhySymbolsPerOctet ());
1559 
1560  // The beacon Tx time and start of the Outgoing superframe Active Period
1561  m_macBeaconTxTime = Simulator::Now () - Seconds (double(beaconSymbols) / symbolRate);
1562 
1563 
1564  m_txPkt = 0;
1566  NS_LOG_DEBUG ("Beacon Sent (m_macBeaconTxTime: " << m_macBeaconTxTime.As (Time::S) << ")");
1567 
1568  MlmeStartConfirmParams mlmeConfirmParams;
1569  mlmeConfirmParams.m_status = MLMESTART_SUCCESS;
1571  {
1572  m_mlmeStartConfirmCallback (mlmeConfirmParams);
1573  }
1574  }
1575  else if (macHdr.IsAckReq ()) // We have sent a regular data packet, check if we have to wait for an ACK.
1576  {
1577  // wait for the ack or the next retransmission timeout
1578  // start retransmission timer
1579  Time waitTime = Seconds ((double) GetMacAckWaitDuration () / symbolRate);
1582  m_setMacState.Cancel ();
1584  return;
1585  }
1586  else
1587  {
1589  // remove the copy of the packet that was just sent
1591  {
1592  McpsDataConfirmParams confirmParams;
1593  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
1594  TxQueueElement *txQElement = m_txQueue.front ();
1595  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
1596  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
1597  m_mcpsDataConfirmCallback (confirmParams);
1598  }
1599  ifsWaitTime = Seconds ((double) GetIfsSize () / symbolRate);
1601  }
1602  }
1603  else
1604  {
1605  // We have send an ACK. Clear the packet buffer.
1606  m_txPkt = 0;
1607  }
1608  }
1609  else if (status == IEEE_802_15_4_PHY_UNSPECIFIED)
1610  {
1611 
1612  if (!macHdr.IsAcknowledgment ())
1613  {
1614  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
1615  TxQueueElement *txQElement = m_txQueue.front ();
1616  m_macTxDropTrace (txQElement->txQPkt);
1618  {
1619  McpsDataConfirmParams confirmParams;
1620  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
1621  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
1622  m_mcpsDataConfirmCallback (confirmParams);
1623  }
1625  }
1626  else
1627  {
1628  NS_LOG_ERROR ("Unable to send ACK");
1629  }
1630  }
1631  else
1632  {
1633  // Something went really wrong. The PHY is not in the correct state for
1634  // data transmission.
1635  NS_FATAL_ERROR ("Transmission attempt failed with PHY status " << status);
1636  }
1637 
1638 
1639  if (!ifsWaitTime.IsZero ())
1640  {
1641  m_ifsEvent = Simulator::Schedule (ifsWaitTime, &LrWpanMac::IfsWaitTimeout, this, ifsWaitTime);
1642  }
1643 
1644  m_setMacState.Cancel ();
1646 
1647 
1648 }
1649 
1650 void
1652 {
1653  NS_LOG_FUNCTION (this << status);
1654  // Direct this call through the csmaCa object
1655  m_csmaCa->PlmeCcaConfirm (status);
1656 }
1657 
1658 void
1659 LrWpanMac::PlmeEdConfirm (LrWpanPhyEnumeration status, uint8_t energyLevel)
1660 {
1661  NS_LOG_FUNCTION (this << status << energyLevel);
1662 
1663 }
1664 
1665 void
1668  LrWpanPhyPibAttributes* attribute)
1669 {
1670  NS_LOG_FUNCTION (this << status << id << attribute);
1671 }
1672 
1673 void
1675 {
1676  NS_LOG_FUNCTION (this << status);
1677 
1679  {
1680  NS_ASSERT (m_txPkt);
1681 
1682  // Start sending if we are in state SENDING and the PHY transmitter was enabled.
1686  m_phy->PdDataRequest (m_txPkt->GetSize (), m_txPkt);
1687  }
1688  else if (m_lrWpanMacState == MAC_CSMA && (status == IEEE_802_15_4_PHY_RX_ON || status == IEEE_802_15_4_PHY_SUCCESS))
1689  {
1690  // Start the CSMA algorithm as soon as the receiver is enabled.
1691  m_csmaCa->Start ();
1692  }
1693  else if (m_lrWpanMacState == MAC_IDLE)
1694  {
1696 
1697  if (status == IEEE_802_15_4_PHY_RX_ON || status == IEEE_802_15_4_PHY_SUCCESS)
1698  {
1699  // Check if there is not messages to transmit when going idle
1700  CheckQueue ();
1701  }
1702 
1703  }
1704  else if (m_lrWpanMacState == MAC_ACK_PENDING)
1705  {
1707  }
1708  else
1709  {
1710  // TODO: What to do when we receive an error?
1711  // If we want to transmit a packet, but switching the transceiver on results
1712  // in an error, we have to recover somehow (and start sending again).
1713  NS_FATAL_ERROR ("Error changing transceiver state");
1714  }
1715 }
1716 
1717 void
1720 {
1721  NS_LOG_FUNCTION (this << status << id);
1722 }
1723 
1724 void
1726 {
1727  NS_LOG_FUNCTION (this << "mac state = " << macState);
1728 
1729  McpsDataConfirmParams confirmParams;
1730 
1731  if (macState == MAC_IDLE)
1732  {
1734 
1735  if (m_macRxOnWhenIdle)
1736  {
1737  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
1738  }
1739  else
1740  {
1741  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
1742  }
1743 
1744 
1745  }
1746  else if (macState == MAC_ACK_PENDING)
1747  {
1749  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
1750  }
1751  else if (macState == MAC_CSMA)
1752  {
1754 
1756  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
1757  }
1758  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_IDLE)
1759  {
1760  // Channel is idle, set transmitter to TX_ON
1762  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
1763  }
1764  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_ACCESS_FAILURE)
1765  {
1766  NS_ASSERT (m_txPkt);
1767 
1768  // cannot find a clear channel, drop the current packet.
1769  NS_LOG_DEBUG ( this << " cannot find clear channel");
1770  confirmParams.m_msduHandle = m_txQueue.front ()->txQMsduHandle;
1774  {
1775  m_mcpsDataConfirmCallback (confirmParams);
1776  }
1777  // remove the copy of the packet that was just sent
1780  }
1781  else if (m_lrWpanMacState == MAC_CSMA && macState == MAC_CSMA_DEFERRED)
1782  {
1784  m_txPkt = 0;
1785  NS_LOG_DEBUG ("****** PACKET DEFERRED to the next superframe *****");
1786  }
1787 }
1788 
1791 {
1792  return m_associationStatus;
1793 }
1794 
1795 void
1797 {
1798  m_associationStatus = status;
1799 }
1800 
1801 uint16_t
1803 {
1804  return m_macPanId;
1805 }
1806 
1807 void
1808 LrWpanMac::SetPanId (uint16_t panId)
1809 {
1810  m_macPanId = panId;
1811 }
1812 
1813 void
1815 {
1816  NS_LOG_LOGIC (this << " change lrwpan mac state from "
1817  << m_lrWpanMacState << " to "
1818  << newState);
1819  m_macStateLogger (m_lrWpanMacState, newState);
1820  m_lrWpanMacState = newState;
1821 }
1822 
1823 uint64_t
1825 {
1826  return m_csmaCa->GetUnitBackoffPeriod () + m_phy->aTurnaroundTime + m_phy->GetPhySHRDuration ()
1827  + ceil (6 * m_phy->GetPhySymbolsPerOctet ());
1828 }
1829 
1830 uint8_t
1832 {
1833  return m_macMaxFrameRetries;
1834 }
1835 
1836 void
1838 {
1839  NS_LOG_DEBUG ("Transmit Queue Size: " << m_txQueue.size ());
1840 }
1841 
1842 void
1844 {
1845  m_macMaxFrameRetries = retries;
1846 }
1847 
1848 bool
1850 {
1851  NS_ASSERT (m_txPkt);
1852  LrWpanMacHeader macHdr;
1853  m_txPkt->PeekHeader (macHdr);
1854 
1855  if (m_macCoordShortAddress == macHdr.GetShortDstAddr ()
1856  || m_macCoordExtendedAddress == macHdr.GetExtDstAddr ())
1857  {
1858  return true;
1859  }
1860  else
1861  {
1862  std::cout << "ERROR: Packet not for the coordinator!\n";
1863  return false;
1864 
1865  }
1866 
1867 }
1868 
1869 uint32_t
1871 {
1872  NS_ASSERT (m_txPkt);
1873 
1874  if (m_txPkt->GetSize () <= aMaxSIFSFrameSize)
1875  {
1876  return m_macSIFSPeriod;
1877  }
1878  else
1879  {
1880  return m_macLIFSPeriod;
1881  }
1882 }
1883 
1884 void
1886 {
1888 }
1889 
1890 void
1892 {
1894 }
1895 
1896 
1897 uint64_t
1899 {
1900  NS_ASSERT (m_txPkt);
1901  // Sync Header (SHR) + 8 bits PHY header (PHR) + PSDU
1902  return (m_phy->GetPhySHRDuration () + 1 * m_phy->GetPhySymbolsPerOctet () +
1903  (m_txPkt->GetSize () * m_phy->GetPhySymbolsPerOctet ()));
1904 }
1905 
1906 bool
1908 {
1909  NS_ASSERT (m_txPkt);
1910  LrWpanMacHeader macHdr;
1911  m_txPkt->PeekHeader (macHdr);
1912 
1913  return macHdr.IsAckReq ();
1914 }
1915 
1916 } // namespace ns3
1917 
void SetBeaconOrder(uint8_t bcnOrder)
Set the superframe specification Beacon Order field.
MlmeSyncLossIndicationCallback m_mlmeSyncLossIndicationCallback
This callback is used to indicate the loss of synchronization with a coordinator. ...
Definition: lr-wpan-mac.h:1231
TracedValue< LrWpanMacState > m_lrWpanMacState
The current state of the MAC layer.
Definition: lr-wpan-mac.h:1258
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
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:652
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:557
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:429
uint16_t m_dstPanId
Destination PAN identifier.
Definition: lr-wpan-mac.h:248
TX_OPTION_INDIRECT.
Definition: lr-wpan-mac.h:61
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
bool IsBroadcast(void) const
Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void CheckQueue(void)
Check the transmission queue.
Definition: lr-wpan-mac.cc:898
LrWpanSyncLossReason m_lossReason
The reason for the lost of synchronization.
Definition: lr-wpan-mac.h:376
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t GetSeqNum(void) const
Get the frame Sequence number.
static const 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:492
bool m_beaconTrackingOn
Indication of whether the current device is tracking incoming beacons.
Definition: lr-wpan-mac.h:894
static const 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:486
bool m_trackBcn
True if the mlme sync with the next beacon and attempts to track future beacons.
Definition: lr-wpan-mac.h:323
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
Class that implements the LR-WPAN MAC state machine.
Definition: lr-wpan-mac.h:448
Mac16Address GetShortDstAddr(void) const
Get the Destination Short address.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint8_t GetFinalCapSlot(void) const
Check if the Final CAP Slot bit is enabled.
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...
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
Mac16Address GetShortSrcAddr(void) const
Get the Source Short address.
uint8_t GetBeaconOrder(void) const
Get the Superframe Specification Beacon Order field.
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:249
void RemoveFirstTxQElement()
Remove the tip of the transmission queue, including clean up related to the last packet transmission...
Mac64Address m_srcExtAddr
Source extended address.
Definition: lr-wpan-mac.h:275
virtual ~LrWpanMac(void)
Definition: lr-wpan-mac.cc:197
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:1134
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:140
uint32_t phyCurrentPage
Current channel page.
Definition: lr-wpan-phy.h:163
PendingAddrFields GetPndAddrFields(void) const
static bool ChecksumEnabled(void)
Definition: node.cc:278
CHANNEL_IDLE.
Definition: lr-wpan-mac.h:76
bool IsData(void) const
Returns true if the header is a data.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:380
bool isCoordDest(void)
Check if the packet destination is its coordinator.
McpsDataConfirmCallback m_mcpsDataConfirmCallback
This callback is used to report data transmission request status to the upper layers.
Definition: lr-wpan-mac.h:1254
std::deque< TxQueueElement * > m_txQueue
The transmit queue used by the MAC.
Definition: lr-wpan-mac.h:1289
MAC_CSMA_DEFERRED.
Definition: lr-wpan-mac.h:80
Mac64Address GetExtendedAddress(void) const
Get the extended address of this MAC.
Definition: lr-wpan-mac.cc:287
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:278
uint8_t m_dstAddrMode
Destination address mode.
Definition: lr-wpan-mac.h:276
#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
Mac64Address m_dstExtAddr
Destination extended address.
Definition: lr-wpan-mac.h:279
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
SequenceNumber< uint8_t, int8_t > SequenceNumber8
8 bit Sequence number.
uint8_t m_logCh
The channel number on which to attempt coordinator synchronization.
Definition: lr-wpan-mac.h:322
void SetMlmeBeaconNotifyIndicationCallback(MlmeBeaconNotifyIndicationCallback c)
Set the callback for the indication of an incoming beacon packet.
static const uint32_t aNumSuperframeSlots
Number of a superframe slots per superframe.
Definition: lr-wpan-mac.h:473
void SetMlmeStartConfirmCallback(MlmeStartConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
Definition: lr-wpan-mac.cc:995
bool IsBattLifeExt(void) const
Check if the Battery Life Extension bit is enabled.
bool m_battLifeExt
Flag indicating whether or not the Battery life extension (BLE) features are used.
Definition: lr-wpan-mac.h:308
LrWpanAssociationStatus m_associationStatus
The current association status of the MAC layer.
Definition: lr-wpan-mac.h:1270
uint8_t m_incomingFnlCapSlot
Indication of the Slot where the CAP portion of the INCOMING Superframe ends.
Definition: lr-wpan-mac.h:807
Mac64Address m_dstExtAddr
Destination extended address.
Definition: lr-wpan-mac.h:250
Mac64Address m_macCoordExtendedAddress
The extended address of the coordinator through which the device is associated.
Definition: lr-wpan-mac.h:756
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
virtual void DoDispose(void)
Destructor implementation.
Definition: lr-wpan-mac.cc:216
TracedCallback< LrWpanMacState, LrWpanMacState > m_macStateLogger
A trace source that fires when the LrWpanMac changes states.
Definition: lr-wpan-mac.h:1213
void SetShortAddress(Mac16Address address)
Set the short address of this MAC.
Definition: lr-wpan-mac.cc:265
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
uint8_t m_incomingBeaconOrder
The beaconOrder value of the INCOMING frame.
Definition: lr-wpan-mac.h:796
Represent the Mac Header with the Frame Control and Sequence Number fields.
bool IsCommand(void) const
Returns true if the header is a command.
uint8_t m_incomingSuperframeOrder
Used by all devices that have a parent.
Definition: lr-wpan-mac.h:803
uint16_t GetDstPanId(void) const
Get the Destination PAN ID.
uint32_t m_superframeDuration
Indication of the superframe duration in symbols.
Definition: lr-wpan-mac.h:876
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:157
McpsDataIndicationCallback m_mcpsDataIndicationCallback
This callback is used to notify incoming packets to the upper layers.
Definition: lr-wpan-mac.h:1248
void SetMcpsDataConfirmCallback(McpsDataConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
Definition: lr-wpan-mac.cc:989
void AwaitBeacon(void)
Called after the end of an INCOMING superframe to start the moment a device waits for a new incoming ...
Definition: lr-wpan-mac.cc:854
Incoming Superframe.
Definition: lr-wpan-mac.h:104
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:1243
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_numCsmacaRetry
The number of CSMA/CA retries used for sending the current packet.
Definition: lr-wpan-mac.h:1302
MLME-START.request params.
Definition: lr-wpan-mac.h:288
void IfsWaitTimeout(Time ifsTime)
After a successful transmission of a frame (beacon, data) or an ack frame reception, the mac layer wait an Interframe Space (IFS) time and triggers this function to continue with the MAC flow.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:251
uint32_t m_incomingBeaconInterval
Indication of the interval a node should receive a superframe expressed in symbols.
Definition: lr-wpan-mac.h:881
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:262
uint8_t GetFrameVer(void) const
Get the Frame Version of Frame control field.
EventId m_incCapEvent
Scheduler event for the end of the incoming superframe CAP.
Definition: lr-wpan-mac.h:1331
static const uint32_t aMaxPhyPacketSize
The maximum packet size accepted by the PHY.
Definition: lr-wpan-phy.h:262
void SetSuperframeSpecField(SuperframeField sfrmField)
Set the superframe specification field to the beacon payload header.
uint16_t m_dstPanId
Destination PAN identifier.
Definition: lr-wpan-mac.h:277
Contention Free Period.
Definition: lr-wpan-mac.h:92
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets are being sent down to L1.
Definition: lr-wpan-mac.h:1126
an EUI-64 address
Definition: mac64-address.h:43
phy
Definition: third.py:93
Ptr< Packet > m_txPkt
The packet which is currently being sent by the MAC layer.
Definition: lr-wpan-mac.h:1274
bool GetRxOnWhenIdle(void)
Check if the receiver will be enabled when the MAC is idle.
Definition: lr-wpan-mac.cc:240
The Beacon transmission or reception Period.
Definition: lr-wpan-mac.h:90
MLME-BEACON-NOTIFY.indication params.
Definition: lr-wpan-mac.h:359
LrWpanAssociationStatus GetAssociationStatus(void) const
Get the current association status.
void SetLrWpanMacState(LrWpanMacState macState)
CSMA-CA algorithm calls back the MAC after executing channel assessment.
void SetMacMaxFrameRetries(uint8_t retries)
Set the macMaxFrameRetries attribute value.
void PlmeEdConfirm(LrWpanPhyEnumeration status, uint8_t energyLevel)
IEEE 802.15.4-2006 section 6.2.2.4 PLME-ED.confirm status and energy level.
uint8_t m_macBeaconOrder
Used by a PAN coordinator or coordinator.
Definition: lr-wpan-mac.h:768
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:1204
TX_OPTION_ACK.
Definition: lr-wpan-mac.h:59
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:1113
uint8_t m_fnlCapSlot
Indication of the Slot where the CAP portion of the OUTGOING Superframe ends.
Definition: lr-wpan-mac.h:790
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:1157
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:516
bool m_panCoor
Indication of whether the current device is the PAN coordinator.
Definition: lr-wpan-mac.h:866
void SetSuperframeOrder(uint8_t frmOrder)
Set the superframe specification Superframe Order field.
uint64_t GetTxPacketSymbols(void)
Obtain the number of symbols in the packet which is currently being sent by the MAC layer...
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
Definition: lr-wpan-mac.h:306
bool isTxAckReq(void)
Check if the packet to transmit requires acknowledgment.
bool IsZero(void) const
Exactly equivalent to t == 0.
Definition: nstime.h:301
MlmeBeaconNotifyIndicationCallback m_mlmeBeaconNotifyIndicationCallback
This callback is used to notify incoming beacon packets to the upper layers.
Definition: lr-wpan-mac.h:1226
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:588
SuperframeType
Superframe type.
Definition: lr-wpan-mac.h:101
Ptr< Packet > txQPkt
Queued packet.
Definition: lr-wpan-mac.h:989
uint8_t GetDstAddrMode(void) const
Get the Dest.
uint8_t m_logCh
Logical channel on which to start using the new superframe configuration.
Definition: lr-wpan-mac.h:302
bool PrepareRetransmission(void)
Check for remaining retransmissions for the packet currently being sent.
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
Hold an unsigned integer type.
Definition: uinteger.h:44
EventId m_ackWaitTimeout
Scheduler event for the ACK timeout of the currently transmitted data packet.
Definition: lr-wpan-mac.h:1307
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:1141
EventId m_ifsEvent
Scheduler event for Interframe spacing wait time.
Definition: lr-wpan-mac.h:1315
uint16_t GetPanId(void) const
Get the PAN id used by this MAC.
void SetMlmeSyncLossIndicationCallback(MlmeSyncLossIndicationCallback c)
Set the callback for the loss of synchronization with a coordinator.
mac
Definition: third.py:99
EventId m_setMacState
Scheduler event for a deferred MAC state change.
Definition: lr-wpan-mac.h:1311
SuperframeField GetSuperframeField(void)
Constructs a Superframe specification field from the local information, the superframe Specification ...
Definition: lr-wpan-mac.cc:920
PendingAddrFields GetPendingAddrFields(void)
Constructs Pending Address Fields from the local information, the Pending Address Fields are part of ...
Definition: lr-wpan-mac.cc:955
Helper structure for managing transmission queue elements.
Definition: lr-wpan-mac.h:986
bool m_macRxOnWhenIdle
Indication of whether the MAC sublayer is to enable its receiver during idle periods.
Definition: lr-wpan-mac.h:840
Outgoing Superframe.
Definition: lr-wpan-mac.h:103
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
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:612
enum LrWpanMacType GetType(void) const
Get the header type.
MCPS-DATA.confirm params.
Definition: lr-wpan-mac.h:260
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_txOptions
Tx Options (bitfield)
Definition: lr-wpan-mac.h:252
Ptr< Packet > txQPkt
Queued packet.
Definition: lr-wpan-mac.h:998
void StartInactivePeriod(SuperframeType superframeType)
Start the Inactive Period in a beacon-enabled mode.
Definition: lr-wpan-mac.cc:817
void PrintTransmitQueueSize(void)
Print the number of elements in the packet transmit queue.
uint32_t GetIfsSize()
Get the size of the Interframe Space according to MPDU size (m_txPkt).
void SendOneBeacon(void)
Called to send a single beacon frame.
Definition: lr-wpan-mac.cc:666
uint32_t m_macLIFSPeriod
The minimum time forming a Long InterFrame Spacing (LIFS) period.
Definition: lr-wpan-mac.h:845
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:305
uint8_t m_mpduLinkQuality
LQI value measured during reception of the MPDU.
Definition: lr-wpan-mac.h:280
void SetPhy(Ptr< LrWpanPhy > phy)
Set the underlying PHY for the MAC.
Definition: lr-wpan-mac.cc:971
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
GtsFields GetGtsFields(void)
Constructs the Guaranteed Time Slots (GTS) Fields from local information The GTS Fields are part of t...
Definition: lr-wpan-mac.cc:945
Helper structure for managing indirect transmission queue elements.
Definition: lr-wpan-mac.h:995
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
bool IsAcknowledgment(void) const
Returns true if the header is an ack.
void SetAssociatedCoor(Mac16Address mac)
Check if the packet destination is its coordinator.
SuperframeField GetSuperframeSpecField(void) const
Get the superframe specification field from the beacon payload header.
Implements the header for the MAC payload beacon frame according to the IEEE 802.15.4-2011 Std.
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:1106
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...
uint8_t m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:272
Mac64Address GetExtSrcAddr(void) const
Get the Source Extended address.
uint16_t m_PanId
Pan Identifier used by the device.
Definition: lr-wpan-mac.h:301
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
Definition: lr-wpan-mac.h:263
LrWpanAddressMode m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:246
uint8_t m_retransmission
The number of already used retransmission for the currently transmitted packet.
Definition: lr-wpan-mac.h:1298
EventId m_trackingEvent
Scheduler event to track the incoming beacons.
Definition: lr-wpan-mac.h:1339
static const uint32_t aBaseSlotDuration
Length of a superframe slot in symbols.
Definition: lr-wpan-mac.h:468
Mac64Address m_selfExt
The extended address used by this MAC.
Definition: lr-wpan-mac.h:1285
uint64_t GetMacAckWaitDuration(void) const
Get the macAckWaitDuration attribute value.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
EventId m_cfpEvent
Scheduler event for the end of the outgoing superframe CFP.
Definition: lr-wpan-mac.h:1327
uint8_t GetSrcAddrMode(void) const
Get the Source Addressing Mode of Frame control field.
address
Definition: first.py:44
LrWpanAddressMode m_dstAddrMode
Destination address mode.
Definition: lr-wpan-mac.h:247
bool IsAckReq(void) const
Check if Ack.
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
Definition: packet.cc:307
uint16_t m_macTransactionPersistanceTime
The maximum time (in superframe periods) that a transaction is stored by a coordinator and indicated ...
Definition: lr-wpan-mac.h:781
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
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:1165
void StartCAP(SuperframeType superframeType)
Called to begin the Contention Access Period (CAP) in a beacon-enabled mode.
Definition: lr-wpan-mac.cc:724
uint8_t GetFrameOrder(void) const
Get the Superframe Specification Frame Order field.
TX_OPTION_GTS.
Definition: lr-wpan-mac.h:60
void SetRxOnWhenIdle(bool rxOnWhenIdle)
Set if the receiver should be enabled when the MAC is idle.
Definition: lr-wpan-mac.cc:246
uint32_t RemoveTrailer(Trailer &trailer)
Remove a deserialized trailer from the internal buffer.
Definition: packet.cc:318
uint32_t m_beaconInterval
Indication of the Interval used by the coordinator to transmit beacon frames expressed in symbols...
Definition: lr-wpan-mac.h:871
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:1149
bool m_macPromiscuousMode
Indicates if MAC sublayer is in receive all mode.
Definition: lr-wpan-mac.h:813
Mac16Address m_srcAddr
Source address.
Definition: lr-wpan-mac.h:274
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:1237
SequenceNumber8 m_macBsn
Sequence number added to transmitted beacon frame, 00-ff.
Definition: lr-wpan-mac.h:829
This class can contain 16 bit addresses.
Definition: mac16-address.h:41
Represent the Superframe Specification information field.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
uint8_t m_macSuperframeOrder
Used by a PAN coordinator or coordinator.
Definition: lr-wpan-mac.h:775
EventId m_capEvent
Scheduler event for the end of the outgoing superframe CAP.
Definition: lr-wpan-mac.h:1323
uint8_t m_dsn
The DSN of the received data frame.
Definition: lr-wpan-mac.h:281
std::deque< IndTxQueueElement * > m_indTxQueue
The indirect transmit queue used by the MAC pending messages.
Definition: lr-wpan-mac.h:1293
Mac16Address m_macCoordShortAddress
The short address of the coordinator through which the device is associated.
Definition: lr-wpan-mac.h:750
LrWpanMac(void)
Default constructor.
Definition: lr-wpan-mac.cc:152
uint8_t m_bsn
The beacon sequence number.
Definition: lr-wpan-mac.h:361
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:1184
void SetExtendedAddress(Mac64Address address)
Set the extended address of this MAC.
Definition: lr-wpan-mac.cc:272
uint8_t m_macMaxFrameRetries
The maximum number of retries allowed after a transmission failure.
Definition: lr-wpan-mac.h:834
uint16_t m_panId
The PAN identifier with which the device lost synchronization or to which it was realigned.
Definition: lr-wpan-mac.h:377
uint8_t txQMsduHandle
MSDU Handle.
Definition: lr-wpan-mac.h:988
uint16_t GetSrcPanId(void) const
Get the Source PAN ID.
bool IsMulticast(void) const
Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e., if its first 3 bits are 100).
Contention Access Period.
Definition: lr-wpan-mac.h:91
static TypeId GetTypeId(void)
Get the type ID.
Definition: lr-wpan-mac.cc:58
uint32_t m_logChPage
Logical channel page on which to start using the new superframe configuration.
Definition: lr-wpan-mac.h:303
uint32_t m_incomingSuperframeDuration
Indication of the superframe duration in symbols (e.g.
Definition: lr-wpan-mac.h:886
#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
Represent the Mac Trailer with the Frame Check Sequence field.
Ptr< LrWpanPhy > m_phy
The PHY associated with this MAC.
Definition: lr-wpan-mac.h:1217
void SetGtsFields(GtsFields gtsFields)
Set the superframe Guaranteed Time Slot (GTS) fields to the beacon payload header.
EventId m_beaconEvent
Scheduler event for generation of one beacon.
Definition: lr-wpan-mac.h:1319
bool IsBeacon(void) const
Returns true if the header is a beacon.
MLME-POLL.request params.
Definition: lr-wpan-mac.h:330
void SetFinalCapSlot(uint8_t capSlot)
Set the superframe specification Final CAP slot field.
CHANNEL_ACCESS_FAILURE.
Definition: lr-wpan-mac.h:75
uint32_t m_ifs
The value of the necessary InterFrame Space after the transmission of a packet.
Definition: lr-wpan-mac.h:862
MLME-SYNC.request params.
Definition: lr-wpan-mac.h:316
Time expireTime
The expiration time of the packet in the indirect transmission queue.
Definition: lr-wpan-mac.h:999
MAC_CSMA.
Definition: lr-wpan-mac.h:72
Time m_macBeaconRxTime
The time that the device received its last bit of the beacon frame.
Definition: lr-wpan-mac.h:742
Implements the header for the MAC payload command frame according to the IEEE 802.15.4-2011 Std.
SequenceNumber8 m_macDsn
Sequence number added to transmitted data or MAC command frame, 00-ff.
Definition: lr-wpan-mac.h:824
void SetBattLifeExt(bool battLifeExt)
Set the Superframe Specification Battery Life Extension (BLE).
MAC_ACK_PENDING.
Definition: lr-wpan-mac.h:74
uint64_t m_rxBeaconSymbols
The total size of the received beacon in symbols.
Definition: lr-wpan-mac.h:786
static const uint32_t aMinMPDUOverhead
The minimum number of octets added by the MAC sublayer to the PSDU.
Definition: lr-wpan-mac.h:462
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:858
uint32_t m_macSIFSPeriod
The minimum time forming a Short InterFrame Spacing (SIFS) period.
Definition: lr-wpan-mac.h:850
void ChangeMacState(LrWpanMacState newState)
Change the current MAC state to the given new state.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
MLME-SYNC-LOSS.indication params.
Definition: lr-wpan-mac.h:374
Time m_macBeaconTxTime
The time that the device transmitted its last beacon frame.
Definition: lr-wpan-mac.h:735
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
uint8_t m_numLostBeacons
The number of consecutive loss beacons in a beacon tracking operation.
Definition: lr-wpan-mac.h:898
TracedCallback< Time > m_macIfsEndTrace
The trace source is fired at the end of any Interframe Space (IFS).
Definition: lr-wpan-mac.h:1095
Ptr< LrWpanCsmaCa > m_csmaCa
The CSMA/CA implementation used by this MAC.
Definition: lr-wpan-mac.h:1221
LrWpanMacState
MAC states.
Definition: lr-wpan-mac.h:69
LrWpanAssociationStatus
table 83 of 802.15.4
Definition: lr-wpan-mac.h:150
void SetPndAddrFields(PendingAddrFields pndAddrFields)
Set the superframe Pending Address fields to the beacon payload header.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
uint8_t GetMacMaxFrameRetries(void) const
Get the macMaxFrameRetries attribute value.
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:1120
uint8_t m_deviceCapability
Indication of current device capability (FFD or RFD)
Definition: lr-wpan-mac.h:890
uint8_t phyCurrentChannel
The RF channel to use.
Definition: lr-wpan-phy.h:159
uint16_t m_macPanId
16 bits id of PAN on which this device is operating.
Definition: lr-wpan-mac.h:819
TracedValue< SuperframeStatus > m_incSuperframeStatus
The current period of the incoming superframe.
Definition: lr-wpan-mac.h:1262
void StartCFP(SuperframeType superframeType)
Called to begin the Contention Free Period (CFP) in a beacon-enabled mode.
Definition: lr-wpan-mac.cc:771
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
bool m_panCoor
On true this device will become coordinator.
Definition: lr-wpan-mac.h:307
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:257
void PlmeSetTRXStateConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.8 PLME-SET-TRX-STATE.confirm Set PHY state.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:105
second
Definition: nstime.h:115
Full Functional Device (FFD)
void SetPanCoor(bool panCoor)
Set the Superframe Specification PAN coordinator field.
void SendAck(uint8_t seqno)
Send an acknowledgment packet for the given sequence number.
MCPS-DATA.request params.
Definition: lr-wpan-mac.h:236
bool CheckFcs(Ptr< const Packet > p)
Check the FCS of a given packet against the FCS value stored in the trailer.
A base class which provides memory management and object aggregation.
Definition: object.h:87
LrWpanMlmeStartConfirmStatus m_status
The status of a MLME-start.request.
Definition: lr-wpan-mac.h:352
void AckWaitTimeout(void)
Handle an ACK timeout with a packet retransmission, if there are retransmission left, or a packet drop.
bool m_coorRealgn
True if a realignment request command is to be transmitted prior changing the superframe.
Definition: lr-wpan-mac.h:309
Represent the Pending Address Specification field.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
Represent the GTS information fields.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
Ptr< LrWpanPhy > GetPhy(void)
Get the underlying PHY of the MAC.
Definition: lr-wpan-mac.cc:977
Mac16Address m_shortAddress
The short address used by this MAC.
Definition: lr-wpan-mac.h:1280
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
Mac16Address GetShortAddress(void) const
Get the short address of this MAC.
Definition: lr-wpan-mac.cc:280
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaCa)
Set the CSMA/CA implementation to be used by the MAC.
Definition: lr-wpan-mac.cc:965
void SetPanId(uint16_t panId)
Set the PAN id used by this MAC.
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...
Inactive Period or unslotted CSMA-CA.
Definition: lr-wpan-mac.h:93
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lr-wpan-mac.cc:201
static Mac64Address Allocate(void)
Allocate a new Mac64Address.
uint8_t txQMsduHandle
MSDU Handle.
Definition: lr-wpan-mac.h:997
static const uint32_t aBaseSuperframeDuration
Length of a superframe in symbols.
Definition: lr-wpan-mac.h:479
TracedValue< SuperframeStatus > m_outSuperframeStatus
The current period of the outgoing superframe.
Definition: lr-wpan-mac.h:1266
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
MAC_SENDING.
Definition: lr-wpan-mac.h:73
MLME-START.confirm params.
Definition: lr-wpan-mac.h:350
uint16_t m_srcPanId
Source PAN identifier.
Definition: lr-wpan-mac.h:273
MAC_IDLE.
Definition: lr-wpan-mac.h:71
void BeaconSearchTimeout(void)
Called if the device is unable to locate a beacon in the time set by MLME-SYNC.request.
Definition: lr-wpan-mac.cc:867
void SetMlmePollConfirmCallback(MlmePollConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
void SetAssociationStatus(LrWpanAssociationStatus status)
Set the current association status.
MCPS-DATA.indication params.
Definition: lr-wpan-mac.h:270
Mac64Address GetExtDstAddr(void) const
Get the Destination Extended address.
EventId m_incCfpEvent
Scheduler event for the end of the incoming superframe CFP.
Definition: lr-wpan-mac.h:1335
void SetMcpsDataIndicationCallback(McpsDataIndicationCallback c)
Set the callback for the indication of an incoming data packet.
Definition: lr-wpan-mac.cc:983