Left: | ||
Right: |
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) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 */ | 19 */ |
20 | 20 |
21 #include "ns3/log.h" | 21 #include "ns3/log.h" |
22 #include "ns3/simulator.h" | |
22 #include "dcf-manager.h" | 23 #include "dcf-manager.h" |
23 #include "dcf-state.h" | 24 #include "dca-txop.h" |
25 #include "wifi-phy-listener.h" | |
26 #include "wifi-phy.h" | |
27 #include "mac-low.h" | |
24 | 28 |
25 namespace ns3 { | 29 namespace ns3 { |
26 | 30 |
27 NS_LOG_COMPONENT_DEFINE ("DcfManager"); | 31 NS_LOG_COMPONENT_DEFINE ("DcfManager"); |
28 | 32 |
29 /** | 33 /** |
30 * Listener for PHY events. Forwards to DcfManager | 34 * Listener for PHY events. Forwards to DcfManager |
31 */ | 35 */ |
32 class PhyListener : public ns3::WifiPhyListener | 36 class PhyListener : public ns3::WifiPhyListener |
33 { | 37 { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 { | 127 { |
124 NS_LOG_FUNCTION (this); | 128 NS_LOG_FUNCTION (this); |
125 delete m_phyListener; | 129 delete m_phyListener; |
126 m_phyListener = 0; | 130 m_phyListener = 0; |
127 } | 131 } |
128 | 132 |
129 void | 133 void |
130 DcfManager::DoDispose (void) | 134 DcfManager::DoDispose (void) |
131 { | 135 { |
132 NS_LOG_FUNCTION (this); | 136 NS_LOG_FUNCTION (this); |
133 for (Ptr<DcfState> i : m_states) | 137 for (Ptr<DcaTxop> i : m_states) |
134 { | 138 { |
135 i->Dispose (); | 139 i->Dispose (); |
136 i = 0; | 140 i = 0; |
137 } | 141 } |
138 } | 142 } |
139 | 143 |
140 void | 144 void |
141 DcfManager::SetupPhyListener (Ptr<WifiPhy> phy) | 145 DcfManager::SetupPhyListener (Ptr<WifiPhy> phy) |
142 { | 146 { |
143 NS_LOG_FUNCTION (this << phy); | 147 NS_LOG_FUNCTION (this << phy); |
144 if (m_phyListener != 0) | 148 NS_ASSERT (m_phyListener == 0); |
145 { | |
146 delete m_phyListener; | |
147 } | |
148 m_phyListener = new PhyListener (this); | 149 m_phyListener = new PhyListener (this); |
149 phy->RegisterListener (m_phyListener); | 150 phy->RegisterListener (m_phyListener); |
150 } | 151 } |
151 | 152 |
152 void | 153 void |
153 DcfManager::RemovePhyListener (Ptr<WifiPhy> phy) | 154 DcfManager::RemovePhyListener (Ptr<WifiPhy> phy) |
154 { | 155 { |
155 NS_LOG_FUNCTION (this << phy); | 156 NS_LOG_FUNCTION (this << phy); |
156 if (m_phyListener != 0) | 157 if (m_phyListener != 0) |
157 { | 158 { |
158 phy->UnregisterListener (m_phyListener); | 159 phy->UnregisterListener (m_phyListener); |
159 delete m_phyListener; | 160 delete m_phyListener; |
160 m_phyListener = 0; | 161 m_phyListener = 0; |
161 } | 162 } |
162 } | 163 } |
163 | 164 |
164 void | 165 void |
165 DcfManager::SetupLow (Ptr<MacLow> low) | 166 DcfManager::SetupLow (Ptr<MacLow> low) |
166 { | 167 { |
167 NS_LOG_FUNCTION (this << low); | 168 NS_LOG_FUNCTION (this << low); |
168 low->RegisterDcf (this); | 169 low->RegisterDcf (this); |
169 } | 170 } |
170 | 171 |
171 void | 172 void |
172 DcfManager::SetSlot (Time slotTime) | 173 DcfManager::SetSlot (Time slotTime) |
173 { | 174 { |
174 NS_LOG_FUNCTION (this << slotTime); | 175 NS_LOG_FUNCTION (this << slotTime); |
175 m_slotTimeUs = static_cast<uint32_t> (slotTime.GetMicroSeconds ()); | 176 m_slotTimeUs = static_cast<uint32_t> (slotTime.GetMicroSeconds ()); |
S. Deronne
2018/03/30 06:56:53
m_slotTimeUs could be int64_t?
ammo6818-vandals.uidaho.edu
2018/04/05 17:51:00
no, changing causes issues with UpdateBackoffSlots
S. Deronne
2018/04/05 19:46:50
Which kind of issue? This maybe worth to see how t
| |
176 } | 177 } |
177 | 178 |
178 void | 179 void |
179 DcfManager::SetSifs (Time sifs) | 180 DcfManager::SetSifs (Time sifs) |
180 { | 181 { |
181 NS_LOG_FUNCTION (this << sifs); | 182 NS_LOG_FUNCTION (this << sifs); |
182 m_sifs = sifs; | 183 m_sifs = sifs; |
183 } | 184 } |
184 | 185 |
185 void | 186 void |
186 DcfManager::SetEifsNoDifs (Time eifsNoDifs) | 187 DcfManager::SetEifsNoDifs (Time eifsNoDifs) |
187 { | 188 { |
188 NS_LOG_FUNCTION (this << eifsNoDifs); | 189 NS_LOG_FUNCTION (this << eifsNoDifs); |
189 m_eifsNoDifs = eifsNoDifs; | 190 m_eifsNoDifs = eifsNoDifs; |
190 } | 191 } |
191 | 192 |
192 Time | 193 Time |
193 DcfManager::GetEifsNoDifs () const | 194 DcfManager::GetEifsNoDifs () const |
194 { | 195 { |
195 NS_LOG_FUNCTION (this); | 196 NS_LOG_FUNCTION (this); |
196 return m_eifsNoDifs; | 197 return m_eifsNoDifs; |
197 } | 198 } |
198 | 199 |
199 void | 200 void |
200 DcfManager::Add (Ptr<DcfState> dcf) | 201 DcfManager::Add (Ptr<DcaTxop> dcf) |
201 { | 202 { |
202 NS_LOG_FUNCTION (this << dcf); | 203 NS_LOG_FUNCTION (this << dcf); |
203 m_states.push_back (dcf); | 204 m_states.push_back (dcf); |
204 } | 205 } |
205 | 206 |
206 Time | 207 Time |
207 DcfManager::MostRecent (Time a, Time b) const | 208 DcfManager::MostRecent (Time a, Time b) const |
208 { | 209 { |
209 return Max (a, b); | 210 return Max (a, b); |
210 } | 211 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 // CCA busy | 245 // CCA busy |
245 Time lastCCABusyEnd = m_lastBusyStart + m_lastBusyDuration; | 246 Time lastCCABusyEnd = m_lastBusyStart + m_lastBusyDuration; |
246 if (lastCCABusyEnd > Simulator::Now ()) | 247 if (lastCCABusyEnd > Simulator::Now ()) |
247 { | 248 { |
248 return true; | 249 return true; |
249 } | 250 } |
250 return false; | 251 return false; |
251 } | 252 } |
252 | 253 |
253 bool | 254 bool |
254 DcfManager::IsWithinAifs (Ptr<DcfState> state) const | 255 DcfManager::IsWithinAifs (Ptr<DcaTxop> state) const |
255 { | 256 { |
256 NS_LOG_FUNCTION (this << state); | 257 NS_LOG_FUNCTION (this << state); |
257 Time ifsEnd = GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_sl otTimeUs); | 258 Time ifsEnd = GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_sl otTimeUs); |
258 if (ifsEnd > Simulator::Now ()) | 259 if (ifsEnd > Simulator::Now ()) |
259 { | 260 { |
260 NS_LOG_DEBUG ("IsWithinAifs () true; ifsEnd is at " << ifsEnd.GetSeconds ( )); | 261 NS_LOG_DEBUG ("IsWithinAifs () true; ifsEnd is at " << ifsEnd.GetSeconds ( )); |
261 return true; | 262 return true; |
262 } | 263 } |
263 NS_LOG_DEBUG ("IsWithinAifs () false; ifsEnd was at " << ifsEnd.GetSeconds ()) ; | 264 NS_LOG_DEBUG ("IsWithinAifs () false; ifsEnd was at " << ifsEnd.GetSeconds ()) ; |
264 return false; | 265 return false; |
265 } | 266 } |
266 | 267 |
267 void | 268 void |
268 DcfManager::RequestAccess (Ptr<DcfState> state) | 269 DcfManager::RequestAccess (Ptr<DcaTxop> state) |
269 { | 270 { |
270 NS_LOG_FUNCTION (this << state); | 271 NS_LOG_FUNCTION (this << state); |
271 //Deny access if in sleep mode or off | 272 //Deny access if in sleep mode or off |
272 if (m_sleeping || m_off) | 273 if (m_sleeping || m_off) |
273 { | 274 { |
274 return; | 275 return; |
275 } | 276 } |
276 UpdateBackoff (); | 277 UpdateBackoff (); |
277 NS_ASSERT (!state->IsAccessRequested ()); | 278 NS_ASSERT (!state->IsAccessRequested ()); |
278 state->NotifyAccessRequested (); | 279 state->NotifyAccessRequested (); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 DoRestartAccessTimeoutIfNeeded (); | 313 DoRestartAccessTimeoutIfNeeded (); |
313 } | 314 } |
314 | 315 |
315 void | 316 void |
316 DcfManager::DoGrantAccess (void) | 317 DcfManager::DoGrantAccess (void) |
317 { | 318 { |
318 NS_LOG_FUNCTION (this); | 319 NS_LOG_FUNCTION (this); |
319 uint32_t k = 0; | 320 uint32_t k = 0; |
320 for (States::iterator i = m_states.begin (); i != m_states.end (); k++) | 321 for (States::iterator i = m_states.begin (); i != m_states.end (); k++) |
321 { | 322 { |
322 Ptr<DcfState> state = *i; | 323 Ptr<DcaTxop> state = *i; |
323 if (state->IsAccessRequested () | 324 if (state->IsAccessRequested () |
324 && GetBackoffEndFor (state) <= Simulator::Now () ) | 325 && GetBackoffEndFor (state) <= Simulator::Now () ) |
325 { | 326 { |
326 /** | 327 /** |
327 * This is the first dcf we find with an expired backoff and which | 328 * This is the first dcf we find with an expired backoff and which |
328 * needs access to the medium. i.e., it has data to send. | 329 * needs access to the medium. i.e., it has data to send. |
329 */ | 330 */ |
330 NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. access g ranted. slots=" << state->GetBackoffSlots ()); | 331 NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. access g ranted. slots=" << state->GetBackoffSlots ()); |
331 i++; //go to the next item in the list. | 332 i++; //go to the next item in the list. |
332 k++; | 333 k++; |
333 std::vector<Ptr<DcfState> > internalCollisionStates; | 334 std::vector<Ptr<DcaTxop> > internalCollisionStates; |
334 for (States::iterator j = i; j != m_states.end (); j++, k++) | 335 for (States::iterator j = i; j != m_states.end (); j++, k++) |
335 { | 336 { |
336 Ptr<DcfState> otherState = *j; | 337 Ptr<DcaTxop> otherState = *j; |
337 if (otherState->IsAccessRequested () | 338 if (otherState->IsAccessRequested () |
338 && GetBackoffEndFor (otherState) <= Simulator::Now ()) | 339 && GetBackoffEndFor (otherState) <= Simulator::Now ()) |
339 { | 340 { |
340 NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" << | 341 NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" << |
341 otherState->GetBackoffSlots ()); | 342 otherState->GetBackoffSlots ()); |
342 /** | 343 /** |
343 * all other dcfs with a lower priority whose backoff | 344 * all other dcfs with a lower priority whose backoff |
344 * has expired and which needed access to the medium | 345 * has expired and which needed access to the medium |
345 * must be notified that we did get an internal collision. | 346 * must be notified that we did get an internal collision. |
346 */ | 347 */ |
347 internalCollisionStates.push_back (otherState); | 348 internalCollisionStates.push_back (otherState); |
348 } | 349 } |
349 } | 350 } |
350 | 351 |
351 /** | 352 /** |
352 * Now, we notify all of these changes in one go. It is necessary to | 353 * Now, we notify all of these changes in one go. It is necessary to |
353 * perform first the calculations of which states are colliding and th en | 354 * perform first the calculations of which states are colliding and th en |
354 * only apply the changes because applying the changes through notific ation | 355 * only apply the changes because applying the changes through notific ation |
355 * could change the global state of the manager, and, thus, could chan ge | 356 * could change the global state of the manager, and, thus, could chan ge |
356 * the result of the calculations. | 357 * the result of the calculations. |
357 */ | 358 */ |
358 state->NotifyAccessGranted (); | 359 state->NotifyAccessGranted (); |
359 for (std::vector<Ptr<DcfState> >::iterator l = internalCollisionStates .begin (); | 360 for (std::vector<Ptr<DcaTxop> >::iterator l = internalCollisionStates. begin (); |
360 l != internalCollisionStates.end (); l++) | 361 l != internalCollisionStates.end (); l++) |
361 { | 362 { |
362 (*l)->NotifyInternalCollision (); | 363 (*l)->NotifyInternalCollision (); |
363 } | 364 } |
364 break; | 365 break; |
365 } | 366 } |
366 i++; | 367 i++; |
367 } | 368 } |
368 } | 369 } |
369 | 370 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 ); | 410 ); |
410 NS_LOG_INFO ("access grant start=" << accessGrantedStart << | 411 NS_LOG_INFO ("access grant start=" << accessGrantedStart << |
411 ", rx access start=" << rxAccessStart << | 412 ", rx access start=" << rxAccessStart << |
412 ", busy access start=" << busyAccessStart << | 413 ", busy access start=" << busyAccessStart << |
413 ", tx access start=" << txAccessStart << | 414 ", tx access start=" << txAccessStart << |
414 ", nav access start=" << navAccessStart); | 415 ", nav access start=" << navAccessStart); |
415 return accessGrantedStart; | 416 return accessGrantedStart; |
416 } | 417 } |
417 | 418 |
418 Time | 419 Time |
419 DcfManager::GetBackoffStartFor (Ptr<DcfState> state) | 420 DcfManager::GetBackoffStartFor (Ptr<DcaTxop> state) |
420 { | 421 { |
421 NS_LOG_FUNCTION (this << state); | 422 NS_LOG_FUNCTION (this << state); |
422 Time mostRecentEvent = MostRecent (state->GetBackoffStart (), | 423 Time mostRecentEvent = MostRecent (state->GetBackoffStart (), |
423 GetAccessGrantStart () + MicroSeconds (stat e->GetAifsn () * m_slotTimeUs)); | 424 GetAccessGrantStart () + MicroSeconds (stat e->GetAifsn () * m_slotTimeUs)); |
424 | 425 |
425 return mostRecentEvent; | 426 return mostRecentEvent; |
426 } | 427 } |
427 | 428 |
428 Time | 429 Time |
429 DcfManager::GetBackoffEndFor (Ptr<DcfState> state) | 430 DcfManager::GetBackoffEndFor (Ptr<DcaTxop> state) |
430 { | 431 { |
431 NS_LOG_FUNCTION (this << state); | 432 NS_LOG_FUNCTION (this << state); |
432 NS_LOG_DEBUG ("Backoff start: " << GetBackoffStartFor (state).As (Time::US) << | 433 NS_LOG_DEBUG ("Backoff start: " << GetBackoffStartFor (state).As (Time::US) << |
433 " end: " << (GetBackoffStartFor (state) + | 434 " end: " << (GetBackoffStartFor (state) + |
434 MicroSeconds (state->GetBackoffSlots () * m_slotTim eUs)).As (Time::US)); | 435 MicroSeconds (state->GetBackoffSlots () * m_slotTim eUs)).As (Time::US)); |
435 return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs); | 436 return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs); |
436 } | 437 } |
437 | 438 |
438 void | 439 void |
439 DcfManager::UpdateBackoff (void) | 440 DcfManager::UpdateBackoff (void) |
440 { | 441 { |
441 NS_LOG_FUNCTION (this); | 442 NS_LOG_FUNCTION (this); |
442 uint32_t k = 0; | 443 uint32_t k = 0; |
443 for (States::iterator i = m_states.begin (); i != m_states.end (); i++, k++) | 444 for (States::iterator i = m_states.begin (); i != m_states.end (); i++, k++) |
444 { | 445 { |
445 Ptr<DcfState> state = *i; | 446 Ptr<DcaTxop> state = *i; |
446 | 447 |
447 Time backoffStart = GetBackoffStartFor (state); | 448 Time backoffStart = GetBackoffStartFor (state); |
448 if (backoffStart <= Simulator::Now ()) | 449 if (backoffStart <= Simulator::Now ()) |
449 { | 450 { |
450 uint32_t nus = static_cast<uint32_t> ((Simulator::Now () - backoffStar t).GetMicroSeconds ()); | 451 uint32_t nus = static_cast<uint32_t> ((Simulator::Now () - backoffStar t).GetMicroSeconds ()); |
S. Deronne
2018/03/30 06:56:53
same comment here for nus
ammo6818-vandals.uidaho.edu
2018/04/05 17:51:00
no, changing causes issues with UpdateBackoffSlots
| |
451 uint32_t nIntSlots = nus / m_slotTimeUs; | 452 uint32_t nIntSlots = nus / m_slotTimeUs; |
452 /* | 453 /* |
453 * EDCA behaves slightly different to DCA. For EDCA we | 454 * EDCA behaves slightly different to DCA. For EDCA we |
454 * decrement once at the slot boundary at the end of AIFS as | 455 * decrement once at the slot boundary at the end of AIFS as |
455 * well as once at the end of each clear slot | 456 * well as once at the end of each clear slot |
456 * thereafter. For DCA we only decrement at the end of each | 457 * thereafter. For DCA we only decrement at the end of each |
457 * clear slot after DIFS. We account for the extra backoff | 458 * clear slot after DIFS. We account for the extra backoff |
458 * by incrementing the slot count here in the case of | 459 * by incrementing the slot count here in the case of |
459 * EDCA. The if statement whose body we are in has confirmed | 460 * EDCA. The if statement whose body we are in has confirmed |
460 * that a minimum of AIFS has elapsed since last busy | 461 * that a minimum of AIFS has elapsed since last busy |
461 * medium. | 462 * medium. |
462 */ | 463 */ |
463 if (state->IsEdca ()) | 464 if (state->IsEdca ()) |
464 { | 465 { |
465 nIntSlots++; | 466 nIntSlots++; |
466 } | 467 } |
467 uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ()); | 468 uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ()); |
468 NS_LOG_DEBUG ("dcf " << k << " dec backoff slots=" << n); | 469 NS_LOG_DEBUG ("dcf " << k << " dec backoff slots=" << n); |
469 Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeU s); | 470 Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeU s); |
470 state->UpdateBackoffSlotsNow (n, backoffUpdateBound); | 471 state->UpdateBackoffSlotsNow (n, backoffUpdateBound); |
471 } | 472 } |
472 } | 473 } |
473 } | 474 } |
474 | 475 |
475 void | 476 void |
476 DcfManager::DoRestartAccessTimeoutIfNeeded (void) | 477 DcfManager::DoRestartAccessTimeoutIfNeeded (void) |
477 { | 478 { |
478 NS_LOG_FUNCTION (this); | 479 NS_LOG_FUNCTION (this); |
479 /** | 480 /** |
480 * Is there a DcfState which needs to access the medium, and, | 481 * Is there a DcaTxop which needs to access the medium, and, |
481 * if there is one, how many slots for AIFS+backoff does it require ? | 482 * if there is one, how many slots for AIFS+backoff does it require ? |
482 */ | 483 */ |
483 bool accessTimeoutNeeded = false; | 484 bool accessTimeoutNeeded = false; |
484 Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime (); | 485 Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime (); |
485 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) | 486 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) |
486 { | 487 { |
487 Ptr<DcfState> state = *i; | 488 Ptr<DcaTxop> state = *i; |
488 if (state->IsAccessRequested ()) | 489 if (state->IsAccessRequested ()) |
489 { | 490 { |
490 Time tmp = GetBackoffEndFor (state); | 491 Time tmp = GetBackoffEndFor (state); |
491 if (tmp > Simulator::Now ()) | 492 if (tmp > Simulator::Now ()) |
492 { | 493 { |
493 accessTimeoutNeeded = true; | 494 accessTimeoutNeeded = true; |
494 expectedBackoffEnd = std::min (expectedBackoffEnd, tmp); | 495 expectedBackoffEnd = std::min (expectedBackoffEnd, tmp); |
495 } | 496 } |
496 } | 497 } |
497 } | 498 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 | 610 |
610 //Cancel timeout | 611 //Cancel timeout |
611 if (m_accessTimeout.IsRunning ()) | 612 if (m_accessTimeout.IsRunning ()) |
612 { | 613 { |
613 m_accessTimeout.Cancel (); | 614 m_accessTimeout.Cancel (); |
614 } | 615 } |
615 | 616 |
616 //Reset backoffs | 617 //Reset backoffs |
617 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) | 618 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) |
618 { | 619 { |
619 Ptr<DcfState> state = *i; | 620 Ptr<DcaTxop> state = *i; |
620 uint32_t remainingSlots = state->GetBackoffSlots (); | 621 uint32_t remainingSlots = state->GetBackoffSlots (); |
621 if (remainingSlots > 0) | 622 if (remainingSlots > 0) |
622 { | 623 { |
623 state->UpdateBackoffSlotsNow (remainingSlots, now); | 624 state->UpdateBackoffSlotsNow (remainingSlots, now); |
624 NS_ASSERT (state->GetBackoffSlots () == 0); | 625 NS_ASSERT (state->GetBackoffSlots () == 0); |
625 } | 626 } |
626 state->ResetCw (); | 627 state->ResetCw (); |
627 state->m_accessRequested = false; | 628 state->m_accessRequested = false; |
628 state->NotifyChannelSwitching (); | 629 state->NotifyChannelSwitching (); |
629 } | 630 } |
(...skipping 11 matching lines...) Expand all Loading... | |
641 m_sleeping = true; | 642 m_sleeping = true; |
642 //Cancel timeout | 643 //Cancel timeout |
643 if (m_accessTimeout.IsRunning ()) | 644 if (m_accessTimeout.IsRunning ()) |
644 { | 645 { |
645 m_accessTimeout.Cancel (); | 646 m_accessTimeout.Cancel (); |
646 } | 647 } |
647 | 648 |
648 //Reset backoffs | 649 //Reset backoffs |
649 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) | 650 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) |
650 { | 651 { |
651 Ptr<DcfState> state = *i; | 652 Ptr<DcaTxop> state = *i; |
652 state->NotifySleep (); | 653 state->NotifySleep (); |
653 } | 654 } |
654 } | 655 } |
655 | 656 |
656 void | 657 void |
657 DcfManager::NotifyOffNow (void) | 658 DcfManager::NotifyOffNow (void) |
658 { | 659 { |
659 NS_LOG_FUNCTION (this); | 660 NS_LOG_FUNCTION (this); |
660 m_off = true; | 661 m_off = true; |
661 //Cancel timeout | 662 //Cancel timeout |
662 if (m_accessTimeout.IsRunning ()) | 663 if (m_accessTimeout.IsRunning ()) |
663 { | 664 { |
664 m_accessTimeout.Cancel (); | 665 m_accessTimeout.Cancel (); |
665 } | 666 } |
666 | 667 |
667 //Reset backoffs | 668 //Reset backoffs |
668 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) | 669 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) |
669 { | 670 { |
670 Ptr<DcfState> state = *i; | 671 Ptr<DcaTxop> state = *i; |
671 state->NotifyOff (); | 672 state->NotifyOff (); |
672 } | 673 } |
673 } | 674 } |
674 | 675 |
675 void | 676 void |
676 DcfManager::NotifyWakeupNow (void) | 677 DcfManager::NotifyWakeupNow (void) |
677 { | 678 { |
678 NS_LOG_FUNCTION (this); | 679 NS_LOG_FUNCTION (this); |
679 m_sleeping = false; | 680 m_sleeping = false; |
680 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) | 681 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) |
681 { | 682 { |
682 Ptr<DcfState> state = *i; | 683 Ptr<DcaTxop> state = *i; |
683 uint32_t remainingSlots = state->GetBackoffSlots (); | 684 uint32_t remainingSlots = state->GetBackoffSlots (); |
684 if (remainingSlots > 0) | 685 if (remainingSlots > 0) |
685 { | 686 { |
686 state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ()); | 687 state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ()); |
687 NS_ASSERT (state->GetBackoffSlots () == 0); | 688 NS_ASSERT (state->GetBackoffSlots () == 0); |
688 } | 689 } |
689 state->ResetCw (); | 690 state->ResetCw (); |
690 state->m_accessRequested = false; | 691 state->m_accessRequested = false; |
691 state->NotifyWakeUp (); | 692 state->NotifyWakeUp (); |
692 } | 693 } |
693 } | 694 } |
694 | 695 |
695 void | 696 void |
696 DcfManager::NotifyOnNow (void) | 697 DcfManager::NotifyOnNow (void) |
697 { | 698 { |
698 NS_LOG_FUNCTION (this); | 699 NS_LOG_FUNCTION (this); |
699 m_off = false; | 700 m_off = false; |
700 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) | 701 for (States::iterator i = m_states.begin (); i != m_states.end (); i++) |
701 { | 702 { |
702 Ptr<DcfState> state = *i; | 703 Ptr<DcaTxop> state = *i; |
703 uint32_t remainingSlots = state->GetBackoffSlots (); | 704 uint32_t remainingSlots = state->GetBackoffSlots (); |
704 if (remainingSlots > 0) | 705 if (remainingSlots > 0) |
705 { | 706 { |
706 state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ()); | 707 state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ()); |
707 NS_ASSERT (state->GetBackoffSlots () == 0); | 708 NS_ASSERT (state->GetBackoffSlots () == 0); |
708 } | 709 } |
709 state->ResetCw (); | 710 state->ResetCw (); |
710 state->m_accessRequested = false; | 711 state->m_accessRequested = false; |
711 state->NotifyOn (); | 712 state->NotifyOn (); |
712 } | 713 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 | 771 |
771 void | 772 void |
772 DcfManager::NotifyCtsTimeoutResetNow () | 773 DcfManager::NotifyCtsTimeoutResetNow () |
773 { | 774 { |
774 NS_LOG_FUNCTION (this); | 775 NS_LOG_FUNCTION (this); |
775 m_lastCtsTimeoutEnd = Simulator::Now (); | 776 m_lastCtsTimeoutEnd = Simulator::Now (); |
776 DoRestartAccessTimeoutIfNeeded (); | 777 DoRestartAccessTimeoutIfNeeded (); |
777 } | 778 } |
778 | 779 |
779 } //namespace ns3 | 780 } //namespace ns3 |
LEFT | RIGHT |