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