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  */
25 #include "lr-wpan-mac.h"
26 #include "lr-wpan-csmaca.h"
27 #include "lr-wpan-mac-header.h"
28 #include "lr-wpan-mac-trailer.h"
29 #include <ns3/simulator.h>
30 #include <ns3/log.h>
31 #include <ns3/uinteger.h>
32 #include <ns3/node.h>
33 #include <ns3/packet.h>
34 #include <ns3/random-variable-stream.h>
35 #include <ns3/double.h>
36 
37 #undef NS_LOG_APPEND_CONTEXT
38 #define NS_LOG_APPEND_CONTEXT \
39  std::clog << "[address " << m_shortAddress << "] ";
40 
41 namespace ns3 {
42 
43 NS_LOG_COMPONENT_DEFINE ("LrWpanMac");
44 
45 NS_OBJECT_ENSURE_REGISTERED (LrWpanMac);
46 
47 const uint32_t LrWpanMac::aMinMPDUOverhead = 9; // Table 85
48 
49 TypeId
51 {
52  static TypeId tid = TypeId ("ns3::LrWpanMac")
53  .SetParent<Object> ()
54  .AddConstructor<LrWpanMac> ()
55  .AddAttribute ("PanId", "16-bit identifier of the associated PAN",
56  UintegerValue (),
58  MakeUintegerChecker<uint16_t> ())
59  .AddTraceSource ("MacTxEnqueue",
60  "Trace source indicating a packet has been "
61  "enqueued in the transaction queue",
63  "ns3::Packet::TracedCallback")
64  .AddTraceSource ("MacTxDequeue",
65  "Trace source indicating a packet has was "
66  "dequeued from the transaction queue",
68  "ns3::Packet::TracedCallback")
69  .AddTraceSource ("MacTx",
70  "Trace source indicating a packet has "
71  "arrived for transmission by this device",
73  "ns3::Packet::TracedCallback")
74  .AddTraceSource ("MacTxOk",
75  "Trace source indicating a packet has been "
76  "successfully sent",
78  "ns3::Packet::TracedCallback")
79  .AddTraceSource ("MacTxDrop",
80  "Trace source indicating a packet has been "
81  "dropped during transmission",
83  "ns3::Packet::TracedCallback")
84  .AddTraceSource ("MacPromiscRx",
85  "A packet has been received by this device, "
86  "has been passed up from the physical layer "
87  "and is being forwarded up the local protocol stack. "
88  "This is a promiscuous trace,",
90  "ns3::Packet::TracedCallback")
91  .AddTraceSource ("MacRx",
92  "A packet has been received by this device, "
93  "has been passed up from the physical layer "
94  "and is being forwarded up the local protocol stack. "
95  "This is a non-promiscuous trace,",
97  "ns3::Packet::TracedCallback")
98  .AddTraceSource ("MacRxDrop",
99  "Trace source indicating a packet was received, "
100  "but dropped before being forwarded up the stack",
102  "ns3::Packet::TracedCallback")
103  .AddTraceSource ("Sniffer",
104  "Trace source simulating a non-promiscuous "
105  "packet sniffer attached to the device",
107  "ns3::Packet::TracedCallback")
108  .AddTraceSource ("PromiscSniffer",
109  "Trace source simulating a promiscuous "
110  "packet sniffer attached to the device",
112  "ns3::Packet::TracedCallback")
113  .AddTraceSource ("MacState",
114  "The state of LrWpan Mac",
116  "ns3::LrWpanMac::StateTracedCallback")
117  .AddTraceSource ("MacSentPkt",
118  "Trace source reporting some information about "
119  "the sent packet",
121  "ns3::LrWpanMac::SentTracedCallback")
122  ;
123  return tid;
124 }
125 
127 {
128 
129  // First set the state to a known value, call ChangeMacState to fire trace source.
132 
133  m_macRxOnWhenIdle = true;
134  m_macPanId = 0;
137  m_macPromiscuousMode = false;
139  m_retransmission = 0;
140  m_numCsmacaRetry = 0;
141  m_txPkt = 0;
142 
143  Ptr<UniformRandomVariable> uniformVar = CreateObject<UniformRandomVariable> ();
144  uniformVar->SetAttribute ("Min", DoubleValue (0.0));
145  uniformVar->SetAttribute ("Max", DoubleValue (255.0));
146  m_macDsn = SequenceNumber8 (uniformVar->GetValue ());
147  m_shortAddress = Mac16Address ("00:00");
148 }
149 
151 {
152 }
153 
154 void
156 {
157  if (m_macRxOnWhenIdle)
158  {
159  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
160  }
161  else
162  {
163  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
164  }
165 
167 }
168 
169 void
171 {
172  if (m_csmaCa != 0)
173  {
174  m_csmaCa->Dispose ();
175  m_csmaCa = 0;
176  }
177  m_txPkt = 0;
178  for (uint32_t i = 0; i < m_txQueue.size (); i++)
179  {
180  m_txQueue[i]->txQPkt = 0;
181  delete m_txQueue[i];
182  }
183  m_txQueue.clear ();
184  m_phy = 0;
185  m_mcpsDataIndicationCallback = MakeNullCallback< void, McpsDataIndicationParams, Ptr<Packet> > ();
186  m_mcpsDataConfirmCallback = MakeNullCallback< void, McpsDataConfirmParams > ();
187 
189 }
190 
191 bool
193 {
194  return m_macRxOnWhenIdle;
195 }
196 
197 void
198 LrWpanMac::SetRxOnWhenIdle (bool rxOnWhenIdle)
199 {
200  NS_LOG_FUNCTION (this << rxOnWhenIdle);
201  m_macRxOnWhenIdle = rxOnWhenIdle;
202 
203  if (m_lrWpanMacState == MAC_IDLE)
204  {
205  if (m_macRxOnWhenIdle)
206  {
207  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
208  }
209  else
210  {
211  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
212  }
213  }
214 }
215 
216 void
218 {
219  //NS_LOG_FUNCTION (this << address);
221 }
222 
223 void
225 {
226  //NS_LOG_FUNCTION (this << address);
227  m_selfExt = address;
228 }
229 
230 
233 {
234  NS_LOG_FUNCTION (this);
235  return m_shortAddress;
236 }
237 
240 {
241  NS_LOG_FUNCTION (this);
242  return m_selfExt;
243 }
244 void
246 {
247  NS_LOG_FUNCTION (this << p);
248 
249  McpsDataConfirmParams confirmParams;
250  confirmParams.m_msduHandle = params.m_msduHandle;
251 
252  // TODO: We need a drop trace for the case that the packet is too large or the request parameters are maleformed.
253  // The current tx drop trace is not suitable, because packets dropped using this trace carry the mac header
254  // and footer, while packets being dropped here do not have them.
255 
257  m_macDsn++;
258 
260  {
261  // Note, this is just testing maximum theoretical frame size per the spec
262  // The frame could still be too large once headers are put on
263  // in which case the phy will reject it instead
264  NS_LOG_ERROR (this << " packet too big: " << p->GetSize ());
265  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
267  {
268  m_mcpsDataConfirmCallback (confirmParams);
269  }
270  return;
271  }
272 
273  if ((params.m_srcAddrMode == NO_PANID_ADDR)
274  && (params.m_dstAddrMode == NO_PANID_ADDR))
275  {
276  NS_LOG_ERROR (this << " Can not send packet with no Address field" );
277  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
279  {
280  m_mcpsDataConfirmCallback (confirmParams);
281  }
282  return;
283  }
284  switch (params.m_srcAddrMode)
285  {
286  case NO_PANID_ADDR:
287  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
288  macHdr.SetNoPanIdComp ();
289  break;
290  case ADDR_MODE_RESERVED:
291  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
292  break;
293  case SHORT_ADDR:
294  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
295  macHdr.SetSrcAddrFields (GetPanId (), GetShortAddress ());
296  break;
297  case EXT_ADDR:
298  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
299  macHdr.SetSrcAddrFields (GetPanId (), GetExtendedAddress ());
300  break;
301  default:
302  NS_LOG_ERROR (this << " Can not send packet with incorrect Source Address mode = " << params.m_srcAddrMode);
303  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
305  {
306  m_mcpsDataConfirmCallback (confirmParams);
307  }
308  return;
309  }
310 
311  macHdr.SetDstAddrMode (params.m_dstAddrMode);
312  // TODO: Add field for EXT_ADDR destination address (and use it here).
313  macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstAddr);
314  macHdr.SetSecDisable ();
315  //extract the last 3 bits in TxOptions and map to macHdr
316  int b0 = params.m_txOptions & TX_OPTION_ACK;
317  int b1 = params.m_txOptions & TX_OPTION_GTS;
318  int b2 = params.m_txOptions & TX_OPTION_INDIRECT;
319  if (b0 == TX_OPTION_ACK)
320  {
321  // Set AckReq bit only if the destination is not the broadcast address.
322  if (!(macHdr.GetDstAddrMode () == SHORT_ADDR && macHdr.GetShortDstAddr () == "ff:ff"))
323  {
324  macHdr.SetAckReq ();
325  }
326  }
327  else if (b0 == 0)
328  {
329  macHdr.SetNoAckReq ();
330  }
331  else
332  {
334  NS_LOG_ERROR (this << "Incorrect TxOptions bit 0 not 0/1");
336  {
337  m_mcpsDataConfirmCallback (confirmParams);
338  }
339  return;
340  }
341 
342  //if is Slotted CSMA means its beacon enabled
343  if (m_csmaCa->IsSlottedCsmaCa ())
344  {
345  if (b1 == TX_OPTION_GTS)
346  {
347  //TODO:GTS Transmission
348  }
349  else if (b1 == 0)
350  {
351  //TODO:CAP Transmission
352  }
353  else
354  {
355  NS_LOG_ERROR (this << "Incorrect TxOptions bit 1 not 0/1");
358  {
359  m_mcpsDataConfirmCallback (confirmParams);
360  }
361  return;
362  }
363  }
364  else
365  {
366  if (b1 != 0)
367  {
368  NS_LOG_ERROR (this << "for non-beacon-enables PAN, bit 1 should always be set to 0");
371  {
372  m_mcpsDataConfirmCallback (confirmParams);
373  }
374  return;
375  }
376  }
377 
378  if (b2 == TX_OPTION_INDIRECT)
379  {
380  //TODO :indirect tx
381  }
382  else if (b2 == 0)
383  {
384  //TODO :direct tx
385  }
386  else
387  {
388  NS_LOG_ERROR (this << "Incorrect TxOptions bit 2 not 0/1");
391  {
392  m_mcpsDataConfirmCallback (confirmParams);
393  }
394  return;
395  }
396 
397  p->AddHeader (macHdr);
398 
399  LrWpanMacTrailer macTrailer;
400  // Calculate FCS if the global attribute ChecksumEnable is set.
401  if (Node::ChecksumEnabled ())
402  {
403  macTrailer.EnableFcs (true);
404  macTrailer.SetFcs (p);
405  }
406  p->AddTrailer (macTrailer);
407 
409 
410  TxQueueElement *txQElement = new TxQueueElement;
411  txQElement->txQMsduHandle = params.m_msduHandle;
412  txQElement->txQPkt = p;
413  m_txQueue.push_back (txQElement);
414 
415  CheckQueue ();
416 }
417 
418 void
420 {
421  NS_LOG_FUNCTION (this);
422 
423  // Pull a packet from the queue and start sending, if we are not already sending.
424  if (m_lrWpanMacState == MAC_IDLE && !m_txQueue.empty () && m_txPkt == 0 && !m_setMacState.IsRunning ())
425  {
426  TxQueueElement *txQElement = m_txQueue.front ();
427  m_txPkt = txQElement->txQPkt;
429  }
430 }
431 
432 void
434 {
435  m_csmaCa = csmaCa;
436 }
437 
438 void
440 {
441  m_phy = phy;
442 }
443 
446 {
447  return m_phy;
448 }
449 
450 void
452 {
454 }
455 
456 void
458 {
460 }
461 
462 void
463 LrWpanMac::PdDataIndication (uint32_t psduLength, Ptr<Packet> p, uint8_t lqi)
464 {
466 
467  NS_LOG_FUNCTION (this << psduLength << p << lqi);
468 
469  bool acceptFrame;
470 
471  // from sec 7.5.6.2 Reception and rejection, Std802.15.4-2006
472  // level 1 filtering, test FCS field and reject if frame fails
473  // level 2 filtering if promiscuous mode pass frame to higher layer otherwise perform level 3 filtering
474  // level 3 filtering accept frame
475  // if Frame type and version is not reserved, and
476  // if there is a dstPanId then dstPanId=m_macPanId or broadcastPanI, and
477  // if there is a shortDstAddr then shortDstAddr =shortMacAddr or broadcastAddr, and
478  // if beacon frame then srcPanId = m_macPanId
479  // if only srcAddr field in Data or Command frame,accept frame if srcPanId=m_macPanId
480 
481  Ptr<Packet> originalPkt = p->Copy (); // because we will strip headers
482 
483  m_promiscSnifferTrace (originalPkt);
484 
485  m_macPromiscRxTrace (originalPkt);
486  // XXX no rejection tracing (to macRxDropTrace) being performed below
487 
488  LrWpanMacTrailer receivedMacTrailer;
489  p->RemoveTrailer (receivedMacTrailer);
490  if (Node::ChecksumEnabled ())
491  {
492  receivedMacTrailer.EnableFcs (true);
493  }
494 
495  // level 1 filtering
496  if (!receivedMacTrailer.CheckFcs (p))
497  {
498  m_macRxDropTrace (originalPkt);
499  }
500  else
501  {
502  LrWpanMacHeader receivedMacHdr;
503  p->RemoveHeader (receivedMacHdr);
504 
506  params.m_dsn = receivedMacHdr.GetSeqNum ();
507  params.m_mpduLinkQuality = lqi;
508  params.m_srcPanId = receivedMacHdr.GetSrcPanId ();
509  params.m_srcAddrMode = receivedMacHdr.GetSrcAddrMode ();
510  // TODO: Add field for EXT_ADDR source address.
511  if (params.m_srcAddrMode == SHORT_ADDR)
512  {
513  params.m_srcAddr = receivedMacHdr.GetShortSrcAddr ();
514  }
515  params.m_dstPanId = receivedMacHdr.GetDstPanId ();
516  params.m_dstAddrMode = receivedMacHdr.GetDstAddrMode ();
517  // TODO: Add field for EXT_ADDR destination address.
518  if (params.m_dstAddrMode == SHORT_ADDR)
519  {
520  params.m_dstAddr = receivedMacHdr.GetShortDstAddr ();
521  }
522 
523  NS_LOG_DEBUG ("Packet from " << params.m_srcAddr << " to " << params.m_dstAddr);
524 
526  {
527  //level 2 filtering
529  {
530  NS_LOG_DEBUG ("promiscuous mode, forwarding up");
531  m_mcpsDataIndicationCallback (params, p);
532  }
533  else
534  {
535  NS_LOG_ERROR (this << " Data Indication Callback not initialised");
536  }
537  }
538  else
539  {
540  //level 3 frame filtering
541  acceptFrame = (receivedMacHdr.GetType () != LrWpanMacHeader::LRWPAN_MAC_RESERVED);
542 
543  if (acceptFrame)
544  {
545  acceptFrame = (receivedMacHdr.GetFrameVer () <= 1);
546  }
547 
548  if (acceptFrame
549  && (receivedMacHdr.GetDstAddrMode () > 1))
550  {
551  acceptFrame = receivedMacHdr.GetDstPanId () == m_macPanId
552  || receivedMacHdr.GetDstPanId () == 0xffff;
553  }
554 
555  if (acceptFrame
556  && (receivedMacHdr.GetDstAddrMode () == 2))
557  {
558  acceptFrame = receivedMacHdr.GetShortDstAddr () == m_shortAddress
559  || receivedMacHdr.GetShortDstAddr () == Mac16Address ("ff:ff"); // check for broadcast addrs
560  }
561 
562  if (acceptFrame
563  && (receivedMacHdr.GetDstAddrMode () == 3))
564  {
565  acceptFrame = (receivedMacHdr.GetExtDstAddr () == m_selfExt);
566  }
567 
568  if (acceptFrame
569  && (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_BEACON))
570  {
571  if (m_macPanId == 0xffff)
572  {
573  // TODO: Accept only if the frame version field is valid
574  acceptFrame = true;
575  }
576  else
577  {
578  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId;
579  }
580  }
581 
582  if (acceptFrame
583  && ((receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_DATA)
584  || (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_COMMAND))
585  && (receivedMacHdr.GetSrcAddrMode () > 1))
586  {
587  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId; // \todo need to check if PAN coord
588  }
589 
590  if (acceptFrame)
591  {
592  m_macRxTrace (originalPkt);
593  // \todo: What should we do if we receive a frame while waiting for an ACK?
594  // Especially if this frame has the ACK request bit set, should we reply with an ACK, possibly missing the pending ACK?
595 
596  // If the received frame is a frame with the ACK request bit set, we immediately send back an ACK.
597  // If we are currently waiting for a pending ACK, we assume the ACK was lost and trigger a retransmission after sending the ACK.
598  if ((receivedMacHdr.IsData () || receivedMacHdr.IsCommand ()) && receivedMacHdr.IsAckReq ()
599  && !(receivedMacHdr.GetDstAddrMode () == SHORT_ADDR && receivedMacHdr.GetShortDstAddr () == "ff:ff"))
600  {
601  // If this is a data or mac command frame, which is not a broadcast,
602  // with ack req set, generate and send an ack frame.
603  // If there is a CSMA medium access in progress we cancel the medium access
604  // for sending the ACK frame. A new transmission attempt will be started
605  // after the ACK was send.
607  {
610  }
611  else if (m_lrWpanMacState == MAC_CSMA)
612  {
613  // \todo: If we receive a packet while doing CSMA/CA, should we drop the packet because of channel busy,
614  // or should we restart CSMA/CA for the packet after sending the ACK?
615  // Currently we simply restart CSMA/CA after sending the ACK.
616  m_csmaCa->Cancel ();
617  }
618  // Cancel any pending MAC state change, ACKs have higher priority.
622  }
623 
624  if (receivedMacHdr.IsData () && !m_mcpsDataIndicationCallback.IsNull ())
625  {
626  // If it is a data frame, push it up the stack.
627  NS_LOG_DEBUG ("PdDataIndication(): Packet is for me; forwarding up");
628  m_mcpsDataIndicationCallback (params, p);
629  }
630  else if (receivedMacHdr.IsAcknowledgment () && m_txPkt && m_lrWpanMacState == MAC_ACK_PENDING)
631  {
632  LrWpanMacHeader macHdr;
633  m_txPkt->PeekHeader (macHdr);
634  if (receivedMacHdr.GetSeqNum () == macHdr.GetSeqNum ())
635  {
637  // If it is an ACK with the expected sequence number, finish the transmission
638  // and notify the upper layer.
641  {
642  TxQueueElement *txQElement = m_txQueue.front ();
643  McpsDataConfirmParams confirmParams;
644  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
645  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
646  m_mcpsDataConfirmCallback (confirmParams);
647  }
651  }
652  else
653  {
654  // 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)
656  if (!PrepareRetransmission ())
657  {
660  }
661  else
662  {
665  }
666  }
667  }
668  }
669  else
670  {
671  m_macRxDropTrace (originalPkt);
672  }
673  }
674  }
675 }
676 
677 void
678 LrWpanMac::SendAck (uint8_t seqno)
679 {
680  NS_LOG_FUNCTION (this << static_cast<uint32_t> (seqno));
681 
683 
684  // Generate a corresponding ACK Frame.
686  LrWpanMacTrailer macTrailer;
687  Ptr<Packet> ackPacket = Create<Packet> (0);
688  ackPacket->AddHeader (macHdr);
689  // Calculate FCS if the global attribute ChecksumEnable is set.
690  if (Node::ChecksumEnabled ())
691  {
692  macTrailer.EnableFcs (true);
693  macTrailer.SetFcs (ackPacket);
694  }
695  ackPacket->AddTrailer (macTrailer);
696 
697  // Enqueue the ACK packet for further processing
698  // when the transmitter is activated.
699  m_txPkt = ackPacket;
700 
701  // Switch transceiver to TX mode. Proceed sending the Ack on confirm.
703  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
704 }
705 
706 void
708 {
709  TxQueueElement *txQElement = m_txQueue.front ();
710  Ptr<const Packet> p = txQElement->txQPkt;
711  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
712 
713  Ptr<Packet> pkt = p->Copy ();
714  LrWpanMacHeader hdr;
715  pkt->RemoveHeader (hdr);
716  if (hdr.GetShortDstAddr () != Mac16Address ("ff:ff"))
717  {
719  }
720 
721  txQElement->txQPkt = 0;
722  delete txQElement;
723  m_txQueue.pop_front ();
724  m_txPkt = 0;
725  m_retransmission = 0;
726  m_numCsmacaRetry = 0;
728 }
729 
730 void
732 {
733  NS_LOG_FUNCTION (this);
734 
735  // TODO: If we are a PAN coordinator and this was an indirect transmission,
736  // we will not initiate a retransmission. Instead we wait for the data
737  // being extracted after a new data request command.
738  if (!PrepareRetransmission ())
739  {
741  }
742  else
743  {
745  }
746 }
747 
748 bool
750 {
751  NS_LOG_FUNCTION (this);
752 
754  {
755  // Maximum number of retransmissions has been reached.
756  // remove the copy of the packet that was just sent
757  TxQueueElement *txQElement = m_txQueue.front ();
758  m_macTxDropTrace (txQElement->txQPkt);
760  {
761  McpsDataConfirmParams confirmParams;
762  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
763  confirmParams.m_status = IEEE_802_15_4_NO_ACK;
764  m_mcpsDataConfirmCallback (confirmParams);
765  }
767  return false;
768  }
769  else
770  {
772  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
773  // Start next CCA process for this packet.
774  return true;
775  }
776 }
777 
778 void
780 {
782 
783  NS_LOG_FUNCTION (this << status << m_txQueue.size ());
784 
785  LrWpanMacHeader macHdr;
786  m_txPkt->PeekHeader (macHdr);
787  if (status == IEEE_802_15_4_PHY_SUCCESS)
788  {
789  if (!macHdr.IsAcknowledgment ())
790  {
791  // We have just send a regular data packet, check if we have to wait
792  // for an ACK.
793  if (macHdr.IsAckReq ())
794  {
795  // wait for the ack or the next retransmission timeout
796  // start retransmission timer
797  Time waitTime = MicroSeconds (GetMacAckWaitDuration () * 1000 * 1000 / m_phy->GetDataOrSymbolRate (false));
802  return;
803  }
804  else
805  {
807  // remove the copy of the packet that was just sent
809  {
810  McpsDataConfirmParams confirmParams;
811  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
812  TxQueueElement *txQElement = m_txQueue.front ();
813  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
814  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
815  m_mcpsDataConfirmCallback (confirmParams);
816  }
818  }
819  }
820  else
821  {
822  // We have send an ACK. Clear the packet buffer.
823  m_txPkt = 0;
824  }
825  }
826  else if (status == IEEE_802_15_4_PHY_UNSPECIFIED)
827  {
828 
829  if (!macHdr.IsAcknowledgment ())
830  {
831  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
832  TxQueueElement *txQElement = m_txQueue.front ();
833  m_macTxDropTrace (txQElement->txQPkt);
835  {
836  McpsDataConfirmParams confirmParams;
837  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
838  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
839  m_mcpsDataConfirmCallback (confirmParams);
840  }
842  }
843  else
844  {
845  NS_LOG_ERROR ("Unable to send ACK");
846  }
847  }
848  else
849  {
850  // Something went really wrong. The PHY is not in the correct state for
851  // data transmission.
852  NS_FATAL_ERROR ("Transmission attempt failed with PHY status " << status);
853  }
854 
857 }
858 
859 void
861 {
862  NS_LOG_FUNCTION (this << status);
863  // Direct this call through the csmaCa object
864  m_csmaCa->PlmeCcaConfirm (status);
865 }
866 
867 void
868 LrWpanMac::PlmeEdConfirm (LrWpanPhyEnumeration status, uint8_t energyLevel)
869 {
870  NS_LOG_FUNCTION (this << status << energyLevel);
871 
872 }
873 
874 void
877  LrWpanPhyPibAttributes* attribute)
878 {
879  NS_LOG_FUNCTION (this << status << id << attribute);
880 }
881 
882 void
884 {
885  NS_LOG_FUNCTION (this << status);
886 
888  {
889  NS_ASSERT (m_txPkt);
890 
891  // Start sending if we are in state SENDING and the PHY transmitter was enabled.
895  m_phy->PdDataRequest (m_txPkt->GetSize (), m_txPkt);
896  }
897  else if (m_lrWpanMacState == MAC_CSMA && (status == IEEE_802_15_4_PHY_RX_ON || status == IEEE_802_15_4_PHY_SUCCESS))
898  {
899  // Start the CSMA algorithm as soon as the receiver is enabled.
900  m_csmaCa->Start ();
901  }
902  else if (m_lrWpanMacState == MAC_IDLE)
903  {
905  // Do nothing special when going idle.
906  }
907  else if (m_lrWpanMacState == MAC_ACK_PENDING)
908  {
910  }
911  else
912  {
913  // TODO: What to do when we receive an error?
914  // If we want to transmit a packet, but switching the transceiver on results
915  // in an error, we have to recover somehow (and start sending again).
916  NS_FATAL_ERROR ("Error changing transceiver state");
917  }
918 }
919 
920 void
923 {
924  NS_LOG_FUNCTION (this << status << id);
925 }
926 
927 void
929 {
930  NS_LOG_FUNCTION (this << "mac state = " << macState);
931 
932  McpsDataConfirmParams confirmParams;
933 
934  if (macState == MAC_IDLE)
935  {
937 
938  if (m_macRxOnWhenIdle)
939  {
940  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
941  }
942  else
943  {
944  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
945  }
946 
947  CheckQueue ();
948  }
949  else if (macState == MAC_ACK_PENDING)
950  {
952  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
953  }
954  else if (macState == MAC_CSMA)
955  {
957 
959  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
960  }
961  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_IDLE)
962  {
963  // Channel is idle, set transmitter to TX_ON
965  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
966  }
967  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_ACCESS_FAILURE)
968  {
969  NS_ASSERT (m_txPkt);
970 
971  // cannot find a clear channel, drop the current packet.
972  NS_LOG_DEBUG ( this << " cannot find clear channel");
973  confirmParams.m_msduHandle = m_txQueue.front ()->txQMsduHandle;
977  {
978  m_mcpsDataConfirmCallback (confirmParams);
979  }
980  // remove the copy of the packet that was just sent
982 
984  }
985 }
986 
989 {
990  return m_associationStatus;
991 }
992 
993 void
995 {
996  m_associationStatus = status;
997 }
998 
999 uint16_t
1001 {
1002  return m_macPanId;
1003 }
1004 
1005 void
1006 LrWpanMac::SetPanId (uint16_t panId)
1007 {
1008  m_macPanId = panId;
1009 }
1010 
1011 void
1013 {
1014  NS_LOG_LOGIC (this << " change lrwpan mac state from "
1015  << m_lrWpanMacState << " to "
1016  << newState);
1017  m_macStateLogger (m_lrWpanMacState, newState);
1018  m_lrWpanMacState = newState;
1019 }
1020 
1021 uint64_t
1023 {
1024  return m_csmaCa->GetUnitBackoffPeriod () + m_phy->aTurnaroundTime + m_phy->GetPhySHRDuration ()
1025  + ceil (6 * m_phy->GetPhySymbolsPerOctet ());
1026 }
1027 
1028 uint8_t
1030 {
1031  return m_macMaxFrameRetries;
1032 }
1033 
1034 void
1036 {
1037  m_macMaxFrameRetries = retries;
1038 }
1039 
1040 } // namespace ns3
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
uint16_t m_dstPanId
Destination PAN identifier.
Definition: lr-wpan-mac.h:144
TX_OPTION_INDIRECT.
Definition: lr-wpan-mac.h:58
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
void CheckQueue(void)
Check the transmission queue.
Definition: lr-wpan-mac.cc:419
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
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...
Definition: lr-wpan-mac.cc:875
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:145
void RemoveFirstTxQElement()
Remove the tip of the transmission queue, including clean up related to the last packet transmission...
Definition: lr-wpan-mac.cc:707
virtual ~LrWpanMac(void)
Definition: lr-wpan-mac.cc:150
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:639
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:126
LrWpanAssociationStatus GetAssociationStatus(void) const
Get the current association status.
Definition: lr-wpan-mac.cc:988
static bool ChecksumEnabled(void)
Definition: node.cc:268
CHANNEL_IDLE.
Definition: lr-wpan-mac.h:73
McpsDataConfirmCallback m_mcpsDataConfirmCallback
This callback is used to report data transmission request status to the upper layers.
Definition: lr-wpan-mac.h:745
std::deque< TxQueueElement * > m_txQueue
The transmit queue used by the MAC.
Definition: lr-wpan-mac.h:778
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:173
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1072
uint8_t m_dstAddrMode
Destination address mode.
Definition: lr-wpan-mac.h:171
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
LrWpanMacState m_lrWpanMacState
The current state of the MAC layer.
Definition: lr-wpan-mac.h:750
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:766
LrWpanAssociationStatus m_associationStatus
The current association status of the MAC layer.
Definition: lr-wpan-mac.h:755
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:338
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
virtual void DoDispose(void)
Destructor implementation.
Definition: lr-wpan-mac.cc:170
TracedCallback< LrWpanMacState, LrWpanMacState > m_macStateLogger
A trace source that fires when the LrWpanMac changes states.
Definition: lr-wpan-mac.h:722
void SetShortAddress(Mac16Address address)
Set the short address of this MAC.
Definition: lr-wpan-mac.cc:217
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
Represent the Mac Header with the Frame Control and Sequence Number fields.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:819
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:143
McpsDataIndicationCallback m_mcpsDataIndicationCallback
This callback is used to notify incoming packets to the upper layers.
Definition: lr-wpan-mac.h:738
void SetMcpsDataConfirmCallback(McpsDataConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
Definition: lr-wpan-mac.cc:457
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:245
uint8_t m_numCsmacaRetry
The number of CSMA/CA retries used for sending the current packet.
Definition: lr-wpan-mac.h:789
Mac16Address GetShortSrcAddr(void) const
Get the Source Short address.
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:146
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:157
static const uint32_t aMaxPhyPacketSize
The maximum packet size accepted by the PHY.
Definition: lr-wpan-phy.h:248
uint16_t m_dstPanId
Destination PAN identifier.
Definition: lr-wpan-mac.h:172
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:630
an EUI-64 address
Definition: mac64-address.h:43
Ptr< Packet > m_txPkt
The packet which is currently being sent by the MAC layer.
Definition: lr-wpan-mac.h:760
bool IsData(void) const
Returns true if the header is a data.
bool GetRxOnWhenIdle(void)
Check if the receiver will be enabled when the MAC is idle.
Definition: lr-wpan-mac.cc:192
void SetLrWpanMacState(LrWpanMacState macState)
CSMA-CA algorithm calls back the MAC after executing channel assessment.
Definition: lr-wpan-mac.cc:928
Mac64Address GetExtendedAddress(void) const
Get the extended address of this MAC.
Definition: lr-wpan-mac.cc:239
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.
Definition: lr-wpan-mac.cc:868
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:714
TX_OPTION_ACK.
Definition: lr-wpan-mac.h:56
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:615
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:665
Ptr< Packet > txQPkt
Queued packet.
Definition: lr-wpan-mac.h:553
bool PrepareRetransmission(void)
Check for remaining retransmissions for the packet currently being sent.
Definition: lr-wpan-mac.cc:749
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
Definition: lr-wpan-mac.cc:860
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:795
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:647
Mac64Address GetExtDstAddr(void) const
Get the Destination Extended address.
EventId m_setMacState
Scheduler event for a deferred MAC state change.
Definition: lr-wpan-mac.h:800
Helper structure for managing transmission queue elements.
Definition: lr-wpan-mac.h:550
bool m_macRxOnWhenIdle
Indication of whether the MAC sublayer is to enable its receiver during idle periods.
Definition: lr-wpan-mac.h:498
MCPS-DATA.confirm params.
Definition: lr-wpan-mac.h:155
void PdDataConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.1.2 Confirm the end of transmission of an MPDU to MAC.
Definition: lr-wpan-mac.cc:779
uint8_t m_txOptions
Tx Options (bitfield)
Definition: lr-wpan-mac.h:147
bool IsAckReq(void) const
Check if Ack.
uint8_t m_mpduLinkQuality
LQI value measured during reception of the MPDU.
Definition: lr-wpan-mac.h:174
void SetPhy(Ptr< LrWpanPhy > phy)
Set the underlying PHY for the MAC.
Definition: lr-wpan-mac.cc:439
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
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:607
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...
Definition: lr-wpan-mac.cc:463
uint8_t m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:168
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
Definition: lr-wpan-mac.h:158
LrWpanAddressMode m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:142
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:277
uint8_t m_retransmission
The number of already used retransmission for the currently transmitted packet.
Definition: lr-wpan-mac.h:784
Mac64Address m_selfExt
The extended address used by this MAC.
Definition: lr-wpan-mac.h:773
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t GetSrcAddrMode(void) const
Get the Source Addressing Mode of Frame control field.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
Definition: lr-wpan-mac.h:143
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
Definition: packet.cc:284
double GetValue(double min, double max)
Returns a random double from the uniform distribution with 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:674
bool IsAcknowledgment(void) const
Returns true if the header is an ack.
Mac16Address GetShortDstAddr(void) const
Get the Destination Short address.
TX_OPTION_GTS.
Definition: lr-wpan-mac.h:57
void SetRxOnWhenIdle(bool rxOnWhenIdle)
Set if the receiver should be enabled when the MAC is idle.
Definition: lr-wpan-mac.cc:198
uint32_t RemoveTrailer(Trailer &trailer)
Remove a deserialized trailer from the internal buffer.
Definition: packet.cc:300
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:656
uint16_t GetSrcPanId(void) const
Get the Source PAN ID.
bool m_macPromiscuousMode
Indicates if MAC sublayer is in receive all mode.
Definition: lr-wpan-mac.h:472
Mac16Address m_srcAddr
Source address.
Definition: lr-wpan-mac.h:170
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:980
This class can contain 16 bit addresses.
Definition: mac16-address.h:41
uint8_t m_dsn
The DSN of the received data frame.
Definition: lr-wpan-mac.h:175
LrWpanMac(void)
Default constructor.
Definition: lr-wpan-mac.cc:126
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:694
void SetExtendedAddress(Mac64Address address)
Set the extended address of this MAC.
Definition: lr-wpan-mac.cc:224
uint8_t m_macMaxFrameRetries
The maximum number of retries allowed after a transmission failure.
Definition: lr-wpan-mac.h:491
uint8_t txQMsduHandle
MSDU Handle.
Definition: lr-wpan-mac.h:552
static TypeId GetTypeId(void)
Get the type ID.
Definition: lr-wpan-mac.cc:50
uint8_t GetFrameVer(void) const
Get the Frame Version of Frame control field.
#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:84
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:727
CHANNEL_ACCESS_FAILURE.
Definition: lr-wpan-mac.h:72
MAC_CSMA.
Definition: lr-wpan-mac.h:69
SequenceNumber8 m_macDsn
Sequence number added to transmitted data or MAC command frame, 00-ff.
Definition: lr-wpan-mac.h:485
MAC_ACK_PENDING.
Definition: lr-wpan-mac.h:71
static const uint32_t aMinMPDUOverhead
The minimum number of octets added by the MAC sublayer to the PSDU.
Definition: lr-wpan-mac.h:218
void ChangeMacState(LrWpanMacState newState)
Change the current MAC state to the given new state.
bool IsCommand(void) const
Returns true if the header is a command.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
uint8_t GetMacMaxFrameRetries(void) const
Get the macMaxFrameRetries attribute value.
Ptr< LrWpanCsmaCa > m_csmaCa
The CSMA/CA implementation used by this MAC.
Definition: lr-wpan-mac.h:732
LrWpanMacState
MAC states.
Definition: lr-wpan-mac.h:66
LrWpanAssociationStatus
table 83 of 802.15.4
Definition: lr-wpan-mac.h:95
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
Mac16Address GetShortAddress(void) const
Get the short address of this MAC.
Definition: lr-wpan-mac.cc:232
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:623
uint8_t GetSeqNum(void) const
Get the frame Sequence number.
uint16_t m_macPanId
16 bits id of PAN on which this device is operating.
Definition: lr-wpan-mac.h:479
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:875
SequenceNumber< uint8_t, int8_t > SequenceNumber8
8 bit Sequence number.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:220
void PlmeSetTRXStateConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.8 PLME-SET-TRX-STATE.confirm Set PHY state.
Definition: lr-wpan-mac.cc:883
enum LrWpanMacType GetType(void) const
Get the header type.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:104
void SendAck(uint8_t seqno)
Send an acknowledgment packet for the given sequence number.
Definition: lr-wpan-mac.cc:678
MCPS-DATA.request params.
Definition: lr-wpan-mac.h:131
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
tuple address
Definition: first.py:37
uint16_t GetPanId(void) const
Get the PAN id used by this MAC.
void AckWaitTimeout(void)
Handle an ACK timeout with a packet retransmission, if there are retransmission left, or a packet drop.
Definition: lr-wpan-mac.cc:731
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
Ptr< LrWpanPhy > GetPhy(void)
Get the underlying PHY of the MAC.
Definition: lr-wpan-mac.cc:445
Mac16Address m_shortAddress
The short address used by this MAC.
Definition: lr-wpan-mac.h:767
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:190
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
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:51
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaCa)
Set the CSMA/CA implementation to be used by the MAC.
Definition: lr-wpan-mac.cc:433
uint8_t GetDstAddrMode(void) const
Get the Dest.
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...
Definition: lr-wpan-mac.cc:921
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lr-wpan-mac.cc:155
static Mac64Address Allocate(void)
Allocate a new Mac64Address.
uint16_t GetDstPanId(void) const
Get the Destination PAN ID.
uint64_t GetMacAckWaitDuration(void) const
Get the macAckWaitDuration attribute value.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:345
MAC_SENDING.
Definition: lr-wpan-mac.h:70
uint16_t m_srcPanId
Source PAN identifier.
Definition: lr-wpan-mac.h:169
MAC_IDLE.
Definition: lr-wpan-mac.h:68
void SetAssociationStatus(LrWpanAssociationStatus status)
Set the current association status.
Definition: lr-wpan-mac.cc:994
MCPS-DATA.indication params.
Definition: lr-wpan-mac.h:166
void SetMcpsDataIndicationCallback(McpsDataIndicationCallback c)
Set the callback for the indication of an incoming data packet.
Definition: lr-wpan-mac.cc:451