A Discrete-Event Network Simulator
API
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 
39 using namespace ns3;
40 
41 NS_LOG_COMPONENT_DEFINE("multirate");
42 
78 class Experiment
79 {
80  public:
87  Experiment(std::string name);
97  Gnuplot2dDataset Run(const WifiHelper& wifi,
98  const YansWifiPhyHelper& wifiPhy,
99  const WifiMacHelper& wifiMac,
100  const YansWifiChannelHelper& wifiChannel,
101  const MobilityHelper& mobility);
102 
110  bool CommandSetup(int argc, char** argv);
111 
117  bool IsRouting() const
118  {
119  return m_enableRouting;
120  }
121 
127  bool IsMobility() const
128  {
129  return m_enableMobility;
130  }
131 
137  uint32_t GetScenario() const
138  {
139  return m_scenario;
140  }
141 
147  std::string GetRtsThreshold() const
148  {
149  return m_rtsThreshold;
150  }
151 
157  std::string GetOutputFileName() const
158  {
159  return m_outputFileName;
160  }
161 
167  std::string GetRateManager() const
168  {
169  return m_rateManager;
170  }
171 
172  private:
186  NodeContainer GenerateNeighbors(NodeContainer c, uint32_t senderId);
187 
196  void ApplicationSetup(Ptr<Node> client, Ptr<Node> server, double start, double stop);
203  void AssignNeighbors(NodeContainer c);
211  void SelectSrcDest(NodeContainer c);
221  void CheckThroughput();
229  void SendMultiDestinations(Ptr<Node> sender, NodeContainer c);
230 
231  Gnuplot2dDataset m_output;
232 
233  double m_totalTime;
234  double m_expMean;
236 
237  uint32_t m_bytesTotal;
238  uint32_t m_packetSize;
239  uint32_t m_gridSize;
240  uint32_t m_nodeDistance;
241  uint32_t m_port;
242  uint32_t m_scenario;
243 
249 
259  std::string m_rtsThreshold;
260  std::string m_rateManager;
261  std::string m_outputFileName;
262 };
263 
265 {
266 }
267 
268 Experiment::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 {
291  m_output.SetStyle(Gnuplot2dDataset::LINES);
292 }
293 
296 {
297  TypeId tid = TypeId::LookupByName("ns3::UdpSocketFactory");
298  Ptr<Socket> sink = Socket::CreateSocket(node, tid);
299  InetSocketAddress local = InetSocketAddress(Ipv4Address::GetAny(), m_port);
300  sink->Bind(local);
301  sink->SetRecvCallback(MakeCallback(&Experiment::ReceivePacket, this));
302 
303  return sink;
304 }
305 
306 void
308 {
309  Ptr<Packet> packet;
310  while ((packet = socket->Recv()))
311  {
312  m_bytesTotal += packet->GetSize();
313  }
314 }
315 
316 void
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
324  Simulator::Schedule(Seconds(m_samplingPeriod), &Experiment::CheckThroughput, this);
325 }
326 
327 void
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 
381 void
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 
398 void
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 
443 static 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 
470 void
472 {
473  Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4>();
474 
475  Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress(1, 0);
476  Ipv4Address ipv4AddrServer = iaddrServer.GetLocal();
477 
479 
480  // Equipping the source node with OnOff Application used for sending
481  OnOffHelper onoff("ns3::UdpSocketFactory",
483  onoff.SetConstantRate(DataRate(60000000));
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;
502  NodeContainer c;
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 
522 
523  if (m_enableRouting)
524  {
525  internet.SetRoutingHelper(list); // has effect on the next Install ()
526  }
527  internet.Install(c);
528 
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  {
579  AssignNeighbors(c);
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 
631  CheckThroughput();
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 
652  Simulator::Stop(Seconds(m_totalTime));
653  Simulator::Run();
654 
655  if (m_enableFlowMon)
656  {
657  flowmonHelper.SerializeToXmlFile((GetOutputFileName() + ".flomon"), false, false);
658  }
659 
660  Simulator::Destroy();
661 
662  return m_output;
663 }
664 
665 bool
666 Experiment::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 
694 int
695 main(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 
706  Gnuplot gnuplot;
707  Gnuplot2dDataset dataset;
708 
710  WifiMacHelper wifiMac;
711  YansWifiPhyHelper wifiPhy;
712  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
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.
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
Setup the receiving socket.
Definition: wifi-adhoc.cc:152
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
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
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
double GetValue(double mean, double bound)
Get the next random value drawn from the distribution.
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:118
void SetStyle(enum Style style)
Definition: gnuplot.cc:345
void Add(double x, double y)
Definition: gnuplot.cc:362
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition: gnuplot.h:373
void AddDataset(const GnuplotDataset &dataset)
Definition: gnuplot.cc:759
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition: gnuplot.cc:765
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
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.
uint32_t GetId() const
Definition: node.cc:117
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:204
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:44
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
a 2d rectangle
Definition: rectangle.h:35
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
Hold variables of type string.
Definition: string.h:56
a unique identifier for an interface.
Definition: type-id.h:59
Hold an unsigned integer type.
Definition: uinteger.h:45
double GetValue(double min, double max)
Get the next random value drawn from the distribution.
uint32_t GetInteger(uint32_t min, uint32_t max)
Get the next random value drawn from the distribution.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Definition: vector.h:324
helps to create WifiNetDevice objects
Definition: wifi-helper.h:324
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
manage and create wifi channel objects for the YANS model.
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
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:327
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:305
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
@ WIFI_STANDARD_80211a
address
Definition: first.py:47
devices
Definition: first.py:42
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
cmd
Definition: second.py:40
wifi
Definition: third.py:95
mobility
Definition: third.py:105
phy
Definition: third.py:89
#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