63 #include "ns3/command-line.h" 64 #include "ns3/config.h" 65 #include "ns3/string.h" 66 #include "ns3/spectrum-wifi-helper.h" 68 #include "ns3/mobility-helper.h" 69 #include "ns3/application-container.h" 70 #include "ns3/multi-model-spectrum-channel.h" 71 #include "ns3/wifi-net-device.h" 72 #include "ns3/ap-wifi-mac.h" 73 #include "ns3/he-configuration.h" 74 #include "ns3/packet-socket-helper.h" 75 #include "ns3/packet-socket-client.h" 76 #include "ns3/packet-socket-server.h" 85 std::string sub = context.substr (10);
86 uint32_t pos = sub.find (
"/Device");
87 return atoi (sub.substr (0, pos).c_str ());
98 main (
int argc,
char *argv[])
100 double duration = 10.0;
104 double powSta1 = 10.0;
105 double powSta2 = 10.0;
106 double powAp1 = 21.0;
107 double powAp2 = 21.0;
108 double ccaEdTrSta1 = -62;
109 double ccaEdTrSta2 = -62;
110 double ccaEdTrAp1 = -62;
111 double ccaEdTrAp2 = -62;
112 uint32_t payloadSize = 1500;
114 double interval = 0.001;
115 bool enableObssPd =
true;
116 double obssPdThreshold = -72.0;
119 cmd.AddValue (
"duration",
"Duration of simulation (s)", duration);
120 cmd.AddValue (
"interval",
"Inter packet interval (s)", interval);
121 cmd.AddValue (
"enableObssPd",
"Enable/disable OBSS_PD", enableObssPd);
122 cmd.AddValue (
"d1",
"Distance between STA1 and AP1 (m)", d1);
123 cmd.AddValue (
"d2",
"Distance between STA2 and AP2 (m)", d2);
124 cmd.AddValue (
"d3",
"Distance between AP1 and AP2 (m)", d3);
125 cmd.AddValue (
"powSta1",
"Power of STA1 (dBm)", powSta1);
126 cmd.AddValue (
"powSta2",
"Power of STA2 (dBm)", powSta2);
127 cmd.AddValue (
"powAp1",
"Power of AP1 (dBm)", powAp1);
128 cmd.AddValue (
"powAp2",
"Power of AP2 (dBm)", powAp2);
129 cmd.AddValue (
"ccaEdTrSta1",
"CCA-ED Threshold of STA1 (dBm)", ccaEdTrSta1);
130 cmd.AddValue (
"ccaEdTrSta2",
"CCA-ED Threshold of STA2 (dBm)", ccaEdTrSta2);
131 cmd.AddValue (
"ccaEdTrAp1",
"CCA-ED Threshold of AP1 (dBm)", ccaEdTrAp1);
132 cmd.AddValue (
"ccaEdTrAp2",
"CCA-ED Threshold of AP2 (dBm)", ccaEdTrAp2);
133 cmd.AddValue (
"mcs",
"The constant MCS value to transmit HE PPDUs", mcs);
134 cmd.Parse (argc, argv);
159 wifi.SetObssPdAlgorithm (
"ns3::ConstantObssPdAlgorithm",
164 std::ostringstream oss;
165 oss <<
"HeMcs" << mcs;
166 wifi.SetRemoteStationManager (
"ns3::ConstantRateWifiManager",
176 mac.SetType (
"ns3::StaWifiMac",
185 mac.SetType (
"ns3::ApWifiMac",
202 mac.SetType (
"ns3::StaWifiMac",
211 mac.SetType (
"ns3::ApWifiMac",
224 positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
225 positionAlloc->
Add (Vector (d3, 0.0, 0.0));
226 positionAlloc->
Add (Vector (0.0, d1, 0.0));
227 positionAlloc->
Add (Vector (d3, d2, 0.0));
228 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
229 mobility.SetPositionAllocator (positionAlloc);
234 packetSocket.
Install (wifiApNodes);
280 for (uint32_t i = 0; i < 2; i++)
282 double throughput =
static_cast<double> (
bytesReceived[2 + i]) * 8 / 1000 / 1000 / duration;
283 std::cout <<
"Throughput for BSS " << i + 1 <<
": " << throughput <<
" Mbit/s" << std::endl;
void Set(std::string name, const AttributeValue &v)
holds a vector of ns3::Application pointers.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void SetPreambleDetectionModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Ptr< HeConfiguration > GetHeConfiguration(void) const
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Hold variables of type string.
an address for a packet socket
static void Run(void)
Run the simulation.
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
helps to create WifiNetDevice objects
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
a polymophic address class
void SocketRx(std::string context, Ptr< const Packet > p, const Address &addr)
AttributeValue implementation for Time.
void SetChannel(Ptr< SpectrumChannel > channel)
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Hold together all Wifi-related objects.
std::vector< uint32_t > bytesReceived(4)
Parse command-line arguments.
void Connect(std::string path, const CallbackBase &cb)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPhysicalAddress(const Address address)
Set the destination address.
keep track of a set of node pointers.
create MAC layers for a ns3::WifiNetDevice.
Wi-Fi AP state machineHandle association, dis-association and authentication, of STAs within an infra...
void SetErrorRateModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
The IEEE 802.11 SSID Information Element.
Helper class used to assign positions and mobility models to nodes.
Ptr< WifiMac > GetMac(void) const
uint32_t ContextToNodeId(std::string context)
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Ssid.
void SetProtocol(uint16_t protocol)
Set the protocol.
void Add(Vector v)
Add a position to the list of positions.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
a unique identifier for an interface.
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...
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Make it easy to create and manage PHY objects for the spectrum model.