A Discrete-Event Network Simulator
API
block-ack-agreement.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 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-agreement.h"
22 #include "ns3/log.h"
23 
24 namespace ns3 {
25 
26 NS_LOG_COMPONENT_DEFINE ("BlockAckAgreement");
27 
29  : m_amsduSupported (0),
30  m_blockAckPolicy (1),
31  m_htSupported (0),
32  m_inactivityEvent ()
33 {
34  NS_LOG_FUNCTION (this);
35 }
36 
38  : m_amsduSupported (0),
39  m_blockAckPolicy (1),
40  m_htSupported (0),
41  m_inactivityEvent ()
42 {
43  NS_LOG_FUNCTION (this << peer << static_cast<uint32_t> (tid));
44  m_tid = tid;
45  m_peer = peer;
46 }
47 
49 {
50  NS_LOG_FUNCTION (this);
52 }
53 
54 void
55 BlockAckAgreement::SetBufferSize (uint16_t bufferSize)
56 {
57  NS_LOG_FUNCTION (this << bufferSize);
58  NS_ASSERT (bufferSize <= 1024);
59  NS_ASSERT (bufferSize % 16 == 0);
60  m_bufferSize = bufferSize;
61 }
62 
63 void
65 {
66  NS_LOG_FUNCTION (this << timeout);
68 }
69 
70 void
72 {
73  NS_LOG_FUNCTION (this << seq);
74  NS_ASSERT (seq < 4096);
75  m_startingSeq = seq;
76 }
77 
78 void
80 {
81  NS_LOG_FUNCTION (this << seq);
82  NS_ASSERT (((seq >> 4) & 0x0fff) < 4096);
83  m_startingSeq = (seq >> 4) & 0x0fff;
84 }
85 
86 void
88 {
89  NS_LOG_FUNCTION (this);
90  m_blockAckPolicy = 1;
91 }
92 
93 void
95 {
96  NS_LOG_FUNCTION (this);
97  m_blockAckPolicy = 0;
98 }
99 
100 void
102 {
103  NS_LOG_FUNCTION (this << supported);
104  m_amsduSupported = supported;
105 }
106 
107 uint8_t
109 {
110  NS_LOG_FUNCTION (this);
111  return m_tid;
112 }
113 
116 {
117  NS_LOG_FUNCTION (this);
118  return m_peer;
119 }
120 
121 uint16_t
123 {
124  NS_LOG_FUNCTION (this);
125  return m_bufferSize;
126 }
127 
128 uint16_t
130 {
131  NS_LOG_FUNCTION (this);
132  return m_timeout;
133 }
134 
135 uint16_t
137 {
138  NS_LOG_FUNCTION (this);
139  return m_startingSeq;
140 }
141 
142 uint16_t
144 {
145  NS_LOG_FUNCTION (this);
146  uint16_t seqControl = (m_startingSeq << 4) & 0xfff0;
147  return seqControl;
148 }
149 
150 bool
152 {
153  NS_LOG_FUNCTION (this);
154  return (m_blockAckPolicy == 1);
155 }
156 
157 bool
159 {
160  NS_LOG_FUNCTION (this);
161  return (m_amsduSupported == 1) ? true : false;
162 }
163 
164 uint16_t
166 {
167  return m_winEnd;
168 }
169 
170 void
172 {
173  m_winEnd = seq;
174 }
175 
176 void
178 {
179  NS_LOG_FUNCTION (this << htSupported);
180  m_htSupported = htSupported;
181 }
182 
183 bool
185 {
186  NS_LOG_FUNCTION (this);
187  return (m_htSupported == 1) ? true : false;
188 }
189 
190 } //namespace ns3
uint8_t GetTid(void) const
Return the Traffic ID (TID).
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Mac48Address m_peer
Peer address.
uint16_t GetTimeout(void) const
Return the timeout.
uint16_t GetWinEnd(void) const
Return the ending sequence number.
Mac48Address GetPeer(void) const
Return the peer 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:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
bool IsImmediateBlockAck(void) const
Check whether the current ACK policy is immediate block ACK.
uint16_t m_startingSeq
Starting squence control.
ns3::Time timeout
uint16_t GetStartingSequence(void) const
Return the starting squence number.
uint16_t m_winEnd
Ending sequence number.
uint16_t m_timeout
Timeout.
bool IsAmsduSupported(void) const
Check whether A-MSDU is supported.
uint8_t m_tid
Traffic ID.
uint8_t m_htSupported
Flag whether HT is supported.
uint8_t m_blockAckPolicy
Type of block ack: immediate or delayed.
void SetWinEnd(uint16_t seq)
Set ending sequence number.
void SetStartingSequenceControl(uint16_t seq)
Set starting sequence control.
uint16_t m_bufferSize
Buffer size.
void SetStartingSequence(uint16_t seq)
Set starting sequence number.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
uint8_t m_amsduSupported
Flag whether MSDU aggregation is supported.
void SetDelayedBlockAck(void)
Set Block ACK policy to delayed ACK.
void SetAmsduSupport(bool supported)
Enable or disable A-MSDU support.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
void SetImmediateBlockAck(void)
Set Block ACK policy to immediate ACK.
void SetTimeout(uint16_t timeout)
Set timeout.
bool IsHtSupported(void) const
Check whether HT is supported.
uint16_t GetStartingSequenceControl(void) const
Return the starting sequence control.
void SetBufferSize(uint16_t bufferSize)
Set buffer size.
uint16_t GetBufferSize(void) const
Return the buffer size.
void SetHtSupported(bool htSupported)
Enable or disable HT support.