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 == 1) ? 1 : 0;
120  }
121 
127  bool IsMobility() const
128  {
129  return (m_enableMobility == 1) ? 1 : 0;
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 
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(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  WifiMacHelper mac = wifiMac;
509  NetDeviceContainer devices = wifi.Install(phy, mac, c);
510 
512  Ipv4StaticRoutingHelper staticRouting;
513 
515 
516  if (m_enableRouting)
517  {
518  list.Add(staticRouting, 0);
519  list.Add(olsr, 10);
520  }
521 
522  InternetStackHelper internet;
523 
524  if (m_enableRouting)
525  {
526  internet.SetRoutingHelper(list); // has effect on the next Install ()
527  }
528  internet.Install(c);
529 
531  address.SetBase("10.0.0.0", "255.255.255.0");
532 
533  Ipv4InterfaceContainer ipInterfaces;
534  ipInterfaces = address.Assign(devices);
535 
536  MobilityHelper mobil = mobility;
537  mobil.SetPositionAllocator("ns3::GridPositionAllocator",
538  "MinX",
539  DoubleValue(0.0),
540  "MinY",
541  DoubleValue(0.0),
542  "DeltaX",
544  "DeltaY",
546  "GridWidth",
548  "LayoutType",
549  StringValue("RowFirst"));
550 
551  mobil.SetMobilityModel("ns3::ConstantPositionMobilityModel");
552 
554  {
555  // Rectangle (xMin, xMax, yMin, yMax)
556  mobil.SetMobilityModel("ns3::RandomDirection2dMobilityModel",
557  "Bounds",
558  RectangleValue(Rectangle(0, 500, 0, 500)),
559  "Speed",
560  StringValue("ns3::ConstantRandomVariable[Constant=10]"),
561  "Pause",
562  StringValue("ns3::ConstantRandomVariable[Constant=0.2]"));
563  }
564  mobil.Install(c);
565 
566  if (m_scenario == 1 && m_enableRouting)
567  {
568  SelectSrcDest(c);
569  }
570  else if (m_scenario == 2)
571  {
572  // All flows begin at the same time
573  for (uint32_t i = 0; i < nodeSize - 1; i = i + 2)
574  {
575  ApplicationSetup(c.Get(i), c.Get(i + 1), 0, m_totalTime);
576  }
577  }
578  else if (m_scenario == 3)
579  {
580  AssignNeighbors(c);
581  // Note: these senders are hand-picked in order to ensure good coverage
582  // for 10x10 grid, basically one sender for each quadrant
583  // you might have to change these values for other grids
584  NS_LOG_DEBUG(">>>>>>>>>region A<<<<<<<<<");
586 
587  NS_LOG_DEBUG(">>>>>>>>>region B<<<<<<<<<");
589 
590  NS_LOG_DEBUG(">>>>>>>>>region C<<<<<<<<<");
592 
593  NS_LOG_DEBUG(">>>>>>>>>region D<<<<<<<<<");
595  }
596  else if (m_scenario == 4)
597  {
598  // GenerateNeighbors(NodeContainer, uint32_t sender)
599  // Note: these senders are hand-picked in order to ensure good coverage
600  // you might have to change these values for other grids
601  NodeContainer c1;
602  NodeContainer c2;
603  NodeContainer c3;
604  NodeContainer c4;
605  NodeContainer c5;
606  NodeContainer c6;
607  NodeContainer c7;
608  NodeContainer c8;
609  NodeContainer c9;
610 
611  c1 = GenerateNeighbors(c, 22);
612  c2 = GenerateNeighbors(c, 24);
613  c3 = GenerateNeighbors(c, 26);
614  c4 = GenerateNeighbors(c, 42);
615  c5 = GenerateNeighbors(c, 44);
616  c6 = GenerateNeighbors(c, 46);
617  c7 = GenerateNeighbors(c, 62);
618  c8 = GenerateNeighbors(c, 64);
619  c9 = GenerateNeighbors(c, 66);
620 
621  SendMultiDestinations(c.Get(22), c1);
622  SendMultiDestinations(c.Get(24), c2);
623  SendMultiDestinations(c.Get(26), c3);
624  SendMultiDestinations(c.Get(42), c4);
625  SendMultiDestinations(c.Get(44), c5);
626  SendMultiDestinations(c.Get(46), c6);
627  SendMultiDestinations(c.Get(62), c7);
628  SendMultiDestinations(c.Get(64), c8);
629  SendMultiDestinations(c.Get(66), c9);
630  }
631 
632  CheckThroughput();
633 
634  if (m_enablePcap)
635  {
636  phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
637  phy.EnablePcapAll(GetOutputFileName());
638  }
639 
640  if (m_enableTracing)
641  {
642  AsciiTraceHelper ascii;
643  phy.EnableAsciiAll(ascii.CreateFileStream(GetOutputFileName() + ".tr"));
644  }
645 
646  FlowMonitorHelper flowmonHelper;
647 
648  if (m_enableFlowMon)
649  {
650  flowmonHelper.InstallAll();
651  }
652 
653  Simulator::Stop(Seconds(m_totalTime));
654  Simulator::Run();
655 
656  if (m_enableFlowMon)
657  {
658  flowmonHelper.SerializeToXmlFile((GetOutputFileName() + ".flomon"), false, false);
659  }
660 
661  Simulator::Destroy();
662 
663  return m_output;
664 }
665 
666 bool
667 Experiment::CommandSetup(int argc, char** argv)
668 {
669  // for commandline input
670  CommandLine cmd(__FILE__);
671  cmd.AddValue("packetSize", "packet size", m_packetSize);
672  cmd.AddValue("totalTime", "simulation time", m_totalTime);
673  // according to totalTime, select an appropriate samplingPeriod automatically.
674  if (m_totalTime < 1.0)
675  {
676  m_samplingPeriod = 0.1;
677  }
678  else
679  {
680  m_samplingPeriod = 1.0;
681  }
682  // or user selects a samplingPeriod.
683  cmd.AddValue("samplingPeriod", "sampling period", m_samplingPeriod);
684  cmd.AddValue("rtsThreshold", "rts threshold", m_rtsThreshold);
685  cmd.AddValue("rateManager", "type of rate", m_rateManager);
686  cmd.AddValue("outputFileName", "output filename", m_outputFileName);
687  cmd.AddValue("enableRouting", "enable Routing", m_enableRouting);
688  cmd.AddValue("enableMobility", "enable Mobility", m_enableMobility);
689  cmd.AddValue("scenario", "scenario ", m_scenario);
690 
691  cmd.Parse(argc, argv);
692  return true;
693 }
694 
695 int
696 main(int argc, char* argv[])
697 {
699  experiment = Experiment("multirate");
700 
701  // for commandline input
702  experiment.CommandSetup(argc, argv);
703 
704  std::ofstream outfile(experiment.GetOutputFileName() + ".plt");
705 
707  Gnuplot gnuplot;
708  Gnuplot2dDataset dataset;
709 
711  WifiMacHelper wifiMac;
712  YansWifiPhyHelper wifiPhy;
713  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
714 
715  wifiMac.SetType("ns3::AdhocWifiMac", "Ssid", StringValue("Testbed"));
716  wifi.SetStandard(WIFI_STANDARD_80211a);
717  wifi.SetRemoteStationManager(experiment.GetRateManager());
718 
719  NS_LOG_INFO("Scenario: " << experiment.GetScenario());
720  NS_LOG_INFO("Rts Threshold: " << experiment.GetRtsThreshold());
721  NS_LOG_INFO("Name: " << experiment.GetOutputFileName());
722  NS_LOG_INFO("Rate: " << experiment.GetRateManager());
723  NS_LOG_INFO("Routing: " << experiment.IsRouting());
724  NS_LOG_INFO("Mobility: " << experiment.IsMobility());
725 
726  dataset = experiment.Run(wifi, wifiPhy, wifiMac, wifiChannel, mobility);
727 
728  gnuplot.AddDataset(dataset);
729  gnuplot.GenerateOutput(outfile);
730 
731  return 0;
732 }
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
Scnario 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:100
AttributeValue implementation for Address.
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:173
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: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.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
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:43
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:79
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
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:152
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:200
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
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
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:863
a 2d rectangle
Definition: rectangle.h:35
AttributeValue implementation for Rectangle.
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:60
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:325
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:328
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:296
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
@ WIFI_STANDARD_80211a
address
Definition: first.py:40
devices
Definition: first.py:35
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:707
Definition: olsr.py:1
cmd
Definition: second.py:33
mac
Definition: third.py:85
wifi
Definition: third.py:88
mobility
Definition: third.py:96
phy
Definition: third.py:82
#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