A Discrete-Event Network Simulator
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
15namespace 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 */
47{
48 public:
49 /**
50 * Constructor
51 */
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 */
Block ack window.
void Reset(uint16_t winStart)
Reset the window by clearing all the elements and setting winStart to the given value.
BlockAckWindow()
Constructor.
std::size_t GetWinSize() const
Get the window size.
void Advance(std::size_t count)
Advance the current winStart by the given number of positions.
uint16_t GetWinStart() const
Get the current winStart value.
uint16_t GetWinEnd() const
Get the current winEnd value.
uint16_t m_winStart
window start (sequence number)
std::size_t m_head
index of winStart in the vector
void Init(uint16_t winStart, uint16_t winSize)
Initialize the window with the given starting sequence number and size.
std::vector< bool > m_window
window
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.