9#include "ns3/adhoc-wifi-mac.h"
10#include "ns3/ap-wifi-mac.h"
11#include "ns3/channel-access-manager.h"
12#include "ns3/config.h"
13#include "ns3/frame-exchange-manager.h"
14#include "ns3/interference-helper.h"
15#include "ns3/mgt-action-headers.h"
16#include "ns3/mobility-helper.h"
17#include "ns3/multi-model-spectrum-channel.h"
18#include "ns3/packet-socket-client.h"
19#include "ns3/packet-socket-helper.h"
20#include "ns3/packet-socket-server.h"
21#include "ns3/pointer.h"
22#include "ns3/qos-txop.h"
23#include "ns3/rng-seed-manager.h"
24#include "ns3/simulator.h"
25#include "ns3/spectrum-wifi-helper.h"
26#include "ns3/spectrum-wifi-phy.h"
27#include "ns3/sta-wifi-mac.h"
28#include "ns3/string.h"
30#include "ns3/wifi-net-device.h"
31#include "ns3/wifi-spectrum-phy-interface.h"
41template <
typename TxopType>
50template <
typename TxopType>
67 void QueueTx(uint64_t txTime, uint64_t expectedGrantTime);
181template <
typename TxopType>
205 dcf->NotifyChannelAccessed(0);
218 m_test->NotifyChannelSwitching();
231template <
typename TxopType>
269 uint64_t eifsNoDifsNoSifs,
309 void AddRxOkEvt(uint64_t at, uint64_t duration);
322 void AddRxErrorEvt(uint64_t at, uint64_t duration, uint64_t timeUntilError);
334 void AddTxEvt(uint64_t at, uint64_t duration);
369 uint64_t expectedGrantTime,
381 uint64_t expectedGrantTime,
391 uint64_t expectedGrantTime,
403 const std::vector<Time>& per20MhzDurations = {});
445template <
typename TxopType>
449 m_expectedGrants.emplace_back(txTime, expectedGrantTime);
452template <
typename TxopType>
459template <
typename TxopType>
464 TxopType::DoDispose();
467template <
typename TxopType>
472 m_test->NotifyAccessGranted(m_i);
475template <
typename TxopType>
479 m_test->GenerateBackoff(m_i);
482template <
typename TxopType>
486 return !m_expectedGrants.empty();
489template <
typename TxopType>
495template <
typename TxopType>
501template <
typename TxopType>
507template <
typename TxopType>
513 if (!state->m_expectedGrants.empty())
515 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front();
516 state->m_expectedGrants.pop_front();
519 "Expected access grant is now");
520 m_ChannelAccessManager->NotifyTxStartNow(
MicroSeconds(expected.first));
521 m_ChannelAccessManager->NotifyAckTimeoutStartNow(
526template <
typename TxopType>
532 m_ChannelAccessManager,
536template <
typename TxopType>
542 "Have expected internal collisions");
543 if (!state->m_expectedInternalCollision.empty())
549 MicroSeconds(expected.at),
550 "Expected internal collision time is now");
551 state->StartBackoffNow(expected.nSlots, 0);
555template <typename TxopType>
561 if (!state->m_expectedBackoff.empty())
566 MicroSeconds(expected.at),
567 "Expected backoff is now");
568 state->StartBackoffNow(expected.nSlots, 0);
572template <typename TxopType>
576 for (
auto& state : m_txop)
578 if (!state->m_expectedGrants.empty())
580 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front();
581 state->m_expectedGrants.pop_front();
584 "Expected grant is now");
590template <
typename TxopType>
603template <typename TxopType>
610 backoff.nSlots = nSlots;
614template <typename TxopType>
624template <
typename TxopType>
631template <
typename TxopType>
635 uint64_t eifsNoDifsNoSifs,
641 m_ChannelAccessManager->SetupFrameExchangeManager(m_feManager);
642 m_ChannelAccessManager->SetSlot(
MicroSeconds(slotTime));
644 m_ChannelAccessManager->SetEifsNoDifs(
MicroSeconds(eifsNoDifsNoSifs + sifs));
645 m_ackTimeoutValue = ackTimeoutValue;
655 m_ChannelAccessManager->SetupPhyListener(m_phy);
658template <
typename TxopType>
663 m_txop.push_back(txop);
664 m_ChannelAccessManager->Add(txop);
669 mac->SetWifiPhys({
nullptr});
670 txop->SetWifiMac(mac);
671 txop->SetAifsn(aifsn);
674template <
typename TxopType>
680 m_ChannelAccessManager->RemovePhyListener(m_phy);
682 m_ChannelAccessManager->Dispose();
683 m_ChannelAccessManager =
nullptr;
684 m_feManager =
nullptr;
686 for (
auto i = m_txop.begin(); i != m_txop.end(); i++)
692 "Have no internal collisions");
702template <
typename TxopType>
708 m_ChannelAccessManager,
712 m_ChannelAccessManager);
715template <
typename TxopType>
721 m_ChannelAccessManager,
725template <
typename TxopType>
731 m_ChannelAccessManager,
735 m_ChannelAccessManager,
752template <
typename TxopType>
756 uint64_t timeUntilError)
760 m_ChannelAccessManager,
764 m_ChannelAccessManager,
781 m_ChannelAccessManager,
784 std::vector<Time>{});
787template <
typename TxopType>
793 m_ChannelAccessManager,
797template <
typename TxopType>
803 m_ChannelAccessManager,
807template <
typename TxopType>
813 m_ChannelAccessManager);
816template <
typename TxopType>
820 uint64_t expectedGrantTime,
823 AddAccessRequestWithSuccessfulAck(at, txTime, expectedGrantTime, 0, from);
826template <
typename TxopType>
830 uint64_t expectedGrantTime,
841template <
typename TxopType>
845 uint64_t expectedGrantTime,
856 AddAckTimeoutReset(expectedGrantTime + txTime + ackDelay);
859template <
typename TxopType>
862 uint64_t expectedGrantTime,
866 state->QueueTx(txTime, expectedGrantTime);
867 if (m_ChannelAccessManager->NeedBackoffUponAccess(state, hadFramesToTransmit,
true))
869 state->GenerateBackoff(0);
871 m_ChannelAccessManager->RequestAccess(state);
874template <
typename TxopType>
879 const std::vector<Time>& per20MhzDurations)
883 m_ChannelAccessManager,
889template <
typename TxopType>
895 m_ChannelAccessManager,
900template <
typename TxopType>
906 m_ChannelAccessManager,
910template <
typename TxopType>
917 m_ChannelAccessManager->SetAttribute(
"ResetBackoffThreshold",
922 m_ChannelAccessManager,
926 auto txop = m_txop[from];
928 m_ChannelAccessManager->SetupPhyListener(m_phy);
929 if (duration > threshold)
932 if (m_ChannelAccessManager->NeedBackoffUponAccess(txop, hadFramesToTransmit,
true))
934 txop->GenerateBackoff(0);
936 m_ChannelAccessManager->RequestAccess(txop);
941template <
typename TxopType>
949 newPhy->SetOperatingChannel(m_phy->GetOperatingChannel());
952 m_ChannelAccessManager->SetupPhyListener(newPhy);
956 m_ChannelAccessManager->RemovePhyListener(newPhy);
958 m_ChannelAccessManager->SetupPhyListener(m_phy);
977 AddAccessRequest(1, 1, 5, 0);
978 AddAccessRequest(8, 2, 12, 0);
989 AddAccessRequest(1, 1, 5, 0);
990 AddRxInsideSifsEvt(7, 10);
992 AddAccessRequest(14, 2, 18, 0);
1006 StartTest(4, 6, 10);
1010 AddAccessRequest(30, 2, 118, 0);
1011 ExpectBackoff(30, 4, 0);
1020 StartTest(4, 6, 10);
1023 AddAccessRequest(30, 2, 70, 0);
1024 ExpectBackoff(30, 0, 0);
1033 StartTest(4, 6, 10);
1037 AddAccessRequest(30, 2, 110, 0);
1038 ExpectBackoff(30, 0, 0);
1046 StartTest(4, 6, 10);
1049 AddAccessRequest(62, 2, 72, 0);
1057 StartTest(4, 6, 10);
1060 AddAccessRequest(70, 2, 80, 0);
1069 StartTest(4, 6, 10);
1071 AddRxErrorEvt(20, 40);
1072 AddAccessRequest(30, 2, 102, 0);
1073 ExpectBackoff(30, 4, 0);
1083 StartTest(4, 6, 10);
1085 AddRxErrorEvt(20, 40);
1086 AddAccessRequest(70, 2, 86, 0);
1095 StartTest(4, 6, 10);
1097 AddRxErrorEvt(20, 40, 20);
1098 ExpectBusy(41,
true);
1099 ExpectBusy(59,
true);
1100 ExpectBusy(61,
false);
1109 StartTest(4, 6, 10);
1111 AddRxErrorEvt(20, 40);
1112 AddAccessRequest(30, 2, 101, 0);
1113 ExpectBackoff(30, 4, 0);
1126 StartTest(4, 6, 10);
1130 AddAccessRequest(30, 10, 78, 0);
1131 ExpectBackoff(30, 2, 0);
1132 AddAccessRequest(40, 2, 110, 1);
1133 ExpectBackoff(40, 0, 1);
1134 ExpectInternalCollision(78, 1, 1);
1144 StartTest(4, 6, 10);
1147 AddAccessRequestWithAckTimeout(20, 20, 34, 1);
1148 AddAccessRequest(64, 10, 80, 0);
1160 StartTest(4, 6, 10);
1163 AddAccessRequestWithSuccessfulAck(20, 20, 34, 2, 1);
1164 AddAccessRequest(55, 10, 62, 0);
1171 StartTest(4, 6, 10);
1173 AddAccessRequest(20, 20, 34, 0);
1175 AddAccessRequest(61, 10, 80, 0);
1176 ExpectBackoff(61, 1, 0);
1182 StartTest(4, 6, 10);
1185 AddNavStart(60, 15);
1188 AddAccessRequest(30, 10, 93, 0);
1189 ExpectBackoff(30, 2, 0);
1195 StartTest(4, 6, 10);
1198 AddNavStart(60, 15);
1201 AddAccessRequest(30, 10, 91, 0);
1202 ExpectBackoff(30, 2, 0);
1208 StartTest(4, 6, 10);
1211 AddAccessRequest(80, 10, 94, 0);
1214 StartTest(4, 6, 10);
1218 AddAccessRequest(30, 50, 108, 0);
1219 ExpectBackoff(30, 3, 0);
1227 StartTest(1, 3, 10);
1229 AddSwitchingEvt(0, 20);
1230 AddAccessRequest(21, 1, 25, 0);
1238 StartTest(1, 3, 10);
1240 AddSwitchingEvt(20, 20);
1241 AddCcaBusyEvt(30, 20);
1242 ExpectBackoff(45, 2, 0);
1243 AddAccessRequest(45, 1, 56, 0);
1250 StartTest(1, 3, 10);
1252 AddRxStartEvt(20, 40);
1253 AddSwitchingEvt(30, 20);
1254 AddAccessRequest(51, 1, 55, 0);
1261 StartTest(1, 3, 10);
1263 AddCcaBusyEvt(20, 40);
1264 AddSwitchingEvt(30, 20);
1265 AddAccessRequest(51, 1, 55, 0);
1272 StartTest(1, 3, 10);
1274 AddNavStart(20, 40);
1275 AddSwitchingEvt(30, 20);
1276 AddAccessRequest(51, 1, 55, 0);
1284 StartTest(1, 3, 10);
1286 AddAccessRequestWithAckTimeout(20, 20, 24, 0);
1287 AddAccessRequest(49, 1, 54, 0);
1288 AddSwitchingEvt(54, 5);
1289 AddAccessRequest(60, 1, 64, 0);
1297 StartTest(4, 6, 10);
1300 AddAccessRequest(30, 2, 80, 0);
1301 ExpectBackoff(30, 4, 0);
1302 AddSwitchingEvt(80, 20);
1303 AddAccessRequest(101, 2, 111, 0);
1321 StartTest(4, 6, 10, 20,
MHz_u{40});
1325 AddAccessRequest(52, 20, 60, 0);
1335 StartTest(4, 6, 10, 20,
MHz_u{80});
1339 AddAccessRequest(58, 20, 60, 0);
1349 StartTest(4, 6, 10, 20,
MHz_u{80});
1353 AddAccessRequest(62, 20, 64, 0);
1364 StartTest(4, 6, 10, 20,
MHz_u{160});
1366 AddRxErrorEvt(20, 30);
1368 AddAccessRequest(55, 20, 76, 0);
1379 StartTest(4, 6, 10, 20,
MHz_u{160});
1381 AddRxErrorEvt(20, 30);
1383 AddAccessRequest(70, 20, 76, 0);
1394 StartTest(4, 6, 10, 20,
MHz_u{160});
1396 AddRxErrorEvt(20, 30);
1398 AddAccessRequest(82, 20, 84, 0);
1407 StartTest(4, 6, 10);
1410 AddAccessRequest(30, 20, 76, 0);
1411 ExpectBackoff(30, 4, 0);
1420 StartTest(4, 6, 10);
1425 AddAccessRequest(30, 20, 107, 0);
1426 ExpectBackoff(30, 3, 0);
1435 StartTest(4, 6, 10);
1438 AddAccessRequest(30, 20, 81, 0);
1439 ExpectBackoff(30, 3, 0);
1440 AddPhyDisconnectEvt(61, 10, 0, 0);
1449 StartTest(4, 6, 10);
1452 AddAccessRequest(30, 20, 89, 0);
1453 ExpectBackoff(30, 3, 0);
1454 AddPhyDisconnectEvt(61, 10, 20, 0);
1464 StartTest(4, 6, 10);
1467 AddAccessRequest(30, 20, 76, 0);
1468 ExpectBackoff(30, 4, 0);
1469 AddPhyReconnectEvt(61, 10);
1492 void DoRun()
override;
1507 :
TestCase(
"Check calculation of the largest idle primary channel")
1548 const auto idleWidth = (busyChannel == WifiChannelListType::WIFI_CHANLIST_PRIMARY)
1550 : ((1 << (busyChannel - 1)) *
MHz_u{20});
1552 Time checkTime1 = start + ccaBusyStartDelay + ccaBusyDuration / 2;
1554 Time interval1 = (ccaBusyStartDelay + ccaBusyDuration) / 2;
1557 "Incorrect width of the idle channel in an interval "
1558 <<
"ending within CCA_BUSY (channel width: " << chWidth
1559 <<
" MHz, busy channel: " << busyChannel <<
")");
1565 Time checkTime2 = start + ccaBusyStartDelay + ccaBusyDuration + ccaBusyRxInterval / 2;
1567 Time interval2 = (ccaBusyDuration + ccaBusyRxInterval) / 2;
1570 "Incorrect width of the idle channel in an interval "
1571 <<
"starting within CCA_BUSY (channel width: " << chWidth
1572 <<
" MHz, busy channel: " << busyChannel <<
")");
1584 Time checkTime3 = start + ccaBusyStartDelay + ccaBusyDuration + ccaBusyRxInterval + rxDuration;
1586 Time interval3 = ccaBusyDuration / 2 + ccaBusyRxInterval;
1587 Time end3 = checkTime3 - rxDuration;
1590 "Incorrect width of the idle channel in an interval "
1591 <<
"preceding RX start and overlapping CCA_BUSY "
1592 <<
"(channel width: " << chWidth
1593 <<
" MHz, busy channel: " << busyChannel <<
")");
1598 const Time& checkTime4 = checkTime3;
1600 const Time& interval4 = ccaBusyRxInterval;
1601 Time end4 = checkTime4 - rxDuration;
1604 "Incorrect width of the idle channel in the interval "
1605 <<
"following CCA_BUSY and preceding RX start (channel "
1606 <<
"width: " << chWidth <<
" MHz, busy channel: " << busyChannel
1613 Time checkTime5 = checkTime4 + interval5;
1617 "Incorrect width of the idle channel in an interval "
1618 <<
"following RX end (channel width: " << chWidth
1619 <<
" MHz, busy channel: " << busyChannel <<
")");
1623 const Time& checkTime6 = checkTime5;
1625 Time interval6 = interval5 + rxDuration / 2;
1628 "Incorrect width of the idle channel in an interval "
1629 <<
"overlapping RX (channel width: " << chWidth
1630 <<
" MHz, busy channel: " << busyChannel <<
")");
1639 uint8_t channel = 0;
1640 std::list<WifiChannelListType> busyChannels;
1646 for (
const auto busyChannel : busyChannels)
1659 m_phy->SetOperatingChannel(
1666 RunOne(chWidth, busyChannel);
1739 void DoRun()
override;
1787 :
TestCase(
"Check attributes impacting the generation of backoff values"),
1788 m_generateBackoffIfTxopWithoutTx(type == GEN_BACKOFF_IF_TXOP_NO_TX),
1789 m_proactiveBackoff(type == PROACTIVE_BACKOFF)
1802 int64_t streamNumber = 10;
1814 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
1823 phyHelper.
Set(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
1827 mac.SetType(
"ns3::ApWifiMac",
1835 mac.SetType(
"ns3::StaWifiMac",
1848 ->TraceConnectWithoutContext(
"PhyTxPsduBegin",
1851 ->TraceConnectWithoutContext(
"PhyTxPsduBegin",
1855 m_apMac->GetQosTxop(
AC_VO)->TraceConnectWithoutContext(
1864 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1865 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
1868 mobility.SetPositionAllocator(positionAlloc);
1869 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
1870 mobility.Install(apNode);
1871 mobility.Install(staNode);
1876 packetSocket.
Install(staNode);
1884 server->SetLocal(srvAddr);
1885 server->SetStartTime(
Seconds(0));
1886 server->SetStopTime(
Seconds(1));
1887 staNode->AddApplication(server);
1906 m_apMac->GetMacQueueScheduler()->BlockQueues(WifiQueueBlockedReason::TID_NOT_MAPPED,
1912 {SINGLE_LINK_OP_ID});
1923 "Unexpected total number of generated backoff values");
1936 for (
const auto& [aid, psdu] : psduMap)
1938 std::stringstream ss;
1939 ss << std::setprecision(10) << psdu->GetHeader(0).GetTypeString();
1940 if (psdu->GetHeader(0).IsAction())
1944 psdu->GetPayload(0)->PeekHeader(actionHdr);
1945 actionHdr.
Print(ss);
1947 ss <<
" #MPDUs " << psdu->GetNMpdus() <<
" duration/ID " << psdu->GetHeader(0).GetDuration()
1948 <<
" RA = " << psdu->GetAddr1() <<
" TA = " << psdu->GetAddr2()
1949 <<
" ADDR3 = " << psdu->GetHeader(0).GetAddr3()
1950 <<
" ToDS = " << psdu->GetHeader(0).IsToDs()
1951 <<
" FromDS = " << psdu->GetHeader(0).IsFromDs();
1952 if (psdu->GetHeader(0).IsAssocReq())
1957 else if (psdu->GetHeader(0).IsAck())
1966 m_apMac->GetDevice()->GetNode(),
1970 else if (psdu->GetHeader(0).IsQosData())
1975 ss << mpdu->GetHeader().GetSequenceNumber() <<
",";
1977 ss <<
"} TID = " << +psdu->GetHeader(0).GetQosTid();
1985 NS_LOG_INFO(
"TX duration = " << txDuration.As(
Time::MS) <<
" TXVECTOR = " << txVector <<
"\n");
1991 NS_LOG_INFO(
"Backoff value " << backoff <<
" generated by AP on link " << +linkId <<
" for "
1996 const std::size_t nValues = 5;
2003 "First backoff value should be generated at initialization time");
2011 "Second backoff value should be generated after association");
2018 "Second backoff value should be generated after AssocReq TX start time");
2021 "Second backoff value should be generated right after AssocReq "
2022 "PPDU payload starts");
2030 "Third backoff value should be generated after association");
2034 GenerateInterference();
2040 NS_TEST_EXPECT_MSG_EQ(m_nGenBackoff,
2042 "Unexpected number of generated backoff values");
2049 Simulator::Schedule(m_interferenceDuration, [=, this]() {
2050 auto voEdcaf = m_apMac->GetQosTxop(AC_VO);
2052 m_apMac->GetChannelAccessManager(linkId)->NeedBackoffUponAccess(voEdcaf,
2056 m_apMac->GetChannelAccessManager(linkId)->GetBackoffEndFor(voEdcaf) -
2057 Simulator::Now() + NanoSeconds(1);
2060 Simulator::Schedule(delay, [=, this]() {
2062 NS_TEST_EXPECT_MSG_EQ(m_nGenBackoff,
2064 "Unexpected number of generated backoff values");
2065 GenerateInterference();
2067 NS_TEST_EXPECT_MSG_EQ(m_nGenBackoff,
2069 "Unexpected number of generated backoff values");
2078 m_apMac->GetMacQueueScheduler()->UnblockQueues(WifiQueueBlockedReason::TID_NOT_MAPPED,
2081 m_staMac->GetAddress(),
2082 m_apMac->GetAddress(),
2088 if (m_generateBackoffIfTxopWithoutTx)
2094 if (m_nGenBackoff == 1)
2097 delay = m_apMac->GetWifiPhy(linkId)->GetSifs() +
2098 m_apMac->GetQosTxop(
AC_VO)->GetAifsn(linkId) *
2099 m_apMac->GetWifiPhy(linkId)->GetSlot();
2101 else if (m_nGenBackoff <= nValues)
2105 "Expected a timer to be running");
2108 "Backoff value generated too early");
2109 m_nextBackoffGen.Cancel();
2113 delay = m_apMac->GetWifiPhy(linkId)->GetSlot();
2116 if (m_nGenBackoff < nValues)
2119 delay += backoff * m_apMac->GetWifiPhy(linkId)->GetSlot();
2134 "Expected a new backoff value to be generated at time "
2148 spectrumSignalParams->txPhy = phy->GetCurrentInterface();
2149 spectrumSignalParams->txAntenna = phy->GetAntenna();
2150 spectrumSignalParams->psd = psd;
2152 phy->StartRx(spectrumSignalParams, phy->GetCurrentInterface());
2212 TestCase::Duration::QUICK);
2214 TestCase::Duration::QUICK);
static ChannelAccessManagerTestSuite g_camTestSuite
static TxopTestSuite g_dcfTestSuite
static QosTxopTestSuite g_edcaTestSuite
Test the GenerateBackoffIfTxopWithoutTx and ProactiveBackoff attributes of the ChannelAccessManager.
void Transmit(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when a FEM passes PSDUs to the PHY.
Ptr< StaWifiMac > m_staMac
MAC of the non-AP STA.
Ptr< ApWifiMac > m_apMac
AP wifi MAC.
std::size_t m_nGenBackoff
number of generated backoff values
void GenerateInterference()
Generate interference to make CCA busy.
Time m_assocReqStartTxTime
Association Request start TX time.
const Time m_interferenceDuration
interference duration
static constexpr uint8_t m_tid
TID of generated packet.
Ptr< PacketSocketClient > m_client
client to be installed on the AP after association
void MissedBackoff()
Indicate that a new backoff value has not been generated as expected.
EventId m_nextBackoffGen
timer elapsing when next backoff value is expected to be generated
void DoRun() override
Implementation to actually run this TestCase.
std::size_t m_nAcks
number of transmitted Ack frames
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void BackoffGenerated(AcIndex ac, uint32_t backoff, uint8_t linkId)
Callback invoked when a new backoff value is generated by the given AC on the station.
Time m_assocReqPpduHdrDuration
Association Request PPDU header TX duration.
bool m_generateBackoffIfTxopWithoutTx
whether the GenerateBackoffIfTxopWithoutTx attribute is set to true
std::size_t m_nExpectedGenBackoff
expected total number of generated backoff values
bool m_proactiveBackoff
whether the ProactiveBackoff attribute is set to true
BackoffGenerationTest(TestType type)
Constructor.
TestType
Tested attributes.
@ GEN_BACKOFF_IF_TXOP_NO_TX
ChannelAccessManager Stub.
ChannelAccessManagerStub()
Time GetEifsNoDifs() const override
Return the EIFS duration minus a DIFS.
void SetEifsNoDifs(Time eifsNoDifs)
Set the duration of EIFS - DIFS.
void SetSlot(Time slot)
Set the slot duration.
Time GetSlot() const override
Return the slot duration for this PHY.
Time m_sifs
SIFS duration.
Time GetSifs() const override
Return the Short Interframe Space (SIFS) for this PHY.
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS).
Time m_eifsNoDifs
EIFS duration minus a DIFS.
Channel Access Manager Test.
void AddAccessRequestWithSuccessfulAck(uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, uint32_t ackDelay, uint32_t from)
Add access request with successful ack.
void AddAckTimeoutReset(uint64_t at)
Add Ack timeout reset function.
void NotifyInternalCollision(Ptr< TxopTest< TxopType > > state)
Notify internal collision function.
void AddRxOkEvt(uint64_t at, uint64_t duration)
Add receive OK event function.
void AddRxStartEvt(uint64_t at, uint64_t duration)
Add receive start event function.
uint32_t m_ackTimeoutValue
the Ack timeout value
void AddAccessRequestWithAckTimeout(uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, uint32_t from)
Add access request with Ack timeout.
ChannelAccessManagerTest()
void AddPhyReconnectEvt(uint64_t at, uint64_t duration)
Add a PHY reconnect event consisting in another PHY operating on the link for the given time.
void GenerateBackoff(uint32_t i)
Generate backoff function.
void NotifyAccessGranted(uint32_t i)
Notify access granted function.
void StartTest(uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs, uint32_t ackTimeoutValue=20, MHz_u chWidth=MHz_u{20})
Start test function.
std::vector< Ptr< TxopTest< TxopType > > > TxopTests
the TXOP tests typedef
void ExpectBackoff(uint64_t time, uint32_t nSlots, uint32_t from)
Expect generate backoff function.
void DoRun() override
Implementation to actually run this TestCase.
void AddTxop(uint32_t aifsn)
Add Txop function.
Ptr< SpectrumWifiPhy > m_phy
the PHY object
void DoAccessRequest(uint64_t txTime, uint64_t expectedGrantTime, Ptr< TxopTest< TxopType > > state)
Add access request with successful Ack.
void AddAccessRequest(uint64_t at, uint64_t txTime, uint64_t expectedGrantTime, uint32_t from)
Add access function.
void AddSwitchingEvt(uint64_t at, uint64_t duration)
Add switching event function.
Ptr< ChannelAccessManagerStub > m_ChannelAccessManager
the channel access manager
void AddRxErrorEvt(uint64_t at, uint64_t duration)
Add receive error event function for error at end of frame.
void ExpectBusy(uint64_t time, bool busy)
Schedule a check that the channel access manager is busy or idle.
void EndTest()
End test function.
void AddCcaBusyEvt(uint64_t at, uint64_t duration, WifiChannelListType channelType=WIFI_CHANLIST_PRIMARY, const std::vector< Time > &per20MhzDurations={})
Add CCA busy event function.
TxopTests m_txop
the vector of Txop test instances
void ExpectInternalCollision(uint64_t time, uint32_t nSlots, uint32_t from)
Expect internal collision function.
void AddPhyDisconnectEvt(uint64_t at, uint64_t duration, uint64_t threshold, uint32_t from)
Add a PHY disconnect event consisting in the PHY leaving the link and returning after a given time.
void AddNavStart(uint64_t at, uint64_t duration)
Add NAV start function.
void AddRxInsideSifsEvt(uint64_t at, uint64_t duration)
Add receive inside SIFS event function.
Ptr< FrameExchangeManagerStub< TxopType > > m_feManager
the Frame Exchange Manager stubbed
void DoCheckBusy(bool busy)
Perform check that channel access manager is busy or idle.
void AddNavReset(uint64_t at, uint64_t duration)
Add NAV reset function.
void AddTxEvt(uint64_t at, uint64_t duration)
Add transmit event function.
void NotifyChannelSwitching()
Notify channel switching function.
ChannelAccessManager Test Suite.
ChannelAccessManagerTestSuite()
Frame Exchange Manager Stub.
void NotifySwitchingStartNow(Time duration) override
void NotifyInternalCollision(Ptr< Txop > txop) override
Notify that an internal collision has occurred for the given Txop.
bool StartTransmission(Ptr< Txop > dcf, MHz_u allowedWidth) override
Request the FrameExchangeManager to start a frame exchange sequence.
ChannelAccessManagerTest< TxopType > * m_test
the test DCF/EDCA manager
FrameExchangeManagerStub(ChannelAccessManagerTest< TxopType > *test)
Constructor.
Test the calculation of the largest idle primary channel performed by ChannelAccessManager::GetLarges...
Ptr< SpectrumWifiPhy > m_phy
PHY object.
LargestIdlePrimaryChannelTest()
void RunOne(MHz_u chWidth, WifiChannelListType busyChannel)
Test a specific combination of operating channel width and busy channel type.
~LargestIdlePrimaryChannelTest() override=default
void DoRun() override
Implementation to actually run this TestCase.
Ptr< ChannelAccessManager > m_cam
channel access manager
ExpectedBackoffs m_expectedInternalCollision
expected backoff due to an internal collision
void DoDispose() override
Destructor implementation.
void GenerateBackoff(uint8_t linkId) override
Generate a new backoff for the given link now.
uint32_t m_i
the index of the Txop
void NotifyChannelAccessed(uint8_t linkId, Time txopDuration=Seconds(0)) override
Called by the FrameExchangeManager to notify that channel access has been granted on the given link f...
void QueueTx(uint64_t txTime, uint64_t expectedGrantTime)
Queue transmit function.
ExpectedBackoffs m_expectedBackoff
expected backoff (not due to an internal collision)
std::list< ExpectedGrant > ExpectedGrants
the collection of expected grants typedef
void NotifySleep(uint8_t linkId) override
Notify that the given link switched to sleep mode.
ChannelAccessManagerTest< TxopType > * m_test
Check if the Txop has frames to transmit.
ExpectedGrants m_expectedGrants
expected grants
std::list< ExpectedBackoff > ExpectedBackoffs
expected backoffs typedef
void NotifyWakeUp(uint8_t linkId) override
When wake up operation occurs on a link, channel access on that link will be restarted.
bool HasFramesToTransmit(uint8_t linkId) override
Check if the Txop has frames to transmit over the given link.
TxopTest(ChannelAccessManagerTest< TxopType > *test, uint32_t i)
Constructor.
std::pair< uint64_t, uint64_t > ExpectedGrant
the expected grant typedef
AttributeValue implementation for Boolean.
Manage a set of ns3::Txop.
void NotifyRxStartNow(Time duration)
void NotifySwitchingStartNow(PhyListener *phyListener, Time duration)
void NotifyAckTimeoutResetNow()
Notify that ack timer has reset.
void NotifyTxStartNow(Time duration)
void NotifyRxEndOkNow()
Notify the Txop that a packet reception was just completed successfully.
void NotifyCcaBusyStartNow(Time duration, WifiChannelListType channelType, const std::vector< Time > &per20MhzDurations)
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for PHY events on the given PHY.
void NotifyRxEndErrorNow(const WifiTxVector &txVector)
Notify the Txop that a packet reception was just completed unsuccessfuly.
void NotifyNavResetNow(Time duration)
void NotifyNavStartNow(Time duration)
An identifier for simulation events.
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6 Mbps.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Make it easy to create and manage PHY objects for the spectrum model.
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
create MAC layers for a ns3::WifiNetDevice.
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void Set(std::string name, const AttributeValue &v)
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
std::tuple< uint8_t, MHz_u, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying a segment of an operating channel.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
@ WIFI_CHANLIST_SECONDARY40
@ WIFI_CHANLIST_SECONDARY
@ WIFI_CHANLIST_SECONDARY80
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
std::size_t Count20MHzSubchannels(MHz_u channelWidth)
Return the number of 20 MHz subchannels covering the channel width.
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
-ns3 Test suite for the ns3 wrapper script
ExpectedBackoff structure.
uint32_t nSlots
number of slots
ChannelAccessStatus access
channel access status