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 = {});
426template <
typename TxopType>
430 m_expectedGrants.emplace_back(txTime, expectedGrantTime);
433template <
typename TxopType>
440template <
typename TxopType>
445 TxopType::DoDispose();
448template <
typename TxopType>
453 m_test->NotifyAccessGranted(m_i);
456template <
typename TxopType>
460 m_test->GenerateBackoff(m_i);
463template <
typename TxopType>
467 return !m_expectedGrants.empty();
470template <
typename TxopType>
476template <
typename TxopType>
482template <
typename TxopType>
488template <
typename TxopType>
494 if (!state->m_expectedGrants.empty())
496 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front();
497 state->m_expectedGrants.pop_front();
500 "Expected access grant is now");
501 m_ChannelAccessManager->NotifyTxStartNow(
MicroSeconds(expected.first));
502 m_ChannelAccessManager->NotifyAckTimeoutStartNow(
507template <
typename TxopType>
513 m_ChannelAccessManager,
517template <
typename TxopType>
523 "Have expected internal collisions");
524 if (!state->m_expectedInternalCollision.empty())
530 MicroSeconds(expected.at),
531 "Expected internal collision time is now");
532 state->StartBackoffNow(expected.nSlots, 0);
536template <typename TxopType>
542 if (!state->m_expectedBackoff.empty())
547 MicroSeconds(expected.at),
548 "Expected backoff is now");
549 state->StartBackoffNow(expected.nSlots, 0);
553template <typename TxopType>
557 for (
auto& state : m_txop)
559 if (!state->m_expectedGrants.empty())
561 std::pair<uint64_t, uint64_t> expected = state->m_expectedGrants.front();
562 state->m_expectedGrants.pop_front();
565 "Expected grant is now");
571template <
typename TxopType>
584template <typename TxopType>
591 backoff.nSlots = nSlots;
595template <typename TxopType>
605template <
typename TxopType>
612template <
typename TxopType>
616 uint64_t eifsNoDifsNoSifs,
622 m_ChannelAccessManager->SetupFrameExchangeManager(m_feManager);
623 m_ChannelAccessManager->SetSlot(
MicroSeconds(slotTime));
625 m_ChannelAccessManager->SetEifsNoDifs(
MicroSeconds(eifsNoDifsNoSifs + sifs));
626 m_ackTimeoutValue = ackTimeoutValue;
636 m_ChannelAccessManager->SetupPhyListener(m_phy);
639template <
typename TxopType>
644 m_txop.push_back(txop);
645 m_ChannelAccessManager->Add(txop);
650 mac->SetWifiPhys({
nullptr});
651 txop->SetWifiMac(mac);
652 txop->SetAifsn(aifsn);
655template <
typename TxopType>
661 for (
auto i = m_txop.begin(); i != m_txop.end(); i++)
667 "Have no internal collisions");
674 m_ChannelAccessManager->RemovePhyListener(m_phy);
676 m_ChannelAccessManager->Dispose();
677 m_ChannelAccessManager =
nullptr;
678 m_feManager =
nullptr;
682template <
typename TxopType>
688 m_ChannelAccessManager,
692 m_ChannelAccessManager);
695template <
typename TxopType>
701 m_ChannelAccessManager,
705template <
typename TxopType>
711 m_ChannelAccessManager,
715 m_ChannelAccessManager);
718template <
typename TxopType>
722 uint64_t timeUntilError)
726 m_ChannelAccessManager,
730 m_ChannelAccessManager);
733 m_ChannelAccessManager,
736 std::vector<Time>{});
739template <
typename TxopType>
745 m_ChannelAccessManager,
749template <
typename TxopType>
755 m_ChannelAccessManager,
759template <
typename TxopType>
765 m_ChannelAccessManager);
768template <
typename TxopType>
772 uint64_t expectedGrantTime,
775 AddAccessRequestWithSuccessfulAck(at, txTime, expectedGrantTime, 0, from);
778template <
typename TxopType>
782 uint64_t expectedGrantTime,
793template <
typename TxopType>
797 uint64_t expectedGrantTime,
808 AddAckTimeoutReset(expectedGrantTime + txTime + ackDelay);
811template <
typename TxopType>
814 uint64_t expectedGrantTime,
818 state->QueueTx(txTime, expectedGrantTime);
819 if (m_ChannelAccessManager->NeedBackoffUponAccess(state, hadFramesToTransmit,
true))
821 state->GenerateBackoff(0);
823 m_ChannelAccessManager->RequestAccess(state);
826template <
typename TxopType>
831 const std::vector<Time>& per20MhzDurations)
835 m_ChannelAccessManager,
841template <
typename TxopType>
847 m_ChannelAccessManager,
852template <
typename TxopType>
858 m_ChannelAccessManager,
875 AddAccessRequest(1, 1, 5, 0);
876 AddAccessRequest(8, 2, 12, 0);
887 AddAccessRequest(1, 1, 5, 0);
888 AddRxInsideSifsEvt(7, 10);
890 AddAccessRequest(14, 2, 18, 0);
908 AddAccessRequest(30, 2, 118, 0);
909 ExpectBackoff(30, 4, 0);
921 AddAccessRequest(30, 2, 70, 0);
922 ExpectBackoff(30, 0, 0);
935 AddAccessRequest(30, 2, 110, 0);
936 ExpectBackoff(30, 0, 0);
947 AddAccessRequest(62, 2, 72, 0);
958 AddAccessRequest(70, 2, 80, 0);
969 AddRxErrorEvt(20, 40);
970 AddAccessRequest(30, 2, 102, 0);
971 ExpectBackoff(30, 4, 0);
983 AddRxErrorEvt(20, 40);
984 AddAccessRequest(70, 2, 86, 0);
995 AddRxErrorEvt(20, 40, 20);
996 ExpectBusy(41,
true);
997 ExpectBusy(59,
true);
998 ExpectBusy(61,
false);
1007 StartTest(4, 6, 10);
1009 AddRxErrorEvt(20, 40);
1010 AddAccessRequest(30, 2, 101, 0);
1011 ExpectBackoff(30, 4, 0);
1024 StartTest(4, 6, 10);
1028 AddAccessRequest(30, 10, 78, 0);
1029 ExpectBackoff(30, 2, 0);
1030 AddAccessRequest(40, 2, 110, 1);
1031 ExpectBackoff(40, 0, 1);
1032 ExpectInternalCollision(78, 1, 1);
1042 StartTest(4, 6, 10);
1045 AddAccessRequestWithAckTimeout(20, 20, 34, 1);
1046 AddAccessRequest(64, 10, 80, 0);
1058 StartTest(4, 6, 10);
1061 AddAccessRequestWithSuccessfulAck(20, 20, 34, 2, 1);
1062 AddAccessRequest(55, 10, 62, 0);
1069 StartTest(4, 6, 10);
1071 AddAccessRequest(20, 20, 34, 0);
1073 AddAccessRequest(61, 10, 80, 0);
1074 ExpectBackoff(61, 1, 0);
1080 StartTest(4, 6, 10);
1083 AddNavStart(60, 15);
1086 AddAccessRequest(30, 10, 93, 0);
1087 ExpectBackoff(30, 2, 0);
1093 StartTest(4, 6, 10);
1096 AddNavStart(60, 15);
1099 AddAccessRequest(30, 10, 91, 0);
1100 ExpectBackoff(30, 2, 0);
1106 StartTest(4, 6, 10);
1109 AddAccessRequest(80, 10, 94, 0);
1112 StartTest(4, 6, 10);
1116 AddAccessRequest(30, 50, 108, 0);
1117 ExpectBackoff(30, 3, 0);
1125 StartTest(1, 3, 10);
1127 AddSwitchingEvt(0, 20);
1128 AddAccessRequest(21, 1, 25, 0);
1136 StartTest(1, 3, 10);
1138 AddSwitchingEvt(20, 20);
1139 AddCcaBusyEvt(30, 20);
1140 ExpectBackoff(45, 2, 0);
1141 AddAccessRequest(45, 1, 56, 0);
1148 StartTest(1, 3, 10);
1150 AddRxStartEvt(20, 40);
1151 AddSwitchingEvt(30, 20);
1152 AddAccessRequest(51, 1, 55, 0);
1159 StartTest(1, 3, 10);
1161 AddCcaBusyEvt(20, 40);
1162 AddSwitchingEvt(30, 20);
1163 AddAccessRequest(51, 1, 55, 0);
1170 StartTest(1, 3, 10);
1172 AddNavStart(20, 40);
1173 AddSwitchingEvt(30, 20);
1174 AddAccessRequest(51, 1, 55, 0);
1182 StartTest(1, 3, 10);
1184 AddAccessRequestWithAckTimeout(20, 20, 24, 0);
1185 AddAccessRequest(49, 1, 54, 0);
1186 AddSwitchingEvt(54, 5);
1187 AddAccessRequest(60, 1, 64, 0);
1195 StartTest(4, 6, 10);
1198 AddAccessRequest(30, 2, 80, 0);
1199 ExpectBackoff(30, 4, 0);
1200 AddSwitchingEvt(80, 20);
1201 AddAccessRequest(101, 2, 111, 0);
1219 StartTest(4, 6, 10, 20, 40);
1223 AddAccessRequest(52, 20, 60, 0);
1233 StartTest(4, 6, 10, 20, 80);
1237 AddAccessRequest(58, 20, 60, 0);
1247 StartTest(4, 6, 10, 20, 80);
1251 AddAccessRequest(62, 20, 64, 0);
1262 StartTest(4, 6, 10, 20, 160);
1264 AddRxErrorEvt(20, 30);
1266 AddAccessRequest(55, 20, 76, 0);
1277 StartTest(4, 6, 10, 20, 160);
1279 AddRxErrorEvt(20, 30);
1281 AddAccessRequest(70, 20, 76, 0);
1292 StartTest(4, 6, 10, 20, 160);
1294 AddRxErrorEvt(20, 30);
1296 AddAccessRequest(82, 20, 84, 0);
1305 StartTest(4, 6, 10);
1308 AddAccessRequest(30, 20, 76, 0);
1309 ExpectBackoff(30, 4, 0);
1320 StartTest(4, 6, 10);
1325 AddAccessRequest(30, 20, 107, 0);
1326 ExpectBackoff(30, 3, 0);
1349 void DoRun()
override;
1364 :
TestCase(
"Check calculation of the largest idle primary channel")
1399 std::vector<Time>(chWidth == 20 ? 0 : chWidth / 20,
Seconds(0)));
1404 MHz_u idleWidth = (busyChannel == WifiChannelListType::WIFI_CHANLIST_PRIMARY)
1406 : ((1 << (busyChannel - 1)) * 20);
1408 Time checkTime1 = start + ccaBusyStartDelay + ccaBusyDuration / 2;
1410 Time interval1 = (ccaBusyStartDelay + ccaBusyDuration) / 2;
1413 "Incorrect width of the idle channel in an interval "
1414 <<
"ending within CCA_BUSY (channel width: " << chWidth
1415 <<
" MHz, busy channel: " << busyChannel <<
")");
1421 Time checkTime2 = start + ccaBusyStartDelay + ccaBusyDuration + ccaBusyRxInterval / 2;
1423 Time interval2 = (ccaBusyDuration + ccaBusyRxInterval) / 2;
1426 "Incorrect width of the idle channel in an interval "
1427 <<
"starting within CCA_BUSY (channel width: " << chWidth
1428 <<
" MHz, busy channel: " << busyChannel <<
")");
1440 Time checkTime3 = start + ccaBusyStartDelay + ccaBusyDuration + ccaBusyRxInterval + rxDuration;
1442 Time interval3 = ccaBusyDuration / 2 + ccaBusyRxInterval;
1443 Time end3 = checkTime3 - rxDuration;
1446 "Incorrect width of the idle channel in an interval "
1447 <<
"preceding RX start and overlapping CCA_BUSY "
1448 <<
"(channel width: " << chWidth
1449 <<
" MHz, busy channel: " << busyChannel <<
")");
1454 const Time& checkTime4 = checkTime3;
1456 const Time& interval4 = ccaBusyRxInterval;
1457 Time end4 = checkTime4 - rxDuration;
1460 "Incorrect width of the idle channel in the interval "
1461 <<
"following CCA_BUSY and preceding RX start (channel "
1462 <<
"width: " << chWidth <<
" MHz, busy channel: " << busyChannel
1469 Time checkTime5 = checkTime4 + interval5;
1473 "Incorrect width of the idle channel in an interval "
1474 <<
"following RX end (channel width: " << chWidth
1475 <<
" MHz, busy channel: " << busyChannel <<
")");
1479 const Time& checkTime6 = checkTime5;
1481 Time interval6 = interval5 + rxDuration / 2;
1484 "Incorrect width of the idle channel in an interval "
1485 <<
"overlapping RX (channel width: " << chWidth
1486 <<
" MHz, busy channel: " << busyChannel <<
")");
1495 uint8_t channel = 0;
1496 std::list<WifiChannelListType> busyChannels;
1498 for (
MHz_u chWidth : {20, 40, 80, 160})
1502 for (
const auto busyChannel : busyChannels)
1515 m_phy->SetOperatingChannel(
1522 RunOne(chWidth, busyChannel);
1595 void DoRun()
override;
1643 :
TestCase(
"Check attributes impacting the generation of backoff values"),
1644 m_generateBackoffIfTxopWithoutTx(type == GEN_BACKOFF_IF_TXOP_NO_TX),
1645 m_proactiveBackoff(type == PROACTIVE_BACKOFF)
1658 int64_t streamNumber = 10;
1670 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
1679 phyHelper.
Set(
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
1683 mac.SetType(
"ns3::ApWifiMac",
1691 mac.SetType(
"ns3::StaWifiMac",
1704 ->TraceConnectWithoutContext(
"PhyTxPsduBegin",
1707 ->TraceConnectWithoutContext(
"PhyTxPsduBegin",
1711 m_apMac->GetQosTxop(
AC_VO)->TraceConnectWithoutContext(
1720 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1721 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
1724 mobility.SetPositionAllocator(positionAlloc);
1725 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
1726 mobility.Install(apNode);
1727 mobility.Install(staNode);
1732 packetSocket.
Install(staNode);
1740 server->SetLocal(srvAddr);
1741 server->SetStartTime(
Seconds(0));
1742 server->SetStopTime(
Seconds(1));
1743 staNode->AddApplication(server);
1762 m_apMac->GetMacQueueScheduler()->BlockQueues(WifiQueueBlockedReason::TID_NOT_MAPPED,
1768 {SINGLE_LINK_OP_ID});
1779 "Unexpected total number of generated backoff values");
1792 for (
const auto& [aid, psdu] : psduMap)
1794 std::stringstream ss;
1795 ss << std::setprecision(10) << psdu->GetHeader(0).GetTypeString();
1796 if (psdu->GetHeader(0).IsAction())
1800 psdu->GetPayload(0)->PeekHeader(actionHdr);
1801 actionHdr.
Print(ss);
1803 ss <<
" #MPDUs " << psdu->GetNMpdus() <<
" duration/ID " << psdu->GetHeader(0).GetDuration()
1804 <<
" RA = " << psdu->GetAddr1() <<
" TA = " << psdu->GetAddr2()
1805 <<
" ADDR3 = " << psdu->GetHeader(0).GetAddr3()
1806 <<
" ToDS = " << psdu->GetHeader(0).IsToDs()
1807 <<
" FromDS = " << psdu->GetHeader(0).IsFromDs();
1808 if (psdu->GetHeader(0).IsAssocReq())
1813 else if (psdu->GetHeader(0).IsAck())
1822 m_apMac->GetDevice()->GetNode(),
1826 else if (psdu->GetHeader(0).IsQosData())
1831 ss << mpdu->GetHeader().GetSequenceNumber() <<
",";
1833 ss <<
"} TID = " << +psdu->GetHeader(0).GetQosTid();
1841 NS_LOG_INFO(
"TX duration = " << txDuration.As(
Time::MS) <<
" TXVECTOR = " << txVector <<
"\n");
1847 NS_LOG_INFO(
"Backoff value " << backoff <<
" generated by AP on link " << +linkId <<
" for "
1852 const std::size_t nValues = 5;
1859 "First backoff value should be generated at initialization time");
1867 "Second backoff value should be generated after association");
1874 "Second backoff value should be generated after AssocReq TX start time");
1877 "Second backoff value should be generated right after AssocReq "
1878 "PPDU payload starts");
1886 "Third backoff value should be generated after association");
1890 GenerateInterference();
1896 NS_TEST_EXPECT_MSG_EQ(m_nGenBackoff,
1898 "Unexpected number of generated backoff values");
1905 Simulator::Schedule(m_interferenceDuration, [=, this]() {
1906 auto voEdcaf = m_apMac->GetQosTxop(AC_VO);
1908 m_apMac->GetChannelAccessManager(linkId)->NeedBackoffUponAccess(voEdcaf,
1912 m_apMac->GetChannelAccessManager(linkId)->GetBackoffEndFor(voEdcaf) -
1913 Simulator::Now() + NanoSeconds(1);
1916 Simulator::Schedule(delay, [=, this]() {
1918 NS_TEST_EXPECT_MSG_EQ(m_nGenBackoff,
1920 "Unexpected number of generated backoff values");
1921 GenerateInterference();
1923 NS_TEST_EXPECT_MSG_EQ(m_nGenBackoff,
1925 "Unexpected number of generated backoff values");
1934 m_apMac->GetMacQueueScheduler()->UnblockQueues(WifiQueueBlockedReason::TID_NOT_MAPPED,
1937 m_staMac->GetAddress(),
1938 m_apMac->GetAddress(),
1944 if (m_generateBackoffIfTxopWithoutTx)
1950 if (m_nGenBackoff == 1)
1953 delay = m_apMac->GetWifiPhy(linkId)->GetSifs() +
1954 m_apMac->GetQosTxop(
AC_VO)->GetAifsn(linkId) *
1955 m_apMac->GetWifiPhy(linkId)->GetSlot();
1957 else if (m_nGenBackoff <= nValues)
1961 "Expected a timer to be running");
1964 "Backoff value generated too early");
1965 m_nextBackoffGen.Cancel();
1969 delay = m_apMac->GetWifiPhy(linkId)->GetSlot();
1972 if (m_nGenBackoff < nValues)
1975 delay += backoff * m_apMac->GetWifiPhy(linkId)->GetSlot();
1990 "Expected a new backoff value to be generated at time "
2000 *psd =
DbmToW(20) / 80e6;
2004 spectrumSignalParams->txPhy = phy->GetCurrentInterface();
2005 spectrumSignalParams->txAntenna = phy->GetAntenna();
2006 spectrumSignalParams->psd = psd;
2008 phy->StartRx(spectrumSignalParams, phy->GetCurrentInterface());
2068 TestCase::Duration::QUICK);
2070 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 GenerateBackoff(uint32_t i)
Generate backoff function.
void NotifyAccessGranted(uint32_t i)
Notify access granted 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.
void StartTest(uint64_t slotTime, uint64_t sifs, uint64_t eifsNoDifsNoSifs, uint32_t ackTimeoutValue=20, MHz_u chWidth=20)
Start test 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 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
Manage a set of ns3::Txop.
void NotifyRxEndErrorNow()
Notify the Txop that a packet reception was just completed unsuccessfuly.
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 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.
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.
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.
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)
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
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.
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.
-ns3 Test suite for the ns3 wrapper script
ExpectedBackoff structure.
uint32_t nSlots
number of slots
ChannelAccessStatus access
channel access status