A Discrete-Event Network Simulator
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
8Transmi */
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
18namespace 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
28{
29 public:
30 /**
31 * Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff
32 * time)
33 */
35
36 /**
37 * Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff
38 * time)
39 */
41
42 /**
43 * Caps the exponential function when the number of retries reaches m_ceiling.
44 */
46
47 /**
48 * Maximum number of transmission retries before the packet is dropped.
49 */
51
52 /**
53 * Length of one slot. A slot time, it usually the packet transmission time, if the packet size
54 * is fixed.
55 */
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 */
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 */
111
112 /**
113 * Random number generator
114 */
116};
117
118} // namespace ns3
119
120#endif /* BACKOFF_H */
The backoff class is used for calculating backoff times when many net devices can write to the same c...
Definition backoff.h:28
void ResetBackoffTime()
Indicates to the backoff object that the last packet was successfully transmitted and that the number...
Definition backoff.cc:74
uint32_t m_maxRetries
Maximum number of transmission retries before the packet is dropped.
Definition backoff.h:50
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
uint32_t m_maxSlots
Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff time)
Definition backoff.h:40
uint32_t m_numBackoffRetries
Number of times that the transmitter has tried to unsuccessfuly transmit the current packet.
Definition backoff.h:110
bool MaxRetriesReached() const
Definition backoff.cc:80
void IncrNumRetries()
Increments the number of retries by 1.
Definition backoff.cc:86
uint32_t m_minSlots
Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff time)
Definition backoff.h:34
Time GetBackoffTime()
Definition backoff.cc:47
Ptr< UniformRandomVariable > m_rng
Random number generator.
Definition backoff.h:115
uint32_t m_ceiling
Caps the exponential function when the number of retries reaches m_ceiling.
Definition backoff.h:45
Time m_slotTime
Length of one slot.
Definition backoff.h:56
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Every class exported by the ns3 library is enclosed in the ns3 namespace.