9#include "ns3/ap-wifi-mac.h"
10#include "ns3/boolean.h"
11#include "ns3/config.h"
12#include "ns3/mobility-helper.h"
13#include "ns3/multi-model-spectrum-channel.h"
14#include "ns3/packet-socket-client.h"
15#include "ns3/packet-socket-helper.h"
16#include "ns3/packet-socket-server.h"
17#include "ns3/qos-utils.h"
18#include "ns3/rng-seed-manager.h"
19#include "ns3/spectrum-wifi-helper.h"
20#include "ns3/string.h"
22#include "ns3/wifi-net-device.h"
23#include "ns3/wifi-psdu.h"
50 void DoRun()
override;
106 :
TestCase(
"Test case for resuming data transmission when the recipient moves back"),
127 for (
const auto& psduPair : psduMap)
129 std::stringstream ss;
130 ss <<
" " << psduPair.second->GetHeader(0).GetTypeString() <<
" seq "
131 << psduPair.second->GetHeader(0).GetSequenceNumber() <<
" from "
132 << psduPair.second->GetAddr2() <<
" to " << psduPair.second->GetAddr1();
137 if (psduMap.begin()->second->GetHeader(0).IsQosData())
141 if (!psduMap.begin()->second->GetHeader(0).IsRetry())
177 client->SetRemote(socket);
179 client->SetStartTime(
Seconds(0.5));
180 client->SetStopTime(
Seconds(1));
183 server->SetLocal(socket);
185 server->SetStartTime(
Seconds(0));
186 server->SetStopTime(
Seconds(1));
193 Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/ChannelSettings",
203 if (state == WifiPhyState::SWITCHING)
216 int64_t streamNumber = 100;
223 spectrumChannel->AddPropagationLossModel(lossModel);
225 spectrumChannel->SetPropagationDelayModel(delayModel);
228 phy.SetChannel(spectrumChannel);
229 phy.Set(
"ChannelSettings",
StringValue(
"{36, 20, BAND_5GHZ, 0}"));
233 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
236 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(
Ssid(
"channel-switching-test")));
240 mac.SetType(
"ns3::ApWifiMac",
243 "EnableBeaconJitter",
254 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
255 positionAlloc->Add(Vector(5.0, 0.0, 0.0));
256 mobility.SetPositionAllocator(positionAlloc);
258 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
265 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/$ns3::StaWifiMac/Assoc",
272 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/State/State",
275 "/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Phy/State/State",
284 "The QoS Data frame should have been transmitted twice by the STA");
287 "The QoS Data frame should have been received once by the AP");
This test verifies that communication between an AP and a STA resumes after that both switch channel ...
uint8_t m_assocCount
count of completed Assoc Request procedures
NetDeviceContainer m_staDevice
STA device container.
void StateChange(uint32_t nodeId, Time start, Time duration, WifiPhyState state)
Callback invoked when the PHY on the given node changes state.
uint32_t m_payloadSize
payload size in bytes
NodeContainer m_staNode
STA node container.
void Associated(Mac48Address bssid)
Callback invoked when a station associates with an AP.
void SendPacket()
Send a packet from the STA to the AP through a packet socket.
uint64_t m_rxBytes
RX bytes.
void L7Receive(Ptr< const Packet > p, const Address &addr)
Function to trace packets received by the server application.
std::array< uint8_t, 2 > m_channelSwitchCount
Per-node number of channel switch events.
NetDeviceContainer m_apDevice
AP device container.
WifiChannelSwitchingTest()
Constructor.
void ChannelSwitch()
Request channel switch on both AP and STA.
NodeContainer m_apNode
AP node container.
~WifiChannelSwitchingTest() override
void Transmit(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when PHY receives a PSDU to transmit from the MAC.
void DoRun() override
Implementation to actually run this TestCase.
uint8_t m_txCount
count of transmissions
WifiChannelSwitchingTestSuite()
a polymophic address class
AttributeValue implementation for Boolean.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
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.
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 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.
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 EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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.
Make it easy to create and manage PHY objects for the spectrum model.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=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
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.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
void Set(std::string path, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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 MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
WifiPhyState
The state of the PHY layer.
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...
static WifiChannelSwitchingTestSuite g_issue211TestSuite
the test suite