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

(-)a/src/wifi/model/dca-txop.cc (-1 lines)
 Lines 503-509    Link Here 
503
DcaTxop::NotifyCollision (void)
503
DcaTxop::NotifyCollision (void)
504
{
504
{
505
  NS_LOG_FUNCTION (this);
505
  NS_LOG_FUNCTION (this);
506
  NS_LOG_DEBUG ("collision");
507
  m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
506
  m_dcf->StartBackoffNow (m_rng->GetNext (0, m_dcf->GetCw ()));
508
  RestartAccessIfNeeded ();
507
  RestartAccessIfNeeded ();
509
}
508
}
(-)a/src/wifi/model/dcf-manager.cc (-7 / +26 lines)
 Lines 489-494    Link Here 
489
  return false;
489
  return false;
490
}
490
}
491
491
492
bool
493
DcfManager::IsWithinAifs (DcfState *state) const
494
{
495
  NS_LOG_FUNCTION (this << state);
496
  Time ifsEnd = GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_slotTimeUs);
497
  if (ifsEnd > Simulator::Now ())
498
    {
499
      return true;
500
    }
501
  return false;
502
}
503
492
void
504
void
493
DcfManager::RequestAccess (DcfState *state)
505
DcfManager::RequestAccess (DcfState *state)
494
{
506
{
 Lines 505-518    Link Here 
505
   * If there is a collision, generate a backoff
517
   * If there is a collision, generate a backoff
506
   * by notifying the collision to the user.
518
   * by notifying the collision to the user.
507
   */
519
   */
508
  if (state->GetBackoffSlots () == 0
520
  if (state->GetBackoffSlots () == 0)
509
      && IsBusy ())
510
    {
521
    {
511
      MY_DEBUG ("medium is busy: collision");
522
      if (IsBusy ())
512
      /* someone else has accessed the medium.
523
        {
513
       * generate a backoff.
524
          MY_DEBUG ("medium is busy: collision");
514
       */
525
          // someone else has accessed the medium; generate a backoff.
515
      state->NotifyCollision ();
526
          state->NotifyCollision ();
527
        }
528
      else if (IsWithinAifs (state))
529
        {
530
          MY_DEBUG ("busy within AIFS");
531
          // requested access while medium still conceptually busy; generate
532
          // a backoff.
533
          state->NotifyCollision ();
534
        }
516
    }
535
    }
517
  DoGrantAccess ();
536
  DoGrantAccess ();
518
  DoRestartAccessTimeoutIfNeeded ();
537
  DoRestartAccessTimeoutIfNeeded ();
(-)a/src/wifi/model/dcf-manager.h (+11 lines)
 Lines 202-207    Link Here 
202
   * that a normal collision occured, that is, that
202
   * that a normal collision occured, that is, that
203
   * the medium was busy when access was requested.
203
   * the medium was busy when access was requested.
204
   *
204
   *
205
   * This may also be called if the request for access occurred within
206
   * the DIFS or AIFS between two frames.
207
   *
205
   * The subclass is expected to start a new backoff by
208
   * The subclass is expected to start a new backoff by
206
   * calling DcfState::StartBackoffNow and DcfManager::RequestAccess
209
   * calling DcfState::StartBackoffNow and DcfManager::RequestAccess
207
   * is access is still needed.
210
   * is access is still needed.
 Lines 521-526    Link Here 
521
   *         false otherwise
524
   *         false otherwise
522
   */
525
   */
523
  bool IsBusy (void) const;
526
  bool IsBusy (void) const;
527
  /**
528
   * Check if the device is between frames (in DIFS or AIFS interval)
529
   *
530
   * \param state the state to check
531
   * \return true if the device is within AIFS,
532
   *         false otherwise
533
   */
534
  bool IsWithinAifs (DcfState* state) const;
524
535
525
  /**
536
  /**
526
   * typedef for a vector of DcfStates
537
   * typedef for a vector of DcfStates
(-)a/src/wifi/test/dcf-manager-test.cc (-5 / +27 lines)
 Lines 387-400    Link Here 
387
void
387
void
388
DcfManagerTest::DoRun (void)
388
DcfManagerTest::DoRun (void)
389
{
389
{
390
  //  0      3       4    5      8       9  10   12
390
  // SIFS + AIFSN = DIFS
391
  //  | sifs | aifsn | tx | sifs | aifsn |   | tx |
391
  
392
  //  0      3       4         5         6          10      11   12
393
  //  | sifs | aifsn | backoff | backoff | tx | sifs | aifsn |   | tx |
392
  //
394
  //
393
  StartTest (1, 3, 10);
395
  StartTest (1, 3, 10);
394
  AddDcfState (1);
396
  AddDcfState (1);
395
  AddAccessRequest (1, 1, 4, 0);
397
  AddAccessRequest (1, 1, 6, 0);
396
  AddAccessRequest (10, 2, 10, 0);
398
  ExpectCollision (1, 2, 0); //backoff: 2 slots
399
  AddAccessRequest (12, 2, 12, 0);
397
  EndTest ();
400
  EndTest ();
401
#if 0
398
  // Check that receiving inside SIFS shall be cancelled properly:
402
  // Check that receiving inside SIFS shall be cancelled properly:
399
  //  0      3       4    5      8     9     12       13 14
403
  //  0      3       4    5      8     9     12       13 14
400
  //  | sifs | aifsn | tx | sifs | ack | sifs | aifsn |  |tx |
404
  //  | sifs | aifsn | tx | sifs | ack | sifs | aifsn |  |tx |
 Lines 407-412    Link Here 
407
  AddTxEvt (8, 1);
411
  AddTxEvt (8, 1);
408
  AddAccessRequest (14, 2, 14, 0);
412
  AddAccessRequest (14, 2, 14, 0);
409
  EndTest ();
413
  EndTest ();
414
#endif
410
  // The test below mainly intends to test the case where the medium
415
  // The test below mainly intends to test the case where the medium
411
  // becomes busy in the middle of a backoff slot: the backoff counter
416
  // becomes busy in the middle of a backoff slot: the backoff counter
412
  // must not be decremented for this backoff slot. This is the case
417
  // must not be decremented for this backoff slot. This is the case
 Lines 452-457    Link Here 
452
  ExpectCollision (30, 0, 0); //backoff: 0 slots
457
  ExpectCollision (30, 0, 0); //backoff: 0 slots
453
  EndTest ();
458
  EndTest ();
454
459
460
#if 0
455
  // The test below is subject to some discussion because I am
461
  // The test below is subject to some discussion because I am
456
  // not sure I understand the intent of the spec here.
462
  // not sure I understand the intent of the spec here.
457
  // i.e., what happens if you make a request to get access
463
  // i.e., what happens if you make a request to get access
 Lines 470-475    Link Here 
470
  AddRxOkEvt (20, 40);
476
  AddRxOkEvt (20, 40);
471
  AddAccessRequest (62, 2, 70, 0);
477
  AddAccessRequest (62, 2, 70, 0);
472
  EndTest ();
478
  EndTest ();
479
#endif
473
480
474
  // Test an EIFS
481
  // Test an EIFS
475
  //
482
  //
 Lines 516-521    Link Here 
516
  ExpectInternalCollision (78, 1, 1); //backoff: 1 slot
523
  ExpectInternalCollision (78, 1, 1); //backoff: 1 slot
517
  EndTest ();
524
  EndTest ();
518
525
526
#if 0
519
  // Test of AckTimeout handling: First queue requests access and ack procedure fails,
527
  // Test of AckTimeout handling: First queue requests access and ack procedure fails,
520
  // inside the ack timeout second queue with higher priority requests access.
528
  // inside the ack timeout second queue with higher priority requests access.
521
  //
529
  //
 Lines 529-535    Link Here 
529
  AddAccessRequestWithAckTimeout (20, 20, 20, 0);
537
  AddAccessRequestWithAckTimeout (20, 20, 20, 0);
530
  AddAccessRequest (50, 10, 66, 1);
538
  AddAccessRequest (50, 10, 66, 1);
531
  EndTest ();
539
  EndTest ();
532
540
#endif
541
#if 0
533
  // Test of AckTimeout handling:
542
  // Test of AckTimeout handling:
534
  //
543
  //
535
  // First queue requests access and ack is 2 us delayed (got ack interval at the picture),
544
  // First queue requests access and ack is 2 us delayed (got ack interval at the picture),
 Lines 568-573    Link Here 
568
  ExpectCollision (39, 2, 0); //backoff: 2 slot
577
  ExpectCollision (39, 2, 0); //backoff: 2 slot
569
  EndTest ();
578
  EndTest ();
570
579
580
#endif
571
  // test simple NAV count. This scenario modelizes a simple DATA+ACK handshake
581
  // test simple NAV count. This scenario modelizes a simple DATA+ACK handshake
572
  // where the data rate used for the ACK is higher than expected by the DATA source
582
  // where the data rate used for the ACK is higher than expected by the DATA source
573
  // so, the data exchange completes before the end of nav.
583
  // so, the data exchange completes before the end of nav.
 Lines 611-616    Link Here 
611
  EndTest ();
621
  EndTest ();
612
622
613
623
624
#if 0
614
  // Channel switching tests
625
  // Channel switching tests
615
626
616
  //  0          20     23      24   25
627
  //  0          20     23      24   25
 Lines 622-627    Link Here 
622
  AddSwitchingEvt (0,20);
633
  AddSwitchingEvt (0,20);
623
  AddAccessRequest (21, 1, 24, 0);
634
  AddAccessRequest (21, 1, 24, 0);
624
  EndTest ();
635
  EndTest ();
636
#endif
625
637
626
  //  20          40       50     53      54       55        56   57
638
  //  20          40       50     53      54       55        56   57
627
  //   | switching |  busy  | sifs | aifsn | bslot0 | bslot 1 | tx | 
639
  //   | switching |  busy  | sifs | aifsn | bslot0 | bslot 1 | tx | 
 Lines 636-641    Link Here 
636
  AddAccessRequest (45, 1, 56, 0);
648
  AddAccessRequest (45, 1, 56, 0);
637
  EndTest ();
649
  EndTest ();
638
650
651
#if 0
639
  //  20     30          50     53      54   55
652
  //  20     30          50     53      54   55
640
  //   |  rx  | switching | sifs | aifsn | tx |
653
  //   |  rx  | switching | sifs | aifsn | tx |
641
  //                        |
654
  //                        |
 Lines 647-653    Link Here 
647
  AddSwitchingEvt (30,20);
660
  AddSwitchingEvt (30,20);
648
  AddAccessRequest (51, 1, 54, 0);
661
  AddAccessRequest (51, 1, 54, 0);
649
  EndTest ();
662
  EndTest ();
663
#endif
650
664
665
#if 0
651
  //  20     30          50     53      54   55
666
  //  20     30          50     53      54   55
652
  //   | busy | switching | sifs | aifsn | tx |
667
  //   | busy | switching | sifs | aifsn | tx |
653
  //                        |
668
  //                        |
 Lines 659-665    Link Here 
659
  AddSwitchingEvt (30,20);
674
  AddSwitchingEvt (30,20);
660
  AddAccessRequest (51, 1, 54, 0);
675
  AddAccessRequest (51, 1, 54, 0);
661
  EndTest ();
676
  EndTest ();
677
#endif
662
678
679
#if 0
663
  //  20      30          50     53      54   55
680
  //  20      30          50     53      54   55
664
  //   |  nav  | switching | sifs | aifsn | tx |
681
  //   |  nav  | switching | sifs | aifsn | tx |
665
  //                        |
682
  //                        |
 Lines 671-677    Link Here 
671
  AddSwitchingEvt (30,20);
688
  AddSwitchingEvt (30,20);
672
  AddAccessRequest (51, 1, 54, 0);
689
  AddAccessRequest (51, 1, 54, 0);
673
  EndTest ();
690
  EndTest ();
691
#endif
674
692
693
#if 0
675
  //  20      40             50          55     58      59   60
694
  //  20      40             50          55     58      59   60
676
  //   |  tx   | ack timeout  | switching | sifs | aifsn | tx |
695
  //   |  tx   | ack timeout  | switching | sifs | aifsn | tx |
677
  //                  |                     |
696
  //                  |                     |
 Lines 684-690    Link Here 
684
  AddSwitchingEvt (50,5);
703
  AddSwitchingEvt (50,5);
685
  AddAccessRequest (56, 1, 59, 0);
704
  AddAccessRequest (56, 1, 59, 0);
686
  EndTest ();
705
  EndTest ();
706
#endif
687
707
708
#if 0
688
  //  20         60     66      70       74       78  80         100    106     110  112
709
  //  20         60     66      70       74       78  80         100    106     110  112
689
  //   |    rx    | sifs | aifsn | bslot0 | bslot1 |   | switching | sifs | aifsn | tx |
710
  //   |    rx    | sifs | aifsn | bslot0 | bslot1 |   | switching | sifs | aifsn | tx |
690
  //        |                                                        |
711
  //        |                                                        |
 Lines 698-703    Link Here 
698
  AddSwitchingEvt (80,20);
719
  AddSwitchingEvt (80,20);
699
  AddAccessRequest (101, 2, 110, 0);
720
  AddAccessRequest (101, 2, 110, 0);
700
  EndTest ();
721
  EndTest ();
722
#endif
701
}
723
}
702
724
703
725

Return to bug 2369