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 #include "block-ack-agreement.h"
21 #include "ns3/log.h"
22 
23 namespace ns3 {
24 
25 NS_LOG_COMPONENT_DEFINE ("BlockAckAgreement");
26 
28  : m_amsduSupported (0),
29  m_blockAckPolicy (1),
30  m_htSupported (0),
31  m_inactivityEvent ()
32 {
33  NS_LOG_FUNCTION (this);
34 }
35 
37  : m_amsduSupported (0),
38  m_blockAckPolicy (1),
39  m_htSupported (0),
40  m_inactivityEvent ()
41 {
42  NS_LOG_FUNCTION (this << peer << static_cast<uint32_t> (tid));
43  m_tid = tid;
44  m_peer = peer;
45 }
46 
48 {
49  NS_LOG_FUNCTION (this);
51 }
52 
53 void
54 BlockAckAgreement::SetBufferSize (uint16_t bufferSize)
55 {
56  NS_LOG_FUNCTION (this << bufferSize);
57  NS_ASSERT (bufferSize <= 1024);
58  NS_ASSERT (bufferSize % 16 == 0);
59  m_bufferSize = bufferSize;
60 }
61 void
63 {
64  NS_LOG_FUNCTION (this << timeout);
66 }
67 void
69 {
70  NS_LOG_FUNCTION (this << seq);
71  NS_ASSERT (seq < 4096);
72  m_startingSeq = seq;
73 }
74 void
76 {
77  NS_LOG_FUNCTION (this);
78  m_blockAckPolicy = 1;
79 }
80 void
82 {
83  NS_LOG_FUNCTION (this);
84  m_blockAckPolicy = 0;
85 }
86 void
88 {
89  NS_LOG_FUNCTION (this << supported);
90  m_amsduSupported = supported;
91 }
92 
93 uint8_t
95 {
96  NS_LOG_FUNCTION (this);
97  return m_tid;
98 }
101 {
102  NS_LOG_FUNCTION (this);
103  return m_peer;
104 }
105 uint16_t
107 {
108  NS_LOG_FUNCTION (this);
109  return m_bufferSize;
110 }
111 uint16_t
113 {
114  NS_LOG_FUNCTION (this);
115  return m_timeout;
116 }
117 uint16_t
119 {
120  NS_LOG_FUNCTION (this);
121  return m_startingSeq;
122 }
123 uint16_t
125 {
126  NS_LOG_FUNCTION (this);
127  uint16_t seqControl = (m_startingSeq << 4) | 0xfff0;
128  return seqControl;
129 }
130 bool
132 {
133  NS_LOG_FUNCTION (this);
134  return (m_blockAckPolicy == 1);
135 }
136 bool
138 {
139  NS_LOG_FUNCTION (this);
140  return (m_amsduSupported == 1) ? true : false;
141 }
142 uint16_t
144 {
145  return m_winEnd;
146 }
147 void
149 {
150  m_winEnd = seq;
151 }
152 void
154 {
155  NS_LOG_FUNCTION (this << htSupported);
156  m_htSupported = htSupported;
157 }
158 bool
160 {
161  NS_LOG_FUNCTION (this);
162  return (m_htSupported == 1) ? true : false;
163 }
164 
165 } // 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.
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 squence 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.