A Discrete-Event Network Simulator
API
lr-wpan-csmaca.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  * Author:
19  * kwong yin <kwong-sang.yin@boeing.com>
20  * Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
21  * Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
22  */
23 
24 #include "lr-wpan-csmaca.h"
25 #include <ns3/random-variable-stream.h>
26 #include <ns3/simulator.h>
27 #include <ns3/log.h>
28 #include <algorithm>
29 
30 #undef NS_LOG_APPEND_CONTEXT
31 #define NS_LOG_APPEND_CONTEXT \
32  std::clog << "[address " << m_mac->GetShortAddress () << "] ";
33 
34 namespace ns3 {
35 
36 NS_LOG_COMPONENT_DEFINE ("LrWpanCsmaCa");
37 
38 NS_OBJECT_ENSURE_REGISTERED (LrWpanCsmaCa);
39 
40 TypeId
42 {
43  static TypeId tid = TypeId ("ns3::LrWpanCsmaCa")
44  .SetParent<Object> ()
45  .SetGroupName ("LrWpan")
46  .AddConstructor<LrWpanCsmaCa> ()
47  ;
48  return tid;
49 }
50 
52 {
53  // TODO-- make these into ns-3 attributes
54 
55  m_isSlotted = false;
56  m_NB = 0;
57  m_CW = 2;
58  m_macBattLifeExt = false;
59  m_macMinBE = 3;
60  m_macMaxBE = 5;
62  m_aUnitBackoffPeriod = 20; // symbols
63  m_random = CreateObject<UniformRandomVariable> ();
64  m_BE = m_macMinBE;
65  m_ccaRequestRunning = false;
67  m_coorDest = false;
68 }
69 
71 {
72  m_mac = 0;
73 }
74 
75 void
77 {
78  m_lrWpanMacStateCallback = MakeNullCallback <void, LrWpanMacState> ();
79  m_lrWpanMacTransCostCallback = MakeNullCallback <void, uint32_t> ();
80 
81  Cancel ();
82  m_mac = 0;
83 }
84 
85 void
87 {
88  m_mac = mac;
89 }
90 
93 {
94  return m_mac;
95 }
96 
97 void
99 {
100  NS_LOG_FUNCTION (this);
101  m_isSlotted = true;
102 }
103 
104 void
106 {
107  NS_LOG_FUNCTION (this);
108  m_isSlotted = false;
109 }
110 
111 bool
113 {
114  NS_LOG_FUNCTION (this);
115  return (m_isSlotted);
116 }
117 
118 bool
120 {
121  NS_LOG_FUNCTION (this);
122  return (!m_isSlotted);
123 }
124 
125 void
126 LrWpanCsmaCa::SetMacMinBE (uint8_t macMinBE)
127 {
128  NS_LOG_FUNCTION (this << macMinBE);
129  m_macMinBE = macMinBE;
130 }
131 
132 uint8_t
134 {
135  NS_LOG_FUNCTION (this);
136  return m_macMinBE;
137 }
138 
139 void
140 LrWpanCsmaCa::SetMacMaxBE (uint8_t macMaxBE)
141 {
142  NS_LOG_FUNCTION (this << macMaxBE);
143  m_macMinBE = macMaxBE;
144 }
145 
146 uint8_t
148 {
149  NS_LOG_FUNCTION (this);
150  return m_macMaxBE;
151 }
152 
153 void
154 LrWpanCsmaCa::SetMacMaxCSMABackoffs (uint8_t macMaxCSMABackoffs)
155 {
156  NS_LOG_FUNCTION (this << macMaxCSMABackoffs);
157  m_macMaxCSMABackoffs = macMaxCSMABackoffs;
158 }
159 
160 uint8_t
162 {
163  NS_LOG_FUNCTION (this);
164  return m_macMaxCSMABackoffs;
165 }
166 
167 void
168 LrWpanCsmaCa::SetUnitBackoffPeriod (uint64_t unitBackoffPeriod)
169 {
170  NS_LOG_FUNCTION (this << unitBackoffPeriod);
171  m_aUnitBackoffPeriod = unitBackoffPeriod;
172 }
173 
174 uint64_t
176 {
177  NS_LOG_FUNCTION (this);
178  return m_aUnitBackoffPeriod;
179 }
180 
181 
182 Time
184 {
185  NS_LOG_FUNCTION (this);
186 
187  // The reference for the beginning of the SUPERFRAME (the active period) changes depending
188  // on the data packet being sent from the Coordinator/outgoing frame (Tx beacon time reference)
189  // or other device/incoming frame (Rx beacon time reference ).
190 
191  Time elapsedSuperframe; // (i.e The beacon + the elapsed CAP)
192  Time currentTime;
193  double symbolsToBoundary;
194  Time nextBoundary;
195  uint64_t elapsedSuperframeSymbols;
196  uint64_t symbolRate;
197  Time timeAtBoundary;
198  Time elapsedCap;
199  Time beaconTime;
200 
201 
202  currentTime = Simulator::Now ();
203  symbolRate = (uint64_t) m_mac->GetPhy ()->GetDataOrSymbolRate (false); //symbols per second
204 
205  if (m_coorDest)
206  {
207  // Take the Incoming Frame Reference
208  elapsedSuperframe = currentTime - m_mac->m_macBeaconRxTime;
209 
210  beaconTime = Seconds ((double) m_mac->m_rxBeaconSymbols / symbolRate);
211  elapsedCap = elapsedSuperframe - beaconTime;
212  NS_LOG_DEBUG ("Elapsed incoming CAP symbols: " << (elapsedCap.GetSeconds () * symbolRate) << " (" << elapsedCap.As (Time::S) << ")");
213  NS_UNUSED (beaconTime);
214  NS_UNUSED (elapsedCap);
215  }
216  else
217  {
218  // Take the Outgoing Frame Reference
219  elapsedSuperframe = currentTime - m_mac->m_macBeaconTxTime;
220  }
221 
222  // get a close value to the the boundary in symbols
223  elapsedSuperframeSymbols = elapsedSuperframe.GetSeconds () * symbolRate;
224  symbolsToBoundary = m_aUnitBackoffPeriod - std::fmod ((double) elapsedSuperframeSymbols,m_aUnitBackoffPeriod);
225 
226  timeAtBoundary = Seconds ((double)(elapsedSuperframeSymbols + symbolsToBoundary) / symbolRate);
227 
228  // get the exact time boundary
229  nextBoundary = timeAtBoundary - elapsedSuperframe;
230 
231  NS_LOG_DEBUG ("Elapsed Superframe symbols: " << elapsedSuperframeSymbols << " ("
232  << elapsedSuperframe.As (Time::S) << ")");
233 
234  NS_LOG_DEBUG ("Next backoff period boundary in approx. " << nextBoundary.GetSeconds () * symbolRate << " symbols ("
235  << nextBoundary.As (Time::S) << ")");
236 
237  return nextBoundary;
238 
239 }
240 
241 
242 void
244 {
245  NS_LOG_FUNCTION (this);
246  m_NB = 0;
247  if (IsSlottedCsmaCa ())
248  {
249  // TODO: Check if the current PHY is using the Japanese band 950 Mhz:
250  // (IEEE_802_15_4_950MHZ_BPSK and IEEE_802_15_4_950MHZ_2GFSK)
251  // if in use, m_CW = 1.
252  // Currently 950 Mhz band PHYs are not supported in ns-3.
253  // To know the current used PHY, making the method for GetPhy()->GetMyPhyOption()
254  // public is necessary. Alternatively, the current PHY used
255  // can be known using phyCurrentPage variable.
256 
257  m_CW = 2;
258 
259  if (m_macBattLifeExt)
260  {
261  m_BE = std::min (static_cast<uint8_t> (2), m_macMinBE);
262  }
263  else
264  {
265  m_BE = m_macMinBE;
266  }
267 
268  // m_coorDest to decide between incoming and outgoing superframes times
269  m_coorDest = m_mac->isCoordDest ();
270 
271  // Locate backoff period boundary. (i.e. a time delay to align with the next backoff period boundary)
272  Time backoffBoundary = GetTimeToNextSlot ();
274 
275  }
276  else
277  {
278  m_BE = m_macMinBE;
280  }
281 }
282 
283 void
285 {
289 }
290 
291 
292 
293 void
295 {
296  NS_LOG_FUNCTION (this);
297 
298  uint64_t upperBound = (uint64_t) pow (2, m_BE) - 1;
299  Time randomBackoff;
300  uint64_t symbolRate;
301  Time timeLeftInCap;
302 
303  symbolRate = (uint64_t) m_mac->GetPhy ()->GetDataOrSymbolRate (false); //symbols per second
304 
305  // We should not recalculate the random backoffPeriods if we are in a slotted CSMA-CA and the
306  // transmission was previously deferred (m_randomBackoffPeriods != 0)
308  {
309  m_randomBackoffPeriodsLeft = (uint64_t)m_random->GetValue (0, upperBound + 1);
310  }
311 
312  randomBackoff = Seconds ((double) (m_randomBackoffPeriodsLeft * GetUnitBackoffPeriod ()) / symbolRate);
313 
314  if (IsUnSlottedCsmaCa ())
315  {
316  NS_LOG_DEBUG ("Unslotted CSMA-CA: requesting CCA after backoff of " << m_randomBackoffPeriodsLeft <<
317  " periods (" << randomBackoff.As (Time::S) << ")");
319  }
320  else
321  {
322  // We must make sure there is enough time left in the CAP, otherwise we continue in
323  // the CAP of the next superframe after the transmission/reception of the beacon (and the IFS)
324  timeLeftInCap = GetTimeLeftInCap ();
325 
326  NS_LOG_DEBUG ("Slotted CSMA-CA: proceeding after random backoff of " << m_randomBackoffPeriodsLeft <<
327  " periods (" << (randomBackoff.GetSeconds () * symbolRate) << " symbols or " << randomBackoff.As (Time::S) << ")");
328 
329 
330 
331 
332  NS_LOG_DEBUG ("Backoff periods left in CAP: " << ((timeLeftInCap.GetSeconds () * symbolRate) / m_aUnitBackoffPeriod) << " ("
333  << (timeLeftInCap.GetSeconds () * symbolRate) << " symbols or "
334  << timeLeftInCap.As (Time::S) << ")");
335 
336 
337  if (randomBackoff > timeLeftInCap)
338  {
339  uint64_t usedBackoffs = (double)(timeLeftInCap.GetSeconds () * symbolRate) / m_aUnitBackoffPeriod;
340  m_randomBackoffPeriodsLeft -= usedBackoffs;
341  NS_LOG_DEBUG ("No time in CAP to complete backoff delay, deferring to the next CAP");
343  }
344  else
345  {
347  }
348 
349  }
350 }
351 
352 
353 Time
355 {
356  Time currentTime;
357  uint64_t capSymbols;
358  Time endCapTime;
359  uint64_t activeSlot;
360  uint64_t symbolRate;
361  Time rxBeaconTime;
362 
363 
364  // At this point, the currentTime should be aligned on a backoff period boundary
365  currentTime = Simulator::Now ();
366  symbolRate = (uint64_t) m_mac->GetPhy ()->GetDataOrSymbolRate (false); //symbols per second
367 
368 
369  if (m_coorDest)
370  { // Take Incoming frame reference
371  activeSlot = m_mac->m_incomingSuperframeDuration / 16;
372  capSymbols = activeSlot * (m_mac->m_incomingFnlCapSlot + 1);
373  endCapTime = m_mac->m_macBeaconRxTime +
374  Seconds ((double) capSymbols / symbolRate);
375  }
376  else
377  { // Take Outgoing frame reference
378  activeSlot = m_mac->m_superframeDuration / 16;
379  capSymbols = activeSlot * (m_mac->m_fnlCapSlot + 1);
380  endCapTime = m_mac->m_macBeaconTxTime +
381  Seconds ((double) capSymbols / symbolRate);
382  }
383 
384  return (endCapTime - currentTime);
385 }
386 
387 
388 void
390 {
391  NS_LOG_FUNCTION (this);
392 
393  Time timeLeftInCap;
394  uint16_t ccaSymbols;
395  uint32_t transactionSymbols;
396  Time transactionTime;
397  uint64_t symbolRate;
398 
399  ccaSymbols = 0;
401  symbolRate = (uint64_t) m_mac->GetPhy ()->GetDataOrSymbolRate (false);
402  timeLeftInCap = GetTimeLeftInCap ();
403 
404 
405  // TODO: On the 950 Mhz Band (Japanese Band)
406  // only a single CCA check is performed;
407  // the CCA check duration time is:
408  //
409  // CCA symbols = phyCCADuration * m_CW (1)
410  // other PHYs:
411  // CCA symbols = 8 * m_CW(2)
412  //
413  // note: phyCCADuration & 950Mhz band PHYs are
414  // not currently implemented in ns-3.
415  ccaSymbols += 8 * m_CW;
416 
417  // The MAC sublayer shall proceed if the remaining CSMA-CA algorithm steps
418  // can be completed before the end of the CAP.
419  // See IEEE 802.15.4-2011 (Sections 5.1.1.1 and 5.1.1.4)
420  // Transaction = 2 CCA + frame transmission (SHR+PHR+PPDU) + turnaroudtime*2 (Rx->Tx & Tx->Rx) + IFS (LIFS or SIFS) and Ack time (if ack flag true)
421 
422  transactionSymbols = ccaSymbols + m_mac->GetTxPacketSymbols ();
423 
424  if (m_mac->isTxAckReq ())
425  {
426  NS_LOG_DEBUG ("ACK duration symbols: " << m_mac->GetMacAckWaitDuration ());
427  transactionSymbols += m_mac->GetMacAckWaitDuration ();
428  }
429  else
430  {
431  //time the PHY takes to switch from Rx to Tx and Tx to Rx
432  transactionSymbols += (m_mac->GetPhy ()->aTurnaroundTime *2);
433  }
434  transactionSymbols += m_mac->GetIfsSize ();
435 
436  // Report the transaction cost
438  {
439  m_lrWpanMacTransCostCallback (transactionSymbols);
440  }
441 
442  transactionTime = Seconds ((double) transactionSymbols / symbolRate);
443  NS_LOG_DEBUG ("Total required transaction: " << transactionSymbols << " symbols (" << transactionTime.As (Time::S) << ")");
444 
445  if (transactionTime > timeLeftInCap)
446  {
447  NS_LOG_DEBUG ("Transaction of " << transactionSymbols << " symbols " <<
448  "cannot be completed in CAP, deferring transmission to the next CAP");
449 
450 
451 
452  NS_LOG_DEBUG ("Symbols left in CAP: " << (timeLeftInCap.GetSeconds () * symbolRate) <<
453  " (" << timeLeftInCap.As (Time::S) << ")");
454 
456  }
457  else
458  {
460  }
461 
462 }
463 
464 void
466 {
467  NS_LOG_FUNCTION (this);
468  m_ccaRequestRunning = true;
469  m_mac->GetPhy ()->PlmeCcaRequest ();
470 }
471 
472 void
474 {
475  NS_LOG_FUNCTION (this);
477 }
478 
479 void
481 {
482  NS_LOG_FUNCTION (this << status);
483 
484  // Only react on this event, if we are actually waiting for a CCA.
485  // If the CSMA algorithm was canceled, we could still receive this event from
486  // the PHY. In this case we ignore the event.
488  {
489  m_ccaRequestRunning = false;
490  if (status == IEEE_802_15_4_PHY_IDLE)
491  {
492  if (IsSlottedCsmaCa ())
493  {
494  m_CW--;
495  if (m_CW == 0)
496  {
497  // inform MAC channel is idle
499  {
500  NS_LOG_LOGIC ("Notifying MAC of idle channel");
502  }
503  }
504  else
505  {
506  NS_LOG_LOGIC ("Perform CCA again, m_CW = " << m_CW);
507  m_requestCcaEvent = Simulator::ScheduleNow (&LrWpanCsmaCa::RequestCCA, this); // Perform CCA again
508  }
509  }
510  else
511  {
512  // inform MAC, channel is idle
514  {
515  NS_LOG_LOGIC ("Notifying MAC of idle channel");
517  }
518  }
519  }
520  else
521  {
522  if (IsSlottedCsmaCa ())
523  {
524  m_CW = 2;
525  }
526  m_BE = std::min (static_cast<uint16_t> (m_BE + 1), static_cast<uint16_t> (m_macMaxBE));
527  m_NB++;
529  {
530  // no channel found so cannot send pkt
531  NS_LOG_DEBUG ("Channel access failure");
533  {
534  NS_LOG_LOGIC ("Notifying MAC of Channel access failure");
536  }
537  return;
538  }
539  else
540  {
541  NS_LOG_DEBUG ("Perform another backoff; m_NB = " << static_cast<uint16_t> (m_NB));
542  m_randomBackoffEvent = Simulator::ScheduleNow (&LrWpanCsmaCa::RandomBackoffDelay, this); //Perform another backoff (step 2)
543  }
544  }
545  }
546 }
547 
548 
549 void
551 {
552  NS_LOG_FUNCTION (this);
554 }
555 
556 
557 void
559 {
560  NS_LOG_FUNCTION (this);
562 }
563 
564 void
565 LrWpanCsmaCa::SetBatteryLifeExtension (bool batteryLifeExtension)
566 {
567  m_macBattLifeExt = batteryLifeExtension;
568 }
569 
570 
571 int64_t
573 {
574  NS_LOG_FUNCTION (this);
575  m_random->SetStream (stream);
576  return 1;
577 }
578 
579 uint8_t
581 {
582  return m_NB;
583 }
584 
585 bool
587 {
588  return m_macBattLifeExt;
589 }
590 
591 } //namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::LrWpanCsmaCa::m_requestCcaEvent
EventId m_requestCcaEvent
Scheduler event when to start the CCA after a random backoff.
Definition: lr-wpan-csmaca.h:340
ns3::LrWpanCsmaCa::GetMacMinBE
uint8_t GetMacMinBE(void) const
Get the minimum backoff exponent value.
Definition: lr-wpan-csmaca.cc:133
ns3::LrWpanCsmaCa::m_endCapEvent
EventId m_endCapEvent
Scheduler event for the end of the current CAP.
Definition: lr-wpan-csmaca.h:336
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
min
#define min(a, b)
Definition: 80211b.c:42
ns3::LrWpanCsmaCa::PlmeCcaConfirm
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
Definition: lr-wpan-csmaca.cc:480
lr-wpan-csmaca.h
ns3::Callback< void, uint32_t >
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
ns3::LrWpanCsmaCa::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: lr-wpan-csmaca.cc:572
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Callback::IsNull
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
ns3::LrWpanCsmaCa::m_macMaxCSMABackoffs
uint8_t m_macMaxCSMABackoffs
Maximum number of backoffs.
Definition: lr-wpan-csmaca.h:316
ns3::LrWpanCsmaCa::SetMacMinBE
void SetMacMinBE(uint8_t macMinBE)
Set the minimum backoff exponent value.
Definition: lr-wpan-csmaca.cc:126
ns3::LrWpanCsmaCa::SetBatteryLifeExtension
void SetBatteryLifeExtension(bool batteryLifeExtension)
Set the value of the Battery Life Extension.
Definition: lr-wpan-csmaca.cc:565
ns3::IEEE_802_15_4_PHY_IDLE
@ IEEE_802_15_4_PHY_IDLE
Definition: lr-wpan-phy.h:111
ns3::LrWpanCsmaCa::m_lrWpanMacStateCallback
LrWpanMacStateCallback m_lrWpanMacStateCallback
The callback to inform the configured MAC of the CSMA/CA result.
Definition: lr-wpan-csmaca.h:280
ns3::LrWpanCsmaCa::m_randomBackoffPeriodsLeft
uint64_t m_randomBackoffPeriodsLeft
Count the number of remaining random backoff periods left to delay.
Definition: lr-wpan-csmaca.h:324
ns3::LrWpanCsmaCa::SetLrWpanMacTransCostCallback
void SetLrWpanMacTransCostCallback(LrWpanMacTransCostCallback trans)
Set the callback function to report a transaction cost in slotted CSMA-CA.
Definition: lr-wpan-csmaca.cc:550
ns3::LrWpanCsmaCa::SetUnitBackoffPeriod
void SetUnitBackoffPeriod(uint64_t unitBackoffPeriod)
Set the number of symbols forming the basic time period used by the CSMA-CA algorithm.
Definition: lr-wpan-csmaca.cc:168
ns3::LrWpanCsmaCa::m_lrWpanMacTransCostCallback
LrWpanMacTransCostCallback m_lrWpanMacTransCostCallback
The callback to inform the cost of a transaction in slotted CSMA-CA.
Definition: lr-wpan-csmaca.h:276
third.mac
mac
Definition: third.py:99
ns3::Time::As
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:429
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
ns3::LrWpanCsmaCa::GetTimeLeftInCap
Time GetTimeLeftInCap()
Get the time left in the CAP portion of the Outgoing or Incoming superframe.
Definition: lr-wpan-csmaca.cc:354
ns3::LrWpanCsmaCa::SetMacMaxBE
void SetMacMaxBE(uint8_t macMaxBE)
Set the maximum backoff exponent value.
Definition: lr-wpan-csmaca.cc:140
ns3::LrWpanCsmaCa::SetUnSlottedCsmaCa
void SetUnSlottedCsmaCa(void)
Configure for the use of the unslotted CSMA/CA version.
Definition: lr-wpan-csmaca.cc:105
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::LrWpanCsmaCa::m_macBattLifeExt
bool m_macBattLifeExt
Battery Life Extension.
Definition: lr-wpan-csmaca.h:304
ns3::LrWpanCsmaCa::SetMac
void SetMac(Ptr< LrWpanMac > mac)
Set the MAC to which this CSMA/CA implementation is attached to.
Definition: lr-wpan-csmaca.cc:86
ns3::LrWpanCsmaCa::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: lr-wpan-csmaca.cc:76
ns3::LrWpanCsmaCa::GetMacMaxBE
uint8_t GetMacMaxBE(void) const
Get the maximum backoff exponent value.
Definition: lr-wpan-csmaca.cc:147
ns3::LrWpanCsmaCa::Start
void Start(void)
Start CSMA-CA algorithm (step 1), initialize NB, BE for both slotted and unslotted CSMA-CA.
Definition: lr-wpan-csmaca.cc:243
ns3::LrWpanCsmaCa::m_NB
uint8_t m_NB
Number of backoffs for the current transmission.
Definition: lr-wpan-csmaca.h:292
ns3::LrWpanCsmaCa::m_macMinBE
uint8_t m_macMinBE
Minimum backoff exponent.
Definition: lr-wpan-csmaca.h:308
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::LrWpanCsmaCa::GetMacMaxCSMABackoffs
uint8_t GetMacMaxCSMABackoffs(void) const
Get the maximum number of backoffs.
Definition: lr-wpan-csmaca.cc:161
ns3::LrWpanCsmaCa::m_aUnitBackoffPeriod
uint64_t m_aUnitBackoffPeriod
Number of symbols per CSMA/CA time unit, default 20 symbols.
Definition: lr-wpan-csmaca.h:320
ns3::LrWpanCsmaCa::GetNB
uint8_t GetNB(void)
Get the number of CSMA retries.
Definition: lr-wpan-csmaca.cc:580
ns3::LrWpanCsmaCa::RequestCCA
void RequestCCA(void)
Request the Phy to perform CCA (Step 3)
Definition: lr-wpan-csmaca.cc:465
ns3::LrWpanCsmaCa::LrWpanCsmaCa
LrWpanCsmaCa(void)
Default constructor.
Definition: lr-wpan-csmaca.cc:51
ns3::LrWpanCsmaCa::m_random
Ptr< UniformRandomVariable > m_random
Uniform random variable stream.
Definition: lr-wpan-csmaca.h:328
ns3::LrWpanCsmaCa::RandomBackoffDelay
void RandomBackoffDelay(void)
In step 2 of the CSMA-CA, perform a random backoff in the range of 0 to 2^BE -1.
Definition: lr-wpan-csmaca.cc:294
ns3::LrWpanCsmaCa::GetTimeToNextSlot
Time GetTimeToNextSlot(void) const
Locates the time to the next backoff period boundary in the SUPERFRAME and returns the amount of time...
Definition: lr-wpan-csmaca.cc:183
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::MAC_CSMA_DEFERRED
@ MAC_CSMA_DEFERRED
MAC_CSMA_DEFERRED.
Definition: lr-wpan-mac.h:80
ns3::LrWpanCsmaCa::m_isSlotted
bool m_isSlotted
Beacon-enabled slotted or nonbeacon-enabled unslotted CSMA-CA.
Definition: lr-wpan-csmaca.h:284
ns3::LrWpanCsmaCa::DeferCsmaTimeout
void DeferCsmaTimeout(void)
The CSMA algorithm call this function at the end of the CAP to return the MAC state back to to IDLE a...
Definition: lr-wpan-csmaca.cc:473
ns3::EventId::Cancel
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
NS_UNUSED
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
ns3::LrWpanPhyEnumeration
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:106
ns3::CHANNEL_ACCESS_FAILURE
@ CHANNEL_ACCESS_FAILURE
CHANNEL_ACCESS_FAILURE.
Definition: lr-wpan-mac.h:75
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::LrWpanCsmaCa::m_mac
Ptr< LrWpanMac > m_mac
The MAC instance for which this CSMA/CA implemenation is configured.
Definition: lr-wpan-csmaca.h:288
ns3::LrWpanCsmaCa::IsUnSlottedCsmaCa
bool IsUnSlottedCsmaCa(void) const
Check if the unslotted CSMA/CA version is being used.
Definition: lr-wpan-csmaca.cc:119
ns3::LrWpanCsmaCa::Cancel
void Cancel(void)
Cancel CSMA-CA algorithm.
Definition: lr-wpan-csmaca.cc:284
ns3::LrWpanCsmaCa::m_ccaRequestRunning
bool m_ccaRequestRunning
Flag indicating that the PHY is currently running a CCA.
Definition: lr-wpan-csmaca.h:350
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
ns3::LrWpanCsmaCa::m_BE
uint8_t m_BE
Backoff exponent.
Definition: lr-wpan-csmaca.h:300
ns3::LrWpanCsmaCa::SetSlottedCsmaCa
void SetSlottedCsmaCa(void)
Configure for the use of the slotted CSMA/CA version.
Definition: lr-wpan-csmaca.cc:98
ns3::LrWpanCsmaCa::GetUnitBackoffPeriod
uint64_t GetUnitBackoffPeriod(void) const
Get the number of symbols forming the basic time period used by the CSMA-CA algorithm.
Definition: lr-wpan-csmaca.cc:175
ns3::LrWpanCsmaCa::m_randomBackoffEvent
EventId m_randomBackoffEvent
Scheduler event for the start of the next random backoff/slot.
Definition: lr-wpan-csmaca.h:332
ns3::LrWpanCsmaCa::SetLrWpanMacStateCallback
void SetLrWpanMacStateCallback(LrWpanMacStateCallback macState)
Set the callback function to the MAC.
Definition: lr-wpan-csmaca.cc:558
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::LrWpanCsmaCa::CanProceed
void CanProceed(void)
In the slotted CSMA-CA, after random backoff, determine if the remaining CSMA-CA operation can procee...
Definition: lr-wpan-csmaca.cc:389
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::Time::S
@ S
second
Definition: nstime.h:115
ns3::LrWpanCsmaCa::m_coorDest
bool m_coorDest
Indicates whether the CSMA procedure is targeted for a message to be sent to the coordinator.
Definition: lr-wpan-csmaca.h:356
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::LrWpanCsmaCa::m_macMaxBE
uint8_t m_macMaxBE
Maximum backoff exponent.
Definition: lr-wpan-csmaca.h:312
ns3::LrWpanCsmaCa::GetBatteryLifeExtension
bool GetBatteryLifeExtension(void)
Get the value of the Battery Life Extension.
Definition: lr-wpan-csmaca.cc:586
ns3::RandomVariableStream::SetStream
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Definition: random-variable-stream.cc:100
ns3::LrWpanCsmaCa::~LrWpanCsmaCa
virtual ~LrWpanCsmaCa(void)
Definition: lr-wpan-csmaca.cc:70
ns3::LrWpanCsmaCa::GetMac
Ptr< LrWpanMac > GetMac(void) const
Get the MAC to which this CSMA/CA implementation is attached to.
Definition: lr-wpan-csmaca.cc:92
ns3::LrWpanCsmaCa::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: lr-wpan-csmaca.cc:41
ns3::LrWpanCsmaCa::IsSlottedCsmaCa
bool IsSlottedCsmaCa(void) const
Check if the slotted CSMA/CA version is being used.
Definition: lr-wpan-csmaca.cc:112
ns3::CHANNEL_IDLE
@ CHANNEL_IDLE
CHANNEL_IDLE.
Definition: lr-wpan-mac.h:76
ns3::LrWpanCsmaCa
This class is a helper for the LrWpanMac to manage the Csma/CA state machine according to IEEE 802....
Definition: lr-wpan-csmaca.h:57
ns3::UniformRandomVariable::GetValue
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Definition: random-variable-stream.cc:182
ns3::LrWpanCsmaCa::m_canProceedEvent
EventId m_canProceedEvent
Scheduler event for checking if we can complete the transmission before the end of the CAP.
Definition: lr-wpan-csmaca.h:345
ns3::Simulator::ScheduleNow
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:587
ns3::LrWpanCsmaCa::SetMacMaxCSMABackoffs
void SetMacMaxCSMABackoffs(uint8_t macMaxCSMABackoffs)
Set the maximum number of backoffs.
Definition: lr-wpan-csmaca.cc:154
ns3::Time::GetSeconds
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:380
ns3::LrWpanCsmaCa::m_CW
uint8_t m_CW
Contention window length (used in slotted ver only).
Definition: lr-wpan-csmaca.h:296