A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::Backoff Class Reference

The backoff class is used for calculating backoff times when many net devices can write to the same channel. More...

#include "backoff.h"

+ Collaboration diagram for ns3::Backoff:

Public Member Functions

 Backoff ()
 
 Backoff (Time slotTime, uint32_t minSlots, uint32_t maxSlots, uint32_t ceiling, uint32_t maxRetries)
 Constructor.
 
int64_t AssignStreams (int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model.
 
Time GetBackoffTime ()
 
void IncrNumRetries ()
 Increments the number of retries by 1.
 
bool MaxRetriesReached () const
 
void ResetBackoffTime ()
 Indicates to the backoff object that the last packet was successfully transmitted and that the number of retries should be reset to 0.
 

Public Attributes

uint32_t m_ceiling
 Caps the exponential function when the number of retries reaches m_ceiling.
 
uint32_t m_maxRetries
 Maximum number of transmission retries before the packet is dropped.
 
uint32_t m_maxSlots
 Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff time)
 
uint32_t m_minSlots
 Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff time)
 
Time m_slotTime
 Length of one slot.
 

Private Attributes

uint32_t m_numBackoffRetries
 Number of times that the transmitter has tried to unsuccessfuly transmit the current packet.
 
Ptr< UniformRandomVariablem_rng
 Random number generator.
 

Detailed Description

The backoff class is used for calculating backoff times when many net devices can write to the same channel.

Definition at line 27 of file backoff.h.

Constructor & Destructor Documentation

◆ Backoff() [1/2]

ns3::Backoff::Backoff ( )

Definition at line 18 of file backoff.cc.

References ns3::CreateObject(), m_ceiling, m_maxRetries, m_maxSlots, m_minSlots, m_numBackoffRetries, m_rng, m_slotTime, ns3::MicroSeconds(), and ResetBackoffTime().

+ Here is the call graph for this function:

◆ Backoff() [2/2]

ns3::Backoff::Backoff ( Time slotTime,
uint32_t minSlots,
uint32_t maxSlots,
uint32_t ceiling,
uint32_t maxRetries )

Constructor.

Parameters
slotTimeLength of one slot
minSlotsMinimum number of backoff slots
maxSlotsMaximum number of backoff slots
ceilingCap to the exponential function
maxRetriesMaximum number of transmission retries

Definition at line 31 of file backoff.cc.

References ns3::CreateObject(), m_ceiling, m_maxRetries, m_maxSlots, m_minSlots, m_numBackoffRetries, m_rng, and m_slotTime.

+ Here is the call graph for this function:

Member Function Documentation

◆ AssignStreams()

int64_t ns3::Backoff::AssignStreams ( int64_t stream)

Assign a fixed random variable stream number to the random variables used by this model.

Return the number of streams (possibly zero) that have been assigned.

Parameters
streamfirst stream index to use
Returns
the number of stream indices assigned by this model

Definition at line 92 of file backoff.cc.

References m_rng, and NS_LOG_FUNCTION.

Referenced by ns3::CsmaNetDevice::AssignStreams().

+ Here is the caller graph for this function:

◆ GetBackoffTime()

Time ns3::Backoff::GetBackoffTime ( )
Returns
The amount of time that the net device should wait before trying to retransmit the packet

Definition at line 47 of file backoff.cc.

References m_ceiling, m_maxSlots, m_minSlots, m_numBackoffRetries, m_rng, and m_slotTime.

Referenced by ns3::CsmaNetDevice::TransmitStart().

+ Here is the caller graph for this function:

◆ IncrNumRetries()

void ns3::Backoff::IncrNumRetries ( )

Increments the number of retries by 1.

Definition at line 86 of file backoff.cc.

References m_numBackoffRetries.

Referenced by ns3::CsmaNetDevice::TransmitStart().

+ Here is the caller graph for this function:

◆ MaxRetriesReached()

bool ns3::Backoff::MaxRetriesReached ( ) const
Returns
True if the maximum number of retries has been reached

Definition at line 80 of file backoff.cc.

References m_maxRetries, and m_numBackoffRetries.

Referenced by ns3::CsmaNetDevice::TransmitStart().

+ Here is the caller graph for this function:

◆ ResetBackoffTime()

void ns3::Backoff::ResetBackoffTime ( )

Indicates to the backoff object that the last packet was successfully transmitted and that the number of retries should be reset to 0.

Definition at line 74 of file backoff.cc.

References m_numBackoffRetries.

Referenced by Backoff(), ns3::CsmaNetDevice::TransmitAbort(), and ns3::CsmaNetDevice::TransmitStart().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_ceiling

uint32_t ns3::Backoff::m_ceiling

Caps the exponential function when the number of retries reaches m_ceiling.

Definition at line 45 of file backoff.h.

Referenced by Backoff(), Backoff(), GetBackoffTime(), and ns3::CsmaNetDevice::SetBackoffParams().

◆ m_maxRetries

uint32_t ns3::Backoff::m_maxRetries

Maximum number of transmission retries before the packet is dropped.

Definition at line 50 of file backoff.h.

Referenced by Backoff(), Backoff(), MaxRetriesReached(), and ns3::CsmaNetDevice::SetBackoffParams().

◆ m_maxSlots

uint32_t ns3::Backoff::m_maxSlots

Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff time)

Definition at line 40 of file backoff.h.

Referenced by Backoff(), Backoff(), GetBackoffTime(), and ns3::CsmaNetDevice::SetBackoffParams().

◆ m_minSlots

uint32_t ns3::Backoff::m_minSlots

Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff time)

Definition at line 34 of file backoff.h.

Referenced by Backoff(), Backoff(), GetBackoffTime(), and ns3::CsmaNetDevice::SetBackoffParams().

◆ m_numBackoffRetries

uint32_t ns3::Backoff::m_numBackoffRetries
private

Number of times that the transmitter has tried to unsuccessfuly transmit the current packet.

Definition at line 110 of file backoff.h.

Referenced by Backoff(), Backoff(), GetBackoffTime(), IncrNumRetries(), MaxRetriesReached(), and ResetBackoffTime().

◆ m_rng

Ptr<UniformRandomVariable> ns3::Backoff::m_rng
private

Random number generator.

Definition at line 115 of file backoff.h.

Referenced by Backoff(), Backoff(), AssignStreams(), and GetBackoffTime().

◆ m_slotTime

Time ns3::Backoff::m_slotTime

Length of one slot.

A slot time, it usually the packet transmission time, if the packet size is fixed.

Definition at line 56 of file backoff.h.

Referenced by Backoff(), Backoff(), GetBackoffTime(), and ns3::CsmaNetDevice::SetBackoffParams().


The documentation for this class was generated from the following files: