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  .SetGroupName ("LrWpan")
55  .AddConstructor<LrWpanMac> ()
56  .AddAttribute ("PanId", "16-bit identifier of the associated PAN",
57  UintegerValue (),
59  MakeUintegerChecker<uint16_t> ())
60  .AddTraceSource ("MacTxEnqueue",
61  "Trace source indicating a packet has been "
62  "enqueued in the transaction queue",
64  "ns3::Packet::TracedCallback")
65  .AddTraceSource ("MacTxDequeue",
66  "Trace source indicating a packet has was "
67  "dequeued from the transaction queue",
69  "ns3::Packet::TracedCallback")
70  .AddTraceSource ("MacTx",
71  "Trace source indicating a packet has "
72  "arrived for transmission by this device",
74  "ns3::Packet::TracedCallback")
75  .AddTraceSource ("MacTxOk",
76  "Trace source indicating a packet has been "
77  "successfully sent",
79  "ns3::Packet::TracedCallback")
80  .AddTraceSource ("MacTxDrop",
81  "Trace source indicating a packet has been "
82  "dropped during transmission",
84  "ns3::Packet::TracedCallback")
85  .AddTraceSource ("MacPromiscRx",
86  "A packet has been received by this device, "
87  "has been passed up from the physical layer "
88  "and is being forwarded up the local protocol stack. "
89  "This is a promiscuous trace,",
91  "ns3::Packet::TracedCallback")
92  .AddTraceSource ("MacRx",
93  "A packet has been received by this device, "
94  "has been passed up from the physical layer "
95  "and is being forwarded up the local protocol stack. "
96  "This is a non-promiscuous trace,",
98  "ns3::Packet::TracedCallback")
99  .AddTraceSource ("MacRxDrop",
100  "Trace source indicating a packet was received, "
101  "but dropped before being forwarded up the stack",
103  "ns3::Packet::TracedCallback")
104  .AddTraceSource ("Sniffer",
105  "Trace source simulating a non-promiscuous "
106  "packet sniffer attached to the device",
108  "ns3::Packet::TracedCallback")
109  .AddTraceSource ("PromiscSniffer",
110  "Trace source simulating a promiscuous "
111  "packet sniffer attached to the device",
113  "ns3::Packet::TracedCallback")
114  .AddTraceSource ("MacState",
115  "The state of LrWpan Mac",
117  "ns3::LrWpanMac::StateTracedCallback")
118  .AddTraceSource ("MacSentPkt",
119  "Trace source reporting some information about "
120  "the sent packet",
122  "ns3::LrWpanMac::SentTracedCallback")
123  ;
124  return tid;
125 }
126 
128 {
129 
130  // First set the state to a known value, call ChangeMacState to fire trace source.
133 
134  m_macRxOnWhenIdle = true;
135  m_macPanId = 0;
138  m_macPromiscuousMode = false;
140  m_retransmission = 0;
141  m_numCsmacaRetry = 0;
142  m_txPkt = 0;
143 
144  Ptr<UniformRandomVariable> uniformVar = CreateObject<UniformRandomVariable> ();
145  uniformVar->SetAttribute ("Min", DoubleValue (0.0));
146  uniformVar->SetAttribute ("Max", DoubleValue (255.0));
147  m_macDsn = SequenceNumber8 (uniformVar->GetValue ());
148  m_shortAddress = Mac16Address ("00:00");
149 }
150 
152 {
153 }
154 
155 void
157 {
158  if (m_macRxOnWhenIdle)
159  {
160  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
161  }
162  else
163  {
164  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
165  }
166 
168 }
169 
170 void
172 {
173  if (m_csmaCa != 0)
174  {
175  m_csmaCa->Dispose ();
176  m_csmaCa = 0;
177  }
178  m_txPkt = 0;
179  for (uint32_t i = 0; i < m_txQueue.size (); i++)
180  {
181  m_txQueue[i]->txQPkt = 0;
182  delete m_txQueue[i];
183  }
184  m_txQueue.clear ();
185  m_phy = 0;
186  m_mcpsDataIndicationCallback = MakeNullCallback< void, McpsDataIndicationParams, Ptr<Packet> > ();
187  m_mcpsDataConfirmCallback = MakeNullCallback< void, McpsDataConfirmParams > ();
188 
190 }
191 
192 bool
194 {
195  return m_macRxOnWhenIdle;
196 }
197 
198 void
199 LrWpanMac::SetRxOnWhenIdle (bool rxOnWhenIdle)
200 {
201  NS_LOG_FUNCTION (this << rxOnWhenIdle);
202  m_macRxOnWhenIdle = rxOnWhenIdle;
203 
204  if (m_lrWpanMacState == MAC_IDLE)
205  {
206  if (m_macRxOnWhenIdle)
207  {
208  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
209  }
210  else
211  {
212  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
213  }
214  }
215 }
216 
217 void
219 {
220  //NS_LOG_FUNCTION (this << address);
222 }
223 
224 void
226 {
227  //NS_LOG_FUNCTION (this << address);
228  m_selfExt = address;
229 }
230 
231 
234 {
235  NS_LOG_FUNCTION (this);
236  return m_shortAddress;
237 }
238 
241 {
242  NS_LOG_FUNCTION (this);
243  return m_selfExt;
244 }
245 void
247 {
248  NS_LOG_FUNCTION (this << p);
249 
250  McpsDataConfirmParams confirmParams;
251  confirmParams.m_msduHandle = params.m_msduHandle;
252 
253  // TODO: We need a drop trace for the case that the packet is too large or the request parameters are maleformed.
254  // The current tx drop trace is not suitable, because packets dropped using this trace carry the mac header
255  // and footer, while packets being dropped here do not have them.
256 
258  m_macDsn++;
259 
261  {
262  // Note, this is just testing maximum theoretical frame size per the spec
263  // The frame could still be too large once headers are put on
264  // in which case the phy will reject it instead
265  NS_LOG_ERROR (this << " packet too big: " << p->GetSize ());
266  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
268  {
269  m_mcpsDataConfirmCallback (confirmParams);
270  }
271  return;
272  }
273 
274  if ((params.m_srcAddrMode == NO_PANID_ADDR)
275  && (params.m_dstAddrMode == NO_PANID_ADDR))
276  {
277  NS_LOG_ERROR (this << " Can not send packet with no Address field" );
278  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
280  {
281  m_mcpsDataConfirmCallback (confirmParams);
282  }
283  return;
284  }
285  switch (params.m_srcAddrMode)
286  {
287  case NO_PANID_ADDR:
288  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
289  macHdr.SetNoPanIdComp ();
290  break;
291  case ADDR_MODE_RESERVED:
292  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
293  break;
294  case SHORT_ADDR:
295  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
296  macHdr.SetSrcAddrFields (GetPanId (), GetShortAddress ());
297  break;
298  case EXT_ADDR:
299  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
300  macHdr.SetSrcAddrFields (GetPanId (), GetExtendedAddress ());
301  break;
302  default:
303  NS_LOG_ERROR (this << " Can not send packet with incorrect Source Address mode = " << params.m_srcAddrMode);
304  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
306  {
307  m_mcpsDataConfirmCallback (confirmParams);
308  }
309  return;
310  }
311 
312  macHdr.SetDstAddrMode (params.m_dstAddrMode);
313  // TODO: Add field for EXT_ADDR destination address (and use it here).
314  macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstAddr);
315  macHdr.SetSecDisable ();
316  //extract the last 3 bits in TxOptions and map to macHdr
317  int b0 = params.m_txOptions & TX_OPTION_ACK;
318  int b1 = params.m_txOptions & TX_OPTION_GTS;
319  int b2 = params.m_txOptions & TX_OPTION_INDIRECT;
320  if (b0 == TX_OPTION_ACK)
321  {
322  // Set AckReq bit only if the destination is not the broadcast address.
323  if (!(macHdr.GetDstAddrMode () == SHORT_ADDR && macHdr.GetShortDstAddr () == "ff:ff"))
324  {
325  macHdr.SetAckReq ();
326  }
327  }
328  else if (b0 == 0)
329  {
330  macHdr.SetNoAckReq ();
331  }
332  else
333  {
335  NS_LOG_ERROR (this << "Incorrect TxOptions bit 0 not 0/1");
337  {
338  m_mcpsDataConfirmCallback (confirmParams);
339  }
340  return;
341  }
342 
343  //if is Slotted CSMA means its beacon enabled
344  if (m_csmaCa->IsSlottedCsmaCa ())
345  {
346  if (b1 == TX_OPTION_GTS)
347  {
348  //TODO:GTS Transmission
349  }
350  else if (b1 == 0)
351  {
352  //TODO:CAP Transmission
353  }
354  else
355  {
356  NS_LOG_ERROR (this << "Incorrect TxOptions bit 1 not 0/1");
359  {
360  m_mcpsDataConfirmCallback (confirmParams);
361  }
362  return;
363  }
364  }
365  else
366  {
367  if (b1 != 0)
368  {
369  NS_LOG_ERROR (this << "for non-beacon-enables PAN, bit 1 should always be set to 0");
372  {
373  m_mcpsDataConfirmCallback (confirmParams);
374  }
375  return;
376  }
377  }
378 
379  if (b2 == TX_OPTION_INDIRECT)
380  {
381  //TODO :indirect tx
382  }
383  else if (b2 == 0)
384  {
385  //TODO :direct tx
386  }
387  else
388  {
389  NS_LOG_ERROR (this << "Incorrect TxOptions bit 2 not 0/1");
392  {
393  m_mcpsDataConfirmCallback (confirmParams);
394  }
395  return;
396  }
397 
398  p->AddHeader (macHdr);
399 
400  LrWpanMacTrailer macTrailer;
401  // Calculate FCS if the global attribute ChecksumEnable is set.
402  if (Node::ChecksumEnabled ())
403  {
404  macTrailer.EnableFcs (true);
405  macTrailer.SetFcs (p);
406  }
407  p->AddTrailer (macTrailer);
408 
410 
411  TxQueueElement *txQElement = new TxQueueElement;
412  txQElement->txQMsduHandle = params.m_msduHandle;
413  txQElement->txQPkt = p;
414  m_txQueue.push_back (txQElement);
415 
416  CheckQueue ();
417 }
418 
419 void
421 {
422  NS_LOG_FUNCTION (this);
423 
424  // Pull a packet from the queue and start sending, if we are not already sending.
425  if (m_lrWpanMacState == MAC_IDLE && !m_txQueue.empty () && m_txPkt == 0 && !m_setMacState.IsRunning ())
426  {
427  TxQueueElement *txQElement = m_txQueue.front ();
428  m_txPkt = txQElement->txQPkt;
430  }
431 }
432 
433 void
435 {
436  m_csmaCa = csmaCa;
437 }
438 
439 void
441 {
442  m_phy = phy;
443 }
444 
447 {
448  return m_phy;
449 }
450 
451 void
453 {
455 }
456 
457 void
459 {
461 }
462 
463 void
464 LrWpanMac::PdDataIndication (uint32_t psduLength, Ptr<Packet> p, uint8_t lqi)
465 {
467 
468  NS_LOG_FUNCTION (this << psduLength << p << lqi);
469 
470  bool acceptFrame;
471 
472  // from sec 7.5.6.2 Reception and rejection, Std802.15.4-2006
473  // level 1 filtering, test FCS field and reject if frame fails
474  // level 2 filtering if promiscuous mode pass frame to higher layer otherwise perform level 3 filtering
475  // level 3 filtering accept frame
476  // if Frame type and version is not reserved, and
477  // if there is a dstPanId then dstPanId=m_macPanId or broadcastPanI, and
478  // if there is a shortDstAddr then shortDstAddr =shortMacAddr or broadcastAddr, and
479  // if beacon frame then srcPanId = m_macPanId
480  // if only srcAddr field in Data or Command frame,accept frame if srcPanId=m_macPanId
481 
482  Ptr<Packet> originalPkt = p->Copy (); // because we will strip headers
483 
484  m_promiscSnifferTrace (originalPkt);
485 
486  m_macPromiscRxTrace (originalPkt);
487  // XXX no rejection tracing (to macRxDropTrace) being performed below
488 
489  LrWpanMacTrailer receivedMacTrailer;
490  p->RemoveTrailer (receivedMacTrailer);
491  if (Node::ChecksumEnabled ())
492  {
493  receivedMacTrailer.EnableFcs (true);
494  }
495 
496  // level 1 filtering
497  if (!receivedMacTrailer.CheckFcs (p))
498  {
499  m_macRxDropTrace (originalPkt);
500  }
501  else
502  {
503  LrWpanMacHeader receivedMacHdr;
504  p->RemoveHeader (receivedMacHdr);
505 
507  params.m_dsn = receivedMacHdr.GetSeqNum ();
508  params.m_mpduLinkQuality = lqi;
509  params.m_srcPanId = receivedMacHdr.GetSrcPanId ();
510  params.m_srcAddrMode = receivedMacHdr.GetSrcAddrMode ();
511  // TODO: Add field for EXT_ADDR source address.
512  if (params.m_srcAddrMode == SHORT_ADDR)
513  {
514  params.m_srcAddr = receivedMacHdr.GetShortSrcAddr ();
515  }
516  params.m_dstPanId = receivedMacHdr.GetDstPanId ();
517  params.m_dstAddrMode = receivedMacHdr.GetDstAddrMode ();
518  // TODO: Add field for EXT_ADDR destination address.
519  if (params.m_dstAddrMode == SHORT_ADDR)
520  {
521  params.m_dstAddr = receivedMacHdr.GetShortDstAddr ();
522  }
523 
524  NS_LOG_DEBUG ("Packet from " << params.m_srcAddr << " to " << params.m_dstAddr);
525 
527  {
528  //level 2 filtering
530  {
531  NS_LOG_DEBUG ("promiscuous mode, forwarding up");
532  m_mcpsDataIndicationCallback (params, p);
533  }
534  else
535  {
536  NS_LOG_ERROR (this << " Data Indication Callback not initialised");
537  }
538  }
539  else
540  {
541  //level 3 frame filtering
542  acceptFrame = (receivedMacHdr.GetType () != LrWpanMacHeader::LRWPAN_MAC_RESERVED);
543 
544  if (acceptFrame)
545  {
546  acceptFrame = (receivedMacHdr.GetFrameVer () <= 1);
547  }
548 
549  if (acceptFrame
550  && (receivedMacHdr.GetDstAddrMode () > 1))
551  {
552  acceptFrame = receivedMacHdr.GetDstPanId () == m_macPanId
553  || receivedMacHdr.GetDstPanId () == 0xffff;
554  }
555 
556  if (acceptFrame
557  && (receivedMacHdr.GetDstAddrMode () == 2))
558  {
559  acceptFrame = receivedMacHdr.GetShortDstAddr () == m_shortAddress
560  || receivedMacHdr.GetShortDstAddr () == Mac16Address ("ff:ff"); // check for broadcast addrs
561  }
562 
563  if (acceptFrame
564  && (receivedMacHdr.GetDstAddrMode () == 3))
565  {
566  acceptFrame = (receivedMacHdr.GetExtDstAddr () == m_selfExt);
567  }
568 
569  if (acceptFrame
570  && (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_BEACON))
571  {
572  if (m_macPanId == 0xffff)
573  {
574  // TODO: Accept only if the frame version field is valid
575  acceptFrame = true;
576  }
577  else
578  {
579  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId;
580  }
581  }
582 
583  if (acceptFrame
584  && ((receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_DATA)
585  || (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_COMMAND))
586  && (receivedMacHdr.GetSrcAddrMode () > 1))
587  {
588  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId; // \todo need to check if PAN coord
589  }
590 
591  if (acceptFrame)
592  {
593  m_macRxTrace (originalPkt);
594  // \todo: What should we do if we receive a frame while waiting for an ACK?
595  // Especially if this frame has the ACK request bit set, should we reply with an ACK, possibly missing the pending ACK?
596 
597  // If the received frame is a frame with the ACK request bit set, we immediately send back an ACK.
598  // If we are currently waiting for a pending ACK, we assume the ACK was lost and trigger a retransmission after sending the ACK.
599  if ((receivedMacHdr.IsData () || receivedMacHdr.IsCommand ()) && receivedMacHdr.IsAckReq ()
600  && !(receivedMacHdr.GetDstAddrMode () == SHORT_ADDR && receivedMacHdr.GetShortDstAddr () == "ff:ff"))
601  {
602  // If this is a data or mac command frame, which is not a broadcast,
603  // with ack req set, generate and send an ack frame.
604  // If there is a CSMA medium access in progress we cancel the medium access
605  // for sending the ACK frame. A new transmission attempt will be started
606  // after the ACK was send.
608  {
611  }
612  else if (m_lrWpanMacState == MAC_CSMA)
613  {
614  // \todo: If we receive a packet while doing CSMA/CA, should we drop the packet because of channel busy,
615  // or should we restart CSMA/CA for the packet after sending the ACK?
616  // Currently we simply restart CSMA/CA after sending the ACK.
617  m_csmaCa->Cancel ();
618  }
619  // Cancel any pending MAC state change, ACKs have higher priority.
623  }
624 
625  if (receivedMacHdr.IsData () && !m_mcpsDataIndicationCallback.IsNull ())
626  {
627  // If it is a data frame, push it up the stack.
628  NS_LOG_DEBUG ("PdDataIndication(): Packet is for me; forwarding up");
629  m_mcpsDataIndicationCallback (params, p);
630  }
631  else if (receivedMacHdr.IsAcknowledgment () && m_txPkt && m_lrWpanMacState == MAC_ACK_PENDING)
632  {
633  LrWpanMacHeader macHdr;
634  m_txPkt->PeekHeader (macHdr);
635  if (receivedMacHdr.GetSeqNum () == macHdr.GetSeqNum ())
636  {
638  // If it is an ACK with the expected sequence number, finish the transmission
639  // and notify the upper layer.
642  {
643  TxQueueElement *txQElement = m_txQueue.front ();
644  McpsDataConfirmParams confirmParams;
645  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
646  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
647  m_mcpsDataConfirmCallback (confirmParams);
648  }
652  }
653  else
654  {
655  // 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)
657  if (!PrepareRetransmission ())
658  {
661  }
662  else
663  {
666  }
667  }
668  }
669  }
670  else
671  {
672  m_macRxDropTrace (originalPkt);
673  }
674  }
675  }
676 }
677 
678 void
679 LrWpanMac::SendAck (uint8_t seqno)
680 {
681  NS_LOG_FUNCTION (this << static_cast<uint32_t> (seqno));
682 
684 
685  // Generate a corresponding ACK Frame.
687  LrWpanMacTrailer macTrailer;
688  Ptr<Packet> ackPacket = Create<Packet> (0);
689  ackPacket->AddHeader (macHdr);
690  // Calculate FCS if the global attribute ChecksumEnable is set.
691  if (Node::ChecksumEnabled ())
692  {
693  macTrailer.EnableFcs (true);
694  macTrailer.SetFcs (ackPacket);
695  }
696  ackPacket->AddTrailer (macTrailer);
697 
698  // Enqueue the ACK packet for further processing
699  // when the transmitter is activated.
700  m_txPkt = ackPacket;
701 
702  // Switch transceiver to TX mode. Proceed sending the Ack on confirm.
704  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
705 }
706 
707 void
709 {
710  TxQueueElement *txQElement = m_txQueue.front ();
711  Ptr<const Packet> p = txQElement->txQPkt;
712  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
713 
714  Ptr<Packet> pkt = p->Copy ();
715  LrWpanMacHeader hdr;
716  pkt->RemoveHeader (hdr);
717  if (hdr.GetShortDstAddr () != Mac16Address ("ff:ff"))
718  {
720  }
721 
722  txQElement->txQPkt = 0;
723  delete txQElement;
724  m_txQueue.pop_front ();
725  m_txPkt = 0;
726  m_retransmission = 0;
727  m_numCsmacaRetry = 0;
729 }
730 
731 void
733 {
734  NS_LOG_FUNCTION (this);
735 
736  // TODO: If we are a PAN coordinator and this was an indirect transmission,
737  // we will not initiate a retransmission. Instead we wait for the data
738  // being extracted after a new data request command.
739  if (!PrepareRetransmission ())
740  {
742  }
743  else
744  {
746  }
747 }
748 
749 bool
751 {
752  NS_LOG_FUNCTION (this);
753 
755  {
756  // Maximum number of retransmissions has been reached.
757  // remove the copy of the packet that was just sent
758  TxQueueElement *txQElement = m_txQueue.front ();
759  m_macTxDropTrace (txQElement->txQPkt);
761  {
762  McpsDataConfirmParams confirmParams;
763  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
764  confirmParams.m_status = IEEE_802_15_4_NO_ACK;
765  m_mcpsDataConfirmCallback (confirmParams);
766  }
768  return false;
769  }
770  else
771  {
773  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
774  // Start next CCA process for this packet.
775  return true;
776  }
777 }
778 
779 void
781 {
783 
784  NS_LOG_FUNCTION (this << status << m_txQueue.size ());
785 
786  LrWpanMacHeader macHdr;
787  m_txPkt->PeekHeader (macHdr);
788  if (status == IEEE_802_15_4_PHY_SUCCESS)
789  {
790  if (!macHdr.IsAcknowledgment ())
791  {
792  // We have just send a regular data packet, check if we have to wait
793  // for an ACK.
794  if (macHdr.IsAckReq ())
795  {
796  // wait for the ack or the next retransmission timeout
797  // start retransmission timer
798  Time waitTime = MicroSeconds (GetMacAckWaitDuration () * 1000 * 1000 / m_phy->GetDataOrSymbolRate (false));
803  return;
804  }
805  else
806  {
808  // remove the copy of the packet that was just sent
810  {
811  McpsDataConfirmParams confirmParams;
812  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
813  TxQueueElement *txQElement = m_txQueue.front ();
814  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
815  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
816  m_mcpsDataConfirmCallback (confirmParams);
817  }
819  }
820  }
821  else
822  {
823  // We have send an ACK. Clear the packet buffer.
824  m_txPkt = 0;
825  }
826  }
827  else if (status == IEEE_802_15_4_PHY_UNSPECIFIED)
828  {
829 
830  if (!macHdr.IsAcknowledgment ())
831  {
832  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
833  TxQueueElement *txQElement = m_txQueue.front ();
834  m_macTxDropTrace (txQElement->txQPkt);
836  {
837  McpsDataConfirmParams confirmParams;
838  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
839  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
840  m_mcpsDataConfirmCallback (confirmParams);
841  }
843  }
844  else
845  {
846  NS_LOG_ERROR ("Unable to send ACK");
847  }
848  }
849  else
850  {
851  // Something went really wrong. The PHY is not in the correct state for
852  // data transmission.
853  NS_FATAL_ERROR ("Transmission attempt failed with PHY status " << status);
854  }
855 
858 }
859 
860 void
862 {
863  NS_LOG_FUNCTION (this << status);
864  // Direct this call through the csmaCa object
865  m_csmaCa->PlmeCcaConfirm (status);
866 }
867 
868 void
869 LrWpanMac::PlmeEdConfirm (LrWpanPhyEnumeration status, uint8_t energyLevel)
870 {
871  NS_LOG_FUNCTION (this << status << energyLevel);
872 
873 }
874 
875 void
878  LrWpanPhyPibAttributes* attribute)
879 {
880  NS_LOG_FUNCTION (this << status << id << attribute);
881 }
882 
883 void
885 {
886  NS_LOG_FUNCTION (this << status);
887 
889  {
890  NS_ASSERT (m_txPkt);
891 
892  // Start sending if we are in state SENDING and the PHY transmitter was enabled.
896  m_phy->PdDataRequest (m_txPkt->GetSize (), m_txPkt);
897  }
898  else if (m_lrWpanMacState == MAC_CSMA && (status == IEEE_802_15_4_PHY_RX_ON || status == IEEE_802_15_4_PHY_SUCCESS))
899  {
900  // Start the CSMA algorithm as soon as the receiver is enabled.
901  m_csmaCa->Start ();
902  }
903  else if (m_lrWpanMacState == MAC_IDLE)
904  {
906  // Do nothing special when going idle.
907  }
908  else if (m_lrWpanMacState == MAC_ACK_PENDING)
909  {
911  }
912  else
913  {
914  // TODO: What to do when we receive an error?
915  // If we want to transmit a packet, but switching the transceiver on results
916  // in an error, we have to recover somehow (and start sending again).
917  NS_FATAL_ERROR ("Error changing transceiver state");
918  }
919 }
920 
921 void
924 {
925  NS_LOG_FUNCTION (this << status << id);
926 }
927 
928 void
930 {
931  NS_LOG_FUNCTION (this << "mac state = " << macState);
932 
933  McpsDataConfirmParams confirmParams;
934 
935  if (macState == MAC_IDLE)
936  {
938 
939  if (m_macRxOnWhenIdle)
940  {
941  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
942  }
943  else
944  {
945  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
946  }
947 
948  CheckQueue ();
949  }
950  else if (macState == MAC_ACK_PENDING)
951  {
953  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
954  }
955  else if (macState == MAC_CSMA)
956  {
958 
960  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
961  }
962  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_IDLE)
963  {
964  // Channel is idle, set transmitter to TX_ON
966  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
967  }
968  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_ACCESS_FAILURE)
969  {
970  NS_ASSERT (m_txPkt);
971 
972  // cannot find a clear channel, drop the current packet.
973  NS_LOG_DEBUG ( this << " cannot find clear channel");
974  confirmParams.m_msduHandle = m_txQueue.front ()->txQMsduHandle;
978  {
979  m_mcpsDataConfirmCallback (confirmParams);
980  }
981  // remove the copy of the packet that was just sent
983 
985  }
986 }
987 
990 {
991  return m_associationStatus;
992 }
993 
994 void
996 {
997  m_associationStatus = status;
998 }
999 
1000 uint16_t
1002 {
1003  return m_macPanId;
1004 }
1005 
1006 void
1007 LrWpanMac::SetPanId (uint16_t panId)
1008 {
1009  m_macPanId = panId;
1010 }
1011 
1012 void
1014 {
1015  NS_LOG_LOGIC (this << " change lrwpan mac state from "
1016  << m_lrWpanMacState << " to "
1017  << newState);
1018  m_macStateLogger (m_lrWpanMacState, newState);
1019  m_lrWpanMacState = newState;
1020 }
1021 
1022 uint64_t
1024 {
1025  return m_csmaCa->GetUnitBackoffPeriod () + m_phy->aTurnaroundTime + m_phy->GetPhySHRDuration ()
1026  + ceil (6 * m_phy->GetPhySymbolsPerOctet ());
1027 }
1028 
1029 uint8_t
1031 {
1032  return m_macMaxFrameRetries;
1033 }
1034 
1035 void
1037 {
1038  m_macMaxFrameRetries = retries;
1039 }
1040 
1041 } // 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:102
void CheckQueue(void)
Check the transmission queue.
Definition: lr-wpan-mac.cc:420
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Class that implements the LR-WPAN Mac state machine.
Definition: lr-wpan-mac.h:204
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:876
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:708
virtual ~LrWpanMac(void)
Definition: lr-wpan-mac.cc:151
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:989
static bool ChecksumEnabled(void)
Definition: node.cc:269
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:1078
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:67
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:339
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
virtual void DoDispose(void)
Destructor implementation.
Definition: lr-wpan-mac.cc:171
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:218
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:458
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:246
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:193
void SetLrWpanMacState(LrWpanMacState macState)
CSMA-CA algorithm calls back the MAC after executing channel assessment.
Definition: lr-wpan-mac.cc:929
Mac64Address GetExtendedAddress(void) const
Get the extended address of this MAC.
Definition: lr-wpan-mac.cc:240
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:869
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:750
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
Definition: lr-wpan-mac.cc:861
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:780
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:440
#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:464
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:199
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:127
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:225
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:90
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:233
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:882
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:884
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:679
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:732
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:446
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:57
TypeId SetParent(TypeId tid)
Definition: type-id.cc:638
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaCa)
Set the CSMA/CA implementation to be used by the MAC.
Definition: lr-wpan-mac.cc:434
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:922
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lr-wpan-mac.cc:156
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:346
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:995
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:452