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/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 using namespace ns3;
68 
69 NS_LOG_COMPONENT_DEFINE ("multirate");
70 
71 class Experiment
72 {
73 public:
74 
75  Experiment ();
76  Experiment (std::string name);
77  Gnuplot2dDataset Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy,
78  const WifiMacHelper &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 {
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 
369 
370 }
371 
374  const WifiMacHelper &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  WifiMacHelper mac = wifiMac;
386  NetDeviceContainer devices = wifi.Install (phy, mac, c);
387 
388 
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  FlowMonitorHelper flowmonHelper;
512 
513  if (enableFlowMon)
514  {
515  flowmonHelper.InstallAll ();
516  }
517 
518  Simulator::Stop (Seconds (totalTime));
519  Simulator::Run ();
520 
521  if (enableFlowMon)
522  {
523  flowmonHelper.SerializeToXmlFile ((GetOutputFileName () + ".flomon"), false, false);
524  }
525 
526  Simulator::Destroy ();
527 
528  return m_output;
529 }
530 
531 bool
532 Experiment::CommandSetup (int argc, char **argv)
533 {
534  // for commandline input
536  cmd.AddValue ("packetSize", "packet size", packetSize);
537  cmd.AddValue ("totalTime", "simulation time", totalTime);
538  // according to totalTime, select an appropriate samplingPeriod automatically.
539  if (totalTime < 1.0)
540  {
541  samplingPeriod = 0.1;
542  }
543  else
544  {
545  samplingPeriod = 1.0;
546  }
547  // or user selects a samplingPeriod.
548  cmd.AddValue ("samplingPeriod", "sampling period", samplingPeriod);
549  cmd.AddValue ("rtsThreshold", "rts threshold", rtsThreshold);
550  cmd.AddValue ("rateManager", "type of rate", rateManager);
551  cmd.AddValue ("outputFileName", "output filename", outputFileName);
552  cmd.AddValue ("enableRouting", "enable Routing", enableRouting);
553  cmd.AddValue ("enableMobility", "enable Mobility", enableMobility);
554  cmd.AddValue ("scenario", "scenario ", scenario);
555 
556  cmd.Parse (argc, argv);
557  return true;
558 }
559 
560 int main (int argc, char *argv[])
561 {
562 
564  experiment = Experiment ("multirate");
565 
566  //for commandline input
567  experiment.CommandSetup (argc, argv);
568 
569  // set value to 0 for enabling fragmentation
570  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
571  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue (experiment.GetRtsThreshold ()));
572 
573  std::ofstream outfile ((experiment.GetOutputFileName ()+ ".plt").c_str ());
574 
576  Gnuplot gnuplot;
577  Gnuplot2dDataset dataset;
578 
580  WifiMacHelper wifiMac;
581  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
582  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
583  Ssid ssid = Ssid ("Testbed");
584 
585  wifiMac.SetType ("ns3::AdhocWifiMac",
586  "Ssid", SsidValue (ssid));
588  wifi.SetRemoteStationManager (experiment.GetRateManager ());
589 
590  NS_LOG_INFO ("Scenario: " << experiment.GetScenario ());
591  NS_LOG_INFO ("Rts Threshold: " << experiment.GetRtsThreshold ());
592  NS_LOG_INFO ("Name: " << experiment.GetOutputFileName ());
593  NS_LOG_INFO ("Rate: " << experiment.GetRateManager ());
594  NS_LOG_INFO ("Routing: " << experiment.IsRouting ());
595  NS_LOG_INFO ("Mobility: " << experiment.IsMobility ());
596 
597  dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility);
598 
599  gnuplot.AddDataset (dataset);
600  gnuplot.GenerateOutput (outfile);
601 
602  return 0;
603 }
double samplingPeriod
Definition: multirate.cc:106
Helper class for UAN CW MAC example.
bool enablePcap
Definition: multirate.cc:115
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:47
holds a vector of ns3::Application pointers.
bool enableFlowMon
Definition: multirate.cc:117
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: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
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:683
Ipv4Address GetLocal(void) const
Get the local address.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
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: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:315
def start()
Definition: core.py:1482
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:792
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:244
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:231
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
void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes)
Same as SerializeToXmlStream, but writes to a file instead.
tuple cmd
Definition: second.py:35
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:712
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:81
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:367
Hold an unsigned integer type.
Definition: uinteger.h:44
Vector3D Vector
Definition: vector.h:166
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:706
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:121
double Run(bool enableProtection, bool enableShortSlotTime, bool enableShortPlcpPreamble, bool isMixed, bool isUdp, uint32_t payloadSize, uint32_t simulationTime)
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:255
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
NodeContainer containerD
Definition: multirate.cc:121
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: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)
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:102
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:38
double expMean
Definition: multirate.cc:105
bool enableTracing
Definition: multirate.cc:116
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:349
bool enableRouting
Definition: multirate.cc:118
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:495
uint32_t scenario
Definition: multirate.cc:113
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:236
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
AttributeValue implementation for Ssid.
Definition: ssid.h:95
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
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)
Get the next random value, as a double from the exponential distribution with the specified mean and ...
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.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:340
bool CommandSetup(int argc, char **argv)
Definition: multirate.cc:532
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:88
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:191
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:58
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
Definition: multirate.cc:153
a 2d rectangle
Definition: rectangle.h:34
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