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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca
18 * Derived from the p2p net device file
19Transmi */
20
21#ifndef BACKOFF_H
22#define BACKOFF_H
23
24#include "ns3/nstime.h"
25#include "ns3/random-variable-stream.h"
26
27#include <stdint.h>
28
29namespace ns3
30{
31
32/**
33 * \ingroup csma
34 * \brief The backoff class is used for calculating backoff times
35 * when many net devices can write to the same channel
36 */
37
39{
40 public:
41 /**
42 * Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff
43 * time)
44 */
46
47 /**
48 * Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff
49 * time)
50 */
52
53 /**
54 * Caps the exponential function when the number of retries reaches m_ceiling.
55 */
57
58 /**
59 * Maximum number of transmission retries before the packet is dropped.
60 */
62
63 /**
64 * Length of one slot. A slot time, it usually the packet transmission time, if the packet size
65 * is fixed.
66 */
68
69 Backoff();
70 /**
71 * \brief Constructor
72 * \param slotTime Length of one slot
73 * \param minSlots Minimum number of backoff slots
74 * \param maxSlots Maximum number of backoff slots
75 * \param ceiling Cap to the exponential function
76 * \param maxRetries Maximum number of transmission retries
77 */
78 Backoff(Time slotTime,
79 uint32_t minSlots,
80 uint32_t maxSlots,
81 uint32_t ceiling,
82 uint32_t maxRetries);
83
84 /**
85 * \return The amount of time that the net device should wait before
86 * trying to retransmit the packet
87 */
89
90 /**
91 * Indicates to the backoff object that the last packet was
92 * successfully transmitted and that the number of retries should be
93 * reset to 0.
94 */
95 void ResetBackoffTime();
96
97 /**
98 * \return True if the maximum number of retries has been reached
99 */
100 bool MaxRetriesReached() const;
101
102 /**
103 * Increments the number of retries by 1.
104 */
105 void IncrNumRetries();
106
107 /**
108 * Assign a fixed random variable stream number to the random variables
109 * used by this model. Return the number of streams (possibly zero) that
110 * have been assigned.
111 *
112 * \param stream first stream index to use
113 * \return the number of stream indices assigned by this model
114 */
115 int64_t AssignStreams(int64_t stream);
116
117 private:
118 /**
119 * Number of times that the transmitter has tried to unsuccessfuly transmit the current packet.
120 */
122
123 /**
124 * Random number generator
125 */
127};
128
129} // namespace ns3
130
131#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:39
void ResetBackoffTime()
Indicates to the backoff object that the last packet was successfully transmitted and that the number...
Definition: backoff.cc:85
uint32_t m_maxRetries
Maximum number of transmission retries before the packet is dropped.
Definition: backoff.h:61
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: backoff.cc:103
uint32_t m_maxSlots
Maximum number of backoff slots (when multiplied by m_slotTime, determines maximum backoff time)
Definition: backoff.h:51
uint32_t m_numBackoffRetries
Number of times that the transmitter has tried to unsuccessfuly transmit the current packet.
Definition: backoff.h:121
bool MaxRetriesReached() const
Definition: backoff.cc:91
void IncrNumRetries()
Increments the number of retries by 1.
Definition: backoff.cc:97
uint32_t m_minSlots
Minimum number of backoff slots (when multiplied by m_slotTime, determines minimum backoff time)
Definition: backoff.h:45
Time GetBackoffTime()
Definition: backoff.cc:58
Ptr< UniformRandomVariable > m_rng
Random number generator.
Definition: backoff.h:126
uint32_t m_ceiling
Caps the exponential function when the number of retries reaches m_ceiling.
Definition: backoff.h:56
Time m_slotTime
Length of one slot.
Definition: backoff.h:67
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Every class exported by the ns3 library is enclosed in the ns3 namespace.