|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
53 #include "ns3/gnuplot.h"
54 #include "ns3/command-line.h"
55 #include "ns3/config.h"
56 #include "ns3/uinteger.h"
57 #include "ns3/boolean.h"
59 #include "ns3/yans-wifi-helper.h"
61 #include "ns3/mobility-helper.h"
62 #include "ns3/internet-stack-helper.h"
63 #include "ns3/ipv4-address-helper.h"
64 #include "ns3/packet-sink-helper.h"
65 #include "ns3/on-off-helper.h"
66 #include "ns3/yans-wifi-channel.h"
67 #include "ns3/mobility-model.h"
89 uint32_t m_bytesTotal;
101 m_bytesTotal += packet->
GetSize ();
128 double mbs = ((m_bytesTotal * 8.0) / (1000000 * stepsTime));
130 m_output.Add (pos.x, mbs);
148 int main (
int argc,
char *argv[])
150 uint32_t rtsThreshold = 65535;
151 std::string staManager =
"ns3::MinstrelHtWifiManager";
152 std::string apManager =
"ns3::MinstrelHtWifiManager";
153 std::string standard =
"802.11n-5GHz";
154 std::string outputFileName =
"minstrelHT";
155 uint32_t BeMaxAmpduSize = 65535;
156 bool shortGuardInterval =
false;
157 uint32_t chWidth = 20;
167 cmd.AddValue (
"staManager",
"PRC Manager of the STA", staManager);
168 cmd.AddValue (
"apManager",
"PRC Manager of the AP", apManager);
169 cmd.AddValue (
"standard",
"Wifi Phy Standard", standard);
170 cmd.AddValue (
"shortGuardInterval",
"Enable Short Guard Interval in all stations", shortGuardInterval);
171 cmd.AddValue (
"channelWidth",
"Channel width of all the stations", chWidth);
172 cmd.AddValue (
"rtsThreshold",
"RTS threshold", rtsThreshold);
173 cmd.AddValue (
"BeMaxAmpduSize",
"BE Mac A-MPDU size", BeMaxAmpduSize);
174 cmd.AddValue (
"outputFileName",
"Output filename", outputFileName);
175 cmd.AddValue (
"steps",
"How many different distances to try", steps);
176 cmd.AddValue (
"stepsTime",
"Time on each step", stepsTime);
177 cmd.AddValue (
"stepsSize",
"Distance between steps", stepsSize);
178 cmd.AddValue (
"AP1_x",
"Position of AP1 in x coordinate", ap1_x);
179 cmd.AddValue (
"AP1_y",
"Position of AP1 in y coordinate", ap1_y);
180 cmd.AddValue (
"STA1_x",
"Position of STA1 in x coordinate", sta1_x);
181 cmd.AddValue (
"STA1_y",
"Position of STA1 in y coordinate", sta1_y);
182 cmd.Parse (argc, argv);
184 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")
220 wifi.SetRemoteStationManager (staManager,
"RtsCtsThreshold",
UintegerValue (rtsThreshold));
223 wifiMac.
SetType (
"ns3::StaWifiMac",
228 wifi.SetRemoteStationManager (apManager,
"RtsCtsThreshold",
UintegerValue (rtsThreshold));
231 wifiMac.
SetType (
"ns3::ApWifiMac",
233 wifiApDevices.
Add (
wifi.Install (wifiPhy, wifiMac, wifiApNodes.
Get (0)));
235 else if (standard ==
"802.11n-2.4GHz" || standard ==
"802.11n-5GHz")
237 if (standard ==
"802.11n-2.4GHz")
241 else if (standard ==
"802.11n-5GHz")
249 wifi.SetRemoteStationManager (staManager,
"RtsCtsThreshold",
UintegerValue (rtsThreshold));
252 wifiMac.
SetType (
"ns3::StaWifiMac",
257 wifi.SetRemoteStationManager (apManager,
"RtsCtsThreshold",
UintegerValue (rtsThreshold));
260 wifiMac.
SetType (
"ns3::ApWifiMac",
262 wifiApDevices.
Add (
wifi.Install (wifiPhy, wifiMac, wifiApNodes.
Get (0)));
266 else if (standard ==
"802.11ac")
272 wifi.SetRemoteStationManager (staManager,
"RtsCtsThreshold",
UintegerValue (rtsThreshold));
275 wifiMac.
SetType (
"ns3::StaWifiMac",
280 wifi.SetRemoteStationManager (apManager,
"RtsCtsThreshold",
UintegerValue (rtsThreshold));
283 wifiMac.
SetType (
"ns3::ApWifiMac",
285 wifiApDevices.
Add (
wifi.Install (wifiPhy, wifiMac, wifiApNodes.
Get (0)));
290 wifiDevices.
Add (wifiStaDevices);
291 wifiDevices.
Add (wifiApDevices);
297 Config::Set (
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/ShortGuardIntervalSupported",
BooleanValue (shortGuardInterval));
303 positionAlloc->
Add (Vector (ap1_x, ap1_y, 0.0));
304 positionAlloc->
Add (Vector (sta1_x, sta1_y, 0.0));
305 mobility.SetPositionAllocator (positionAlloc);
306 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
318 stack.Install (wifiApNodes);
321 address.SetBase (
"10.1.1.0",
"255.255.255.0");
331 onoff.SetConstantRate (
DataRate (
"400Mb/s"), 1420);
348 Config::ConnectFailSafe (
"/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");
holds a vector of ns3::NetDevice pointers
@ WIFI_STANDARD_80211n_5GHZ
static Vector GetPosition(Ptr< Node > node)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void AdvancePosition(Ptr< Node > node, int stepsSize, int stepsTime)
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
Parse command-line arguments.
void RxCallback(std::string path, Ptr< const Packet > packet, const Address &from)
void Add(Vector v)
Add a position to the list of positions.
void Set(std::string path, const AttributeValue &value)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
AttributeValue implementation for Boolean.
static void SetPosition(Ptr< Node > node, Vector position)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
helps to create WifiNetDevice objects
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Ipv4 addresses are stored in host order in this class.
void SetTerminal(const std::string &terminal)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void SetChannel(Ptr< YansWifiChannel > channel)
Class to represent a 2D points plot.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
AttributeValue implementation for Ssid.
The IEEE 802.11 SSID Information Element.
Class for representing data rates.
Ptr< YansWifiChannel > Create(void) const
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
void SetPosition(Ptr< Node > node, Vector position)
a polymophic address class
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
NodeStatistics(NetDeviceContainer aps, NetDeviceContainer stas)
bool ConnectFailSafe(std::string path, const CallbackBase &cb)
This function will attempt to find all trace sources which match the input path and will then connect...
void CheckStatistics(double time)
void AddDataset(const GnuplotDataset &dataset)
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 void Run(void)
Run the simulation.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Gnuplot2dDataset GetDatafile()
void Connect(std::string path, const CallbackBase &cb)
Vector GetPosition(Ptr< Node > node)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
holds a vector of ns3::Application pointers.
void SetTitle(const std::string &title)
AttributeValue implementation for Time.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
void SetType(std::string type, Args &&... args)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
manage and create wifi channel objects for the YANS model.
create MAC layers for a ns3::WifiNetDevice.
@ WIFI_STANDARD_80211n_2_4GHZ
aggregate IP/TCP/UDP functionality to existing Nodes.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Helper class used to assign positions and mobility models to nodes.
void RateCallback(std::string path, uint64_t rate, Mac48Address dest)