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/spectrum-wifi-helper.h"
41 #include "ns3/spectrum-wifi-phy.h"
43 #include "ns3/threshold-preamble-detection-model.h"
44 #include "ns3/wifi-mac-header.h"
45 #include "ns3/wifi-mpdu.h"
46 #include "ns3/wifi-net-device.h"
47 #include "ns3/wifi-psdu.h"
48 #include "ns3/wifi-spectrum-signal-parameters.h"
49 #include "ns3/wifi-spectrum-value-helper.h"
50 #include "ns3/wifi-utils.h"
77 void DoSetup()
override;
78 void DoTeardown()
override;
95 std::vector<bool> statusPerMpdu);
105 void DoRun()
override;
122 void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
129 :
TestCase(
"Threshold preamble detection model test when no frame capture model is applied"),
155 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
FREQUENCY,
161 txParams->psd = txPowerSpectrum;
162 txParams->txPhy =
nullptr;
163 txParams->duration = txDuration;
164 txParams->ppdu = ppdu;
187 currentState = state->GetState();
191 "PHY State " << currentState <<
" does not match expected state "
197 uint32_t expectedFailureCount)
200 expectedSuccessCount,
201 "Didn't receive right number of successful packets");
203 expectedFailureCount,
204 "Didn't receive right number of unsuccessful packets");
211 std::vector<bool> statusPerMpdu)
233 m_phy = CreateObject<SpectrumWifiPhy>();
246 CreateObject<ThresholdPreambleDetectionModel>();
247 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(4));
248 preambleDetectionModel->SetAttribute(
"MinimumRssi",
DoubleValue(-82));
262 RngSeedManager::SetSeed(1);
263 RngSeedManager::SetRun(1);
264 int64_t streamNumber = 0;
268 double rxPowerDbm = -50;
274 Simulator::Schedule(
Seconds(1.0),
308 Simulator::Schedule(
Seconds(1.1),
320 Simulator::Schedule(
Seconds(2.0),
350 Simulator::Schedule(
Seconds(2.1),
362 Simulator::Schedule(
Seconds(3.0),
392 Simulator::Schedule(
Seconds(3.1),
403 Simulator::Schedule(
Seconds(4.0),
451 Simulator::Schedule(
Seconds(4.1),
463 Simulator::Schedule(
Seconds(5.0),
493 Simulator::Schedule(
Seconds(5.1),
506 Simulator::Schedule(
Seconds(6.0),
540 Simulator::Schedule(
Seconds(6.1),
552 Simulator::Schedule(
Seconds(7.0),
567 Simulator::Schedule(
Seconds(7.1),
580 Simulator::Schedule(
Seconds(8.0),
595 Simulator::Schedule(
Seconds(8.1),
606 Simulator::Schedule(
Seconds(9.0),
645 Simulator::Schedule(
Seconds(9.1),
656 Simulator::Schedule(
Seconds(10.0),
671 Simulator::Schedule(
Seconds(10.1),
683 Simulator::Schedule(
Seconds(11.0),
724 Simulator::Schedule(
Seconds(12.0),
735 Simulator::Destroy();
769 std::vector<bool> statusPerMpdu);
779 void DoRun()
override;
796 void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
803 "Threshold preamble detection model test when simple frame capture model is applied"),
829 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
FREQUENCY,
835 txParams->psd = txPowerSpectrum;
836 txParams->txPhy =
nullptr;
837 txParams->duration = txDuration;
838 txParams->ppdu = ppdu;
860 currentState = state->GetState();
864 "PHY State " << currentState <<
" does not match expected state "
870 uint32_t expectedFailureCount)
873 expectedSuccessCount,
874 "Didn't receive right number of successful packets");
876 expectedFailureCount,
877 "Didn't receive right number of unsuccessful packets");
884 std::vector<bool> statusPerMpdu)
905 m_phy = CreateObject<SpectrumWifiPhy>();
918 CreateObject<ThresholdPreambleDetectionModel>();
919 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(4));
920 preambleDetectionModel->SetAttribute(
"MinimumRssi",
DoubleValue(-82));
924 frameCaptureModel->SetAttribute(
"Margin",
DoubleValue(5));
939 RngSeedManager::SetSeed(1);
940 RngSeedManager::SetRun(1);
941 int64_t streamNumber = 1;
945 double rxPowerDbm = -50;
951 Simulator::Schedule(
Seconds(1.0),
985 Simulator::Schedule(
Seconds(1.1),
997 Simulator::Schedule(
Seconds(2.0),
1027 Simulator::Schedule(
Seconds(2.1),
1039 Simulator::Schedule(
Seconds(3.0),
1069 Simulator::Schedule(
Seconds(3.1),
1080 Simulator::Schedule(
Seconds(4.0),
1128 Simulator::Schedule(
Seconds(4.1),
1140 Simulator::Schedule(
Seconds(5.0),
1174 Simulator::Schedule(
Seconds(5.1),
1186 Simulator::Schedule(
Seconds(6.0),
1230 Simulator::Schedule(
Seconds(6.1),
1242 Simulator::Schedule(
Seconds(7.0),
1246 Simulator::Schedule(
Seconds(7.0),
1272 Simulator::Schedule(
Seconds(7.1),
1284 Simulator::Schedule(
Seconds(8.0),
1288 Simulator::Schedule(
Seconds(8.0),
1313 Simulator::Schedule(
Seconds(8.1),
1324 Simulator::Schedule(
Seconds(9.0),
1328 Simulator::Schedule(
Seconds(9.0),
1362 Simulator::Schedule(
Seconds(9.1),
1374 Simulator::Schedule(
Seconds(10.0),
1378 Simulator::Schedule(
Seconds(10.0),
1403 Simulator::Schedule(
Seconds(10.1),
1415 Simulator::Schedule(
Seconds(11.0),
1419 Simulator::Schedule(
Seconds(11.0),
1453 Simulator::Schedule(
Seconds(11.1),
1466 Simulator::Schedule(
Seconds(12.0),
1500 Simulator::Schedule(
Seconds(12.1),
1512 Simulator::Schedule(
Seconds(13.0),
1527 Simulator::Schedule(
Seconds(13.1),
1540 Simulator::Schedule(
Seconds(14.0),
1555 Simulator::Schedule(
Seconds(14.1),
1566 Simulator::Schedule(
Seconds(15.0),
1605 Simulator::Schedule(
Seconds(15.1),
1618 Simulator::Schedule(
Seconds(16.0),
1638 Simulator::Schedule(
Seconds(16.1),
1650 Simulator::Schedule(
Seconds(17.0),
1694 Simulator::Schedule(
Seconds(17.1),
1703 Simulator::Schedule(
Seconds(18.0),
1712 Simulator::Schedule(
Seconds(18.1),
1720 Simulator::Schedule(
Seconds(19.0),
1729 Simulator::Schedule(
Seconds(19.1),
1737 Simulator::Schedule(
Seconds(20.0),
1741 Simulator::Schedule(
Seconds(20.0),
1746 Simulator::Schedule(
Seconds(20.1),
1754 Simulator::Schedule(
Seconds(21.0),
1758 Simulator::Schedule(
Seconds(21.0),
1764 Simulator::Schedule(
Seconds(21.1),
1771 Simulator::Destroy();
1791 void DoRun()
override;
1813 std::vector<bool> statusPerMpdu);
1849 :
TestCase(
"Simple frame capture model test"),
1850 m_rxSuccess1000B(false),
1851 m_rxSuccess1500B(false),
1852 m_rxDropped1000B(false),
1853 m_rxDropped1500B(false),
1877 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
FREQUENCY,
1883 txParams->psd = txPowerSpectrum;
1884 txParams->txPhy =
nullptr;
1885 txParams->duration = txDuration;
1886 txParams->ppdu = ppdu;
1895 std::vector<bool> statusPerMpdu)
1903 else if (psdu->
GetSize() == 1530)
1917 else if (p->
GetSize() == 1530)
1964 m_phy = CreateObject<SpectrumWifiPhy>();
1977 CreateObject<ThresholdPreambleDetectionModel>();
1978 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(2));
1982 frameCaptureModel->SetAttribute(
"Margin",
DoubleValue(5));
1997 RngSeedManager::SetSeed(1);
1998 RngSeedManager::SetRun(1);
1999 int64_t streamNumber = 2;
2000 double rxPowerDbm = -30;
2006 Simulator::Schedule(
Seconds(1.0),
2022 Simulator::Schedule(
Seconds(2.0),
2032 Simulator::Schedule(
Seconds(2.1),
2041 Simulator::Schedule(
Seconds(3.0),
2052 Simulator::Schedule(
Seconds(3.1),
2061 Simulator::Schedule(
Seconds(4.0),
2075 Simulator::Destroy();
2101 void DoRun()
override;
2118 :
TestCase(
"PHY headers reception test"),
2142 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
FREQUENCY,
2148 txParams->psd = txPowerSpectrum;
2149 txParams->txPhy =
nullptr;
2150 txParams->duration = txDuration;
2151 txParams->ppdu = ppdu;
2171 currentState = state->GetState();
2175 "PHY State " << currentState <<
" does not match expected state "
2187 m_phy = CreateObject<SpectrumWifiPhy>();
2206 RngSeedManager::SetSeed(1);
2207 RngSeedManager::SetRun(1);
2208 int64_t streamNumber = 0;
2212 double rxPowerDbm = -50;
2506 Simulator::Destroy();
2526 void DoRun()
override;
2538 std::vector<bool> statusPerMpdu);
2627 :
TestCase(
"A-MPDU reception test"),
2628 m_rxSuccessBitmapAmpdu1(0),
2629 m_rxSuccessBitmapAmpdu2(0),
2630 m_rxFailureBitmapAmpdu1(0),
2631 m_rxFailureBitmapAmpdu2(0),
2632 m_rxDroppedBitmapAmpdu1(0),
2633 m_rxDroppedBitmapAmpdu2(0),
2658 std::vector<bool> statusPerMpdu)
2661 if (statusPerMpdu.empty())
2666 "Should have one receive status per MPDU");
2667 auto rxOkForMpdu = statusPerMpdu.begin();
2668 for (
auto mpdu = psdu->
begin(); mpdu != psdu->
end(); ++mpdu)
2689 else if (size == 1130)
2693 else if (size == 1230)
2697 else if (size == 1330)
2701 else if (size == 1430)
2705 else if (size == 1530)
2715 for (
auto mpdu = psdu->
begin(); mpdu != psdu->
end(); ++mpdu)
2728 else if (size == 1130)
2732 else if (size == 1230)
2736 else if (size == 1330)
2740 else if (size == 1430)
2744 else if (size == 1530)
2758 else if (p->
GetSize() == 1130)
2762 else if (p->
GetSize() == 1230)
2766 else if (p->
GetSize() == 1330)
2770 else if (p->
GetSize() == 1430)
2774 else if (p->
GetSize() == 1530)
2785 "RX success bitmap for A-MPDU 1 is not as expected");
2793 "RX success bitmap for A-MPDU 2 is not as expected");
2801 "RX failure bitmap for A-MPDU 1 is not as expected");
2809 "RX failure bitmap for A-MPDU 2 is not as expected");
2817 "RX dropped bitmap for A-MPDU 1 is not as expected");
2825 "RX dropped bitmap for A-MPDU 2 is not as expected");
2835 currentState = state->GetState();
2838 "PHY State " << currentState <<
" does not match expected state "
2852 std::vector<Ptr<WifiMpdu>> mpduList;
2853 for (
size_t i = 0; i < 3; ++i)
2855 Ptr<Packet> p = Create<Packet>(referencePacketSize + i * 100);
2856 mpduList.push_back(Create<WifiMpdu>(p, hdr));
2866 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(
FREQUENCY,
2872 txParams->psd = txPowerSpectrum;
2873 txParams->txPhy =
nullptr;
2874 txParams->duration = txDuration;
2875 txParams->ppdu = ppdu;
2884 m_phy = CreateObject<SpectrumWifiPhy>();
2898 CreateObject<ThresholdPreambleDetectionModel>();
2899 preambleDetectionModel->SetAttribute(
"Threshold",
DoubleValue(2));
2903 frameCaptureModel->SetAttribute(
"Margin",
DoubleValue(5));
2918 RngSeedManager::SetSeed(1);
2919 RngSeedManager::SetRun(2);
2920 int64_t streamNumber = 1;
2921 double rxPowerDbm = -30;
2931 Simulator::Schedule(
Seconds(1.0),
2945 Simulator::Schedule(
Seconds(1.1),
2949 Simulator::Schedule(
Seconds(1.1),
2953 Simulator::Schedule(
Seconds(1.1),
2959 Simulator::Schedule(
Seconds(1.1),
2963 Simulator::Schedule(
Seconds(1.1),
2967 Simulator::Schedule(
Seconds(1.1),
2981 Simulator::Schedule(
Seconds(2.0),
2995 Simulator::Schedule(
Seconds(2.1),
2999 Simulator::Schedule(
Seconds(2.1),
3003 Simulator::Schedule(
Seconds(2.1),
3009 Simulator::Schedule(
Seconds(2.1),
3013 Simulator::Schedule(
Seconds(2.1),
3017 Simulator::Schedule(
Seconds(2.1),
3031 Simulator::Schedule(
Seconds(3.0),
3045 Simulator::Schedule(
Seconds(3.1),
3049 Simulator::Schedule(
Seconds(3.1),
3053 Simulator::Schedule(
Seconds(3.1),
3059 Simulator::Schedule(
Seconds(3.1),
3063 Simulator::Schedule(
Seconds(3.1),
3067 Simulator::Schedule(
Seconds(3.1),
3081 Simulator::Schedule(
Seconds(4.0),
3095 Simulator::Schedule(
Seconds(4.1),
3099 Simulator::Schedule(
Seconds(4.1),
3103 Simulator::Schedule(
Seconds(4.1),
3109 Simulator::Schedule(
Seconds(4.1),
3113 Simulator::Schedule(
Seconds(4.1),
3117 Simulator::Schedule(
Seconds(4.1),
3131 Simulator::Schedule(
Seconds(5.0),
3145 Simulator::Schedule(
Seconds(5.1),
3149 Simulator::Schedule(
Seconds(5.1),
3153 Simulator::Schedule(
Seconds(5.1),
3159 Simulator::Schedule(
Seconds(5.1),
3163 Simulator::Schedule(
Seconds(5.1),
3167 Simulator::Schedule(
Seconds(5.1),
3181 Simulator::Schedule(
Seconds(6.0),
3195 Simulator::Schedule(
Seconds(6.1),
3199 Simulator::Schedule(
Seconds(6.1),
3203 Simulator::Schedule(
Seconds(6.1),
3209 Simulator::Schedule(
Seconds(6.1),
3213 Simulator::Schedule(
Seconds(6.1),
3217 Simulator::Schedule(
Seconds(6.1),
3230 Simulator::Schedule(
Seconds(7.0),
3244 Simulator::Schedule(
Seconds(7.1),
3248 Simulator::Schedule(
Seconds(7.1),
3252 Simulator::Schedule(
Seconds(7.1),
3258 Simulator::Schedule(
Seconds(7.1),
3262 Simulator::Schedule(
Seconds(7.1),
3266 Simulator::Schedule(
Seconds(7.1),
3279 Simulator::Schedule(
Seconds(8.0),
3293 Simulator::Schedule(
Seconds(8.1),
3297 Simulator::Schedule(
Seconds(8.1),
3301 Simulator::Schedule(
Seconds(8.1),
3307 Simulator::Schedule(
Seconds(8.1),
3311 Simulator::Schedule(
Seconds(8.1),
3315 Simulator::Schedule(
Seconds(8.1),
3329 Simulator::Schedule(
Seconds(9.0),
3343 Simulator::Schedule(
Seconds(9.1),
3347 Simulator::Schedule(
Seconds(9.1),
3351 Simulator::Schedule(
Seconds(9.1),
3357 Simulator::Schedule(
Seconds(9.1),
3361 Simulator::Schedule(
Seconds(9.1),
3365 Simulator::Schedule(
Seconds(9.1),
3379 Simulator::Schedule(
Seconds(10.0),
3393 Simulator::Schedule(
Seconds(10.1),
3397 Simulator::Schedule(
Seconds(10.1),
3401 Simulator::Schedule(
Seconds(10.1),
3407 Simulator::Schedule(
Seconds(10.1),
3411 Simulator::Schedule(
Seconds(10.1),
3415 Simulator::Schedule(
Seconds(10.1),
3429 Simulator::Schedule(
Seconds(11.0),
3443 Simulator::Schedule(
Seconds(11.1),
3447 Simulator::Schedule(
Seconds(11.1),
3451 Simulator::Schedule(
Seconds(11.1),
3457 Simulator::Schedule(
Seconds(11.1),
3461 Simulator::Schedule(
Seconds(11.1),
3465 Simulator::Schedule(
Seconds(11.1),
3479 Simulator::Schedule(
Seconds(12.0),
3494 Simulator::Schedule(
Seconds(12.1),
3498 Simulator::Schedule(
Seconds(12.1),
3502 Simulator::Schedule(
Seconds(12.1),
3509 Simulator::Schedule(
Seconds(12.1),
3513 Simulator::Schedule(
Seconds(12.1),
3517 Simulator::Schedule(
Seconds(12.1),
3531 Simulator::Schedule(
Seconds(13.0),
3546 Simulator::Schedule(
Seconds(13.1),
3550 Simulator::Schedule(
Seconds(13.1),
3554 Simulator::Schedule(
Seconds(13.1),
3560 Simulator::Schedule(
Seconds(13.1),
3564 Simulator::Schedule(
Seconds(13.1),
3568 Simulator::Schedule(
Seconds(13.1),
3582 Simulator::Schedule(
Seconds(14.0),
3596 Simulator::Schedule(
Seconds(14.1),
3600 Simulator::Schedule(
Seconds(14.1),
3604 Simulator::Schedule(
Seconds(14.1),
3610 Simulator::Schedule(
Seconds(14.1),
3614 Simulator::Schedule(
Seconds(14.1),
3618 Simulator::Schedule(
Seconds(14.1),
3632 Simulator::Schedule(
Seconds(15.0),
3646 Simulator::Schedule(
Seconds(15.1),
3650 Simulator::Schedule(
Seconds(15.1),
3654 Simulator::Schedule(
Seconds(15.1),
3660 Simulator::Schedule(
Seconds(15.1),
3664 Simulator::Schedule(
Seconds(15.1),
3668 Simulator::Schedule(
Seconds(15.1),
3682 Simulator::Schedule(
Seconds(16.0),
3696 Simulator::Schedule(
Seconds(16.1),
3700 Simulator::Schedule(
Seconds(16.1),
3704 Simulator::Schedule(
Seconds(16.1),
3710 Simulator::Schedule(
Seconds(16.1),
3714 Simulator::Schedule(
Seconds(16.1),
3718 Simulator::Schedule(
Seconds(16.1),
3732 Simulator::Schedule(
Seconds(17.0),
3746 Simulator::Schedule(
Seconds(17.1),
3750 Simulator::Schedule(
Seconds(17.1),
3754 Simulator::Schedule(
Seconds(17.1),
3761 Simulator::Schedule(
Seconds(17.1),
3765 Simulator::Schedule(
Seconds(17.1),
3769 Simulator::Schedule(
Seconds(17.1),
3783 Simulator::Schedule(
Seconds(18.0),
3797 Simulator::Schedule(
Seconds(18.1),
3801 Simulator::Schedule(
Seconds(18.1),
3805 Simulator::Schedule(
Seconds(18.1),
3811 Simulator::Schedule(
Seconds(18.1),
3815 Simulator::Schedule(
Seconds(18.1),
3819 Simulator::Schedule(
Seconds(18.1),
3833 Simulator::Schedule(
Seconds(19.0),
3847 Simulator::Schedule(
Seconds(19.1),
3851 Simulator::Schedule(
Seconds(19.1),
3855 Simulator::Schedule(
Seconds(19.1),
3861 Simulator::Schedule(
Seconds(19.1),
3865 Simulator::Schedule(
Seconds(19.1),
3869 Simulator::Schedule(
Seconds(19.1),
3883 Simulator::Schedule(
Seconds(20.0),
3897 Simulator::Schedule(
Seconds(20.1),
3901 Simulator::Schedule(
Seconds(20.1),
3905 Simulator::Schedule(
Seconds(20.1),
3912 Simulator::Schedule(
Seconds(20.1),
3916 Simulator::Schedule(
Seconds(20.1),
3920 Simulator::Schedule(
Seconds(20.1),
3934 Simulator::Schedule(
Seconds(21.0),
3948 Simulator::Schedule(
Seconds(21.1),
3952 Simulator::Schedule(
Seconds(21.1),
3956 Simulator::Schedule(
Seconds(21.1),
3962 Simulator::Schedule(
Seconds(21.1),
3966 Simulator::Schedule(
Seconds(21.1),
3970 Simulator::Schedule(
Seconds(21.1),
3984 Simulator::Schedule(
Seconds(22.0),
3998 Simulator::Schedule(
Seconds(22.1),
4002 Simulator::Schedule(
Seconds(22.1),
4006 Simulator::Schedule(
Seconds(22.1),
4012 Simulator::Schedule(
Seconds(22.1),
4016 Simulator::Schedule(
Seconds(22.1),
4020 Simulator::Schedule(
Seconds(22.1),
4033 Simulator::Schedule(
Seconds(23.0),
4048 Simulator::Schedule(
Seconds(23.1),
4052 Simulator::Schedule(
Seconds(23.1),
4056 Simulator::Schedule(
Seconds(23.1),
4064 Simulator::Schedule(
Seconds(23.1),
4068 Simulator::Schedule(
Seconds(23.1),
4072 Simulator::Schedule(
Seconds(23.1),
4080 Simulator::Destroy();
4125 void DoRun()
override;
4130 :
TestCase(
"Check correct behavior when a STA is receiving a transmission using an unsupported "
4146 if (reason ==
RXING)
4148 std::cout <<
"Dropped a packet because already receiving" << std::endl;
4156 uint16_t m_nStations = 2;
4162 int64_t streamNumber = 100;
4172 spectrumChannel->AddPropagationLossModel(lossModel);
4174 CreateObject<ConstantSpeedPropagationDelayModel>();
4175 spectrumChannel->SetPropagationDelayModel(delayModel);
4178 phy.SetChannel(spectrumChannel);
4183 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
4186 mac.SetType(
"ns3::StaWifiMac",
4198 mac.SetType(
"ns3::ApWifiMac",
4205 "EnableBeaconJitter",
4214 for (uint16_t i = 0; i < m_nStations; i++)
4216 dev = DynamicCast<WifiNetDevice>(m_staDevices.
Get(i));
4220 Ssid(
"wifi-backoff-ssid"));
4224 wifi.AssignStreams(m_apDevices, streamNumber);
4229 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
4230 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
4231 positionAlloc->Add(Vector(0.0, 1.0, 0.0));
4232 positionAlloc->Add(Vector(-1.0, 0.0, 0.0));
4233 mobility.SetPositionAllocator(positionAlloc);
4235 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
4240 dev = DynamicCast<WifiNetDevice>(m_apDevices.
Get(0));
4249 for (uint16_t i = 0; i < m_nStations; i++)
4259 client->SetRemote(socket);
4262 client->SetStopTime(
Seconds(1.0));
4264 legacyStaClient->SetAttribute(
"PacketSize",
UintegerValue(1500));
4265 legacyStaClient->SetAttribute(
"MaxPackets",
UintegerValue(200));
4267 legacyStaClient->SetRemote(socket);
4270 legacyStaClient->SetStopTime(
Seconds(1.0));
4272 server->SetLocal(socket);
4274 server->SetStartTime(
Seconds(0.0));
4275 server->SetStopTime(
Seconds(1.0));
4279 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
4287 Simulator::Destroy();
4315 void DoRun()
override;
4336 std::vector<bool> statusPerMpdu);
4362 void CheckRx(uint32_t expectedCountRxSuccess,
4363 uint32_t expectedCountRxFailure,
4364 uint32_t expectedCountRxDropped,
4365 std::optional<Time> expectedLastRxSucceeded,
4366 std::optional<Time> expectedLastRxFailed,
4367 std::optional<Time> expectedLastRxDropped);
4381 :
TestCase(
"Check correct behavior when a STA is receiving a transmission using an unsupported "
4383 m_countRxSuccess(0),
4384 m_countRxFailure(0),
4385 m_countRxDropped(0),
4386 m_lastRxSucceeded(std::nullopt),
4387 m_lastRxFailed(std::nullopt),
4388 m_lastRxDropped(std::nullopt)
4394 uint16_t centerFreqMhz,
4395 uint16_t bandwidthMhz)
4400 auto pkt = Create<Packet>(1000);
4409 auto ppdu = Create<HePpdu>(psdu, txVector, centerFreqMhz, txDuration,
WIFI_PHY_BAND_5GHZ, 0);
4411 auto txPowerSpectrum =
4412 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity(centerFreqMhz,
4417 auto txParams = Create<WifiSpectrumSignalParameters>();
4418 txParams->psd = txPowerSpectrum;
4419 txParams->txPhy =
nullptr;
4420 txParams->duration = txDuration;
4421 txParams->ppdu = ppdu;
4422 txParams->txWidth = bandwidthMhz;
4431 std::vector<bool> statusPerMpdu)
4457 uint32_t expectedCountRxFailure,
4458 uint32_t expectedCountRxDropped,
4459 std::optional<Time> expectedLastRxSucceeded,
4460 std::optional<Time> expectedLastRxFailed,
4461 std::optional<Time> expectedLastRxDropped)
4464 expectedCountRxSuccess,
4465 "Didn't receive right number of successful packets");
4468 expectedCountRxFailure,
4469 "Didn't receive right number of unsuccessful packets");
4472 expectedCountRxDropped,
4473 "Didn't receive right number of dropped packets");
4475 if (expectedCountRxSuccess > 0)
4478 NS_ASSERT(expectedLastRxSucceeded.has_value());
4480 expectedLastRxSucceeded.value(),
4481 "Didn't receive the last successful packet at the expected time");
4484 if (expectedCountRxFailure > 0)
4487 NS_ASSERT(expectedLastRxFailed.has_value());
4489 expectedLastRxFailed.value(),
4490 "Didn't receive the last unsuccessful packet at the expected time");
4493 if (expectedCountRxDropped > 0)
4496 NS_ASSERT(expectedLastRxDropped.has_value());
4498 expectedLastRxDropped.value(),
4499 "Didn't drop the last filtered packet at the expected time");
4506 m_phy = CreateObject<SpectrumWifiPhy>();
4508 auto interferenceHelper = CreateObject<InterferenceHelper>();
4510 auto error = CreateObject<NistErrorRateModel>();
4531 RngSeedManager::SetSeed(1);
4532 RngSeedManager::SetRun(1);
4534 int64_t streamNumber = 0;
4543 Simulator::Schedule(
Seconds(1.0),
4551 Simulator::Schedule(
Seconds(1.5),
4559 heSigAExpectedRxTime);
4564 Simulator::Destroy();
4582 void DoRun()
override;
4607 uint16_t phyCenterFreqMhz,
4609 uint16_t ppduCenterFreqMhz,
4610 bool expectedP20Overlap,
4611 bool expectedP20Covered);
4617 :
TestCase(
"Check correct detection of whether P20 is fully covered (hence it can be received) "
4618 "or overlaps with the bandwidth of an incoming PPDU")
4625 [[maybe_unused]]
auto [channelNumber, centerFreq, channelWidth,
type, phyBand] =
4631 auto pkt = Create<Packet>(1000);
4634 auto psdu = Create<WifiPsdu>(pkt, hdr);
4637 return Create<HePpdu>(psdu, txVector, ppduCenterFreqMhz, txDuration, band, 0);
4643 m_phy = CreateObject<SpectrumWifiPhy>();
4645 auto interferenceHelper = CreateObject<InterferenceHelper>();
4647 auto error = CreateObject<NistErrorRateModel>();
4660 uint16_t phyCenterFreqMhz,
4662 uint16_t ppduCenterFreqMhz,
4663 bool expectedP20Overlap,
4664 bool expectedP20Covered)
4666 [[maybe_unused]]
const auto [channelNumber, centerFreq, channelWidth,
type, phyBand] =
4671 auto p20MinFreq = p20CenterFreq - 10;
4672 auto p20MaxFreq = p20CenterFreq + 10;
4674 auto ppdu =
CreatePpdu(band, ppduCenterFreqMhz);
4676 auto p20Overlap = ppdu->DoesOverlapChannel(p20MinFreq, p20MaxFreq);
4679 "PPDU is " << (expectedP20Overlap ?
"expected" :
"not expected")
4680 <<
" to overlap with the P20");
4687 .GetChannelWidth());
4690 "PPDU is " << (expectedP20Covered ?
"expected" :
"not expected")
4691 <<
" to cover the whole P20");
4745 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 unsuccessfuly received MPDUs in A-MPDU #1
uint8_t m_rxFailureBitmapAmpdu2
bitmap of unsuccessfuly received MPDUs in A-MPDU #2
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
~TestAmpduReception() override
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 DoTeardown() override
Implementation to do any local setup required for this TestCase.
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
Ptr< SpectrumWifiPhy > m_phy
Phy.
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...
void RunOne(WifiPhyBand band, uint16_t phyCenterFreqMhz, uint8_t p20Index, uint16_t ppduCenterFreqMhz, bool expectedP20Overlap, bool expectedP20Covered)
Run one function.
Ptr< SpectrumWifiPhy > m_phy
PHY.
TestPrimary20CoveredByPpdu()
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< HePpdu > CreatePpdu(WifiPhyBand band, uint16_t ppduCenterFreqMhz)
Function to create a PPDU.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
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 SendPacket(double rxPowerDbm, uint32_t packetSize)
Send packet function.
~TestSimpleFrameCaptureModel() override
void Reset()
Reset function.
Ptr< SpectrumWifiPhy > m_phy
Phy.
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.
uint64_t m_uid
the UID to use for the PPDU
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
TestSimpleFrameCaptureModel()
bool m_rxDropped1000B
count dropped packets with 1000B payload
Preamble detection test w/o frame capture.
TestThresholdPreambleDetectionWithFrameCapture()
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void SendPacket(double rxPowerDbm)
Send packet function.
void RxFailure(Ptr< const WifiPsdu > psdu)
Spectrum wifi receive failure function.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
~TestThresholdPreambleDetectionWithFrameCapture() override
void DoTeardown() 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 DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
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.
uint64_t m_uid
the UID to use for the PPDU
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 DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
uint64_t m_uid
the UID to use for the PPDU
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void SendPacket(double rxPowerDbm)
Send packet function.
Ptr< SpectrumWifiPhy > m_phy
Phy.
uint32_t m_countRxSuccess
count RX success
~TestThresholdPreambleDetectionWithoutFrameCapture() override
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
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.
TestUnsupportedBandwidthReception()
std::optional< Time > m_lastRxDropped
time of last RX drop, if any
std::optional< Time > m_lastRxSucceeded
time of last RX success, if any
Ptr< SpectrumWifiPhy > m_phy
PHY.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
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 SendPpdu(WifiPhyBand band, uint16_t centerFreqMhz, uint16_t bandwidthMhz)
Function to create a PPDU.
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.
~TestUnsupportedModulationReception() override
void Dropped(std::string context, Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Callback invoked when PHY drops an incoming packet.
TestUnsupportedModulationReception()
Constructor.
uint16_t m_dropped
number of packets dropped by the AP because it was already receiving
wifi PHY reception Test Suite
WifiPhyReceptionTestSuite()
AttributeValue implementation for Boolean.
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.
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 StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
Ptr< WifiMac > GetMac() const
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
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 SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
void SetReceiveOkCallback(RxOkCallback callback)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
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...