@@ -76,10 +76,6 @@ class TxopTest : public TxopType
76
76
void NotifyChannelAccessed (uint8_t linkId, Time txopDuration = Seconds(0 )) override ;
77
77
// / @copydoc ns3::Txop::HasFramesToTransmit
78
78
bool HasFramesToTransmit (uint8_t linkId) override ;
79
- // / @copydoc ns3::Txop::NotifySleep
80
- void NotifySleep (uint8_t linkId) override ;
81
- // / @copydoc ns3::Txop::NotifyWakeUp
82
- void NotifyWakeUp (uint8_t linkId) override ;
83
79
// / @copydoc ns3::Txop::GenerateBackoff
84
80
void GenerateBackoff (uint8_t linkId) override ;
85
81
@@ -117,8 +113,18 @@ class TxopTest : public TxopType
117
113
class ChannelAccessManagerStub : public ChannelAccessManager
118
114
{
119
115
public:
120
- ChannelAccessManagerStub ()
116
+ /* *
117
+ * @brief Get the type ID.
118
+ * @return the object TypeId
119
+ */
120
+ static TypeId GetTypeId ()
121
121
{
122
+ static TypeId tid = TypeId (" ns3::ChannelAccessManagerStub" )
123
+ .SetParent <ns3::ChannelAccessManager>()
124
+ .SetGroupName (" Wifi" )
125
+ .AddConstructor <ChannelAccessManagerStub>()
126
+ .HideFromDocumentation ();
127
+ return tid;
122
128
}
123
129
124
130
/* *
@@ -240,6 +246,7 @@ class ChannelAccessManagerTest : public TestCase
240
246
uint64_t eifsNoDifsNoSifs{10 }; // /< the EIFS no DIFS no SIFS in microseconds
241
247
uint32_t ackTimeoutValue{20 }; // /< the Ack timeout value in microseconds
242
248
MHz_u chWidth{20 }; // /< the channel width
249
+ uint64_t resetBackoffThr{}; // /< reset backoff threshold
243
250
};
244
251
245
252
ChannelAccessManagerTest ();
@@ -420,10 +427,9 @@ class ChannelAccessManagerTest : public TestCase
420
427
*
421
428
* @param at the event time
422
429
* @param duration the duration of the interval during which no PHY is connected
423
- * @param threshold the value for the ResetBackoffThreshold attribute
424
430
* @param from the index of the Txop that has to request channel access when PHY is reconnected
425
431
*/
426
- void AddPhyDisconnectEvt (uint64_t at, uint64_t duration, uint64_t threshold, uint32_t from);
432
+ void AddPhyDisconnectEvt (uint64_t at, uint64_t duration, uint32_t from);
427
433
428
434
/* *
429
435
* Add a PHY reconnect event consisting in another PHY operating on the link for the given time.
@@ -433,6 +439,22 @@ class ChannelAccessManagerTest : public TestCase
433
439
*/
434
440
void AddPhyReconnectEvt (uint64_t at, uint64_t duration);
435
441
442
+ /* *
443
+ * Add PHY sleep/resume events.
444
+ *
445
+ * @param at the event time
446
+ * @param duration the duration of the interval during which the PHY is in sleep state
447
+ */
448
+ void AddPhySleepEvt (uint64_t at, uint64_t duration);
449
+
450
+ /* *
451
+ * Add PHY off/on events.
452
+ *
453
+ * @param at the event time
454
+ * @param duration the duration of the interval during which the PHY is in off state
455
+ */
456
+ void AddPhyOffEvt (uint64_t at, uint64_t duration);
457
+
436
458
typedef std::vector<Ptr<TxopTest<TxopType>>> TxopTests; // !< the TXOP tests typedef
437
459
438
460
Ptr<FrameExchangeManagerStub<TxopType>> m_feManager; // !< the Frame Exchange Manager stubbed
@@ -486,18 +508,6 @@ TxopTest<TxopType>::HasFramesToTransmit(uint8_t linkId)
486
508
return !m_expectedGrants.empty ();
487
509
}
488
510
489
- template <typename TxopType>
490
- void
491
- TxopTest<TxopType>::NotifySleep(uint8_t linkId)
492
- {
493
- }
494
-
495
- template <typename TxopType>
496
- void
497
- TxopTest<TxopType>::NotifyWakeUp(uint8_t linkId)
498
- {
499
- }
500
-
501
511
template <typename TxopType>
502
512
ChannelAccessManagerTest<TxopType>::ChannelAccessManagerTest()
503
513
: TestCase(" ChannelAccessManager" )
@@ -632,7 +642,9 @@ template <typename TxopType>
632
642
void
633
643
ChannelAccessManagerTest<TxopType>::StartTest(const Params& params)
634
644
{
635
- m_ChannelAccessManager = CreateObject<ChannelAccessManagerStub>();
645
+ m_ChannelAccessManager = CreateObjectWithAttributes<ChannelAccessManagerStub>(
646
+ " ResetBackoffThreshold" ,
647
+ TimeValue (MicroSeconds (params.resetBackoffThr )));
636
648
m_feManager = CreateObject<FrameExchangeManagerStub<TxopType>>(this );
637
649
m_ChannelAccessManager->SetupFrameExchangeManager (m_feManager);
638
650
m_ChannelAccessManager->SetSlot (MicroSeconds (params.slotTime ));
@@ -662,7 +674,8 @@ ChannelAccessManagerTest<TxopType>::AddTxop(uint32_t aifsn)
662
674
auto mac = CreateObjectWithAttributes<AdhocWifiMac>(
663
675
" Txop" ,
664
676
PointerValue (CreateObjectWithAttributes<Txop>(" AcIndex" , StringValue (" AC_BE_NQOS" ))));
665
- mac->SetWifiPhys ({nullptr });
677
+ mac->SetWifiPhys ({m_phy});
678
+ mac->SetChannelAccessManagers ({m_ChannelAccessManager});
666
679
txop->SetWifiMac (mac);
667
680
txop->SetAifsn (aifsn);
668
681
}
@@ -908,11 +921,10 @@ template <typename TxopType>
908
921
void
909
922
ChannelAccessManagerTest<TxopType>::AddPhyDisconnectEvt (uint64_t at,
910
923
uint64_t duration,
911
- uint64_t threshold,
912
924
uint32_t from)
913
925
{
914
- m_ChannelAccessManager-> SetAttribute ( " ResetBackoffThreshold " ,
915
- TimeValue ( MicroSeconds ( threshold)) );
926
+ TimeValue threshold;
927
+ m_ChannelAccessManager-> GetAttribute ( " ResetBackoffThreshold " , threshold);
916
928
917
929
Simulator::Schedule (MicroSeconds (at) - Now (),
918
930
&ChannelAccessManager::RemovePhyListener,
@@ -923,7 +935,7 @@ ChannelAccessManagerTest<TxopType>::AddPhyDisconnectEvt(uint64_t at,
923
935
auto txop = m_txop[from];
924
936
auto hadFramesToTransmit = txop->HasFramesToTransmit (SINGLE_LINK_OP_ID);
925
937
m_ChannelAccessManager->SetupPhyListener (m_phy);
926
- if (duration > threshold)
938
+ if (MicroSeconds ( duration) > threshold. Get () )
927
939
{
928
940
// request channel access again because all backoffs have been reset
929
941
if (m_ChannelAccessManager->NeedBackoffUponAccess (txop, hadFramesToTransmit, true ))
@@ -958,6 +970,22 @@ ChannelAccessManagerTest<TxopType>::AddPhyReconnectEvt(uint64_t at, uint64_t dur
958
970
});
959
971
}
960
972
973
+ template <typename TxopType>
974
+ void
975
+ ChannelAccessManagerTest<TxopType>::AddPhySleepEvt (uint64_t at, uint64_t duration)
976
+ {
977
+ Simulator::Schedule (MicroSeconds (at) - Now (), &WifiPhy::SetSleepMode, m_phy, false );
978
+ Simulator::Schedule (MicroSeconds (at + duration) - Now (), &WifiPhy::ResumeFromSleep, m_phy);
979
+ }
980
+
981
+ template <typename TxopType>
982
+ void
983
+ ChannelAccessManagerTest<TxopType>::AddPhyOffEvt (uint64_t at, uint64_t duration)
984
+ {
985
+ Simulator::Schedule (MicroSeconds (at) - Now (), &WifiPhy::SetOffMode, m_phy);
986
+ Simulator::Schedule (MicroSeconds (at + duration) - Now (), &WifiPhy::ResumeFromOff, m_phy);
987
+ }
988
+
961
989
/*
962
990
* Specialization of DoRun () method for DCF
963
991
*/
@@ -1489,12 +1517,12 @@ ChannelAccessManagerTest<QosTxop>::DoRun()
1489
1517
// | | |
1490
1518
// 30 request access. decrement reset
1491
1519
// backoff slots: 3 slots: 2 backoff
1492
- StartTest ({.slotTime = 4 , .sifs = 6 });
1520
+ StartTest ({.slotTime = 4 , .sifs = 6 , . resetBackoffThr = 5 });
1493
1521
AddTxop (1 );
1494
1522
AddRxOkEvt (20 , 30 );
1495
1523
AddAccessRequest (30 , 20 , 81 , 0 );
1496
1524
ExpectBackoff (30 , 3 , 0 );
1497
- AddPhyDisconnectEvt (61 , 10 , 0 , 0 );
1525
+ AddPhyDisconnectEvt (61 , 10 , 0 );
1498
1526
EndTest ();
1499
1527
1500
1528
// Check backoff freeze while no PHY operates on a link for less than the threshold.
@@ -1503,12 +1531,12 @@ ChannelAccessManagerTest<QosTxop>::DoRun()
1503
1531
// | | | | |
1504
1532
// 30 request access. decrement resume decrement decrement
1505
1533
// backoff slots: 3 slots: 2 backoff slots: 1 slots: 0
1506
- StartTest ({.slotTime = 4 , .sifs = 6 });
1534
+ StartTest ({.slotTime = 4 , .sifs = 6 , . resetBackoffThr = 20 });
1507
1535
AddTxop (1 );
1508
1536
AddRxOkEvt (20 , 30 );
1509
1537
AddAccessRequest (30 , 20 , 89 , 0 );
1510
1538
ExpectBackoff (30 , 3 , 0 );
1511
- AddPhyDisconnectEvt (61 , 10 , 20 , 0 );
1539
+ AddPhyDisconnectEvt (61 , 10 , 0 );
1512
1540
EndTest ();
1513
1541
1514
1542
// Check backoff left unmodified when previous PHY is reconnected to the link
@@ -1525,6 +1553,66 @@ ChannelAccessManagerTest<QosTxop>::DoRun()
1525
1553
ExpectBackoff (30 , 4 , 0 );
1526
1554
AddPhyReconnectEvt (61 , 10 );
1527
1555
EndTest ();
1556
+
1557
+ // Check reset of backoff and generation of new backoff value after that PHY is put to sleep for
1558
+ // more than the threshold.
1559
+ // 20 50 56 60 63 73 79 83 87 91 95 115
1560
+ // | rx | sifs | aifsn | idle | phy sleep | sifs | aifsn | idle | idle | idle | tx |
1561
+ // | | | | | |
1562
+ // 30 request access. decrement reset backoff decrement decrement decrement
1563
+ // backoff slots: 3 slots: 2 backoff slots: 3 slots: 2 slots: 1 slots: 0
1564
+ StartTest ({.slotTime = 4 , .sifs = 6 , .resetBackoffThr = 5 });
1565
+ AddTxop (1 );
1566
+ AddRxOkEvt (20 , 30 );
1567
+ AddAccessRequest (30 , 20 , 95 , 0 );
1568
+ ExpectBackoff (30 , 3 , 0 );
1569
+ AddPhySleepEvt (63 , 10 );
1570
+ ExpectBackoff (73 , 3 , 0 );
1571
+ EndTest ();
1572
+
1573
+ // Check backoff freeze while PHY is put to sleep for less than the threshold.
1574
+ // 20 50 56 60 61 71 77 81 85 89 109
1575
+ // | rx | sifs | aifsn | idle | phy sleep | sifs | aifsn | idle | idle | tx |
1576
+ // | | | | |
1577
+ // 30 request access. decrement resume decrement decrement
1578
+ // backoff slots: 3 slots: 2 backoff slots: 1 slots: 0
1579
+ StartTest ({.slotTime = 4 , .sifs = 6 , .resetBackoffThr = 20 });
1580
+ AddTxop (1 );
1581
+ AddRxOkEvt (20 , 30 );
1582
+ AddAccessRequest (30 , 20 , 89 , 0 );
1583
+ ExpectBackoff (30 , 3 , 0 );
1584
+ AddPhySleepEvt (61 , 10 );
1585
+ EndTest ();
1586
+
1587
+ // Check reset of backoff and generation of new backoff value after that PHY is put to off for
1588
+ // more than the threshold.
1589
+ // 20 50 56 60 61 71 77 81 85 89 93 113
1590
+ // | rx | sifs | aifsn | idle | phy off | sifs | aifsn | idle | idle | idle | tx |
1591
+ // | | | | | |
1592
+ // 30 request access. decrement reset backoff decrement decrement decrement
1593
+ // backoff slots: 3 slots: 2 backoff slots: 3 slots: 2 slots: 1 slots: 0
1594
+ StartTest ({.slotTime = 4 , .sifs = 6 , .resetBackoffThr = 5 });
1595
+ AddTxop (1 );
1596
+ AddRxOkEvt (20 , 30 );
1597
+ AddAccessRequest (30 , 20 , 93 , 0 );
1598
+ ExpectBackoff (30 , 3 , 0 );
1599
+ AddPhyOffEvt (61 , 10 );
1600
+ ExpectBackoff (71 , 3 , 0 );
1601
+ EndTest ();
1602
+
1603
+ // Check backoff freeze while PHY is put to off for less than the threshold.
1604
+ // 20 50 56 60 63 73 79 83 87 91 111
1605
+ // | rx | sifs | aifsn | idle | phy off | sifs | aifsn | idle | idle | tx |
1606
+ // | | | | |
1607
+ // 30 request access. decrement resume decrement decrement
1608
+ // backoff slots: 3 slots: 2 backoff slots: 1 slots: 0
1609
+ StartTest ({.slotTime = 4 , .sifs = 6 , .resetBackoffThr = 20 });
1610
+ AddTxop (1 );
1611
+ AddRxOkEvt (20 , 30 );
1612
+ AddAccessRequest (30 , 20 , 91 , 0 );
1613
+ ExpectBackoff (30 , 3 , 0 );
1614
+ AddPhyOffEvt (63 , 10 );
1615
+ EndTest ();
1528
1616
}
1529
1617
1530
1618
/* *
0 commit comments