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(false),
25 m_blockAckPolicy(1),
26 m_tid(tid),
27 m_htSupported(false),
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
139
140uint16_t
145
146void
148{
149 NS_LOG_FUNCTION(this << htSupported);
150 m_htSupported = htSupported;
151}
152
153bool
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
173 {static_cast<uint8_t>(*it / 8)}};
174}
175
178{
179 if (!m_htSupported)
180 {
182 }
183 // Multi-TID Block Ack Request is not currently supported
185}
186
187std::size_t
188BlockAckAgreement::GetDistance(uint16_t seqNumber, uint16_t startingSeqNumber)
189{
190 NS_ASSERT(seqNumber < SEQNO_SPACE_SIZE && startingSeqNumber < SEQNO_SPACE_SIZE);
191 return (seqNumber - startingSeqNumber + SEQNO_SPACE_SIZE) % SEQNO_SPACE_SIZE;
192}
193
194void
196{
197 m_gcrGroupAddress = gcrGroupAddress;
198}
199
200const std::optional<Mac48Address>&
205
206} // 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 SetGcrGroupAddress(const Mac48Address &gcrGroupAddress)
Set the GCR group address for this agreement.
void SetImmediateBlockAck()
Set block ack policy to immediate Ack.
void SetStartingSequence(uint16_t seq)
Set starting sequence number.
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.
bool m_amsduSupported
Flag whether MSDU aggregation is supported.
std::optional< Mac48Address > m_gcrGroupAddress
the optional GCR group address
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.
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.
const std::optional< Mac48Address > & GetGcrGroupAddress() const
Get the GCR group address of this agreement if it is a GCR Block Ack agreement.
uint16_t GetBufferSize() const
Return the buffer size.
bool m_htSupported
Flag whether HT is supported.
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:185
ns3::Time timeout
The different BlockAckRequest variants.
The different BlockAck variants.