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 "ns3/log.h"
22 #include "block-ack-agreement.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 << peer << +tid);
35  m_tid = tid;
36  m_peer = peer;
37 }
38 
40 {
41  NS_LOG_FUNCTION (this);
43 }
44 
45 void
46 BlockAckAgreement::SetBufferSize (uint16_t bufferSize)
47 {
48  NS_LOG_FUNCTION (this << bufferSize);
49  NS_ASSERT (bufferSize <= 1024);
50  NS_ASSERT (bufferSize % 16 == 0);
51  m_bufferSize = bufferSize;
52 }
53 
54 void
56 {
57  NS_LOG_FUNCTION (this << timeout);
59 }
60 
61 void
63 {
64  NS_LOG_FUNCTION (this << seq);
65  NS_ASSERT (seq < 4096);
66  m_startingSeq = seq;
67 }
68 
69 void
71 {
72  NS_LOG_FUNCTION (this << seq);
73  NS_ASSERT (((seq >> 4) & 0x0fff) < 4096);
74  m_startingSeq = (seq >> 4) & 0x0fff;
75 }
76 
77 void
79 {
80  NS_LOG_FUNCTION (this);
81  m_blockAckPolicy = 1;
82 }
83 
84 void
86 {
87  NS_LOG_FUNCTION (this);
88  m_blockAckPolicy = 0;
89 }
90 
91 void
93 {
94  NS_LOG_FUNCTION (this << supported);
95  m_amsduSupported = supported;
96 }
97 
98 uint8_t
100 {
101  NS_LOG_FUNCTION (this);
102  return m_tid;
103 }
104 
107 {
108  NS_LOG_FUNCTION (this);
109  return m_peer;
110 }
111 
112 uint16_t
114 {
115  NS_LOG_FUNCTION (this);
116  return m_bufferSize;
117 }
118 
119 uint16_t
121 {
122  NS_LOG_FUNCTION (this);
123  return m_timeout;
124 }
125 
126 uint16_t
128 {
129  NS_LOG_FUNCTION (this);
130  return m_startingSeq;
131 }
132 
133 uint16_t
135 {
136  NS_LOG_FUNCTION (this);
137  uint16_t seqControl = (m_startingSeq << 4) & 0xfff0;
138  return seqControl;
139 }
140 
141 bool
143 {
144  NS_LOG_FUNCTION (this);
145  return (m_blockAckPolicy == 1);
146 }
147 
148 bool
150 {
151  NS_LOG_FUNCTION (this);
152  return (m_amsduSupported == 1) ? true : false;
153 }
154 
155 uint16_t
157 {
158  return m_winEnd;
159 }
160 
161 void
163 {
164  m_winEnd = seq;
165 }
166 
167 void
169 {
170  NS_LOG_FUNCTION (this << htSupported);
171  m_htSupported = htSupported;
172 }
173 
174 bool
176 {
177  NS_LOG_FUNCTION (this);
178  return (m_htSupported == 1) ? true : false;
179 }
180 
181 } //namespace ns3
#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 GetWinEnd(void) const
Return the ending sequence number.
#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
uint16_t GetStartingSequence(void) const
Return the starting squence number.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
uint16_t m_startingSeq
Starting squence control.
ns3::Time timeout
bool IsHtSupported(void) const
Check whether HT is supported.
bool IsImmediateBlockAck(void) const
Check whether the current ACK policy is immediate block ACK.
uint16_t m_winEnd
Ending sequence number.
uint16_t m_timeout
Timeout.
uint8_t m_tid
Traffic ID.
uint8_t m_htSupported
Flag whether HT is supported.
uint16_t GetTimeout(void) const
Return the timeout.
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.
Mac48Address GetPeer(void) const
Return the peer address.
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.
bool IsAmsduSupported(void) const
Check whether A-MSDU is supported.
void SetDelayedBlockAck(void)
Set Block ACK policy to delayed ACK.
EventId m_inactivityEvent
inactivity event
void SetAmsduSupport(bool supported)
Enable or disable A-MSDU support.
uint16_t GetBufferSize(void) const
Return the buffer size.
uint16_t GetStartingSequenceControl(void) const
Return the starting sequence control.
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.
void SetBufferSize(uint16_t bufferSize)
Set buffer size.
uint8_t GetTid(void) const
Return the Traffic ID (TID).
void SetHtSupported(bool htSupported)
Enable or disable HT support.
BlockAckAgreement(Mac48Address peer, uint8_t tid)
Constructor for BlockAckAgreement with given peer and TID.