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 ("MacStateValue",
115  "The state of LrWpan Mac",
117  "ns3::TracedValueCallback::LrWpanMacState")
118  .AddTraceSource ("MacState",
119  "The state of LrWpan Mac",
121  "ns3::LrWpanMac::StateTracedCallback")
122  .AddTraceSource ("MacSentPkt",
123  "Trace source reporting some information about "
124  "the sent packet",
126  "ns3::LrWpanMac::SentTracedCallback")
127  ;
128  return tid;
129 }
130 
132 {
133 
134  // First set the state to a known value, call ChangeMacState to fire trace source.
137 
138  m_macRxOnWhenIdle = true;
139  m_macPanId = 0;
142  m_macPromiscuousMode = false;
144  m_retransmission = 0;
145  m_numCsmacaRetry = 0;
146  m_txPkt = 0;
147 
148  Ptr<UniformRandomVariable> uniformVar = CreateObject<UniformRandomVariable> ();
149  uniformVar->SetAttribute ("Min", DoubleValue (0.0));
150  uniformVar->SetAttribute ("Max", DoubleValue (255.0));
151  m_macDsn = SequenceNumber8 (uniformVar->GetValue ());
152  m_shortAddress = Mac16Address ("00:00");
153 }
154 
156 {
157 }
158 
159 void
161 {
162  if (m_macRxOnWhenIdle)
163  {
164  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
165  }
166  else
167  {
168  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
169  }
170 
172 }
173 
174 void
176 {
177  if (m_csmaCa != 0)
178  {
179  m_csmaCa->Dispose ();
180  m_csmaCa = 0;
181  }
182  m_txPkt = 0;
183  for (uint32_t i = 0; i < m_txQueue.size (); i++)
184  {
185  m_txQueue[i]->txQPkt = 0;
186  delete m_txQueue[i];
187  }
188  m_txQueue.clear ();
189  m_phy = 0;
190  m_mcpsDataIndicationCallback = MakeNullCallback< void, McpsDataIndicationParams, Ptr<Packet> > ();
191  m_mcpsDataConfirmCallback = MakeNullCallback< void, McpsDataConfirmParams > ();
192 
194 }
195 
196 bool
198 {
199  return m_macRxOnWhenIdle;
200 }
201 
202 void
203 LrWpanMac::SetRxOnWhenIdle (bool rxOnWhenIdle)
204 {
205  NS_LOG_FUNCTION (this << rxOnWhenIdle);
206  m_macRxOnWhenIdle = rxOnWhenIdle;
207 
208  if (m_lrWpanMacState == MAC_IDLE)
209  {
210  if (m_macRxOnWhenIdle)
211  {
212  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
213  }
214  else
215  {
216  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
217  }
218  }
219 }
220 
221 void
223 {
224  //NS_LOG_FUNCTION (this << address);
226 }
227 
228 void
230 {
231  //NS_LOG_FUNCTION (this << address);
232  m_selfExt = address;
233 }
234 
235 
238 {
239  NS_LOG_FUNCTION (this);
240  return m_shortAddress;
241 }
242 
245 {
246  NS_LOG_FUNCTION (this);
247  return m_selfExt;
248 }
249 void
251 {
252  NS_LOG_FUNCTION (this << p);
253 
254  McpsDataConfirmParams confirmParams;
255  confirmParams.m_msduHandle = params.m_msduHandle;
256 
257  // TODO: We need a drop trace for the case that the packet is too large or the request parameters are maleformed.
258  // The current tx drop trace is not suitable, because packets dropped using this trace carry the mac header
259  // and footer, while packets being dropped here do not have them.
260 
262  m_macDsn++;
263 
265  {
266  // Note, this is just testing maximum theoretical frame size per the spec
267  // The frame could still be too large once headers are put on
268  // in which case the phy will reject it instead
269  NS_LOG_ERROR (this << " packet too big: " << p->GetSize ());
270  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
272  {
273  m_mcpsDataConfirmCallback (confirmParams);
274  }
275  return;
276  }
277 
278  if ((params.m_srcAddrMode == NO_PANID_ADDR)
279  && (params.m_dstAddrMode == NO_PANID_ADDR))
280  {
281  NS_LOG_ERROR (this << " Can not send packet with no Address field" );
282  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
284  {
285  m_mcpsDataConfirmCallback (confirmParams);
286  }
287  return;
288  }
289  switch (params.m_srcAddrMode)
290  {
291  case NO_PANID_ADDR:
292  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
293  macHdr.SetNoPanIdComp ();
294  break;
295  case ADDR_MODE_RESERVED:
296  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
297  break;
298  case SHORT_ADDR:
299  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
300  macHdr.SetSrcAddrFields (GetPanId (), GetShortAddress ());
301  break;
302  case EXT_ADDR:
303  macHdr.SetSrcAddrMode (params.m_srcAddrMode);
304  macHdr.SetSrcAddrFields (GetPanId (), GetExtendedAddress ());
305  break;
306  default:
307  NS_LOG_ERROR (this << " Can not send packet with incorrect Source Address mode = " << params.m_srcAddrMode);
308  confirmParams.m_status = IEEE_802_15_4_INVALID_ADDRESS;
310  {
311  m_mcpsDataConfirmCallback (confirmParams);
312  }
313  return;
314  }
315 
316  macHdr.SetDstAddrMode (params.m_dstAddrMode);
317  // TODO: Add field for EXT_ADDR destination address (and use it here).
318  macHdr.SetDstAddrFields (params.m_dstPanId, params.m_dstAddr);
319  macHdr.SetSecDisable ();
320  //extract the last 3 bits in TxOptions and map to macHdr
321  int b0 = params.m_txOptions & TX_OPTION_ACK;
322  int b1 = params.m_txOptions & TX_OPTION_GTS;
323  int b2 = params.m_txOptions & TX_OPTION_INDIRECT;
324  if (b0 == TX_OPTION_ACK)
325  {
326  // Set AckReq bit only if the destination is not the broadcast address.
327  if (!(macHdr.GetDstAddrMode () == SHORT_ADDR && macHdr.GetShortDstAddr () == "ff:ff"))
328  {
329  macHdr.SetAckReq ();
330  }
331  }
332  else if (b0 == 0)
333  {
334  macHdr.SetNoAckReq ();
335  }
336  else
337  {
339  NS_LOG_ERROR (this << "Incorrect TxOptions bit 0 not 0/1");
341  {
342  m_mcpsDataConfirmCallback (confirmParams);
343  }
344  return;
345  }
346 
347  //if is Slotted CSMA means its beacon enabled
348  if (m_csmaCa->IsSlottedCsmaCa ())
349  {
350  if (b1 == TX_OPTION_GTS)
351  {
352  //TODO:GTS Transmission
353  }
354  else if (b1 == 0)
355  {
356  //TODO:CAP Transmission
357  }
358  else
359  {
360  NS_LOG_ERROR (this << "Incorrect TxOptions bit 1 not 0/1");
363  {
364  m_mcpsDataConfirmCallback (confirmParams);
365  }
366  return;
367  }
368  }
369  else
370  {
371  if (b1 != 0)
372  {
373  NS_LOG_ERROR (this << "for non-beacon-enables PAN, bit 1 should always be set to 0");
376  {
377  m_mcpsDataConfirmCallback (confirmParams);
378  }
379  return;
380  }
381  }
382 
383  if (b2 == TX_OPTION_INDIRECT)
384  {
385  //TODO :indirect tx
386  }
387  else if (b2 == 0)
388  {
389  //TODO :direct tx
390  }
391  else
392  {
393  NS_LOG_ERROR (this << "Incorrect TxOptions bit 2 not 0/1");
396  {
397  m_mcpsDataConfirmCallback (confirmParams);
398  }
399  return;
400  }
401 
402  p->AddHeader (macHdr);
403 
404  LrWpanMacTrailer macTrailer;
405  // Calculate FCS if the global attribute ChecksumEnable is set.
406  if (Node::ChecksumEnabled ())
407  {
408  macTrailer.EnableFcs (true);
409  macTrailer.SetFcs (p);
410  }
411  p->AddTrailer (macTrailer);
412 
414 
415  TxQueueElement *txQElement = new TxQueueElement;
416  txQElement->txQMsduHandle = params.m_msduHandle;
417  txQElement->txQPkt = p;
418  m_txQueue.push_back (txQElement);
419 
420  CheckQueue ();
421 }
422 
423 void
425 {
426  NS_LOG_FUNCTION (this);
427 
428  // Pull a packet from the queue and start sending, if we are not already sending.
429  if (m_lrWpanMacState == MAC_IDLE && !m_txQueue.empty () && m_txPkt == 0 && !m_setMacState.IsRunning ())
430  {
431  TxQueueElement *txQElement = m_txQueue.front ();
432  m_txPkt = txQElement->txQPkt;
434  }
435 }
436 
437 void
439 {
440  m_csmaCa = csmaCa;
441 }
442 
443 void
445 {
446  m_phy = phy;
447 }
448 
451 {
452  return m_phy;
453 }
454 
455 void
457 {
459 }
460 
461 void
463 {
465 }
466 
467 void
468 LrWpanMac::PdDataIndication (uint32_t psduLength, Ptr<Packet> p, uint8_t lqi)
469 {
471 
472  NS_LOG_FUNCTION (this << psduLength << p << lqi);
473 
474  bool acceptFrame;
475 
476  // from sec 7.5.6.2 Reception and rejection, Std802.15.4-2006
477  // level 1 filtering, test FCS field and reject if frame fails
478  // level 2 filtering if promiscuous mode pass frame to higher layer otherwise perform level 3 filtering
479  // level 3 filtering accept frame
480  // if Frame type and version is not reserved, and
481  // if there is a dstPanId then dstPanId=m_macPanId or broadcastPanI, and
482  // if there is a shortDstAddr then shortDstAddr =shortMacAddr or broadcastAddr, and
483  // if beacon frame then srcPanId = m_macPanId
484  // if only srcAddr field in Data or Command frame,accept frame if srcPanId=m_macPanId
485 
486  Ptr<Packet> originalPkt = p->Copy (); // because we will strip headers
487 
488  m_promiscSnifferTrace (originalPkt);
489 
490  m_macPromiscRxTrace (originalPkt);
491  // XXX no rejection tracing (to macRxDropTrace) being performed below
492 
493  LrWpanMacTrailer receivedMacTrailer;
494  p->RemoveTrailer (receivedMacTrailer);
495  if (Node::ChecksumEnabled ())
496  {
497  receivedMacTrailer.EnableFcs (true);
498  }
499 
500  // level 1 filtering
501  if (!receivedMacTrailer.CheckFcs (p))
502  {
503  m_macRxDropTrace (originalPkt);
504  }
505  else
506  {
507  LrWpanMacHeader receivedMacHdr;
508  p->RemoveHeader (receivedMacHdr);
509 
511  params.m_dsn = receivedMacHdr.GetSeqNum ();
512  params.m_mpduLinkQuality = lqi;
513  params.m_srcPanId = receivedMacHdr.GetSrcPanId ();
514  params.m_srcAddrMode = receivedMacHdr.GetSrcAddrMode ();
515  // TODO: Add field for EXT_ADDR source address.
516  if (params.m_srcAddrMode == SHORT_ADDR)
517  {
518  params.m_srcAddr = receivedMacHdr.GetShortSrcAddr ();
519  }
520  params.m_dstPanId = receivedMacHdr.GetDstPanId ();
521  params.m_dstAddrMode = receivedMacHdr.GetDstAddrMode ();
522  // TODO: Add field for EXT_ADDR destination address.
523  if (params.m_dstAddrMode == SHORT_ADDR)
524  {
525  params.m_dstAddr = receivedMacHdr.GetShortDstAddr ();
526  }
527 
528  NS_LOG_DEBUG ("Packet from " << params.m_srcAddr << " to " << params.m_dstAddr);
529 
531  {
532  //level 2 filtering
534  {
535  NS_LOG_DEBUG ("promiscuous mode, forwarding up");
536  m_mcpsDataIndicationCallback (params, p);
537  }
538  else
539  {
540  NS_LOG_ERROR (this << " Data Indication Callback not initialised");
541  }
542  }
543  else
544  {
545  //level 3 frame filtering
546  acceptFrame = (receivedMacHdr.GetType () != LrWpanMacHeader::LRWPAN_MAC_RESERVED);
547 
548  if (acceptFrame)
549  {
550  acceptFrame = (receivedMacHdr.GetFrameVer () <= 1);
551  }
552 
553  if (acceptFrame
554  && (receivedMacHdr.GetDstAddrMode () > 1))
555  {
556  acceptFrame = receivedMacHdr.GetDstPanId () == m_macPanId
557  || receivedMacHdr.GetDstPanId () == 0xffff;
558  }
559 
560  if (acceptFrame
561  && (receivedMacHdr.GetDstAddrMode () == 2))
562  {
563  acceptFrame = receivedMacHdr.GetShortDstAddr () == m_shortAddress
564  || receivedMacHdr.GetShortDstAddr () == Mac16Address ("ff:ff"); // check for broadcast addrs
565  }
566 
567  if (acceptFrame
568  && (receivedMacHdr.GetDstAddrMode () == 3))
569  {
570  acceptFrame = (receivedMacHdr.GetExtDstAddr () == m_selfExt);
571  }
572 
573  if (acceptFrame
574  && (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_BEACON))
575  {
576  if (m_macPanId == 0xffff)
577  {
578  // TODO: Accept only if the frame version field is valid
579  acceptFrame = true;
580  }
581  else
582  {
583  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId;
584  }
585  }
586 
587  if (acceptFrame
588  && ((receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_DATA)
589  || (receivedMacHdr.GetType () == LrWpanMacHeader::LRWPAN_MAC_COMMAND))
590  && (receivedMacHdr.GetSrcAddrMode () > 1))
591  {
592  acceptFrame = receivedMacHdr.GetSrcPanId () == m_macPanId; // \todo need to check if PAN coord
593  }
594 
595  if (acceptFrame)
596  {
597  m_macRxTrace (originalPkt);
598  // \todo: What should we do if we receive a frame while waiting for an ACK?
599  // Especially if this frame has the ACK request bit set, should we reply with an ACK, possibly missing the pending ACK?
600 
601  // If the received frame is a frame with the ACK request bit set, we immediately send back an ACK.
602  // If we are currently waiting for a pending ACK, we assume the ACK was lost and trigger a retransmission after sending the ACK.
603  if ((receivedMacHdr.IsData () || receivedMacHdr.IsCommand ()) && receivedMacHdr.IsAckReq ()
604  && !(receivedMacHdr.GetDstAddrMode () == SHORT_ADDR && receivedMacHdr.GetShortDstAddr () == "ff:ff"))
605  {
606  // If this is a data or mac command frame, which is not a broadcast,
607  // with ack req set, generate and send an ack frame.
608  // If there is a CSMA medium access in progress we cancel the medium access
609  // for sending the ACK frame. A new transmission attempt will be started
610  // after the ACK was send.
612  {
615  }
616  else if (m_lrWpanMacState == MAC_CSMA)
617  {
618  // \todo: If we receive a packet while doing CSMA/CA, should we drop the packet because of channel busy,
619  // or should we restart CSMA/CA for the packet after sending the ACK?
620  // Currently we simply restart CSMA/CA after sending the ACK.
621  m_csmaCa->Cancel ();
622  }
623  // Cancel any pending MAC state change, ACKs have higher priority.
627  }
628 
629  if (receivedMacHdr.IsData () && !m_mcpsDataIndicationCallback.IsNull ())
630  {
631  // If it is a data frame, push it up the stack.
632  NS_LOG_DEBUG ("PdDataIndication(): Packet is for me; forwarding up");
633  m_mcpsDataIndicationCallback (params, p);
634  }
635  else if (receivedMacHdr.IsAcknowledgment () && m_txPkt && m_lrWpanMacState == MAC_ACK_PENDING)
636  {
637  LrWpanMacHeader macHdr;
638  m_txPkt->PeekHeader (macHdr);
639  if (receivedMacHdr.GetSeqNum () == macHdr.GetSeqNum ())
640  {
642  // If it is an ACK with the expected sequence number, finish the transmission
643  // and notify the upper layer.
646  {
647  TxQueueElement *txQElement = m_txQueue.front ();
648  McpsDataConfirmParams confirmParams;
649  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
650  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
651  m_mcpsDataConfirmCallback (confirmParams);
652  }
656  }
657  else
658  {
659  // 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)
661  if (!PrepareRetransmission ())
662  {
665  }
666  else
667  {
670  }
671  }
672  }
673  }
674  else
675  {
676  m_macRxDropTrace (originalPkt);
677  }
678  }
679  }
680 }
681 
682 void
683 LrWpanMac::SendAck (uint8_t seqno)
684 {
685  NS_LOG_FUNCTION (this << static_cast<uint32_t> (seqno));
686 
688 
689  // Generate a corresponding ACK Frame.
691  LrWpanMacTrailer macTrailer;
692  Ptr<Packet> ackPacket = Create<Packet> (0);
693  ackPacket->AddHeader (macHdr);
694  // Calculate FCS if the global attribute ChecksumEnable is set.
695  if (Node::ChecksumEnabled ())
696  {
697  macTrailer.EnableFcs (true);
698  macTrailer.SetFcs (ackPacket);
699  }
700  ackPacket->AddTrailer (macTrailer);
701 
702  // Enqueue the ACK packet for further processing
703  // when the transmitter is activated.
704  m_txPkt = ackPacket;
705 
706  // Switch transceiver to TX mode. Proceed sending the Ack on confirm.
708  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
709 }
710 
711 void
713 {
714  TxQueueElement *txQElement = m_txQueue.front ();
715  Ptr<const Packet> p = txQElement->txQPkt;
716  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
717 
718  Ptr<Packet> pkt = p->Copy ();
719  LrWpanMacHeader hdr;
720  pkt->RemoveHeader (hdr);
721  if (hdr.GetShortDstAddr () != Mac16Address ("ff:ff"))
722  {
724  }
725 
726  txQElement->txQPkt = 0;
727  delete txQElement;
728  m_txQueue.pop_front ();
729  m_txPkt = 0;
730  m_retransmission = 0;
731  m_numCsmacaRetry = 0;
733 }
734 
735 void
737 {
738  NS_LOG_FUNCTION (this);
739 
740  // TODO: If we are a PAN coordinator and this was an indirect transmission,
741  // we will not initiate a retransmission. Instead we wait for the data
742  // being extracted after a new data request command.
743  if (!PrepareRetransmission ())
744  {
746  }
747  else
748  {
750  }
751 }
752 
753 bool
755 {
756  NS_LOG_FUNCTION (this);
757 
759  {
760  // Maximum number of retransmissions has been reached.
761  // remove the copy of the packet that was just sent
762  TxQueueElement *txQElement = m_txQueue.front ();
763  m_macTxDropTrace (txQElement->txQPkt);
765  {
766  McpsDataConfirmParams confirmParams;
767  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
768  confirmParams.m_status = IEEE_802_15_4_NO_ACK;
769  m_mcpsDataConfirmCallback (confirmParams);
770  }
772  return false;
773  }
774  else
775  {
777  m_numCsmacaRetry += m_csmaCa->GetNB () + 1;
778  // Start next CCA process for this packet.
779  return true;
780  }
781 }
782 
783 void
785 {
787 
788  NS_LOG_FUNCTION (this << status << m_txQueue.size ());
789 
790  LrWpanMacHeader macHdr;
791  m_txPkt->PeekHeader (macHdr);
792  if (status == IEEE_802_15_4_PHY_SUCCESS)
793  {
794  if (!macHdr.IsAcknowledgment ())
795  {
796  // We have just send a regular data packet, check if we have to wait
797  // for an ACK.
798  if (macHdr.IsAckReq ())
799  {
800  // wait for the ack or the next retransmission timeout
801  // start retransmission timer
802  Time waitTime = MicroSeconds (GetMacAckWaitDuration () * 1000 * 1000 / m_phy->GetDataOrSymbolRate (false));
807  return;
808  }
809  else
810  {
812  // remove the copy of the packet that was just sent
814  {
815  McpsDataConfirmParams confirmParams;
816  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
817  TxQueueElement *txQElement = m_txQueue.front ();
818  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
819  confirmParams.m_status = IEEE_802_15_4_SUCCESS;
820  m_mcpsDataConfirmCallback (confirmParams);
821  }
823  }
824  }
825  else
826  {
827  // We have send an ACK. Clear the packet buffer.
828  m_txPkt = 0;
829  }
830  }
831  else if (status == IEEE_802_15_4_PHY_UNSPECIFIED)
832  {
833 
834  if (!macHdr.IsAcknowledgment ())
835  {
836  NS_ASSERT_MSG (m_txQueue.size () > 0, "TxQsize = 0");
837  TxQueueElement *txQElement = m_txQueue.front ();
838  m_macTxDropTrace (txQElement->txQPkt);
840  {
841  McpsDataConfirmParams confirmParams;
842  confirmParams.m_msduHandle = txQElement->txQMsduHandle;
843  confirmParams.m_status = IEEE_802_15_4_FRAME_TOO_LONG;
844  m_mcpsDataConfirmCallback (confirmParams);
845  }
847  }
848  else
849  {
850  NS_LOG_ERROR ("Unable to send ACK");
851  }
852  }
853  else
854  {
855  // Something went really wrong. The PHY is not in the correct state for
856  // data transmission.
857  NS_FATAL_ERROR ("Transmission attempt failed with PHY status " << status);
858  }
859 
862 }
863 
864 void
866 {
867  NS_LOG_FUNCTION (this << status);
868  // Direct this call through the csmaCa object
869  m_csmaCa->PlmeCcaConfirm (status);
870 }
871 
872 void
873 LrWpanMac::PlmeEdConfirm (LrWpanPhyEnumeration status, uint8_t energyLevel)
874 {
875  NS_LOG_FUNCTION (this << status << energyLevel);
876 
877 }
878 
879 void
882  LrWpanPhyPibAttributes* attribute)
883 {
884  NS_LOG_FUNCTION (this << status << id << attribute);
885 }
886 
887 void
889 {
890  NS_LOG_FUNCTION (this << status);
891 
893  {
894  NS_ASSERT (m_txPkt);
895 
896  // Start sending if we are in state SENDING and the PHY transmitter was enabled.
900  m_phy->PdDataRequest (m_txPkt->GetSize (), m_txPkt);
901  }
902  else if (m_lrWpanMacState == MAC_CSMA && (status == IEEE_802_15_4_PHY_RX_ON || status == IEEE_802_15_4_PHY_SUCCESS))
903  {
904  // Start the CSMA algorithm as soon as the receiver is enabled.
905  m_csmaCa->Start ();
906  }
907  else if (m_lrWpanMacState == MAC_IDLE)
908  {
910  // Do nothing special when going idle.
911  }
912  else if (m_lrWpanMacState == MAC_ACK_PENDING)
913  {
915  }
916  else
917  {
918  // TODO: What to do when we receive an error?
919  // If we want to transmit a packet, but switching the transceiver on results
920  // in an error, we have to recover somehow (and start sending again).
921  NS_FATAL_ERROR ("Error changing transceiver state");
922  }
923 }
924 
925 void
928 {
929  NS_LOG_FUNCTION (this << status << id);
930 }
931 
932 void
934 {
935  NS_LOG_FUNCTION (this << "mac state = " << macState);
936 
937  McpsDataConfirmParams confirmParams;
938 
939  if (macState == MAC_IDLE)
940  {
942 
943  if (m_macRxOnWhenIdle)
944  {
945  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
946  }
947  else
948  {
949  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TRX_OFF);
950  }
951 
952  CheckQueue ();
953  }
954  else if (macState == MAC_ACK_PENDING)
955  {
957  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
958  }
959  else if (macState == MAC_CSMA)
960  {
962 
964  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON);
965  }
966  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_IDLE)
967  {
968  // Channel is idle, set transmitter to TX_ON
970  m_phy->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON);
971  }
972  else if (m_lrWpanMacState == MAC_CSMA && macState == CHANNEL_ACCESS_FAILURE)
973  {
974  NS_ASSERT (m_txPkt);
975 
976  // cannot find a clear channel, drop the current packet.
977  NS_LOG_DEBUG ( this << " cannot find clear channel");
978  confirmParams.m_msduHandle = m_txQueue.front ()->txQMsduHandle;
982  {
983  m_mcpsDataConfirmCallback (confirmParams);
984  }
985  // remove the copy of the packet that was just sent
987 
989  }
990 }
991 
994 {
995  return m_associationStatus;
996 }
997 
998 void
1000 {
1001  m_associationStatus = status;
1002 }
1003 
1004 uint16_t
1006 {
1007  return m_macPanId;
1008 }
1009 
1010 void
1011 LrWpanMac::SetPanId (uint16_t panId)
1012 {
1013  m_macPanId = panId;
1014 }
1015 
1016 void
1018 {
1019  NS_LOG_LOGIC (this << " change lrwpan mac state from "
1020  << m_lrWpanMacState << " to "
1021  << newState);
1022  m_macStateLogger (m_lrWpanMacState, newState);
1023  m_lrWpanMacState = newState;
1024 }
1025 
1026 uint64_t
1028 {
1029  return m_csmaCa->GetUnitBackoffPeriod () + m_phy->aTurnaroundTime + m_phy->GetPhySHRDuration ()
1030  + ceil (6 * m_phy->GetPhySymbolsPerOctet ());
1031 }
1032 
1033 uint8_t
1035 {
1036  return m_macMaxFrameRetries;
1037 }
1038 
1039 void
1041 {
1042  m_macMaxFrameRetries = retries;
1043 }
1044 
1045 } // namespace ns3
TracedValue< LrWpanMacState > m_lrWpanMacState
The current state of the MAC layer.
Definition: lr-wpan-mac.h:769
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:159
TX_OPTION_INDIRECT.
Definition: lr-wpan-mac.h:59
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void CheckQueue(void)
Check the transmission queue.
Definition: lr-wpan-mac.cc:424
#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:219
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:880
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:160
void RemoveFirstTxQElement()
Remove the tip of the transmission queue, including clean up related to the last packet transmission...
Definition: lr-wpan-mac.cc:712
virtual ~LrWpanMac(void)
Definition: lr-wpan-mac.cc:155
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:656
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:140
LrWpanAssociationStatus GetAssociationStatus(void) const
Get the current association status.
Definition: lr-wpan-mac.cc:993
static bool ChecksumEnabled(void)
Definition: node.cc:276
CHANNEL_IDLE.
Definition: lr-wpan-mac.h:74
McpsDataConfirmCallback m_mcpsDataConfirmCallback
This callback is used to report data transmission request status to the upper layers.
Definition: lr-wpan-mac.h:764
std::deque< TxQueueElement * > m_txQueue
The transmit queue used by the MAC.
Definition: lr-wpan-mac.h:797
Mac16Address m_dstAddr
Destination address.
Definition: lr-wpan-mac.h:188
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
uint8_t m_dstAddrMode
Destination address mode.
Definition: lr-wpan-mac.h:186
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_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:792
LrWpanAssociationStatus m_associationStatus
The current association status of the MAC layer.
Definition: lr-wpan-mac.h:774
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual void DoDispose(void)
Destructor implementation.
Definition: lr-wpan-mac.cc:175
TracedCallback< LrWpanMacState, LrWpanMacState > m_macStateLogger
A trace source that fires when the LrWpanMac changes states.
Definition: lr-wpan-mac.h:741
void SetShortAddress(Mac16Address address)
Set the short address of this MAC.
Definition: lr-wpan-mac.cc:222
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
Represent the Mac Header with the Frame Control and Sequence Number fields.
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:757
void SetMcpsDataConfirmCallback(McpsDataConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
Definition: lr-wpan-mac.cc:462
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:250
uint8_t m_numCsmacaRetry
The number of CSMA/CA retries used for sending the current packet.
Definition: lr-wpan-mac.h:808
Mac16Address GetShortSrcAddr(void) const
Get the Source Short address.
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:161
uint8_t m_msduHandle
MSDU handle.
Definition: lr-wpan-mac.h:172
static const uint32_t aMaxPhyPacketSize
The maximum packet size accepted by the PHY.
Definition: lr-wpan-phy.h:262
uint16_t m_dstPanId
Destination PAN identifier.
Definition: lr-wpan-mac.h:187
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:647
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:779
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:197
void SetLrWpanMacState(LrWpanMacState macState)
CSMA-CA algorithm calls back the MAC after executing channel assessment.
Definition: lr-wpan-mac.cc:933
Mac64Address GetExtendedAddress(void) const
Get the extended address of this MAC.
Definition: lr-wpan-mac.cc:244
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:873
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:731
TX_OPTION_ACK.
Definition: lr-wpan-mac.h:57
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:632
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:682
tuple phy
Definition: third.py:86
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1238
Ptr< Packet > txQPkt
Queued packet.
Definition: lr-wpan-mac.h:570
bool PrepareRetransmission(void)
Check for remaining retransmissions for the packet currently being sent.
Definition: lr-wpan-mac.cc:754
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
Definition: lr-wpan-mac.cc:865
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:814
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:664
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:819
Helper structure for managing transmission queue elements.
Definition: lr-wpan-mac.h:567
bool m_macRxOnWhenIdle
Indication of whether the MAC sublayer is to enable its receiver during idle periods.
Definition: lr-wpan-mac.h:513
MCPS-DATA.confirm params.
Definition: lr-wpan-mac.h:170
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:784
uint8_t m_txOptions
Tx Options (bitfield)
Definition: lr-wpan-mac.h:162
bool IsAckReq(void) const
Check if Ack.
uint8_t m_mpduLinkQuality
LQI value measured during reception of the MPDU.
Definition: lr-wpan-mac.h:189
void SetPhy(Ptr< LrWpanPhy > phy)
Set the underlying PHY for the MAC.
Definition: lr-wpan-mac.cc:444
#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:624
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:468
uint8_t m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:183
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
Definition: lr-wpan-mac.h:173
LrWpanAddressMode m_srcAddrMode
Source address mode.
Definition: lr-wpan-mac.h:157
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:278
uint8_t m_retransmission
The number of already used retransmission for the currently transmitted packet.
Definition: lr-wpan-mac.h:803
Mac64Address m_selfExt
The extended address used by this MAC.
Definition: lr-wpan-mac.h:792
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:158
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
Definition: packet.cc:285
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:691
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:58
void SetRxOnWhenIdle(bool rxOnWhenIdle)
Set if the receiver should be enabled when the MAC is idle.
Definition: lr-wpan-mac.cc:203
uint32_t RemoveTrailer(Trailer &trailer)
Remove a deserialized trailer from the internal buffer.
Definition: packet.cc:296
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:673
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:487
Mac16Address m_srcAddr
Source address.
Definition: lr-wpan-mac.h:185
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
Definition: simulator.h:1401
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:190
LrWpanMac(void)
Default constructor.
Definition: lr-wpan-mac.cc:131
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:711
void SetExtendedAddress(Mac64Address address)
Set the extended address of this MAC.
Definition: lr-wpan-mac.cc:229
uint8_t m_macMaxFrameRetries
The maximum number of retries allowed after a transmission failure.
Definition: lr-wpan-mac.h:506
uint8_t txQMsduHandle
MSDU Handle.
Definition: lr-wpan-mac.h:569
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:746
CHANNEL_ACCESS_FAILURE.
Definition: lr-wpan-mac.h:73
MAC_CSMA.
Definition: lr-wpan-mac.h:70
SequenceNumber8 m_macDsn
Sequence number added to transmitted data or MAC command frame, 00-ff.
Definition: lr-wpan-mac.h:500
MAC_ACK_PENDING.
Definition: lr-wpan-mac.h:72
static const uint32_t aMinMPDUOverhead
The minimum number of octets added by the MAC sublayer to the PSDU.
Definition: lr-wpan-mac.h:233
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:751
LrWpanMacState
MAC states.
Definition: lr-wpan-mac.h:67
LrWpanAssociationStatus
table 83 of 802.15.4
Definition: lr-wpan-mac.h:110
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:237
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:640
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:494
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
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:888
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:105
void SendAck(uint8_t seqno)
Send an acknowledgment packet for the given sequence number.
Definition: lr-wpan-mac.cc:683
MCPS-DATA.request params.
Definition: lr-wpan-mac.h:146
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:736
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:450
Mac16Address m_shortAddress
The short address used by this MAC.
Definition: lr-wpan-mac.h:786
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:191
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:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaCa)
Set the CSMA/CA implementation to be used by the MAC.
Definition: lr-wpan-mac.cc:438
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:926
virtual void DoInitialize(void)
Initialize() implementation.
Definition: lr-wpan-mac.cc:160
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:257
MAC_SENDING.
Definition: lr-wpan-mac.h:71
uint16_t m_srcPanId
Source PAN identifier.
Definition: lr-wpan-mac.h:184
MAC_IDLE.
Definition: lr-wpan-mac.h:69
void SetAssociationStatus(LrWpanAssociationStatus status)
Set the current association status.
Definition: lr-wpan-mac.cc:999
MCPS-DATA.indication params.
Definition: lr-wpan-mac.h:181
void SetMcpsDataIndicationCallback(McpsDataIndicationCallback c)
Set the callback for the indication of an incoming data packet.
Definition: lr-wpan-mac.cc:456