LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 MIRKO BANCHI | 3 * Copyright (c) 2009 MIRKO BANCHI |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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· | 6 * it under the terms of the GNU General Public License version 2 as· |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mirko Banchi <mk.banchi@gmail.com> | 18 * Author: Mirko Banchi <mk.banchi@gmail.com> |
19 */ | 19 */ |
20 #include "block-ack-agreement.h" | 20 #include "block-ack-agreement.h" |
21 | 21 |
22 namespace ns3 { | 22 namespace ns3 { |
23 | 23 |
24 BlockAckAgreement::BlockAckAgreement () | 24 BlockAckAgreement::BlockAckAgreement () |
25 : m_amsduSupported (0), | 25 : m_amsduSupported (0), |
26 m_blockAckPolicy (1), | 26 m_blockAckPolicy (1), |
27 m_state (PENDING), | |
28 m_sentMpdus (0), | |
29 m_inactivityEvent () | 27 m_inactivityEvent () |
30 {} | 28 {} |
31 | 29 |
32 BlockAckAgreement::BlockAckAgreement (Mac48Address peer, uint8_t tid) | 30 BlockAckAgreement::BlockAckAgreement (Mac48Address peer, uint8_t tid) |
33 : m_amsduSupported (0), | 31 : m_amsduSupported (0), |
34 m_blockAckPolicy (1), | 32 m_blockAckPolicy (1), |
35 m_state (PENDING), | |
36 m_sentMpdus (0), | |
37 m_inactivityEvent () | 33 m_inactivityEvent () |
38 { | 34 { |
39 m_tid = tid; | 35 m_tid = tid; |
40 m_peer = peer; | 36 m_peer = peer; |
41 } | 37 } |
42 | 38 |
43 BlockAckAgreement::~BlockAckAgreement () | 39 BlockAckAgreement::~BlockAckAgreement () |
44 { | 40 { |
45 m_inactivityEvent.Cancel (); | 41 m_inactivityEvent.Cancel (); |
46 } | 42 } |
47 | 43 |
48 void | |
49 BlockAckAgreement::SetTid (uint8_t tid) | |
50 { | |
51 m_tid = tid; | |
52 } | |
53 void | |
54 BlockAckAgreement::SetPeer (Mac48Address peer) | |
55 { | |
56 m_peer = peer; | |
57 } | |
58 void | 44 void |
59 BlockAckAgreement::SetBufferSize (uint16_t bufferSize) | 45 BlockAckAgreement::SetBufferSize (uint16_t bufferSize) |
60 { | 46 { |
61 NS_ASSERT (bufferSize <= 1024); | 47 NS_ASSERT (bufferSize <= 1024); |
62 m_bufferSize = bufferSize; | 48 m_bufferSize = bufferSize; |
63 } | 49 } |
64 void | 50 void |
65 BlockAckAgreement::SetTimeout (uint16_t timeout) | 51 BlockAckAgreement::SetTimeout (uint16_t timeout) |
66 { | 52 { |
67 m_timeout = timeout; | 53 m_timeout = timeout; |
(...skipping 12 matching lines...) Expand all Loading... |
80 void | 66 void |
81 BlockAckAgreement::SetDelayedBlockAck (void) | 67 BlockAckAgreement::SetDelayedBlockAck (void) |
82 { | 68 { |
83 m_blockAckPolicy = 0; | 69 m_blockAckPolicy = 0; |
84 } | 70 } |
85 void | 71 void |
86 BlockAckAgreement::SetAmsduSupport (bool supported) | 72 BlockAckAgreement::SetAmsduSupport (bool supported) |
87 { | 73 { |
88 m_amsduSupported = supported; | 74 m_amsduSupported = supported; |
89 } | 75 } |
90 void | |
91 BlockAckAgreement::SetState (enum State state) | |
92 { | |
93 m_state = state; | |
94 if (state == INACTIVE) | |
95 { | |
96 m_sentMpdus = 0; | |
97 } | |
98 } | |
99 void | |
100 BlockAckAgreement::NotifyMpduTransmission (void) | |
101 { | |
102 NS_ASSERT (m_sentMpdus < m_bufferSize); | |
103 m_sentMpdus++; | |
104 } | |
105 | |
106 | 76 |
107 uint8_t | 77 uint8_t |
108 BlockAckAgreement::GetTid (void) const | 78 BlockAckAgreement::GetTid (void) const |
109 { | 79 { |
110 return m_tid; | 80 return m_tid; |
111 } | 81 } |
112 Mac48Address | 82 Mac48Address |
113 BlockAckAgreement::GetPeer (void) const | 83 BlockAckAgreement::GetPeer (void) const |
114 { | 84 { |
115 return m_peer; | 85 return m_peer; |
(...skipping 22 matching lines...) Expand all Loading... |
138 bool | 108 bool |
139 BlockAckAgreement::IsImmediateBlockAck (void) const | 109 BlockAckAgreement::IsImmediateBlockAck (void) const |
140 { | 110 { |
141 return (m_blockAckPolicy == 1); | 111 return (m_blockAckPolicy == 1); |
142 } | 112 } |
143 bool | 113 bool |
144 BlockAckAgreement::IsAmsduSupported (void) const | 114 BlockAckAgreement::IsAmsduSupported (void) const |
145 { | 115 { |
146 return (m_amsduSupported == 1)?true:false; | 116 return (m_amsduSupported == 1)?true:false; |
147 } | 117 } |
148 bool | |
149 BlockAckAgreement::IsPending (void) const | |
150 { | |
151 return (m_state == PENDING)?true:false; | |
152 } | |
153 bool | |
154 BlockAckAgreement::IsEstablished (void) const | |
155 { | |
156 return (m_state == ESTABLISHED)?true:false; | |
157 } | |
158 bool | |
159 BlockAckAgreement::IsInactive (void) const | |
160 { | |
161 return (m_state == INACTIVE)?true:false; | |
162 } | |
163 bool | |
164 BlockAckAgreement::IsUnsuccessful (void) const | |
165 { | |
166 return (m_state == UNSUCCESSFUL)?true:false; | |
167 } | |
168 bool | |
169 BlockAckAgreement::NeedBlockAckRequest (void) const | |
170 { | |
171 return (m_sentMpdus == m_bufferSize/2)?true:false; | |
172 } | |
173 void | |
174 BlockAckAgreement::CompleteExchange (void) | |
175 { | |
176 m_sentMpdus = 0; | |
177 } | |
178 | |
179 bool | |
180 BlockAckAgreement::operator== (BlockAckAgreement const &agreement) | |
181 { | |
182 return (m_tid == agreement.m_tid && m_peer == agreement.m_peer); | |
183 } | |
184 bool operator< (BlockAckAgreement const &agreement1, BlockAckAgreement const &ag
reement2) | |
185 { | |
186 return (agreement1.GetTid () < agreement2.GetTid ()); | |
187 } | |
188 | 118 |
189 } //namespace ns3 | 119 } //namespace ns3 |
LEFT | RIGHT |