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_peer (peer),
30  m_amsduSupported (0),
31  m_blockAckPolicy (1),
32  m_tid (tid),
33  m_htSupported (0),
34  m_inactivityEvent ()
35 {
36  NS_LOG_FUNCTION (this << peer << +tid);
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 <= 256);
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  return m_tid;
102 }
103 
106 {
107  NS_LOG_FUNCTION (this);
108  return m_peer;
109 }
110 
111 uint16_t
113 {
114  return m_bufferSize;
115 }
116 
117 uint16_t
119 {
120  return m_timeout;
121 }
122 
123 uint16_t
125 {
126  return m_startingSeq;
127 }
128 
129 uint16_t
131 {
132  uint16_t seqControl = (m_startingSeq << 4) & 0xfff0;
133  return seqControl;
134 }
135 
136 bool
138 {
139  return (m_blockAckPolicy == 1);
140 }
141 
142 bool
144 {
145  return (m_amsduSupported == 1) ? true : false;
146 }
147 
148 uint16_t
150 {
151  return m_winEnd;
152 }
153 
154 void
156 {
157  m_winEnd = seq;
158 }
159 
160 void
162 {
163  NS_LOG_FUNCTION (this << htSupported);
164  m_htSupported = htSupported;
165 }
166 
167 bool
169 {
170  return (m_htSupported == 1) ? true : false;
171 }
172 
173 } //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:204
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.