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.cc
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
#include "
block-ack-window.h
"
10
11
#include "
wifi-utils.h
"
12
13
#include "ns3/log.h"
14
15
namespace
ns3
16
{
17
18
NS_LOG_COMPONENT_DEFINE
(
"BlockAckWindow"
);
19
20
BlockAckWindow::BlockAckWindow
()
21
: m_winStart(0),
22
m_head(0)
23
{
24
}
25
26
void
27
BlockAckWindow::Init
(uint16_t winStart, uint16_t winSize)
28
{
29
NS_LOG_FUNCTION
(
this
<< winStart << winSize);
30
m_winStart
= winStart;
31
m_window
.assign(winSize,
false
);
32
m_head
= 0;
33
}
34
35
void
36
BlockAckWindow::Reset
(uint16_t winStart)
37
{
38
Init
(winStart,
m_window
.size());
39
}
40
41
uint16_t
42
BlockAckWindow::GetWinStart
()
const
43
{
44
return
m_winStart
;
45
}
46
47
uint16_t
48
BlockAckWindow::GetWinEnd
()
const
49
{
50
return
(
m_winStart
+
m_window
.size() - 1) %
SEQNO_SPACE_SIZE
;
51
}
52
53
std::size_t
54
BlockAckWindow::GetWinSize
()
const
55
{
56
return
m_window
.size();
57
}
58
59
std::vector<bool>::reference
60
BlockAckWindow::At
(std::size_t distance)
61
{
62
NS_ASSERT
(distance <
m_window
.size());
63
64
return
m_window
.at((
m_head
+ distance) %
m_window
.size());
65
}
66
67
std::vector<bool>::const_reference
68
BlockAckWindow::At
(std::size_t distance)
const
69
{
70
NS_ASSERT
(distance <
m_window
.size());
71
72
return
m_window
.at((
m_head
+ distance) %
m_window
.size());
73
}
74
75
void
76
BlockAckWindow::Advance
(std::size_t count)
77
{
78
NS_LOG_FUNCTION
(
this
<< count);
79
80
if
(count >=
m_window
.size())
81
{
82
Reset
((
m_winStart
+ count) %
SEQNO_SPACE_SIZE
);
83
return
;
84
}
85
86
for
(std::size_t i = 0; i < count; i++)
87
{
88
m_window
[
m_head
] =
false
;
89
m_head
= (
m_head
+ 1) %
m_window
.size();
90
}
91
m_winStart
= (
m_winStart
+ count) %
SEQNO_SPACE_SIZE
;
92
}
93
94
}
// namespace ns3
block-ack-window.h
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
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SEQNO_SPACE_SIZE
static constexpr uint16_t SEQNO_SPACE_SIZE
Size of the space of sequence numbers.
Definition
wifi-utils.h:176
wifi-utils.h
src
wifi
model
block-ack-window.cc
Generated on Fri Nov 8 2024 13:59:07 for ns-3 by
1.11.0