A Discrete-Event Network Simulator
API
wsnconstructor.cc
Go to the documentation of this file.
1 
2 /*
3 * Copyright (c) 2020 DLTLT
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Corresponding author: Niki Hrovatin <niki.hrovatin@famnit.upr.si>
19 */
20 
21 #include "wsnconstructor.h"
22 
23 // Network topolgy -> set of wireless devices
24 //
25 //
26 // Wireless - adhoc network
27 // 10.1.1.0
28 //
29 // ((*)) ((*)) ((*))
30 //
31 //
32 //
33 
34 NS_OBJECT_ENSURE_REGISTERED (WsnConstructor);
35 
36 NS_LOG_COMPONENT_DEFINE ("wsnconstructor");
37 
38 TypeId
40 {
41  static TypeId tid =
42  TypeId ("ns3::WsnConstructor")
43  .SetParent<Object> ()
44  .AddConstructor<WsnConstructor> ()
45  .AddAttribute ("SimulationSeed", "Seed value of the simulation",
46  TypeId::ATTR_CONSTRUCT | TypeId::ATTR_SET | TypeId::ATTR_GET,
47  UintegerValue ((uint32_t) 0),
48  MakeUintegerAccessor (&WsnConstructor::m_simulationSeed),
49  MakeUintegerChecker<uint32_t> ())
50  .AddAttribute ("SimulationName", "Name of the simulation", StringValue ("default"),
51  MakeStringAccessor (&WsnConstructor::m_simulationName),
52  MakeStringChecker ())
53  .AddAttribute ("Topology", "Network topology (random disc topology OR grid topology)",
54  EnumValue (Topology::GRID), MakeEnumAccessor (&WsnConstructor::m_topology),
55  MakeEnumChecker (Topology::GRID, "grid", Topology::DISC, "disc"))
56  .AddAttribute (
57  "IEEE80211n_carrier", "Carrier frequency of the IEEE 802.11n",
58  EnumValue (IEEE_80211n::F_24GHz), MakeEnumAccessor (&WsnConstructor::m_mac),
59  MakeEnumChecker (IEEE_80211n::F_24GHz, "2_4GHz", IEEE_80211n::F_5GHz, "5GHz"))
60  .AddAttribute ("Routing", "Routing algorithm for wireless multi-hop networks",
61  EnumValue (Routing::OLSR), MakeEnumAccessor (&WsnConstructor::m_routing),
62  MakeEnumChecker (Routing::AODV, "aodv", Routing::DSR, "dsr", Routing::OLSR,
63  "olsr", Routing::DSDV, "dsdv"))
64  .AddAttribute ("NodeNumber", "Number of sensor nodes in the network",
65  TypeId::ATTR_CONSTRUCT | TypeId::ATTR_SET | TypeId::ATTR_GET,
66  UintegerValue ((uint16_t) 50),
67  MakeUintegerAccessor (&WsnConstructor::m_numNodes),
68  MakeUintegerChecker<uint16_t> ())
69  .AddAttribute ("Radius", "Parameter for the setup of the random disc topology",
70  TypeId::ATTR_CONSTRUCT | TypeId::ATTR_SET | TypeId::ATTR_GET,
71  UintegerValue ((uint16_t) 15),
72  MakeUintegerAccessor (&WsnConstructor::m_radius),
73  MakeUintegerChecker<uint16_t> ())
74  .AddAttribute ("CellSide",
75  "The length of a cell side in the grid topology. The length is "
76  "representing the distance between neighbouring nodes on the cardinal "
77  "directions of the reference node.",
78  TypeId::ATTR_CONSTRUCT | TypeId::ATTR_SET | TypeId::ATTR_GET,
79  UintegerValue ((uint16_t) 20),
80  MakeUintegerAccessor (&WsnConstructor::m_cellSide),
81  MakeUintegerChecker<uint16_t> ())
82  .AddAttribute ("Verbosity", "Verbosity of the simulation", EnumValue (Verbosity::Both),
83  MakeEnumAccessor (&WsnConstructor::m_verbosity),
84  MakeEnumChecker (Verbosity::NO, "no", Verbosity::ConsoleLog, "consoleLog",
85  Verbosity::PrintDescription, "description",
86  Verbosity::Both, "both"))
87  .AddAttribute ("MSS", "Maximum segment size",
88  TypeId::ATTR_CONSTRUCT | TypeId::ATTR_SET | TypeId::ATTR_GET,
89  UintegerValue (536), MakeUintegerAccessor (&WsnConstructor::m_mss),
90  MakeUintegerChecker<uint16_t> ())
91  .AddAttribute (
92  "CommOverhead", "Collect statistics about the communication overhead",
93  EnumValue (CommunicationStatistics::Y), MakeEnumAccessor (&WsnConstructor::m_stats),
94  MakeEnumChecker (CommunicationStatistics::N, "n", CommunicationStatistics::Y, "y"))
95  .AddAttribute (
96  "Paths",
97  "String of values delimited by the symbol \",\" each value representing the number "
98  "of hops the onion will travel to return back to the sink node issuer of the onion.",
99  StringValue ("5,10,20,30,40,50"),
100  MakeStringAccessor (&WsnConstructor::m_pathsLengths), MakeStringChecker ())
101  .AddAttribute ("RepeatePaths",
102  "Integer specifying the number of times to generate the onion message for "
103  "each value of the parameter Paths",
104  TypeId::ATTR_CONSTRUCT | TypeId::ATTR_SET | TypeId::ATTR_GET,
105  UintegerValue ((uint16_t) 1),
106  MakeUintegerAccessor (&WsnConstructor::m_onionRepeate),
107  MakeUintegerChecker<uint16_t> ());
108  return tid;
109 }
110 
111 //constructor
113 {
114 }
115 
116 void
118 {
119  //seed cannot be zero
120  RngSeedManager::SetSeed (m_simulationSeed + 1); //random seeder
121 
122  switch (m_routing)
123  {
124  case Routing::AODV:
126  break;
127  case Routing::DSR:
129  break;
130  case Routing::OLSR:
132  break;
133  case Routing::DSDV:
135  break;
136  }
137 
138  switch (m_topology)
139  {
140  case Topology::GRID:
141  m_simulationName = m_simulationName + "_GRID_";
142  break;
143  case Topology::DISC:
144  m_simulationName = m_simulationName + "_DISC_";
145  break;
146  }
147 
148  //set the maximum segment size of the network
149  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (m_mss));
150  Config::SetDefault ("ns3::Wsn_node::MSS", UintegerValue (m_mss));
151 
153  m_simulationName + std::to_string (m_numNodes) + "_" + std::to_string (m_simulationSeed);
154 
155  m_simulationDescription = m_simulationDescription + "Simulation name: " + m_simulationName + "\n";
156 
157  int run = RngSeedManager::GetRun ();
158  int seed = RngSeedManager::GetRun ();
160  "Simulation randomstream setup, run: " + std::to_string (run) +
161  ", seed:" + std::to_string (seed) + "\n";
162 
163  m_onionValidator = CreateObject<OnionValidator> ();
164 
165  //verbosity of the simulation
167  {
168  LogComponentEnable ("wsnconstructor", LOG_LEVEL_INFO);
169  LogComponentEnable ("sink", LOG_LEVEL_INFO);
170  LogComponentEnable ("sensornode", LOG_LEVEL_INFO);
171  LogComponentEnable ("outputmanager", LOG_LEVEL_INFO);
172  LogComponentEnable ("onionrouting", LOG_LEVEL_INFO);
173  }
175  {
176  m_outputManager = CreateObject<OutputManager> (m_simulationName, m_simulationSeed, m_numNodes,
177  m_topology, m_routing, true);
178  }
179  else
180  {
181  m_outputManager = CreateObject<OutputManager> (m_simulationName, m_simulationSeed, m_numNodes,
182  m_topology, m_routing, false);
183  }
184  m_outputManager->CreateOutputFile ();
185 }
186 
190 void
192 {
194 
195  CreateNodes ();
196  CreateDevices ();
197 
198  switch (m_topology)
199  {
200  case Topology::GRID:
202  break;
203  case Topology::DISC:
205  break;
206  }
207 
210 
212  {
214  }
215 
216  time_t givemetime = time (NULL);
218  m_simulationDescription + "Simulation started at: " + ctime (&givemetime);
219 
221 
222  givemetime = time (NULL);
223  std::cout << "Simulation: " << m_simulationName
224  << " started at time: " << std::string (ctime (&givemetime)) << std::endl;
225 
226  Simulator::Run ();
227 
228  givemetime = time (NULL);
229 
230  m_outputManager->SimulationEnd (std::string (ctime (&givemetime)));
231 
232  givemetime = time (NULL);
233  std::cout << "Simulation: " << m_simulationName
234  << " ended at time: " + std::string (ctime (&givemetime)) << std::endl;
235 
237  {
238  //save data collected by the data object
239  Ptr<DataOutputInterface> output;
240  output = CreateObject<OmnetDataOutput> ();
241  output->SetFilePrefix ("./src/onion_routing_wsn/sim_results/comm-overhead-stats-" +
243  output->Output (data);
244  }
245 
246  Simulator::Destroy ();
247 }
248 
255 void
257 {
258  //count the number of paths
259  int start = 0;
260  int end = m_pathsLengths.find (',');
261  while (end != -1)
262  {
263  m_numOnionPaths++;
264  start = end + 1; //increase by the delimiter size in this case one symbol (,)
265  end = m_pathsLengths.find (',', start);
266  }
267  m_onionPathsLengths = new uint16_t[++m_numOnionPaths];
268 
269  //insert the path length in single cells of the array m_onionPathsLengths
270  start = 0;
271  end = m_pathsLengths.find (',');
272  int i = 0;
273  while (end != -1)
274  {
276  (uint16_t) (unsigned int) std::stoi (m_pathsLengths.substr (start, end - start));
277  start = end + 1; //increase by the delimiter size in this case one symbol (,)
278  end = m_pathsLengths.find (',', start);
279  i++;
280  }
282  (uint16_t) (unsigned int) std::stoi (m_pathsLengths.substr (start, end - start));
283 }
284 
285 void
287 {
288 
289  data.DescribeRun ("onion-routing-wsn", m_simulationDescription, "communication overhead", "");
290  data.AddMetadata ("Captured data:",
291  "Count of packets and statistics about packet size. (sum is in bytes)");
292 
293  Ptr<PacketSizeMinMaxAvgTotalCalculator> macTxPkts =
294  CreateObject<PacketSizeMinMaxAvgTotalCalculator> ();
295  macTxPkts->SetKey ("total-wsn-communication-overhead-transmitted");
296  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
297  MakeCallback (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate, macTxPkts));
298  data.AddDataCalculator (macTxPkts);
299  Ptr<PacketSizeMinMaxAvgTotalCalculator> macRxPkts =
300  CreateObject<PacketSizeMinMaxAvgTotalCalculator> ();
301  macRxPkts->SetKey ("total-wsn-communication-overhead-received");
302  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
303  MakeCallback (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate, macRxPkts));
304  data.AddDataCalculator (macRxPkts);
305  Ptr<PacketSizeMinMaxAvgTotalCalculator> appRx =
306  CreateObject<PacketSizeMinMaxAvgTotalCalculator> ();
307  appRx->SetKey ("app-layer-data-received");
308  Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::Wsn_node/AppRx",
309  MakeCallback (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate, appRx));
310  data.AddDataCalculator (appRx);
311 }
312 
316 void
318 {
319  NS_LOG_INFO ("--------------- Create " << m_numNodes << " sensor nodes and 1 sink node");
320 
321  m_sink.Create (1);
322  sensornodes.Create (m_numNodes);
323 
324  wifiNodes.Add (m_sink);
325  wifiNodes.Add (sensornodes);
326 
328  "Total sensornodes: " + std::to_string (sensornodes.GetN ()) +
329  " and 1 sink node \n";
330 }
331 
335 void
337 {
338  NS_LOG_INFO ("--------------- Creating and configuring devices & setup WiFi channel");
339 
340  WifiHelper wifi;
341  //define the used standard
342  switch (m_mac)
343  {
345  wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
346  break;
347  case IEEE_80211n::F_5GHz:
348  wifi.SetStandard (WIFI_STANDARD_80211n_5GHZ);
349  break;
350  }
351 
352  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager");
353  //htmcs = High throughput modulation coding schemes
354 
355  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper ();
356 
357  //Configure the channel:
358  YansWifiChannelHelper wifiChannel;
359  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
360 
361  //get details about MCS
362  StringValue ptr;
363  Ptr<ConstantRateWifiManager> cr = CreateObject<ConstantRateWifiManager> ();
364  cr->GetAttribute ("DataMode", ptr);
365  std::string mcs_details = ", DataMode: " + ptr.Get ();
366  cr->GetAttribute ("ControlMode", ptr);
367  mcs_details = mcs_details + ", ControlMode: " + ptr.Get ();
368 
369  switch (m_mac)
370  {
372  //if wifiPhy is 2.4Ghz
373  wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel", "Exponent",
374  DoubleValue (3.0), "ReferenceLoss", DoubleValue (40.0459));
376  m_simulationDescription + "Wireless: IEEE 802.11n at 2.4GHz, " + mcs_details;
377  break;
378  case IEEE_80211n::F_5GHz:
379  //if wifiPhy is default - 5Ghz
380  wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel", "Exponent",
381  DoubleValue (3.0));
383  m_simulationDescription + "Wireless: IEEE 802.11n at 5GHz, " + mcs_details;
384  break;
385  }
386 
387  wifiPhy.SetChannel (wifiChannel.Create ());
388 
389  //MAC configuration
390  WifiMacHelper wifiMac;
391  wifiMac.SetType ("ns3::AdhocWifiMac", "BE_MaxAmpduSize", UintegerValue (65535));
392 
393  //install devices
394  wifiDevices = wifi.Install (wifiPhy, wifiMac, wifiNodes);
395  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HtConfiguration/"
396  "ShortGuardIntervalSupported",
397  BooleanValue (false)); //set guard interval -- interval betweensymbols to 800ns
398 
399  //get MTU and MSS details
400  UintegerValue mtu;
401  wifiDevices.Get (0)->GetAttribute ("Mtu", mtu);
402  m_simulationDescription = m_simulationDescription + ", MTU:" + std::to_string (mtu.Get ()) +
403  ", MSS:" + std::to_string (m_mss) + "\n";
404 }
405 
406 /*
407 * allocate nodes on physical positions in space
408 *
409 * construct the random disc topology
410 * sensor nodes are randomly deployed on a disc shaped plane
411 */
412 
413 void
415 {
416  //allocate3 positions
417  NS_LOG_INFO ("--------------- Building disc topology");
418 
419  //calculate radius of the disc based on node density and communication range
420  // compute the radius of a circle that covers the sum of the areas of each node
421  int r_disc = m_radius * sqrt (m_numNodes);
422 
425  "Network topology: RANDOM DISC, node radius: " + std::to_string (m_radius) +
426  "m , disc topology radius: " + std::to_string (r_disc) +
427  "m. Sink node located at x:" + std::to_string ((int) r_disc) +
428  ",y:" + std::to_string ((int) r_disc) + " \n";
429 
430  //Random disc
431  ObjectFactory rndDisc;
432  rndDisc.SetTypeId ("ns3::RandomDiscPositionAllocator");
433  rndDisc.Set ("Rho", StringValue ("ns3::UniformRandomVariable[Min=40|Max=" +
434  std::to_string (r_disc) + "]"));
435  rndDisc.Set ("X", DoubleValue (r_disc));
436  rndDisc.Set ("Y", DoubleValue (r_disc));
437  rndDisc.Set ("Z", DoubleValue (0));
438 
439  Ptr<PositionAllocator> posAlloc = rndDisc.Create ()->GetObject<PositionAllocator> ();
440 
441  mobility.SetPositionAllocator (posAlloc);
442  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
443  mobility.Install (sensornodes);
444 
445  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
446  positionAlloc->Add (Vector (r_disc, r_disc, 0.0)); // only one position for sink
447  mobility.SetPositionAllocator (positionAlloc);
448  mobility.Install (m_sink);
449 }
450 
451 /*
452 * allocate nodes on physical positions in space
453 *
454 * construct the grid topology
455 * sensor nodes are deployed in a plane following a grid structure; each sensor node is equidistant from the closest sensor nodes in cardinal directions
456 */
457 
458 void
460 {
461  NS_LOG_INFO ("--------------- Building grid topology");
462 
463  //calculate row size based on node number
464  int row_size = sqrt (m_numNodes);
465  int deltaX = m_cellSide;
466  int deltaY = m_cellSide;
467 
468  mobility.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (0), "MinY",
469  DoubleValue (0), "DeltaX", DoubleValue (deltaX), "DeltaY",
470  DoubleValue (deltaY), "GridWidth", UintegerValue (row_size),
471  "LayoutType", StringValue ("RowFirst"));
472 
473  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
474  //put the sink around the middle of the grid
475  mobility.Install (sensornodes);
476  mobility.Install (m_sink);
477 
478  //change the location of the sink node to center by swap it with a node in the center
479  Ptr<MobilityModel> sinkMobility = m_sink.Get (0)->GetObject<MobilityModel> ();
480 
481  //Get the middle sensor node
482  int m = row_size / 2 * row_size + row_size / 2;
483 
484  Ptr<MobilityModel> middleNodeMobility = sensornodes.Get (m)->GetObject<MobilityModel> ();
485  double middleNode_x = middleNodeMobility->GetPosition ().x;
486  double middleNode_y = middleNodeMobility->GetPosition ().y;
487  //swap node positions
488  middleNodeMobility->SetPosition (
489  Vector (sinkMobility->GetPosition ().x, sinkMobility->GetPosition ().y, 0));
490  sinkMobility->SetPosition (Vector (middleNode_x, middleNode_y, 0));
491 
493  "Network topology: GRID with row size: " + std::to_string (row_size) +
494  ". Distance between nodes on X-axis: " + std::to_string (deltaX) +
495  "m. Distance between nodes on Y-axis: " + std::to_string (deltaY) +
496  "m. Sink node located at x:" + std::to_string ((int) middleNode_x) +
497  ",y:" + std::to_string ((int) middleNode_y) + " \n";
498 }
499 
503 void
505 {
506 
507  NS_LOG_INFO ("--------------- Install routing & internet stack ");
508 
509  switch (m_routing)
510  {
511  case Routing::AODV:
512  m_outputManager->SetRouting (Routing::AODV);
513  AODVrouting ();
514  break;
515  case Routing::DSR:
516  m_outputManager->SetRouting (Routing::DSR);
517  DSRrouting ();
518  break;
519  case Routing::OLSR:
520  m_outputManager->SetRouting (Routing::OLSR);
521  OLSRrouting ();
522  break;
523  case Routing::DSDV:
524  m_outputManager->SetRouting (Routing::DSDV);
525  DSDVrouting ();
526  break;
527  }
528 
529  Ipv4AddressHelper address;
530 
531  address.SetBase ("10.1.0.0", "255.255.0.0");
532 
533  wifiInterfaces = address.Assign (wifiDevices);
534 }
535 
536 void
538 {
539  //DSR routing
541 
542  DsrMainHelper dsrMain;
543  DsrHelper dsr;
544 
545  InternetStackHelper stack;
546  stack.Install (wifiNodes);
547  dsrMain.Install (dsr, wifiNodes);
548 }
549 
550 void
552 {
553  //AODV routing
554  m_simulationDescription = m_simulationDescription + "Routing: AODV\n";
555 
556  AodvHelper aodv;
557 
558  Ipv4StaticRoutingHelper staticRouting;
559 
560  Ipv4ListRoutingHelper list;
561  list.Add (staticRouting, 0);
562  list.Add (aodv, 10);
563 
564  InternetStackHelper stack;
565  stack.SetRoutingHelper (list);
566  stack.Install (wifiNodes);
567 }
568 
569 void
571 {
572  //OLSR routing
573  m_simulationDescription = m_simulationDescription + "Routing: OLSR\n";
574 
575  OlsrHelper olsr;
576 
577  Ipv4StaticRoutingHelper staticRouting;
578 
579  Ipv4ListRoutingHelper list;
580  list.Add (staticRouting, 0);
581  list.Add (olsr, 10);
582 
583  InternetStackHelper stack;
584  stack.SetRoutingHelper (list);
585  stack.Install (wifiNodes);
586 }
587 
588 void
590 {
591  //DSDV routing
592  m_simulationDescription = m_simulationDescription + "Routing: DSDV\n";
593 
594  DsdvHelper dsdv;
595 
596  Ipv4StaticRoutingHelper staticRouting;
597 
598  Ipv4ListRoutingHelper list;
599  list.Add (staticRouting, 0);
600  list.Add (dsdv, 10);
601 
602  InternetStackHelper stack;
603  stack.SetRoutingHelper (list);
604  stack.Install (wifiNodes);
605 }
606 
610 void
612 {
613  NS_LOG_INFO ("--------------- Configuring Applications ");
614 
615  //olsr is a proactive routing algo and need some time to compute routes
616  //at least 30s
617  int routing_setup_time = 20;
618 
620  {
621  routing_setup_time = 60;
622  }
623 
624  //sink helper
626  //node helper - create nodes helpers to install node application
628 
629  //install sink apps
630  sinkApps = msh.Install (m_sink);
631  //install node apps
632  sensornodeApps.Add (mnh.Install (sensornodes));
633 
634  //setup onion routing settings on the sink node
635  sinkApps.Get (0)->GetObject<Sink> ()->Setup (m_onionPathsLengths, m_numOnionPaths,
637 
638  //start apps
639  sinkApps.Start (Seconds (1.0 + routing_setup_time));
640  sensornodeApps.Start (Seconds (2.0 + routing_setup_time));
641 
642  UintegerValue node_delay;
643  sinkApps.Get (0)->GetObject<Sink> ()->GetAttribute ("Delay", node_delay);
644  int start_onion = (node_delay.Get () * m_numNodes) / 1000 +
645  5; // when the sink node will start send onions in seconds
646 
648  m_simulationDescription + "Routing setup time: " + std::to_string (routing_setup_time) +
649  "s, nodes are starting sequentially with " + std::to_string (node_delay.Get ()) +
650  "ms interval, onion starts at: " + std::to_string (start_onion + routing_setup_time) + "s\n";
651 
652  m_simulationDescription = m_simulationDescription + "Onion path lengths: ";
653 
654  for (int i = 0; i < m_numOnionPaths; ++i)
655  {
657  m_simulationDescription + std::to_string (m_onionPathsLengths[i]) + " ";
658  }
659  m_simulationDescription = m_simulationDescription + " repeate each path lenght " +
660  std::to_string (m_onionRepeate) + " times.\n";
661 }
662 
663 int
664 main (int argc, char **argv)
665 {
666 
667  //Load attributes from xml configuration file
668  Config::SetDefault ("ns3::ConfigStore::Filename",
669  StringValue ("src/onion_routing_wsn/configParameters.xml"));
670  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Load"));
671  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
672  ConfigStore inputConfig;
673  inputConfig.ConfigureDefaults ();
674 
675  //load attributes setup from commandline
676  CommandLine cmd;
677  cmd.AddValue (
678  "a_simNum",
679  "ns3::WsnConstructor::SimulationSeed"); //number of the simulation, that defines the seed
680  cmd.AddValue ("a_name", "ns3::WsnConstructor::SimulationName"); // a name used as identifier
681  cmd.AddValue ("a_routing",
682  "ns3::WsnConstructor::Routing"); //the selected routing protocol
683  cmd.AddValue ("a_topology", "ns3::WsnConstructor::Topology"); //the selected topology
684  cmd.AddValue ("a_nodeNumber", "ns3::WsnConstructor::NodeNumber"); //number of nodes in the network
685  cmd.Parse (argc, argv);
686 
687  Ptr<WsnConstructor> bt = CreateObject<WsnConstructor> ();
688 
689  bt->Configure (); //configure the simulation
690 
691  bt->Run ();
692 
693  return 0;
694 }
WsnConstructor::InstallApplications
void InstallApplications()
Install applications on nodes and setup starting time of the handshake and the onion start time.
Definition: wsnconstructor.cc:611
WsnConstructor::sinkApps
ApplicationContainer sinkApps
Container of sink node applications.
Definition: wsnconstructor.h:228
WsnConstructor::Configure
void Configure()
Generate a description of attributes given from the config file and from CLI set the simulation seed ...
Definition: wsnconstructor.cc:117
WsnConstructor::DSDVrouting
void DSDVrouting()
Install DSDV routing.
Definition: wsnconstructor.cc:589
ns3::OLSR
@ OLSR
Optimized Link State Routing Protocol ns3::Olsr.
Definition: enums.h:44
WsnConstructor::wifiDevices
NetDeviceContainer wifiDevices
Container of wireless devices.
Definition: wsnconstructor.h:226
ns3::ConsoleLog
@ ConsoleLog
Output data and simulation description on console log, output data in csv file.
Definition: enums.h:82
WsnConstructor::m_mac
enum IEEE_80211n m_mac
Carrier frequency of the IEEE 802.11n.
Definition: wsnconstructor.h:108
WsnConstructor::m_radius
uint16_t m_radius
Parameter for the setup of the random disc topology.
Definition: wsnconstructor.h:112
WsnConstructor::CreateNodes
void CreateNodes()
Create node objects.
Definition: wsnconstructor.cc:317
ns3::SensorNodeHelper
Helper class for the creation of SensorNode applications.
Definition: sensornode-helper.h:56
ns3::DSR
@ DSR
Dynamic Source Routing ns3::Dsr.
Definition: enums.h:43
WsnConstructor::BuildDiscTopology
void BuildDiscTopology()
Deploy nodes at random positions on a disc shaped plane.
Definition: wsnconstructor.cc:414
ns3::Y
@ Y
output on file in "./src/onion_routing_wsn/sim_results/"
Definition: enums.h:96
wsnconstructor.h
ns3::DISC
@ DISC
Random disc topology.
Definition: enums.h:57
WsnConstructor::m_routing
enum Routing m_routing
routing algorithm for wireless multihop networks
Definition: wsnconstructor.h:106
ns3::F_5GHz
@ F_5GHz
5GHz
Definition: enums.h:69
ns3::GRID
@ GRID
Grid topology.
Definition: enums.h:56
WsnConstructor::m_stats
enum CommunicationStatistics m_stats
setting of recording communication statistics
Definition: wsnconstructor.h:110
WsnConstructor::m_numOnionPaths
uint16_t m_numOnionPaths
Number of different onion paths.
Definition: wsnconstructor.h:124
WsnConstructor::DSRrouting
void DSRrouting()
Install DSR routing.
Definition: wsnconstructor.cc:537
ns3::SensorNodeHelper::Install
ApplicationContainer Install(NodeContainer c) const
Definition: sensornode-helper.cc:65
WsnConstructor::InstallInternetStack
void InstallInternetStack()
Installing the internet stack on nodes and setting up IP-addresses.
Definition: wsnconstructor.cc:504
WsnConstructor::m_mss
uint16_t m_mss
maximum segment size
Definition: wsnconstructor.h:111
WsnConstructor::m_sink
NodeContainer m_sink
Container of the sink node.
Definition: wsnconstructor.h:224
ns3::NO
@ NO
No output on console log, except notifying simulation start and end, output data in csv file.
Definition: enums.h:80
WsnConstructor::m_numNodes
uint16_t m_numNodes
number of sensor nodes in the WSN
Definition: wsnconstructor.h:105
WsnConstructor::wifiInterfaces
Ipv4InterfaceContainer wifiInterfaces
Container of netork interfaces.
Definition: wsnconstructor.h:227
WsnConstructor::CaptureStatistics
void CaptureStatistics()
Instantiate objects for collecting data with the statistical framework.
Definition: wsnconstructor.cc:286
ns3::DSDV
@ DSDV
Destination-Sequenced Distance Vector routing ns3::Dsdv.
Definition: enums.h:45
WsnConstructor::m_onionValidator
Ptr< OnionValidator > m_onionValidator
Checks if the onion messagess transiting in the network are valid.
Definition: wsnconstructor.h:118
WsnConstructor::wifiNodes
NodeContainer wifiNodes
Container of wireless nodes.
Definition: wsnconstructor.h:223
WsnConstructor::CreateDevices
void CreateDevices()
Create Network devices and setup the wireless communication based on the IEEE 802....
Definition: wsnconstructor.cc:336
ns3::Both
@ Both
print all simulation output on console log and csv file
Definition: enums.h:84
WsnConstructor::m_pathsLengths
std::string m_pathsLengths
String of values delimited by the symbol "," each value representing the number of hops the onion wil...
Definition: wsnconstructor.h:128
WsnConstructor::m_cellSide
uint16_t m_cellSide
Parameter for the setup of the grid topology.
Definition: wsnconstructor.h:113
WsnConstructor::m_simulationDescription
std::string m_simulationDescription
String holding a description of parameters used in the simulation.
Definition: wsnconstructor.h:120
WsnConstructor::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: wsnconstructor.cc:39
ns3::SinkHelper
Helper class for the creation of Sink applications.
Definition: sink-helper.h:66
WsnConstructor::sensornodeApps
ApplicationContainer sensornodeApps
Container of sensor node applications.
Definition: wsnconstructor.h:229
WsnConstructor::OLSRrouting
void OLSRrouting()
Install OLSR routing.
Definition: wsnconstructor.cc:570
ns3::PrintDescription
@ PrintDescription
No output on console log, print simulation description and data on csv file.
Definition: enums.h:83
WsnConstructor::ProcessPathString
void ProcessPathString()
Split the string m_pathsLengths by the delimiter (,) and save each value into m_onionPathsLengths and...
Definition: wsnconstructor.cc:256
WsnConstructor::m_simulationName
std::string m_simulationName
name of the simulation
Definition: wsnconstructor.h:121
WsnConstructor::WsnConstructor
WsnConstructor()
Default constructor.
Definition: wsnconstructor.cc:112
WsnConstructor::mobility
MobilityHelper mobility
Topology helper.
Definition: wsnconstructor.h:222
ns3::Sink
The application of the sink node. The node that generates onion messagess.
Definition: sink.h:49
WsnConstructor::sensornodes
NodeContainer sensornodes
Container of sensor nodes.
Definition: wsnconstructor.h:225
WsnConstructor::m_onionPathsLengths
uint16_t * m_onionPathsLengths
Array containing one onion path length in each cell.
Definition: wsnconstructor.h:125
ns3::N
@ N
no output
Definition: enums.h:95
ns3::F_24GHz
@ F_24GHz
2.4GHz
Definition: enums.h:68
WsnConstructor::data
DataCollector data
Collect data with the stats framework.
Definition: wsnconstructor.h:130
WsnConstructor
The class that constructs the WSN, setup applications on nodes and starts the simulation.
Definition: wsnconstructor.h:69
ns3::AODV
@ AODV
Ad Hoc On-Demand Distance Vector ns3::Aodv.
Definition: enums.h:42
WsnConstructor::m_verbosity
enum Verbosity m_verbosity
verbosity of the simulation
Definition: wsnconstructor.h:109
WsnConstructor::m_simulationSeed
uint32_t m_simulationSeed
seed to use for the random generation of numbers during the simulation
Definition: wsnconstructor.h:104
WsnConstructor::Run
void Run()
Construct the WSN, install applications on nodes and start the simulation.
Definition: wsnconstructor.cc:191
WsnConstructor::BuildGridTopology
void BuildGridTopology()
Sensor nodes are deployed according to a grid structure; each sensor node is equidistant from the clo...
Definition: wsnconstructor.cc:459
WsnConstructor::m_topology
enum Topology m_topology
network topology
Definition: wsnconstructor.h:107
ns3::SinkHelper::Install
ApplicationContainer Install(NodeContainer c) const
Definition: sink-helper.cc:65
WsnConstructor::m_outputManager
Ptr< OutputManager > m_outputManager
Manages the output of the simulation.
Definition: wsnconstructor.h:116
WsnConstructor::m_onionRepeate
uint16_t m_onionRepeate
Number of times to generate the onion for each value of path length.
Definition: wsnconstructor.h:126
WsnConstructor::AODVrouting
void AODVrouting()
Install AODV routing.
Definition: wsnconstructor.cc:551