88 #include "ns3/abort.h"
89 #include "ns3/ap-wifi-mac.h"
90 #include "ns3/application-container.h"
91 #include "ns3/command-line.h"
92 #include "ns3/config.h"
93 #include "ns3/double.h"
94 #include "ns3/he-configuration.h"
95 #include "ns3/he-phy.h"
96 #include "ns3/mobility-helper.h"
97 #include "ns3/multi-model-spectrum-channel.h"
98 #include "ns3/obss-pd-algorithm.h"
99 #include "ns3/packet-socket-client.h"
100 #include "ns3/packet-socket-helper.h"
101 #include "ns3/packet-socket-server.h"
102 #include "ns3/spectrum-wifi-helper.h"
103 #include "ns3/ssid.h"
104 #include "ns3/string.h"
105 #include "ns3/wifi-net-device.h"
116 std::string sub = context.substr(10);
117 uint32_t pos = sub.find(
"/Device");
118 return std::stoi(sub.substr(0, pos));
132 bool powerRestricted,
133 double txPowerMaxDbmSiso,
134 double txPowerMaxDbmMimo)
139 <<
" rssiDbm: " << rssiDbm <<
" powerRestricted: " << powerRestricted
140 <<
" txPowerMaxDbmSiso: " << txPowerMaxDbmSiso
141 <<
" txPowerMaxDbmMimo: " << txPowerMaxDbmMimo << std::endl;
143 else if (context ==
"2")
146 <<
" rssiDbm: " << rssiDbm <<
" powerRestricted: " << powerRestricted
147 <<
" txPowerMaxDbmSiso: " << txPowerMaxDbmSiso
148 <<
" txPowerMaxDbmMimo: " << txPowerMaxDbmMimo << std::endl;
157 main(
int argc,
char* argv[])
159 double duration = 10.0;
163 double powSta1 = 10.0;
164 double powSta2 = 10.0;
165 double powAp1 = 21.0;
166 double powAp2 = 21.0;
167 double ccaEdTrSta1 = -62;
168 double ccaEdTrSta2 = -62;
169 double ccaEdTrAp1 = -62;
170 double ccaEdTrAp2 = -62;
171 double minimumRssi = -82;
172 int channelWidth = 20;
173 uint32_t payloadSize = 1500;
175 double interval = 0.001;
176 bool enableObssPd =
true;
177 double obssPdThreshold = -72.0;
180 cmd.AddValue(
"duration",
"Duration of simulation (s)", duration);
181 cmd.AddValue(
"interval",
"Inter packet interval (s)", interval);
182 cmd.AddValue(
"enableObssPd",
"Enable/disable OBSS_PD", enableObssPd);
183 cmd.AddValue(
"d1",
"Distance between STA1 and AP1 (m)", d1);
184 cmd.AddValue(
"d2",
"Distance between STA2 and AP2 (m)", d2);
185 cmd.AddValue(
"d3",
"Distance between AP1 and AP2 (m)", d3);
186 cmd.AddValue(
"powSta1",
"Power of STA1 (dBm)", powSta1);
187 cmd.AddValue(
"powSta2",
"Power of STA2 (dBm)", powSta2);
188 cmd.AddValue(
"powAp1",
"Power of AP1 (dBm)", powAp1);
189 cmd.AddValue(
"powAp2",
"Power of AP2 (dBm)", powAp2);
190 cmd.AddValue(
"ccaEdTrSta1",
"CCA-ED Threshold of STA1 (dBm)", ccaEdTrSta1);
191 cmd.AddValue(
"ccaEdTrSta2",
"CCA-ED Threshold of STA2 (dBm)", ccaEdTrSta2);
192 cmd.AddValue(
"ccaEdTrAp1",
"CCA-ED Threshold of AP1 (dBm)", ccaEdTrAp1);
193 cmd.AddValue(
"ccaEdTrAp2",
"CCA-ED Threshold of AP2 (dBm)", ccaEdTrAp2);
194 cmd.AddValue(
"minimumRssi",
195 "Minimum RSSI for the ThresholdPreambleDetectionModel",
197 cmd.AddValue(
"channelWidth",
"Bandwidth of the channel in MHz [20, 40, or 80]", channelWidth);
198 cmd.AddValue(
"obssPdThreshold",
"Threshold for the OBSS PD Algorithm", obssPdThreshold);
199 cmd.AddValue(
"mcs",
"The constant MCS value to transmit HE PPDUs", mcs);
200 cmd.Parse(argc, argv);
202 g_resetFile1.open(
"wifi-spatial-reuse-resets-bss-1.txt", std::ofstream::out);
203 g_resetFile2.open(
"wifi-spatial-reuse-resets-bss-2.txt", std::ofstream::out);
214 spectrumChannel->AddPropagationLossModel(lossModel);
216 CreateObject<ConstantSpeedPropagationDelayModel>();
217 spectrumChannel->SetPropagationDelayModel(delayModel);
221 switch (channelWidth)
224 spectrumPhy.
Set(
"ChannelSettings",
StringValue(
"{36, 20, BAND_5GHZ, 0}"));
227 spectrumPhy.
Set(
"ChannelSettings",
StringValue(
"{62, 40, BAND_5GHZ, 0}"));
230 spectrumPhy.
Set(
"ChannelSettings",
StringValue(
"{171, 80, BAND_5GHZ, 0}"));
233 NS_ABORT_MSG(
"Unrecognized channel width: " << channelWidth);
244 wifi.SetObssPdAlgorithm(
"ns3::ConstantObssPdAlgorithm",
250 std::ostringstream oss;
251 oss <<
"HeMcs" << mcs;
252 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
264 mac.SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(ssidA));
272 mac.SetType(
"ns3::ApWifiMac",
"Ssid", SsidValue(ssidA));
288 mac.SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(ssidB));
296 mac.SetType(
"ns3::ApWifiMac",
"Ssid", SsidValue(ssidB));
308 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
309 positionAlloc->Add(Vector(d3, 0.0, 0.0));
310 positionAlloc->Add(Vector(0.0, d1, 0.0));
311 positionAlloc->Add(Vector(d3, d2, 0.0));
312 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
313 mobility.SetPositionAllocator(positionAlloc);
318 packetSocket.
Install(wifiApNodes);
329 client->SetRemote(socketAddr);
335 server->SetLocal(socketAddr);
346 client->SetRemote(socketAddr);
352 server->SetLocal(socketAddr);
356 Config::Connect(
"/NodeList/*/ApplicationList/*/$ns3::PacketSocketServer/Rx",
363 auto hePhyA = DynamicCast<HePhy>(deviceA->GetPhy()->GetPhyEntity(
WIFI_MOD_CLASS_HE));
367 auto hePhyB = DynamicCast<HePhy>(deviceB->GetPhy()->GetPhyEntity(
WIFI_MOD_CLASS_HE));
376 for (uint32_t i = 0; i < 2; i++)
379 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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
uint32_t GetSize() 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.
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.
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.
Ptr< WifiMac > GetMac() const
Ptr< HeConfiguration > GetHeConfiguration() const
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
@ 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...
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::vector< uint32_t > bytesReceived(4)
std::ofstream g_resetFile1
void SocketRx(std::string context, Ptr< const Packet > p, const Address &addr)