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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 namespace ns3 { | 36 namespace ns3 { |
37 | 37 |
38 BlockAckManager::Item::Item () | 38 BlockAckManager::Item::Item () |
39 {} | 39 {} |
40 | 40 |
41 BlockAckManager::Item::Item (Ptr<const Packet> packet, const WifiMacHeader &hdr,
Time tStamp) | 41 BlockAckManager::Item::Item (Ptr<const Packet> packet, const WifiMacHeader &hdr,
Time tStamp) |
42 : packet (packet), hdr (hdr), timestamp (tStamp) | 42 : packet (packet), hdr (hdr), timestamp (tStamp) |
43 {} | 43 {} |
44 | 44 |
| 45 Bar::Bar () |
| 46 {} |
| 47 |
| 48 Bar::Bar (Ptr<const Packet> bar, Mac48Address recipient, uint8_t tid, bool immed
iate) |
| 49 : bar (bar), recipient (recipient), tid (tid), immediate (immediate) |
| 50 {} |
| 51 |
45 BlockAckManager::BlockAckManager () | 52 BlockAckManager::BlockAckManager () |
46 {} | 53 {} |
47 | 54 |
48 BlockAckManager::~BlockAckManager () | 55 BlockAckManager::~BlockAckManager () |
49 { | 56 { |
50 m_queue = 0; | 57 m_queue = 0; |
51 m_agreements.clear (); | 58 m_agreements.clear (); |
52 m_retryPackets.clear (); | 59 m_retryPackets.clear (); |
53 } | 60 } |
54 | 61 |
55 bool | 62 bool |
56 BlockAckManager::ExistsAgreement (Mac48Address recipient, uint8_t tid) const | 63 BlockAckManager::ExistsAgreement (Mac48Address recipient, uint8_t tid) const |
57 { | 64 { |
58 return (m_agreements.find (std::make_pair (recipient, tid)) != m_agreements.en
d ()); | 65 return (m_agreements.find (std::make_pair (recipient, tid)) != m_agreements.en
d ()); |
59 } | 66 } |
60 | 67 |
61 bool | 68 bool |
62 BlockAckManager::ExistsAgreementInState (Mac48Address recipient, uint8_t tid,· | 69 BlockAckManager::ExistsAgreementInState (Mac48Address recipient, uint8_t tid,· |
63 enum BlockAckAgreement::State state) co
nst | 70 enum OriginatorBlockAckAgreement::State
state) const |
64 { | 71 { |
65 AgreementsCI it; | 72 AgreementsCI it; |
66 it = m_agreements.find (std::make_pair (recipient, tid)); | 73 it = m_agreements.find (std::make_pair (recipient, tid)); |
67 if (it != m_agreements.end ()) | 74 if (it != m_agreements.end ()) |
68 { | 75 { |
69 switch (state) { | 76 switch (state) { |
70 case BlockAckAgreement::INACTIVE: | 77 case OriginatorBlockAckAgreement::INACTIVE: |
71 return it->second.first.IsInactive (); | 78 return it->second.first.IsInactive (); |
72 case BlockAckAgreement::ESTABLISHED: | 79 case OriginatorBlockAckAgreement::ESTABLISHED: |
73 return it->second.first.IsEstablished (); | 80 return it->second.first.IsEstablished (); |
74 case BlockAckAgreement::PENDING: | 81 case OriginatorBlockAckAgreement::PENDING: |
75 return it->second.first.IsPending (); | 82 return it->second.first.IsPending (); |
76 case BlockAckAgreement::UNSUCCESSFUL: | 83 case OriginatorBlockAckAgreement::UNSUCCESSFUL: |
77 return it->second.first.IsUnsuccessful (); | 84 return it->second.first.IsUnsuccessful (); |
78 default: | 85 default: |
79 NS_FATAL_ERROR ("Invalid state for block ack agreement"); | 86 NS_FATAL_ERROR ("Invalid state for block ack agreement"); |
80 } | 87 } |
81 } | 88 } |
82 return false; | 89 return false; |
83 } | 90 } |
84 | 91 |
85 void | 92 void |
86 BlockAckManager::CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Addr
ess recipient) | 93 BlockAckManager::CreateAgreement (const MgtAddBaRequestHeader *reqHdr, Mac48Addr
ess recipient) |
87 { | 94 { |
88 pair<Mac48Address, uint8_t> key (recipient, reqHdr->GetTid ()); | 95 pair<Mac48Address, uint8_t> key (recipient, reqHdr->GetTid ()); |
89 BlockAckAgreement agreement; | 96 OriginatorBlockAckAgreement agreement (recipient, reqHdr->GetTid ()); |
90 agreement.SetTid (reqHdr->GetTid ()); | |
91 agreement.SetPeer (recipient); | |
92 agreement.SetStartingSequence (reqHdr->GetStartingSequence ()); | 97 agreement.SetStartingSequence (reqHdr->GetStartingSequence ()); |
93 /* for now we assume that originator doesn't use this field. Use of this field······· | 98 /* for now we assume that originator doesn't use this field. Use of this field······· |
94 is mandatory only for recipient */ | 99 is mandatory only for recipient */ |
95 agreement.SetBufferSize (0); | 100 agreement.SetBufferSize (0); |
96 agreement.SetTimeout (reqHdr->GetTimeout ()); | 101 agreement.SetTimeout (reqHdr->GetTimeout ()); |
97 agreement.SetAmsduSupport (reqHdr->IsAmsduSupported ()); | 102 agreement.SetAmsduSupport (reqHdr->IsAmsduSupported ()); |
98 if (reqHdr->IsImmediateBlockAck ()) | 103 if (reqHdr->IsImmediateBlockAck ()) |
99 { | 104 { |
100 agreement.SetImmediateBlockAck (); | 105 agreement.SetImmediateBlockAck (); |
101 }························· | 106 }························· |
102 else | 107 else |
103 { | 108 { |
104 agreement.SetDelayedBlockAck (); | 109 agreement.SetDelayedBlockAck (); |
105 } | 110 } |
106 agreement.SetState (BlockAckAgreement::PENDING); | 111 agreement.SetState (OriginatorBlockAckAgreement::PENDING); |
107 PacketQueue queue(0); | 112 PacketQueue queue(0); |
108 pair<BlockAckAgreement, PacketQueue> value (agreement, queue); | 113 pair<OriginatorBlockAckAgreement, PacketQueue> value (agreement, queue); |
109 m_agreements.insert (make_pair (key, value)); | 114 m_agreements.insert (make_pair (key, value)); |
110 m_blockPackets (recipient, reqHdr->GetTid ()); | 115 m_blockPackets (recipient, reqHdr->GetTid ()); |
111 } | 116 } |
112 | 117 |
113 void | 118 void |
114 BlockAckManager::DestroyAgreement (Mac48Address recipient, uint8_t tid) | 119 BlockAckManager::DestroyAgreement (Mac48Address recipient, uint8_t tid) |
115 { | 120 { |
116 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 121 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
117 if (it != m_agreements.end ()) | 122 if (it != m_agreements.end ()) |
118 { | 123 { |
119 for (list<PacketQueueI>::iterator i = m_retryPackets.begin (); i != m_retr
yPackets.end ();) | 124 for (list<PacketQueueI>::iterator i = m_retryPackets.begin (); i != m_retr
yPackets.end ();) |
120 { | 125 { |
121 if ((*i)->hdr.GetAddr1 () == recipient && (*i)->hdr.GetQosTid () == ti
d) | 126 if ((*i)->hdr.GetAddr1 () == recipient && (*i)->hdr.GetQosTid () == ti
d) |
122 { | 127 { |
123 i = m_retryPackets.erase (i); | 128 i = m_retryPackets.erase (i); |
124 } | 129 } |
125 else | 130 else |
126 { | 131 { |
127 i++; | 132 i++; |
128 } | 133 } |
129 } | 134 } |
130 m_agreements.erase (it); | 135 m_agreements.erase (it); |
| 136 //remove scheduled bar |
| 137 for (list<Bar>::iterator i = m_bars.begin (); i != m_bars.end ();) |
| 138 { |
| 139 if (i->recipient == recipient && i->tid == tid) |
| 140 { |
| 141 i = m_bars.erase (i); |
| 142 } |
| 143 else |
| 144 { |
| 145 i++; |
| 146 } |
| 147 } |
131 } | 148 } |
132 } | 149 } |
133 | 150 |
134 void | 151 void |
135 BlockAckManager::UpdateAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Ad
dress recipient) | 152 BlockAckManager::UpdateAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Ad
dress recipient) |
136 { | 153 { |
137 uint8_t tid = respHdr->GetTid (); | 154 uint8_t tid = respHdr->GetTid (); |
138 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 155 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
139 if (it != m_agreements.end ()) | 156 if (it != m_agreements.end ()) |
140 { | 157 { |
141 BlockAckAgreement& agreement = it->second.first; | 158 OriginatorBlockAckAgreement& agreement = it->second.first; |
142 agreement.SetBufferSize (respHdr->GetBufferSize () + 1); | 159 agreement.SetBufferSize (respHdr->GetBufferSize () + 1); |
143 agreement.SetTimeout (respHdr->GetTimeout ()); | 160 agreement.SetTimeout (respHdr->GetTimeout ()); |
144 agreement.SetAmsduSupport (respHdr->IsAmsduSupported ()); | 161 agreement.SetAmsduSupport (respHdr->IsAmsduSupported ()); |
145 if (respHdr->IsImmediateBlockAck ()) | 162 if (respHdr->IsImmediateBlockAck ()) |
146 { | 163 { |
147 agreement.SetImmediateBlockAck (); | 164 agreement.SetImmediateBlockAck (); |
148 }························· | 165 }························· |
149 else | 166 else |
150 { | 167 { |
151 agreement.SetDelayedBlockAck (); | 168 agreement.SetDelayedBlockAck (); |
152 } | 169 } |
153 agreement.SetState (BlockAckAgreement::ESTABLISHED); | 170 agreement.SetState (OriginatorBlockAckAgreement::ESTABLISHED); |
154 if (agreement.GetTimeout () != 0) | 171 if (agreement.GetTimeout () != 0) |
155 { | 172 { |
156 Time timeout = MicroSeconds (1024 * agreement.GetTimeout ()); | 173 Time timeout = MicroSeconds (1024 * agreement.GetTimeout ()); |
157 agreement.m_inactivityEvent = Simulator::Schedule (timeout,· | 174 agreement.m_inactivityEvent = Simulator::Schedule (timeout,· |
158 &BlockAckManager::I
nactivityTimeout,· | 175 &BlockAckManager::I
nactivityTimeout,· |
159 this, | 176 this, |
160 recipient, tid); | 177 recipient, tid); |
161 } | 178 } |
162 } | 179 } |
163 m_unblockPackets (recipient, tid); | 180 m_unblockPackets (recipient, tid); |
(...skipping 24 matching lines...) Expand all Loading... |
188 CleanupBuffers (); | 205 CleanupBuffers (); |
189 PacketQueueI queueIt = m_retryPackets.front (); | 206 PacketQueueI queueIt = m_retryPackets.front (); |
190 m_retryPackets.pop_front (); | 207 m_retryPackets.pop_front (); |
191 packet = queueIt->packet; | 208 packet = queueIt->packet; |
192 hdr = queueIt->hdr; | 209 hdr = queueIt->hdr; |
193 hdr.SetRetry (); | 210 hdr.SetRetry (); |
194 NS_LOG_INFO ("Retry packet seq="<<hdr.GetSequenceNumber ()); | 211 NS_LOG_INFO ("Retry packet seq="<<hdr.GetSequenceNumber ()); |
195 uint8_t tid = hdr.GetQosTid (); | 212 uint8_t tid = hdr.GetQosTid (); |
196 Mac48Address recipient = hdr.GetAddr1 (); | 213 Mac48Address recipient = hdr.GetAddr1 (); |
197 | 214 |
198 if (ExistsAgreementInState (recipient, tid, BlockAckAgreement::ESTABLISHED
) || | 215 if (ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::E
STABLISHED) || |
199 SwitchToBlockAckIfNeeded (recipient, tid, hdr.GetSequenceNumber ())) | 216 SwitchToBlockAckIfNeeded (recipient, tid, hdr.GetSequenceNumber ())) |
200 { | 217 { |
201 hdr.SetQosAckPolicy (WifiMacHeader::BLOCK_ACK); | 218 hdr.SetQosAckPolicy (WifiMacHeader::BLOCK_ACK); |
202 } | 219 } |
203 else | 220 else |
204 { | 221 { |
205 /* From section 9.10.3 in IEEE802.11e standard: | 222 /* From section 9.10.3 in IEEE802.11e standard: |
206 * In order to improve efficiency, originators using the Block Ack fac
ility | 223 * In order to improve efficiency, originators using the Block Ack fac
ility |
207 * may send MPDU frames with the Ack Policy subfield in QoS control fr
ames | 224 * may send MPDU frames with the Ack Policy subfield in QoS control fr
ames |
208 * set to Normal Ack if only a few MPDUs are available for transmissio
n.[...] | 225 * set to Normal Ack if only a few MPDUs are available for transmissio
n.[...] |
209 * When there are sufficient number of MPDUs, the originator may switc
h back to· | 226 * When there are sufficient number of MPDUs, the originator may switc
h back to· |
210 * the use of Block Ack. | 227 * the use of Block Ack. |
211 */ | 228 */ |
212 hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); | 229 hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); |
213 AgreementsI i = m_agreements.find (std::make_pair (recipient, tid)); | 230 AgreementsI i = m_agreements.find (std::make_pair (recipient, tid)); |
214 i->second.second.erase (queueIt); | 231 i->second.second.erase (queueIt); |
215 } | 232 } |
216 } | 233 } |
217 return packet; | 234 return packet; |
218 } | 235 } |
219 | 236 |
220 bool | 237 bool |
| 238 BlockAckManager::HasBar (struct Bar &bar) |
| 239 { |
| 240 if (m_bars.size () > 0) |
| 241 { |
| 242 bar = m_bars.front (); |
| 243 m_bars.pop_front (); |
| 244 return true; |
| 245 } |
| 246 return false; |
| 247 } |
| 248 |
| 249 bool |
221 BlockAckManager::HasPackets (void) const | 250 BlockAckManager::HasPackets (void) const |
222 { | 251 { |
223 return (m_retryPackets.size () > 0); | 252 return (m_retryPackets.size () > 0 || m_bars.size () > 0); |
224 } | 253 } |
225 | 254 |
226 uint32_t | 255 uint32_t |
227 BlockAckManager::GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const | 256 BlockAckManager::GetNBufferedPackets (Mac48Address recipient, uint8_t tid) const |
228 { | 257 { |
229 uint32_t nPackets = 0; | 258 uint32_t nPackets = 0; |
230 if (ExistsAgreement (recipient, tid)) | 259 if (ExistsAgreement (recipient, tid)) |
231 { | 260 { |
232 AgreementsCI it = m_agreements.find (std::make_pair (recipient, tid)); | 261 AgreementsCI it = m_agreements.find (std::make_pair (recipient, tid)); |
233 PacketQueueCI queueIt = (*it).second.second.begin (); | 262 PacketQueueCI queueIt = (*it).second.second.begin (); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 308 } |
280 | 309 |
281 void | 310 void |
282 BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac4
8Address recipient) | 311 BlockAckManager::NotifyGotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac4
8Address recipient) |
283 { | 312 { |
284 NS_LOG_FUNCTION (this); | 313 NS_LOG_FUNCTION (this); |
285 uint16_t sequenceFirstLost = 0; | 314 uint16_t sequenceFirstLost = 0; |
286 if (!blockAck->IsMultiTid ()) | 315 if (!blockAck->IsMultiTid ()) |
287 { | 316 { |
288 uint8_t tid = blockAck->GetTidInfo (); | 317 uint8_t tid = blockAck->GetTidInfo (); |
289 if (ExistsAgreementInState (recipient, tid, BlockAckAgreement::ESTABLISHED
)) | 318 if (ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::E
STABLISHED)) |
290 { | 319 { |
291 bool foundFirstLost = false; | 320 bool foundFirstLost = false; |
292 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 321 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
293 PacketQueueI queueEnd = it->second.second.end (); | 322 PacketQueueI queueEnd = it->second.second.end (); |
294 | 323 |
295 if (it->second.first.m_inactivityEvent.IsRunning ()) | 324 if (it->second.first.m_inactivityEvent.IsRunning ()) |
296 { | 325 { |
297 /* Upon reception of a block ack frame, the inactivity timer at th
e· | 326 /* Upon reception of a block ack frame, the inactivity timer at th
e· |
298 originator must be reset.· | 327 originator must be reset.· |
299 For more details see section 11.5.3 in IEEE802.11e standard */ | 328 For more details see section 11.5.3 in IEEE802.11e standard */ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 378 } |
350 m_retryPackets.push_back (queueIt); | 379 m_retryPackets.push_back (queueIt); |
351 queueIt++; | 380 queueIt++; |
352 } | 381 } |
353 } | 382 } |
354 } | 383 } |
355 uint16_t newSeq = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, re
cipient); | 384 uint16_t newSeq = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, re
cipient); |
356 if ((foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid, sequ
enceFirstLost)) || | 385 if ((foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid, sequ
enceFirstLost)) || |
357 (!foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid, new
Seq))) | 386 (!foundFirstLost && !SwitchToBlockAckIfNeeded (recipient, tid, new
Seq))) |
358 { | 387 { |
359 it->second.first.SetState (BlockAckAgreement::INACTIVE); | 388 it->second.first.SetState (OriginatorBlockAckAgreement::INACTIVE); |
360 } | 389 } |
361 } | 390 } |
362 } | 391 } |
363 else | 392 else |
364 { | 393 { |
365 //NOT SUPPORTED FOR NOW | 394 //NOT SUPPORTED FOR NOW |
366 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); | 395 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); |
367 } | 396 } |
368 } | 397 } |
369 | 398 |
370 void | 399 void |
371 BlockAckManager::SetBlockAckType (enum BlockAckType bAckType) | 400 BlockAckManager::SetBlockAckType (enum BlockAckType bAckType) |
372 { | 401 { |
373 m_blockAckType = bAckType; | 402 m_blockAckType = bAckType; |
374 } | 403 } |
375 | 404 |
376 Ptr<Packet> | 405 Ptr<Packet> |
377 BlockAckManager::ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t ti
d) | 406 BlockAckManager::ScheduleBlockAckReqIfNeeded (Mac48Address recipient, uint8_t ti
d) |
378 { | 407 { |
379 /* This method checks if a BlockAckRequest frame should be send to the recipie
nt station. | 408 /* This method checks if a BlockAckRequest frame should be send to the recipie
nt station. |
380 Number of packets under block ack is specified in BlockAckAgreement object
but sometimes | 409 Number of packets under block ack is specified in OriginatorBlockAckAgreeme
nt object but sometimes |
381 this number could be incorrect. In fact is possible that a block ack agreem
ent exists for n | 410 this number could be incorrect. In fact is possible that a block ack agreem
ent exists for n |
382 packets but some of these packets are dropped due to MSDU lifetime expirati
on. | 411 packets but some of these packets are dropped due to MSDU lifetime expirati
on. |
383 */ | 412 */ |
384 NS_LOG_FUNCTION (this); | 413 NS_LOG_FUNCTION (this); |
385 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 414 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
386 NS_ASSERT (it != m_agreements.end ()); | 415 NS_ASSERT (it != m_agreements.end ()); |
387 | 416 |
388 if ((*it).second.first.NeedBlockAckRequest () || | 417 if ((*it).second.first.NeedBlockAckRequest () || |
389 (GetNRetryNeededPackets (recipient, tid) == 0 && | 418 (GetNRetryNeededPackets (recipient, tid) == 0 && |
390 m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient
) == 0)) | 419 m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient
) == 0)) |
391 { | 420 { |
392 BlockAckAgreement &agreement = (*it).second.first; | 421 OriginatorBlockAckAgreement &agreement = (*it).second.first; |
393 agreement.CompleteExchange (); | 422 agreement.CompleteExchange (); |
394 | 423 |
395 CtrlBAckRequestHeader reqHdr; | 424 CtrlBAckRequestHeader reqHdr; |
396 if (m_blockAckType == BASIC_BLOCK_ACK) | 425 if (m_blockAckType == BASIC_BLOCK_ACK || m_blockAckType == COMPRESSED_BLOC
K_ACK) |
397 { | 426 { |
398 reqHdr.SetType (BASIC_BLOCK_ACK); | 427 reqHdr.SetType (m_blockAckType); |
399 reqHdr.SetTidInfo (agreement.GetTid ()); | |
400 reqHdr.SetStartingSequence (agreement.GetStartingSequence ()); | |
401 } | |
402 else if (m_blockAckType == COMPRESSED_BLOCK_ACK) | |
403 { | |
404 reqHdr.SetType (COMPRESSED_BLOCK_ACK); | |
405 reqHdr.SetTidInfo (agreement.GetTid ()); | 428 reqHdr.SetTidInfo (agreement.GetTid ()); |
406 reqHdr.SetStartingSequence (agreement.GetStartingSequence ()); | 429 reqHdr.SetStartingSequence (agreement.GetStartingSequence ()); |
407 } | 430 } |
408 else if (m_blockAckType == MULTI_TID_BLOCK_ACK) | 431 else if (m_blockAckType == MULTI_TID_BLOCK_ACK) |
409 { | 432 { |
410 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); | 433 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); |
411 } | 434 } |
412 else | 435 else |
413 { | 436 { |
414 NS_FATAL_ERROR ("Invalid block ack type."); | 437 NS_FATAL_ERROR ("Invalid block ack type."); |
(...skipping 11 matching lines...) Expand all Loading... |
426 m_blockAckInactivityTimeout (recipient, tid, true); | 449 m_blockAckInactivityTimeout (recipient, tid, true); |
427 } | 450 } |
428 | 451 |
429 void | 452 void |
430 BlockAckManager::NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid
, uint16_t startingSeq) | 453 BlockAckManager::NotifyAgreementEstablished (Mac48Address recipient, uint8_t tid
, uint16_t startingSeq) |
431 { | 454 { |
432 NS_LOG_FUNCTION (this); | 455 NS_LOG_FUNCTION (this); |
433 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 456 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
434 NS_ASSERT (it != m_agreements.end ()); | 457 NS_ASSERT (it != m_agreements.end ()); |
435 ···· | 458 ···· |
436 it->second.first.SetState (BlockAckAgreement::ESTABLISHED); | 459 it->second.first.SetState (OriginatorBlockAckAgreement::ESTABLISHED); |
437 it->second.first.SetStartingSequence (startingSeq); | 460 it->second.first.SetStartingSequence (startingSeq); |
438 } | 461 } |
439 | 462 |
440 void | 463 void |
441 BlockAckManager::NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t ti
d) | 464 BlockAckManager::NotifyAgreementUnsuccessful (Mac48Address recipient, uint8_t ti
d) |
442 { | 465 { |
443 NS_LOG_FUNCTION (this); | 466 NS_LOG_FUNCTION (this); |
444 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 467 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
445 NS_ASSERT (it != m_agreements.end ()); | 468 NS_ASSERT (it != m_agreements.end ()); |
446 if (it != m_agreements.end ()) | 469 if (it != m_agreements.end ()) |
447 { | 470 { |
448 it->second.first.SetState (BlockAckAgreement::UNSUCCESSFUL); | 471 it->second.first.SetState (OriginatorBlockAckAgreement::UNSUCCESSFUL); |
449 } | 472 } |
450 } | 473 } |
451 | 474 |
452 Ptr<Packet> | 475 void |
453 BlockAckManager::NotifyMpduTransmission (Mac48Address recipient, uint8_t tid) | 476 BlockAckManager::NotifyMpduTransmission (Mac48Address recipient, uint8_t tid) |
454 { | 477 { |
455 NS_LOG_FUNCTION (this); | 478 NS_LOG_FUNCTION (this); |
456 Ptr<Packet> bar = 0; | 479 Ptr<Packet> bar = 0; |
457 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); | 480 AgreementsI it = m_agreements.find (std::make_pair (recipient, tid)); |
458 NS_ASSERT (it != m_agreements.end ()); | 481 NS_ASSERT (it != m_agreements.end ()); |
459 it->second.first.NotifyMpduTransmission (); | 482 it->second.first.NotifyMpduTransmission (); |
460 bar = ScheduleBlockAckReqIfNeeded (recipient, tid); | 483 bar = ScheduleBlockAckReqIfNeeded (recipient, tid); |
461 return bar; | 484 if (bar != 0) |
| 485 { |
| 486 Bar request (bar, recipient, tid, it->second.first.IsImmediateBlockAck ())
; |
| 487 m_bars.push_back (request); |
| 488 } |
462 } | 489 } |
463 | 490 |
464 void | 491 void |
465 BlockAckManager::SetQueue (Ptr<WifiMacQueue> queue) | 492 BlockAckManager::SetQueue (Ptr<WifiMacQueue> queue) |
466 { | 493 { |
467 m_queue = queue; | 494 m_queue = queue; |
468 } | 495 } |
469 | 496 |
470 bool | 497 bool |
471 BlockAckManager::SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid,
uint16_t startingSeq) | 498 BlockAckManager::SwitchToBlockAckIfNeeded (Mac48Address recipient, uint8_t tid,
uint16_t startingSeq) |
472 { | 499 { |
473 NS_LOG_FUNCTION (this); | 500 NS_LOG_FUNCTION (this); |
474 NS_ASSERT (!ExistsAgreementInState (recipient, tid, BlockAckAgreement::PENDING
)); | 501 NS_ASSERT (!ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreemen
t::PENDING)); |
475 if (!ExistsAgreementInState (recipient, tid, BlockAckAgreement::UNSUCCESSFUL)
&& ExistsAgreement (recipient, tid)) | 502 if (!ExistsAgreementInState (recipient, tid, OriginatorBlockAckAgreement::UNSU
CCESSFUL) && ExistsAgreement (recipient, tid)) |
476 { | 503 { |
477 uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader
::ADDR1, recipient) + | 504 uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader
::ADDR1, recipient) + |
478 GetNBufferedPackets (recipient, tid); | 505 GetNBufferedPackets (recipient, tid); |
479 if (packets >= m_blockAckThreshold) | 506 if (packets >= m_blockAckThreshold) |
480 { | 507 { |
481 NotifyAgreementEstablished (recipient, tid, startingSeq); | 508 NotifyAgreementEstablished (recipient, tid, startingSeq); |
482 return true; | 509 return true; |
483 } | 510 } |
484 } | 511 } |
485 return false; | 512 return false; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 m_maxDelay = maxDelay; | 590 m_maxDelay = maxDelay; |
564 } | 591 } |
565 | 592 |
566 void | 593 void |
567 BlockAckManager::SetBlockAckInactivityCallback (Callback<void, Mac48Address, uin
t8_t, bool> callback) | 594 BlockAckManager::SetBlockAckInactivityCallback (Callback<void, Mac48Address, uin
t8_t, bool> callback) |
568 { | 595 { |
569 m_blockAckInactivityTimeout = callback; | 596 m_blockAckInactivityTimeout = callback; |
570 } | 597 } |
571 | 598 |
572 void | 599 void |
573 BlockAckManager::SetBlockPacketCallback (Callback<void, Mac48Address, uint8_t> c
allback) | 600 BlockAckManager::SetBlockDestinationCallback (Callback<void, Mac48Address, uint8
_t> callback) |
574 { | 601 { |
575 m_blockPackets = callback; | 602 m_blockPackets = callback; |
576 } | 603 } |
577 | 604 |
578 void | 605 void |
579 BlockAckManager::SetUnblockPacketCallback (Callback<void, Mac48Address, uint8_t>
callback) | 606 BlockAckManager::SetUnblockDestinationCallback (Callback<void, Mac48Address, uin
t8_t> callback) |
580 { | 607 { |
581 m_unblockPackets = callback; | 608 m_unblockPackets = callback; |
582 } | 609 } |
583 | 610 |
584 void | 611 void |
585 BlockAckManager::SetTxMiddle (MacTxMiddle* txMiddle) | 612 BlockAckManager::SetTxMiddle (MacTxMiddle* txMiddle) |
586 { | 613 { |
587 m_txMiddle = txMiddle; | 614 m_txMiddle = txMiddle; |
588 } | 615 } |
589 | 616 |
590 } //namespace ns3 | 617 } //namespace ns3 |
LEFT | RIGHT |