20 #include "ns3/ampdu-tag.h"
21 #include "ns3/ap-wifi-mac.h"
22 #include "ns3/boolean.h"
23 #include "ns3/config.h"
24 #include "ns3/double.h"
25 #include "ns3/he-phy.h"
26 #include "ns3/he-ppdu.h"
27 #include "ns3/interference-helper.h"
29 #include "ns3/mobility-helper.h"
30 #include "ns3/mpdu-aggregator.h"
31 #include "ns3/multi-model-spectrum-channel.h"
32 #include "ns3/nist-error-rate-model.h"
33 #include "ns3/packet-socket-address.h"
34 #include "ns3/packet-socket-client.h"
35 #include "ns3/packet-socket-helper.h"
36 #include "ns3/packet-socket-server.h"
37 #include "ns3/pointer.h"
38 #include "ns3/rng-seed-manager.h"
39 #include "ns3/simple-frame-capture-model.h"
40 #include "ns3/single-model-spectrum-channel.h"
41 #include "ns3/spectrum-wifi-helper.h"
42 #include "ns3/spectrum-wifi-phy.h"
44 #include "ns3/threshold-preamble-detection-model.h"
45 #include "ns3/wifi-bandwidth-filter.h"
46 #include "ns3/wifi-mac-header.h"
47 #include "ns3/wifi-mpdu.h"
48 #include "ns3/wifi-net-device.h"
49 #include "ns3/wifi-psdu.h"
50 #include "ns3/wifi-spectrum-phy-interface.h"
51 #include "ns3/wifi-spectrum-signal-parameters.h"
52 #include "ns3/wifi-spectrum-value-helper.h"
53 #include "ns3/wifi-utils.h"
88 void DoSetup()
override;
89 void DoTeardown()
override;
138 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
FREQUENCY,
144 txParams->psd = txPowerSpectrum;
145 txParams->txPhy =
nullptr;
146 txParams->duration = txDuration;
147 txParams->ppdu = ppdu;
167 currentState = state->GetState();
171 "PHY State " << currentState <<
" does not match expected state "
181 m_phy = CreateObject<SpectrumWifiPhy>();
225 std::vector<bool> statusPerMpdu);
235 void DoRun()
override;
242 void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
248 "Threshold preamble detection model test when no frame capture model is applied")
254 uint32_t expectedFailureCount)
257 expectedSuccessCount,
258 "Didn't receive right number of successful packets");
260 expectedFailureCount,
261 "Didn't receive right number of unsuccessful packets");
268 std::vector<bool> statusPerMpdu)
292 CreateObject<ThresholdPreambleDetectionModel>();
293 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(4));
294 preambleDetectionModel->SetAttribute(
"MinimumRssi",
DoubleValue(-82));
301 RngSeedManager::SetSeed(1);
302 RngSeedManager::SetRun(1);
303 int64_t streamNumber = 0;
307 double rxPowerDbm = -50;
313 Simulator::Schedule(
Seconds(1.0),
349 Simulator::Schedule(
Seconds(1.1),
361 Simulator::Schedule(
Seconds(2.0),
395 Simulator::Schedule(
Seconds(2.1),
407 Simulator::Schedule(
Seconds(3.0),
441 Simulator::Schedule(
Seconds(3.1),
452 Simulator::Schedule(
Seconds(4.0),
504 Simulator::Schedule(
Seconds(4.1),
516 Simulator::Schedule(
Seconds(5.0),
550 Simulator::Schedule(
Seconds(5.1),
563 Simulator::Schedule(
Seconds(6.0),
599 Simulator::Schedule(
Seconds(6.1),
611 Simulator::Schedule(
Seconds(7.0),
630 Simulator::Schedule(
Seconds(7.1),
643 Simulator::Schedule(
Seconds(8.0),
662 Simulator::Schedule(
Seconds(8.1),
673 Simulator::Schedule(
Seconds(9.0),
716 Simulator::Schedule(
Seconds(9.1),
727 Simulator::Schedule(
Seconds(10.0),
746 Simulator::Schedule(
Seconds(10.1),
758 Simulator::Schedule(
Seconds(11.0),
801 Simulator::Schedule(
Seconds(12.0),
814 Simulator::Destroy();
841 std::vector<bool> statusPerMpdu);
851 void DoRun()
override;
858 void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
863 "Threshold preamble detection model test when simple frame capture model is applied")
869 uint32_t expectedFailureCount)
872 expectedSuccessCount,
873 "Didn't receive right number of successful packets");
875 expectedFailureCount,
876 "Didn't receive right number of unsuccessful packets");
883 std::vector<bool> statusPerMpdu)
907 CreateObject<ThresholdPreambleDetectionModel>();
908 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(4));
909 preambleDetectionModel->SetAttribute(
"MinimumRssi",
DoubleValue(-82));
913 frameCaptureModel->SetAttribute(
"Margin",
DoubleValue(5));
921 RngSeedManager::SetSeed(1);
922 RngSeedManager::SetRun(1);
923 int64_t streamNumber = 1;
927 double rxPowerDbm = -50;
933 Simulator::Schedule(
Seconds(1.0),
969 Simulator::Schedule(
Seconds(1.1),
981 Simulator::Schedule(
Seconds(2.0),
1015 Simulator::Schedule(
Seconds(2.1),
1027 Simulator::Schedule(
Seconds(3.0),
1061 Simulator::Schedule(
Seconds(3.1),
1072 Simulator::Schedule(
Seconds(4.0),
1124 Simulator::Schedule(
Seconds(4.1),
1136 Simulator::Schedule(
Seconds(5.0),
1174 Simulator::Schedule(
Seconds(5.1),
1186 Simulator::Schedule(
Seconds(6.0),
1234 Simulator::Schedule(
Seconds(6.1),
1246 Simulator::Schedule(
Seconds(7.0),
1252 Simulator::Schedule(
Seconds(7.0),
1280 Simulator::Schedule(
Seconds(7.1),
1292 Simulator::Schedule(
Seconds(8.0),
1298 Simulator::Schedule(
Seconds(8.0),
1325 Simulator::Schedule(
Seconds(8.1),
1336 Simulator::Schedule(
Seconds(9.0),
1342 Simulator::Schedule(
Seconds(9.0),
1378 Simulator::Schedule(
Seconds(9.1),
1390 Simulator::Schedule(
Seconds(10.0),
1396 Simulator::Schedule(
Seconds(10.0),
1423 Simulator::Schedule(
Seconds(10.1),
1435 Simulator::Schedule(
Seconds(11.0),
1441 Simulator::Schedule(
Seconds(11.0),
1477 Simulator::Schedule(
Seconds(11.1),
1490 Simulator::Schedule(
Seconds(12.0),
1526 Simulator::Schedule(
Seconds(12.1),
1538 Simulator::Schedule(
Seconds(13.0),
1557 Simulator::Schedule(
Seconds(13.1),
1570 Simulator::Schedule(
Seconds(14.0),
1589 Simulator::Schedule(
Seconds(14.1),
1600 Simulator::Schedule(
Seconds(15.0),
1643 Simulator::Schedule(
Seconds(15.1),
1656 Simulator::Schedule(
Seconds(16.0),
1680 Simulator::Schedule(
Seconds(16.1),
1692 Simulator::Schedule(
Seconds(17.0),
1740 Simulator::Schedule(
Seconds(17.1),
1749 Simulator::Schedule(
Seconds(18.0),
1762 Simulator::Schedule(
Seconds(18.1),
1770 Simulator::Schedule(
Seconds(19.0),
1783 Simulator::Schedule(
Seconds(19.1),
1791 Simulator::Schedule(
Seconds(20.0),
1797 Simulator::Schedule(
Seconds(20.0),
1804 Simulator::Schedule(
Seconds(20.1),
1812 Simulator::Schedule(
Seconds(21.0),
1818 Simulator::Schedule(
Seconds(21.0),
1826 Simulator::Schedule(
Seconds(21.1),
1833 Simulator::Destroy();
1849 void DoRun()
override;
1865 std::vector<bool> statusPerMpdu);
1905 std::vector<bool> statusPerMpdu)
1913 else if (psdu->
GetSize() == 1530)
1927 else if (p->
GetSize() == 1530)
1976 CreateObject<ThresholdPreambleDetectionModel>();
1977 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(2));
1981 frameCaptureModel->SetAttribute(
"Margin",
DoubleValue(5));
1989 RngSeedManager::SetSeed(1);
1990 RngSeedManager::SetRun(1);
1991 int64_t streamNumber = 2;
1992 double rxPowerDbm = -30;
1998 Simulator::Schedule(
Seconds(1.0),
2016 Simulator::Schedule(
Seconds(2.0),
2028 Simulator::Schedule(
Seconds(2.1),
2037 Simulator::Schedule(
Seconds(3.0),
2050 Simulator::Schedule(
Seconds(3.1),
2059 Simulator::Schedule(
Seconds(4.0),
2075 Simulator::Destroy();
2090 void DoRun()
override;
2101 RngSeedManager::SetSeed(1);
2102 RngSeedManager::SetRun(1);
2103 int64_t streamNumber = 0;
2107 double rxPowerDbm = -50;
2113 Simulator::Schedule(
Seconds(1.0),
2151 Simulator::Schedule(
Seconds(2.0),
2202 Simulator::Schedule(
Seconds(3.0),
2243 Simulator::Schedule(
Seconds(4.0),
2297 Simulator::Schedule(
Seconds(5.0),
2325 Simulator::Schedule(
Seconds(6.0),
2373 Simulator::Schedule(
Seconds(7.0),
2412 Simulator::Schedule(
Seconds(8.0),
2457 Simulator::Destroy();
2473 void DoRun()
override;
2485 std::vector<bool> statusPerMpdu);
2589 std::vector<bool> statusPerMpdu)
2592 if (statusPerMpdu.empty())
2597 "Should have one receive status per MPDU");
2598 auto rxOkForMpdu = statusPerMpdu.begin();
2599 for (
auto mpdu = psdu->
begin(); mpdu != psdu->
end(); ++mpdu)
2620 else if (size == 1130)
2624 else if (size == 1230)
2628 else if (size == 1330)
2632 else if (size == 1430)
2636 else if (size == 1530)
2646 for (
auto mpdu = psdu->
begin(); mpdu != psdu->
end(); ++mpdu)
2659 else if (size == 1130)
2663 else if (size == 1230)
2667 else if (size == 1330)
2671 else if (size == 1430)
2675 else if (size == 1530)
2689 else if (p->
GetSize() == 1130)
2693 else if (p->
GetSize() == 1230)
2697 else if (p->
GetSize() == 1330)
2701 else if (p->
GetSize() == 1430)
2705 else if (p->
GetSize() == 1530)
2716 "RX success bitmap for A-MPDU 1 is not as expected");
2724 "RX success bitmap for A-MPDU 2 is not as expected");
2732 "RX failure bitmap for A-MPDU 1 is not as expected");
2740 "RX failure bitmap for A-MPDU 2 is not as expected");
2748 "RX dropped bitmap for A-MPDU 1 is not as expected");
2756 "RX dropped bitmap for A-MPDU 2 is not as expected");
2766 currentState = state->GetState();
2769 "PHY State " << currentState <<
" does not match expected state "
2783 std::vector<Ptr<WifiMpdu>> mpduList;
2784 for (
size_t i = 0; i < 3; ++i)
2786 Ptr<Packet> p = Create<Packet>(referencePacketSize + i * 100);
2787 mpduList.push_back(Create<WifiMpdu>(p, hdr));
2797 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
FREQUENCY,
2803 txParams->psd = txPowerSpectrum;
2804 txParams->txPhy =
nullptr;
2805 txParams->duration = txDuration;
2806 txParams->ppdu = ppdu;
2822 CreateObject<ThresholdPreambleDetectionModel>();
2823 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(2));
2827 frameCaptureModel->SetAttribute(
"Margin",
DoubleValue(5));
2835 RngSeedManager::SetSeed(1);
2836 RngSeedManager::SetRun(2);
2837 int64_t streamNumber = 1;
2838 double rxPowerDbm = -30;
2848 Simulator::Schedule(
Seconds(1.0),
2862 Simulator::Schedule(
Seconds(1.1),
2866 Simulator::Schedule(
Seconds(1.1),
2870 Simulator::Schedule(
Seconds(1.1),
2876 Simulator::Schedule(
Seconds(1.1),
2880 Simulator::Schedule(
Seconds(1.1),
2884 Simulator::Schedule(
Seconds(1.1),
2898 Simulator::Schedule(
Seconds(2.0),
2912 Simulator::Schedule(
Seconds(2.1),
2916 Simulator::Schedule(
Seconds(2.1),
2920 Simulator::Schedule(
Seconds(2.1),
2926 Simulator::Schedule(
Seconds(2.1),
2930 Simulator::Schedule(
Seconds(2.1),
2934 Simulator::Schedule(
Seconds(2.1),
2948 Simulator::Schedule(
Seconds(3.0),
2962 Simulator::Schedule(
Seconds(3.1),
2966 Simulator::Schedule(
Seconds(3.1),
2970 Simulator::Schedule(
Seconds(3.1),
2976 Simulator::Schedule(
Seconds(3.1),
2980 Simulator::Schedule(
Seconds(3.1),
2984 Simulator::Schedule(
Seconds(3.1),
2998 Simulator::Schedule(
Seconds(4.0),
3012 Simulator::Schedule(
Seconds(4.1),
3016 Simulator::Schedule(
Seconds(4.1),
3020 Simulator::Schedule(
Seconds(4.1),
3026 Simulator::Schedule(
Seconds(4.1),
3030 Simulator::Schedule(
Seconds(4.1),
3034 Simulator::Schedule(
Seconds(4.1),
3048 Simulator::Schedule(
Seconds(5.0),
3062 Simulator::Schedule(
Seconds(5.1),
3066 Simulator::Schedule(
Seconds(5.1),
3070 Simulator::Schedule(
Seconds(5.1),
3076 Simulator::Schedule(
Seconds(5.1),
3080 Simulator::Schedule(
Seconds(5.1),
3084 Simulator::Schedule(
Seconds(5.1),
3098 Simulator::Schedule(
Seconds(6.0),
3112 Simulator::Schedule(
Seconds(6.1),
3116 Simulator::Schedule(
Seconds(6.1),
3120 Simulator::Schedule(
Seconds(6.1),
3126 Simulator::Schedule(
Seconds(6.1),
3130 Simulator::Schedule(
Seconds(6.1),
3134 Simulator::Schedule(
Seconds(6.1),
3147 Simulator::Schedule(
Seconds(7.0),
3161 Simulator::Schedule(
Seconds(7.1),
3165 Simulator::Schedule(
Seconds(7.1),
3169 Simulator::Schedule(
Seconds(7.1),
3175 Simulator::Schedule(
Seconds(7.1),
3179 Simulator::Schedule(
Seconds(7.1),
3183 Simulator::Schedule(
Seconds(7.1),
3196 Simulator::Schedule(
Seconds(8.0),
3210 Simulator::Schedule(
Seconds(8.1),
3214 Simulator::Schedule(
Seconds(8.1),
3218 Simulator::Schedule(
Seconds(8.1),
3224 Simulator::Schedule(
Seconds(8.1),
3228 Simulator::Schedule(
Seconds(8.1),
3232 Simulator::Schedule(
Seconds(8.1),
3246 Simulator::Schedule(
Seconds(9.0),
3260 Simulator::Schedule(
Seconds(9.1),
3264 Simulator::Schedule(
Seconds(9.1),
3268 Simulator::Schedule(
Seconds(9.1),
3274 Simulator::Schedule(
Seconds(9.1),
3278 Simulator::Schedule(
Seconds(9.1),
3282 Simulator::Schedule(
Seconds(9.1),
3296 Simulator::Schedule(
Seconds(10.0),
3310 Simulator::Schedule(
Seconds(10.1),
3314 Simulator::Schedule(
Seconds(10.1),
3318 Simulator::Schedule(
Seconds(10.1),
3324 Simulator::Schedule(
Seconds(10.1),
3328 Simulator::Schedule(
Seconds(10.1),
3332 Simulator::Schedule(
Seconds(10.1),
3346 Simulator::Schedule(
Seconds(11.0),
3360 Simulator::Schedule(
Seconds(11.1),
3364 Simulator::Schedule(
Seconds(11.1),
3368 Simulator::Schedule(
Seconds(11.1),
3374 Simulator::Schedule(
Seconds(11.1),
3378 Simulator::Schedule(
Seconds(11.1),
3382 Simulator::Schedule(
Seconds(11.1),
3396 Simulator::Schedule(
Seconds(12.0),
3411 Simulator::Schedule(
Seconds(12.1),
3415 Simulator::Schedule(
Seconds(12.1),
3419 Simulator::Schedule(
Seconds(12.1),
3426 Simulator::Schedule(
Seconds(12.1),
3430 Simulator::Schedule(
Seconds(12.1),
3434 Simulator::Schedule(
Seconds(12.1),
3448 Simulator::Schedule(
Seconds(13.0),
3463 Simulator::Schedule(
Seconds(13.1),
3467 Simulator::Schedule(
Seconds(13.1),
3471 Simulator::Schedule(
Seconds(13.1),
3477 Simulator::Schedule(
Seconds(13.1),
3481 Simulator::Schedule(
Seconds(13.1),
3485 Simulator::Schedule(
Seconds(13.1),
3499 Simulator::Schedule(
Seconds(14.0),
3513 Simulator::Schedule(
Seconds(14.1),
3517 Simulator::Schedule(
Seconds(14.1),
3521 Simulator::Schedule(
Seconds(14.1),
3527 Simulator::Schedule(
Seconds(14.1),
3531 Simulator::Schedule(
Seconds(14.1),
3535 Simulator::Schedule(
Seconds(14.1),
3549 Simulator::Schedule(
Seconds(15.0),
3563 Simulator::Schedule(
Seconds(15.1),
3567 Simulator::Schedule(
Seconds(15.1),
3571 Simulator::Schedule(
Seconds(15.1),
3577 Simulator::Schedule(
Seconds(15.1),
3581 Simulator::Schedule(
Seconds(15.1),
3585 Simulator::Schedule(
Seconds(15.1),
3599 Simulator::Schedule(
Seconds(16.0),
3613 Simulator::Schedule(
Seconds(16.1),
3617 Simulator::Schedule(
Seconds(16.1),
3621 Simulator::Schedule(
Seconds(16.1),
3627 Simulator::Schedule(
Seconds(16.1),
3631 Simulator::Schedule(
Seconds(16.1),
3635 Simulator::Schedule(
Seconds(16.1),
3649 Simulator::Schedule(
Seconds(17.0),
3663 Simulator::Schedule(
Seconds(17.1),
3667 Simulator::Schedule(
Seconds(17.1),
3671 Simulator::Schedule(
Seconds(17.1),
3678 Simulator::Schedule(
Seconds(17.1),
3682 Simulator::Schedule(
Seconds(17.1),
3686 Simulator::Schedule(
Seconds(17.1),
3700 Simulator::Schedule(
Seconds(18.0),
3714 Simulator::Schedule(
Seconds(18.1),
3718 Simulator::Schedule(
Seconds(18.1),
3722 Simulator::Schedule(
Seconds(18.1),
3728 Simulator::Schedule(
Seconds(18.1),
3732 Simulator::Schedule(
Seconds(18.1),
3736 Simulator::Schedule(
Seconds(18.1),
3750 Simulator::Schedule(
Seconds(19.0),
3764 Simulator::Schedule(
Seconds(19.1),
3768 Simulator::Schedule(
Seconds(19.1),
3772 Simulator::Schedule(
Seconds(19.1),
3778 Simulator::Schedule(
Seconds(19.1),
3782 Simulator::Schedule(
Seconds(19.1),
3786 Simulator::Schedule(
Seconds(19.1),
3800 Simulator::Schedule(
Seconds(20.0),
3814 Simulator::Schedule(
Seconds(20.1),
3818 Simulator::Schedule(
Seconds(20.1),
3822 Simulator::Schedule(
Seconds(20.1),
3829 Simulator::Schedule(
Seconds(20.1),
3833 Simulator::Schedule(
Seconds(20.1),
3837 Simulator::Schedule(
Seconds(20.1),
3851 Simulator::Schedule(
Seconds(21.0),
3865 Simulator::Schedule(
Seconds(21.1),
3869 Simulator::Schedule(
Seconds(21.1),
3873 Simulator::Schedule(
Seconds(21.1),
3879 Simulator::Schedule(
Seconds(21.1),
3883 Simulator::Schedule(
Seconds(21.1),
3887 Simulator::Schedule(
Seconds(21.1),
3901 Simulator::Schedule(
Seconds(22.0),
3915 Simulator::Schedule(
Seconds(22.1),
3919 Simulator::Schedule(
Seconds(22.1),
3923 Simulator::Schedule(
Seconds(22.1),
3929 Simulator::Schedule(
Seconds(22.1),
3933 Simulator::Schedule(
Seconds(22.1),
3937 Simulator::Schedule(
Seconds(22.1),
3950 Simulator::Schedule(
Seconds(23.0),
3965 Simulator::Schedule(
Seconds(23.1),
3969 Simulator::Schedule(
Seconds(23.1),
3973 Simulator::Schedule(
Seconds(23.1),
3981 Simulator::Schedule(
Seconds(23.1),
3985 Simulator::Schedule(
Seconds(23.1),
3989 Simulator::Schedule(
Seconds(23.1),
3997 Simulator::Destroy();
4027 void DoRun()
override;
4045 :
TestCase(
"Check correct behavior when a STA is receiving a transmission using an unsupported "
4056 if (reason ==
RXING)
4058 std::cout <<
"Dropped a packet because already receiving" << std::endl;
4066 uint16_t m_nStations = 2;
4070 int64_t streamNumber = 100;
4080 spectrumChannel->AddPropagationLossModel(lossModel);
4082 CreateObject<ConstantSpeedPropagationDelayModel>();
4083 spectrumChannel->SetPropagationDelayModel(delayModel);
4086 phy.SetChannel(spectrumChannel);
4091 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
4094 mac.SetType(
"ns3::StaWifiMac",
4098 SsidValue(
Ssid(
"non-existent-ssid")));
4106 mac.SetType(
"ns3::ApWifiMac",
4110 SsidValue(
Ssid(
"wifi-backoff-ssid")),
4113 "EnableBeaconJitter",
4122 for (uint16_t i = 0; i < m_nStations; i++)
4124 dev = DynamicCast<WifiNetDevice>(m_staDevices.
Get(i));
4128 Ssid(
"wifi-backoff-ssid"));
4132 wifi.AssignStreams(m_apDevices, streamNumber);
4137 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
4138 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
4139 positionAlloc->Add(Vector(0.0, 1.0, 0.0));
4140 positionAlloc->Add(Vector(-1.0, 0.0, 0.0));
4141 mobility.SetPositionAllocator(positionAlloc);
4143 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
4148 dev = DynamicCast<WifiNetDevice>(m_apDevices.
Get(0));
4157 for (uint16_t i = 0; i < m_nStations; i++)
4167 client->SetRemote(socket);
4172 legacyStaClient->SetAttribute(
"PacketSize",
UintegerValue(1500));
4173 legacyStaClient->SetAttribute(
"MaxPackets",
UintegerValue(200));
4175 legacyStaClient->SetRemote(socket);
4178 legacyStaClient->SetStopTime(
Seconds(1.0));
4180 server->SetLocal(socket);
4187 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
4195 Simulator::Destroy();
4223 void DoRun()
override;
4231 void SendPpdu(uint16_t centerFreqMhz, uint16_t bandwidthMhz);
4243 std::vector<bool> statusPerMpdu);
4269 void CheckRx(uint32_t expectedCountRxSuccess,
4270 uint32_t expectedCountRxFailure,
4271 uint32_t expectedCountRxDropped,
4272 std::optional<Time> expectedLastRxSucceeded,
4273 std::optional<Time> expectedLastRxFailed,
4274 std::optional<Time> expectedLastRxDropped);
4289 :
TestCase(
"Check correct behavior when a STA is receiving a transmission using an unsupported "
4291 m_countRxSuccess(0),
4292 m_countRxFailure(0),
4293 m_countRxDropped(0),
4294 m_lastRxSucceeded(std::nullopt),
4295 m_lastRxFailed(std::nullopt),
4296 m_lastRxDropped(std::nullopt)
4306 auto pkt = Create<Packet>(1000);
4318 auto txPowerSpectrum =
4319 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(centerFreqMhz,
4324 auto txParams = Create<WifiSpectrumSignalParameters>();
4325 txParams->psd = txPowerSpectrum;
4326 txParams->txPhy =
nullptr;
4327 txParams->duration = txDuration;
4328 txParams->ppdu = ppdu;
4337 std::vector<bool> statusPerMpdu)
4363 uint32_t expectedCountRxFailure,
4364 uint32_t expectedCountRxDropped,
4365 std::optional<Time> expectedLastRxSucceeded,
4366 std::optional<Time> expectedLastRxFailed,
4367 std::optional<Time> expectedLastRxDropped)
4370 expectedCountRxSuccess,
4371 "Didn't receive right number of successful packets");
4374 expectedCountRxFailure,
4375 "Didn't receive right number of unsuccessful packets");
4378 expectedCountRxDropped,
4379 "Didn't receive right number of dropped packets");
4381 if (expectedCountRxSuccess > 0)
4384 NS_ASSERT(expectedLastRxSucceeded.has_value());
4386 expectedLastRxSucceeded.value(),
4387 "Didn't receive the last successful packet at the expected time");
4390 if (expectedCountRxFailure > 0)
4393 NS_ASSERT(expectedLastRxFailed.has_value());
4395 expectedLastRxFailed.value(),
4396 "Didn't receive the last unsuccessful packet at the expected time");
4399 if (expectedCountRxDropped > 0)
4402 NS_ASSERT(expectedLastRxDropped.has_value());
4404 expectedLastRxDropped.value(),
4405 "Didn't drop the last filtered packet at the expected time");
4415 m_rxPhy = CreateObject<SpectrumWifiPhy>();
4416 auto rxInterferenceHelper = CreateObject<InterferenceHelper>();
4418 auto rxErrorRateModel = CreateObject<NistErrorRateModel>();
4434 m_txPhy = CreateObject<SpectrumWifiPhy>();
4435 auto txInterferenceHelper = CreateObject<InterferenceHelper>();
4437 auto txErrorRateModel = CreateObject<NistErrorRateModel>();
4456 RngSeedManager::SetSeed(1);
4457 RngSeedManager::SetRun(1);
4459 int64_t streamNumber = 0;
4472 Simulator::Schedule(
Seconds(1.5),
4480 heSigAExpectedRxTime);
4485 Simulator::Destroy();
4503 void DoRun()
override;
4527 uint16_t phyCenterFreqMhz,
4529 uint16_t ppduCenterFreqMhz,
4530 bool expectedP20Overlap,
4531 bool expectedP20Covered);
4538 :
TestCase(
"Check correct detection of whether P20 is fully covered (hence it can be received) "
4539 "or overlaps with the bandwidth of an incoming PPDU")
4546 [[maybe_unused]]
auto [channelNumber, centerFreq, channelWidth,
type, phyBand] =
4547 (*WifiPhyOperatingChannel::FindFirst(0,
4556 auto pkt = Create<Packet>(1000);
4559 auto psdu = Create<WifiPsdu>(pkt, hdr);
4568 m_rxPhy = CreateObject<SpectrumWifiPhy>();
4569 auto rxInterferenceHelper = CreateObject<InterferenceHelper>();
4571 auto rxErrorRateModel = CreateObject<NistErrorRateModel>();
4576 m_txPhy = CreateObject<SpectrumWifiPhy>();
4577 auto txInterferenceHelper = CreateObject<InterferenceHelper>();
4579 auto txErrorRateModel = CreateObject<NistErrorRateModel>();
4596 uint16_t phyCenterFreqMhz,
4598 uint16_t ppduCenterFreqMhz,
4599 bool expectedP20Overlap,
4600 bool expectedP20Covered)
4602 [[maybe_unused]]
const auto [channelNumber, centerFreq, channelWidth,
type, phyBand] =
4608 auto p20MinFreq = p20CenterFreq - 10;
4609 auto p20MaxFreq = p20CenterFreq + 10;
4613 auto p20Overlap = ppdu->DoesOverlapChannel(p20MinFreq, p20MaxFreq);
4616 "PPDU is " << (expectedP20Overlap ?
"expected" :
"not expected")
4617 <<
" to overlap with the P20");
4623 "PPDU is " << (expectedP20Covered ?
"expected" :
"not expected")
4624 <<
" to cover the whole P20");
4678 Simulator::Destroy();
4714 void RxBegin(
bool signalType, uint32_t senderNodeId,
double rxPower,
Time duration);
4728 void DoRun()
override;
4739 uint16_t expectedValue)
4740 :
TestCase(
"Test for early discard of signal in single-model-spectrum-channel::StartTx()"),
4742 m_expectedValue(expectedValue)
4767 "Received a different amount of packets than expected.");
4772 uint32_t senderNodeId [[maybe_unused]],
4773 double rxPower [[maybe_unused]],
4774 Time duration [[maybe_unused]])
4776 NS_LOG_FUNCTION(
this << signalType << senderNodeId << rxPower << duration);
4787 channel->AddSpectrumTransmitFilter(wifiFilter);
4791 m_tx = CreateObject<SpectrumWifiPhy>();
4796 Ptr<Node> nodeRx = CreateObject<Node>();
4798 m_rx = CreateObject<SpectrumWifiPhy>();
4848 Simulator::Destroy();
void RxSuccess(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.
void IncrementSuccessBitmap(uint32_t size)
Increment reception success bitmap.
uint8_t m_rxDroppedBitmapAmpdu2
bitmap of dropped MPDUs in A-MPDU #2
void CheckRxSuccessBitmapAmpdu2(uint8_t expected)
Check the RX success bitmap for A-MPDU 2.
void DoRun() override
Implementation to actually run this TestCase.
void CheckRxDroppedBitmapAmpdu1(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 1.
uint8_t m_rxSuccessBitmapAmpdu1
bitmap of successfully received MPDUs in A-MPDU #1
uint8_t m_rxFailureBitmapAmpdu1
bitmap of unsuccessfully received MPDUs in A-MPDU #1
uint8_t m_rxFailureBitmapAmpdu2
bitmap of unsuccessfully received MPDUs in A-MPDU #2
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
void SendAmpduWithThreeMpdus(double rxPowerDbm, uint32_t referencePacketSize)
Send A-MPDU with 3 MPDUs of different size (i-th MSDU will have 100 bytes more than (i-1)-th).
void RxFailure(Ptr< const WifiPsdu > psdu)
RX failure function.
void CheckRxFailureBitmapAmpdu2(uint8_t expected)
Check the RX failure bitmap for A-MPDU 2.
uint8_t m_rxDroppedBitmapAmpdu1
bitmap of dropped MPDUs in A-MPDU #1
void IncrementFailureBitmap(uint32_t size)
Increment reception failure bitmap.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void ResetBitmaps()
Reset bitmaps function.
void CheckPhyState(WifiPhyState expectedState)
Check the PHY state.
void CheckRxSuccessBitmapAmpdu1(uint8_t expected)
Check the RX success bitmap for A-MPDU 1.
void CheckRxFailureBitmapAmpdu1(uint8_t expected)
Check the RX failure bitmap for A-MPDU 1.
uint8_t m_rxSuccessBitmapAmpdu2
bitmap of successfully received MPDUs in A-MPDU #2
void CheckRxDroppedBitmapAmpdu2(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 2.
Primary 20 MHz Covered By Ppdu Test This test checks whether the functions WifiPpdu::DoesOverlapChann...
Ptr< SpectrumWifiPhy > m_rxPhy
RX PHY.
void RunOne(WifiPhyBand band, uint16_t phyCenterFreqMhz, uint8_t p20Index, uint16_t ppduCenterFreqMhz, bool expectedP20Overlap, bool expectedP20Covered)
Run one function.
TestPrimary20CoveredByPpdu()
Ptr< HePpdu > CreatePpdu(uint16_t ppduCenterFreqMhz)
Function to create a PPDU.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Ptr< SpectrumWifiPhy > m_txPhy
TX PHY.
Simple frame capture model test.
void Expect1000BPacketReceived()
Verify whether 1000 bytes packet has been received.
bool m_rxDropped1500B
count dropped packets with 1500B payload
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void Expect1500BPacketDropped()
Verify whether 1500 bytes packet has been dropped.
void Expect1000BPacketDropped()
Verify whether 1000 bytes packet has been dropped.
void Reset()
Reset function.
void RxSuccess(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
void DoRun() override
Implementation to actually run this TestCase.
bool m_rxSuccess1000B
count received packets with 1000B payload
bool m_rxSuccess1500B
count received packets with 1500B payload
void Expect1500BPacketReceived()
Verify whether 1500 bytes packet has been received.
TestSimpleFrameCaptureModel()
bool m_rxDropped1000B
count dropped packets with 1000B payload
This test verifies the correct function of the WifiBandwidthFilter.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
uint16_t m_expectedValue
expected count of receive events
void Send() const
Send function (sends a single packet)
TestSpectrumChannelWithBandwidthFilter(uint16_t channel, uint16_t expectedValue)
Constructor.
Ptr< SpectrumWifiPhy > m_tx
transmit function
Ptr< SpectrumWifiPhy > m_rx
receive function
void RxBegin(bool signalType, uint32_t senderNodeId, double rxPower, Time duration)
Callback invoked when the PHY model starts to process a signal.
void DoRun() override
Implementation to actually run this TestCase.
void CheckRxPacketCount(uint16_t expectedValue)
Event scheduled at end of simulation for validation.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
uint16_t m_channel
channel for packet transmission
uint32_t m_countRxBegin
count of receive events
Preamble detection test w/o frame capture.
TestThresholdPreambleDetectionWithFrameCapture()
void RxFailure(Ptr< const WifiPsdu > psdu)
Spectrum wifi receive failure function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxSuccess
count RX success
void RxSuccess(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_countRxFailure
count RX failure
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
Preamble detection test w/o frame capture.
void DoRun() override
Implementation to actually run this TestCase.
TestThresholdPreambleDetectionWithoutFrameCapture()
void RxSuccess(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
uint32_t m_countRxFailure
count RX failure
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxSuccess
count RX success
void RxFailure(Ptr< const WifiPsdu > psdu)
Spectrum wifi receive failure function.
Unsupported Bandwidth Reception Test This test checks whether a PHY receiving a PPDU sent over a chan...
uint32_t m_countRxSuccess
count RX success
void DoSetup() override
Implementation to do any local setup required for this TestCase.
Ptr< SpectrumWifiPhy > m_rxPhy
RX PHY.
TestUnsupportedBandwidthReception()
std::optional< Time > m_lastRxDropped
time of last RX drop, if any
Ptr< SpectrumWifiPhy > m_txPhy
TX PHY.
std::optional< Time > m_lastRxSucceeded
time of last RX success, if any
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void SendPpdu(uint16_t centerFreqMhz, uint16_t bandwidthMhz)
Function to create a PPDU.
uint32_t m_countRxFailure
count RX failure
void CheckRx(uint32_t expectedCountRxSuccess, uint32_t expectedCountRxFailure, uint32_t expectedCountRxDropped, std::optional< Time > expectedLastRxSucceeded, std::optional< Time > expectedLastRxFailed, std::optional< Time > expectedLastRxDropped)
Check the reception results.
void RxFailure(Ptr< const WifiPsdu > psdu)
Function called upon a PSDU received unsuccessfuly.
void RxSuccess(Ptr< const WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Function called upon a PSDU received successfully.
void DoRun() override
Implementation to actually run this TestCase.
std::optional< Time > m_lastRxFailed
time of last RX failure, if any
void RxDropped(Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Function called upon a PSDU dropped by the PHY.
uint32_t m_countRxDropped
count RX drop
Unsupported Modulation Reception Test This test creates a mixed network, in which an HE STA and a VHT...
void DoRun() override
Implementation to actually run this TestCase.
void CheckResults()
Check correctness of transmitted frames.
void Dropped(std::string context, Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Callback invoked when PHY drops an incoming packet.
~TestUnsupportedModulationReception() override=default
TestUnsupportedModulationReception()
uint16_t m_dropped
number of packets dropped by the AP because it was already receiving
Wifi Phy Reception Test base class.
WifiPhyReceptionTest(std::string test_name)
Constructor.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
~WifiPhyReceptionTest() override=default
Destructor.
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
uint64_t m_uid
the UID to use for the PPDU
void SendPacket(double rxPowerDbm, uint32_t packetSize, uint8_t mcs)
Send packet function.
Ptr< SpectrumWifiPhy > m_phy
the PHY
void DoSetup() override
Implementation to do any local setup required for this TestCase.
wifi PHY reception Test Suite
WifiPhyReceptionTestSuite()
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
void Dispose()
Dispose of this Object.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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.
Hold objects of type Ptr<T>.
Make it easy to create and manage PHY objects for the spectrum model.
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.
The IEEE 802.11 SSID Information Element.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
Ptr< WifiMac > GetMac() const
void SetPhy(const Ptr< WifiPhy > phy)
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.
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 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.
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying an operating channel.
void SetReceiveOkCallback(RxOkCallback callback)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
This objects implements the PHY state machine of the Wifi device.
std::vector< Ptr< WifiMpdu > >::const_iterator end() const
Return a const iterator to past-the-last MPDU.
std::vector< Ptr< WifiMpdu > >::const_iterator begin() const
Return a const iterator to the first MPDU.
uint32_t GetSize() const
Return the size of the PSDU in bytes.
bool IsAggregate() const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool IsSingle() const
Return true if the PSDU is an S-MPDU.
std::size_t GetNMpdus() const
Return the number of MPDUs constituting the PSDU.
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)
void Connect(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#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 ",...
Time Now()
create an ns3::Time instance which contains the current simulation time.
#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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report 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.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPhyBand
Identifies the PHY 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.
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...
double DbmToW(double dBm)
Convert from dBm to Watts.
RxSignalInfo structure containing info on the received signal.
static const uint8_t CHANNEL_NUMBER
static const uint16_t GUARD_WIDTH
static const uint16_t CHANNEL_WIDTH
static WifiPhyReceptionTestSuite wifiPhyReceptionTestSuite
the test suite
static const uint32_t FREQUENCY
WifiPhyState
The state of the PHY layer.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ RX
The PHY layer is receiving a packet.
@ IDLE
The PHY layer is IDLE.
static const uint32_t packetSize
Packet size generated at the AP.
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...