57 #include "ns3/core-module.h"
58 #include "ns3/network-module.h"
59 #include "ns3/internet-module.h"
60 #include "ns3/mobility-module.h"
61 #include "ns3/wifi-module.h"
62 #include "ns3/applications-module.h"
63 #include "ns3/stats-module.h"
64 #include "ns3/flow-monitor-module.h"
76 void CheckStatistics (
double time);
86 uint32_t m_bytesTotal;
98 m_bytesTotal += packet->
GetSize ();
125 double mbs = ((m_bytesTotal * 8.0) / (1000000 * stepsTime));
127 m_output.Add (pos.x, mbs);
145 int main (
int argc,
char *argv[])
147 uint32_t rtsThreshold = 65535;
148 std::string staManager =
"ns3::MinstrelHtWifiManager";
149 std::string apManager =
"ns3::MinstrelHtWifiManager";
150 std::string standard =
"802.11n-5GHz";
151 std::string outputFileName =
"minstrelHT";
152 uint32_t BE_MaxAmpduSize = 65535;
153 bool shortGuardInterval =
false;
154 uint32_t chWidth = 20;
164 cmd.
AddValue (
"staManager",
"PRC Manager of the STA", staManager);
165 cmd.
AddValue (
"apManager",
"PRC Manager of the AP", apManager);
166 cmd.
AddValue (
"standard",
"Wifi Phy Standard", standard);
167 cmd.
AddValue (
"shortGuardInterval",
"Enable Short Guard Interval in all stations", shortGuardInterval);
168 cmd.
AddValue (
"channelWidth",
"Channel width of all the stations", chWidth);
169 cmd.
AddValue (
"rtsThreshold",
"RTS threshold", rtsThreshold);
170 cmd.
AddValue (
"BE_MaxAmpduSize",
"BE Mac A-MPDU size", BE_MaxAmpduSize);
171 cmd.
AddValue (
"outputFileName",
"Output filename", outputFileName);
172 cmd.
AddValue (
"steps",
"How many different distances to try", steps);
173 cmd.
AddValue (
"stepsTime",
"Time on each step", stepsTime);
174 cmd.
AddValue (
"stepsSize",
"Distance between steps", stepsSize);
175 cmd.
AddValue (
"AP1_x",
"Position of AP1 in x coordinate", ap1_x);
176 cmd.
AddValue (
"AP1_y",
"Position of AP1 in y coordinate", ap1_y);
177 cmd.
AddValue (
"STA1_x",
"Position of STA1 in x coordinate", sta1_x);
178 cmd.
AddValue (
"STA1_y",
"Position of STA1 in y coordinate", sta1_y);
179 cmd.
Parse (argc, argv);
181 int simuTime = steps * stepsTime;
203 if (standard ==
"802.11a" || standard ==
"802.11b" || standard ==
"802.11g")
205 if (standard ==
"802.11a")
209 else if (standard ==
"802.11b")
213 else if (standard ==
"802.11g")
223 wifiMac.
SetType (
"ns3::StaWifiMac",
226 wifiStaDevices.
Add (wifi.
Install (wifiPhy, wifiMac, wifiStaNodes.
Get (0)));
232 wifiMac.
SetType (
"ns3::ApWifiMac",
234 wifiApDevices.
Add (wifi.
Install (wifiPhy, wifiMac, wifiApNodes.
Get (0)));
236 else if (standard ==
"802.11n-2.4GHz" || standard ==
"802.11n-5GHz")
238 if (standard ==
"802.11n-2.4GHz")
242 else if (standard ==
"802.11n-5GHz")
253 wifiMac.
SetType (
"ns3::StaWifiMac",
257 wifiStaDevices.
Add (wifi.
Install (wifiPhy, wifiMac, wifiStaNodes.
Get (0)));
263 wifiMac.
SetType (
"ns3::ApWifiMac",
266 wifiApDevices.
Add (wifi.
Install (wifiPhy, wifiMac, wifiApNodes.
Get (0)));
268 else if (standard ==
"802.11ac")
277 wifiMac.
SetType (
"ns3::StaWifiMac",
281 wifiStaDevices.
Add (wifi.
Install (wifiPhy, wifiMac, wifiStaNodes.
Get (0)));
287 wifiMac.
SetType (
"ns3::ApWifiMac",
290 wifiApDevices.
Add (wifi.
Install (wifiPhy, wifiMac, wifiApNodes.
Get (0)));
293 wifiDevices.
Add (wifiStaDevices);
294 wifiDevices.
Add (wifiApDevices);
303 positionAlloc->
Add (Vector (ap1_x, ap1_y, 0.0));
304 positionAlloc->
Add (Vector (sta1_x, sta1_y, 0.0));
318 stack.Install (wifiApNodes);
319 stack.Install (wifiStaNodes);
321 address.
SetBase (
"10.1.1.0",
"255.255.255.0");
331 onoff.SetConstantRate (
DataRate (
"200Mb/s"), 1420);
348 Config::Connect (
"/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" + apManager +
"/RateChange",
354 std::ofstream outfile ((
"throughput-" + outputFileName +
".plt").c_str ());
355 Gnuplot gnuplot =
Gnuplot ((
"throughput-" + outputFileName +
".eps").c_str (),
"Throughput");
357 gnuplot.
SetLegend (
"Time (seconds)",
"Throughput (Mb/s)");
358 gnuplot.
SetTitle (
"Throughput (AP to STA) vs time");
ERP-OFDM PHY (Clause 19, Section 19.5)
Custom version of log2() to deal with Bug 1467.
holds a vector of ns3::Application pointers.
create HT-enabled MAC layers for a ns3::WifiNetDevice.
AttributeValue implementation for Boolean.
HT OFDM PHY for the 5 GHz band (clause 20)
void SetPosition(Ptr< Node > node, Vector position)
static void AdvancePosition(Ptr< Node > node)
Class to represent a 2D points plot.
holds a vector of std::pair of Ptr and interface index.
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(std::string type, 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< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
void Set(std::string path, const AttributeValue &value)
static Vector GetPosition(Ptr< Node > node)
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Vector GetPosition(void) const
void AddDataset(const GnuplotDataset &dataset)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
void Set(std::string name, const AttributeValue &v)
HT OFDM PHY for the 2.4 GHz band (clause 20)
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
helps to create WifiNetDevice objects
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
void AdvancePosition(Ptr< Node > node, int stepsSize, int stepsTime)
static void SetPosition(Ptr< Node > node, Vector position)
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
a polymophic address class
Gnuplot2dDataset GetDatafile()
void RxCallback(std::string path, Ptr< const Packet > packet, const Address &from)
static HtWifiMacHelper Default(void)
Create a mac helper in a default working state.
Class for representing data rates.
Keep track of the current position and velocity of an object.
void SetChannel(Ptr< YansWifiChannel > channel)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
AttributeValue implementation for Time.
void SetTitle(const std::string &title)
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
static NqosWifiMacHelper Default(void)
Create a mac helper in a default working state.
void RateCallback(std::string path, uint64_t rate, Mac48Address dest)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
create non QoS-enabled MAC layers for a ns3::WifiNetDevice.
Parse command-line arguments.
void Connect(std::string path, const CallbackBase &cb)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static VhtWifiMacHelper Default(void)
Create a mac helper in a default working state.
OFDM PHY for the 5 GHz band (Clause 17)
create VHT-enabled MAC layers for a ns3::WifiNetDevice.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void SetMobilityModel(std::string type, 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(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
manage and create wifi channel objects for the yans model.
static Time Now(void)
Return the current simulation virtual time.
void SetPosition(const Vector &position)
The IEEE 802.11 SSID Information Element.
virtual void SetType(std::string type, 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(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
Set the underlying type of the MAC and its attributes.
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Ssid.
void Add(Vector v)
Add a position to the list of positions.
NodeStatistics(NetDeviceContainer aps, NetDeviceContainer stas)
virtual void SetType(std::string type, 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(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
void CheckStatistics(double time)
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
void SetTerminal(const std::string &terminal)
Vector GetPosition(Ptr< Node > node)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const