A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
backoff.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007 Emmanuelle Laprise
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca
7
* Derived from the p2p net device file
8
Transmi */
9
10
#ifndef BACKOFF_H
11
#define BACKOFF_H
12
13
#include "ns3/nstime.h"
14
#include "ns3/random-variable-stream.h"
15
16
#include <stdint.h>
17
18
namespace
ns3
19
{
20
21
/**
22
* \ingroup csma
23
* \brief The backoff class is used for calculating backoff times
24
* when many net devices can write to the same channel
25
*/
26
27
class
Backoff
28
{
29
public
:
30
/**
31
* Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff
32
* time)
33
*/
34
uint32_t
m_minSlots
;
35
36
/**
37
* Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff
38
* time)
39
*/
40
uint32_t
m_maxSlots
;
41
42
/**
43
* Caps the exponential function when the number of retries reaches m_ceiling.
44
*/
45
uint32_t
m_ceiling
;
46
47
/**
48
* Maximum number of transmission retries before the packet is dropped.
49
*/
50
uint32_t
m_maxRetries
;
51
52
/**
53
* Length of one slot. A slot time, it usually the packet transmission time, if the packet size
54
* is fixed.
55
*/
56
Time
m_slotTime
;
57
58
Backoff
();
59
/**
60
* \brief Constructor
61
* \param slotTime Length of one slot
62
* \param minSlots Minimum number of backoff slots
63
* \param maxSlots Maximum number of backoff slots
64
* \param ceiling Cap to the exponential function
65
* \param maxRetries Maximum number of transmission retries
66
*/
67
Backoff
(
Time
slotTime,
68
uint32_t
minSlots,
69
uint32_t
maxSlots,
70
uint32_t
ceiling,
71
uint32_t
maxRetries);
72
73
/**
74
* \return The amount of time that the net device should wait before
75
* trying to retransmit the packet
76
*/
77
Time
GetBackoffTime
();
78
79
/**
80
* Indicates to the backoff object that the last packet was
81
* successfully transmitted and that the number of retries should be
82
* reset to 0.
83
*/
84
void
ResetBackoffTime
();
85
86
/**
87
* \return True if the maximum number of retries has been reached
88
*/
89
bool
MaxRetriesReached
()
const
;
90
91
/**
92
* Increments the number of retries by 1.
93
*/
94
void
IncrNumRetries
();
95
96
/**
97
* Assign a fixed random variable stream number to the random variables
98
* used by this model. Return the number of streams (possibly zero) that
99
* have been assigned.
100
*
101
* \param stream first stream index to use
102
* \return the number of stream indices assigned by this model
103
*/
104
int64_t
AssignStreams
(int64_t stream);
105
106
private
:
107
/**
108
* Number of times that the transmitter has tried to unsuccessfuly transmit the current packet.
109
*/
110
uint32_t
m_numBackoffRetries
;
111
112
/**
113
* Random number generator
114
*/
115
Ptr<UniformRandomVariable>
m_rng
;
116
};
117
118
}
// namespace ns3
119
120
#endif
/* BACKOFF_H */
ns3::Backoff
The backoff class is used for calculating backoff times when many net devices can write to the same c...
Definition
backoff.h:28
ns3::Backoff::ResetBackoffTime
void ResetBackoffTime()
Indicates to the backoff object that the last packet was successfully transmitted and that the number...
Definition
backoff.cc:74
ns3::Backoff::m_maxRetries
uint32_t m_maxRetries
Maximum number of transmission retries before the packet is dropped.
Definition
backoff.h:50
ns3::Backoff::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition
backoff.cc:92
ns3::Backoff::m_maxSlots
uint32_t m_maxSlots
Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff time)
Definition
backoff.h:40
ns3::Backoff::m_numBackoffRetries
uint32_t m_numBackoffRetries
Number of times that the transmitter has tried to unsuccessfuly transmit the current packet.
Definition
backoff.h:110
ns3::Backoff::MaxRetriesReached
bool MaxRetriesReached() const
Definition
backoff.cc:80
ns3::Backoff::IncrNumRetries
void IncrNumRetries()
Increments the number of retries by 1.
Definition
backoff.cc:86
ns3::Backoff::m_minSlots
uint32_t m_minSlots
Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff time)
Definition
backoff.h:34
ns3::Backoff::Backoff
Backoff()
Definition
backoff.cc:18
ns3::Backoff::GetBackoffTime
Time GetBackoffTime()
Definition
backoff.cc:47
ns3::Backoff::m_rng
Ptr< UniformRandomVariable > m_rng
Random number generator.
Definition
backoff.h:115
ns3::Backoff::m_ceiling
uint32_t m_ceiling
Caps the exponential function when the number of retries reaches m_ceiling.
Definition
backoff.h:45
ns3::Backoff::m_slotTime
Time m_slotTime
Length of one slot.
Definition
backoff.h:56
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
csma
model
backoff.h
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0