24 #include <ns3/random-variable-stream.h> 25 #include <ns3/simulator.h> 40 .SetGroupName (
"LrWpan")
58 m_random = CreateObject<UniformRandomVariable> ();
235 uint64_t upperBound = (uint64_t) pow (2,
m_BE) - 1;
236 uint64_t backoffPeriod;
242 symbolRate = (uint64_t)
m_mac->GetPhy ()->GetDataOrSymbolRate (isData);
265 bool canProceed =
true;
292 m_mac->GetPhy ()->PlmeCcaRequest ();
353 NS_LOG_LOGIC (
"Notifying MAC of Channel access failure");
360 NS_LOG_DEBUG (
"Perform another backoff; m_NB = " << static_cast<uint16_t> (
m_NB));
static TypeId GetTypeId(void)
Get the type ID.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void SetMacMinBE(uint8_t macMinBE)
Set the minimum 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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint8_t GetMacMinBE(void) const
Get the minimum backoff exponent value.
uint8_t GetMacMaxBE(void) const
Get the maximum backoff exponent value.
uint8_t m_NB
Number of backoffs for the current transmission.
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.
uint8_t m_macMinBE
Minimum backoff exponent.
LrWpanMacStateCallback m_lrWpanMacStateCallback
The callback to inform the configured MAC of the CSMA/CA result.
uint8_t GetMacMaxCSMABackoffs(void) const
Get the maximum number of backoffs.
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)
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
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...
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.
bool m_BLE
Battery Life Extension.
Ptr< LrWpanMac > m_mac
The MAC instance for which this CSMAĆ/CA implementation is configured.
uint64_t GetUnitBackoffPeriod(void) const
Get the number of symbols forming the basic time period used by the CSMA-CA algorithm.
bool m_ccaRequestRunning
Flag indicating that the PHY is currently running a CCA.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
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.
Time GetTimeToNextSlot(void) const
Get the amount of time from now to the beginning of the next slot.
bool IsUnSlottedCsmaCa(void) const
Check if the unslotted CSMA/CA version is being used.
bool m_isSlotted
Beacon-enabled slotted or nonbeacon-enabled unslotted CSMA-CA.
uint8_t m_macMaxBE
Maximum backoff exponent.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
EventId m_randomBackoffEvent
Scheduler event for the start of the next random backoff/slot.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void SetSlottedCsmaCa(void)
Configure for the use of the slotted CSMA/CA version.
void CanProceed(void)
In the slotted CSMA-CA, after random backoff, determine if the remaining CSMA-CA operation can procee...
virtual ~LrWpanCsmaCa(void)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
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.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsSlottedCsmaCa(void) const
Check if the slotted CSMA/CA version is being used.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
A base class which provides memory management and object aggregation.
EventId m_requestCcaEvent
Scheduler event when to start the CCA after a random backoff.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC to which this CSMA/CA implementation is attached to.
bool IsNull(void) const
Check for null implementation.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
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.