22#include "ns3/mobility-helper.h"
23#include "ns3/multi-model-spectrum-channel.h"
24#include "ns3/config.h"
25#include "ns3/ap-wifi-mac.h"
26#include "ns3/packet-socket-address.h"
27#include "ns3/packet-socket-client.h"
28#include "ns3/packet-socket-helper.h"
29#include "ns3/packet-socket-server.h"
31#include "ns3/double.h"
32#include "ns3/boolean.h"
33#include "ns3/pointer.h"
34#include "ns3/rng-seed-manager.h"
35#include "ns3/spectrum-wifi-helper.h"
36#include "ns3/wifi-net-device.h"
37#include "ns3/wifi-spectrum-value-helper.h"
38#include "ns3/spectrum-wifi-phy.h"
39#include "ns3/nist-error-rate-model.h"
40#include "ns3/wifi-mac-header.h"
41#include "ns3/ampdu-tag.h"
42#include "ns3/wifi-spectrum-signal-parameters.h"
43#include "ns3/wifi-utils.h"
44#include "ns3/threshold-preamble-detection-model.h"
45#include "ns3/simple-frame-capture-model.h"
46#include "ns3/wifi-mac-queue-item.h"
47#include "ns3/mpdu-aggregator.h"
48#include "ns3/wifi-psdu.h"
49#include "ns3/he-ppdu.h"
50#include "ns3/he-phy.h"
100 void DoRun (
void)
override;
123 :
TestCase (
"Threshold preamble detection model test when no frame capture model is applied"),
124 m_countRxSuccess (0),
125 m_countRxFailure (0),
149 txParams->psd = txPowerSpectrum;
151 txParams->duration = txDuration;
152 txParams->ppdu = ppdu;
171 currentState = state->GetState ();
206 m_phy = CreateObject<SpectrumWifiPhy> ();
215 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (4));
216 preambleDetectionModel->SetAttribute (
"MinimumRssi",
DoubleValue (-82));
230 RngSeedManager::SetSeed (1);
231 RngSeedManager::SetRun (1);
232 int64_t streamNumber = 0;
236 double rxPowerDbm = -50;
422 Simulator::Destroy ();
454 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
464 void DoRun (
void)
override;
487:
TestCase (
"Threshold preamble detection model test when simple frame capture model is applied"),
488 m_countRxSuccess (0),
489 m_countRxFailure (0),
513 txParams->psd = txPowerSpectrum;
515 txParams->duration = txDuration;
516 txParams->ppdu = ppdu;
535 currentState = state->GetState ();
570 m_phy = CreateObject<SpectrumWifiPhy> ();
579 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (4));
580 preambleDetectionModel->SetAttribute (
"MinimumRssi",
DoubleValue (-82));
584 frameCaptureModel->SetAttribute (
"Margin",
DoubleValue (5));
599 RngSeedManager::SetSeed (1);
600 RngSeedManager::SetRun (1);
601 int64_t streamNumber = 1;
605 double rxPowerDbm = -50;
926 Simulator::Destroy ();
946 void DoRun (
void)
override;
966 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
1002:
TestCase (
"Simple frame capture model test"),
1003 m_rxSuccess1000B (false),
1004 m_rxSuccess1500B (false),
1005 m_rxDropped1000B (false),
1006 m_rxDropped1500B (false),
1030 txParams->psd = txPowerSpectrum;
1031 txParams->txPhy = 0;
1032 txParams->duration = txDuration;
1033 txParams->ppdu = ppdu;
1040 WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1048 else if (psdu->
GetSize () == 1530)
1062 else if (p->
GetSize () == 1530)
1108 m_phy = CreateObject<SpectrumWifiPhy> ();
1118 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (2));
1122 frameCaptureModel->SetAttribute (
"Margin",
DoubleValue (5));
1137 RngSeedManager::SetSeed (1);
1138 RngSeedManager::SetRun (1);
1139 int64_t streamNumber = 2;
1140 double rxPowerDbm = -30;
1178 Simulator::Destroy ();
1204 void DoRun (
void)
override;
1221:
TestCase (
"PHY headers reception test"),
1245 txParams->psd = txPowerSpectrum;
1246 txParams->txPhy = 0;
1247 txParams->duration = txDuration;
1248 txParams->ppdu = ppdu;
1267 currentState = state->GetState ();
1281 m_phy = CreateObject<SpectrumWifiPhy> ();
1298 RngSeedManager::SetSeed (1);
1299 RngSeedManager::SetRun (1);
1300 int64_t streamNumber = 0;
1304 double rxPowerDbm = -50;
1429 Simulator::Destroy ();
1449 void DoRun (
void)
override;
1459 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
1546:
TestCase (
"A-MPDU reception test"),
1547 m_rxSuccessBitmapAmpdu1 (0),
1548 m_rxSuccessBitmapAmpdu2 (0),
1549 m_rxFailureBitmapAmpdu1 (0),
1550 m_rxFailureBitmapAmpdu2 (0),
1551 m_rxDroppedBitmapAmpdu1 (0),
1552 m_rxDroppedBitmapAmpdu2 (0),
1575 WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1578 if (statusPerMpdu.empty ())
1583 auto rxOkForMpdu = statusPerMpdu.begin ();
1584 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1605 else if (size == 1130)
1609 else if (size == 1230)
1613 else if (size == 1330)
1617 else if (size == 1430)
1621 else if (size == 1530)
1631 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1644 else if (size == 1130)
1648 else if (size == 1230)
1652 else if (size == 1330)
1656 else if (size == 1430)
1660 else if (size == 1530)
1674 else if (p->
GetSize () == 1130)
1678 else if (p->
GetSize () == 1230)
1682 else if (p->
GetSize () == 1330)
1686 else if (p->
GetSize () == 1430)
1690 else if (p->
GetSize () == 1530)
1739 currentState = state->GetState ();
1752 std::vector<Ptr<WifiMacQueueItem>> mpduList;
1753 for (
size_t i = 0; i < 3; ++i)
1755 Ptr<Packet> p = Create<Packet> (referencePacketSize + i * 100);
1756 mpduList.push_back (Create<WifiMacQueueItem> (p, hdr));
1767 txParams->psd = txPowerSpectrum;
1768 txParams->txPhy = 0;
1769 txParams->duration = txDuration;
1770 txParams->ppdu = ppdu;
1778 m_phy = CreateObject<SpectrumWifiPhy> ();
1789 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (2));
1793 frameCaptureModel->SetAttribute (
"Margin",
DoubleValue (5));
1808 RngSeedManager::SetSeed (1);
1809 RngSeedManager::SetRun (2);
1810 int64_t streamNumber = 1;
1811 double rxPowerDbm = -30;
2346 Simulator::Destroy ();
2391 void DoRun (
void)
override;
2396 :
TestCase (
"Check correct behavior when a STA is receiving a transmission using an unsupported modulation"),
2410 if (reason ==
RXING)
2412 std::cout <<
"Dropped a packet because already receiving" << std::endl;
2420 uint16_t m_nStations = 2;
2426 int64_t streamNumber = 100;
2436 spectrumChannel->AddPropagationLossModel (lossModel);
2438 CreateObject<ConstantSpeedPropagationDelayModel> ();
2439 spectrumChannel->SetPropagationDelayModel (delayModel);
2442 phy.SetChannel (spectrumChannel);
2447 wifi.SetRemoteStationManager (
"ns3::IdealWifiManager");
2450 mac.SetType (
"ns3::StaWifiMac",
"QosSupported",
BooleanValue (
true),
"Ssid",
2459 mac.SetType (
"ns3::ApWifiMac",
"QosSupported",
BooleanValue (
true),
"Ssid",
2469 for (uint16_t i = 0; i < m_nStations; i++)
2471 dev = DynamicCast<WifiNetDevice> (m_staDevices.
Get (i));
2472 Simulator::Schedule (init + i *
MicroSeconds (102400), &WifiMac::SetSsid, dev->
GetMac (),
2473 Ssid (
"wifi-backoff-ssid"));
2477 wifi.AssignStreams (m_apDevices, streamNumber);
2482 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2483 positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2484 positionAlloc->Add (Vector (0.0, 1.0, 0.0));
2485 positionAlloc->Add (Vector (-1.0, 0.0, 0.0));
2486 mobility.SetPositionAllocator (positionAlloc);
2488 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
2493 dev = DynamicCast<WifiNetDevice> (m_apDevices.
Get (0));
2495 dev->
GetMac ()->GetAttribute (
"BE_Txop", ptr);
2502 for (uint16_t i = 0; i < m_nStations; i++)
2512 client->SetRemote (socket);
2515 client->SetStopTime (
Seconds (1.0));
2517 legacyStaClient->SetAttribute (
"PacketSize",
UintegerValue (1500));
2518 legacyStaClient->SetAttribute (
"MaxPackets",
UintegerValue (200));
2520 legacyStaClient->SetRemote (socket);
2521 wifiStaNodes.Get (i)->AddApplication (legacyStaClient);
2523 legacyStaClient->SetStopTime (
Seconds (1.0));
2525 server->SetLocal (socket);
2527 server->SetStartTime (
Seconds (0.0));
2528 server->SetStopTime (
Seconds (1.0));
2532 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
2535 Simulator::Stop (
Seconds (1));
2540 Simulator::Destroy ();
2562 :
TestSuite (
"wifi-phy-reception", UNIT)
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 DoTeardown(void) override
Implementation to do any local setup required for 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
void RxFailure(Ptr< WifiPsdu > psdu)
RX failure function.
uint8_t m_rxFailureBitmapAmpdu2
bitmap of unsuccessfully received MPDUs in A-MPDU #2
void DoRun(void) override
Implementation to actually run this TestCase.
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 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 ResetBitmaps()
Reset bitmaps function.
void CheckPhyState(WifiPhyState expectedState)
Check the PHY state.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
virtual ~TestAmpduReception()
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.
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.
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 Expect1500BPacketDropped()
Verify whether 1500 bytes packet has been dropped.
void Expect1000BPacketDropped()
Verify whether 1000 bytes packet has been dropped.
void DoRun(void) override
Implementation to actually run this TestCase.
void Reset(void)
Reset function.
void SendPacket(double rxPowerDbm, uint32_t packetSize)
Send packet function.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
bool m_rxSuccess1000B
count received packets with 1000B payload
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
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(void) override
Implementation to do any local setup required for this TestCase.
TestSimpleFrameCaptureModel()
bool m_rxDropped1000B
count dropped packets with 1000B payload
virtual ~TestSimpleFrameCaptureModel()
Preamble detection test w/o frame capture.
TestThresholdPreambleDetectionWithFrameCapture()
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void SendPacket(double rxPowerDbm)
Send packet function.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxSuccess
count RX success
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
uint32_t m_countRxFailure
count RX failure
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void DoRun(void) override
Implementation to actually run this TestCase.
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
virtual ~TestThresholdPreambleDetectionWithFrameCapture()
uint64_t m_uid
the UID to use for the PPDU
Preamble detection test w/o frame capture.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
TestThresholdPreambleDetectionWithoutFrameCapture()
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxFailure
count RX failure
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
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
virtual ~TestThresholdPreambleDetectionWithoutFrameCapture()
void DoRun(void) override
Implementation to actually run this TestCase.
void SendPacket(double rxPowerDbm)
Send packet function.
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
Ptr< SpectrumWifiPhy > m_phy
Phy.
uint32_t m_countRxSuccess
count RX success
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Unsupported Modulation Reception Test This test creates a mixed network, in which an HE STA and a VHT...
virtual ~TestUnsupportedModulationReception()
void DoRun(void) override
Implementation to actually run this TestCase.
void Dropped(std::string context, Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Callback invoked when PHY drops an incoming packet.
void CheckResults(void)
Check correctness of transmitted frames.
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.
virtual Address GetAddress(void) const =0
virtual uint32_t GetIfIndex(void) const =0
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(void)
Dispose of this Object.
uint32_t GetSize(void) 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(void) const
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
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.
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.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
This objects implements the PHY state machine of the Wifi device.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator end(void) const
Return a const iterator to past-the-last MPDU.
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
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(void)
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.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double DbmToW(double dBm)
Convert from dBm to Watts.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
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
Pcket size generated at the AP.