A Discrete-Event Network Simulator
API
lr-wpan-csmaca.h
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 #ifndef LR_WPAN_CSMACA_H
25 #define LR_WPAN_CSMACA_H
26 
27 #include <ns3/object.h>
28 #include <ns3/event-id.h>
29 #include <ns3/lr-wpan-mac.h>
30 
31 namespace ns3 {
32 
33 class UniformRandomVariable;
34 
56 class LrWpanCsmaCa : public Object
57 {
58 
59 public:
65  static TypeId GetTypeId (void);
69  LrWpanCsmaCa (void);
70  virtual ~LrWpanCsmaCa (void);
76  void SetMac (Ptr<LrWpanMac> mac);
82  Ptr<LrWpanMac> GetMac (void) const;
83 
87  void SetSlottedCsmaCa (void);
91  void SetUnSlottedCsmaCa (void);
97  bool IsSlottedCsmaCa (void) const;
103  bool IsUnSlottedCsmaCa (void) const;
110  void SetMacMinBE (uint8_t macMinBE);
117  uint8_t GetMacMinBE (void) const;
124  void SetMacMaxBE (uint8_t macMaxBE);
131  uint8_t GetMacMaxBE (void) const;
138  void SetMacMaxCSMABackoffs (uint8_t macMaxCSMABackoffs);
139 
146  uint8_t GetMacMaxCSMABackoffs (void) const;
154  void SetUnitBackoffPeriod (uint64_t unitBackoffPeriod);
162  uint64_t GetUnitBackoffPeriod (void) const;
169  Time GetTimeToNextSlot (void) const;
174  void Start (void);
178  void Cancel (void);
182  void RandomBackoffDelay (void);
190  void CanProceed (void);
194  void RequestCCA (void);
199  void DeferCsmaTimeout (void);
211  void PlmeCcaConfirm (LrWpanPhyEnumeration status);
233  void SetBatteryLifeExtension (bool batteryLifeExtension);
241  int64_t AssignStreams (int64_t stream);
247  uint8_t GetNB (void);
253  bool GetBatteryLifeExtension (void);
254 
255 private:
256  // Disable implicit copy constructors
266 
267  virtual void DoDispose (void);
292  uint8_t m_NB;
296  uint8_t m_CW;
300  uint8_t m_BE;
308  uint8_t m_macMinBE; //
312  uint8_t m_macMaxBE;
357 
358 };
359 
360 }
361 
362 // namespace ns-3
363 
364 #endif /* LR_WPAN_CSMACA_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
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
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
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
ns3::Callback< void, LrWpanMacState >
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::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::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::operator=
LrWpanCsmaCa & operator=(LrWpanCsmaCa const &)
Copy constructor - defined and not implemented.
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::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::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::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::LrWpanPhyEnumeration
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:106
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
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
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::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
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::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::LrWpanCsmaCa
LrWpanCsmaCa(LrWpanCsmaCa const &)
Copy constructor - defined and not implemented.
ns3::LrWpanCsmaCa::IsSlottedCsmaCa
bool IsSlottedCsmaCa(void) const
Check if the slotted CSMA/CA version is being used.
Definition: lr-wpan-csmaca.cc:112
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::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::LrWpanCsmaCa::SetMacMaxCSMABackoffs
void SetMacMaxCSMABackoffs(uint8_t macMaxCSMABackoffs)
Set the maximum number of backoffs.
Definition: lr-wpan-csmaca.cc:154
ns3::LrWpanMacTransCostCallback
Callback< void, uint32_t > LrWpanMacTransCostCallback
This method informs the transaction cost in a slotted CSMA-CA data transmission.
Definition: lr-wpan-csmaca.h:49
ns3::LrWpanCsmaCa::m_CW
uint8_t m_CW
Contention window length (used in slotted ver only).
Definition: lr-wpan-csmaca.h:296
ns3::LrWpanMacStateCallback
Callback< void, LrWpanMacState > LrWpanMacStateCallback
This method informs the MAC whether the channel is idle or busy.
Definition: lr-wpan-csmaca.h:33