9#include "ns3/adhoc-wifi-mac.h"
10#include "ns3/boolean.h"
11#include "ns3/config.h"
12#include "ns3/double.h"
13#include "ns3/mgt-headers.h"
14#include "ns3/mobility-helper.h"
15#include "ns3/packet-socket-client.h"
16#include "ns3/packet-socket-helper.h"
17#include "ns3/packet-socket-server.h"
18#include "ns3/pointer.h"
19#include "ns3/random-variable-stream.h"
20#include "ns3/rng-seed-manager.h"
22#include "ns3/wifi-helper.h"
23#include "ns3/wifi-mac-helper.h"
24#include "ns3/wifi-net-device.h"
25#include "ns3/wifi-psdu.h"
26#include "ns3/yans-wifi-helper.h"
51 void DoRun()
override;
84 std::vector<Ptr<AdhocWifiMac>>
m_macs;
89 :
TestCase(
"Check beaconing operation in IBSS")
96 const auto& mpdu = *psduMap.cbegin()->second->begin();
98 if (mpdu->GetHeader().IsBeacon())
101 mpdu->GetPacket()->PeekHeader(beacon);
102 m_txBeacons.push_back({mpdu->GetHeader(), beacon});
111 for (std::size_t i = 0; i <
m_macs.size(); ++i)
113 const auto value = (
m_macs[i]->GetAddress() == sender) ? 1.0 : 0.0;
122 for (std::size_t i = 0; i <
m_txBeacons.size(); ++i)
125 m_macs.at(i % 2)->GetAddress(),
126 "Expected STAs to alternate Beacon transmissions");
127 const auto& capabilities =
m_txBeacons[i].beacon.m_capability;
141 int64_t streamNumber = 100;
148 phy.SetChannel(channel.Create());
154 mac.SetType(
"ns3::AdhocWifiMac",
159 "EnableBeaconJitter",
162 auto ibssDevices = wifi.Install(phy, mac, ibssNodes);
166 for (
uint32_t i = 0; i < ibssDevices.GetN(); ++i)
171 jitter->SetAttribute(
"Constant",
DoubleValue((i == 0) ? 0.0 : 1.0));
172 adhocMac->SetAttribute(
"BeaconJitter",
PointerValue(jitter));
173 m_macs.push_back(adhocMac);
180 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
181 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
182 mobility.SetPositionAllocator(positionAlloc);
184 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
185 mobility.Install(ibssNodes);
188 "/NodeList/*/DeviceList/0/$ns3::WifiNetDevice/Phys/0/PhyTxPsduBegin",
222 void DoRun()
override;
276 :
TestCase(
"Check transmissions in IBSS when peers have different capabilities"),
287 const auto& mpdu = *psduMap.cbegin()->second->begin();
289 if (mpdu->GetHeader().IsData())
321 "Unexpected amount of generated packets");
327 const std::size_t expectedDroppedPackets =
m_beaconing ? 1 : 0;
329 expectedDroppedPackets,
330 "Incorrect amount of dropped packets");
339 const std::size_t expectedTxPackets =
344 "Incorrect amount of transmitted packets");
351 const std::size_t expectedRxPackets =
355 "Incorrect amount of received packets");
361 "The first generated packet should have been dropped");
364 "The second generated packet should have been received");
368 for (std::size_t i = 0; i <
m_rxPackets.size(); ++i)
372 "Received packets are not in correct order");
392 NS_ABORT_MSG(
"TX and RX standards combination not covered by the test");
412 "Unexpected modulation class");
423 int64_t streamNumber = 100;
430 phy.SetChannel(channel.Create());
434 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager",
435 "IncrementRetryCountUnderBa",
439 mac.SetType(
"ns3::AdhocWifiMac",
445 auto ibssDevices = wifi.Install(phy, mac, ibssNodes.
Get(0));
448 ibssDevices.Add(wifi.Install(phy, mac, ibssNodes.
Get(1)));
455 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
456 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
457 mobility.SetPositionAllocator(positionAlloc);
459 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
460 mobility.Install(ibssNodes);
463 packetSocket.
Install(ibssNodes);
473 client->SetRemote(socketAddr);
475 client->SetStartTime(
Seconds(0.0));
476 client->SetStopTime(
Seconds(1.0));
479 server->SetLocal(socketAddr);
481 server->SetStartTime(
Seconds(0.0));
482 server->SetStopTime(
Seconds(1.0));
524 for (
auto& [txStandard, rxStandard] : std::vector<std::pair<WifiStandard, WifiStandard>>{
529 for (
auto beaconing : {
true,
false})
Test the beaconing operation in IBSS.
IbssBeaconingTest()
Constructor.
virtual void Transmit(WifiConstPsduMap psduMap, WifiTxVector txVector, Watt_u txPower)
Callback invoked when a FEM passes PSDUs to the PHY.
void DoRun() override
Implementation to actually run this TestCase.
void UpdateBeaconJitters(Mac48Address sender)
Update the BeaconJitter of the IBSS STAs based on the sender of the Beacon to have control over the r...
std::vector< Ptr< ConstantRandomVariable > > m_beaconJitters
BeaconJitter of the IBSS STAs.
std::vector< Ptr< AdhocWifiMac > > m_macs
MAC of the IBSS STAs.
void CheckResults()
Check correctness of transmitted beacon frames.
std::vector< BeaconFrameInfo > m_txBeacons
transmitted beacons
void DoSetup() override
Implementation to do any local setup required for this TestCase.
Test transmissions in IBSS when peers have different capabilities.
std::vector< Ptr< const Packet > > m_generatedPackets
generated packets
void DoRun() override
Implementation to actually run this TestCase.
WifiStandard m_rxStandard
the standard for the RX device
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::vector< Ptr< const Packet > > m_rxPackets
received packets
WifiStandard m_txStandard
the standard for the TX device
void TxGenerated(Ptr< const Packet > pkt, const Address &addr)
Callback invoked when a packet is generated by the packet socket client.
void TxDrop(Ptr< const Packet > packet)
Callback invoked when a packet is dropped by the MAC prior to enqueueing.
void CheckResults()
Check that the simulation produced the expected results.
bool m_beaconing
flag whether beacon generation is enabled
std::vector< WifiTxVector > m_txVectors
TXVECTOR of transmitted packets.
std::vector< Ptr< const Packet > > m_droppedPackets
dropped packets
IbssCapabilitiesTest(WifiStandard txStandard, WifiStandard rxStandard, bool beaconing)
Constructor.
std::size_t m_nPackets
number of packets to generate
void Receive(Ptr< const Packet > pkt, const Address &addr)
Callback invoked when a packet is received by the packet socket server.
void Transmit(WifiConstPsduMap psduMap, WifiTxVector txVector, Watt_u txPower)
Callback invoked when a FEM passes PSDUs to the PHY.
a polymophic address class
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.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
an address for a packet socket
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.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
create MAC layers for a ns3::WifiNetDevice.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
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...
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination 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 ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22).
@ WIFI_MOD_CLASS_HE
HE (Clause 27).
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double Watt_u
Watt weak type.
Information about transmitted beacon frames.
WifiMacHeader header
MAC header.
MgtBeaconHeader beacon
Beacon header.
static WifiP2pTestSuite g_wifiP2pTestSuite
the test suite