18#include "ns3/boolean.h"
19#include "ns3/constant-position-mobility-model.h"
20#include "ns3/he-phy.h"
21#include "ns3/interference-helper.h"
23#include "ns3/mobility-helper.h"
24#include "ns3/multi-model-spectrum-channel.h"
25#include "ns3/nist-error-rate-model.h"
26#include "ns3/ofdm-ppdu.h"
27#include "ns3/pointer.h"
28#include "ns3/spectrum-wifi-helper.h"
29#include "ns3/spectrum-wifi-phy.h"
30#include "ns3/string.h"
32#include "ns3/wifi-mac-header.h"
33#include "ns3/wifi-net-device.h"
34#include "ns3/wifi-phy-listener.h"
35#include "ns3/wifi-psdu.h"
36#include "ns3/wifi-spectrum-phy-interface.h"
37#include "ns3/wifi-spectrum-signal-parameters.h"
38#include "ns3/wifi-spectrum-value-helper.h"
39#include "ns3/wifi-utils.h"
90 return std::any_of(
m_rxing.cbegin(),
m_rxing.cend(), [](
const auto& rxing) {
143 std::vector<bool> statusPerMpdu);
152 void DoRun()
override;
200 txParams->psd = txPowerSpectrum;
201 txParams->txPhy =
nullptr;
202 txParams->duration = txDuration;
203 txParams->ppdu = ppdu;
219 std::vector<bool> statusPerMpdu)
244 m_phy = CreateObject<SpectrumWifiPhy>();
258 node->AddDevice(dev);
272 double txPowerWatts = 0.010;
333 const std::vector<Time>& )
override
403 void DoRun()
override;
420 m_listener = std::make_shared<TestPhyListener>();
427 double txPowerWatts = 0.010;
435 "Didn't receive NotifyCcaBusyStart (once preamble is detected + prolonged by L-SIG "
436 "reception, then switched to Rx by at the beginning of data)");
465 void DoRun()
override;
494 :
TestCase(
"SpectrumWifiPhy test RX filters"),
495 m_txChannelWidth(20),
537 for (
const auto& pair : rxPowersW)
539 NS_LOG_INFO(
"band: (" << pair.first <<
") -> powerW=" << pair.second <<
" ("
540 <<
WToDbm(pair.second) <<
" dBm)");
543 size_t numBands = rxPowersW.size();
552 "Total number of bands handled by the receiver is incorrect");
556 auto it = rxPowersW.find(band);
557 NS_LOG_INFO(
"powerW total band: " << it->second <<
" (" <<
WToDbm(it->second) <<
" dBm)");
558 int totalRxPower =
static_cast<int>(
WToDbm(it->second) + 0.5);
559 int expectedTotalRxPower;
564 expectedTotalRxPower = 16;
569 expectedTotalRxPower =
573 expectedTotalRxPower,
574 "Total received power is not correct");
579 it = rxPowersW.find(band);
580 NS_LOG_INFO(
"powerW in primary 20 MHz channel: " << it->second <<
" (" <<
WToDbm(it->second)
582 int rxPowerPrimaryChannel20 =
static_cast<int>(
WToDbm(it->second) + 0.5);
583 int expectedRxPowerPrimaryChannel20 = 16 -
static_cast<int>(
RatioToDb(channelWidth / 20));
585 expectedRxPowerPrimaryChannel20,
586 "Received power in the primary 20 MHz band is not correct");
598 lossModel->SetFrequency(5.180e9);
599 spectrumChannel->AddPropagationLossModel(lossModel);
601 CreateObject<ConstantSpeedPropagationDelayModel>();
602 spectrumChannel->SetPropagationDelayModel(delayModel);
606 m_txPhy = CreateObject<ExtSpectrumWifiPhy>();
617 txNode->AggregateObject(apMobility);
618 txNode->AddDevice(txDev);
622 m_rxPhy = CreateObject<ExtSpectrumWifiPhy>();
632 rxNode->AggregateObject(sta1Mobility);
633 rxNode->AddDevice(rxDev);
650 uint16_t txFrequency;
675 uint16_t rxFrequency;
701 for (uint16_t bw = 160; bw >= 20; bw = bw / 2)
705 for (
unsigned int type = 0; type < 7; type++)
708 for (std::size_t index = 1; index <=
HeRu::GetNRus(bw, ruType); index++)
713 std::make_pair(subcarrierGroup.front().first,
714 subcarrierGroup.back().second);
847 void DoRun()
override;
860 uint8_t channelNumber,
861 uint16_t channelWidth,
862 std::optional<std::size_t> listenerIndex);
896 std::vector<bool> statusPerMpdu);
915 bool interferencesExpected);
925 bool interferencesExpected);
944 const std::vector<std::size_t>& expectedConnectedPhysPerChannel);
956 bool expectedCcaBusyIndication,
958 Time propagationDelay);
985 std::vector<uint32_t>
987 std::vector<uint32_t>
996 bool trackSignalsInactiveInterfaces,
998 :
TestCase{
"SpectrumWifiPhy test operation with multiple RF interfaces"},
999 m_trackSignalsInactiveInterfaces{trackSignalsInactiveInterfaces},
1000 m_chanSwitchScenario{chanSwitchScenario}
1007 uint8_t channelNumber,
1008 uint16_t channelWidth,
1009 std::optional<std::size_t> listenerIndex)
1011 NS_LOG_FUNCTION(
this << phy << band << +channelNumber << channelWidth);
1015 listener->m_notifyMaybeCcaBusyStart = 0;
1016 listener->m_ccaBusyStart =
Seconds(0);
1017 listener->m_ccaBusyEnd =
Seconds(0);
1032 NS_LOG_FUNCTION(
this << phy << txPowerDbm << payloadSize << phy->GetCurrentFrequencyRange()
1033 << phy->GetChannelWidth() << phy->GetChannelNumber());
1049 phy->SetTxPowerStart(txPowerDbm);
1050 phy->SetTxPowerEnd(txPowerDbm);
1060 const auto payloadBytes = packet->GetSize() - 30;
1061 NS_LOG_FUNCTION(
this << index << payloadBytes << phy->GetCurrentFrequencyRange()
1062 << phy->GetChannelWidth() << phy->GetChannelNumber());
1089 bool interferencesExpected)
1102 interferencesExpected);
1108 bool interferencesExpected)
1112 phy->GetAttribute(
"InterferenceHelper", ptr);
1115 const auto energyDuration = interferenceHelper->GetEnergyDuration(0, band);
1117 interferencesExpected,
1118 "Incorrect interferences detection");
1128 const std::vector<std::size_t>& expectedConnectedPhysPerChannel)
1130 NS_LOG_FUNCTION(
this << index << expectedNumRx << expectedNumRxSuccess << expectedRxBytes
1131 << expectedFrequencyRangeActiveRfInterface);
1132 const auto phy =
m_rxPhys.at(index);
1133 std::size_t numActiveInterfaces = 0;
1134 for (
const auto& [freqRange, interface] : phy->GetSpectrumPhyInterfaces())
1136 const auto expectedActive = (freqRange == expectedFrequencyRangeActiveRfInterface);
1137 const auto isActive = (
interface == phy->GetCurrentInterface());
1141 numActiveInterfaces++;
1149 expectedConnectedPhysPerChannel.at(i),
1150 "Incorrect number of PHYs attached to the spectrum channel");
1154 expectedNumRxSuccess,
1155 "Unexpected amount of successfully received packets");
1158 "Unexpected amount of unsuccessfully received packets");
1160 expectedNumRxSuccess,
1161 "Unexpected amount of RX payload start indication");
1166 bool expectedCcaBusyIndication,
1167 Time switchingDelay,
1168 Time propagationDelay)
1170 const auto expectedCcaBusyStart =
1172 const auto expectedCcaBusyEnd =
1174 NS_LOG_FUNCTION(
this << index << expectedCcaBusyIndication << expectedCcaBusyStart
1175 << expectedCcaBusyEnd);
1177 const auto ccaBusyIndication = (listener->m_notifyMaybeCcaBusyStart > 0);
1178 const auto ccaBusyStart = listener->m_ccaBusyStart;
1179 const auto ccaBusyEnd = listener->m_ccaBusyEnd;
1181 expectedCcaBusyIndication,
1182 "CCA busy indication check failed");
1192 phy->GetAttribute(
"InterferenceHelper", ptr);
1211 for (std::size_t rxPhyIndex = 0; rxPhyIndex <
m_rxPhys.size(); ++rxPhyIndex)
1213 auto txPhy =
m_txPhys.at(rxPhyIndex);
1215 txPhy->GetPhyBand(),
1216 txPhy->GetChannelNumber(),
1217 txPhy->GetChannelWidth(),
1253 struct SpectrumPhyInterfaceInfo
1258 std::string bandName;
1270 const std::vector<SpectrumPhyInterfaceInfo> interfaces{
1276 for (std::size_t i = 0; i < interfaces.size(); ++i)
1278 auto spectrumChannel = CreateObject<MultiModelSpectrumChannel>();
1279 [[maybe_unused]]
const auto [channel, frequency, channelWidth, type, band] =
1284 interfaces.at(i).band));
1286 auto delayModel = CreateObject<ConstantSpeedPropagationDelayModel>();
1287 spectrumChannel->SetPropagationDelayModel(delayModel);
1288 std::ostringstream oss;
1289 oss <<
"{" << +interfaces.at(i).number <<
", 0, " << interfaces.at(i).bandName <<
", 0}";
1291 phyHelper.
AddChannel(spectrumChannel, interfaces.at(i).range);
1297 mac.SetType(
"ns3::ApWifiMac",
"BeaconGeneration",
BooleanValue(
false));
1298 phyHelper.
Set(
"TrackSignalsFromInactiveInterfaces",
BooleanValue(
false));
1299 auto apDevice = wifi.Install(phyHelper, mac, wifiApNode.Get(0));
1301 mac.SetType(
"ns3::StaWifiMac",
"ActiveProbing",
BooleanValue(
false));
1302 phyHelper.
Set(
"TrackSignalsFromInactiveInterfaces",
1304 auto staDevice = wifi.Install(phyHelper, mac, wifiStaNode.
Get(0));
1307 auto positionAlloc = CreateObject<ListPositionAllocator>();
1309 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1310 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
1311 mobility.SetPositionAllocator(positionAlloc);
1313 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
1314 mobility.Install(wifiApNode);
1315 mobility.Install(wifiStaNode);
1317 for (std::size_t i = 0; i < interfaces.size(); ++i)
1320 DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(apDevice.Get(0))->GetPhy(i));
1327 const auto index =
m_rxPhys.size();
1329 DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(staDevice.Get(0))->GetPhy(i));
1334 rxPhy->TraceConnectWithoutContext(
1338 rxPhy->SetReceiveOkCallback(
1340 rxPhy->SetReceiveErrorCallback(
1343 auto listener = std::make_shared<TestPhyListener>();
1344 rxPhy->RegisterListener(listener);
1377 const auto ccaEdThresholdDbm = -62.0;
1378 const auto txAfterChannelSwitchDelay =
1383 const auto checkResultsDelay =
1385 const auto flushResultsDelay =
1387 const auto txOngoingAfterTxStartedDelay =
1395 std::vector<std::size_t> expectedConnectedPhysPerChannel =
1399 std::vector<std::size_t>{2, 2, 2, 2};
1402 for (std::size_t i = 0; i < 4; ++i)
1412 for (std::size_t j = 0; j < 4; ++j)
1416 const auto& expectedFreqRange = txPhy->GetCurrentFrequencyRange();
1421 txPpduPhy->GetCurrentFrequencyRange(),
1422 txPpduPhy->GetBand(txPpduPhy->GetChannelWidth(), 0),
1430 (i == j) ? 1000 : 0,
1432 expectedConnectedPhysPerChannel);
1440 for (std::size_t i = 0; i < 4; ++i)
1450 const auto& expectedFreqRange = txPpduPhy->GetCurrentFrequencyRange();
1451 for (std::size_t j = 0; j < 4; ++j)
1455 for (std::size_t k = 0; k < expectedConnectedPhysPerChannel.size(); ++k)
1457 expectedConnectedPhysPerChannel.at(k) = (k == i) ? 5 : 1;
1465 txPpduPhy->GetPhyBand(),
1466 txPpduPhy->GetChannelNumber(),
1467 txPpduPhy->GetChannelWidth(),
1473 txPpduPhy->GetCurrentFrequencyRange(),
1474 txPpduPhy->GetBand(txPpduPhy->GetChannelWidth(), 0),
1484 expectedConnectedPhysPerChannel);
1493 const auto secondSpectrumChannelIndex = 1;
1494 auto channel36TxPhy =
m_txPhys.at(secondSpectrumChannelIndex);
1495 const auto& expectedFreqRange = channel36TxPhy->GetCurrentFrequencyRange();
1496 for (std::size_t i = 0; i < 4; ++i)
1506 for (std::size_t j = 0; j < 4; ++j)
1510 for (std::size_t k = 0; k < expectedConnectedPhysPerChannel.size(); ++k)
1512 expectedConnectedPhysPerChannel.at(k) =
1513 (k == secondSpectrumChannelIndex) ? 5 : 1;
1528 (i == secondSpectrumChannelIndex) ? 1 : 0,
1529 (i == secondSpectrumChannelIndex) ? 1 : 0,
1530 (i == secondSpectrumChannelIndex) ? 1000 : 0,
1532 expectedConnectedPhysPerChannel);
1540 for (
const auto txPowerDbm : {-60.0 , -70.0 })
1542 for (std::size_t i = 0; i < 4; ++i)
1544 for (std::size_t j = 0; j < 4; ++j)
1547 const auto startChannel =
1552 txPpduPhy->GetPhyBand());
1553 for (uint16_t bw = txPpduPhy->GetChannelWidth(); bw >= 20; bw /= 2)
1555 [[maybe_unused]]
const auto [channel, frequency, channelWidth, type, band] =
1560 txPpduPhy->GetPhyBand(),
1577 for (std::size_t k = 0; k < 4; ++k)
1579 if ((i != j) && (k == i))
1583 const auto expectCcaBusyIndication =
1584 (k == i) ? (txPowerDbm >= ccaEdThresholdDbm)
1586 ? ((txPowerDbm >= ccaEdThresholdDbm) ? (j == k) :
false)
1589 delay + checkResultsDelay,
1593 expectCcaBusyIndication,
1594 txOngoingAfterTxStartedDelay,
1631 txPpduPhy->GetPhyBand(),
1632 txPpduPhy->GetChannelNumber(),
1633 txPpduPhy->GetChannelWidth(),
1652 txPpduPhy->GetPhyBand(),
1653 txPpduPhy->GetChannelNumber(),
1654 txPpduPhy->GetChannelWidth(),
1668 delay + checkResultsDelay,
1676 txPpduPhy->GetCurrentFrequencyRange(),
1677 expectedConnectedPhysPerChannel);
1698 txPpduPhy->GetPhyBand(),
1699 txPpduPhy->GetChannelNumber(),
1700 txPpduPhy->GetChannelWidth(),
1720 m_txPhys.at(0)->GetChannelNumber(),
1731 txPpduPhy->GetPhyBand(),
1732 txPpduPhy->GetChannelNumber(),
1733 txPpduPhy->GetChannelWidth(),
1762 m_rxPhys.at(2)->GetChannelNumber(),
1773 txPpduPhy->GetPhyBand(),
1774 txPpduPhy->GetChannelNumber(),
1775 txPpduPhy->GetChannelWidth(),
1795 txPpduPhy->GetCurrentFrequencyRange(),
1796 expectedConnectedPhysPerChannel);
1826 void DoRun()
override;
1830 :
TestCase(
"Check PHY interfaces added to PHY instances using helper")
1841 phyHelper.
Set(0,
"ChannelSettings",
StringValue(
"{2, 0, BAND_2_4GHZ, 0}"));
1842 phyHelper.
Set(1,
"ChannelSettings",
StringValue(
"{36, 0, BAND_5GHZ, 0}"));
1843 phyHelper.
Set(2,
"ChannelSettings",
StringValue(
"{1, 0, BAND_6GHZ, 0}"));
1857 DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(0));
1861 "Incorrect number of PHY interfaces added to PHY link ID 0");
1864 DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(1));
1868 "Incorrect number of PHY interfaces added to PHY link ID 1");
1871 DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(2));
1875 "Incorrect number of PHY interfaces added to PHY link ID 2");
1884 phyLink0 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(0));
1888 "Incorrect number of PHY interfaces added to PHY link ID 0");
1891 "Incorrect PHY interfaces added to PHY link ID 0");
1893 phyLink1 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(1));
1897 "Incorrect number of PHY interfaces added to PHY link ID 1");
1900 "Incorrect PHY interfaces added to PHY link ID 1");
1902 phyLink2 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(2));
1906 "Incorrect number of PHY interfaces added to PHY link ID 2");
1909 "Incorrect PHY interfaces added to PHY link ID 2");
1916 phyLink0 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(0));
1920 "Incorrect number of PHY interfaces added to PHY link ID 0");
1923 "Incorrect PHY interfaces added to PHY link ID 0");
1926 "Incorrect PHY interfaces added to PHY link ID 0");
1928 phyLink1 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(1));
1932 "Incorrect number of PHY interfaces added to PHY link ID 1");
1935 "Incorrect PHY interfaces added to PHY link ID 1");
1937 phyLink2 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(2));
1941 "Incorrect number of PHY interfaces added to PHY link ID 2");
1944 "Incorrect PHY interfaces added to PHY link ID 2");
1951 phyLink0 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(0));
1955 "Incorrect number of PHY interfaces added to PHY link ID 0");
1958 "Incorrect PHY interfaces added to PHY link ID 0");
1961 "Incorrect PHY interfaces added to PHY link ID 0");
1964 "Incorrect PHY interfaces added to PHY link ID 0");
1966 phyLink1 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(1));
1970 "Incorrect number of PHY interfaces added to PHY link ID 1");
1973 "Incorrect PHY interfaces added to PHY link ID 0");
1976 "Incorrect PHY interfaces added to PHY link ID 0");
1979 "Incorrect PHY interfaces added to PHY link ID 0");
1981 phyLink2 = DynamicCast<SpectrumWifiPhy>(DynamicCast<WifiNetDevice>(device.Get(0))->GetPhy(2));
1985 "Incorrect number of PHY interfaces added to PHY link ID 2");
1988 "Incorrect PHY interfaces added to PHY link ID 0");
1991 "Incorrect PHY interfaces added to PHY link ID 0");
1994 "Incorrect PHY interfaces added to PHY link ID 0");
2020 TestCase::Duration::QUICK);
2024 TestCase::Duration::QUICK);
2028 TestCase::Duration::QUICK);
Extended InterferenceHelper class for the purpose of the tests.
static TypeId GetTypeId()
Get the type ID.
bool IsRxing() const
Indicate whether the interference helper is in receiving state.
Extended SpectrumWifiPhy class for the purpose of the tests.
Spectrum Wifi Phy Basic Test.
void SpectrumWifiPhyRxSuccess(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
~SpectrumWifiPhyBasicTest() override
SpectrumWifiPhyBasicTest()
Ptr< SpectrumSignalParameters > MakeSignal(double txPowerWatts, const WifiPhyOperatingChannel &channel)
Make signal function.
void SpectrumWifiPhyRxFailure(Ptr< const WifiPsdu > psdu)
Spectrum wifi receive failure function.
void SendSignal(double txPowerWatts)
Send signal function.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
uint64_t m_uid
the UID to use for the PPDU
Ptr< SpectrumWifiPhy > m_phy
Phy.
Spectrum Wifi Phy Filter Test.
void RxCallback(Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by the PHYs.
uint16_t m_txChannelWidth
TX channel width (MHz)
~SpectrumWifiPhyFilterTest() override
SpectrumWifiPhyFilterTest()
void DoRun() override
Implementation to actually run this TestCase.
void RunOne()
Run one function.
void SendPpdu()
Send PPDU function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
std::set< WifiSpectrumBandIndices > m_ruBands
spectrum bands associated to all the RUs
Ptr< ExtSpectrumWifiPhy > m_rxPhy
RX PHY.
uint16_t m_rxChannelWidth
RX channel width (MHz)
Ptr< ExtSpectrumWifiPhy > m_txPhy
TX PHY.
Spectrum Wifi Phy Interfaces Helper Test.
~SpectrumWifiPhyInterfacesHelperTest() override=default
SpectrumWifiPhyInterfacesHelperTest()
void DoRun() override
Implementation to actually run this TestCase.
Spectrum Wifi Phy Listener Test.
void DoRun() override
Implementation to actually run this TestCase.
~SpectrumWifiPhyListenerTest() override
void DoSetup() override
Implementation to do any local setup required for this TestCase.
SpectrumWifiPhyListenerTest()
std::shared_ptr< TestPhyListener > m_listener
listener
Spectrum Wifi Phy Multiple Spectrum Test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::vector< uint32_t > m_rxBytes
count number of received bytes
std::vector< Ptr< SpectrumWifiPhy > > m_rxPhys
RX PHYs.
std::vector< uint32_t > m_countRxSuccess
count number of packets successfully received by PHYs
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
ChannelSwitchScenario m_chanSwitchScenario
the channel switch scenario to consider for the test
void DoRun() override
Implementation to actually run this TestCase.
void DoCheckInterferences(Ptr< SpectrumWifiPhy > phy, const WifiSpectrumBandInfo &band, bool interferencesExpected)
Check the interferences.
void SwitchChannel(Ptr< SpectrumWifiPhy > phy, WifiPhyBand band, uint8_t channelNumber, uint16_t channelWidth, std::optional< std::size_t > listenerIndex)
Switch channel function.
bool m_trackSignalsInactiveInterfaces
flag to indicate whether signals coming from inactive spectrum PHY interfaces are tracked during the ...
void RxSuccess(std::size_t index, Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Receive success function.
std::vector< std::shared_ptr< TestPhyListener > > m_listeners
listeners
Time m_lastTxEnd
hold the time at which the last transmission ended
void RxFailure(std::size_t index, Ptr< const WifiPsdu > psdu)
Receive failure function.
Time m_lastTxStart
hold the time at which the last transmission started
std::vector< uint32_t > m_counts
count number of packets received by PHYs
void SendPpdu(Ptr< SpectrumWifiPhy > phy, double txPowerDbm, uint32_t payloadSize)
Send PPDU function.
void CheckResults(std::size_t index, uint32_t expectedNumRx, uint32_t expectedNumRxSuccess, uint32_t expectedRxBytes, FrequencyRange expectedFrequencyRangeActiveRfInterface, const std::vector< std::size_t > &expectedConnectedPhysPerChannel)
Verify results.
std::vector< Ptr< SpectrumWifiPhy > > m_txPhys
TX PHYs.
std::vector< Ptr< MultiModelSpectrumChannel > > m_spectrumChannels
Spectrum channels.
void CheckInterferences(Ptr< SpectrumWifiPhy > phy, const FrequencyRange &freqRange, const WifiSpectrumBandInfo &band, bool interferencesExpected)
Schedule now to check the interferences.
SpectrumWifiPhyMultipleInterfacesTest(bool trackSignalsInactiveInterfaces, ChannelSwitchScenario chanSwitchScenario)
Constructor.
void CheckCcaIndication(std::size_t index, bool expectedCcaBusyIndication, Time switchingDelay, Time propagationDelay)
Verify CCA indication reported by a given PHY.
void RxCallback(std::size_t index, Ptr< const Packet > packet, RxPowerWattPerChannelBand rxPowersW)
Callback triggered when a packet is received by a PHY.
void Reset()
Reset function.
void CheckRxingState(Ptr< SpectrumWifiPhy > phy, bool rxingExpected)
Verify rxing state of the interference helper.
ChannelSwitchScenario
Enumeration for channel switching scenarios.
@ BETWEEN_TX_RX
perform channel switch during propagation delay (after TX and before RX)
@ BEFORE_TX
start TX after channel switch is completed
std::vector< uint32_t > m_countRxFailure
count number of packets unsuccessfully received by PHYs
Spectrum Wifi Phy Test Suite.
SpectrumWifiPhyTestSuite()
Time m_ccaBusyEnd
CCA_BUSY end time.
void Reset()
Reset function.
void NotifyWakeup() override
Notify listeners that we woke up.
Time m_ccaBusyStart
CCA_BUSY start time.
void NotifyRxEndOk() override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
void NotifyOff() override
Notify listeners that we went to switch off.
TestPhyListener()=default
Create a test PhyListener.
void NotifySleep() override
Notify listeners that we went to sleep.
void NotifySwitchingStart(Time duration) override
uint32_t m_notifyMaybeCcaBusyStart
notify maybe CCA busy start
uint32_t m_notifyRxStart
notify receive start
void NotifyTxStart(Time duration, double txPowerDbm) override
void NotifyCcaBusyStart(Time duration, WifiChannelListType channelType, const std::vector< Time > &) override
void NotifyRxStart(Time duration) override
void NotifyOn() override
Notify listeners that we went to switch on.
uint32_t m_notifyRxEndOk
notify receive end OK
void NotifyRxEndError() override
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
uint32_t m_notifyRxEndError
notify receive end error
~TestPhyListener() override=default
AttributeValue implementation for Boolean.
static WifiMode GetHeMcs11()
Return MCS 11 from HE MCS values.
static WifiMode GetHeMcs0()
Return MCS 0 from HE MCS values.
static WifiSpectrumBandIndices ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, uint32_t subcarrierSpacing, HeRu::SubcarrierRange subcarrierRange, uint8_t bandIndex=0)
static SubcarrierGroup GetSubcarrierGroup(uint16_t bw, RuType ruType, std::size_t phyIndex)
Get the subcarrier group of the RU having the given PHY index among all the RUs of the given type (nu...
static std::size_t GetNRus(uint16_t bw, RuType ruType)
Get the number of distinct RUs of the given type (number of tones) available in a HE PPDU of the give...
std::vector< SubcarrierRange > SubcarrierGroup
a vector of subcarrier ranges defining a subcarrier group
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
RuType
The different HE Resource Unit (RU) types.
handles interference calculations
std::map< FrequencyRange, bool > m_rxing
flag whether it is in receiving state for a given FrequencyRange
Helper class used to assign positions and mobility models to nodes.
keep track of a set of node pointers.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void Dispose()
Dispose of this Object.
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6 Mbps.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
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 EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Make it easy to create and manage PHY objects for the spectrum model.
void ResetPhyToFreqRangeMapping()
Reset mapping of the spectrum PHY interfaces added to the PHY instances.
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
void AddPhyToFreqRangeMapping(uint8_t linkId, const FrequencyRange &freqRange)
Add a given spectrum PHY interface to the PHY instance corresponding of a given link.
void SetDevice(const Ptr< WifiNetDevice > device) override
Sets the device this PHY is associated with.
void StartRx(Ptr< SpectrumSignalParameters > rxParams, Ptr< const WifiSpectrumPhyInterface > interface)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
Attach a SpectrumChannel to use for a given frequency range.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const override
WifiSpectrumBandInfo GetBand(uint16_t bandWidth, uint8_t bandIndex=0) override
Get the info of a given band.
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.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
helps to create WifiNetDevice objects
virtual void SetStandard(WifiStandard standard)
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
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)
void SetInterferenceHelper(std::string type, Args &&... args)
Helper function used to set the interference helper.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument.
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
uint32_t GetSubcarrierSpacing() const
void SetReceiveErrorCallback(RxErrorCallback callback)
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
void RegisterListener(const std::shared_ptr< WifiPhyListener > &listener)
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying an operating channel.
virtual WifiSpectrumBandInfo GetBand(uint16_t bandWidth, uint8_t bandIndex=0)=0
Get the info of a given band.
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
void SetReceiveOkCallback(RxOkCallback callback)
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
receive notifications about PHY events.
Class that keeps track of all information about the current PHY operating channel.
static ConstIterator FindFirst(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band, ConstIterator start=m_frequencyChannels.begin())
Find the first channel matching the specified parameters.
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM (802.11a/g).
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,...
#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.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal 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.
WifiPhyBand
Identifies the PHY band.
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WIFI_SPECTRUM_6_GHZ
Identifier for the frequency range covering the wifi spectrum in the 6 GHz band.
double RatioToDb(double ratio)
Convert from ratio to dB.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double WToDbm(double w)
Convert from Watts to dBm.
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...
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
std::map< WifiSpectrumBandInfo, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.
static const uint8_t CHANNEL_NUMBER
static SpectrumWifiPhyTestSuite spectrumWifiPhyTestSuite
the test suite
static const uint16_t GUARD_WIDTH
static const uint16_t CHANNEL_WIDTH
Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
uint16_t maxFrequency
the maximum frequency in MHz
uint16_t minFrequency
the minimum frequency in MHz
RxSignalInfo structure containing info on the received signal.
WifiSpectrumBandInfo structure containing info about a spectrum band.