78#include "ns3/ap-wifi-mac.h"
79#include "ns3/application-container.h"
80#include "ns3/command-line.h"
81#include "ns3/config.h"
82#include "ns3/double.h"
83#include "ns3/he-configuration.h"
84#include "ns3/he-phy.h"
85#include "ns3/mobility-helper.h"
86#include "ns3/multi-model-spectrum-channel.h"
87#include "ns3/obss-pd-algorithm.h"
88#include "ns3/packet-socket-client.h"
89#include "ns3/packet-socket-helper.h"
90#include "ns3/packet-socket-server.h"
91#include "ns3/spectrum-wifi-helper.h"
93#include "ns3/string.h"
94#include "ns3/wifi-net-device.h"
105 std::string sub = context.substr(10);
107 return std::stoi(sub.substr(0, pos));
121 bool powerRestricted,
122 double txPowerMaxDbmSiso,
123 double txPowerMaxDbmMimo)
128 <<
" rssiDbm: " << rssiDbm <<
" powerRestricted: " << powerRestricted
129 <<
" txPowerMaxDbmSiso: " << txPowerMaxDbmSiso
130 <<
" txPowerMaxDbmMimo: " << txPowerMaxDbmMimo << std::endl;
132 else if (context ==
"2")
135 <<
" rssiDbm: " << rssiDbm <<
" powerRestricted: " << powerRestricted
136 <<
" txPowerMaxDbmSiso: " << txPowerMaxDbmSiso
137 <<
" txPowerMaxDbmMimo: " << txPowerMaxDbmMimo << std::endl;
146main(
int argc,
char* argv[])
148 Time duration{
"10s"};
156 dBm_u ccaEdTrSta1{-62};
157 dBm_u ccaEdTrSta2{-62};
158 dBm_u ccaEdTrAp1{-62};
159 dBm_u ccaEdTrAp2{-62};
160 dBm_u minimumRssi{-82};
161 int channelWidth{20};
164 Time interval{
"1ms"};
165 bool enableObssPd{
true};
166 dBm_u obssPdThreshold{-72.0};
169 cmd.AddValue(
"duration",
"Duration of simulation", duration);
170 cmd.AddValue(
"interval",
"Inter packet interval", interval);
171 cmd.AddValue(
"enableObssPd",
"Enable/disable OBSS_PD", enableObssPd);
172 cmd.AddValue(
"d1",
"Distance between STA1 and AP1 (m)", d1);
173 cmd.AddValue(
"d2",
"Distance between STA2 and AP2 (m)", d2);
174 cmd.AddValue(
"d3",
"Distance between AP1 and AP2 (m)", d3);
175 cmd.AddValue(
"powSta1",
"Power of STA1 (dBm)", powSta1);
176 cmd.AddValue(
"powSta2",
"Power of STA2 (dBm)", powSta2);
177 cmd.AddValue(
"powAp1",
"Power of AP1 (dBm)", powAp1);
178 cmd.AddValue(
"powAp2",
"Power of AP2 (dBm)", powAp2);
179 cmd.AddValue(
"ccaEdTrSta1",
"CCA-ED Threshold of STA1 (dBm)", ccaEdTrSta1);
180 cmd.AddValue(
"ccaEdTrSta2",
"CCA-ED Threshold of STA2 (dBm)", ccaEdTrSta2);
181 cmd.AddValue(
"ccaEdTrAp1",
"CCA-ED Threshold of AP1 (dBm)", ccaEdTrAp1);
182 cmd.AddValue(
"ccaEdTrAp2",
"CCA-ED Threshold of AP2 (dBm)", ccaEdTrAp2);
183 cmd.AddValue(
"minimumRssi",
184 "Minimum RSSI for the ThresholdPreambleDetectionModel",
186 cmd.AddValue(
"channelWidth",
"Bandwidth of the channel in MHz [20, 40, or 80]", channelWidth);
187 cmd.AddValue(
"obssPdThreshold",
"Threshold for the OBSS PD Algorithm", obssPdThreshold);
188 cmd.AddValue(
"mcs",
"The constant MCS value to transmit HE PPDUs", mcs);
189 cmd.Parse(argc, argv);
191 g_resetFile1.open(
"wifi-spatial-reuse-resets-bss-1.txt", std::ofstream::out);
192 g_resetFile2.open(
"wifi-spatial-reuse-resets-bss-2.txt", std::ofstream::out);
203 spectrumChannel->AddPropagationLossModel(lossModel);
206 spectrumChannel->SetPropagationDelayModel(delayModel);
210 switch (channelWidth)
213 spectrumPhy.
Set(
"ChannelSettings",
StringValue(
"{36, 20, BAND_5GHZ, 0}"));
216 spectrumPhy.
Set(
"ChannelSettings",
StringValue(
"{62, 40, BAND_5GHZ, 0}"));
219 spectrumPhy.
Set(
"ChannelSettings",
StringValue(
"{171, 80, BAND_5GHZ, 0}"));
222 NS_ABORT_MSG(
"Unrecognized channel width: " << channelWidth);
233 wifi.SetObssPdAlgorithm(
"ns3::ConstantObssPdAlgorithm",
239 std::ostringstream oss;
240 oss <<
"HeMcs" << mcs;
241 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
253 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssidA));
261 mac.SetType(
"ns3::ApWifiMac",
"Ssid",
SsidValue(ssidA));
268 apDevice->GetHeConfiguration()->SetAttribute(
"BssColor",
UintegerValue(1));
277 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssidB));
285 mac.SetType(
"ns3::ApWifiMac",
"Ssid",
SsidValue(ssidB));
289 apWifiMac = ap2Device->GetMac()->GetObject<
ApWifiMac>();
292 ap2Device->GetHeConfiguration()->SetAttribute(
"BssColor",
UintegerValue(2));
297 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
298 positionAlloc->Add(Vector(d3, 0.0, 0.0));
299 positionAlloc->Add(Vector(0.0, d1, 0.0));
300 positionAlloc->Add(Vector(d3, d2, 0.0));
301 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
302 mobility.SetPositionAllocator(positionAlloc);
307 packetSocket.
Install(wifiApNodes);
308 packetSocket.
Install(wifiStaNodes);
318 client->SetRemote(socketAddr);
324 server->SetLocal(socketAddr);
335 client->SetRemote(socketAddr);
341 server->SetLocal(socketAddr);
345 Config::Connect(
"/NodeList/*/ApplicationList/*/$ns3::PacketSocketServer/Rx",
368 std::cout <<
"Throughput for BSS " << i + 1 <<
": " <<
throughput <<
" Mbit/s" << std::endl;
a polymophic address class
holds a vector of ns3::Application pointers.
Parse command-line arguments.
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
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.
bool TraceConnect(std::string name, std::string context, const CallbackBase &cb)
Connect a TraceSource to a Callback with a context.
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 Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
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.
void SetChannel(const Ptr< SpectrumChannel > channel)
The IEEE 802.11 SSID Information Element.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
Hold together all Wifi-related objects.
void Set(std::string name, const AttributeValue &v)
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
void SetPreambleDetectionModel(std::string type, Args &&... args)
Helper function used to set the preamble detection model.
void Connect(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
uint32_t bytesReceived
Counter of the received bytes.
uint32_t ContextToNodeId(std::string context)
std::ofstream g_resetFile2
void ResetTrace(std::string context, uint8_t bssColor, double rssiDbm, bool powerRestricted, double txPowerMaxDbmSiso, double txPowerMaxDbmMimo)
std::ofstream g_resetFile1
void SocketRx(std::string context, Ptr< const Packet > p, const Address &addr)