View | Details | Raw Unified | Return to bug 556
Collapse All | Expand All

(-)a/src/devices/wifi/dcf-manager-test.cc (-5 / +85 lines)
 Lines 68-74    Link Here 
68
68
69
69
70
private:
70
private:
71
  void StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs);
71
  void StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs, uint32_t ackTimeoutValue = 20);
72
  void AddDcfState (uint32_t aifsn);
72
  void AddDcfState (uint32_t aifsn);
73
  void EndTest (void);
73
  void EndTest (void);
74
  void ExpectInternalCollision (uint64_t time, uint32_t from, uint32_t nSlots);
74
  void ExpectInternalCollision (uint64_t time, uint32_t from, uint32_t nSlots);
 Lines 77-90    Link Here 
77
  void AddRxErrorEvt (uint64_t at, uint64_t duration);
77
  void AddRxErrorEvt (uint64_t at, uint64_t duration);
78
  void AddNavReset (uint64_t at, uint64_t duration);
78
  void AddNavReset (uint64_t at, uint64_t duration);
79
  void AddNavStart (uint64_t at, uint64_t duration);
79
  void AddNavStart (uint64_t at, uint64_t duration);
80
  void AddAckTimeoutReset (uint64_t at);
80
  void AddAccessRequest (uint64_t at, uint64_t txTime, 
81
  void AddAccessRequest (uint64_t at, uint64_t txTime, 
81
                         uint64_t expectedGrantTime, uint32_t from);
82
                         uint64_t expectedGrantTime, uint32_t from);
83
  void AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, 
84
                                  uint64_t expectedGrantTime, uint32_t from);
85
  ///\param ackDelay is delay of the ack after txEnd
86
  void AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, 
87
                                  uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from);
82
  void DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state);
88
  void DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state);
83
  
89
  
84
  typedef std::vector<DcfStateTest *> DcfStates;
90
  typedef std::vector<DcfStateTest *> DcfStates;
85
91
86
  DcfManager *m_dcfManager;
92
  DcfManager *m_dcfManager;
87
  DcfStates m_dcfStates;
93
  DcfStates m_dcfStates;
94
  uint32_t m_ackTimeoutValue;
88
  bool m_result;
95
  bool m_result;
89
};
96
};
90
97
 Lines 130-135    Link Here 
130
  state->m_expectedGrants.pop_front ();
137
  state->m_expectedGrants.pop_front ();
131
  NS_TEST_ASSERT_EQUAL (Simulator::Now (), MicroSeconds (expected.second));
138
  NS_TEST_ASSERT_EQUAL (Simulator::Now (), MicroSeconds (expected.second));
132
  m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first));
139
  m_dcfManager->NotifyTxStartNow (MicroSeconds (expected.first));
140
  m_dcfManager->NotifyAckTimeoutStartNow (MicroSeconds (m_ackTimeoutValue + expected.first));
133
  if (!result)
141
  if (!result)
134
    {
142
    {
135
      m_result = result;
143
      m_result = result;
 Lines 187-198    Link Here 
187
}
195
}
188
196
189
void
197
void
190
DcfManagerTest::StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs)
198
DcfManagerTest::StartTest (uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs, uint32_t ackTimeoutValue)
191
{
199
{
192
  m_dcfManager = new DcfManager ();
200
  m_dcfManager = new DcfManager ();
193
  m_dcfManager->SetSlot (MicroSeconds (slotTime));
201
  m_dcfManager->SetSlot (MicroSeconds (slotTime));
194
  m_dcfManager->SetSifs (MicroSeconds (sifs));
202
  m_dcfManager->SetSifs (MicroSeconds (sifs));
195
  m_dcfManager->SetEifsNoDifs (MicroSeconds (eifsNoDifsNoSifs+sifs));
203
  m_dcfManager->SetEifsNoDifs (MicroSeconds (eifsNoDifsNoSifs+sifs));
204
  m_ackTimeoutValue = ackTimeoutValue;
196
}
205
}
197
206
198
void
207
void
 Lines 260-273    Link Here 
260
                       MicroSeconds (duration));
269
                       MicroSeconds (duration));
261
}
270
}
262
void 
271
void 
272
DcfManagerTest::AddAckTimeoutReset (uint64_t at)
273
{
274
  Simulator::Schedule (MicroSeconds (at) - Now (), 
275
                       &DcfManager::NotifyAckTimeoutResetNow, m_dcfManager);
276
}
277
void 
263
DcfManagerTest::AddAccessRequest (uint64_t at, uint64_t txTime, 
278
DcfManagerTest::AddAccessRequest (uint64_t at, uint64_t txTime, 
279
                                  uint64_t expectedGrantTime, uint32_t from)
280
{
281
  AddAccessRequestWithSuccessfullAck (at, txTime, expectedGrantTime, 0, from);
282
}
283
void 
284
DcfManagerTest::AddAccessRequestWithAckTimeout (uint64_t at, uint64_t txTime, 
264
                                  uint64_t expectedGrantTime, uint32_t from)
285
                                  uint64_t expectedGrantTime, uint32_t from)
265
{
286
{
266
  Simulator::Schedule (MicroSeconds (at) - Now (), 
287
  Simulator::Schedule (MicroSeconds (at) - Now (), 
267
                       &DcfManagerTest::DoAccessRequest, this,
288
                       &DcfManagerTest::DoAccessRequest, this,
268
                       txTime, expectedGrantTime, m_dcfStates[from]);
289
                       txTime, expectedGrantTime, m_dcfStates[from]);
269
}
290
}
270
291
void 
292
DcfManagerTest::AddAccessRequestWithSuccessfullAck (uint64_t at, uint64_t txTime, 
293
                                  uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from)
294
{
295
  NS_ASSERT(ackDelay < m_ackTimeoutValue);
296
  Simulator::Schedule (MicroSeconds (at) - Now (), 
297
                       &DcfManagerTest::DoAccessRequest, this,
298
                       txTime, expectedGrantTime, m_dcfStates[from]);
299
  AddAckTimeoutReset (expectedGrantTime + txTime + ackDelay);
300
}
271
void
301
void
272
DcfManagerTest::DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state)
302
DcfManagerTest::DoAccessRequest (uint64_t txTime, uint64_t expectedGrantTime, DcfStateTest *state)
273
{
303
{
 Lines 301-307    Link Here 
301
  //   |    rx     | sifs | aifsn | bslot0  | bslot1  |   | rx   | sifs  |  aifsn | bslot2 | bslot3 | tx  |
331
  //   |    rx     | sifs | aifsn | bslot0  | bslot1  |   | rx   | sifs  |  aifsn | bslot2 | bslot3 | tx  |
302
  //        |
332
  //        |
303
  //       30 request access. backoff slots: 4
333
  //       30 request access. backoff slots: 4
304
  StartTest (4, 6 , 10);
334
  StartTest (4, 6, 10);
305
  AddDcfState (1);
335
  AddDcfState (1);
306
  AddRxOkEvt (20, 40);
336
  AddRxOkEvt (20, 40);
307
  AddRxOkEvt (80, 20);
337
  AddRxOkEvt (80, 20);
 Lines 388-394    Link Here 
388
  ExpectCollision (40, 0, 1); // backoff: 0 slot
418
  ExpectCollision (40, 0, 1); // backoff: 0 slot
389
  ExpectInternalCollision (78, 1, 1); // backoff: 1 slot
419
  ExpectInternalCollision (78, 1, 1); // backoff: 1 slot
390
  EndTest ();
420
  EndTest ();
421
  
422
  // Test of AckTimeout handling: First queue requests access and ack procedure fails,
423
  // inside the ack timeout second queue with higher priority requests access.
424
  //
425
  //            20           40      50     60  66      76
426
  // DCF0 - low  |     tx     | ack timeout |sifs|       |
427
  // DCF1 - high |                    |     |sifs|  tx   |
428
  //                                  ^ request access
429
  StartTest (4, 6, 10);
430
  AddDcfState (2); // high priority DCF
431
  AddDcfState (0); // low priority DCF
432
  AddAccessRequestWithAckTimeout (20, 20, 20, 0);
433
  AddAccessRequest (50, 10, 66, 1);
434
  EndTest ();
391
435
436
  // Test of AckTimeout handling: 
437
  //
438
  // First queue requests access and ack is 2 us delayed (got ack interval at the picture),
439
  // inside this interval second queue with higher priority requests access.
440
  //
441
  //            20           40  41   42    48      58
442
  // DCF0 - low  |     tx     |got ack |sifs|       |
443
  // DCF1 - high |                |    |sifs|  tx   |
444
  //                              ^ request access
445
  StartTest (4, 6, 10);
446
  AddDcfState (2); // high priority DCF
447
  AddDcfState (0); // low priority DCF
448
  AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0);
449
  AddAccessRequest (41, 10, 48, 1);
450
  EndTest ();
451
452
  //Repeat the same but with one queue:
453
  //            20           40  41   42    48      58
454
  // DCF0 - low  |     tx     |got ack |sifs|       |
455
  //                              ^ request access
456
  StartTest (4, 6, 10);
457
  AddDcfState (2);
458
  AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0);
459
  AddAccessRequest (41, 10, 56, 0);
460
  EndTest ();
461
462
  //Repeat the same when ack was delayed:
463
  //and request the next access before previous tx end:
464
  //            20       39  40       42              64      74
465
  // DCF0 - low  |     tx     |got ack |sifs + 4 * slot|       |
466
  //                      ^ request access
467
  StartTest (4, 6, 10);
468
  AddDcfState (2);
469
  AddAccessRequestWithSuccessfullAck (20, 20, 20, 2, 0);
470
  AddAccessRequest (39, 10, 64, 0);
471
  ExpectCollision (39, 2, 0); // backoff: 2 slot
472
  EndTest ();
392
473
393
  //
474
  //
394
  // test simple NAV count. This scenario modelizes a simple DATA+ACK handshake
475
  // test simple NAV count. This scenario modelizes a simple DATA+ACK handshake
 Lines 404-410    Link Here 
404
  AddAccessRequest (30, 10, 93, 0);
485
  AddAccessRequest (30, 10, 93, 0);
405
  ExpectCollision (30, 2, 0); // backoff: 2 slot
486
  ExpectCollision (30, 2, 0); // backoff: 2 slot
406
  EndTest ();
487
  EndTest ();
407
408
488
409
  //
489
  //
410
  // test more complex NAV handling by a CF-poll. This scenario modelizes a 
490
  // test more complex NAV handling by a CF-poll. This scenario modelizes a 
(-)a/src/devices/wifi/dcf-manager.cc (-10 / +61 lines)
 Lines 160-175    Link Here 
160
 *         Listener for Nav events. Forwards to DcfManager
160
 *         Listener for Nav events. Forwards to DcfManager
161
 ***************************************************************/
161
 ***************************************************************/
162
162
163
class LowNavListener : public ns3::MacLowNavListener {
163
class LowDcfListener : public ns3::MacLowDcfListener {
164
public:
164
public:
165
  LowNavListener (ns3::DcfManager *dcf)
165
  LowDcfListener (ns3::DcfManager *dcf)
166
    : m_dcf (dcf) {}
166
    : m_dcf (dcf) {}
167
  virtual ~LowNavListener () {}
167
  virtual ~LowDcfListener () {}
168
  virtual void NavStart (Time duration) {
168
  virtual void NavStart (Time duration) {
169
    m_dcf->NotifyNavStartNow (duration);
169
    m_dcf->NotifyNavStartNow (duration);
170
  }
170
  }
171
  virtual void NavReset (Time duration) {
171
  virtual void NavReset (Time duration) {
172
    m_dcf->NotifyNavResetNow (duration);
172
    m_dcf->NotifyNavResetNow (duration);
173
  }
174
  virtual void AckTimeoutStart (Time duration) {
175
    m_dcf->NotifyAckTimeoutStartNow (duration);
176
  }
177
  virtual void AckTimeoutReset () {
178
    m_dcf->NotifyAckTimeoutResetNow ();
179
  }
180
  virtual void CtsTimeoutStart (Time duration) {
181
    m_dcf->NotifyCtsTimeoutStartNow (duration);
182
  }
183
  virtual void CtsTimeoutReset () {
184
    m_dcf->NotifyCtsTimeoutResetNow ();
173
  }
185
  }
174
private:
186
private:
175
  ns3::DcfManager *m_dcf;
187
  ns3::DcfManager *m_dcf;
 Lines 208-214    Link Here 
208
 ****************************************************************/
220
 ****************************************************************/
209
221
210
DcfManager::DcfManager ()
222
DcfManager::DcfManager ()
211
  : m_lastNavStart (MicroSeconds (0)),
223
  : m_lastAckTimeoutEnd (MicroSeconds (0)),
224
    m_lastCtsTimeoutEnd (MicroSeconds (0)),
225
    m_lastNavStart (MicroSeconds (0)),
212
    m_lastNavDuration (MicroSeconds (0)),
226
    m_lastNavDuration (MicroSeconds (0)),
213
    m_lastRxStart (MicroSeconds (0)),
227
    m_lastRxStart (MicroSeconds (0)),
214
    m_lastRxDuration (MicroSeconds (0)),
228
    m_lastRxDuration (MicroSeconds (0)),
 Lines 242-249    Link Here 
242
void 
256
void 
243
DcfManager::SetupLowListener (Ptr<MacLow> low)
257
DcfManager::SetupLowListener (Ptr<MacLow> low)
244
{
258
{
245
  m_lowListener = new LowNavListener (this);
259
  m_lowListener = new LowDcfListener (this);
246
  low->RegisterNavListener (m_lowListener);
260
  low->RegisterDcfListener (m_lowListener);
247
}
261
}
248
262
249
void 
263
void 
 Lines 294-299    Link Here 
294
  Time retval = Max (e, f);
308
  Time retval = Max (e, f);
295
  return retval;
309
  return retval;
296
}
310
}
311
Time
312
DcfManager::MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const
313
{
314
  Time g = Max (a, b);
315
  Time h = Max (c, d);
316
  Time i = Max (e, f);
317
  Time k = Max (g, h);
318
  Time retval = Max (k, i);
319
  return retval;
320
}
297
321
298
bool 
322
bool 
299
DcfManager::IsBusy (void) const
323
DcfManager::IsBusy (void) const
 Lines 351-357    Link Here 
351
    {
375
    {
352
      DcfState *state = *i;
376
      DcfState *state = *i;
353
      if (state->IsAccessRequested () && 
377
      if (state->IsAccessRequested () && 
354
          GetBackoffEndFor (state) <= Simulator::Now ())
378
          GetBackoffEndFor (state).GetTimeStep() <= Simulator::Now ().GetTimeStep ())
355
        {
379
        {
356
          /**
380
          /**
357
           * This is the first dcf we find with an expired backoff and which
381
           * This is the first dcf we find with an expired backoff and which
 Lines 428-437    Link Here 
428
  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
452
  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
429
  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
453
  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
430
  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
454
  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
455
  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
456
  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
431
  Time accessGrantedStart = MostRecent (rxAccessStart, 
457
  Time accessGrantedStart = MostRecent (rxAccessStart, 
432
                                        busyAccessStart,
458
                                        busyAccessStart,
433
                                        txAccessStart, 
459
                                        txAccessStart, 
434
                                        navAccessStart);
460
                                        navAccessStart,
461
                                        ackTimeoutAccessStart,
462
                                        ctsTimeoutAccessStart
463
                                        );
435
  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
464
  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
436
               ", rx access start=" << rxAccessStart <<
465
               ", rx access start=" << rxAccessStart <<
437
               ", busy access start=" << busyAccessStart <<
466
               ", busy access start=" << busyAccessStart <<
 Lines 491-497    Link Here 
491
      if (state->IsAccessRequested ())
520
      if (state->IsAccessRequested ())
492
        {
521
        {
493
          Time tmp = GetBackoffEndFor (state);
522
          Time tmp = GetBackoffEndFor (state);
494
          if (tmp > Simulator::Now ())
523
          if (tmp.GetTimeStep () > Simulator::Now ().GetTimeStep ())
495
            {
524
            {
496
              accessTimeoutNeeded = true;
525
              accessTimeoutNeeded = true;
497
              expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
526
              expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
 Lines 586-590    Link Here 
586
      m_lastNavDuration = duration;
615
      m_lastNavDuration = duration;
587
    }
616
    }
588
}
617
}
589
618
void
619
DcfManager::NotifyAckTimeoutStartNow (Time duration)
620
{
621
  NS_ASSERT(m_lastAckTimeoutEnd < Simulator::Now ());
622
  m_lastAckTimeoutEnd = Simulator::Now () + duration;
623
}
624
void
625
DcfManager::NotifyAckTimeoutResetNow ()
626
{
627
  m_lastAckTimeoutEnd = Simulator::Now ();
628
  DoRestartAccessTimeoutIfNeeded ();
629
}
630
void
631
DcfManager::NotifyCtsTimeoutStartNow (Time duration)
632
{
633
  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
634
}
635
void
636
DcfManager::NotifyCtsTimeoutResetNow ()
637
{
638
  m_lastCtsTimeoutEnd = Simulator::Now ();
639
  DoRestartAccessTimeoutIfNeeded ();
640
}
590
} // namespace ns3
641
} // namespace ns3
(-)a/src/devices/wifi/dcf-manager.h (-2 / +9 lines)
 Lines 238-249    Link Here 
238
   * Called at end of rx
238
   * Called at end of rx
239
   */
239
   */
240
  void NotifyNavStartNow (Time duration);
240
  void NotifyNavStartNow (Time duration);
241
241
  void NotifyAckTimeoutStartNow (Time duration);
242
  void NotifyAckTimeoutResetNow ();
243
  void NotifyCtsTimeoutStartNow (Time duration);
244
  void NotifyCtsTimeoutResetNow ();
245
  void NotifyAckTimeoutEnd (Time duration);
242
private:
246
private:
243
  void UpdateBackoff (void);
247
  void UpdateBackoff (void);
244
  Time MostRecent (Time a, Time b) const;
248
  Time MostRecent (Time a, Time b) const;
245
  Time MostRecent (Time a, Time b, Time c) const;
249
  Time MostRecent (Time a, Time b, Time c) const;
246
  Time MostRecent (Time a, Time b, Time c, Time d) const;
250
  Time MostRecent (Time a, Time b, Time c, Time d) const;
251
  Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const;
247
  /**
252
  /**
248
   * Access will never be granted to the medium _before_
253
   * Access will never be granted to the medium _before_
249
   * the time returned by this method.
254
   * the time returned by this method.
 Lines 262-267    Link Here 
262
  typedef std::vector<DcfState *> States;
267
  typedef std::vector<DcfState *> States;
263
268
264
  States m_states;
269
  States m_states;
270
  Time m_lastAckTimeoutEnd;
271
  Time m_lastCtsTimeoutEnd;
265
  Time m_lastNavStart;
272
  Time m_lastNavStart;
266
  Time m_lastNavDuration;
273
  Time m_lastNavDuration;
267
  Time m_lastRxStart;
274
  Time m_lastRxStart;
 Lines 279-285    Link Here 
279
  Time m_slotTime;
286
  Time m_slotTime;
280
  Time m_sifs;
287
  Time m_sifs;
281
  class PhyListener *m_phyListener;
288
  class PhyListener *m_phyListener;
282
  class LowNavListener *m_lowListener;
289
  class LowDcfListener *m_lowListener;
283
};
290
};
284
291
285
} // namespace ns3
292
} // namespace ns3
(-)a/src/devices/wifi/mac-low.cc (-6 / +45 lines)
 Lines 110-118    Link Here 
110
{}
110
{}
111
MacLowTransmissionListener::~MacLowTransmissionListener ()
111
MacLowTransmissionListener::~MacLowTransmissionListener ()
112
{}
112
{}
113
MacLowNavListener::MacLowNavListener ()
113
MacLowDcfListener::MacLowDcfListener ()
114
{}
114
{}
115
MacLowNavListener::~MacLowNavListener ()
115
MacLowDcfListener::~MacLowDcfListener ()
116
{}
116
{}
117
117
118
MacLowTransmissionParameters::MacLowTransmissionParameters ()
118
MacLowTransmissionParameters::MacLowTransmissionParameters ()
 Lines 423-431    Link Here 
423
  m_rxCallback = callback;
423
  m_rxCallback = callback;
424
}
424
}
425
void 
425
void 
426
MacLow::RegisterNavListener (MacLowNavListener *listener)
426
MacLow::RegisterDcfListener (MacLowDcfListener *listener)
427
{
427
{
428
  m_navListeners.push_back (listener);
428
  m_dcfListeners.push_back (listener);
429
}
429
}
430
430
431
431
 Lines 543-548    Link Here 
543
      station->ReportRtsOk (rxSnr, txMode, tag.Get ());
543
      station->ReportRtsOk (rxSnr, txMode, tag.Get ());
544
      
544
      
545
      m_ctsTimeoutEvent.Cancel ();
545
      m_ctsTimeoutEvent.Cancel ();
546
      NotifyCtsTimeoutResetNow ();
546
      m_listener->GotCts (rxSnr, txMode);
547
      m_listener->GotCts (rxSnr, txMode);
547
      NS_ASSERT (m_sendDataEvent.IsExpired ());
548
      NS_ASSERT (m_sendDataEvent.IsExpired ());
548
      m_sendDataEvent = Simulator::Schedule (GetSifs (), 
549
      m_sendDataEvent = Simulator::Schedule (GetSifs (), 
 Lines 569-580    Link Here 
569
          m_normalAckTimeoutEvent.IsRunning ()) 
570
          m_normalAckTimeoutEvent.IsRunning ()) 
570
        {
571
        {
571
          m_normalAckTimeoutEvent.Cancel ();
572
          m_normalAckTimeoutEvent.Cancel ();
573
          NotifyAckTimeoutResetNow ();
572
          gotAck = true;
574
          gotAck = true;
573
        }
575
        }
574
      if (m_txParams.MustWaitFastAck () &&
576
      if (m_txParams.MustWaitFastAck () &&
575
          m_fastAckTimeoutEvent.IsRunning ()) 
577
          m_fastAckTimeoutEvent.IsRunning ()) 
576
        {
578
        {
577
          m_fastAckTimeoutEvent.Cancel ();
579
          m_fastAckTimeoutEvent.Cancel ();
580
          NotifyAckTimeoutResetNow ();
578
          gotAck = true;
581
          gotAck = true;
579
        }
582
        }
580
      if (gotAck) 
583
      if (gotAck) 
 Lines 796-802    Link Here 
796
void
799
void
797
MacLow::DoNavResetNow (Time duration)
800
MacLow::DoNavResetNow (Time duration)
798
{
801
{
799
  for (NavListenersCI i = m_navListeners.begin (); i != m_navListeners.end (); i++) 
802
  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
800
    {
803
    {
801
      (*i)->NavReset (duration);
804
      (*i)->NavReset (duration);
802
    }
805
    }
 Lines 806-812    Link Here 
806
bool
809
bool
807
MacLow::DoNavStartNow (Time duration)
810
MacLow::DoNavStartNow (Time duration)
808
{
811
{
809
  for (NavListenersCI i = m_navListeners.begin (); i != m_navListeners.end (); i++) 
812
  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
810
    {
813
    {
811
      (*i)->NavStart (duration);
814
      (*i)->NavStart (duration);
812
    }
815
    }
 Lines 819-824    Link Here 
819
      return true;
822
      return true;
820
    }
823
    }
821
  return false;
824
  return false;
825
}
826
void
827
MacLow::NotifyAckTimeoutStartNow (Time duration)
828
{
829
  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
830
    {
831
      (*i)->AckTimeoutStart (duration);
832
    }
833
}
834
void
835
MacLow::NotifyAckTimeoutResetNow ()
836
{
837
  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
838
    {
839
      (*i)->AckTimeoutReset ();
840
    }
841
}
842
void
843
MacLow::NotifyCtsTimeoutStartNow (Time duration)
844
{
845
  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
846
    {
847
      (*i)->CtsTimeoutStart (duration);
848
    }
849
}
850
void
851
MacLow::NotifyCtsTimeoutResetNow ()
852
{
853
  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++) 
854
    {
855
      (*i)->CtsTimeoutReset ();
856
    }
822
}
857
}
823
858
824
void
859
void
 Lines 945-950    Link Here 
945
  Time timerDelay = txDuration + GetCtsTimeout ();
980
  Time timerDelay = txDuration + GetCtsTimeout ();
946
981
947
  NS_ASSERT (m_ctsTimeoutEvent.IsExpired ());
982
  NS_ASSERT (m_ctsTimeoutEvent.IsExpired ());
983
  NotifyCtsTimeoutStartNow (timerDelay);
948
  m_ctsTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::CtsTimeout, this);
984
  m_ctsTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::CtsTimeout, this);
949
985
950
  Ptr<Packet> packet = Create<Packet> ();
986
  Ptr<Packet> packet = Create<Packet> ();
 Lines 964-981    Link Here 
964
    {
1000
    {
965
      Time timerDelay = txDuration + GetAckTimeout ();
1001
      Time timerDelay = txDuration + GetAckTimeout ();
966
      NS_ASSERT (m_normalAckTimeoutEvent.IsExpired ());
1002
      NS_ASSERT (m_normalAckTimeoutEvent.IsExpired ());
1003
      NotifyAckTimeoutStartNow (timerDelay);
967
      m_normalAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::NormalAckTimeout, this);
1004
      m_normalAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::NormalAckTimeout, this);
968
    } 
1005
    } 
969
  else if (m_txParams.MustWaitFastAck ()) 
1006
  else if (m_txParams.MustWaitFastAck ()) 
970
    {
1007
    {
971
      Time timerDelay = txDuration + GetPifs ();
1008
      Time timerDelay = txDuration + GetPifs ();
972
      NS_ASSERT (m_fastAckTimeoutEvent.IsExpired ());
1009
      NS_ASSERT (m_fastAckTimeoutEvent.IsExpired ());
1010
      NotifyAckTimeoutStartNow (timerDelay);
973
      m_fastAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::FastAckTimeout, this);
1011
      m_fastAckTimeoutEvent = Simulator::Schedule (timerDelay, &MacLow::FastAckTimeout, this);
974
    } 
1012
    } 
975
  else if (m_txParams.MustWaitSuperFastAck ()) 
1013
  else if (m_txParams.MustWaitSuperFastAck ()) 
976
    {
1014
    {
977
      Time timerDelay = txDuration + GetPifs ();
1015
      Time timerDelay = txDuration + GetPifs ();
978
      NS_ASSERT (m_superFastAckTimeoutEvent.IsExpired ());
1016
      NS_ASSERT (m_superFastAckTimeoutEvent.IsExpired ());
1017
      NotifyAckTimeoutStartNow (timerDelay);
979
      m_superFastAckTimeoutEvent = Simulator::Schedule (timerDelay, 
1018
      m_superFastAckTimeoutEvent = Simulator::Schedule (timerDelay, 
980
                                                        &MacLow::SuperFastAckTimeout, this);
1019
                                                        &MacLow::SuperFastAckTimeout, this);
981
    } 
1020
    } 
(-)a/src/devices/wifi/mac-low.h (-7 / +15 lines)
 Lines 100-109    Link Here 
100
 * and calls to its methods are forwards to the corresponding
100
 * and calls to its methods are forwards to the corresponding
101
 * ns3::Dcf methods.
101
 * ns3::Dcf methods.
102
 */
102
 */
103
class MacLowNavListener {
103
class MacLowDcfListener {
104
public:
104
public:
105
  MacLowNavListener ();
105
  MacLowDcfListener ();
106
  virtual ~MacLowNavListener ();
106
  virtual ~MacLowDcfListener ();
107
  /**
107
  /**
108
   * \param duration duration of NAV timer
108
   * \param duration duration of NAV timer
109
   */
109
   */
 Lines 112-117    Link Here 
112
   * \param duration duration of NAV timer
112
   * \param duration duration of NAV timer
113
   */
113
   */
114
  virtual void NavReset (Time duration) = 0;
114
  virtual void NavReset (Time duration) = 0;
115
  virtual void AckTimeoutStart (Time duration) = 0;
116
  virtual void AckTimeoutReset () = 0;
117
  virtual void CtsTimeoutStart (Time duration) = 0;
118
  virtual void CtsTimeoutReset () = 0;
115
};
119
};
116
120
117
/**
121
/**
 Lines 306-312    Link Here 
306
   * \param listener listen to NAV events for every incoming
310
   * \param listener listen to NAV events for every incoming
307
   *        and outgoing packet.
311
   *        and outgoing packet.
308
   */
312
   */
309
  void RegisterNavListener (MacLowNavListener *listener);
313
  void RegisterDcfListener (MacLowDcfListener *listener);
310
314
311
  /**
315
  /**
312
   * \param packet to send (does not include the 802.11 MAC header and checksum)
316
   * \param packet to send (does not include the 802.11 MAC header and checksum)
 Lines 375-380    Link Here 
375
  void DoNavResetNow (Time duration);
379
  void DoNavResetNow (Time duration);
376
  bool DoNavStartNow (Time duration);
380
  bool DoNavStartNow (Time duration);
377
  bool IsNavZero (void) const;
381
  bool IsNavZero (void) const;
382
  void NotifyAckTimeoutStartNow (Time duration);
383
  void NotifyAckTimeoutResetNow ();
384
  void NotifyCtsTimeoutStartNow (Time duration);
385
  void NotifyCtsTimeoutResetNow ();
378
  void MaybeCancelPrevious (void);
386
  void MaybeCancelPrevious (void);
379
  
387
  
380
  void NavCounterResetCtsMissed (Time rtsEndRxTime);
388
  void NavCounterResetCtsMissed (Time rtsEndRxTime);
 Lines 397-405    Link Here 
397
  Ptr<WifiPhy> m_phy;
405
  Ptr<WifiPhy> m_phy;
398
  Ptr<WifiRemoteStationManager> m_stationManager;
406
  Ptr<WifiRemoteStationManager> m_stationManager;
399
  MacLowRxCallback m_rxCallback;
407
  MacLowRxCallback m_rxCallback;
400
  typedef std::vector<MacLowNavListener *>::const_iterator NavListenersCI;
408
  typedef std::vector<MacLowDcfListener *>::const_iterator DcfListenersCI;
401
  typedef std::vector<MacLowNavListener *> NavListeners;
409
  typedef std::vector<MacLowDcfListener *> DcfListeners;
402
  NavListeners m_navListeners;
410
  DcfListeners m_dcfListeners;
403
411
404
  EventId m_normalAckTimeoutEvent;
412
  EventId m_normalAckTimeoutEvent;
405
  EventId m_fastAckTimeoutEvent;
413
  EventId m_fastAckTimeoutEvent;

Return to bug 556