A Discrete-Event Network Simulator
API
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/applications-module.h"
53 #include "ns3/mobility-module.h"
54 #include "ns3/stats-module.h"
55 #include "ns3/wifi-module.h"
56 #include "ns3/internet-module.h"
57 #include "ns3/flow-monitor-helper.h"
58 #include "ns3/olsr-helper.h"
59 
60 using namespace ns3;
61 
62 NS_LOG_COMPONENT_DEFINE ("multirate");
63 
64 class Experiment
65 {
66 public:
67  Experiment ();
68  Experiment (std::string name);
69  Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
70  const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility);
71 
72  bool CommandSetup (int argc, char **argv);
73  bool IsRouting ()
74  {
75  return (enableRouting == 1) ? 1 : 0;
76  }
77  bool IsMobility ()
78  {
79  return (enableMobility == 1) ? 1 : 0;
80  }
81 
82  uint32_t GetScenario ()
83  {
84  return scenario;
85  }
86 
87  std::string GetRtsThreshold ()
88  {
89  return rtsThreshold;
90  }
91  std::string GetOutputFileName ()
92  {
93  return outputFileName;
94  }
95  std::string GetRateManager ()
96  {
97  return rateManager;
98  }
99 
100 private:
102  NodeContainer GenerateNeighbors (NodeContainer c, uint32_t senderId);
103 
104  void ApplicationSetup (Ptr<Node> client, Ptr<Node> server, double start, double stop);
105  void AssignNeighbors (NodeContainer c);
106  void SelectSrcDest (NodeContainer c);
107  void ReceivePacket (Ptr<Socket> socket);
108  void CheckThroughput ();
109  void SendMultiDestinations (Ptr<Node> sender, NodeContainer c);
110 
112 
113  double totalTime;
114  double expMean;
116 
117  uint32_t bytesTotal;
118  uint32_t packetSize;
119  uint32_t gridSize;
120  uint32_t nodeDistance;
121  uint32_t port;
122  uint32_t scenario;
123 
129 
130  NodeContainer containerA, containerB, containerC, containerD;
131  std::string rtsThreshold, rateManager, outputFileName;
132 };
133 
135 {
136 }
137 
138 Experiment::Experiment (std::string name)
139  : m_output (name),
140  totalTime (0.3),
141  expMean (0.1),
142  //flows being exponentially distributed
143  samplingPeriod (0.1),
144  bytesTotal (0),
145  packetSize (2000),
146  gridSize (10),
147  //10x10 grid for a total of 100 nodes
148  nodeDistance (30),
149  port (5000),
150  scenario (4),
151  enablePcap (false),
152  enableTracing (true),
153  enableFlowMon (false),
154  enableRouting (false),
155  enableMobility (false),
156  rtsThreshold ("2200"),
157  //0 for enabling rts/cts
158  rateManager ("ns3::MinstrelWifiManager"),
159  outputFileName ("minstrel")
160 {
161  m_output.SetStyle (Gnuplot2dDataset::LINES);
162 }
163 
166 {
167  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
168  Ptr<Socket> sink = Socket::CreateSocket (node, tid);
169  InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), port);
170  sink->Bind (local);
172 
173  return sink;
174 }
175 
176 void
178 {
179  Ptr<Packet> packet;
180  while ((packet = socket->Recv ()))
181  {
182  bytesTotal += packet->GetSize ();
183  }
184 }
185 
186 void
188 {
189  double mbs = ((bytesTotal * 8.0) / 1000000 / samplingPeriod);
190  bytesTotal = 0;
191  m_output.Add ((Simulator::Now ()).GetSeconds (), mbs);
192 
193  //check throughput every samplingPeriod second
194  Simulator::Schedule (Seconds (samplingPeriod), &Experiment::CheckThroughput, this);
195 }
196 
203 void
205 {
206  uint32_t totalNodes = c.GetN ();
207  for (uint32_t i = 0; i < totalNodes; i++)
208  {
209  if ( (i % gridSize) <= (gridSize / 2 - 1))
210  {
211  //lower left quadrant
212  if ( i < totalNodes / 2 )
213  {
214  containerA.Add (c.Get (i));
215  }
216 
217  //upper left quadrant
218  if ( i >= (uint32_t)(4 * totalNodes) / 10 )
219  {
220  containerC.Add (c.Get (i));
221  }
222  }
223  if ( (i % gridSize) >= (gridSize / 2 - 1))
224  {
225  //lower right quadrant
226  if ( i < totalNodes / 2 )
227  {
228  containerB.Add (c.Get (i));
229  }
230 
231  //upper right quadrant
232  if ( i >= (uint32_t)(4 * totalNodes) / 10 )
233  {
234  containerD.Add (c.Get (i));
235  }
236  }
237  }
238 }
239 
246 {
247  NodeContainer nc;
248  uint32_t limit = senderId + 2;
249  for (uint32_t i = senderId - 2; i <= limit; i++)
250  {
251  //must ensure the boundaries for other topologies
252  nc.Add (c.Get (i));
253  nc.Add (c.Get (i + 10));
254  nc.Add (c.Get (i + 20));
255  nc.Add (c.Get (i - 10));
256  nc.Add (c.Get (i - 20));
257  }
258  return nc;
259 }
260 
266 void
268 {
269  uint32_t totalNodes = c.GetN ();
270  Ptr<UniformRandomVariable> uvSrc = CreateObject<UniformRandomVariable> ();
271  uvSrc->SetAttribute ("Min", DoubleValue (0));
272  uvSrc->SetAttribute ("Max", DoubleValue (totalNodes / 2 - 1));
273  Ptr<UniformRandomVariable> uvDest = CreateObject<UniformRandomVariable> ();
274  uvDest->SetAttribute ("Min", DoubleValue (totalNodes / 2));
275  uvDest->SetAttribute ("Max", DoubleValue (totalNodes));
276 
277  for (uint32_t i = 0; i < totalNodes / 3; i++)
278  {
279  ApplicationSetup (c.Get (uvSrc->GetInteger ()), c.Get (uvDest->GetInteger ()), 0, totalTime);
280  }
281 }
282 
289 void
291 {
292 
293  // UniformRandomVariable params: (Xrange, Yrange)
294  Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> ();
295  uv->SetAttribute ("Min", DoubleValue (0));
296  uv->SetAttribute ("Max", DoubleValue (c.GetN ()));
297 
298  // ExponentialRandomVariable params: (mean, upperbound)
299  Ptr<ExponentialRandomVariable> ev = CreateObject<ExponentialRandomVariable> ();
300  ev->SetAttribute ("Mean", DoubleValue (expMean));
301  ev->SetAttribute ("Bound", DoubleValue (totalTime));
302 
303  double start = 0.0, stop;
304  uint32_t destIndex;
305 
306  for (uint32_t i = 0; i < c.GetN (); i++)
307  {
308  stop = start + ev->GetValue ();
309  NS_LOG_DEBUG ("Start=" << start << " Stop=" << stop);
310 
311  do
312  {
313  destIndex = (uint32_t) uv->GetValue ();
314  }
315  while ( (c.Get (destIndex))->GetId () == sender->GetId ());
316 
317  ApplicationSetup (sender, c.Get (destIndex), start, stop);
318 
319  start = stop;
320 
321  if (start > totalTime)
322  {
323  break;
324  }
325  }
326 }
327 
328 static inline Vector
330 {
332  return mobility->GetPosition ();
333 }
334 
335 static inline std::string
337 {
338  Vector serverPos = GetPosition (server);
339  Vector clientPos = GetPosition (client);
340 
341  Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4> ();
342  Ptr<Ipv4> ipv4Client = client->GetObject<Ipv4> ();
343 
344  Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0);
345  Ipv4InterfaceAddress iaddrClient = ipv4Client->GetAddress (1,0);
346 
347  Ipv4Address ipv4AddrServer = iaddrServer.GetLocal ();
348  Ipv4Address ipv4AddrClient = iaddrClient.GetLocal ();
349 
350  std::ostringstream oss;
351  oss << "Set up Server Device " << (server->GetDevice (0))->GetAddress ()
352  << " with ip " << ipv4AddrServer
353  << " position (" << serverPos.x << "," << serverPos.y << "," << serverPos.z << ")";
354 
355  oss << "Set up Client Device " << (client->GetDevice (0))->GetAddress ()
356  << " with ip " << ipv4AddrClient
357  << " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")"
358  << "\n";
359  return oss.str ();
360 }
361 
362 void
363 Experiment::ApplicationSetup (Ptr<Node> client, Ptr<Node> server, double start, double stop)
364 {
365  Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4> ();
366 
367  Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0);
368  Ipv4Address ipv4AddrServer = iaddrServer.GetLocal ();
369 
370  NS_LOG_DEBUG (PrintPosition (client, server));
371 
372  // Equipping the source node with OnOff Application used for sending
373  OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address ("10.0.0.1"), port)));
374  onoff.SetConstantRate (DataRate (60000000));
375  onoff.SetAttribute ("PacketSize", UintegerValue (packetSize));
376  onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (ipv4AddrServer, port)));
377 
378  ApplicationContainer apps = onoff.Install (client);
379  apps.Start (Seconds (start));
380  apps.Stop (Seconds (stop));
381 
383 
384 }
385 
388  const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility)
389 {
390 
391 
392  uint32_t nodeSize = gridSize * gridSize;
393  NodeContainer c;
394  c.Create (nodeSize);
395 
396  YansWifiPhyHelper phy = wifiPhy;
397  phy.SetChannel (wifiChannel.Create ());
398 
399  WifiMacHelper mac = wifiMac;
400  NetDeviceContainer devices = wifi.Install (phy, mac, c);
401 
402 
404  Ipv4StaticRoutingHelper staticRouting;
405 
407 
408  if (enableRouting)
409  {
410  list.Add (staticRouting, 0);
411  list.Add (olsr, 10);
412  }
413 
414  InternetStackHelper internet;
415 
416  if (enableRouting)
417  {
418  internet.SetRoutingHelper (list); // has effect on the next Install ()
419  }
420  internet.Install (c);
421 
422 
424  address.SetBase ("10.0.0.0", "255.255.255.0");
425 
426  Ipv4InterfaceContainer ipInterfaces;
427  ipInterfaces = address.Assign (devices);
428 
429  MobilityHelper mobil = mobility;
430  mobil.SetPositionAllocator ("ns3::GridPositionAllocator",
431  "MinX", DoubleValue (0.0),
432  "MinY", DoubleValue (0.0),
433  "DeltaX", DoubleValue (nodeDistance),
434  "DeltaY", DoubleValue (nodeDistance),
435  "GridWidth", UintegerValue (gridSize),
436  "LayoutType", StringValue ("RowFirst"));
437 
438  mobil.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
439 
441  {
442  //Rectangle (xMin, xMax, yMin, yMax)
443  mobil.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
444  "Bounds", RectangleValue (Rectangle (0, 500, 0, 500)),
445  "Speed", StringValue ("ns3::ConstantRandomVariable[Constant=10]"),
446  "Pause", StringValue ("ns3::ConstantRandomVariable[Constant=0.2]"));
447  }
448  mobil.Install (c);
449 
450 
451 // NS_LOG_INFO ("Enabling global routing on all nodes");
452 // Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
453 
454  if ( scenario == 1 && enableRouting)
455  {
456  SelectSrcDest (c);
457  }
458  else if ( scenario == 2)
459  {
460  //All flows begin at the same time
461  for (uint32_t i = 0; i < nodeSize - 1; i = i + 2)
462  {
463  ApplicationSetup (c.Get (i), c.Get (i + 1), 0, totalTime);
464  }
465  }
466  else if ( scenario == 3)
467  {
468  AssignNeighbors (c);
469  //Note: these senders are hand-picked in order to ensure good coverage
470  //for 10x10 grid, basically one sender for each quadrant
471  //you might have to change these values for other grids
472  NS_LOG_DEBUG (">>>>>>>>>region A<<<<<<<<<");
474 
475  NS_LOG_DEBUG (">>>>>>>>>region B<<<<<<<<<");
477 
478  NS_LOG_DEBUG (">>>>>>>>>region C<<<<<<<<<");
480 
481  NS_LOG_DEBUG (">>>>>>>>>region D<<<<<<<<<");
483  }
484  else if ( scenario == 4)
485  {
486  //GenerateNeighbors(NodeContainer, uint32_t sender)
487  //Note: these senders are hand-picked in order to ensure good coverage
488  //you might have to change these values for other grids
489  NodeContainer c1, c2, c3, c4, c5, c6, c7, c8, c9;
490 
491  c1 = GenerateNeighbors (c, 22);
492  c2 = GenerateNeighbors (c, 24);
493  c3 = GenerateNeighbors (c, 26);
494  c4 = GenerateNeighbors (c, 42);
495  c5 = GenerateNeighbors (c, 44);
496  c6 = GenerateNeighbors (c, 46);
497  c7 = GenerateNeighbors (c, 62);
498  c8 = GenerateNeighbors (c, 64);
499  c9 = GenerateNeighbors (c, 66);
500 
501  SendMultiDestinations (c.Get (22), c1);
502  SendMultiDestinations (c.Get (24), c2);
503  SendMultiDestinations (c.Get (26), c3);
504  SendMultiDestinations (c.Get (42), c4);
505  SendMultiDestinations (c.Get (44), c5);
506  SendMultiDestinations (c.Get (46), c6);
507  SendMultiDestinations (c.Get (62), c7);
508  SendMultiDestinations (c.Get (64), c8);
509  SendMultiDestinations (c.Get (66), c9);
510  }
511 
512  CheckThroughput ();
513 
514  if (enablePcap)
515  {
517  }
518 
519  if (enableTracing)
520  {
521  AsciiTraceHelper ascii;
522  phy.EnableAsciiAll (ascii.CreateFileStream (GetOutputFileName () + ".tr"));
523  }
524 
525  FlowMonitorHelper flowmonHelper;
526 
527  if (enableFlowMon)
528  {
529  flowmonHelper.InstallAll ();
530  }
531 
532  Simulator::Stop (Seconds (totalTime));
533  Simulator::Run ();
534 
535  if (enableFlowMon)
536  {
537  flowmonHelper.SerializeToXmlFile ((GetOutputFileName () + ".flomon"), false, false);
538  }
539 
540  Simulator::Destroy ();
541 
542  return m_output;
543 }
544 
545 bool
546 Experiment::CommandSetup (int argc, char **argv)
547 {
548  // for commandline input
550  cmd.AddValue ("packetSize", "packet size", packetSize);
551  cmd.AddValue ("totalTime", "simulation time", totalTime);
552  // according to totalTime, select an appropriate samplingPeriod automatically.
553  if (totalTime < 1.0)
554  {
555  samplingPeriod = 0.1;
556  }
557  else
558  {
559  samplingPeriod = 1.0;
560  }
561  // or user selects a samplingPeriod.
562  cmd.AddValue ("samplingPeriod", "sampling period", samplingPeriod);
563  cmd.AddValue ("rtsThreshold", "rts threshold", rtsThreshold);
564  cmd.AddValue ("rateManager", "type of rate", rateManager);
565  cmd.AddValue ("outputFileName", "output filename", outputFileName);
566  cmd.AddValue ("enableRouting", "enable Routing", enableRouting);
567  cmd.AddValue ("enableMobility", "enable Mobility", enableMobility);
568  cmd.AddValue ("scenario", "scenario ", scenario);
569 
570  cmd.Parse (argc, argv);
571  return true;
572 }
573 
574 int main (int argc, char *argv[])
575 {
576 
578  experiment = Experiment ("multirate");
579 
580  //for commandline input
581  experiment.CommandSetup (argc, argv);
582 
583  // set value to 0 for enabling fragmentation
584  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
585  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue (experiment.GetRtsThreshold ()));
586 
587  std::ofstream outfile ((experiment.GetOutputFileName () + ".plt").c_str ());
588 
590  Gnuplot gnuplot;
591  Gnuplot2dDataset dataset;
592 
594  WifiMacHelper wifiMac;
595  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
596  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
597  Ssid ssid = Ssid ("Testbed");
598 
599  wifiMac.SetType ("ns3::AdhocWifiMac",
600  "Ssid", SsidValue (ssid));
602  wifi.SetRemoteStationManager (experiment.GetRateManager ());
603 
604  NS_LOG_INFO ("Scenario: " << experiment.GetScenario ());
605  NS_LOG_INFO ("Rts Threshold: " << experiment.GetRtsThreshold ());
606  NS_LOG_INFO ("Name: " << experiment.GetOutputFileName ());
607  NS_LOG_INFO ("Rate: " << experiment.GetRateManager ());
608  NS_LOG_INFO ("Routing: " << experiment.IsRouting ());
609  NS_LOG_INFO ("Mobility: " << experiment.IsMobility ());
610 
611  dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility);
612 
613  gnuplot.AddDataset (dataset);
614  gnuplot.GenerateOutput (outfile);
615 
616  return 0;
617 }
double samplingPeriod
Definition: multirate.cc:115
Helper class for UAN CW MAC example.
bool enablePcap
Definition: multirate.cc:124
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:45
holds a vector of ns3::Application pointers.
bool enableFlowMon
Definition: multirate.cc:126
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:161
std::string rateManager
Definition: multirate.cc:131
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:204
NodeContainer containerA
Definition: multirate.cc:130
tuple devices
Definition: first.py:32
uint32_t gridSize
Definition: multirate.cc:119
uint32_t GetScenario()
Definition: multirate.cc:82
void CheckThroughput()
Definition: multirate.cc:187
Class to represent a 2D points plot.
Definition: gnuplot.h:117
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:719
Ipv4Address GetLocal(void) const
Get the local address.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
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:290
Hold variables of type string.
Definition: string.h:41
Make it easy to create and manage PHY objects for the yans model.
bool enablePcap
static Vector GetPosition(Ptr< Node > node)
Definition: multirate.cc:329
def start()
Definition: core.py:1790
void ReceivePacket(Ptr< Socket > socket)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
aggregate IP/TCP/UDP functionality to existing Nodes.
Helper class that adds OLSR routing to nodes.
Definition: olsr-helper.h:40
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:796
Vector GetPosition(void) const
void AddDataset(const GnuplotDataset &dataset)
Definition: gnuplot.cc:756
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:277
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:118
helps to create WifiNetDevice objects
Definition: wifi-helper.h:213
void ReceivePacket(Ptr< Socket > socket)
Definition: multirate.cc:177
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes)
Same as SerializeToXmlStream, but writes to a file instead.
tuple cmd
Definition: second.py:35
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
AttributeValue implementation for Rectangle.
Definition: rectangle.h:97
Class for representing data rates.
Definition: data-rate.h:88
Keep track of the current position and velocity of an object.
void SetChannel(Ptr< YansWifiChannel > channel)
bool IsRouting()
Definition: multirate.cc:73
double Run(Parameters params)
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
tuple mobility
Definition: third.py:101
tuple phy
Definition: third.py:86
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:371
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:217
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:742
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:748
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:142
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
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:130
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.
tuple mac
Definition: third.py:92
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
Definition: command-line.h:205
#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:267
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
NodeContainer containerD
Definition: multirate.cc:130
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string outputFileName
Definition: multirate.cc:131
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:113
bool enableMobility
Definition: multirate.cc:128
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:245
double GetValue(double min, double max)
Get the next random value, as a double in 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 IP flow monitoring on a set of Nodes.
Gnuplot2dDataset m_output
Definition: multirate.cc:111
tuple ssid
Definition: third.py:93
manage and create wifi channel objects for the yans model.
create MAC layers for a ns3::WifiNetDevice.
Definition: olsr.py:1
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:114
bool enableTracing
Definition: multirate.cc:125
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(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
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:363
bool enableRouting
Definition: multirate.cc:127
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
AttributeValue implementation for Address.
Definition: address.h:278
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:107
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:498
uint32_t scenario
Definition: multirate.cc:122
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)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
AttributeValue implementation for Ssid.
Definition: ssid.h:117
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
static std::string PrintPosition(Ptr< Node > client, Ptr< Node > server)
Definition: multirate.cc:336
uint32_t bytesTotal
Definition: multirate.cc:117
double GetValue(double mean, double bound)
Get the next random value, as a double from the exponential distribution with the specified mean and ...
std::string GetOutputFileName()
Definition: multirate.cc:91
std::string GetRtsThreshold()
Definition: multirate.cc:87
std::string rtsThreshold
Definition: multirate.cc:131
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.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:365
bool CommandSetup(int argc, char **argv)
Definition: multirate.cc:546
tuple wifi
Definition: third.py:89
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.
static const uint32_t packetSize
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:95
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
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:77
a unique identifier for an interface.
Definition: type-id.h:58
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
Definition: multirate.cc:165
a 2d rectangle
Definition: rectangle.h:34
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
uint32_t port
Definition: multirate.cc:121
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
NodeContainer containerB
Definition: multirate.cc:130
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:120