|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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/pointer.h"
33 #include "ns3/rng-seed-manager.h"
34 #include "ns3/spectrum-wifi-helper.h"
35 #include "ns3/wifi-net-device.h"
36 #include "ns3/wifi-spectrum-value-helper.h"
37 #include "ns3/spectrum-wifi-phy.h"
38 #include "ns3/nist-error-rate-model.h"
39 #include "ns3/wifi-mac-header.h"
40 #include "ns3/ampdu-tag.h"
41 #include "ns3/wifi-spectrum-signal-parameters.h"
42 #include "ns3/wifi-utils.h"
43 #include "ns3/threshold-preamble-detection-model.h"
44 #include "ns3/simple-frame-capture-model.h"
45 #include "ns3/wifi-mac-queue-item.h"
46 #include "ns3/mpdu-aggregator.h"
47 #include "ns3/wifi-psdu.h"
48 #include "ns3/he-ppdu.h"
49 #include "ns3/he-phy.h"
73 void DoSetup (
void)
override;
74 void DoTeardown (
void)
override;
99 void DoRun (
void)
override;
116 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
122 :
TestCase (
"Threshold preamble detection model test when no frame capture model is applied"),
123 m_countRxSuccess (0),
124 m_countRxFailure (0),
148 txParams->
psd = txPowerSpectrum;
151 txParams->
ppdu = ppdu;
205 m_phy = CreateObject<SpectrumWifiPhy> ();
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;
481 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
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;
516 txParams->
ppdu = ppdu;
570 m_phy = CreateObject<SpectrumWifiPhy> ();
600 RngSeedManager::SetSeed (1);
601 RngSeedManager::SetRun (1);
602 int64_t streamNumber = 1;
606 double rxPowerDbm = -50;
927 Simulator::Destroy ();
947 void DoRun (
void)
override;
967 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
1003 :
TestCase (
"Simple frame capture model test"),
1004 m_rxSuccess1000B (false),
1005 m_rxSuccess1500B (false),
1006 m_rxDropped1000B (false),
1007 m_rxDropped1500B (false),
1031 txParams->
psd = txPowerSpectrum;
1032 txParams->
txPhy = 0;
1034 txParams->
ppdu = ppdu;
1041 WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1049 else if (psdu->
GetSize () == 1530)
1063 else if (p->
GetSize () == 1530)
1109 m_phy = CreateObject<SpectrumWifiPhy> ();
1139 RngSeedManager::SetSeed (1);
1140 RngSeedManager::SetRun (1);
1141 int64_t streamNumber = 2;
1142 double rxPowerDbm = -30;
1180 Simulator::Destroy ();
1206 void DoRun (
void)
override;
1223 :
TestCase (
"PHY headers reception test"),
1247 txParams->
psd = txPowerSpectrum;
1248 txParams->
txPhy = 0;
1250 txParams->
ppdu = ppdu;
1283 m_phy = CreateObject<SpectrumWifiPhy> ();
1301 RngSeedManager::SetSeed (1);
1302 RngSeedManager::SetRun (1);
1303 int64_t streamNumber = 0;
1307 double rxPowerDbm = -50;
1432 Simulator::Destroy ();
1452 void DoRun (
void)
override;
1462 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
1549 :
TestCase (
"A-MPDU reception test"),
1550 m_rxSuccessBitmapAmpdu1 (0),
1551 m_rxSuccessBitmapAmpdu2 (0),
1552 m_rxFailureBitmapAmpdu1 (0),
1553 m_rxFailureBitmapAmpdu2 (0),
1554 m_rxDroppedBitmapAmpdu1 (0),
1555 m_rxDroppedBitmapAmpdu2 (0),
1578 WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1581 if (statusPerMpdu.empty ())
1586 auto rxOkForMpdu = statusPerMpdu.begin ();
1587 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1608 else if (size == 1130)
1612 else if (size == 1230)
1616 else if (size == 1330)
1620 else if (size == 1430)
1624 else if (size == 1530)
1634 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1647 else if (size == 1130)
1651 else if (size == 1230)
1655 else if (size == 1330)
1659 else if (size == 1430)
1663 else if (size == 1530)
1677 else if (p->
GetSize () == 1130)
1681 else if (p->
GetSize () == 1230)
1685 else if (p->
GetSize () == 1330)
1689 else if (p->
GetSize () == 1430)
1693 else if (p->
GetSize () == 1530)
1755 std::vector<Ptr<WifiMacQueueItem>> mpduList;
1756 for (
size_t i = 0; i < 3; ++i)
1758 Ptr<Packet> p = Create<Packet> (referencePacketSize + i * 100);
1759 mpduList.push_back (Create<WifiMacQueueItem> (p, hdr));
1770 txParams->
psd = txPowerSpectrum;
1771 txParams->
txPhy = 0;
1773 txParams->
ppdu = ppdu;
1781 m_phy = CreateObject<SpectrumWifiPhy> ();
1812 RngSeedManager::SetSeed (1);
1813 RngSeedManager::SetRun (2);
1814 int64_t streamNumber = 1;
1815 double rxPowerDbm = -30;
2350 Simulator::Destroy ();
2395 void DoRun (
void)
override;
2400 :
TestCase (
"Check correct behavior when a STA is receiving a transmission using an unsupported modulation"),
2414 if (reason ==
RXING)
2416 std::cout <<
"Dropped a packet because already receiving" << std::endl;
2424 uint16_t m_nStations = 2;
2430 int64_t streamNumber = 100;
2442 CreateObject<ConstantSpeedPropagationDelayModel> ();
2446 phy.SetChannel (spectrumChannel);
2451 wifi.SetRemoteStationManager (
"ns3::IdealWifiManager");
2454 mac.SetType (
"ns3::StaWifiMac",
"QosSupported",
BooleanValue (
true),
"Ssid",
2463 mac.SetType (
"ns3::ApWifiMac",
"QosSupported",
BooleanValue (
true),
"Ssid",
2473 for (uint16_t i = 0; i < m_nStations; i++)
2475 dev = DynamicCast<WifiNetDevice> (m_staDevices.
Get (i));
2476 Simulator::Schedule (init + i *
MicroSeconds (102400), &WifiMac::SetSsid, dev->
GetMac (),
2477 Ssid (
"wifi-backoff-ssid"));
2481 wifi.AssignStreams (m_apDevices, streamNumber);
2486 positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
2487 positionAlloc->
Add (Vector (1.0, 0.0, 0.0));
2488 positionAlloc->
Add (Vector (0.0, 1.0, 0.0));
2489 positionAlloc->
Add (Vector (-1.0, 0.0, 0.0));
2490 mobility.SetPositionAllocator (positionAlloc);
2492 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
2497 dev = DynamicCast<WifiNetDevice> (m_apDevices.
Get (0));
2499 dev->
GetMac ()->GetAttribute (
"BE_Txop", ptr);
2506 for (uint16_t i = 0; i < m_nStations; i++)
2525 wifiStaNodes.Get (i)->AddApplication (legacyStaClient);
2536 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
2539 Simulator::Stop (
Seconds (1));
2544 Simulator::Destroy ();
2566 :
TestSuite (
"wifi-phy-reception", UNIT)
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
holds a vector of ns3::NetDevice pointers
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
bool m_rxSuccess1500B
count received packets with 1500B payload
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
static const uint32_t FREQUENCY
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void SendPacket(double rxPowerDbm, uint32_t packetSize)
Send packet function.
void Add(Vector v)
Add a position to the list of positions.
void Dispose(void)
Dispose of this Object.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
TestThresholdPreambleDetectionWithFrameCapture()
AttributeValue implementation for Boolean.
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual ~TestAmpduReception()
virtual Address GetAddress(void) const =0
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
void SetChannelNumber(uint8_t id) override
Set channel number.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ RX
The PHY layer is receiving a packet.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
helps to create WifiNetDevice objects
std::vector< Ptr< WifiMacQueueItem > >::const_iterator end(void) const
Return a const iterator to past-the-last MPDU.
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
void CheckRxDroppedBitmapAmpdu1(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 1.
@ IDLE
The PHY layer is IDLE.
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void Expect1500BPacketDropped()
Verify whether 1500 bytes packet has been dropped.
WifiPhyReceptionTestSuite()
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
void Expect1000BPacketDropped()
Verify whether 1000 bytes packet has been dropped.
@ WIFI_STANDARD_80211ax_5GHZ
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
uint32_t m_countRxFailure
count RX failure
void DoRun(void) override
Implementation to actually run this TestCase.
void CheckRxSuccessBitmapAmpdu2(uint8_t expected)
Check the RX success bitmap for A-MPDU 2.
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
Preamble detection test w/o frame capture.
void ResetBitmaps()
Reset bitmaps function.
Hold objects of type Ptr<T>.
an address for a packet socket
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
void CheckRxSuccessBitmapAmpdu1(uint8_t expected)
Check the RX success bitmap for A-MPDU 1.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
virtual ~TestThresholdPreambleDetectionWithoutFrameCapture()
void SetReceiveOkCallback(RxOkCallback callback)
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
virtual ~TestThresholdPreambleDetectionWithFrameCapture()
Unsupported Modulation Reception Test This test creates a mixed network, in which an HE STA and a VHT...
Ptr< SpectrumWifiPhy > m_phy
Phy.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
static const uint16_t CHANNEL_WIDTH
This class can be used to hold variables of floating point type such as 'double' or 'float'.
uint64_t m_uid
the UID to use for the PPDU
void DoRun(void) override
Implementation to actually run this TestCase.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
AttributeValue implementation for Ssid.
The IEEE 802.11 SSID Information Element.
void SendPacket(double rxPowerDbm)
Send packet function.
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
void CheckRxDroppedBitmapAmpdu2(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 2.
void SetStopTime(Time stop)
Specify application stop time.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
bool m_rxDropped1500B
count dropped packets with 1500B payload
TestUnsupportedModulationReception()
Constructor.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
This objects implements the PHY state machine of the Wifi device.
void SetStartTime(Time start)
Specify application start time.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
void SetReceiveErrorCallback(RxErrorCallback callback)
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
void IncrementFailureBitmap(uint32_t size)
Increment reception failure bitmap.
uint64_t m_uid
the UID to use for the PPDU
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Ptr< SpectrumWifiPhy > m_phy
Phy.
Preamble detection test w/o frame capture.
uint8_t m_rxFailureBitmapAmpdu1
bitmap of unsuccessfully received MPDUs in A-MPDU #1
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
static const uint8_t CHANNEL_NUMBER
void Expect1000BPacketReceived()
Verify whether 1000 bytes packet has been received.
virtual ~TestUnsupportedModulationReception()
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
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 SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
uint8_t m_rxSuccessBitmapAmpdu2
bitmap of successfully received MPDUs in A-MPDU #2
Simulation virtual time values and global simulation resolution.
uint8_t m_rxSuccessBitmapAmpdu1
bitmap of successfully received MPDUs in A-MPDU #1
uint8_t m_rxFailureBitmapAmpdu2
bitmap of unsuccessfully received MPDUs in A-MPDU #2
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Time duration
The duration of the packet transmission.
void CheckRxFailureBitmapAmpdu2(uint8_t expected)
Check the RX failure bitmap for A-MPDU 2.
void CheckResults(void)
Check correctness of transmitted frames.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
Give ns3::PacketSocket powers to ns3::Node.
void DoRun(void) override
Implementation to actually run this TestCase.
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...
WifiPhyState
The state of the PHY layer.
static const uint16_t GUARD_WIDTH
TestThresholdPreambleDetectionWithoutFrameCapture()
bool m_rxSuccess1000B
count received packets with 1000B payload
uint16_t m_dropped
number of packets dropped by the AP because it was already receiving
Ptr< SpectrumWifiPhy > m_phy
Phy.
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
void DoRun(void) override
Implementation to actually run this TestCase.
uint8_t m_rxDroppedBitmapAmpdu2
bitmap of dropped MPDUs in A-MPDU #2
#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.
void Connect(std::string path, const CallbackBase &cb)
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static const uint32_t packetSize
uint8_t m_rxDroppedBitmapAmpdu1
bitmap of dropped MPDUs in A-MPDU #1
double DbmToW(double dBm)
Convert from dBm to Watts.
void CheckRxFailureBitmapAmpdu1(uint8_t expected)
Check the RX failure bitmap for A-MPDU 1.
static WifiPhyReceptionTestSuite wifiPhyReceptionTestSuite
the test suite
Simple frame capture model test.
RxSignalInfo structure containing info on the received signal.
Time Seconds(double value)
Construct a Time in the indicated unit.
void CheckPhyState(WifiPhyState expectedState)
Check the PHY state.
uint32_t m_countRxSuccess
count RX success
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
uint64_t m_uid
the UID to use for the PPDU
void SetPhysicalAddress(const Address address)
Set the destination address.
Ptr< SpectrumWifiPhy > m_phy
Phy.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
keep track of a set of node pointers.
void SetFrequency(uint16_t freq) override
If the operating channel for this object has not been set yet, the given center frequency is saved an...
void IncrementSuccessBitmap(uint32_t size)
Increment reception success bitmap.
void SetProtocol(uint16_t protocol)
Set the protocol.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.
Hold an unsigned integer type.
bool m_rxDropped1000B
count dropped packets with 1000B payload
create MAC layers for a ns3::WifiNetDevice.
void SetDefault(std::string name, const AttributeValue &value)
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
void RxFailure(Ptr< WifiPsdu > psdu)
RX failure function.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
void SendPacket(double rxPowerDbm)
Send packet function.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
virtual uint32_t GetIfIndex(void) const =0
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
void Expect1500BPacketReceived()
Verify whether 1500 bytes packet has been received.
uint32_t m_countRxFailure
count RX failure
TestSimpleFrameCaptureModel()
Helper class used to assign positions and mobility models to nodes.
void DoRun(void) override
Implementation to actually run this TestCase.
Make it easy to create and manage PHY objects for the spectrum model.
void Dropped(std::string context, Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Callback invoked when PHY drops an incoming packet.
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
wifi PHY reception Test Suite
void Reset(void)
Reset function.
uint32_t m_countRxSuccess
count RX success
Ptr< WifiMac > GetMac(void) const
virtual ~TestSimpleFrameCaptureModel()