A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-multirate.cc
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: Duy Nguyen <duy@soe.ucsc.edu>
16 */
17
18#include "ns3/boolean.h"
19#include "ns3/command-line.h"
20#include "ns3/config.h"
21#include "ns3/double.h"
22#include "ns3/flow-monitor-helper.h"
23#include "ns3/gnuplot.h"
24#include "ns3/internet-stack-helper.h"
25#include "ns3/ipv4-address-helper.h"
26#include "ns3/ipv4-list-routing-helper.h"
27#include "ns3/ipv4-static-routing-helper.h"
28#include "ns3/log.h"
29#include "ns3/mobility-helper.h"
30#include "ns3/mobility-model.h"
31#include "ns3/olsr-helper.h"
32#include "ns3/on-off-helper.h"
33#include "ns3/rectangle.h"
34#include "ns3/string.h"
35#include "ns3/uinteger.h"
36#include "ns3/yans-wifi-channel.h"
37#include "ns3/yans-wifi-helper.h"
38
39using namespace ns3;
40
41NS_LOG_COMPONENT_DEFINE("multirate");
42
43/**
44 * WiFi multirate experiment class.
45 *
46 * It handles the creation and run of an experiment.
47 *
48 * Scenarios: 100 nodes, multiple simultaneous flows, multi-hop ad hoc, routing,
49 * and mobility
50 *
51 * QUICK INSTRUCTIONS:
52 *
53 * To optimize build:
54 * ./ns3 configure -d optimized
55 * ./ns3
56 *
57 * To compile:
58 * ./ns3 run wifi-multirate
59 *
60 * To compile with command line(useful for varying parameters):
61 * ./ns3 run "wifi-multirate --totalTime=0.3s --rateManager=ns3::MinstrelWifiManager"
62 *
63 * To turn on NS_LOG:
64 * export NS_LOG=multirate=level_all
65 * (can only view log if built with ./ns3 configure -d debug)
66 *
67 * To debug:
68 * ./ns3 shell
69 * gdb ./build/debug/examples/wireless/wifi-multirate
70 *
71 * To view pcap files:
72 * tcpdump -nn -tt -r filename.pcap
73 *
74 * To monitor the files:
75 * tail -f filename.pcap
76 *
77 */
78class Experiment
79{
80 public:
82 /**
83 * \brief Construct a new Experiment object
84 *
85 * \param name The name of the experiment.
86 */
87 Experiment(std::string name);
88 /**
89 * Run an experiment.
90 * \param wifi The WifiHelper class.
91 * \param wifiPhy The YansWifiPhyHelper class.
92 * \param wifiMac The WifiMacHelper class.
93 * \param wifiChannel The YansWifiChannelHelper class.
94 * \param mobility The MobilityHelper class.
95 * \return a 2D dataset of the experiment data.
96 */
98 const YansWifiPhyHelper& wifiPhy,
99 const WifiMacHelper& wifiMac,
100 const YansWifiChannelHelper& wifiChannel,
101 const MobilityHelper& mobility);
102
103 /**
104 * \brief Setup the experiment from the command line arguments.
105 *
106 * \param argc The argument count.
107 * \param argv The argument vector.
108 * \return true
109 */
110 bool CommandSetup(int argc, char** argv);
111
112 /**
113 * \brief Check if routing is enabled.
114 *
115 * \return true if routing is enabled.
116 */
117 bool IsRouting() const
118 {
119 return m_enableRouting;
120 }
121
122 /**
123 * \brief Check if mobility is enabled.
124 *
125 * \return true if mobility is enabled.
126 */
127 bool IsMobility() const
128 {
129 return m_enableMobility;
130 }
131
132 /**
133 * \brief Get the Scenario number.
134 *
135 * \return the scenario number.
136 */
138 {
139 return m_scenario;
140 }
141
142 /**
143 * \brief Get the RTS Threshold.
144 *
145 * \return the RTS Threshold.
146 */
147 std::string GetRtsThreshold() const
148 {
149 return m_rtsThreshold;
150 }
151
152 /**
153 * \brief Get the Output File Name.
154 *
155 * \return the Output File Name.
156 */
157 std::string GetOutputFileName() const
158 {
159 return m_outputFileName;
160 }
161
162 /**
163 * \brief Get the Rate Manager.
164 *
165 * \return the Rate Manager.
166 */
167 std::string GetRateManager() const
168 {
169 return m_rateManager;
170 }
171
172 private:
173 /**
174 * \brief Setup the receiving socket.
175 *
176 * \param node The receiving node.
177 * \return the Rx socket.
178 */
180 /**
181 * Generate 1-hop and 2-hop neighbors of a node in grid topology
182 * \param c The node container.
183 * \param senderId The sender ID.
184 * \return the neighbor nodes.
185 */
187
188 /**
189 * \brief Setup the application in the nodes.
190 *
191 * \param client Client node.
192 * \param server Server node.
193 * \param start Start time.
194 * \param stop Stop time.
195 */
196 void ApplicationSetup(Ptr<Node> client, Ptr<Node> server, double start, double stop);
197 /**
198 * Take the grid map, divide it into 4 quadrants
199 * Assign all nodes from each quadrant to a specific container
200 *
201 * \param c The node container.
202 */
204 /**
205 * Sources and destinations are randomly selected such that a node
206 * may be the source for multiple destinations and a node maybe a destination
207 * for multiple sources.
208 *
209 * \param c The node container.
210 */
212 /**
213 * \brief Receive a packet.
214 *
215 * \param socket The receiving socket.
216 */
218 /**
219 * \brief Calculate the throughput.
220 */
221 void CheckThroughput();
222 /**
223 * A sender node will set up a flow to each of the its neighbors
224 * in its quadrant randomly. All the flows are exponentially distributed.
225 *
226 * \param sender The sender node.
227 * \param c The node neighbors.
228 */
230
231 Gnuplot2dDataset m_output; //!< Output dataset.
232
233 double m_totalTime; //!< Total experiment time.
234 double m_expMean; //!< Exponential parameter for sending packets.
235 double m_samplingPeriod; //!< Sampling period.
236
237 uint32_t m_bytesTotal; //!< Total number of received bytes.
238 uint32_t m_packetSize; //!< Packet size.
239 uint32_t m_gridSize; //!< Grid size.
240 uint32_t m_nodeDistance; //!< Node distance.
241 uint32_t m_port; //!< Listening port.
242 uint32_t m_scenario; //!< Scenario number.
243
244 bool m_enablePcap; //!< True if PCAP output is enabled.
245 bool m_enableTracing; //!< True if tracing output is enabled.
246 bool m_enableFlowMon; //!< True if FlowMon is enabled.
247 bool m_enableRouting; //!< True if routing is enabled.
248 bool m_enableMobility; //!< True if mobility is enabled.
249
250 /**
251 * Node containers for each quadrant.
252 * @{
253 */
258 /** @} */
259 std::string m_rtsThreshold; //!< Rts threshold.
260 std::string m_rateManager; //!< Rate manager.
261 std::string m_outputFileName; //!< Output file name.
262};
263
265{
266}
267
268Experiment::Experiment(std::string name)
269 : m_output(name),
270 m_totalTime(0.3),
271 m_expMean(0.1),
272 // flows being exponentially distributed
273 m_samplingPeriod(0.1),
274 m_bytesTotal(0),
275 m_packetSize(2000),
276 m_gridSize(10),
277 // 10x10 grid for a total of 100 nodes
278 m_nodeDistance(30),
279 m_port(5000),
280 m_scenario(4),
281 m_enablePcap(false),
282 m_enableTracing(true),
283 m_enableFlowMon(false),
284 m_enableRouting(false),
285 m_enableMobility(false),
286 m_rtsThreshold("2200"),
287 // 0 for enabling rts/cts
288 m_rateManager("ns3::MinstrelWifiManager"),
289 m_outputFileName("minstrel")
290{
292}
293
296{
297 TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory");
300 sink->Bind(local);
301 sink->SetRecvCallback(MakeCallback(&Experiment::ReceivePacket, this));
302
303 return sink;
304}
305
306void
308{
309 Ptr<Packet> packet;
310 while ((packet = socket->Recv()))
311 {
312 m_bytesTotal += packet->GetSize();
313 }
314}
315
316void
318{
319 double mbs = ((m_bytesTotal * 8.0) / 1000000 / m_samplingPeriod);
320 m_bytesTotal = 0;
321 m_output.Add((Simulator::Now()).GetSeconds(), mbs);
322
323 // check throughput every samplingPeriod second
325}
326
327void
329{
330 uint32_t totalNodes = c.GetN();
331 for (uint32_t i = 0; i < totalNodes; i++)
332 {
333 if ((i % m_gridSize) <= (m_gridSize / 2 - 1))
334 {
335 // lower left quadrant
336 if (i < totalNodes / 2)
337 {
338 m_containerA.Add(c.Get(i));
339 }
340
341 // upper left quadrant
342 if (i >= (uint32_t)(4 * totalNodes) / 10)
343 {
344 m_containerC.Add(c.Get(i));
345 }
346 }
347 if ((i % m_gridSize) >= (m_gridSize / 2 - 1))
348 {
349 // lower right quadrant
350 if (i < totalNodes / 2)
351 {
352 m_containerB.Add(c.Get(i));
353 }
354
355 // upper right quadrant
356 if (i >= (uint32_t)(4 * totalNodes) / 10)
357 {
358 m_containerD.Add(c.Get(i));
359 }
360 }
361 }
362}
363
366{
367 NodeContainer nc;
368 uint32_t limit = senderId + 2;
369 for (uint32_t i = senderId - 2; i <= limit; i++)
370 {
371 // must ensure the boundaries for other topologies
372 nc.Add(c.Get(i));
373 nc.Add(c.Get(i + 10));
374 nc.Add(c.Get(i + 20));
375 nc.Add(c.Get(i - 10));
376 nc.Add(c.Get(i - 20));
377 }
378 return nc;
379}
380
381void
383{
384 uint32_t totalNodes = c.GetN();
385 Ptr<UniformRandomVariable> uvSrc = CreateObject<UniformRandomVariable>();
386 uvSrc->SetAttribute("Min", DoubleValue(0));
387 uvSrc->SetAttribute("Max", DoubleValue(totalNodes / 2 - 1));
388 Ptr<UniformRandomVariable> uvDest = CreateObject<UniformRandomVariable>();
389 uvDest->SetAttribute("Min", DoubleValue(totalNodes / 2));
390 uvDest->SetAttribute("Max", DoubleValue(totalNodes));
391
392 for (uint32_t i = 0; i < totalNodes / 3; i++)
393 {
394 ApplicationSetup(c.Get(uvSrc->GetInteger()), c.Get(uvDest->GetInteger()), 0, m_totalTime);
395 }
396}
397
398void
400{
401 // UniformRandomVariable params: (Xrange, Yrange)
402 Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable>();
403 uv->SetAttribute("Min", DoubleValue(0));
404 uv->SetAttribute("Max", DoubleValue(c.GetN()));
405
406 // ExponentialRandomVariable params: (mean, upperbound)
407 Ptr<ExponentialRandomVariable> ev = CreateObject<ExponentialRandomVariable>();
408 ev->SetAttribute("Mean", DoubleValue(m_expMean));
409 ev->SetAttribute("Bound", DoubleValue(m_totalTime));
410
411 double start = 0.0;
412 double stop;
413 uint32_t destIndex;
414
415 for (uint32_t i = 0; i < c.GetN(); i++)
416 {
417 stop = start + ev->GetValue();
418 NS_LOG_DEBUG("Start=" << start << " Stop=" << stop);
419
420 do
421 {
422 destIndex = (uint32_t)uv->GetValue();
423 } while ((c.Get(destIndex))->GetId() == sender->GetId());
424
425 ApplicationSetup(sender, c.Get(destIndex), start, stop);
426
427 start = stop;
428
429 if (start > m_totalTime)
430 {
431 break;
432 }
433 }
434}
435
436/**
437 * Print the position of two nodes.
438 *
439 * \param client Client node.
440 * \param server Server node.
441 * \return a string with the nodes data and positions
442 */
443static inline std::string
445{
446 Vector serverPos = server->GetObject<MobilityModel>()->GetPosition();
447 Vector clientPos = client->GetObject<MobilityModel>()->GetPosition();
448
449 Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4>();
450 Ptr<Ipv4> ipv4Client = client->GetObject<Ipv4>();
451
452 Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress(1, 0);
453 Ipv4InterfaceAddress iaddrClient = ipv4Client->GetAddress(1, 0);
454
455 Ipv4Address ipv4AddrServer = iaddrServer.GetLocal();
456 Ipv4Address ipv4AddrClient = iaddrClient.GetLocal();
457
458 std::ostringstream oss;
459 oss << "Set up Server Device " << (server->GetDevice(0))->GetAddress() << " with ip "
460 << ipv4AddrServer << " position (" << serverPos.x << "," << serverPos.y << ","
461 << serverPos.z << ")";
462
463 oss << "Set up Client Device " << (client->GetDevice(0))->GetAddress() << " with ip "
464 << ipv4AddrClient << " position (" << clientPos.x << "," << clientPos.y << ","
465 << clientPos.z << ")"
466 << "\n";
467 return oss.str();
468}
469
470void
471Experiment::ApplicationSetup(Ptr<Node> client, Ptr<Node> server, double start, double stop)
472{
473 Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4>();
474
475 Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress(1, 0);
476 Ipv4Address ipv4AddrServer = iaddrServer.GetLocal();
477
478 NS_LOG_DEBUG(PrintPosition(client, server));
479
480 // Equipping the source node with OnOff Application used for sending
481 OnOffHelper onoff("ns3::UdpSocketFactory",
483 onoff.SetConstantRate(DataRate(54000000));
484 onoff.SetAttribute("PacketSize", UintegerValue(m_packetSize));
485 onoff.SetAttribute("Remote", AddressValue(InetSocketAddress(ipv4AddrServer, m_port)));
486
487 ApplicationContainer apps = onoff.Install(client);
488 apps.Start(Seconds(start));
489 apps.Stop(Seconds(stop));
490
492}
493
496 const YansWifiPhyHelper& wifiPhy,
497 const WifiMacHelper& wifiMac,
498 const YansWifiChannelHelper& wifiChannel,
499 const MobilityHelper& mobility)
500{
501 uint32_t nodeSize = m_gridSize * m_gridSize;
503 c.Create(nodeSize);
504
505 YansWifiPhyHelper phy = wifiPhy;
506 phy.SetChannel(wifiChannel.Create());
507
508 NetDeviceContainer devices = wifi.Install(phy, wifiMac, c);
509
511 Ipv4StaticRoutingHelper staticRouting;
512
514
515 if (m_enableRouting)
516 {
517 list.Add(staticRouting, 0);
518 list.Add(olsr, 10);
519 }
520
521 InternetStackHelper internet;
522
523 if (m_enableRouting)
524 {
525 internet.SetRoutingHelper(list); // has effect on the next Install ()
526 }
527 internet.Install(c);
528
529 Ipv4AddressHelper address;
530 address.SetBase("10.0.0.0", "255.255.255.0");
531
532 Ipv4InterfaceContainer ipInterfaces;
533 ipInterfaces = address.Assign(devices);
534
535 MobilityHelper mobil = mobility;
536 mobil.SetPositionAllocator("ns3::GridPositionAllocator",
537 "MinX",
538 DoubleValue(0.0),
539 "MinY",
540 DoubleValue(0.0),
541 "DeltaX",
543 "DeltaY",
545 "GridWidth",
547 "LayoutType",
548 StringValue("RowFirst"));
549
550 mobil.SetMobilityModel("ns3::ConstantPositionMobilityModel");
551
553 {
554 // Rectangle (xMin, xMax, yMin, yMax)
555 mobil.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
556 "Bounds",
557 RectangleValue(Rectangle(0, 500, 0, 500)),
558 "Speed",
559 StringValue("ns3::ConstantRandomVariable[Constant=10]"),
560 "Pause",
561 StringValue("ns3::ConstantRandomVariable[Constant=0.2]"));
562 }
563 mobil.Install(c);
564
565 if (m_scenario == 1 && m_enableRouting)
566 {
567 SelectSrcDest(c);
568 }
569 else if (m_scenario == 2)
570 {
571 // All flows begin at the same time
572 for (uint32_t i = 0; i < nodeSize - 1; i = i + 2)
573 {
574 ApplicationSetup(c.Get(i), c.Get(i + 1), 0, m_totalTime);
575 }
576 }
577 else if (m_scenario == 3)
578 {
580 // Note: these senders are hand-picked in order to ensure good coverage
581 // for 10x10 grid, basically one sender for each quadrant
582 // you might have to change these values for other grids
583 NS_LOG_DEBUG(">>>>>>>>>region A<<<<<<<<<");
585
586 NS_LOG_DEBUG(">>>>>>>>>region B<<<<<<<<<");
588
589 NS_LOG_DEBUG(">>>>>>>>>region C<<<<<<<<<");
591
592 NS_LOG_DEBUG(">>>>>>>>>region D<<<<<<<<<");
594 }
595 else if (m_scenario == 4)
596 {
597 // GenerateNeighbors(NodeContainer, uint32_t sender)
598 // Note: these senders are hand-picked in order to ensure good coverage
599 // you might have to change these values for other grids
600 NodeContainer c1;
601 NodeContainer c2;
602 NodeContainer c3;
603 NodeContainer c4;
604 NodeContainer c5;
605 NodeContainer c6;
606 NodeContainer c7;
607 NodeContainer c8;
608 NodeContainer c9;
609
610 c1 = GenerateNeighbors(c, 22);
611 c2 = GenerateNeighbors(c, 24);
612 c3 = GenerateNeighbors(c, 26);
613 c4 = GenerateNeighbors(c, 42);
614 c5 = GenerateNeighbors(c, 44);
615 c6 = GenerateNeighbors(c, 46);
616 c7 = GenerateNeighbors(c, 62);
617 c8 = GenerateNeighbors(c, 64);
618 c9 = GenerateNeighbors(c, 66);
619
620 SendMultiDestinations(c.Get(22), c1);
621 SendMultiDestinations(c.Get(24), c2);
622 SendMultiDestinations(c.Get(26), c3);
623 SendMultiDestinations(c.Get(42), c4);
624 SendMultiDestinations(c.Get(44), c5);
625 SendMultiDestinations(c.Get(46), c6);
626 SendMultiDestinations(c.Get(62), c7);
627 SendMultiDestinations(c.Get(64), c8);
628 SendMultiDestinations(c.Get(66), c9);
629 }
630
632
633 if (m_enablePcap)
634 {
635 phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
636 phy.EnablePcapAll(GetOutputFileName());
637 }
638
639 if (m_enableTracing)
640 {
641 AsciiTraceHelper ascii;
642 phy.EnableAsciiAll(ascii.CreateFileStream(GetOutputFileName() + ".tr"));
643 }
644
645 FlowMonitorHelper flowmonHelper;
646
647 if (m_enableFlowMon)
648 {
649 flowmonHelper.InstallAll();
650 }
651
654
655 if (m_enableFlowMon)
656 {
657 flowmonHelper.SerializeToXmlFile((GetOutputFileName() + ".flomon"), false, false);
658 }
659
661
662 return m_output;
663}
664
665bool
666Experiment::CommandSetup(int argc, char** argv)
667{
668 // for commandline input
669 CommandLine cmd(__FILE__);
670 cmd.AddValue("packetSize", "packet size", m_packetSize);
671 cmd.AddValue("totalTime", "simulation time", m_totalTime);
672 // according to totalTime, select an appropriate samplingPeriod automatically.
673 if (m_totalTime < 1.0)
674 {
675 m_samplingPeriod = 0.1;
676 }
677 else
678 {
679 m_samplingPeriod = 1.0;
680 }
681 // or user selects a samplingPeriod.
682 cmd.AddValue("samplingPeriod", "sampling period", m_samplingPeriod);
683 cmd.AddValue("rtsThreshold", "rts threshold", m_rtsThreshold);
684 cmd.AddValue("rateManager", "type of rate", m_rateManager);
685 cmd.AddValue("outputFileName", "output filename", m_outputFileName);
686 cmd.AddValue("enableRouting", "enable Routing", m_enableRouting);
687 cmd.AddValue("enableMobility", "enable Mobility", m_enableMobility);
688 cmd.AddValue("scenario", "scenario ", m_scenario);
689
690 cmd.Parse(argc, argv);
691 return true;
692}
693
694int
695main(int argc, char* argv[])
696{
698 experiment = Experiment("multirate");
699
700 // for commandline input
701 experiment.CommandSetup(argc, argv);
702
703 std::ofstream outfile(experiment.GetOutputFileName() + ".plt");
704
705 MobilityHelper mobility;
706 Gnuplot gnuplot;
707 Gnuplot2dDataset dataset;
708
709 WifiHelper wifi;
710 WifiMacHelper wifiMac;
711 YansWifiPhyHelper wifiPhy;
713
714 wifiMac.SetType("ns3::AdhocWifiMac", "Ssid", StringValue("Testbed"));
715 wifi.SetStandard(WIFI_STANDARD_80211a);
716 wifi.SetRemoteStationManager(experiment.GetRateManager());
717
718 NS_LOG_INFO("Scenario: " << experiment.GetScenario());
719 NS_LOG_INFO("Rts Threshold: " << experiment.GetRtsThreshold());
720 NS_LOG_INFO("Name: " << experiment.GetOutputFileName());
721 NS_LOG_INFO("Rate: " << experiment.GetRateManager());
722 NS_LOG_INFO("Routing: " << experiment.IsRouting());
723 NS_LOG_INFO("Mobility: " << experiment.IsMobility());
724
725 dataset = experiment.Run(wifi, wifiPhy, wifiMac, wifiChannel, mobility);
726
727 gnuplot.AddDataset(dataset);
728 gnuplot.GenerateOutput(outfile);
729
730 return 0;
731}
WiFi adhoc experiment class.
Definition: wifi-adhoc.cc:45
void ApplicationSetup(Ptr< Node > client, Ptr< Node > server, double start, double stop)
Setup the application in the nodes.
bool m_enableTracing
True if tracing output is enabled.
std::string GetRtsThreshold() const
Get the RTS Threshold.
bool m_enableMobility
True if mobility is enabled.
uint32_t m_packetSize
Packet size.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
Run an experiment.
Definition: wifi-adhoc.cc:162
std::string m_rtsThreshold
Rts threshold.
uint32_t GetScenario() const
Get the Scenario number.
NodeContainer m_containerD
Node containers for each quadrant.
uint32_t m_bytesTotal
The number of received bytes.
Definition: wifi-adhoc.cc:97
void AssignNeighbors(NodeContainer c)
Take the grid map, divide it into 4 quadrants Assign all nodes from each quadrant to a specific conta...
std::string m_rateManager
Rate manager.
std::string GetRateManager() const
Get the Rate Manager.
void SelectSrcDest(NodeContainer c)
Sources and destinations are randomly selected such that a node may be the source for multiple destin...
std::string GetOutputFileName() const
Get the Output File Name.
bool m_enableRouting
True if routing is enabled.
void ReceivePacket(Ptr< Socket > socket)
Receive a packet.
void CheckThroughput()
Calculate the throughput.
NodeContainer m_containerC
Node containers for each quadrant.
double m_expMean
Exponential parameter for sending packets.
std::string m_outputFileName
Output file name.
NodeContainer GenerateNeighbors(NodeContainer c, uint32_t senderId)
Generate 1-hop and 2-hop neighbors of a node in grid topology.
Gnuplot2dDataset m_output
The output dataset.
Definition: wifi-adhoc.cc:98
NodeContainer m_containerA
Node containers for each quadrant.
bool m_enableFlowMon
True if FlowMon is enabled.
NodeContainer m_containerB
Node containers for each quadrant.
bool CommandSetup(int argc, char **argv)
Setup the experiment from the command line arguments.
bool IsMobility() const
Check if mobility is enabled.
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
Setup the receiving socket.
bool IsRouting() const
Check if routing is enabled.
uint32_t m_port
Listening port.
uint32_t m_nodeDistance
Node distance.
void SendMultiDestinations(Ptr< Node > sender, NodeContainer c)
A sender node will set up a flow to each of the its neighbors in its quadrant randomly.
uint32_t m_scenario
Scenario number.
Experiment(std::string name)
Construct a new Experiment object.
double m_samplingPeriod
Sampling period.
uint32_t m_gridSize
Grid size.
double m_totalTime
Total experiment time.
bool m_enablePcap
True if PCAP output is enabled.
a polymophic address class
Definition: address.h:101
AttributeValue implementation for Address.
Definition: address.h:286
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.
Manage ASCII trace files for device models.
Definition: trace-helper.h:174
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Parse command-line arguments.
Definition: command-line.h:232
Class for representing data rates.
Definition: data-rate.h:89
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Helper to enable IP flow monitoring on a set of Nodes.
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes)
Same as SerializeToXmlStream, but writes to a file instead.
Class to represent a 2D points plot.
Definition: gnuplot.h:116
void SetStyle(Style style)
Definition: gnuplot.cc:359
void Add(double x, double y)
Definition: gnuplot.cc:377
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition: gnuplot.h:370
void AddDataset(const GnuplotDataset &dataset)
Definition: gnuplot.cc:796
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition: gnuplot.cc:802
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.
Definition: ipv4-address.h:42
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:80
a class to store IPv4 address information on an interface
Ipv4Address GetAddress() const
Get the local address.
Ipv4Address GetLocal() const
Get the local address.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class that adds ns3::Ipv4ListRouting objects.
Helper class that adds ns3::Ipv4StaticRouting objects.
Helper class used to assign positions and mobility models to nodes.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void SetMobilityModel(std::string type, Ts &&... args)
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Helper class that adds OLSR routing to nodes.
Definition: olsr-helper.h:42
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a 2d rectangle
Definition: rectangle.h:35
AttributeValue implementation for Rectangle.
Definition: rectangle.h:125
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Definition: socket.cc:72
Hold variables of type string.
Definition: string.h:56
a unique identifier for an interface.
Definition: type-id.h:59
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:836
Hold an unsigned integer type.
Definition: uinteger.h:45
helps to create WifiNetDevice objects
Definition: wifi-helper.h:324
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
Definition: wifi-helper.h:178
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 experiment(std::string queue_disc_type)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
@ WIFI_STANDARD_80211a
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:704
Definition: olsr.py:1
#define list
static std::string PrintPosition(Ptr< Node > client, Ptr< Node > server)
Print the position of two nodes.
Ptr< PacketSink > sink
Pointer to the packet sink application.
Definition: wifi-tcp.cc:55