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
* 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
#include "
block-ack-window.h
"
21
22
#include "
wifi-utils.h
"
23
24
#include "ns3/log.h"
25
26
namespace
ns3
27
{
28
29
NS_LOG_COMPONENT_DEFINE
(
"BlockAckWindow"
);
30
31
BlockAckWindow::BlockAckWindow
()
32
: m_winStart(0),
33
m_head(0)
34
{
35
}
36
37
void
38
BlockAckWindow::Init
(uint16_t winStart, uint16_t winSize)
39
{
40
NS_LOG_FUNCTION
(
this
<< winStart << winSize);
41
m_winStart
= winStart;
42
m_window
.assign(winSize,
false
);
43
m_head
= 0;
44
}
45
46
void
47
BlockAckWindow::Reset
(uint16_t winStart)
48
{
49
Init
(winStart,
m_window
.size());
50
}
51
52
uint16_t
53
BlockAckWindow::GetWinStart
()
const
54
{
55
return
m_winStart
;
56
}
57
58
uint16_t
59
BlockAckWindow::GetWinEnd
()
const
60
{
61
return
(
m_winStart
+
m_window
.size() - 1) %
SEQNO_SPACE_SIZE
;
62
}
63
64
std::size_t
65
BlockAckWindow::GetWinSize
()
const
66
{
67
return
m_window
.size();
68
}
69
70
std::vector<bool>::reference
71
BlockAckWindow::At
(std::size_t distance)
72
{
73
NS_ASSERT
(distance <
m_window
.size());
74
75
return
m_window
.at((
m_head
+ distance) %
m_window
.size());
76
}
77
78
std::vector<bool>::const_reference
79
BlockAckWindow::At
(std::size_t distance)
const
80
{
81
NS_ASSERT
(distance <
m_window
.size());
82
83
return
m_window
.at((
m_head
+ distance) %
m_window
.size());
84
}
85
86
void
87
BlockAckWindow::Advance
(std::size_t count)
88
{
89
NS_LOG_FUNCTION
(
this
<< count);
90
91
if
(count >=
m_window
.size())
92
{
93
Reset
((
m_winStart
+ count) %
SEQNO_SPACE_SIZE
);
94
return
;
95
}
96
97
for
(std::size_t i = 0; i < count; i++)
98
{
99
m_window
[
m_head
] =
false
;
100
m_head
= (
m_head
+ 1) %
m_window
.size();
101
}
102
m_winStart
= (
m_winStart
+ count) %
SEQNO_SPACE_SIZE
;
103
}
104
105
}
// 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: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
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:66
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:238
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:133
wifi-utils.h
src
wifi
model
block-ack-window.cc
Generated on Sun Jul 2 2023 18:22:08 for ns-3 by
1.9.6