A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-power-adaptation-distance.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Universidad de la República - Uruguay
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Matias Richart <mrichart@fing.edu.uy>
7 */
8
9/**
10 * This example program is designed to illustrate the behavior of three
11 * power/rate-adaptive WiFi rate controls; namely, ns3::ParfWifiManager,
12 * ns3::AparfWifiManager and ns3::RrpaaWifiManager.
13 *
14 * The output of this is typically two plot files, named throughput-parf.plt
15 * (or throughput-aparf.plt, if Aparf is used) and power-parf.plt. If
16 * Gnuplot program is available, one can use it to convert the plt file
17 * into an eps file, by running:
18 * @code{.sh}
19 * gnuplot throughput-parf.plt
20 * @endcode
21 * Also, to enable logging of rate and power changes to the terminal, set this
22 * environment variable:
23 * @code{.sh}
24 * export NS_LOG=PowerAdaptationDistance=level_info
25 * @endcode
26 *
27 * This simulation consist of 2 nodes, one AP and one STA.
28 * The AP generates UDP traffic with a CBR of 54 Mbps to the STA.
29 * The AP can use any power and rate control mechanism and the STA uses
30 * only Minstrel rate control.
31 * The STA can be configured to move away from (or towards to) the AP.
32 * By default, the AP is at coordinate (0,0,0) and the STA starts at
33 * coordinate (5,0,0) (meters) and moves away on the x axis by 1 meter every
34 * second.
35 *
36 * The output consists of:
37 * - A plot of average throughput vs. distance.
38 * - A plot of average transmit power vs. distance.
39 * - (if logging is enabled) the changes of power and rate to standard output.
40 *
41 * The Average Transmit Power is defined as an average of the power
42 * consumed per measurement interval, expressed in milliwatts. The
43 * power level for each frame transmission is reported by the simulator,
44 * and the energy consumed is obtained by multiplying the power by the
45 * frame duration. At every 'stepTime' (defaulting to 1 second), the
46 * total energy for the collection period is divided by the step time
47 * and converted from dbm to milliwatt units, and this average is
48 * plotted against time.
49 *
50 * When neither Parf, Aparf or Rrpaa is selected as the rate control, the
51 * generation of the plot of average transmit power vs distance is suppressed
52 * since the other Wifi rate controls do not support the necessary callbacks
53 * for computing the average power.
54 *
55 * To display all the possible arguments and their defaults:
56 * @code{.sh}
57 * ./ns3 run "wifi-power-adaptation-distance --help"
58 * @endcode
59 *
60 * Example usage (selecting Aparf rather than Parf):
61 * @code{.sh}
62 * ./ns3 run "wifi-power-adaptation-distance --manager=ns3::AparfWifiManager
63 * --outputFileName=aparf"
64 * @endcode
65 *
66 * Another example (moving towards the AP):
67 * @code{.sh}
68 * ./ns3 run "wifi-power-adaptation-distance --manager=ns3::AparfWifiManager
69 * --outputFileName=aparf --stepsSize=-1 --STA1_x=200"
70 * @endcode
71 *
72 * To enable the log of rate and power changes:
73 * @code{.sh}
74 * export NS_LOG=PowerAdaptationDistance=level_info
75 * @endcode
76 */
77
78#include "ns3/command-line.h"
79#include "ns3/config.h"
80#include "ns3/double.h"
81#include "ns3/gnuplot.h"
82#include "ns3/internet-stack-helper.h"
83#include "ns3/ipv4-address-helper.h"
84#include "ns3/log.h"
85#include "ns3/mobility-helper.h"
86#include "ns3/mobility-model.h"
87#include "ns3/on-off-helper.h"
88#include "ns3/packet-sink-helper.h"
89#include "ns3/ssid.h"
90#include "ns3/uinteger.h"
91#include "ns3/wifi-mac-header.h"
92#include "ns3/wifi-mac.h"
93#include "ns3/wifi-net-device.h"
94#include "ns3/yans-wifi-channel.h"
95#include "ns3/yans-wifi-helper.h"
96
97using namespace ns3;
99NS_LOG_COMPONENT_DEFINE("PowerAdaptationDistance");
100
101/// Packet size generated at the AP
102static const uint32_t packetSize = 1420;
104/**
105 * @brief Class to collect node statistics.
106 */
107class NodeStatistics
108{
109 public:
110 /**
111 * @brief Constructor.
112 *
113 * @param aps Access points
114 * @param stas WiFi Stations.
115 */
117
118 /**
119 * @brief Callback called by WifiNetDevice/Phy/PhyTxBegin.
120 *
121 * @param path The trace path.
122 * @param packet The sent packet.
123 * @param powerW The Tx power.
124 */
125 void PhyCallback(std::string path, Ptr<const Packet> packet, double powerW);
126 /**
127 * @brief Callback called by PacketSink/Rx.
128 *
129 * @param path The trace path.
130 * @param packet The received packet.
131 * @param from The sender address.
132 */
133 void RxCallback(std::string path, Ptr<const Packet> packet, const Address& from);
134 /**
135 * @brief Callback called by WifiNetDevice/RemoteStationManager/x/PowerChange.
136 *
137 * @param path The trace path.
138 * @param oldPower Old Tx power.
139 * @param newPower Actual Tx power.
140 * @param dest Destination of the transmission.
141 */
142 void PowerCallback(std::string path, dBm_u oldPower, dBm_u newPower, Mac48Address dest);
143 /**
144 * @brief Callback called by WifiNetDevice/RemoteStationManager/x/RateChange.
145 *
146 * @param path The trace path.
147 * @param oldRate Old rate.
148 * @param newRate Actual rate.
149 * @param dest Destination of the transmission.
150 */
151 void RateCallback(std::string path, DataRate oldRate, DataRate newRate, Mac48Address dest);
152 /**
153 * @brief Set the Position of a node.
154 *
155 * @param node The node.
156 * @param position The position.
157 */
158 void SetPosition(Ptr<Node> node, Vector position);
159 /**
160 * Move a node.
161 * @param node The node.
162 * @param stepsSize The step size.
163 * @param stepsTime Time on each step.
164 */
165 void AdvancePosition(Ptr<Node> node, int stepsSize, Time stepsTime);
166 /**
167 * @brief Get the Position of a node.
168 *
169 * @param node The node.
170 * @return the position of the node.
171 */
172 Vector GetPosition(Ptr<Node> node);
173
174 /**
175 * @brief Get the Throughput output data
176 *
177 * @return the Throughput output data.
178 */
180 /**
181 * @brief Get the Power output data.
182 *
183 * @return the Power output data.
184 */
186
187 private:
188 /// Time, DataRate pair vector.
189 typedef std::vector<std::pair<Time, DataRate>> TxTime;
190 /**
191 * @brief Setup the WifiPhy object.
192 *
193 * @param phy The WifiPhy to setup.
194 */
195 void SetupPhy(Ptr<WifiPhy> phy);
196 /**
197 * @brief Get the time at which a given datarate has been recorded.
198 *
199 * @param rate The datarate to search.
200 * @return the time.
201 */
204 std::map<Mac48Address, dBm_u> m_currentPower; //!< Current Tx power for each sender.
205 std::map<Mac48Address, DataRate> m_currentRate; //!< Current Tx rate for each sender.
206 uint32_t m_bytesTotal; //!< Number of received bytes on a given state.
207 double m_totalEnergy; //!< Energy used on a given state.
208 double m_totalTime; //!< Time spent on a given state.
209 TxTime m_timeTable; //!< Time, DataRate table.
210 Gnuplot2dDataset m_output; //!< Throughput output data.
211 Gnuplot2dDataset m_output_power; //!< Power output data.
212};
213
215{
216 Ptr<NetDevice> device = aps.Get(0);
218 Ptr<WifiPhy> phy = wifiDevice->GetPhy();
219 SetupPhy(phy);
220 DataRate dataRate = DataRate(phy->GetDefaultMode().GetDataRate(phy->GetChannelWidth()));
221 const auto power = phy->GetTxPowerEnd();
222 for (uint32_t j = 0; j < stas.GetN(); j++)
223 {
224 Ptr<NetDevice> staDevice = stas.Get(j);
225 Ptr<WifiNetDevice> wifiStaDevice = DynamicCast<WifiNetDevice>(staDevice);
226 Mac48Address addr = wifiStaDevice->GetMac()->GetAddress();
227 m_currentPower[addr] = power;
228 m_currentRate[addr] = dataRate;
229 }
230 m_currentRate[Mac48Address("ff:ff:ff:ff:ff:ff")] = dataRate;
231 m_totalEnergy = 0;
232 m_totalTime = 0;
233 m_bytesTotal = 0;
234 m_output.SetTitle("Throughput Mbits/s");
235 m_output_power.SetTitle("Average Transmit Power");
236}
237
238void
240{
241 for (const auto& mode : phy->GetModeList())
242 {
243 WifiTxVector txVector;
244 txVector.SetMode(mode);
246 txVector.SetChannelWidth(phy->GetChannelWidth());
247 DataRate dataRate(mode.GetDataRate(phy->GetChannelWidth()));
248 Time time = WifiPhy::CalculateTxDuration(packetSize, txVector, phy->GetPhyBand());
249 NS_LOG_DEBUG(mode.GetUniqueName() << " " << time.GetSeconds() << " " << dataRate);
250 m_timeTable.emplace_back(time, dataRate);
252}
253
254Time
256{
257 for (auto i = m_timeTable.begin(); i != m_timeTable.end(); i++)
258 {
259 if (rate == i->second)
260 {
261 return i->first;
262 }
263 }
264 NS_ASSERT(false);
265 return Time(0);
266}
267
268void
269NodeStatistics::PhyCallback(std::string path, Ptr<const Packet> packet, double powerW)
270{
271 WifiMacHeader head;
272 packet->PeekHeader(head);
273 Mac48Address dest = head.GetAddr1();
274
275 if (head.GetType() == WIFI_MAC_DATA)
276 {
277 const auto txTimeSeconds = GetCalcTxTime(m_currentRate[dest]).GetSeconds();
278 m_totalEnergy += DbmToW(m_currentPower[dest]) * txTimeSeconds;
279 m_totalTime += txTimeSeconds;
281}
282
283void
284NodeStatistics::PowerCallback(std::string path, dBm_u oldPower, dBm_u newPower, Mac48Address dest)
285{
286 m_currentPower[dest] = dBm_u{newPower};
287}
288
289void
290NodeStatistics::RateCallback(std::string path,
291 DataRate oldRate,
292 DataRate newRate,
293 Mac48Address dest)
294{
295 m_currentRate[dest] = newRate;
296}
297
298void
299NodeStatistics::RxCallback(std::string path, Ptr<const Packet> packet, const Address& from)
300{
301 m_bytesTotal += packet->GetSize();
302}
303
304void
305NodeStatistics::SetPosition(Ptr<Node> node, Vector position)
306{
307 Ptr<MobilityModel> mobility = node->GetObject<MobilityModel>();
308 mobility->SetPosition(position);
309}
310
311Vector
313{
314 Ptr<MobilityModel> mobility = node->GetObject<MobilityModel>();
315 return mobility->GetPosition();
316}
317
318void
319NodeStatistics::AdvancePosition(Ptr<Node> node, int stepsSize, Time stepsTime)
320{
321 Vector pos = GetPosition(node);
322 double mbs = ((m_bytesTotal * 8.0) / stepsTime.GetMicroSeconds());
323 m_bytesTotal = 0;
324 double atp = m_totalEnergy / stepsTime.GetSeconds();
325 m_totalEnergy = 0;
326 m_totalTime = 0;
327 m_output_power.Add(pos.x, atp);
328 m_output.Add(pos.x, mbs);
329 pos.x += stepsSize;
330 SetPosition(node, pos);
331 NS_LOG_INFO("At time " << Simulator::Now().GetSeconds() << " sec; setting new position to "
332 << pos);
333 Simulator::Schedule(stepsTime,
335 this,
336 node,
337 stepsSize,
338 stepsTime);
339}
340
343{
344 return m_output;
345}
346
349{
350 return m_output_power;
351}
352
353/**
354 * Callback called by WifiNetDevice/RemoteStationManager/x/PowerChange.
355 *
356 * @param path The trace path.
357 * @param oldPower Old Tx power.
358 * @param newPower Actual Tx power.
359 * @param dest Destination of the transmission.
360 */
361void
362PowerCallback(std::string path, double oldPower, double newPower, Mac48Address dest)
363{
364 NS_LOG_INFO((Simulator::Now()).GetSeconds()
365 << " " << dest << " Old power=" << oldPower << " New power=" << newPower);
366}
367
368/**
369 * @brief Callback called by WifiNetDevice/RemoteStationManager/x/RateChange.
370 *
371 * @param path The trace path.
372 * @param oldRate Old rate.
373 * @param newRate Actual rate.
374 * @param dest Destination of the transmission.
375 */
376void
377RateCallback(std::string path, DataRate oldRate, DataRate newRate, Mac48Address dest)
378{
379 NS_LOG_INFO((Simulator::Now()).GetSeconds()
380 << " " << dest << " Old rate=" << oldRate << " New rate=" << newRate);
381}
382
383int
384main(int argc, char* argv[])
385{
386 dBm_u maxPower{17};
387 dBm_u minPower{0};
388 uint32_t powerLevels{18};
389
390 uint32_t rtsThreshold{2346};
391 std::string manager{"ns3::ParfWifiManager"};
392 std::string outputFileName{"parf"};
393 int ap1_x{0};
394 int ap1_y{0};
395 int sta1_x{5};
396 int sta1_y{0};
397 uint32_t steps{200};
398 meter_u stepsSize{1};
399 Time stepsTime{"1s"};
400
401 CommandLine cmd(__FILE__);
402 cmd.AddValue("manager", "PRC Manager", manager);
403 cmd.AddValue("rtsThreshold", "RTS threshold", rtsThreshold);
404 cmd.AddValue("outputFileName", "Output filename", outputFileName);
405 cmd.AddValue("steps", "How many different distances to try", steps);
406 cmd.AddValue("stepsTime", "Time on each step", stepsTime);
407 cmd.AddValue("stepsSize", "Distance between steps", stepsSize);
408 cmd.AddValue("maxPower", "Maximum available transmission level (dbm).", maxPower);
409 cmd.AddValue("minPower", "Minimum available transmission level (dbm).", minPower);
410 cmd.AddValue("powerLevels",
411 "Number of transmission power levels available between "
412 "TxPowerStart and TxPowerEnd included.",
413 powerLevels);
414 cmd.AddValue("AP1_x", "Position of AP1 in x coordinate", ap1_x);
415 cmd.AddValue("AP1_y", "Position of AP1 in y coordinate", ap1_y);
416 cmd.AddValue("STA1_x", "Position of STA1 in x coordinate", sta1_x);
417 cmd.AddValue("STA1_y", "Position of STA1 in y coordinate", sta1_y);
418 cmd.Parse(argc, argv);
419
420 if (steps == 0)
421 {
422 std::cout << "Exiting without running simulation; steps value of 0" << std::endl;
423 }
424
425 Time simuTime = (steps + 1) * stepsTime;
426
427 // Define the APs
428 NodeContainer wifiApNodes;
429 wifiApNodes.Create(1);
430
431 // Define the STAs
433 wifiStaNodes.Create(1);
434
436 wifi.SetStandard(WIFI_STANDARD_80211a);
437 WifiMacHelper wifiMac;
438 YansWifiPhyHelper wifiPhy;
440
441 wifiPhy.SetChannel(wifiChannel.Create());
442
443 NetDeviceContainer wifiApDevices;
444 NetDeviceContainer wifiStaDevices;
445 NetDeviceContainer wifiDevices;
446
447 // Configure the STA node
448 wifi.SetRemoteStationManager("ns3::MinstrelWifiManager",
449 "RtsCtsThreshold",
450 UintegerValue(rtsThreshold));
451 wifiPhy.Set("TxPowerStart", DoubleValue(maxPower));
452 wifiPhy.Set("TxPowerEnd", DoubleValue(maxPower));
453
454 Ssid ssid = Ssid("AP");
455 wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
456 wifiStaDevices.Add(wifi.Install(wifiPhy, wifiMac, wifiStaNodes.Get(0)));
457
458 // Configure the AP node
459 wifi.SetRemoteStationManager(manager,
460 "DefaultTxPowerLevel",
461 UintegerValue(WIFI_MIN_TX_PWR_LEVEL + powerLevels - 1),
462 "RtsCtsThreshold",
463 UintegerValue(rtsThreshold));
464 wifiPhy.Set("TxPowerStart", DoubleValue(minPower));
465 wifiPhy.Set("TxPowerEnd", DoubleValue(maxPower));
466 wifiPhy.Set("TxPowerLevels", UintegerValue(powerLevels));
467
468 ssid = Ssid("AP");
469 wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
470 wifiApDevices.Add(wifi.Install(wifiPhy, wifiMac, wifiApNodes.Get(0)));
471
472 wifiDevices.Add(wifiStaDevices);
473 wifiDevices.Add(wifiApDevices);
474
475 // Configure the mobility.
478 // Initial position of AP and STA
479 positionAlloc->Add(Vector(ap1_x, ap1_y, 0.0));
480 NS_LOG_INFO("Setting initial AP position to " << Vector(ap1_x, ap1_y, 0.0));
481 positionAlloc->Add(Vector(sta1_x, sta1_y, 0.0));
482 NS_LOG_INFO("Setting initial STA position to " << Vector(sta1_x, sta1_y, 0.0));
483 mobility.SetPositionAllocator(positionAlloc);
484 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
485 mobility.Install(wifiApNodes.Get(0));
486 mobility.Install(wifiStaNodes.Get(0));
487
488 // Statistics counter
489 NodeStatistics statistics = NodeStatistics(wifiApDevices, wifiStaDevices);
490
491 // Move the STA by stepsSize meters every stepsTime seconds
492 Simulator::Schedule(Seconds(0.5) + stepsTime,
494 &statistics,
495 wifiStaNodes.Get(0),
496 stepsSize,
497 stepsTime);
498
499 // Configure the IP stack
501 stack.Install(wifiApNodes);
502 stack.Install(wifiStaNodes);
504 address.SetBase("10.1.1.0", "255.255.255.0");
505 Ipv4InterfaceContainer i = address.Assign(wifiDevices);
506 Ipv4Address sinkAddress = i.GetAddress(0);
507 uint16_t port = 9;
508
509 // Configure the CBR generator
510 PacketSinkHelper sink("ns3::UdpSocketFactory", InetSocketAddress(sinkAddress, port));
511 ApplicationContainer apps_sink = sink.Install(wifiStaNodes.Get(0));
512
513 OnOffHelper onoff("ns3::UdpSocketFactory", InetSocketAddress(sinkAddress, port));
514 onoff.SetConstantRate(DataRate("54Mb/s"), packetSize);
515 onoff.SetAttribute("StartTime", TimeValue(Seconds(0.5)));
516 onoff.SetAttribute("StopTime", TimeValue(simuTime));
517 ApplicationContainer apps_source = onoff.Install(wifiApNodes.Get(0));
518
519 apps_sink.Start(Seconds(0.5));
520 apps_sink.Stop(simuTime);
521
522 //------------------------------------------------------------
523 //-- Setup stats and data collection
524 //--------------------------------------------
525
526 // Register packet receptions to calculate throughput
527 Config::Connect("/NodeList/1/ApplicationList/*/$ns3::PacketSink/Rx",
529
530 // Register power and rate changes to calculate the Average Transmit Power
531 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
532 manager + "/PowerChange",
534 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
535 manager + "/RateChange",
537
538 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
540
541 // Callbacks to print every change of power and rate
542 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
543 manager + "/PowerChange",
545 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
546 manager + "/RateChange",
548
549 Simulator::Stop(simuTime);
551
552 std::ofstream outfile("throughput-" + outputFileName + ".plt");
553 Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + ".eps", "Throughput");
554 gnuplot.SetTerminal("post eps color enhanced");
555 gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)");
556 gnuplot.SetTitle("Throughput (AP to STA) vs time");
557 gnuplot.AddDataset(statistics.GetDatafile());
558 gnuplot.GenerateOutput(outfile);
559
560 if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" ||
561 manager == "ns3::RrpaaWifiManager")
562 {
563 std::ofstream outfile2("power-" + outputFileName + ".plt");
564 gnuplot = Gnuplot("power-" + outputFileName + ".eps", "Average Transmit Power");
565 gnuplot.SetTerminal("post eps color enhanced");
566 gnuplot.SetLegend("Time (seconds)", "Power (mW)");
567 gnuplot.SetTitle("Average transmit power (AP to STA) vs time");
568 gnuplot.AddDataset(statistics.GetPowerDatafile());
569 gnuplot.GenerateOutput(outfile2);
570 }
571
573
574 return 0;
575}
Class to collect node statistics.
void SetPosition(Ptr< Node > node, Vector position)
Set the Position of a node.
Gnuplot2dDataset m_output_power
Power output data.
Gnuplot2dDataset GetPowerDatafile()
Get the Power output data.
TxTime m_timeTable
Time, DataRate table.
void RateCallback(std::string path, DataRate oldRate, DataRate newRate, Mac48Address dest)
Callback called by WifiNetDevice/RemoteStationManager/x/RateChange.
Gnuplot2dDataset GetDatafile()
Get the Throughput output data.
void RxCallback(std::string path, Ptr< const Packet > packet, const Address &from)
Callback called by PacketSink/Rx.
NodeStatistics(NetDeviceContainer aps, NetDeviceContainer stas)
Constructor.
Time GetCalcTxTime(DataRate rate)
Get the time at which a given datarate has been recorded.
double m_totalTime
Time spent on a given state.
uint32_t m_bytesTotal
Number of received bytes on a given state.
void SetupPhy(Ptr< WifiPhy > phy)
Setup the WifiPhy object.
std::vector< std::pair< Time, DataRate > > TxTime
Time, DataRate pair vector.
void AdvancePosition(Ptr< Node > node, int stepsSize, Time stepsTime)
Move a node.
Vector GetPosition(Ptr< Node > node)
Get the Position of a node.
double m_totalEnergy
Energy used on a given state.
Gnuplot2dDataset m_output
Throughput output data.
void PowerCallback(std::string path, dBm_u oldPower, dBm_u newPower, Mac48Address dest)
Callback called by WifiNetDevice/RemoteStationManager/x/PowerChange.
std::map< Mac48Address, DataRate > m_currentRate
Current Tx rate for each sender.
std::map< Mac48Address, dBm_u > m_currentPower
Current Tx power for each sender.
void PhyCallback(std::string path, Ptr< const Packet > packet, double powerW)
Callback called by WifiNetDevice/Phy/PhyTxBegin.
a polymophic address class
Definition address.h:114
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Parse command-line arguments.
Class for representing data rates.
Definition data-rate.h:78
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Class to represent a 2D points plot.
Definition gnuplot.h:105
void Add(double x, double y)
Definition gnuplot.cc:366
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition gnuplot.h:359
void AddDataset(const GnuplotDataset &dataset)
Definition gnuplot.cc:785
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Definition gnuplot.cc:765
void SetTerminal(const std::string &terminal)
Definition gnuplot.cc:753
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition gnuplot.cc:791
void SetTitle(const std::string &title)
Definition gnuplot.cc:759
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
an EUI-48 address
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
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.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:580
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:125
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:191
static void Run()
Run the simulation.
Definition simulator.cc:161
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:169
The IEEE 802.11 SSID Information Element.
Definition ssid.h:27
AttributeValue implementation for Ssid.
Definition ssid.h:98
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:398
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:408
Hold an unsigned integer type.
Definition uinteger.h:34
helps to create WifiNetDevice objects
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
virtual WifiMacType GetType() const
Return the type (WifiMacType).
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
void Set(std::string name, const AttributeValue &v)
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition wifi-phy.cc:1574
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetChannelWidth(MHz_u channelWidth)
Sets the selected channelWidth.
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
uint16_t port
Definition dsdv-manet.cc:33
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
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...
Definition callback.h:690
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:966
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:201
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:267
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:274
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1313
@ WIFI_STANDARD_80211a
@ WIFI_PREAMBLE_LONG
address
Definition first.py:36
stack
Definition first.py:33
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static constexpr uint8_t WIFI_MIN_TX_PWR_LEVEL
minimum TX power level value
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:643
double dBm_u
dBm weak type
Definition wifi-units.h:27
@ WIFI_MAC_DATA
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
Definition wifi-utils.cc:32
double meter_u
meter weak type
Definition wifi-units.h:32
ssid
Definition third.py:82
wifi
Definition third.py:84
mobility
Definition third.py:92
wifiStaNodes
Definition third.py:73
void RateCallback(std::string path, DataRate oldRate, DataRate newRate, Mac48Address dest)
Callback called by WifiNetDevice/RemoteStationManager/x/RateChange.
static const uint32_t packetSize
Packet size generated at the AP.
void PowerCallback(std::string path, double oldPower, double newPower, Mac48Address dest)
Callback called by WifiNetDevice/RemoteStationManager/x/PowerChange.
Ptr< PacketSink > sink
Pointer to the packet sink application.
Definition wifi-tcp.cc:44