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" \endcode
64 *
65 * Another example (moving towards the AP):
66 * \code{.sh}
67 * ./ns3 run "wifi-power-adaptation-distance --manager=ns3::AparfWifiManager
68 * --outputFileName=aparf --stepsSize=-1 --STA1_x=200" \endcode
69 *
70 * To enable the log of rate and power changes:
71 * \code{.sh}
72 * export NS_LOG=PowerAdaptationDistance=level_info
73 * \endcode
74 */
75
76#include "ns3/command-line.h"
77#include "ns3/config.h"
78#include "ns3/double.h"
79#include "ns3/gnuplot.h"
80#include "ns3/internet-stack-helper.h"
81#include "ns3/ipv4-address-helper.h"
82#include "ns3/log.h"
83#include "ns3/mobility-helper.h"
84#include "ns3/mobility-model.h"
85#include "ns3/on-off-helper.h"
86#include "ns3/packet-sink-helper.h"
87#include "ns3/ssid.h"
88#include "ns3/uinteger.h"
89#include "ns3/wifi-mac-header.h"
90#include "ns3/wifi-mac.h"
91#include "ns3/wifi-net-device.h"
92#include "ns3/yans-wifi-channel.h"
93#include "ns3/yans-wifi-helper.h"
94
95using namespace ns3;
97NS_LOG_COMPONENT_DEFINE("PowerAdaptationDistance");
98
99/// Packet size generated at the AP
100static const uint32_t packetSize = 1420;
102/**
103 * \brief Class to collect node statistics.
104 */
105class NodeStatistics
106{
107 public:
108 /**
109 * \brief Constructor.
110 *
111 * \param aps Access points
112 * \param stas WiFi Stations.
113 */
115
116 /**
117 * \brief Callback called by WifiNetDevice/Phy/PhyTxBegin.
118 *
119 * \param path The trace path.
120 * \param packet The sent packet.
121 * \param powerW The Tx power.
122 */
123 void PhyCallback(std::string path, Ptr<const Packet> packet, double powerW);
124 /**
125 * \brief Callback called by PacketSink/Rx.
126 *
127 * \param path The trace path.
128 * \param packet The received packet.
129 * \param from The sender address.
130 */
131 void RxCallback(std::string path, Ptr<const Packet> packet, const Address& from);
132 /**
133 * \brief Callback called by WifiNetDevice/RemoteStationManager/x/PowerChange.
134 *
135 * \param path The trace path.
136 * \param oldPower Old Tx power.
137 * \param newPower Actual Tx power.
138 * \param dest Destination of the transmission.
139 */
140 void PowerCallback(std::string path, double oldPower, double newPower, Mac48Address dest);
141 /**
142 * \brief Callback called by WifiNetDevice/RemoteStationManager/x/RateChange.
143 *
144 * \param path The trace path.
145 * \param oldRate Old rate.
146 * \param newRate Actual rate.
147 * \param dest Destination of the transmission.
148 */
149 void RateCallback(std::string path, DataRate oldRate, DataRate newRate, Mac48Address dest);
150 /**
151 * \brief Set the Position of a node.
152 *
153 * \param node The node.
154 * \param position The position.
155 */
156 void SetPosition(Ptr<Node> node, Vector position);
157 /**
158 * Move a node.
159 * \param node The node.
160 * \param stepsSize The step size.
161 * \param stepsTime Time on each step.
162 */
163 void AdvancePosition(Ptr<Node> node, int stepsSize, Time stepsTime);
164 /**
165 * \brief Get the Position of a node.
166 *
167 * \param node The node.
168 * \return the position of the node.
169 */
170 Vector GetPosition(Ptr<Node> node);
171
172 /**
173 * \brief Get the Throughput output data
174 *
175 * \return the Throughput output data.
176 */
178 /**
179 * \brief Get the Power output data.
180 *
181 * \return the Power output data.
182 */
184
185 private:
186 /// Time, DataRate pair vector.
187 typedef std::vector<std::pair<Time, DataRate>> TxTime;
188 /**
189 * \brief Setup the WifiPhy object.
190 *
191 * \param phy The WifiPhy to setup.
192 */
193 void SetupPhy(Ptr<WifiPhy> phy);
194 /**
195 * \brief Get the time at which a given datarate has been recorded.
196 *
197 * \param rate The datarate to search.
198 * \return the time.
199 */
202 std::map<Mac48Address, dBm_u> m_currentPower; //!< Current Tx power for each sender.
203 std::map<Mac48Address, DataRate> m_currentRate; //!< Current Tx rate for each sender.
204 uint32_t m_bytesTotal; //!< Number of received bytes on a given state.
205 double m_totalEnergy; //!< Energy used on a given state.
206 double m_totalTime; //!< Time spent on a given state.
207 TxTime m_timeTable; //!< Time, DataRate table.
208 Gnuplot2dDataset m_output; //!< Throughput output data.
209 Gnuplot2dDataset m_output_power; //!< Power output data.
210};
211
213{
214 Ptr<NetDevice> device = aps.Get(0);
216 Ptr<WifiPhy> phy = wifiDevice->GetPhy();
217 SetupPhy(phy);
218 DataRate dataRate = DataRate(phy->GetDefaultMode().GetDataRate(phy->GetChannelWidth()));
219 const auto power = phy->GetTxPowerEnd();
220 for (uint32_t j = 0; j < stas.GetN(); j++)
221 {
222 Ptr<NetDevice> staDevice = stas.Get(j);
223 Ptr<WifiNetDevice> wifiStaDevice = DynamicCast<WifiNetDevice>(staDevice);
224 Mac48Address addr = wifiStaDevice->GetMac()->GetAddress();
225 m_currentPower[addr] = power;
226 m_currentRate[addr] = dataRate;
227 }
228 m_currentRate[Mac48Address("ff:ff:ff:ff:ff:ff")] = dataRate;
229 m_totalEnergy = 0;
230 m_totalTime = 0;
231 m_bytesTotal = 0;
232 m_output.SetTitle("Throughput Mbits/s");
233 m_output_power.SetTitle("Average Transmit Power");
234}
235
236void
238{
239 for (const auto& mode : phy->GetModeList())
240 {
241 WifiTxVector txVector;
242 txVector.SetMode(mode);
244 txVector.SetChannelWidth(phy->GetChannelWidth());
245 DataRate dataRate(mode.GetDataRate(phy->GetChannelWidth()));
246 Time time = phy->CalculateTxDuration(packetSize, txVector, phy->GetPhyBand());
247 NS_LOG_DEBUG(mode.GetUniqueName() << " " << time.GetSeconds() << " " << dataRate);
248 m_timeTable.emplace_back(time, dataRate);
250}
251
252Time
254{
255 for (auto i = m_timeTable.begin(); i != m_timeTable.end(); i++)
256 {
257 if (rate == i->second)
258 {
259 return i->first;
260 }
261 }
262 NS_ASSERT(false);
263 return Seconds(0);
264}
265
266void
267NodeStatistics::PhyCallback(std::string path, Ptr<const Packet> packet, double powerW)
268{
269 WifiMacHeader head;
270 packet->PeekHeader(head);
271 Mac48Address dest = head.GetAddr1();
272
273 if (head.GetType() == WIFI_MAC_DATA)
274 {
275 m_totalEnergy += pow(10.0, m_currentPower[dest] / 10.0) *
279}
280
281void
282NodeStatistics::PowerCallback(std::string path, double oldPower, double newPower, Mac48Address dest)
283{
284 m_currentPower[dest] = newPower;
285}
286
287void
288NodeStatistics::RateCallback(std::string path,
289 DataRate oldRate,
290 DataRate newRate,
291 Mac48Address dest)
292{
293 m_currentRate[dest] = newRate;
294}
295
296void
297NodeStatistics::RxCallback(std::string path, Ptr<const Packet> packet, const Address& from)
298{
299 m_bytesTotal += packet->GetSize();
300}
301
302void
303NodeStatistics::SetPosition(Ptr<Node> node, Vector position)
304{
305 Ptr<MobilityModel> mobility = node->GetObject<MobilityModel>();
306 mobility->SetPosition(position);
307}
308
309Vector
311{
312 Ptr<MobilityModel> mobility = node->GetObject<MobilityModel>();
313 return mobility->GetPosition();
314}
315
316void
317NodeStatistics::AdvancePosition(Ptr<Node> node, int stepsSize, Time stepsTime)
318{
319 Vector pos = GetPosition(node);
320 double mbs = ((m_bytesTotal * 8.0) / stepsTime.GetMicroSeconds());
321 m_bytesTotal = 0;
322 double atp = m_totalEnergy / stepsTime.GetSeconds();
323 m_totalEnergy = 0;
324 m_totalTime = 0;
325 m_output_power.Add(pos.x, atp);
326 m_output.Add(pos.x, mbs);
327 pos.x += stepsSize;
328 SetPosition(node, pos);
329 NS_LOG_INFO("At time " << Simulator::Now().GetSeconds() << " sec; setting new position to "
330 << pos);
331 Simulator::Schedule(stepsTime,
333 this,
334 node,
335 stepsSize,
336 stepsTime);
337}
338
341{
342 return m_output;
343}
344
347{
348 return m_output_power;
349}
350
351/**
352 * Callback called by WifiNetDevice/RemoteStationManager/x/PowerChange.
353 *
354 * \param path The trace path.
355 * \param oldPower Old Tx power.
356 * \param newPower Actual Tx power.
357 * \param dest Destination of the transmission.
358 */
359void
360PowerCallback(std::string path, double oldPower, double newPower, Mac48Address dest)
361{
362 NS_LOG_INFO((Simulator::Now()).GetSeconds()
363 << " " << dest << " Old power=" << oldPower << " New power=" << newPower);
364}
365
366/**
367 * \brief Callback called by WifiNetDevice/RemoteStationManager/x/RateChange.
368 *
369 * \param path The trace path.
370 * \param oldRate Old rate.
371 * \param newRate Actual rate.
372 * \param dest Destination of the transmission.
373 */
374void
375RateCallback(std::string path, DataRate oldRate, DataRate newRate, Mac48Address dest)
376{
377 NS_LOG_INFO((Simulator::Now()).GetSeconds()
378 << " " << dest << " Old rate=" << oldRate << " New rate=" << newRate);
379}
380
381int
382main(int argc, char* argv[])
383{
384 dBm_u maxPower{17};
385 dBm_u minPower{0};
386 uint32_t powerLevels{18};
387
388 uint32_t rtsThreshold{2346};
389 std::string manager{"ns3::ParfWifiManager"};
390 std::string outputFileName{"parf"};
391 int ap1_x{0};
392 int ap1_y{0};
393 int sta1_x{5};
394 int sta1_y{0};
395 uint32_t steps{200};
396 meter_u stepsSize{1};
397 Time stepsTime{"1s"};
398
399 CommandLine cmd(__FILE__);
400 cmd.AddValue("manager", "PRC Manager", manager);
401 cmd.AddValue("rtsThreshold", "RTS threshold", rtsThreshold);
402 cmd.AddValue("outputFileName", "Output filename", outputFileName);
403 cmd.AddValue("steps", "How many different distances to try", steps);
404 cmd.AddValue("stepsTime", "Time on each step", stepsTime);
405 cmd.AddValue("stepsSize", "Distance between steps", stepsSize);
406 cmd.AddValue("maxPower", "Maximum available transmission level (dbm).", maxPower);
407 cmd.AddValue("minPower", "Minimum available transmission level (dbm).", minPower);
408 cmd.AddValue("powerLevels",
409 "Number of transmission power levels available between "
410 "TxPowerStart and TxPowerEnd included.",
411 powerLevels);
412 cmd.AddValue("AP1_x", "Position of AP1 in x coordinate", ap1_x);
413 cmd.AddValue("AP1_y", "Position of AP1 in y coordinate", ap1_y);
414 cmd.AddValue("STA1_x", "Position of STA1 in x coordinate", sta1_x);
415 cmd.AddValue("STA1_y", "Position of STA1 in y coordinate", sta1_y);
416 cmd.Parse(argc, argv);
417
418 if (steps == 0)
419 {
420 std::cout << "Exiting without running simulation; steps value of 0" << std::endl;
421 }
422
423 Time simuTime = (steps + 1) * stepsTime;
424
425 // Define the APs
426 NodeContainer wifiApNodes;
427 wifiApNodes.Create(1);
428
429 // Define the STAs
431 wifiStaNodes.Create(1);
432
434 wifi.SetStandard(WIFI_STANDARD_80211a);
435 WifiMacHelper wifiMac;
436 YansWifiPhyHelper wifiPhy;
438
439 wifiPhy.SetChannel(wifiChannel.Create());
440
441 NetDeviceContainer wifiApDevices;
442 NetDeviceContainer wifiStaDevices;
443 NetDeviceContainer wifiDevices;
444
445 // Configure the STA node
446 wifi.SetRemoteStationManager("ns3::MinstrelWifiManager",
447 "RtsCtsThreshold",
448 UintegerValue(rtsThreshold));
449 wifiPhy.Set("TxPowerStart", DoubleValue(maxPower));
450 wifiPhy.Set("TxPowerEnd", DoubleValue(maxPower));
451
452 Ssid ssid = Ssid("AP");
453 wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
454 wifiStaDevices.Add(wifi.Install(wifiPhy, wifiMac, wifiStaNodes.Get(0)));
455
456 // Configure the AP node
457 wifi.SetRemoteStationManager(manager,
458 "DefaultTxPowerLevel",
459 UintegerValue(powerLevels - 1),
460 "RtsCtsThreshold",
461 UintegerValue(rtsThreshold));
462 wifiPhy.Set("TxPowerStart", DoubleValue(minPower));
463 wifiPhy.Set("TxPowerEnd", DoubleValue(maxPower));
464 wifiPhy.Set("TxPowerLevels", UintegerValue(powerLevels));
465
466 ssid = Ssid("AP");
467 wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));
468 wifiApDevices.Add(wifi.Install(wifiPhy, wifiMac, wifiApNodes.Get(0)));
469
470 wifiDevices.Add(wifiStaDevices);
471 wifiDevices.Add(wifiApDevices);
472
473 // Configure the mobility.
476 // Initial position of AP and STA
477 positionAlloc->Add(Vector(ap1_x, ap1_y, 0.0));
478 NS_LOG_INFO("Setting initial AP position to " << Vector(ap1_x, ap1_y, 0.0));
479 positionAlloc->Add(Vector(sta1_x, sta1_y, 0.0));
480 NS_LOG_INFO("Setting initial STA position to " << Vector(sta1_x, sta1_y, 0.0));
481 mobility.SetPositionAllocator(positionAlloc);
482 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
483 mobility.Install(wifiApNodes.Get(0));
484 mobility.Install(wifiStaNodes.Get(0));
485
486 // Statistics counter
487 NodeStatistics statistics = NodeStatistics(wifiApDevices, wifiStaDevices);
488
489 // Move the STA by stepsSize meters every stepsTime seconds
490 Simulator::Schedule(Seconds(0.5) + stepsTime,
492 &statistics,
493 wifiStaNodes.Get(0),
494 stepsSize,
495 stepsTime);
496
497 // Configure the IP stack
499 stack.Install(wifiApNodes);
500 stack.Install(wifiStaNodes);
502 address.SetBase("10.1.1.0", "255.255.255.0");
503 Ipv4InterfaceContainer i = address.Assign(wifiDevices);
504 Ipv4Address sinkAddress = i.GetAddress(0);
505 uint16_t port = 9;
506
507 // Configure the CBR generator
508 PacketSinkHelper sink("ns3::UdpSocketFactory", InetSocketAddress(sinkAddress, port));
509 ApplicationContainer apps_sink = sink.Install(wifiStaNodes.Get(0));
510
511 OnOffHelper onoff("ns3::UdpSocketFactory", InetSocketAddress(sinkAddress, port));
512 onoff.SetConstantRate(DataRate("54Mb/s"), packetSize);
513 onoff.SetAttribute("StartTime", TimeValue(Seconds(0.5)));
514 onoff.SetAttribute("StopTime", TimeValue(simuTime));
515 ApplicationContainer apps_source = onoff.Install(wifiApNodes.Get(0));
516
517 apps_sink.Start(Seconds(0.5));
518 apps_sink.Stop(simuTime);
519
520 //------------------------------------------------------------
521 //-- Setup stats and data collection
522 //--------------------------------------------
523
524 // Register packet receptions to calculate throughput
525 Config::Connect("/NodeList/1/ApplicationList/*/$ns3::PacketSink/Rx",
527
528 // Register power and rate changes to calculate the Average Transmit Power
529 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
530 manager + "/PowerChange",
532 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
533 manager + "/RateChange",
535
536 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
538
539 // Callbacks to print every change of power and rate
540 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
541 manager + "/PowerChange",
543 Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/RemoteStationManager/$" +
544 manager + "/RateChange",
546
547 Simulator::Stop(simuTime);
549
550 std::ofstream outfile("throughput-" + outputFileName + ".plt");
551 Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + ".eps", "Throughput");
552 gnuplot.SetTerminal("post eps color enhanced");
553 gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)");
554 gnuplot.SetTitle("Throughput (AP to STA) vs time");
555 gnuplot.AddDataset(statistics.GetDatafile());
556 gnuplot.GenerateOutput(outfile);
557
558 if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" ||
559 manager == "ns3::RrpaaWifiManager")
560 {
561 std::ofstream outfile2("power-" + outputFileName + ".plt");
562 gnuplot = Gnuplot("power-" + outputFileName + ".eps", "Average Transmit Power");
563 gnuplot.SetTerminal("post eps color enhanced");
564 gnuplot.SetLegend("Time (seconds)", "Power (mW)");
565 gnuplot.SetTitle("Average transmit power (AP to STA) vs time");
566 gnuplot.AddDataset(statistics.GetPowerDatafile());
567 gnuplot.GenerateOutput(outfile2);
568 }
569
571
572 return 0;
573}
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.
void PowerCallback(std::string path, double oldPower, double newPower, Mac48Address dest)
Callback called by WifiNetDevice/RemoteStationManager/x/PowerChange.
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.
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:90
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
void SetTitle(const std::string &title)
Change line title.
Definition gnuplot.cc:137
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.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
The IEEE 802.11 SSID Information Element.
Definition ssid.h:25
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:392
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:402
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)
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
void Connect(std::string path, const CallbackBase &cb)
Definition config.cc:967
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
@ 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.
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:684
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580
@ WIFI_MAC_DATA
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