A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
block-ack-agreement.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 MIRKO BANCHI
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mirko Banchi <mk.banchi@gmail.com>
7 */
8
10
11#include "wifi-utils.h"
12
13#include "ns3/log.h"
14
15#include <set>
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("BlockAckAgreement");
21
23 : m_peer(peer),
24 m_amsduSupported(0),
25 m_blockAckPolicy(1),
26 m_tid(tid),
27 m_htSupported(0),
28 m_inactivityEvent()
29{
30 NS_LOG_FUNCTION(this << peer << +tid);
31}
32
38
39void
41{
42 NS_LOG_FUNCTION(this << bufferSize);
43 m_bufferSize = bufferSize;
44}
45
46void
52
53void
55{
56 NS_LOG_FUNCTION(this << seq);
57 NS_ASSERT(seq < 4096);
58 m_startingSeq = seq;
59}
60
61void
63{
64 NS_LOG_FUNCTION(this << seq);
65 NS_ASSERT(((seq >> 4) & 0x0fff) < 4096);
66 m_startingSeq = (seq >> 4) & 0x0fff;
67}
68
69void
75
76void
82
83void
85{
86 NS_LOG_FUNCTION(this << supported);
87 m_amsduSupported = supported;
88}
89
90uint8_t
92{
93 return m_tid;
94}
95
98{
99 NS_LOG_FUNCTION(this);
100 return m_peer;
101}
102
103uint16_t
105{
106 return m_bufferSize;
107}
108
109uint16_t
111{
112 return m_timeout;
113}
114
115uint16_t
120
121uint16_t
123{
124 uint16_t seqControl = (m_startingSeq << 4) & 0xfff0;
125 return seqControl;
126}
127
128bool
133
134bool
136{
137 return m_amsduSupported == 1;
138}
139
140uint16_t
145
146void
148{
149 NS_LOG_FUNCTION(this << htSupported);
150 m_htSupported = htSupported;
151}
152
153bool
155{
156 return m_htSupported == 1;
157}
158
161{
162 if (!m_htSupported)
163 {
164 return BlockAckType::BASIC;
165 }
166
167 std::set<uint16_t> lengths{64, 256, 512, 1024}; // bitmap lengths in bits
168 // first bitmap length that is greater than or equal to the buffer size
169 auto it = lengths.lower_bound(m_bufferSize);
170 NS_ASSERT_MSG(it != lengths.cend(), "Buffer size too large: " << m_bufferSize);
171 // Multi-TID Block Ack is not currently supported
172 return {BlockAckType::COMPRESSED, {static_cast<uint8_t>(*it / 8)}};
173}
174
177{
178 if (!m_htSupported)
179 {
181 }
182 // Multi-TID Block Ack Request is not currently supported
184}
185
186std::size_t
187BlockAckAgreement::GetDistance(uint16_t seqNumber, uint16_t startingSeqNumber)
188{
189 NS_ASSERT(seqNumber < SEQNO_SPACE_SIZE && startingSeqNumber < SEQNO_SPACE_SIZE);
190 return (seqNumber - startingSeqNumber + SEQNO_SPACE_SIZE) % SEQNO_SPACE_SIZE;
191}
192
193} // namespace ns3
uint16_t GetTimeout() const
Return the timeout.
bool IsHtSupported() const
Check whether HT is supported.
BlockAckAgreement(Mac48Address peer, uint8_t tid)
Constructor for BlockAckAgreement with given peer and TID.
Mac48Address m_peer
Peer address.
void SetImmediateBlockAck()
Set block ack policy to immediate Ack.
void SetStartingSequence(uint16_t seq)
Set starting sequence number.
uint8_t m_htSupported
Flag whether HT is supported.
virtual uint16_t GetStartingSequence() const
Return the starting sequence number.
void SetStartingSequenceControl(uint16_t seq)
Set starting sequence control.
BlockAckType GetBlockAckType() const
Get the type of the Block Acks sent by the recipient of this agreement.
EventId m_inactivityEvent
inactivity event
BlockAckReqType GetBlockAckReqType() const
Get the type of the Block Ack Requests sent by the originator of this agreement.
void SetBufferSize(uint16_t bufferSize)
Set buffer size.
uint8_t m_blockAckPolicy
Type of block ack: immediate or delayed.
void SetDelayedBlockAck()
Set block ack policy to delayed Ack.
void SetAmsduSupport(bool supported)
Enable or disable A-MSDU support.
uint16_t GetWinEnd() const
Return the last sequence number covered by the ack window.
uint8_t GetTid() const
Return the Traffic ID (TID).
uint16_t m_startingSeq
Starting sequence control.
uint16_t m_bufferSize
Buffer size.
void SetTimeout(uint16_t timeout)
Set timeout.
bool IsImmediateBlockAck() const
Check whether the current ack policy is immediate BlockAck.
uint8_t m_amsduSupported
Flag whether MSDU aggregation is supported.
static std::size_t GetDistance(uint16_t seqNumber, uint16_t startingSeqNumber)
Get the distance between the given starting sequence number and the given sequence number.
uint16_t GetStartingSequenceControl() const
Return the starting sequence control.
uint16_t GetBufferSize() const
Return the buffer size.
void SetHtSupported(bool htSupported)
Enable or disable HT support.
bool IsAmsduSupported() const
Check whether A-MSDU is supported.
Mac48Address GetPeer() const
Return the peer address.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition event-id.cc:44
an EUI-48 address
#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
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static constexpr uint16_t SEQNO_SPACE_SIZE
Size of the space of sequence numbers.
Definition wifi-utils.h:176
ns3::Time timeout
The different BlockAckRequest variants.
The different BlockAck variants.