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
block-ack-window.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019 Universita' degli Studi di Napoli Federico II
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: Stefano Avallone <stavallo@unina.it>
18
*/
19
20
#ifndef BLOCK_ACK_WINDOW_H
21
#define BLOCK_ACK_WINDOW_H
22
23
#include <cstdint>
24
#include <vector>
25
26
namespace
ns3
27
{
28
29
/**
30
* \ingroup wifi
31
* \brief Block ack window
32
*
33
* This class provides the basic functionalities of a window sliding over a
34
* bitmap: accessing any element in the bitmap and moving the window forward
35
* a given number of positions. This class can be used to implement both
36
* an originator's window and a recipient's window.
37
*
38
* The window is implemented as a vector of bool and managed as a circular
39
* queue. The window is moved forward by advancing the head of the queue and
40
* clearing the elements that become part of the tail of the queue. Hence,
41
* no element is required to be shifted when the window moves forward.
42
*
43
* Example:
44
*
45
* |0|1|1|0|1|1|1|0|1|1|1|1|1|1|1|0|
46
* ^
47
* |
48
* HEAD
49
*
50
* After moving the window forward three positions:
51
*
52
* |0|1|1|0|1|1|1|0|1|1|0|0|0|1|1|0|
53
* ^
54
* |
55
* HEAD
56
*/
57
class
BlockAckWindow
58
{
59
public
:
60
/**
61
* Constructor
62
*/
63
BlockAckWindow
();
64
/**
65
* Initialize the window with the given starting sequence number and size
66
*
67
* \param winStart the window start
68
* \param winSize the window size
69
*/
70
void
Init
(uint16_t winStart, uint16_t winSize);
71
/**
72
* Reset the window by clearing all the elements and setting winStart to the
73
* given value.
74
*
75
* \param winStart the window start
76
*/
77
void
Reset
(uint16_t winStart);
78
/**
79
* Get the current winStart value.
80
*
81
* \return the current winStart value
82
*/
83
uint16_t
GetWinStart
()
const
;
84
/**
85
* Get the current winEnd value.
86
*
87
* \return the current winEnd value
88
*/
89
uint16_t
GetWinEnd
()
const
;
90
/**
91
* Get the window size.
92
*
93
* \return the window size
94
*/
95
std::size_t
GetWinSize
()
const
;
96
/**
97
* Get a reference to the element in the window having the given distance from
98
* the current winStart. Note that the given distance must be less than the
99
* window size.
100
*
101
* \param distance the given distance
102
* \return a reference to the element in the window having the given distance
103
* from the current winStart
104
*/
105
std::vector<bool>::reference
At
(std::size_t distance);
106
/**
107
* Get a const reference to the element in the window having the given distance from
108
* the current winStart. Note that the given distance must be less than the
109
* window size.
110
*
111
* \param distance the given distance
112
* \return a const reference to the element in the window having the given distance
113
* from the current winStart
114
*/
115
std::vector<bool>::const_reference
At
(std::size_t distance)
const
;
116
/**
117
* Advance the current winStart by the given number of positions.
118
*
119
* \param count the number of positions the current winStart must be advanced by
120
*/
121
void
Advance
(std::size_t count);
122
123
private
:
124
uint16_t
m_winStart
;
///< window start (sequence number)
125
std::vector<bool>
m_window
;
///< window
126
std::size_t
m_head
;
///< index of winStart in the vector
127
};
128
129
}
// namespace ns3
130
131
#endif
/* BLOCK_ACK_WINDOW_H */
ns3::BlockAckWindow
Block ack window.
Definition:
block-ack-window.h:58
ns3::BlockAckWindow::Reset
void Reset(uint16_t winStart)
Reset the window by clearing all the elements and setting winStart to the given value.
Definition:
block-ack-window.cc:47
ns3::BlockAckWindow::BlockAckWindow
BlockAckWindow()
Constructor.
Definition:
block-ack-window.cc:31
ns3::BlockAckWindow::GetWinSize
std::size_t GetWinSize() const
Get the window size.
Definition:
block-ack-window.cc:65
ns3::BlockAckWindow::Advance
void Advance(std::size_t count)
Advance the current winStart by the given number of positions.
Definition:
block-ack-window.cc:87
ns3::BlockAckWindow::GetWinStart
uint16_t GetWinStart() const
Get the current winStart value.
Definition:
block-ack-window.cc:53
ns3::BlockAckWindow::GetWinEnd
uint16_t GetWinEnd() const
Get the current winEnd value.
Definition:
block-ack-window.cc:59
ns3::BlockAckWindow::m_winStart
uint16_t m_winStart
window start (sequence number)
Definition:
block-ack-window.h:124
ns3::BlockAckWindow::m_head
std::size_t m_head
index of winStart in the vector
Definition:
block-ack-window.h:126
ns3::BlockAckWindow::Init
void Init(uint16_t winStart, uint16_t winSize)
Initialize the window with the given starting sequence number and size.
Definition:
block-ack-window.cc:38
ns3::BlockAckWindow::m_window
std::vector< bool > m_window
window
Definition:
block-ack-window.h:125
ns3::BlockAckWindow::At
std::vector< bool >::reference At(std::size_t distance)
Get a reference to the element in the window having the given distance from the current winStart.
Definition:
block-ack-window.cc:71
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
wifi
model
block-ack-window.h
Generated on Tue May 28 2024 23:40:06 for ns-3 by
1.9.6