This documentation is not the
Latest Release
.
A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
block-ack-cache.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 MIRKO BANCHI
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mirko Banchi <mk.banchi@gmail.com>
19
*/
20
21
#include "
block-ack-cache.h
"
22
#include "
ctrl-headers.h
"
23
#include "
wifi-mac-header.h
"
24
#include "
qos-utils.h
"
25
#include "ns3/log.h"
26
27
#define WINSIZE_ASSERT NS_ASSERT ((m_winEnd - m_winStart + 4096) % 4096 == m_winSize - 1)
28
29
namespace
ns3
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"BlockAckCache"
);
32
33
void
34
BlockAckCache::Init
(uint16_t winStart, uint16_t winSize)
35
{
36
NS_LOG_FUNCTION
(
this
<< winStart << winSize);
37
m_winStart
= winStart;
38
m_winSize
= winSize <= 64 ? winSize : 64;
39
m_winEnd
= (
m_winStart
+
m_winSize
- 1) % 4096;
40
memset (
m_bitmap
, 0,
sizeof
(
m_bitmap
));
41
}
42
43
uint16_t
44
BlockAckCache::GetWinStart
()
45
{
46
return
m_winStart
;
47
}
48
49
void
50
BlockAckCache::UpdateWithMpdu
(
const
WifiMacHeader
*hdr)
51
{
52
NS_LOG_FUNCTION
(
this
<< hdr);
53
uint16_t seqNumber = hdr->
GetSequenceNumber
();
54
if
(!
QosUtilsIsOldPacket
(
m_winStart
, seqNumber))
55
{
56
if
(!
IsInWindow
(seqNumber))
57
{
58
uint16_t delta = (seqNumber -
m_winEnd
+ 4096) % 4096;
59
if
(delta > 1)
60
{
61
ResetPortionOfBitmap
((
m_winEnd
+ 1) % 4096, ((seqNumber - 1) + 4096) % 4096);
62
}
63
m_winStart
= (
m_winStart
+ delta) % 4096;
64
m_winEnd
= seqNumber;
65
66
WINSIZE_ASSERT
;
67
}
68
m_bitmap
[seqNumber] |= (0x0001 << hdr->
GetFragmentNumber
());
69
}
70
}
71
72
void
73
BlockAckCache::UpdateWithBlockAckReq
(uint16_t startingSeq)
74
{
75
NS_LOG_FUNCTION
(
this
<< startingSeq);
76
if
(!
QosUtilsIsOldPacket
(
m_winStart
, startingSeq))
77
{
78
if
(
IsInWindow
(startingSeq))
79
{
80
if
(startingSeq !=
m_winStart
)
81
{
82
m_winStart
= startingSeq;
83
uint16_t newWinEnd = (
m_winStart
+
m_winSize
- 1) % 4096;
84
ResetPortionOfBitmap
((
m_winEnd
+ 1) % 4096, newWinEnd);
85
m_winEnd
= newWinEnd;
86
87
WINSIZE_ASSERT
;
88
}
89
}
90
else
91
{
92
m_winStart
= startingSeq;
93
m_winEnd
= (
m_winStart
+
m_winSize
- 1) % 4096;
94
ResetPortionOfBitmap
(
m_winStart
,
m_winEnd
);
95
96
WINSIZE_ASSERT
;
97
}
98
}
99
}
100
101
void
102
BlockAckCache::ResetPortionOfBitmap
(uint16_t
start
, uint16_t end)
103
{
104
NS_LOG_FUNCTION
(
this
<< start << end);
105
uint32_t i =
start
;
106
for
(; i != end; i = (i + 1) % 4096)
107
{
108
m_bitmap
[i] = 0;
109
}
110
m_bitmap
[i] = 0;
111
}
112
113
bool
114
BlockAckCache::IsInWindow
(uint16_t seq)
115
{
116
NS_LOG_FUNCTION
(
this
<< seq);
117
return
((seq -
m_winStart
+ 4096) % 4096) <
m_winSize
;
118
}
119
120
void
121
BlockAckCache::FillBlockAckBitmap
(
CtrlBAckResponseHeader
*blockAckHeader)
122
{
123
NS_LOG_FUNCTION
(
this
<< blockAckHeader);
124
if
(blockAckHeader->
IsBasic
())
125
{
126
NS_FATAL_ERROR
(
"Basic block ack is only partially implemented."
);
127
}
128
else
if
(blockAckHeader->
IsCompressed
())
129
{
130
uint32_t i = blockAckHeader->
GetStartingSequence
();
131
uint32_t end = (i +
m_winSize
- 1) % 4096;
132
for
(; i != end; i = (i + 1) % 4096)
133
{
134
if
(
m_bitmap
[i] == 1)
135
{
136
blockAckHeader->
SetReceivedPacket
(i);
137
}
138
}
139
if
(
m_bitmap
[i] == 1)
140
{
141
blockAckHeader->
SetReceivedPacket
(i);
142
}
143
}
144
else
if
(blockAckHeader->
IsMultiTid
())
145
{
146
NS_FATAL_ERROR
(
"Multi-tid block ack is not supported."
);
147
}
148
}
149
150
}
//namespace ns3
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:213
ns3::WifiMacHeader::GetFragmentNumber
uint16_t GetFragmentNumber(void) const
Return the fragment number of the header.
Definition:
wifi-mac-header.cc:800
ns3::BlockAckCache::ResetPortionOfBitmap
void ResetPortionOfBitmap(uint16_t start, uint16_t end)
Definition:
block-ack-cache.cc:102
ns3::CtrlBAckResponseHeader::GetStartingSequence
uint16_t GetStartingSequence(void) const
Return the starting sequence number.
Definition:
ctrl-headers.cc:464
ns3::BlockAckCache::IsInWindow
bool IsInWindow(uint16_t seq)
Definition:
block-ack-cache.cc:114
visualizer.core.start
def start()
Definition:
core.py:1482
ns3::BlockAckCache::m_winStart
uint16_t m_winStart
Definition:
block-ack-cache.h:57
ns3::BlockAckCache::UpdateWithBlockAckReq
void UpdateWithBlockAckReq(uint16_t startingSeq)
Definition:
block-ack-cache.cc:73
ns3::BlockAckCache::Init
void Init(uint16_t winStart, uint16_t winSize)
Definition:
block-ack-cache.cc:34
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::CtrlBAckResponseHeader::IsCompressed
bool IsCompressed(void) const
Check if the current ACK policy is compressed ACK and not multiple TID.
Definition:
ctrl-headers.cc:478
ns3::BlockAckCache::UpdateWithMpdu
void UpdateWithMpdu(const WifiMacHeader *hdr)
Definition:
block-ack-cache.cc:50
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition:
fatal-error.h:145
ns3::QosUtilsIsOldPacket
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet. ...
Definition:
qos-utils.cc:88
qos-utils.h
ctrl-headers.h
wifi-mac-header.h
ns3::CtrlBAckResponseHeader
Headers for Block ack response.
Definition:
ctrl-headers.h:186
block-ack-cache.h
WINSIZE_ASSERT
#define WINSIZE_ASSERT
Definition:
block-ack-cache.cc:27
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::CtrlBAckResponseHeader::IsBasic
bool IsBasic(void) const
Check if the current ACK policy is basic (i.e.
Definition:
ctrl-headers.cc:471
ns3::BlockAckCache::FillBlockAckBitmap
void FillBlockAckBitmap(CtrlBAckResponseHeader *blockAckHeader)
Definition:
block-ack-cache.cc:121
ns3::BlockAckCache::m_winSize
uint8_t m_winSize
Definition:
block-ack-cache.h:58
ns3::BlockAckCache::m_winEnd
uint16_t m_winEnd
Definition:
block-ack-cache.h:59
ns3::CtrlBAckResponseHeader::SetReceivedPacket
void SetReceivedPacket(uint16_t seq)
Set the bitmap that the packet with the given sequence number was received.
Definition:
ctrl-headers.cc:603
ns3::BlockAckCache::GetWinStart
uint16_t GetWinStart(void)
When an A-MPDU is received, the window start may change to a new value depending on the sequence numb...
Definition:
block-ack-cache.cc:44
ns3::BlockAckCache::m_bitmap
uint16_t m_bitmap[4096]
Definition:
block-ack-cache.h:61
ns3::CtrlBAckResponseHeader::IsMultiTid
bool IsMultiTid(void) const
Check if the current ACK policy has multiple TID.
Definition:
ctrl-headers.cc:485
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition:
wifi-mac-header.h:81
ns3::WifiMacHeader::GetSequenceNumber
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.
Definition:
wifi-mac-header.cc:794
src
wifi
model
block-ack-cache.cc
Generated on Wed Nov 11 2015 20:00:51 for ns-3 by
1.8.9.1