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  */
22 
23 #ifndef LR_WPAN_CSMACA_H
24 #define LR_WPAN_CSMACA_H
25 
26 #include <ns3/object.h>
27 #include <ns3/event-id.h>
28 #include <ns3/lr-wpan-mac.h>
29 
30 namespace ns3 {
31 
33 
40 
47 class LrWpanCsmaCa : public Object
48 {
49 
50 public:
56  static TypeId GetTypeId (void);
57 
61  LrWpanCsmaCa (void);
62  virtual ~LrWpanCsmaCa (void);
63 
69  void SetMac (Ptr<LrWpanMac> mac);
70 
76  Ptr<LrWpanMac> GetMac (void) const;
77 
81  void SetSlottedCsmaCa (void);
82 
86  void SetUnSlottedCsmaCa (void);
87 
93  bool IsSlottedCsmaCa (void) const;
94 
100  bool IsUnSlottedCsmaCa (void) const;
101 
108  void SetMacMinBE (uint8_t macMinBE);
109 
116  uint8_t GetMacMinBE (void) const;
117 
124  void SetMacMaxBE (uint8_t macMaxBE);
125 
132  uint8_t GetMacMaxBE (void) const;
133 
140  void SetMacMaxCSMABackoffs (uint8_t macMaxCSMABackoffs);
141 
148  uint8_t GetMacMaxCSMABackoffs (void) const;
149 
157  void SetUnitBackoffPeriod (uint64_t unitBackoffPeriod);
158 
166  uint64_t GetUnitBackoffPeriod (void) const;
167 
173  Time GetTimeToNextSlot (void) const;
174 
179  void Start (void);
180 
184  void Cancel (void);
185 
189  void RandomBackoffDelay (void);
190 
198  void CanProceed (void);
199 
203  void RequestCCA (void);
204 
216  void PlmeCcaConfirm (LrWpanPhyEnumeration status);
217 
225  void SetLrWpanMacStateCallback (LrWpanMacStateCallback macState);
226 
234  int64_t AssignStreams (int64_t stream);
235 
241  uint8_t GetNB (void);
242 
243 private:
244  // Disable implicit copy constructors
248  LrWpanCsmaCa (LrWpanCsmaCa const &);
254 
255  virtual void DoDispose (void);
256 
260  LrWpanMacStateCallback m_lrWpanMacStateCallback;
261 
266 
271 
275  uint8_t m_NB;
276 
280  uint8_t m_CW;
281 
285  uint8_t m_BE;
286 
290  bool m_BLE;
291 
295  uint8_t m_macMinBE; //
296 
300  uint8_t m_macMaxBE;
301 
306 
311 
316 
321 
326 
332 
338 };
339 
340 }
341 
342 // namespace ns-3
343 
344 #endif /* LR_WPAN_CSMACA_H */
static TypeId GetTypeId(void)
Get the type ID.
Time GetTimeToNextSlot(void) const
Get the amount of time from now to the beginning of the next slot.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
uint64_t GetUnitBackoffPeriod(void) const
Get the number of symbols forming the basic time period used by the CSMA-CA algorithm.
LrWpanCsmaCa & operator=(LrWpanCsmaCa const &)
Copy constructor - defined and not implemented.
void SetMacMinBE(uint8_t macMinBE)
Set the minimum backoff exponent value.
uint8_t GetMacMaxBE(void) const
Get the maximum backoff exponent value.
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
uint8_t m_CW
Contention window length (used in slotted ver only).
void SetMac(Ptr< LrWpanMac > mac)
Set the MAC to which this CSMA/CA implementation is attached to.
uint8_t m_NB
Number of backoffs for the current transmission.
bool IsUnSlottedCsmaCa(void) const
Check if the unslotted CSMA/CA version is being used.
uint8_t GetNB(void)
Get the number of CSMA retries.
void SetUnitBackoffPeriod(uint64_t unitBackoffPeriod)
Set the number of symbols forming the basic time period used by the CSMA-CA algorithm.
Callback< void, LrWpanMacState > LrWpanMacStateCallback
This method informs the MAC whether the channel is idle or busy.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC to which this CSMA/CA implementation is attached to.
uint8_t m_macMinBE
Minimum backoff exponent.
LrWpanMacStateCallback m_lrWpanMacStateCallback
The callback to inform the configured MAC of the CSMA/CA result.
void SetMacMaxBE(uint8_t macMaxBE)
Set the maximum backoff exponent value.
void SetUnSlottedCsmaCa(void)
Configure for the use of the unslotted CSMA/CA version.
void RequestCCA(void)
Request the Phy to perform CCA (Step 3)
bool IsSlottedCsmaCa(void) const
Check if the slotted CSMA/CA version is being used.
virtual void DoDispose(void)
Destructor implementation.
void RandomBackoffDelay(void)
In step 2 of the CSMA-CA, perform a random backoff in the range of 0 to 2^BE -1.
void Start(void)
Start CSMA-CA algorithm (step 1), initialize NB, BE for both slotted and unslotted CSMA-CA...
uint8_t GetMacMinBE(void) const
Get the minimum backoff exponent value.
void Cancel(void)
Cancel CSMA-CA algorithm.
uint64_t m_aUnitBackoffPeriod
Number of symbols per CSMA/CA time unit, default 20 symbols.
LrWpanCsmaCa(void)
Default constructor.
The uniform distribution Random Number Generator (RNG).
bool m_BLE
Battery Life Extension.
Ptr< LrWpanMac > m_mac
The MAC instance for which this CSMAƄ/CA implemenation is configured.
tuple mac
Definition: third.py:92
bool m_ccaRequestRunning
Flag indicating that the PHY is currently running a CCA.
void SetLrWpanMacStateCallback(LrWpanMacStateCallback macState)
Set the callback function to the MAC.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< UniformRandomVariable > m_random
Uniform random variable stream.
bool m_isSlotted
Beacon-enabled slotted or nonbeacon-enabled unslotted CSMA-CA.
uint8_t m_macMaxBE
Maximum backoff exponent.
EventId m_randomBackoffEvent
Scheduler event for the start of the next random backoff/slot.
uint8_t GetMacMaxCSMABackoffs(void) const
Get the maximum number of backoffs.
void SetSlottedCsmaCa(void)
Configure for the use of the slotted CSMA/CA version.
An identifier for simulation events.
Definition: event-id.h:53
void CanProceed(void)
In the slotted CSMA-CA, after random backoff, determine if the remaining CSMA-CA operation can procee...
virtual ~LrWpanCsmaCa(void)
uint8_t m_BE
Backoff exponent.
EventId m_canProceedEvent
Scheduler event for checking if we can complete the transmission before the end of the CAP...
This class is a helper for the LrWpanMac to manage the Csma/CA state machine according to IEEE 802...
void SetMacMaxCSMABackoffs(uint8_t macMaxCSMABackoffs)
Set the maximum number of backoffs.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:105
A base class which provides memory management and object aggregation.
Definition: object.h:87
EventId m_requestCcaEvent
Scheduler event when to start the CCA after a random backoff.
a unique identifier for an interface.
Definition: type-id.h:58
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
uint8_t m_macMaxCSMABackoffs
Maximum number of backoffs.