A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
multirate.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: Duy Nguyen <duy@soe.ucsc.edu>
17  */
18 
51 #include "ns3/core-module.h"
52 #include "ns3/network-module.h"
53 #include "ns3/applications-module.h"
54 #include "ns3/mobility-module.h"
55 #include "ns3/stats-module.h"
56 #include "ns3/random-variable-stream.h"
57 #include "ns3/wifi-module.h"
58 #include "ns3/internet-module.h"
59 #include "ns3/flow-monitor-helper.h"
60 #include "ns3/olsr-helper.h"
61 #include "ns3/ipv4-static-routing-helper.h"
62 #include "ns3/ipv4-list-routing-helper.h"
63 
64 #include <iostream>
65 #include <fstream>
66 
67 NS_LOG_COMPONENT_DEFINE ("multirate");
68 
69 using namespace ns3;
70 
72 {
73 public:
74 
75  Experiment ();
76  Experiment (std::string name);
77  Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
78  const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility);
79 
80  bool CommandSetup (int argc, char **argv);
81  bool IsRouting () { return (enableRouting == 1) ? 1 : 0; }
82  bool IsMobility () { return (enableMobility == 1) ? 1 : 0; }
83 
84  uint32_t GetScenario () { return scenario; }
85 
86  std::string GetRtsThreshold () { return rtsThreshold; }
87  std::string GetOutputFileName () { return outputFileName; }
88  std::string GetRateManager () { return rateManager; }
89 
90 private:
91 
93  NodeContainer GenerateNeighbors (NodeContainer c, uint32_t senderId);
94 
95  void ApplicationSetup (Ptr<Node> client, Ptr<Node> server, double start, double stop);
96  void AssignNeighbors (NodeContainer c);
97  void SelectSrcDest (NodeContainer c);
98  void ReceivePacket (Ptr<Socket> socket);
99  void CheckThroughput ();
100  void SendMultiDestinations (Ptr<Node> sender, NodeContainer c);
101 
103 
104  double totalTime;
105  double expMean;
107 
108  uint32_t bytesTotal;
109  uint32_t packetSize;
110  uint32_t gridSize;
111  uint32_t nodeDistance;
112  uint32_t port;
113  uint32_t scenario;
114 
120 
121  NodeContainer containerA, containerB, containerC, containerD;
122  std::string rtsThreshold, rateManager, outputFileName;
123 };
124 
126 {
127 }
128 
129 Experiment::Experiment (std::string name) :
130  m_output (name),
131  totalTime (0.3),
132  expMean (0.1), //flows being exponentially distributed
133  samplingPeriod(0.1),
134  bytesTotal (0),
135  packetSize (2000),
136  gridSize (10), //10x10 grid for a total of 100 nodes
137  nodeDistance (30),
138  port (5000),
139  scenario (4),
140  enablePcap (false),
141  enableTracing (true),
142  enableFlowMon (false),
143  enableRouting (false),
144  enableMobility (false),
145  rtsThreshold ("2200"), //0 for enabling rts/cts
146  rateManager ("ns3::MinstrelWifiManager"),
147  outputFileName ("minstrel")
148 {
149  m_output.SetStyle (Gnuplot2dDataset::LINES);
150 }
151 
154 {
155  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
156  Ptr<Socket> sink = Socket::CreateSocket (node, tid);
157  InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), port);
158  sink->Bind (local);
160 
161  return sink;
162 }
163 
164 void
166 {
167  Ptr<Packet> packet;
168  while ((packet = socket->Recv ()))
169  {
170  bytesTotal += packet->GetSize ();
171  }
172 }
173 
174 void
176 {
177  double mbs = ((bytesTotal * 8.0) /1000000 /samplingPeriod);
178  bytesTotal = 0;
179  m_output.Add ((Simulator::Now ()).GetSeconds (), mbs);
180 
181  //check throughput every samplingPeriod second
182  Simulator::Schedule (Seconds (samplingPeriod), &Experiment::CheckThroughput, this);
183 }
184 
191 void
193 {
194  uint32_t totalNodes = c.GetN ();
195  for (uint32_t i=0; i< totalNodes; i++)
196  {
197  if ( (i % gridSize) <= (gridSize/2 - 1))
198  {
199  //lower left quadrant
200  if ( i < totalNodes/2 )
201  {
202  containerA.Add (c.Get (i));
203  }
204 
205  //upper left quadrant
206  if ( i >= (uint32_t)(4*totalNodes)/10 )
207  {
208  containerC.Add (c.Get (i));
209  }
210  }
211  if ( (i % gridSize) >= (gridSize/2 - 1))
212  {
213  //lower right quadrant
214  if ( i < totalNodes/2 )
215  {
216  containerB.Add (c.Get (i));
217  }
218 
219  //upper right quadrant
220  if ( i >= (uint32_t)(4*totalNodes)/10 )
221  {
222  containerD.Add (c.Get (i));
223  }
224  }
225  }
226 }
227 
234 {
235  NodeContainer nc;
236  uint32_t limit = senderId + 2;
237  for (uint32_t i= senderId - 2; i <= limit; i++)
238  {
239  //must ensure the boundaries for other topologies
240  nc.Add (c.Get (i));
241  nc.Add (c.Get (i + 10));
242  nc.Add (c.Get (i + 20));
243  nc.Add (c.Get (i - 10));
244  nc.Add (c.Get (i - 20));
245  }
246  return nc;
247 }
248 
254 void
256 {
257  uint32_t totalNodes = c.GetN ();
258  Ptr<UniformRandomVariable> uvSrc = CreateObject<UniformRandomVariable> ();
259  uvSrc->SetAttribute ("Min", DoubleValue (0));
260  uvSrc->SetAttribute ("Max", DoubleValue (totalNodes/2 -1));
261  Ptr<UniformRandomVariable> uvDest = CreateObject<UniformRandomVariable> ();
262  uvDest->SetAttribute ("Min", DoubleValue (totalNodes/2));
263  uvDest->SetAttribute ("Max", DoubleValue (totalNodes));
264 
265  for (uint32_t i=0; i < totalNodes/3; i++)
266  {
267  ApplicationSetup (c.Get (uvSrc->GetInteger ()), c.Get (uvDest->GetInteger ()), 0, totalTime);
268  }
269 }
270 
277 void
279 {
280 
281  // UniformRandomVariable params: (Xrange, Yrange)
282  Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> ();
283  uv->SetAttribute ("Min", DoubleValue (0));
284  uv->SetAttribute ("Max", DoubleValue (c.GetN ()));
285 
286  // ExponentialRandomVariable params: (mean, upperbound)
287  Ptr<ExponentialRandomVariable> ev = CreateObject<ExponentialRandomVariable> ();
288  ev->SetAttribute ("Mean", DoubleValue (expMean));
289  ev->SetAttribute ("Bound", DoubleValue (totalTime));
290 
291  double start=0.0, stop=totalTime;
292  uint32_t destIndex;
293 
294  for (uint32_t i=0; i < c.GetN (); i++)
295  {
296  stop = start + ev->GetValue ();
297  NS_LOG_DEBUG ("Start=" << start << " Stop=" << stop);
298 
299  do {
300  destIndex = (uint32_t) uv->GetValue ();
301  } while ( (c.Get (destIndex))->GetId () == sender->GetId ());
302 
303  ApplicationSetup (sender, c.Get (destIndex), start, stop);
304 
305  start = stop;
306 
307  if(start > totalTime)
308  {
309  break;
310  }
311  }
312 }
313 
314 static inline Vector
316 {
317  Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
318  return mobility->GetPosition ();
319 }
320 
321 static inline std::string
323 {
324  Vector serverPos = GetPosition (server);
325  Vector clientPos = GetPosition (client);
326 
327  Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4>();
328  Ptr<Ipv4> ipv4Client = client->GetObject<Ipv4>();
329 
330  Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0);
331  Ipv4InterfaceAddress iaddrClient = ipv4Client->GetAddress (1,0);
332 
333  Ipv4Address ipv4AddrServer = iaddrServer.GetLocal ();
334  Ipv4Address ipv4AddrClient = iaddrClient.GetLocal ();
335 
336  std::ostringstream oss;
337  oss << "Set up Server Device " << (server->GetDevice (0))->GetAddress ()
338  << " with ip " << ipv4AddrServer
339  << " position (" << serverPos.x << "," << serverPos.y << "," << serverPos.z << ")";
340 
341  oss << "Set up Client Device " << (client->GetDevice (0))->GetAddress ()
342  << " with ip " << ipv4AddrClient
343  << " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")"
344  << "\n";
345  return oss.str ();
346 }
347 
348 void
349 Experiment::ApplicationSetup (Ptr<Node> client, Ptr<Node> server, double start, double stop)
350 {
351  Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4> ();
352 
353  Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0);
354  Ipv4Address ipv4AddrServer = iaddrServer.GetLocal ();
355 
356  NS_LOG_DEBUG (PrintPosition (client, server));
357 
358  // Equipping the source node with OnOff Application used for sending
359  OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address ("10.0.0.1"), port)));
360  onoff.SetConstantRate (DataRate (60000000));
361  onoff.SetAttribute ("PacketSize", UintegerValue (packetSize));
362  onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (ipv4AddrServer, port)));
363 
364  ApplicationContainer apps = onoff.Install (client);
365  apps.Start (Seconds (start));
366  apps.Stop (Seconds (stop));
367 
368  Ptr<Socket> sink = SetupPacketReceive (server);
369 
370 }
371 
373 Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
374  const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility)
375 {
376 
377 
378  uint32_t nodeSize = gridSize*gridSize;
379  NodeContainer c;
380  c.Create (nodeSize);
381 
382  YansWifiPhyHelper phy = wifiPhy;
383  phy.SetChannel (wifiChannel.Create ());
384 
385  NqosWifiMacHelper mac = wifiMac;
386  NetDeviceContainer devices = wifi.Install (phy, mac, c);
387 
388 
389  OlsrHelper olsr;
390  Ipv4StaticRoutingHelper staticRouting;
391 
393 
394  if (enableRouting)
395  {
396  list.Add (staticRouting, 0);
397  list.Add (olsr, 10);
398  }
399 
400  InternetStackHelper internet;
401 
402  if (enableRouting)
403  {
404  internet.SetRoutingHelper (list); // has effect on the next Install ()
405  }
406  internet.Install (c);
407 
408 
410  address.SetBase ("10.0.0.0", "255.255.255.0");
411 
412  Ipv4InterfaceContainer ipInterfaces;
413  ipInterfaces = address.Assign (devices);
414 
415  MobilityHelper mobil= mobility;
416  mobil.SetPositionAllocator ("ns3::GridPositionAllocator",
417  "MinX", DoubleValue (0.0),
418  "MinY", DoubleValue (0.0),
419  "DeltaX", DoubleValue (nodeDistance),
420  "DeltaY", DoubleValue (nodeDistance),
421  "GridWidth", UintegerValue (gridSize),
422  "LayoutType", StringValue ("RowFirst"));
423 
424  mobil.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
425 
427  {
428  //Rectangle (xMin, xMax, yMin, yMax)
429  mobil.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
430  "Bounds", RectangleValue (Rectangle (0, 500, 0, 500)),
431  "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=10]"),
432  "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"));
433  }
434  mobil.Install (c);
435 
436 
437 // NS_LOG_INFO ("Enabling global routing on all nodes");
438 // Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
439 
440  if ( scenario == 1 && enableRouting)
441  {
442  SelectSrcDest (c);
443  }
444  else if ( scenario == 2)
445  {
446  //All flows begin at the same time
447  for (uint32_t i = 0; i < nodeSize - 1; i = i+2)
448  {
449  ApplicationSetup (c.Get (i), c.Get (i+1), 0, totalTime);
450  }
451  }
452  else if ( scenario == 3)
453  {
454  AssignNeighbors (c);
455  //Note: these senders are hand-picked in order to ensure good coverage
456  //for 10x10 grid, basically one sender for each quadrant
457  //you might have to change these values for other grids
458  NS_LOG_DEBUG (">>>>>>>>>region A<<<<<<<<<");
460 
461  NS_LOG_DEBUG (">>>>>>>>>region B<<<<<<<<<");
463 
464  NS_LOG_DEBUG (">>>>>>>>>region C<<<<<<<<<");
466 
467  NS_LOG_DEBUG (">>>>>>>>>region D<<<<<<<<<");
469  }
470  else if ( scenario == 4)
471  {
472  //GenerateNeighbors(NodeContainer, uint32_t sender)
473  //Note: these senders are hand-picked in order to ensure good coverage
474  //you might have to change these values for other grids
475  NodeContainer c1, c2, c3, c4, c5, c6, c7, c8, c9;
476 
477  c1 = GenerateNeighbors (c, 22);
478  c2 = GenerateNeighbors (c, 24);;
479  c3 = GenerateNeighbors (c, 26);;
480  c4 = GenerateNeighbors (c, 42);;
481  c5 = GenerateNeighbors (c, 44);;
482  c6 = GenerateNeighbors (c, 46);;
483  c7 = GenerateNeighbors (c, 62);;
484  c8 = GenerateNeighbors (c, 64);;
485  c9 = GenerateNeighbors (c, 66);;
486 
487  SendMultiDestinations (c.Get (22), c1);
488  SendMultiDestinations (c.Get (24), c2);
489  SendMultiDestinations (c.Get (26), c3);
490  SendMultiDestinations (c.Get (42), c4);
491  SendMultiDestinations (c.Get (44), c5);
492  SendMultiDestinations (c.Get (46), c6);
493  SendMultiDestinations (c.Get (62), c7);
494  SendMultiDestinations (c.Get (64), c8);
495  SendMultiDestinations (c.Get (66), c9);
496  }
497 
498  CheckThroughput ();
499 
500  if (enablePcap)
501  {
503  }
504 
505  if (enableTracing)
506  {
507  AsciiTraceHelper ascii;
508  phy.EnableAsciiAll (ascii.CreateFileStream (GetOutputFileName () + ".tr"));
509  }
510 
511  Ptr<FlowMonitor> flowmon;
512  FlowMonitorHelper flowmonHelper;
513 
514  if (enableFlowMon)
515  {
516  flowmon = flowmonHelper.InstallAll ();
517  }
518 
519  Simulator::Stop (Seconds (totalTime));
520  Simulator::Run ();
521 
522  if (enableFlowMon)
523  {
524  flowmon->SerializeToXmlFile ((GetOutputFileName () + ".flomon"), false, false);
525  }
526 
527  Simulator::Destroy ();
528 
529  return m_output;
530 }
531 
532 bool
533 Experiment::CommandSetup (int argc, char **argv)
534 {
535  // for commandline input
536  CommandLine cmd;
537  cmd.AddValue ("packetSize", "packet size", packetSize);
538  cmd.AddValue ("totalTime", "simulation time", totalTime);
539  // according to totalTime, select an appropriate samplingPeriod automatically.
540  if (totalTime < 1.0)
541  {
542  samplingPeriod = 0.1;
543  }
544  else
545  {
546  samplingPeriod = 1.0;
547  }
548  // or user selects a samplingPeriod.
549  cmd.AddValue ("samplingPeriod", "sampling period", samplingPeriod);
550  cmd.AddValue ("rtsThreshold", "rts threshold", rtsThreshold);
551  cmd.AddValue ("rateManager", "type of rate", rateManager);
552  cmd.AddValue ("outputFileName", "output filename", outputFileName);
553  cmd.AddValue ("enableRouting", "enable Routing", enableRouting);
554  cmd.AddValue ("enableMobility", "enable Mobility", enableMobility);
555  cmd.AddValue ("scenario", "scenario ", scenario);
556 
557  cmd.Parse (argc, argv);
558  return true;
559 }
560 
561 int main (int argc, char *argv[])
562 {
563 
565  experiment = Experiment ("multirate");
566 
567  //for commandline input
568  experiment.CommandSetup (argc, argv);
569 
570  // set value to 0 for enabling fragmentation
571  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
572  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue (experiment.GetRtsThreshold ()));
573 
574  std::ofstream outfile ((experiment.GetOutputFileName ()+ ".plt").c_str ());
575 
576  MobilityHelper mobility;
577  Gnuplot gnuplot;
578  Gnuplot2dDataset dataset;
579 
580  WifiHelper wifi = WifiHelper::Default ();
581  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
582  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
583  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
584  Ssid ssid = Ssid ("Testbed");
585 
586  wifiMac.SetType ("ns3::AdhocWifiMac",
587  "Ssid", SsidValue (ssid));
589  wifi.SetRemoteStationManager (experiment.GetRateManager ());
590 
591  NS_LOG_INFO ("Scenario: " << experiment.GetScenario ());
592  NS_LOG_INFO ("Rts Threshold: " << experiment.GetRtsThreshold ());
593  NS_LOG_INFO ("Name: " << experiment.GetOutputFileName ());
594  NS_LOG_INFO ("Rate: " << experiment.GetRateManager ());
595  NS_LOG_INFO ("Routing: " << experiment.IsRouting ());
596  NS_LOG_INFO ("Mobility: " << experiment.IsMobility ());
597 
598  dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility);
599 
600  gnuplot.AddDataset (dataset);
601  gnuplot.GenerateOutput (outfile);
602 
603  return 0;
604 }
double samplingPeriod
Definition: multirate.cc:106
Helper class for UAN CW MAC example.
Definition: multirate.cc:71
bool enablePcap
Definition: multirate.cc:115
holds a vector of ns3::Application pointers.
bool enableFlowMon
Definition: multirate.cc:117
double x
x coordinate of vector
Definition: vector.h:49
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
Manage ASCII trace files for device models.
Definition: trace-helper.h:128
std::string rateManager
Definition: multirate.cc:122
an Inet address class
void AssignNeighbors(NodeContainer c)
Take the grid map, divide it into 4 quadrants Assign all nodes from each quadrant to a specific conta...
Definition: multirate.cc:192
NodeContainer containerA
Definition: multirate.cc:121
tuple devices
Definition: first.py:32
uint32_t gridSize
Definition: multirate.cc:110
uint32_t GetScenario()
Definition: multirate.cc:84
uint32_t GetInteger(uint32_t min, uint32_t max)
Returns a random unsigned integer from a uniform distribution over the interval [min,max] including both ends.
void CheckThroughput()
Definition: multirate.cc:175
Class to represent a 2D points plot.
Definition: gnuplot.h:113
holds a vector of std::pair of Ptr and interface index.
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition: wifi-helper.cc:73
Ipv4Address GetLocal(void) const
Get the local address.
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.
Definition: multirate.cc:278
hold variables of type string
Definition: string.h:19
Make it easy to create and manage PHY objects for the yans model.
bool enablePcap
static Vector GetPosition(Ptr< Node > node)
Definition: multirate.cc:315
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
void ReceivePacket(Ptr< Socket > socket)
aggregate IP/TCP/UDP functionality to existing Nodes.
Helper class that adds OLSR routing to nodes.
Definition: olsr-helper.h:38
uint32_t GetSize(void) const
Definition: packet.h:650
Vector GetPosition(void) const
void AddDataset(const GnuplotDataset &dataset)
Definition: gnuplot.cc:756
NS_LOG_COMPONENT_DEFINE("multirate")
Scenarios: 100 nodes, multiple simultaneous flows, multi-hop ad hoc, routing, and mobility...
#define NS_LOG_INFO(msg)
Definition: log.h:298
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. ...
uint32_t packetSize
Definition: multirate.cc:109
helps to create WifiNetDevice objects
Definition: wifi-helper.h:88
void ReceivePacket(Ptr< Socket > socket)
Definition: multirate.cc:165
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
a 3d vector
Definition: vector.h:31
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:102
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:86
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
hold objects of type ns3::Rectangle
Class for representing data rates.
Definition: data-rate.h:71
Keep track of the current position and velocity of an object.
void SetChannel(Ptr< YansWifiChannel > channel)
bool IsRouting()
Definition: multirate.cc:81
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition: gnuplot.h:367
Hold an unsigned integer type.
Definition: uinteger.h:46
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility)
Definition: multirate.cc:373
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:96
Ptr< NetDevice > GetDevice(uint32_t index) const
Definition: node.cc:132
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1238
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition: gnuplot.cc:762
NodeContainer containerC
Definition: multirate.cc:121
void Add(double x, double y)
Definition: gnuplot.cc:359
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
create non QoS-enabled MAC layers for a ns3::WifiNetDevice.
Parse command-line arguments.
Definition: command-line.h:152
#define list
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
void SelectSrcDest(NodeContainer c)
Sources and destinations are randomly selected such that a node may be the source for multiple destin...
Definition: multirate.cc:255
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
NodeContainer containerD
Definition: multirate.cc:121
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:667
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
std::string outputFileName
Definition: multirate.cc:122
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
keep track of a set of node pointers.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
double totalTime
Definition: multirate.cc:104
bool enableMobility
Definition: multirate.cc:119
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
NodeContainer GenerateNeighbors(NodeContainer c, uint32_t senderId)
Generate 1-hop and 2-hop neighbors of a node in grid topology.
Definition: multirate.cc:233
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Helper to enable IPv4 flow monitoring on a set of Nodes.
Gnuplot2dDataset m_output
Definition: multirate.cc:102
double y
y coordinate of vector
Definition: vector.h:53
manage and create wifi channel objects for the yans model.
void SetStyle(enum Style style)
Definition: gnuplot.cc:342
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
double expMean
Definition: multirate.cc:105
bool enableTracing
Definition: multirate.cc:116
Helper class used to assign positions and mobility models to nodes.
void ApplicationSetup(Ptr< Node > client, Ptr< Node > server, double start, double stop)
Definition: multirate.cc:349
bool enableRouting
Definition: multirate.cc:118
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
hold objects of type ns3::Address
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
uint32_t GetId(void) const
Definition: node.cc:104
a class to store IPv4 address information on an interface
Helper class that adds ns3::Ipv4StaticRouting objects.
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Definition: command-line.h:408
uint32_t scenario
Definition: multirate.cc:113
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes)
Same as SerializeToXmlStream, but writes to a file instead.
virtual Ipv4InterfaceAddress GetAddress(uint32_t interface, uint32_t addressIndex) const =0
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to thi...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
hold objects of type ns3::Ssid
static std::string PrintPosition(Ptr< Node > client, Ptr< Node > server)
Definition: multirate.cc:322
uint32_t bytesTotal
Definition: multirate.cc:108
double GetValue(double mean, double bound)
Returns a random double from an exponential distribution with the specified mean and upper bound...
std::string GetOutputFileName()
Definition: multirate.cc:87
std::string GetRtsThreshold()
Definition: multirate.cc:86
std::string rtsThreshold
Definition: multirate.cc:122
Helper class that adds ns3::Ipv4ListRouting objects.
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
bool CommandSetup(int argc, char **argv)
Definition: multirate.cc:533
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
tuple address
Definition: first.py:37
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
std::string GetRateManager()
Definition: multirate.cc:88
int main(int argc, char *argv[])
Definition: multirate.cc:561
Hold a floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:161
Ptr< T > GetObject(void) const
Definition: object.h:361
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
bool IsMobility()
Definition: multirate.cc:82
a unique identifier for an interface.
Definition: type-id.h:49
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
Definition: multirate.cc:153
a 2d rectangle
Definition: rectangle.h:33
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
uint32_t port
Definition: multirate.cc:112
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
NodeContainer containerB
Definition: multirate.cc:121
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
uint32_t nodeDistance
Definition: multirate.cc:111
double z
z coordinate of vector
Definition: vector.h:57