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