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

(-)a/CHANGES.html (+1 lines)
 Lines 57-62    Link Here 
57
</ul>
57
</ul>
58
<h2>Changes to existing API:</h2>
58
<h2>Changes to existing API:</h2>
59
<ul>
59
<ul>
60
<li> The trace sources BackoffTrace and CwTrace were moved from class QosTxop to base class Txop, allowing these values to be traced for DCF operation.  In addition, the trace signature for BackoffTrace was changed from TracedValue to TracedCallback (callback taking one argument instead of two).  Most users of CwTrace for QosTxop configurations will not need to change existing programs, but users of BackoffTrace will need to adjust the callback signature to match.</li>
60
</ul>
61
</ul>
61
<h2>Changes to build system:</h2>
62
<h2>Changes to build system:</h2>
62
<ul>
63
<ul>
(-)a/src/wifi/model/qos-txop.cc (-28 / +30 lines)
 Lines 52-65    Link Here 
52
    .SetParent<ns3::Txop> ()
52
    .SetParent<ns3::Txop> ()
53
    .SetGroupName ("Wifi")
53
    .SetGroupName ("Wifi")
54
    .AddConstructor<QosTxop> ()
54
    .AddConstructor<QosTxop> ()
55
    .AddTraceSource ("BackoffTrace",
56
                     "Trace source for backoff values",
57
                     MakeTraceSourceAccessor (&QosTxop::m_backoffTrace),
58
                     "ns3::TracedValueCallback::Uint32")
59
    .AddTraceSource ("CwTrace",
60
                     "Trace source for contention window values",
61
                     MakeTraceSourceAccessor (&QosTxop::m_cwTrace),
62
                     "ns3::TracedValueCallback::Uint32")
63
    .AddTraceSource ("TxopTrace",
55
    .AddTraceSource ("TxopTrace",
64
                     "Trace source for txop start and duration times",
56
                     "Trace source for txop start and duration times",
65
                     MakeTraceSourceAccessor (&QosTxop::m_txopTrace),
57
                     MakeTraceSourceAccessor (&QosTxop::m_txopTrace),
 Lines 409-416    Link Here 
409
          UpdateFailedCw ();
401
          UpdateFailedCw ();
410
        }
402
        }
411
    }
403
    }
412
  m_backoffTrace = m_rng->GetInteger (0, GetCw ());
404
  m_backoff = m_rng->GetInteger (0, GetCw ());
413
  StartBackoffNow (m_backoffTrace);
405
  m_backoffTrace (m_backoff);
406
  StartBackoffNow (m_backoff);
414
  RestartAccessIfNeeded ();
407
  RestartAccessIfNeeded ();
415
}
408
}
416
409
 Lines 418-425    Link Here 
418
QosTxop::NotifyCollision (void)
411
QosTxop::NotifyCollision (void)
419
{
412
{
420
  NS_LOG_FUNCTION (this);
413
  NS_LOG_FUNCTION (this);
421
  m_backoffTrace = m_rng->GetInteger (0, GetCw ());
414
  m_backoff = m_rng->GetInteger (0, GetCw ());
422
  StartBackoffNow (m_backoffTrace);
415
  m_backoffTrace (m_backoff);
416
  StartBackoffNow (m_backoff);
423
  RestartAccessIfNeeded ();
417
  RestartAccessIfNeeded ();
424
}
418
}
425
419
 Lines 481-488    Link Here 
481
      UpdateFailedCw ();
475
      UpdateFailedCw ();
482
      m_cwTrace = GetCw ();
476
      m_cwTrace = GetCw ();
483
    }
477
    }
484
  m_backoffTrace = m_rng->GetInteger (0, GetCw ());
478
  m_backoff = m_rng->GetInteger (0, GetCw ());
485
  StartBackoffNow (m_backoffTrace);
479
  m_backoffTrace (m_backoff);
480
  StartBackoffNow (m_backoff);
486
  RestartAccessIfNeeded ();
481
  RestartAccessIfNeeded ();
487
}
482
}
488
483
 Lines 529-536    Link Here 
529
              m_txopTrace (m_startTxop, Simulator::Now () - m_startTxop);
524
              m_txopTrace (m_startTxop, Simulator::Now () - m_startTxop);
530
            }
525
            }
531
          m_cwTrace = GetCw ();
526
          m_cwTrace = GetCw ();
532
          m_backoffTrace = m_rng->GetInteger (0, GetCw ());
527
          m_backoff = m_rng->GetInteger (0, GetCw ());
533
          StartBackoffNow (m_backoffTrace);
528
          m_backoffTrace (m_backoff);
529
          StartBackoffNow (m_backoff);
534
          RestartAccessIfNeeded ();
530
          RestartAccessIfNeeded ();
535
        }
531
        }
536
    }
532
    }
 Lines 543-550    Link Here 
543
            {
539
            {
544
              m_txopTrace (m_startTxop, Simulator::Now () - m_startTxop);
540
              m_txopTrace (m_startTxop, Simulator::Now () - m_startTxop);
545
              m_cwTrace = GetCw ();
541
              m_cwTrace = GetCw ();
546
              m_backoffTrace = m_rng->GetInteger (0, GetCw ());
542
              m_backoff = m_rng->GetInteger (0, GetCw ());
547
              StartBackoffNow (m_backoffTrace);
543
              m_backoffTrace (m_backoff);
544
              StartBackoffNow (m_backoff);
548
              m_fragmentNumber++;
545
              m_fragmentNumber++;
549
              RestartAccessIfNeeded ();
546
              RestartAccessIfNeeded ();
550
            }
547
            }
 Lines 613-620    Link Here 
613
      UpdateFailedCw ();
610
      UpdateFailedCw ();
614
      m_cwTrace = GetCw ();
611
      m_cwTrace = GetCw ();
615
    }
612
    }
616
  m_backoffTrace = m_rng->GetInteger (0, GetCw ());
613
  m_backoff = m_rng->GetInteger (0, GetCw ());
617
  StartBackoffNow (m_backoffTrace);
614
  m_backoffTrace (m_backoff);
615
  StartBackoffNow (m_backoff);
618
  RestartAccessIfNeeded ();
616
  RestartAccessIfNeeded ();
619
}
617
}
620
618
 Lines 687-694    Link Here 
687
      ResetCw ();
685
      ResetCw ();
688
      m_cwTrace = GetCw ();
686
      m_cwTrace = GetCw ();
689
    }
687
    }
690
  m_backoffTrace = m_rng->GetInteger (0, GetCw ());
688
  m_backoff = m_rng->GetInteger (0, GetCw ());
691
  StartBackoffNow (m_backoffTrace);
689
  m_backoffTrace (m_backoff);
690
  StartBackoffNow (m_backoff);
692
  RestartAccessIfNeeded ();
691
  RestartAccessIfNeeded ();
693
}
692
}
694
693
 Lines 941-948    Link Here 
941
  m_currentPacket = 0;
940
  m_currentPacket = 0;
942
  ResetCw ();
941
  ResetCw ();
943
  m_cwTrace = GetCw ();
942
  m_cwTrace = GetCw ();
944
  m_backoffTrace = m_rng->GetInteger (0, GetCw ());
943
  m_backoff = m_rng->GetInteger (0, GetCw ());
945
  StartBackoffNow (m_backoffTrace);
944
  m_backoffTrace (m_backoff);
945
  StartBackoffNow (m_backoff);
946
  StartAccessIfNeeded ();
946
  StartAccessIfNeeded ();
947
}
947
}
948
948
 Lines 1271-1278    Link Here 
1271
          m_txopTrace (m_startTxop, Simulator::Now () - m_startTxop);
1271
          m_txopTrace (m_startTxop, Simulator::Now () - m_startTxop);
1272
        }
1272
        }
1273
      m_cwTrace = GetCw ();
1273
      m_cwTrace = GetCw ();
1274
      m_backoffTrace = m_rng->GetInteger (0, GetCw ());
1274
      m_backoff = m_rng->GetInteger (0, GetCw ());
1275
      StartBackoffNow (m_backoffTrace);
1275
      m_backoffTrace (m_backoff);
1276
      StartBackoffNow (m_backoff);
1276
      RestartAccessIfNeeded ();
1277
      RestartAccessIfNeeded ();
1277
    }
1278
    }
1278
}
1279
}
 Lines 1535-1542    Link Here 
1535
  NS_LOG_FUNCTION (this);
1536
  NS_LOG_FUNCTION (this);
1536
  ResetCw ();
1537
  ResetCw ();
1537
  m_cwTrace = GetCw ();
1538
  m_cwTrace = GetCw ();
1538
  m_backoffTrace = m_rng->GetInteger (0, GetCw ());
1539
  m_backoff = m_rng->GetInteger (0, GetCw ());
1539
  StartBackoffNow (m_backoffTrace);
1540
  m_backoffTrace (m_backoff);
1541
  StartBackoffNow (m_backoff);
1540
}
1542
}
1541
1543
1542
void
1544
void
(-)a/src/wifi/model/qos-txop.h (-2 lines)
 Lines 552-559    Link Here 
552
  bool m_isAccessRequestedForRts;                   //!< flag whether access is requested to transmit a RTS frame
552
  bool m_isAccessRequestedForRts;                   //!< flag whether access is requested to transmit a RTS frame
553
  bool m_currentIsFragmented;                       //!< flag whether current packet is fragmented
553
  bool m_currentIsFragmented;                       //!< flag whether current packet is fragmented
554
554
555
  TracedValue<uint32_t> m_backoffTrace;   //!< backoff trace value
556
  TracedValue<uint32_t> m_cwTrace;        //!< CW trace value
557
  TracedCallback<Time, Time> m_txopTrace; //!< TXOP trace callback
555
  TracedCallback<Time, Time> m_txopTrace; //!< TXOP trace callback
558
};
556
};
559
557
(-)a/src/wifi/model/txop.cc (-6 / +36 lines)
 Lines 69-74    Link Here 
69
                   PointerValue (),
69
                   PointerValue (),
70
                   MakePointerAccessor (&Txop::GetWifiMacQueue),
70
                   MakePointerAccessor (&Txop::GetWifiMacQueue),
71
                   MakePointerChecker<WifiMacQueue> ())
71
                   MakePointerChecker<WifiMacQueue> ())
72
    .AddTraceSource ("BackoffTrace",
73
                     "Trace source for backoff values",
74
                     MakeTraceSourceAccessor (&Txop::m_backoffTrace),
75
                     "ns3::TracedCallback::Uint32Callback")
76
    .AddTraceSource ("CwTrace",
77
                     "Trace source for contention window values",
78
                     MakeTraceSourceAccessor (&Txop::m_cwTrace),
79
                     "ns3::TracedValueCallback::Uint32")
72
  ;
80
  ;
73
  return tid;
81
  return tid;
74
}
82
}
 Lines 78-83    Link Here 
78
    m_cwMin (0),
86
    m_cwMin (0),
79
    m_cwMax (0),
87
    m_cwMax (0),
80
    m_cw (0),
88
    m_cw (0),
89
    m_backoff (0),
81
    m_accessRequested (false),
90
    m_accessRequested (false),
82
    m_backoffSlots (0),
91
    m_backoffSlots (0),
83
    m_backoffStart (Seconds (0.0)),
92
    m_backoffStart (Seconds (0.0)),
 Lines 180-185    Link Here 
180
  if (changed == true)
189
  if (changed == true)
181
    {
190
    {
182
      ResetCw ();
191
      ResetCw ();
192
      m_cwTrace = GetCw ();
183
    }
193
    }
184
}
194
}
185
195
 Lines 192-197    Link Here 
192
  if (changed == true)
202
  if (changed == true)
193
    {
203
    {
194
      ResetCw ();
204
      ResetCw ();
205
      m_cwTrace = GetCw ();
195
    }
206
    }
196
}
207
}
197
208
 Lines 346-352    Link Here 
346
{
357
{
347
  NS_LOG_FUNCTION (this);
358
  NS_LOG_FUNCTION (this);
348
  ResetCw ();
359
  ResetCw ();
349
  StartBackoffNow (m_rng->GetInteger (0, GetCw ()));
360
  m_cwTrace = GetCw ();
361
  m_backoff = m_rng->GetInteger (0, GetCw ());
362
  m_backoffTrace (m_backoff);
363
  StartBackoffNow (m_backoff);
350
}
364
}
351
365
352
bool
366
bool
 Lines 519-525    Link Here 
519
Txop::NotifyCollision (void)
533
Txop::NotifyCollision (void)
520
{
534
{
521
  NS_LOG_FUNCTION (this);
535
  NS_LOG_FUNCTION (this);
522
  StartBackoffNow (m_rng->GetInteger (0, GetCw ()));
536
  m_backoff = m_rng->GetInteger (0, GetCw ());
537
  m_backoffTrace (m_backoff);
538
  StartBackoffNow (m_backoff);
523
  RestartAccessIfNeeded ();
539
  RestartAccessIfNeeded ();
524
}
540
}
525
541
 Lines 580-591    Link Here 
580
      //to reset the dcf.
596
      //to reset the dcf.
581
      m_currentPacket = 0;
597
      m_currentPacket = 0;
582
      ResetCw ();
598
      ResetCw ();
599
      m_cwTrace = GetCw ();
583
    }
600
    }
584
  else
601
  else
585
    {
602
    {
586
      UpdateFailedCw ();
603
      UpdateFailedCw ();
604
      m_cwTrace = GetCw ();
587
    }
605
    }
588
  StartBackoffNow (m_rng->GetInteger (0, GetCw ()));
606
  m_backoff = m_rng->GetInteger (0, GetCw ());
607
  m_backoffTrace (m_backoff);
608
  StartBackoffNow (m_backoff);
589
  RestartAccessIfNeeded ();
609
  RestartAccessIfNeeded ();
590
}
610
}
591
611
 Lines 607-613    Link Here 
607
       */
627
       */
608
      m_currentPacket = 0;
628
      m_currentPacket = 0;
609
      ResetCw ();
629
      ResetCw ();
610
      StartBackoffNow (m_rng->GetInteger (0, GetCw ()));
630
      m_cwTrace = GetCw ();
631
      m_backoff = m_rng->GetInteger (0, GetCw ());
632
      m_backoffTrace (m_backoff);
633
      StartBackoffNow (m_backoff);
611
      RestartAccessIfNeeded ();
634
      RestartAccessIfNeeded ();
612
    }
635
    }
613
  else
636
  else
 Lines 633-646    Link Here 
633
      //to reset the dcf.
656
      //to reset the dcf.
634
      m_currentPacket = 0;
657
      m_currentPacket = 0;
635
      ResetCw ();
658
      ResetCw ();
659
      m_cwTrace = GetCw ();
636
    }
660
    }
637
  else
661
  else
638
    {
662
    {
639
      NS_LOG_DEBUG ("Retransmit");
663
      NS_LOG_DEBUG ("Retransmit");
640
      m_currentHdr.SetRetry ();
664
      m_currentHdr.SetRetry ();
641
      UpdateFailedCw ();
665
      UpdateFailedCw ();
666
      m_cwTrace = GetCw ();
642
    }
667
    }
643
  StartBackoffNow (m_rng->GetInteger (0, GetCw ()));
668
  m_backoff = m_rng->GetInteger (0, GetCw ());
669
  m_backoffTrace (m_backoff);
670
  StartBackoffNow (m_backoff);
644
  RestartAccessIfNeeded ();
671
  RestartAccessIfNeeded ();
645
}
672
}
646
673
 Lines 720-726    Link Here 
720
  NS_LOG_DEBUG ("a transmission that did not require an ACK just finished");
747
  NS_LOG_DEBUG ("a transmission that did not require an ACK just finished");
721
  m_currentPacket = 0;
748
  m_currentPacket = 0;
722
  ResetCw ();
749
  ResetCw ();
723
  StartBackoffNow (m_rng->GetInteger (0, GetCw ()));
750
  m_cwTrace = GetCw ();
751
  m_backoff = m_rng->GetInteger (0, GetCw ());
752
  m_backoffTrace (m_backoff);
753
  StartBackoffNow (m_backoff);
724
  if (!m_txOkCallback.IsNull ())
754
  if (!m_txOkCallback.IsNull ())
725
    {
755
    {
726
      m_txOkCallback (m_currentHdr);
756
      m_txOkCallback (m_currentHdr);
(-)a/src/wifi/model/txop.h (+4 lines)
 Lines 21-26    Link Here 
21
#ifndef TXOP_H
21
#ifndef TXOP_H
22
#define TXOP_H
22
#define TXOP_H
23
23
24
#include "ns3/traced-value.h"
24
#include "mac-low-transmission-parameters.h"
25
#include "mac-low-transmission-parameters.h"
25
#include "wifi-mac-header.h"
26
#include "wifi-mac-header.h"
26
27
 Lines 506-511    Link Here 
506
  uint32_t m_cwMin;       //!< the CW minimum
507
  uint32_t m_cwMin;       //!< the CW minimum
507
  uint32_t m_cwMax;       //!< the CW maximum
508
  uint32_t m_cwMax;       //!< the CW maximum
508
  uint32_t m_cw;          //!< the current CW
509
  uint32_t m_cw;          //!< the current CW
510
  uint32_t m_backoff;     //!< the current backoff
509
  bool m_accessRequested; //!< flag whether channel access is already requested
511
  bool m_accessRequested; //!< flag whether channel access is already requested
510
  uint32_t m_backoffSlots; //!< the backoff slots
512
  uint32_t m_backoffSlots; //!< the backoff slots
511
  /**
513
  /**
 Lines 522-527    Link Here 
522
  WifiMacHeader m_currentHdr; //!< the current header
524
  WifiMacHeader m_currentHdr; //!< the current header
523
  MacLowTransmissionParameters m_currentParams; ///< current transmission parameters
525
  MacLowTransmissionParameters m_currentParams; ///< current transmission parameters
524
  uint8_t m_fragmentNumber; //!< the fragment number
526
  uint8_t m_fragmentNumber; //!< the fragment number
527
  TracedCallback<uint32_t> m_backoffTrace;   //!< backoff trace value
528
  TracedValue<uint32_t> m_cwTrace;        //!< CW trace value
525
};
529
};
526
530
527
} //namespace ns3
531
} //namespace ns3

Return to bug 2986