A Discrete-Event Network Simulator
API
vanet-routing-compare.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 North Carolina State University
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  * Author: Scott E. Carpenter <scarpen@ncsu.edu>
19  *
20  */
21 
22 /*
23  * This example program allows one to run vehicular ad hoc
24  * network (VANET) simulation scenarios in ns-3 to assess
25  * performance by evaluating different 802.11p MAC/PHY
26  * characteristics, propagation loss models (e.g. Friss,
27  * Two-Ray Ground, or ITU R-P.1411), and application traffic
28  * (e.g. Basic Safety Message) and/or routing traffic (e.g.
29  * DSDV, AODV, OLSR, or DSR) under either a synthetic highway
30  * scenario (i.e. a random waypoint mobility model) or by
31  * playing back mobility trace files (i.e. ns-2 movement files).
32  *
33  * The script draws from several ns-3 examples, including:
34  * /examples/routing/manet-routing-compare.cc
35  * /src/propagation/model/itu-r-1411-los-propagation-loss-model.cc
36  * /src/mobility/examples/ns2-mobility-trace.cc
37  * /src/wave/examples/wave-simple-80211p.cc
38  *
39  * The script allows many parameters to be modified and
40  * includes two predefined scenarios. By default
41  * scenario=1 runs for 10 simulated seconds with 40 nodes
42  * (i.e. vehicles) moving according to RandomWaypointMobilityModel
43  * with a speed of 20 m/s and no pause time within a 300x1500 m
44  * region. The WiFi is 802.11p with continuous access to a 10 MHz
45  * Control Channel (CH) for all traffic. All nodes transmit a
46  * 200-byte safety message 10 times per second at 6 Mbps.
47  * Additionally, all nodes (optionally) attempt to
48  * continuously route 64-byte packets at an application
49  * rate of 2.048 Kbps to one of 10 other nodes,
50  * selected as sink nodes. The default routing protocol is AODV
51  * and the Two-Ray Ground loss model is used.
52  * The transmit power is set to 20 dBm and the transmission range
53  * for safety message packet delivery is 145 m.
54  *
55  * Scenario 2 plays back vehicular trace files in
56  * ns-2 movement format, and are taken from:
57  * http://www.lst.inf.ethz.ch/research/ad-hoc/car-traces/
58  * This scenario is 300 simulation seconds of 99
59  * vehicles respectively within the Unterstrass
60  * section of Zurich Switzerland that travel based on
61  * models derived from real traffic data. Note that these
62  * scenarios can require a lot of clock time to complete.
63  *
64  * All parameters can be changed from their defaults (see
65  * --help) and changing simulation parameters can have dramatic
66  * impact on network performance.
67  *
68  * Several items can be output:
69  * - a CSV file of data reception statistics, output once per
70  * second
71  * - final statistics, in a CSV file
72  * - dump of routing tables at 5 seconds into the simulation
73  * - ASCII trace file
74  * - PCAP trace files for each node
75  *
76  * Simulation scenarios can be defined and configuration
77  * settings can be saved using config-store (raw text)
78  * which can they be replayed again. This is an easy way
79  * to define and save the settings for a scenario, and then
80  * re-execute the same scenario exactly, or to set up
81  * several different simulation scenarios.
82  * For example, to set up a scenario and save the configuration
83  * as "scenario1.txt":
84  * ./waf --run "vanet-routing-compare --scenario=1 --saveconfig=scenario1.txt"
85  * Then, to re-play the scenario using the save configuration
86  * settings:
87  * ./waf --run "vanet-routing-compare --loadconfig=scenario1.txt"
88  *
89  * Class Diagram:
90  * main()
91  * +--uses-- VanetRoutingExperiment
92  * +--is_a--- WifiApp
93  * +--uses--- ConfigStoreHelper
94  * +--has_a-- WaveBsmHelper
95  * | +--has_a-- WaveBsmStats
96  * +--has_a-- RoutingHelper
97  * | +--has_a--RoutingStats
98  * +--has_a-- WifiPhyStats
99  *
100  */
101 
102 #include <fstream>
103 #include <iostream>
104 #include "ns3/core-module.h"
105 #include "ns3/network-module.h"
106 #include "ns3/internet-module.h"
107 #include "ns3/mobility-module.h"
108 #include "ns3/wifi-module.h"
109 #include "ns3/aodv-module.h"
110 #include "ns3/olsr-module.h"
111 #include "ns3/dsdv-module.h"
112 #include "ns3/dsr-module.h"
113 #include "ns3/applications-module.h"
114 #include "ns3/itu-r-1411-los-propagation-loss-model.h"
115 #include "ns3/ocb-wifi-mac.h"
116 #include "ns3/wifi-80211p-helper.h"
117 #include "ns3/wave-mac-helper.h"
118 #include "ns3/flow-monitor-module.h"
119 #include "ns3/config-store-module.h"
120 #include "ns3/integer.h"
121 #include "ns3/wave-bsm-helper.h"
122 #include "ns3/wave-helper.h"
123 // future #include "ns3/topology.h"
124 
125 using namespace ns3;
126 using namespace dsr;
127 
128 NS_LOG_COMPONENT_DEFINE ("vanet-routing-compare");
129 
137 {
138 public:
143  RoutingStats ();
144 
149  uint32_t GetRxBytes ();
150 
155  uint32_t GetCumulativeRxBytes ();
156 
161  uint32_t GetRxPkts ();
162 
167  uint32_t GetCumulativeRxPkts ();
168 
175  void IncRxBytes (uint32_t rxBytes);
176 
181  void IncRxPkts ();
182 
188  void SetRxBytes (uint32_t rxBytes);
189 
195  void SetRxPkts (uint32_t rxPkts);
196 
201  uint32_t GetTxBytes ();
202 
208  uint32_t GetCumulativeTxBytes ();
209 
214  uint32_t GetTxPkts ();
215 
220  uint32_t GetCumulativeTxPkts ();
221 
227  void IncTxBytes (uint32_t txBytes);
228 
233  void IncTxPkts ();
234 
240  void SetTxBytes (uint32_t txBytes);
241 
247  void SetTxPkts (uint32_t txPkts);
248 
249 private:
250  uint32_t m_RxBytes;
252  uint32_t m_RxPkts;
254  uint32_t m_TxBytes;
256  uint32_t m_TxPkts;
258 };
259 
261  : m_RxBytes (0),
262  m_cumulativeRxBytes (0),
263  m_RxPkts (0),
264  m_cumulativeRxPkts (0),
265  m_TxBytes (0),
266  m_cumulativeTxBytes (0),
267  m_TxPkts (0),
268  m_cumulativeTxPkts (0)
269 {
270 }
271 
272 uint32_t
274 {
275  return m_RxBytes;
276 }
277 
278 uint32_t
280 {
281  return m_cumulativeRxBytes;
282 }
283 
284 uint32_t
286 {
287  return m_RxPkts;
288 }
289 
290 uint32_t
292 {
293  return m_cumulativeRxPkts;
294 }
295 
296 void
297 RoutingStats::IncRxBytes (uint32_t rxBytes)
298 {
299  m_RxBytes += rxBytes;
300  m_cumulativeRxBytes += rxBytes;
301 }
302 
303 void
305 {
306  m_RxPkts++;
308 }
309 
310 void
311 RoutingStats::SetRxBytes (uint32_t rxBytes)
312 {
313  m_RxBytes = rxBytes;
314 }
315 
316 void
317 RoutingStats::SetRxPkts (uint32_t rxPkts)
318 {
319  m_RxPkts = rxPkts;
320 }
321 
322 uint32_t
324 {
325  return m_TxBytes;
326 }
327 
328 uint32_t
330 {
331  return m_cumulativeTxBytes;
332 }
333 
334 uint32_t
336 {
337  return m_TxPkts;
338 }
339 
340 uint32_t
342 {
343  return m_cumulativeTxPkts;
344 }
345 
346 void
347 RoutingStats::IncTxBytes (uint32_t txBytes)
348 {
349  m_TxBytes += txBytes;
350  m_cumulativeTxBytes += txBytes;
351 }
352 
353 void
355 {
356  m_TxPkts++;
358 }
359 
360 void
361 RoutingStats::SetTxBytes (uint32_t txBytes)
362 {
363  m_TxBytes = txBytes;
364 }
365 
366 void
367 RoutingStats::SetTxPkts (uint32_t txPkts)
368 {
369  m_TxPkts = txPkts;
370 }
371 
382 class RoutingHelper : public Object
383 {
384 public:
389  static TypeId GetTypeId (void);
390 
395  RoutingHelper ();
396 
401  virtual ~RoutingHelper ();
402 
416  void Install (NodeContainer & c,
417  NetDeviceContainer & d,
419  double totalTime,
420  int protocol,
421  uint32_t nSinks,
422  int routingTables);
423 
430  void OnOffTrace (std::string context, Ptr<const Packet> packet);
431 
437 
443  void SetLogging (int log);
444 
445 private:
452 
460  Ipv4InterfaceContainer & adhocTxInterfaces);
461 
469  Ipv4InterfaceContainer & adhocTxInterfaces);
470 
478 
484  void ReceiveRoutingPacket (Ptr<Socket> socket);
485 
486  double m_TotalSimTime; // seconds
487  uint32_t m_protocol; // routing protocol; 0=NONE, 1=OLSR, 2=AODV, 3=DSDV, 4=DSR
488  uint32_t m_port;
489  uint32_t m_nSinks; // number of sink nodes (< all nodes)
490  int m_routingTables; // dump routing table (at t=5 sec). 0=No, 1=Yes
492  std::string m_protocolName;
493  int m_log;
494 };
495 
497 
498 TypeId
500 {
501  static TypeId tid = TypeId ("ns3::RoutingHelper")
502  .SetParent<Object> ()
503  .AddConstructor<RoutingHelper> ();
504  return tid;
505 }
506 
508  : m_TotalSimTime (300.01),
509  m_protocol (0),
510  m_port (9),
511  m_nSinks (0),
512  m_routingTables (0),
513  m_log (0)
514 {
515 }
516 
518 {
519 }
520 
521 void
523  NetDeviceContainer & d,
525  double totalTime,
526  int protocol,
527  uint32_t nSinks,
528  int routingTables)
529 {
530  m_TotalSimTime = totalTime;
531  m_protocol = protocol;
532  m_nSinks = nSinks;
533  m_routingTables = routingTables;
534 
536  AssignIpAddresses (d, i);
537  SetupRoutingMessages (c, i);
538 }
539 
542 {
543  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
544  Ptr<Socket> sink = Socket::CreateSocket (node, tid);
546  sink->Bind (local);
548 
549  return sink;
550 }
551 
552 void
554 {
555  AodvHelper aodv;
557  DsdvHelper dsdv;
558  DsrHelper dsr;
559  DsrMainHelper dsrMain;
561  InternetStackHelper internet;
562 
563  Time rtt = Time (5.0);
564  AsciiTraceHelper ascii;
565  Ptr<OutputStreamWrapper> rtw = ascii.CreateFileStream ("routing_table");
566 
567  switch (m_protocol)
568  {
569  case 0:
570  m_protocolName = "NONE";
571  break;
572  case 1:
573  if (m_routingTables != 0)
574  {
575  olsr.PrintRoutingTableAllAt (rtt, rtw);
576  }
577  list.Add (olsr, 100);
578  m_protocolName = "OLSR";
579  break;
580  case 2:
581  if (m_routingTables != 0)
582  {
583  aodv.PrintRoutingTableAllAt (rtt, rtw);
584  }
585  list.Add (aodv, 100);
586  m_protocolName = "AODV";
587  break;
588  case 3:
589  if (m_routingTables != 0)
590  {
591  dsdv.PrintRoutingTableAllAt (rtt, rtw);
592  }
593  list.Add (dsdv, 100);
594  m_protocolName = "DSDV";
595  break;
596  case 4:
597  // setup is later
598  m_protocolName = "DSR";
599  break;
600  default:
601  NS_FATAL_ERROR ("No such protocol:" << m_protocol);
602  break;
603  }
604 
605  if (m_protocol < 4)
606  {
607  internet.SetRoutingHelper (list);
608  internet.Install (c);
609  }
610  else if (m_protocol == 4)
611  {
612  internet.Install (c);
613  dsrMain.Install (dsr, c);
614  }
615 
616  if (m_log != 0)
617  {
618  NS_LOG_UNCOND ("Routing Setup for " << m_protocolName);
619  }
620 }
621 
622 void
624  Ipv4InterfaceContainer & adhocTxInterfaces)
625 {
626  NS_LOG_INFO ("Assigning IP addresses");
627  Ipv4AddressHelper addressAdhoc;
628  // we may have a lot of nodes, and want them all
629  // in same subnet, to support broadcast
630  addressAdhoc.SetBase ("10.1.0.0", "255.255.0.0");
631  adhocTxInterfaces = addressAdhoc.Assign (d);
632 }
633 
634 void
636  Ipv4InterfaceContainer & adhocTxInterfaces)
637 {
638  // Setup routing transmissions
639  OnOffHelper onoff1 ("ns3::UdpSocketFactory",Address ());
640  onoff1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
641  onoff1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
642 
643  Ptr<UniformRandomVariable> var = CreateObject<UniformRandomVariable> ();
644  int64_t stream = 2;
645  var->SetStream (stream);
646  for (uint32_t i = 0; i < m_nSinks; i++)
647  {
648  // protocol == 0 means no routing data, WAVE BSM only
649  // so do not set up sink
650  if (m_protocol != 0)
651  {
652  Ptr<Socket> sink = SetupRoutingPacketReceive (adhocTxInterfaces.GetAddress (i), c.Get (i));
653  }
654 
655  AddressValue remoteAddress (InetSocketAddress (adhocTxInterfaces.GetAddress (i), m_port));
656  onoff1.SetAttribute ("Remote", remoteAddress);
657 
658  ApplicationContainer temp = onoff1.Install (c.Get (i + m_nSinks));
659  temp.Start (Seconds (var->GetValue (1.0,2.0)));
660  temp.Stop (Seconds (m_TotalSimTime));
661  }
662 }
663 
664 static inline std::string
666 {
667  std::ostringstream oss;
668 
669  oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
670 
671  if (InetSocketAddress::IsMatchingType (srcAddress))
672  {
673  InetSocketAddress addr = InetSocketAddress::ConvertFrom (srcAddress);
674  oss << " received one packet from " << addr.GetIpv4 ();
675  }
676  else
677  {
678  oss << " received one packet!";
679  }
680  return oss.str ();
681 }
682 
683 void
685 {
686  Ptr<Packet> packet;
687  Address srcAddress;
688  while ((packet = socket->RecvFrom (srcAddress)))
689  {
690  // application data, for goodput
691  uint32_t RxRoutingBytes = packet->GetSize ();
692  GetRoutingStats ().IncRxBytes (RxRoutingBytes);
694  if (m_log != 0)
695  {
696  NS_LOG_UNCOND (m_protocolName + " " + PrintReceivedRoutingPacket (socket, packet, srcAddress));
697  }
698  }
699 }
700 
701 void
702 RoutingHelper::OnOffTrace (std::string context, Ptr<const Packet> packet)
703 {
704  uint32_t pktBytes = packet->GetSize ();
705  routingStats.IncTxBytes (pktBytes);
706 }
707 
708 RoutingStats &
710 {
711  return routingStats;
712 }
713 
714 void
716 {
717  m_log = log;
718 }
719 
724 class WifiPhyStats : public Object
725 {
726 public:
731  static TypeId GetTypeId (void);
732 
737  WifiPhyStats ();
738 
743  virtual ~WifiPhyStats ();
744 
750  uint32_t GetTxBytes ();
751 
761  void PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower);
762 
769  void PhyTxDrop (std::string context, Ptr<const Packet> packet);
770 
777  void PhyRxDrop (std::string context, Ptr<const Packet> packet);
778 
779 private:
780  uint32_t m_phyTxPkts;
781  uint32_t m_phyTxBytes;
782 };
783 
785 
786 TypeId
788 {
789  static TypeId tid = TypeId ("ns3::WifiPhyStats")
790  .SetParent<Object> ()
791  .AddConstructor<WifiPhyStats> ();
792  return tid;
793 }
794 
796  : m_phyTxPkts (0),
797  m_phyTxBytes (0)
798 {
799 }
800 
802 {
803 }
804 
805 void
806 WifiPhyStats::PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
807 {
808  NS_LOG_FUNCTION (this << context << packet << "PHYTX mode=" << mode );
809  ++m_phyTxPkts;
810  uint32_t pktSize = packet->GetSize ();
811  m_phyTxBytes += pktSize;
812 
813  //NS_LOG_UNCOND ("Received PHY size=" << pktSize);
814 }
815 
816 void
817 WifiPhyStats::PhyTxDrop (std::string context, Ptr<const Packet> packet)
818 {
819  NS_LOG_UNCOND ("PHY Tx Drop");
820 }
821 
822 void
823 WifiPhyStats::PhyRxDrop (std::string context, Ptr<const Packet> packet)
824 {
825  NS_LOG_UNCOND ("PHY Rx Drop");
826 }
827 
828 uint32_t
830 {
831  return m_phyTxBytes;
832 }
833 
838 class WifiApp
839 {
840 public:
845  WifiApp ();
846 
851  virtual ~WifiApp ();
852 
859  void Simulate (int argc, char **argv);
860 
861 protected:
866  virtual void SetDefaultAttributeValues ();
867 
874  virtual void ParseCommandLineArguments (int argc, char **argv);
875 
880  virtual void ConfigureNodes ();
881 
886  virtual void ConfigureChannels ();
887 
892  virtual void ConfigureDevices ();
893 
898  virtual void ConfigureMobility ();
899 
904  virtual void ConfigureApplications ();
905 
910  virtual void ConfigureTracing ();
911 
916  virtual void RunSimulation ();
917 
922  virtual void ProcessOutputs ();
923 };
924 
926 {
927 }
928 
930 {
931 }
932 
933 void
934 WifiApp::Simulate (int argc, char **argv)
935 {
936  // Simulator Program Flow:
937  // (source: NS-3 Annual Meeting, May, 2014, session 2 slides 6, 28)
938  // (HandleProgramInputs:)
939  // SetDefaultAttributeValues
940  // ParseCommandLineArguments
941  // (ConfigureTopology:)
942  // ConfigureNodes
943  // ConfigureChannels
944  // ConfigureDevices
945  // ConfigureMobility
946  // ConfigureApplications
947  // e.g AddInternetStackToNodes
948  // ConfigureIpAddressingAndRouting
949  // configureSendMessages
950  // ConfigureTracing
951  // RunSimulation
952  // ProcessOutputs
953 
955  ParseCommandLineArguments (argc, argv);
956  ConfigureNodes ();
958  ConfigureDevices ();
961  ConfigureTracing ();
962  RunSimulation ();
963  ProcessOutputs ();
964 }
965 
966 void
968 {
969 }
970 
971 void
972 WifiApp::ParseCommandLineArguments (int argc, char **argv)
973 {
974 }
975 
976 void
978 {
979 }
980 
981 void
983 {
984 }
985 
986 void
988 {
989 }
990 
991 void
993 {
994 }
995 
996 void
998 {
999 }
1000 
1001 void
1003 {
1004 }
1005 
1006 void
1008 {
1009 }
1010 
1011 void
1013 {
1014 }
1015 
1021 {
1022 public:
1027  ConfigStoreHelper ();
1028 
1034  void LoadConfig (std::string configFilename);
1035 
1041  void SaveConfig (std::string configFilename);
1042 };
1043 
1045 {
1046 }
1047 
1048 void
1049 ConfigStoreHelper::LoadConfig (std::string configFilename)
1050 {
1051  // Input config store from txt format
1052  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1053  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1054  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Load"));
1055  ConfigStore inputConfig;
1056  inputConfig.ConfigureDefaults ();
1057  //inputConfig.ConfigureAttributes ();
1058 }
1059 
1060 void
1061 ConfigStoreHelper::SaveConfig (std::string configFilename)
1062 {
1063  // only save if a non-empty filename has been specified
1064  if (configFilename.compare ("") != 0)
1065  {
1066  // Output config store to txt format
1067  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1068  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1069  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
1070  ConfigStore outputConfig;
1071  outputConfig.ConfigureDefaults ();
1072  //outputConfig.ConfigureAttributes ();
1073  }
1074 }
1075 
1082 {
1083 public:
1089 
1090 protected:
1095  virtual void SetDefaultAttributeValues ();
1096 
1103  virtual void ParseCommandLineArguments (int argc, char **argv);
1104 
1109  virtual void ConfigureNodes ();
1110 
1115  virtual void ConfigureChannels ();
1116 
1121  virtual void ConfigureDevices ();
1122 
1127  virtual void ConfigureMobility ();
1128 
1133  virtual void ConfigureApplications ();
1134 
1139  virtual void ConfigureTracing ();
1140 
1145  virtual void RunSimulation ();
1146 
1151  virtual void ProcessOutputs ();
1152 
1153 private:
1158  void Run ();
1159 
1164  void CommandSetup (int argc, char **argv);
1165 
1171  void CheckThroughput ();
1172 
1177  void SetupLogFile ();
1178 
1183  void SetupLogging ();
1184 
1189  void ConfigureDefaults ();
1190 
1195  void SetupAdhocMobilityNodes ();
1196 
1201  void SetupAdhocDevices ();
1202 
1210  void SetupWaveMessages ();
1211 
1217  void SetupRoutingMessages ();
1218 
1223  void SetupScenario ();
1224 
1229  void WriteCsvHeader ();
1230 
1235  void SetConfigFromGlobals ();
1236 
1241  void SetGlobalsFromConfig ();
1242 
1243  static void
1244  CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobility);
1245 
1246  uint32_t m_port;
1247  std::string m_CSVfileName;
1248  std::string m_CSVfileName2;
1249  uint32_t m_nSinks;
1250  std::string m_protocolName;
1251  double m_txp;
1253  uint32_t m_protocol;
1254 
1255  uint32_t m_lossModel;
1256  uint32_t m_fading;
1257  std::string m_lossModelName;
1258 
1259  std::string m_phyMode;
1260  uint32_t m_80211mode;
1261 
1262  std::string m_traceFile;
1263  std::string m_logFile;
1264  uint32_t m_mobility;
1265  uint32_t m_nNodes;
1267  std::string m_rate;
1268  std::string m_phyModeB;
1269  std::string m_trName;
1270  int m_nodeSpeed; //in m/s
1271  int m_nodePause; //in s
1272  uint32_t m_wavePacketSize; // bytes
1273  double m_waveInterval; // seconds
1275  std::ofstream m_os;
1278  uint32_t m_scenario;
1283  int m_pcap;
1286 
1290  int m_log;
1291  // used to get consistent random numbers across scenarios
1292  int64_t m_streamIndex;
1304  std::vector <double> m_txSafetyRanges;
1305  std::string m_exp;
1307 };
1308 
1310  : m_port (9),
1311  m_CSVfileName ("vanet-routing.output.csv"),
1312  m_CSVfileName2 ("vanet-routing.output2.csv"),
1313  m_nSinks (10),
1314  m_protocolName ("protocol"),
1315  m_txp (20),
1316  m_traceMobility (false),
1317  // AODV
1318  m_protocol (2),
1319  // Two-Ray ground
1320  m_lossModel (3),
1321  m_fading (0),
1322  m_lossModelName (""),
1323  m_phyMode ("OfdmRate6MbpsBW10MHz"),
1324  // 1=802.11p
1325  m_80211mode (1),
1326  m_traceFile (""),
1327  m_logFile ("low99-ct-unterstrass-1day.filt.7.adj.log"),
1328  m_mobility (1),
1329  m_nNodes (156),
1330  m_TotalSimTime (300.01),
1331  m_rate ("2048bps"),
1332  m_phyModeB ("DsssRate11Mbps"),
1333  m_trName ("vanet-routing-compare"),
1334  m_nodeSpeed (20),
1335  m_nodePause (0),
1336  m_wavePacketSize (200),
1337  m_waveInterval (0.1),
1338  m_verbose (0),
1339  m_scenario (1),
1340  m_gpsAccuracyNs (40),
1341  m_txMaxDelayMs (10),
1342  m_routingTables (0),
1343  m_asciiTrace (0),
1344  m_pcap (0),
1345  m_loadConfigFilename ("load-config.txt"),
1346  m_saveConfigFilename (""),
1347  m_log (0),
1348  m_streamIndex (0),
1349  m_adhocTxNodes (),
1350  m_txSafetyRange1 (50.0),
1351  m_txSafetyRange2 (100.0),
1352  m_txSafetyRange3 (150.0),
1353  m_txSafetyRange4 (200.0),
1354  m_txSafetyRange5 (250.0),
1355  m_txSafetyRange6 (300.0),
1356  m_txSafetyRange7 (350.0),
1357  m_txSafetyRange8 (400.0),
1358  m_txSafetyRange9 (450.0),
1359  m_txSafetyRange10 (500.0),
1360  m_txSafetyRanges (),
1361  m_exp (""),
1362  m_cumulativeBsmCaptureStart (0)
1363 {
1364  m_wifiPhyStats = CreateObject<WifiPhyStats> ();
1365  m_routingHelper = CreateObject<RoutingHelper> ();
1366 
1367  // set to non-zero value to enable
1368  // simply uncond logging during simulation run
1369  m_log = 1;
1370 }
1371 
1372 void
1374 {
1375  // handled in constructor
1376 }
1377 
1378 // important configuration items stored in global values
1379 static ns3::GlobalValue g_port ("VRCport",
1380  "Port",
1381  ns3::UintegerValue (9),
1382  ns3::MakeUintegerChecker<uint32_t> ());
1383 static ns3::GlobalValue g_nSinks ("VRCnSinks",
1384  "Number of sink nodes for routing non-BSM traffic",
1385  ns3::UintegerValue (10),
1386  ns3::MakeUintegerChecker<uint32_t> ());
1387 static ns3::GlobalValue g_traceMobility ("VRCtraceMobility",
1388  "Trace mobility 1=yes;0=no",
1389  ns3::UintegerValue (0),
1390  ns3::MakeUintegerChecker<uint32_t> ());
1391 static ns3::GlobalValue g_protocol ("VRCprotocol",
1392  "Routing protocol",
1393  ns3::UintegerValue (2),
1394  ns3::MakeUintegerChecker<uint32_t> ());
1395 static ns3::GlobalValue g_lossModel ("VRClossModel",
1396  "Propagation Loss Model",
1397  ns3::UintegerValue (3),
1398  ns3::MakeUintegerChecker<uint32_t> ());
1399 static ns3::GlobalValue g_fading ("VRCfading",
1400  "Fast Fading Model",
1401  ns3::UintegerValue (0),
1402  ns3::MakeUintegerChecker<uint32_t> ());
1403 static ns3::GlobalValue g_80211mode ("VRC80211mode",
1404  "802.11 mode (0=802.11a;1=802.11p)",
1405  ns3::UintegerValue (1),
1406  ns3::MakeUintegerChecker<uint32_t> ());
1407 static ns3::GlobalValue g_mobility ("VRCmobility",
1408  "Mobility mode 0=random waypoint;1=mobility trace file",
1409  ns3::UintegerValue (1),
1410  ns3::MakeUintegerChecker<uint32_t> ());
1411 static ns3::GlobalValue g_nNodes ("VRCnNodes",
1412  "Number of nodes (vehicles)",
1413  ns3::UintegerValue (156),
1414  ns3::MakeUintegerChecker<uint32_t> ());
1415 static ns3::GlobalValue g_nodeSpeed ("VRCnodeSpeed",
1416  "Node speed (m/s) for RWP model",
1417  ns3::UintegerValue (20),
1418  ns3::MakeUintegerChecker<uint32_t> ());
1419 static ns3::GlobalValue g_nodePause ("VRCnodePause",
1420  "Node pause time (s) for RWP model",
1421  ns3::UintegerValue (0),
1422  ns3::MakeUintegerChecker<uint32_t> ());
1423 static ns3::GlobalValue g_wavePacketSize ("VRCwavePacketSize",
1424  "Size in bytes of WAVE BSM",
1425  ns3::UintegerValue (200),
1426  ns3::MakeUintegerChecker<uint32_t> ());
1427 static ns3::GlobalValue g_verbose ("VRCverbose",
1428  "Verbose 0=no;1=yes",
1429  ns3::UintegerValue (0),
1430  ns3::MakeUintegerChecker<uint32_t> ());
1431 static ns3::GlobalValue g_scenario ("VRCscenario",
1432  "Scenario",
1433  ns3::UintegerValue (1),
1434  ns3::MakeUintegerChecker<uint32_t> ());
1435 static ns3::GlobalValue g_routingTables ("VRCroutingTables",
1436  "Dump routing tables at t=5 seconds 0=no;1=yes",
1437  ns3::UintegerValue (0),
1438  ns3::MakeUintegerChecker<uint32_t> ());
1439 static ns3::GlobalValue g_asciiTrace ("VRCasciiTrace",
1440  "Dump ASCII trace 0=no;1=yes",
1441  ns3::UintegerValue (0),
1442  ns3::MakeUintegerChecker<uint32_t> ());
1443 static ns3::GlobalValue g_pcap ("VRCpcap",
1444  "Generate PCAP files 0=no;1=yes",
1445  ns3::UintegerValue (0),
1446  ns3::MakeUintegerChecker<uint32_t> ());
1447 static ns3::GlobalValue g_cumulativeBsmCaptureStart ("VRCcumulativeBsmCaptureStart",
1448  "Simulation starte time for capturing cumulative BSM",
1449  ns3::UintegerValue (0),
1450  ns3::MakeUintegerChecker<uint32_t> ());
1451 
1452 static ns3::GlobalValue g_txSafetyRange1 ("VRCtxSafetyRange1",
1453  "BSM range for PDR inclusion",
1454  ns3::DoubleValue (50.0),
1455  ns3::MakeDoubleChecker<double> ());
1456 
1457 static ns3::GlobalValue g_txSafetyRange2 ("VRCtxSafetyRange2",
1458  "BSM range for PDR inclusion",
1459  ns3::DoubleValue (100.0),
1460  ns3::MakeDoubleChecker<double> ());
1461 
1462 static ns3::GlobalValue g_txSafetyRange3 ("VRCtxSafetyRange3",
1463  "BSM range for PDR inclusion",
1464  ns3::DoubleValue (150.0),
1465  ns3::MakeDoubleChecker<double> ());
1466 
1467 static ns3::GlobalValue g_txSafetyRange4 ("VRCtxSafetyRange4",
1468  "BSM range for PDR inclusion",
1469  ns3::DoubleValue (200.0),
1470  ns3::MakeDoubleChecker<double> ());
1471 
1472 static ns3::GlobalValue g_txSafetyRange5 ("VRCtxSafetyRange5",
1473  "BSM range for PDR inclusion",
1474  ns3::DoubleValue (250.0),
1475  ns3::MakeDoubleChecker<double> ());
1476 static ns3::GlobalValue g_txSafetyRange6 ("VRCtxSafetyRange6",
1477  "BSM range for PDR inclusion",
1478  ns3::DoubleValue (300.0),
1479  ns3::MakeDoubleChecker<double> ());
1480 static ns3::GlobalValue g_txSafetyRange7 ("VRCtxSafetyRange7",
1481  "BSM range for PDR inclusion",
1482  ns3::DoubleValue (350.0),
1483  ns3::MakeDoubleChecker<double> ());
1484 static ns3::GlobalValue g_txSafetyRange8 ("VRCtxSafetyRange8",
1485  "BSM range for PDR inclusion",
1486  ns3::DoubleValue (400.0),
1487  ns3::MakeDoubleChecker<double> ());
1488 static ns3::GlobalValue g_txSafetyRange9 ("VRCtxSafetyRange9",
1489  "BSM range for PDR inclusion",
1490  ns3::DoubleValue (450.0),
1491  ns3::MakeDoubleChecker<double> ());
1492 static ns3::GlobalValue g_txSafetyRange10 ("VRCtxSafetyRange10",
1493  "BSM range for PDR inclusion",
1494  ns3::DoubleValue (500.0),
1495  ns3::MakeDoubleChecker<double> ());
1496 static ns3::GlobalValue g_txp ("VRCtxp",
1497  "Transmission power dBm",
1498  ns3::DoubleValue (7.5),
1499  ns3::MakeDoubleChecker<double> ());
1500 static ns3::GlobalValue g_totalTime ("VRCtotalTime",
1501  "Total simulation time (s)",
1502  ns3::DoubleValue (300.01),
1503  ns3::MakeDoubleChecker<double> ());
1504 static ns3::GlobalValue g_waveInterval ("VRCwaveInterval",
1505  "Interval (s) between WAVE BSMs",
1506  ns3::DoubleValue (0.1),
1507  ns3::MakeDoubleChecker<double> ());
1508 static ns3::GlobalValue g_gpsAccuracyNs ("VRCgpsAccuracyNs",
1509  "GPS sync accuracy (ns)",
1510  ns3::DoubleValue (40),
1511  ns3::MakeDoubleChecker<double> ());
1512 static ns3::GlobalValue g_txMaxDelayMs ("VRCtxMaxDelayMs",
1513  "Tx May Delay (ms)",
1514  ns3::DoubleValue (10),
1515  ns3::MakeDoubleChecker<double> ());
1516 static ns3::GlobalValue g_CSVfileName ("VRCCSVfileName",
1517  "CSV filename (for time series data)",
1518  ns3::StringValue ("vanet-routing.output.csv"),
1520 static ns3::GlobalValue g_CSVfileName2 ("VRCCSVfileName2",
1521  "CSV filename 2 (for overall simulation scenario results)",
1522  ns3::StringValue ("vanet-routing.output2.csv"),
1524 static ns3::GlobalValue g_phyMode ("VRCphyMode",
1525  "PHY mode (802.11p)",
1526  ns3::StringValue ("OfdmRate6MbpsBW10MHz"),
1528 static ns3::GlobalValue g_traceFile ("VRCtraceFile",
1529  "Mobility trace filename",
1530  ns3::StringValue ("./src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob"),
1532 static ns3::GlobalValue g_logFile ("VRClogFile",
1533  "Log filename",
1534  ns3::StringValue ("low99-ct-unterstrass-1day.filt.7.adj.log"),
1536 static ns3::GlobalValue g_rate ("VRCrate",
1537  "Data rate",
1538  ns3::StringValue ("2048bps"),
1540 static ns3::GlobalValue g_phyModeB ("VRCphyModeB",
1541  "PHY mode (802.11a)",
1542  ns3::StringValue ("DsssRate11Mbps"),
1544 static ns3::GlobalValue g_trName ("VRCtrName",
1545  "Trace name",
1546  ns3::StringValue ("vanet-routing-compare"),
1548 
1549 void
1551 {
1552  CommandSetup (argc, argv);
1553  SetupScenario ();
1554 
1555  // user may specify up to 10 different tx distances
1556  // to be used for calculating different values of Packet
1557  // Delivery Ratio (PDR). Used to see the effects of
1558  // fading over distance
1559  m_txSafetyRanges.resize (10, 0);
1570 
1571  ConfigureDefaults ();
1572 
1573  // we are done with all configuration
1574  // save config-store, if requested
1576  ConfigStoreHelper configStoreHelper;
1577  configStoreHelper.SaveConfig (m_saveConfigFilename);
1578 
1579  m_waveBsmHelper.GetWaveBsmStats ()->SetLogging (m_log);
1581 }
1582 
1583 void
1585 {
1587 }
1588 
1589 void
1591 {
1592  // set up channel and devices
1593  SetupAdhocDevices ();
1594 }
1595 
1596 void
1598 {
1599  // devices are set up in SetupAdhocDevices(),
1600  // called by ConfigureChannels()
1601 
1602  // every device will have PHY callback for tracing
1603  // which is used to determine the total amount of
1604  // data transmitted, and then used to calculate
1605  // the MAC/PHY overhead beyond the app-data
1606  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&WifiPhyStats::PhyTxTrace, m_wifiPhyStats));
1607  // TxDrop, RxDrop not working yet. Not sure what I'm doing wrong.
1608  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback (&WifiPhyStats::PhyTxDrop, m_wifiPhyStats));
1609  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback (&WifiPhyStats::PhyRxDrop, m_wifiPhyStats));
1610 }
1611 
1612 void
1614 {
1616 }
1617 
1618 void
1620 {
1621  // Traffic mix consists of:
1622  // 1. routing data
1623  // 2. Broadcasting of Basic Safety Message (BSM)
1625  SetupWaveMessages ();
1626 
1627  // config trace to capture app-data (bytes) for
1628  // routing data, subtracted and used for
1629  // routing overhead
1630  std::ostringstream oss;
1631  oss.str ("");
1632  oss << "/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx";
1634 }
1635 
1636 void
1638 {
1639  WriteCsvHeader ();
1640  SetupLogFile ();
1641  SetupLogging ();
1642 
1643  AsciiTraceHelper ascii;
1644  MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (m_trName + ".mob"));
1645 }
1646 
1647 void
1649 {
1650  Run ();
1651 }
1652 
1653 void
1655 {
1656  // calculate and output final results
1657  double bsm_pdr1 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (1);
1658  double bsm_pdr2 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (2);
1659  double bsm_pdr3 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (3);
1660  double bsm_pdr4 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (4);
1661  double bsm_pdr5 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (5);
1662  double bsm_pdr6 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (6);
1663  double bsm_pdr7 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (7);
1664  double bsm_pdr8 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (8);
1665  double bsm_pdr9 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (9);
1666  double bsm_pdr10 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (10);
1667 
1668  double averageRoutingGoodputKbps = 0.0;
1669  uint32_t totalBytesTotal = m_routingHelper->GetRoutingStats ().GetCumulativeRxBytes ();
1670  averageRoutingGoodputKbps = (((double) totalBytesTotal * 8.0) / m_TotalSimTime) / 1000.0;
1671 
1672  // calculate MAC/PHY overhead (mac-phy-oh)
1673  // total WAVE BSM bytes sent
1674  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1675  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1676  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1677  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1678  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1679  double mac_phy_oh = 0.0;
1680  if (totalPhyBytes > 0)
1681  {
1682  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1683  }
1684 
1685  if (m_log != 0)
1686  {
1687  NS_LOG_UNCOND ("BSM_PDR1=" << bsm_pdr1 << " BSM_PDR2=" << bsm_pdr2 << " BSM_PDR3=" << bsm_pdr3 << " BSM_PDR4=" << bsm_pdr4 << " BSM_PDR5=" << bsm_pdr5 << " BSM_PDR6=" << bsm_pdr6 << " BSM_PDR7=" << bsm_pdr7 << " BSM_PDR8=" << bsm_pdr8 << " BSM_PDR9=" << bsm_pdr9 << " BSM_PDR10=" << bsm_pdr10 << " Goodput=" << averageRoutingGoodputKbps << "Kbps MAC/PHY-oh=" << mac_phy_oh);
1688 
1689  }
1690 
1691  std::ofstream out (m_CSVfileName2.c_str (), std::ios::app);
1692 
1693  out << bsm_pdr1 << ","
1694  << bsm_pdr2 << ","
1695  << bsm_pdr3 << ","
1696  << bsm_pdr4 << ","
1697  << bsm_pdr5 << ","
1698  << bsm_pdr6 << ","
1699  << bsm_pdr7 << ","
1700  << bsm_pdr8 << ","
1701  << bsm_pdr9 << ","
1702  << bsm_pdr10 << ","
1703  << averageRoutingGoodputKbps << ","
1704  << mac_phy_oh << ""
1705  << std::endl;
1706 
1707  out.close ();
1708 
1709  m_os.close (); // close log file
1710 }
1711 
1712 void
1714 {
1715  NS_LOG_INFO ("Run Simulation.");
1716 
1717  CheckThroughput ();
1718 
1719  Simulator::Stop (Seconds (m_TotalSimTime));
1720  Simulator::Run ();
1721  Simulator::Destroy ();
1722 }
1723 
1724 // Prints actual position and velocity when a course change event occurs
1725 void
1727 CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobility)
1728 {
1729  Vector pos = mobility->GetPosition (); // Get position
1730  Vector vel = mobility->GetVelocity (); // Get velocity
1731 
1732  pos.z = 1.5;
1733 
1734  int nodeId = mobility->GetObject<Node> ()->GetId ();
1735  double t = (Simulator::Now ()).GetSeconds ();
1736  if (t >= 1.0)
1737  {
1738  WaveBsmHelper::GetNodesMoving ()[nodeId] = 1;
1739  }
1740 
1741  //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::Now () );
1742 
1743  // Prints position and velocities
1744  *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y
1745  << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
1746  << ", z=" << vel.z << std::endl;
1747 }
1748 
1749 void
1751 {
1752  uint32_t bytesTotal = m_routingHelper->GetRoutingStats ().GetRxBytes ();
1753  uint32_t packetsReceived = m_routingHelper->GetRoutingStats ().GetRxPkts ();
1754  double kbps = (bytesTotal * 8.0) / 1000;
1755  double wavePDR = 0.0;
1756  int wavePktsSent = m_waveBsmHelper.GetWaveBsmStats ()->GetTxPktCount ();
1757  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1758  if (wavePktsSent > 0)
1759  {
1760  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1761  wavePDR = (double) wavePktsReceived / (double) wavePktsSent;
1762  }
1763 
1764  int waveExpectedRxPktCount = m_waveBsmHelper.GetWaveBsmStats ()->GetExpectedRxPktCount (1);
1765  int waveRxPktInRangeCount = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktInRangeCount (1);
1766  double wavePDR1_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (1);
1767  double wavePDR2_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (2);
1768  double wavePDR3_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (3);
1769  double wavePDR4_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (4);
1770  double wavePDR5_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (5);
1771  double wavePDR6_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (6);
1772  double wavePDR7_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (7);
1773  double wavePDR8_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (8);
1774  double wavePDR9_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (9);
1775  double wavePDR10_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (10);
1776 
1777  // calculate MAC/PHY overhead (mac-phy-oh)
1778  // total WAVE BSM bytes sent
1779  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1780  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1781  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1782  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1783  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1784  double mac_phy_oh = 0.0;
1785  if (totalPhyBytes > 0)
1786  {
1787  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1788  }
1789 
1790  std::ofstream out (m_CSVfileName.c_str (), std::ios::app);
1791 
1792  if (m_log != 0 )
1793  {
1794  NS_LOG_UNCOND ("At t=" << (Simulator::Now ()).GetSeconds () << "s BSM_PDR1=" << wavePDR1_2 << " BSM_PDR1=" << wavePDR2_2 << " BSM_PDR3=" << wavePDR3_2 << " BSM_PDR4=" << wavePDR4_2 << " BSM_PDR5=" << wavePDR5_2 << " BSM_PDR6=" << wavePDR6_2 << " BSM_PDR7=" << wavePDR7_2 << " BSM_PDR8=" << wavePDR8_2 << " BSM_PDR9=" << wavePDR9_2 << " BSM_PDR10=" << wavePDR10_2 << " Goodput=" << kbps << "Kbps" /*<< " MAC/PHY-OH=" << mac_phy_oh*/);
1795  }
1796 
1797  out << (Simulator::Now ()).GetSeconds () << ","
1798  << kbps << ","
1799  << packetsReceived << ","
1800  << m_nSinks << ","
1801  << m_protocolName << ","
1802  << m_txp << ","
1803  << wavePktsSent << ","
1804  << wavePktsReceived << ","
1805  << wavePDR << ","
1806  << waveExpectedRxPktCount << ","
1807  << waveRxPktInRangeCount << ","
1808  << wavePDR1_2 << ","
1809  << wavePDR2_2 << ","
1810  << wavePDR3_2 << ","
1811  << wavePDR4_2 << ","
1812  << wavePDR5_2 << ","
1813  << wavePDR6_2 << ","
1814  << wavePDR7_2 << ","
1815  << wavePDR8_2 << ","
1816  << wavePDR9_2 << ","
1817  << wavePDR10_2 << ","
1818  << mac_phy_oh << ""
1819  << std::endl;
1820 
1821  out.close ();
1822 
1825  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktCount (0);
1826  m_waveBsmHelper.GetWaveBsmStats ()->SetTxPktCount (0);
1827  for (int index = 1; index <= 10; index++)
1828  {
1829  m_waveBsmHelper.GetWaveBsmStats ()->SetExpectedRxPktCount (index, 0);
1830  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktInRangeCount (index, 0);
1831  }
1832 
1833  double currentTime = (Simulator::Now ()).GetSeconds ();
1834  if (currentTime <= (double) m_cumulativeBsmCaptureStart)
1835  {
1836  for (int index = 1; index <= 10; index++)
1837  {
1838  m_waveBsmHelper.GetWaveBsmStats ()->ResetTotalRxPktCounts (index);
1839  }
1840  }
1841 
1842  Simulator::Schedule (Seconds (1.0), &VanetRoutingExperiment::CheckThroughput, this);
1843 }
1844 
1845 void
1847 {
1848  // get settings saved from config-store
1849  UintegerValue uintegerValue;
1850  DoubleValue doubleValue;
1851  StringValue stringValue;
1852 
1853  // This may not be the best way to manage program configuration
1854  // (directing them through global values), but management
1855  // through the config-store here is copied from
1856  // src/lte/examples/lena-dual-stripe.cc
1857 
1858  GlobalValue::GetValueByName ("VRCport", uintegerValue);
1859  m_port = uintegerValue.Get ();
1860  GlobalValue::GetValueByName ("VRCnSinks", uintegerValue);
1861  m_nSinks = uintegerValue.Get ();
1862  GlobalValue::GetValueByName ("VRCtraceMobility", uintegerValue);
1863  m_traceMobility = uintegerValue.Get ();
1864  GlobalValue::GetValueByName ("VRCprotocol", uintegerValue);
1865  m_protocol = uintegerValue.Get ();
1866  GlobalValue::GetValueByName ("VRClossModel", uintegerValue);
1867  m_lossModel = uintegerValue.Get ();
1868  GlobalValue::GetValueByName ("VRCfading", uintegerValue);
1869  m_fading = uintegerValue.Get ();
1870  GlobalValue::GetValueByName ("VRC80211mode", uintegerValue);
1871  m_80211mode = uintegerValue.Get ();
1872  GlobalValue::GetValueByName ("VRCmobility", uintegerValue);
1873  m_mobility = uintegerValue.Get ();
1874  GlobalValue::GetValueByName ("VRCnNodes", uintegerValue);
1875  m_nNodes = uintegerValue.Get ();
1876  GlobalValue::GetValueByName ("VRCnodeSpeed", uintegerValue);
1877  m_nodeSpeed = uintegerValue.Get ();
1878  GlobalValue::GetValueByName ("VRCnodePause", uintegerValue);
1879  m_nodePause = uintegerValue.Get ();
1880  GlobalValue::GetValueByName ("VRCwavePacketSize", uintegerValue);
1881  m_wavePacketSize = uintegerValue.Get ();
1882  GlobalValue::GetValueByName ("VRCverbose", uintegerValue);
1883  m_verbose = uintegerValue.Get ();
1884  GlobalValue::GetValueByName ("VRCscenario", uintegerValue);
1885  m_scenario = uintegerValue.Get ();
1886  GlobalValue::GetValueByName ("VRCroutingTables", uintegerValue);
1887  m_routingTables = uintegerValue.Get ();
1888  GlobalValue::GetValueByName ("VRCasciiTrace", uintegerValue);
1889  m_asciiTrace = uintegerValue.Get ();
1890  GlobalValue::GetValueByName ("VRCpcap", uintegerValue);
1891  m_pcap = uintegerValue.Get ();
1892  GlobalValue::GetValueByName ("VRCcumulativeBsmCaptureStart", uintegerValue);
1893  m_cumulativeBsmCaptureStart = uintegerValue.Get ();
1894 
1895  GlobalValue::GetValueByName ("VRCtxSafetyRange1", doubleValue);
1896  m_txSafetyRange1 = doubleValue.Get ();
1897  GlobalValue::GetValueByName ("VRCtxSafetyRange2", doubleValue);
1898  m_txSafetyRange2 = doubleValue.Get ();
1899  GlobalValue::GetValueByName ("VRCtxSafetyRange3", doubleValue);
1900  m_txSafetyRange3 = doubleValue.Get ();
1901  GlobalValue::GetValueByName ("VRCtxSafetyRange4", doubleValue);
1902  m_txSafetyRange4 = doubleValue.Get ();
1903  GlobalValue::GetValueByName ("VRCtxSafetyRange5", doubleValue);
1904  m_txSafetyRange5 = doubleValue.Get ();
1905  GlobalValue::GetValueByName ("VRCtxSafetyRange6", doubleValue);
1906  m_txSafetyRange6 = doubleValue.Get ();
1907  GlobalValue::GetValueByName ("VRCtxSafetyRange7", doubleValue);
1908  m_txSafetyRange7 = doubleValue.Get ();
1909  GlobalValue::GetValueByName ("VRCtxSafetyRange8", doubleValue);
1910  m_txSafetyRange8 = doubleValue.Get ();
1911  GlobalValue::GetValueByName ("VRCtxSafetyRange9", doubleValue);
1912  m_txSafetyRange9 = doubleValue.Get ();
1913  GlobalValue::GetValueByName ("VRCtxSafetyRange10", doubleValue);
1914  m_txSafetyRange10 = doubleValue.Get ();
1915  GlobalValue::GetValueByName ("VRCtxp", doubleValue);
1916  m_txp = doubleValue.Get ();
1917  GlobalValue::GetValueByName ("VRCtotalTime", doubleValue);
1918  m_TotalSimTime = doubleValue.Get ();
1919  GlobalValue::GetValueByName ("VRCwaveInterval", doubleValue);
1920  m_waveInterval = doubleValue.Get ();
1921  GlobalValue::GetValueByName ("VRCgpsAccuracyNs", doubleValue);
1922  m_gpsAccuracyNs = doubleValue.Get ();
1923  GlobalValue::GetValueByName ("VRCtxMaxDelayMs", doubleValue);
1924  m_txMaxDelayMs = doubleValue.Get ();
1925 
1926  GlobalValue::GetValueByName ("VRCCSVfileName", stringValue);
1927  m_CSVfileName = stringValue.Get ();
1928  GlobalValue::GetValueByName ("VRCCSVfileName2", stringValue);
1929  m_CSVfileName2 = stringValue.Get ();
1930  GlobalValue::GetValueByName ("VRCphyMode", stringValue);
1931  m_phyMode = stringValue.Get ();
1932  GlobalValue::GetValueByName ("VRCtraceFile", stringValue);
1933  m_traceFile = stringValue.Get ();
1934  GlobalValue::GetValueByName ("VRClogFile", stringValue);
1935  m_logFile = stringValue.Get ();
1936  GlobalValue::GetValueByName ("VRCrate", stringValue);
1937  m_rate = stringValue.Get ();
1938  GlobalValue::GetValueByName ("VRCphyModeB", stringValue);
1939  m_phyModeB = stringValue.Get ();
1940  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1941  m_trName = stringValue.Get ();
1942 }
1943 
1944 void
1946 {
1947  // get settings saved from config-store
1948  UintegerValue uintegerValue;
1949  DoubleValue doubleValue;
1950  StringValue stringValue;
1951 
1970 
1986 
1995  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1996  m_trName = stringValue.Get ();
1997 }
1998 
1999 void
2001 {
2002  CommandLine cmd;
2003  double txDist1 = 50.0;
2004  double txDist2 = 100.0;
2005  double txDist3 = 150.0;
2006  double txDist4 = 200.0;
2007  double txDist5 = 250.0;
2008  double txDist6 = 300.0;
2009  double txDist7 = 350.0;
2010  double txDist8 = 350.0;
2011  double txDist9 = 350.0;
2012  double txDist10 = 350.0;
2013 
2014  // allow command line overrides
2015  cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName);
2016  cmd.AddValue ("CSVfileName2", "The name of the CSV output file name2", m_CSVfileName2);
2017  cmd.AddValue ("totaltime", "Simulation end time", m_TotalSimTime);
2018  cmd.AddValue ("nodes", "Number of nodes (i.e. vehicles)", m_nNodes);
2019  cmd.AddValue ("sinks", "Number of routing sinks", m_nSinks);
2020  cmd.AddValue ("txp", "Transmit power (dB), e.g. txp=7.5", m_txp);
2021  cmd.AddValue ("traceMobility", "Enable mobility tracing", m_traceMobility);
2022  cmd.AddValue ("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol);
2023  cmd.AddValue ("lossModel", "1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance", m_lossModel);
2024  cmd.AddValue ("fading", "0=None;1=Nakagami;(buildings=1 overrides)", m_fading);
2025  cmd.AddValue ("phyMode", "Wifi Phy mode", m_phyMode);
2026  cmd.AddValue ("80211Mode", "1=802.11p; 2=802.11b; 3=WAVE-PHY", m_80211mode);
2027  cmd.AddValue ("traceFile", "Ns2 movement trace file", m_traceFile);
2028  cmd.AddValue ("logFile", "Log file", m_logFile);
2029  cmd.AddValue ("mobility", "1=trace;2=RWP", m_mobility);
2030  cmd.AddValue ("rate", "Rate", m_rate);
2031  cmd.AddValue ("phyModeB", "Phy mode 802.11b", m_phyModeB);
2032  cmd.AddValue ("speed", "Node speed (m/s)", m_nodeSpeed);
2033  cmd.AddValue ("pause", "Node pause (s)", m_nodePause);
2034  cmd.AddValue ("verbose", "0=quiet;1=verbose", m_verbose);
2035  cmd.AddValue ("bsm", "(WAVE) BSM size (bytes)", m_wavePacketSize);
2036  cmd.AddValue ("interval", "(WAVE) BSM interval (s)", m_waveInterval);
2037  cmd.AddValue ("scenario", "1=synthetic, 2=playback-trace", m_scenario);
2038  // User is allowed to have up to 10 different PDRs (Packet
2039  // Delivery Ratios) calculate, and so can specify up to
2040  // 10 different tx distances.
2041  cmd.AddValue ("txdist1", "Expected BSM tx range, m", txDist1);
2042  cmd.AddValue ("txdist2", "Expected BSM tx range, m", txDist2);
2043  cmd.AddValue ("txdist3", "Expected BSM tx range, m", txDist3);
2044  cmd.AddValue ("txdist4", "Expected BSM tx range, m", txDist4);
2045  cmd.AddValue ("txdist5", "Expected BSM tx range, m", txDist5);
2046  cmd.AddValue ("txdist6", "Expected BSM tx range, m", txDist6);
2047  cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7);
2048  cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8);
2049  cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9);
2050  cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10);
2051  cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs);
2052  cmd.AddValue ("txmaxdelay", "Tx max delay, in ms", m_txMaxDelayMs);
2053  cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routingTables);
2054  cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace);
2055  cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap);
2056  cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilename);
2057  cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilename);
2058  cmd.AddValue ("exp", "Experiment", m_exp);
2059  cmd.AddValue ("BsmCaptureStart", "Start time to begin capturing pkts for cumulative Bsm", m_cumulativeBsmCaptureStart);
2060  cmd.Parse (argc, argv);
2061 
2062  m_txSafetyRange1 = txDist1;
2063  m_txSafetyRange2 = txDist2;
2064  m_txSafetyRange3 = txDist3;
2065  m_txSafetyRange4 = txDist4;
2066  m_txSafetyRange5 = txDist5;
2067  m_txSafetyRange6 = txDist6;
2068  m_txSafetyRange7 = txDist7;
2069  m_txSafetyRange8 = txDist8;
2070  m_txSafetyRange9 = txDist9;
2071  m_txSafetyRange10 = txDist10;
2072  // load configuration info from config-store
2073  ConfigStoreHelper configStoreHelper;
2074  configStoreHelper.LoadConfig (m_loadConfigFilename);
2075  // transfer config-store values to config parameters
2077 
2078  // parse again so you can override input file default values via command line
2079  cmd.Parse (argc, argv);
2080 
2081  m_txSafetyRange1 = txDist1;
2082  m_txSafetyRange2 = txDist2;
2083  m_txSafetyRange3 = txDist3;
2084  m_txSafetyRange4 = txDist4;
2085  m_txSafetyRange5 = txDist5;
2086  m_txSafetyRange6 = txDist6;
2087  m_txSafetyRange7 = txDist7;
2088  m_txSafetyRange8 = txDist8;
2089  m_txSafetyRange9 = txDist9;
2090  m_txSafetyRange10 = txDist10;
2091 }
2092 
2093 void
2095 {
2096  // open log file for output
2097  m_os.open (m_logFile.c_str ());
2098 }
2099 
2101 {
2102 
2103  // Enable logging from the ns2 helper
2104  LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
2105 
2106  Packet::EnablePrinting ();
2107 }
2108 
2109 void
2111 {
2112  Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64"));
2113  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (m_rate));
2114 
2115  //Set Non-unicastMode rate to unicast mode
2116  if (m_80211mode == 2)
2117  {
2118  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyModeB));
2119  }
2120  else
2121  {
2122  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyMode));
2123  }
2124 }
2125 
2126 void
2128 {
2129  if (m_mobility == 1)
2130  {
2131  // Create Ns2MobilityHelper with the specified trace log file as parameter
2133  ns2.Install (); // configure movements for each node, while reading trace file
2134  // initially assume all nodes are not moving
2135  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 0);
2136  }
2137  else if (m_mobility == 2)
2138  {
2139  MobilityHelper mobilityAdhoc;
2140 
2141  ObjectFactory pos;
2142  pos.SetTypeId ("ns3::RandomBoxPositionAllocator");
2143  pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
2144  pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
2145  // we need antenna height uniform [1.0 .. 2.0] for loss model
2146  pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"));
2147 
2148  Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
2149  m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex);
2150 
2151  std::stringstream ssSpeed;
2152  ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]";
2153  std::stringstream ssPause;
2154  ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]";
2155  mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
2156  "Speed", StringValue (ssSpeed.str ()),
2157  "Pause", StringValue (ssPause.str ()),
2158  "PositionAllocator", PointerValue (taPositionAlloc));
2159  mobilityAdhoc.SetPositionAllocator (taPositionAlloc);
2160  mobilityAdhoc.Install (m_adhocTxNodes);
2161  m_streamIndex += mobilityAdhoc.AssignStreams (m_adhocTxNodes, m_streamIndex);
2162 
2163  // initially assume all nodes are moving
2164  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 1);
2165  }
2166 
2167  // Configure callback for logging
2168  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2170 }
2171 
2172 void
2174 {
2175  if (m_lossModel == 1)
2176  {
2177  m_lossModelName = "ns3::FriisPropagationLossModel";
2178  }
2179  else if (m_lossModel == 2)
2180  {
2181  m_lossModelName = "ns3::ItuR1411LosPropagationLossModel";
2182  }
2183  else if (m_lossModel == 3)
2184  {
2185  m_lossModelName = "ns3::TwoRayGroundPropagationLossModel";
2186  }
2187  else if (m_lossModel == 4)
2188  {
2189  m_lossModelName = "ns3::LogDistancePropagationLossModel";
2190  }
2191  else
2192  {
2193  // Unsupported propagation loss model.
2194  // Treating as ERROR
2195  NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance");
2196  }
2197 
2198  // frequency
2199  double freq = 0.0;
2200  if ((m_80211mode == 1)
2201  || (m_80211mode == 3))
2202  {
2203  // 802.11p 5.9 GHz
2204  freq = 5.9e9;
2205  }
2206  else
2207  {
2208  // 802.11b 2.4 GHz
2209  freq = 2.4e9;
2210  }
2211 
2212  // Setup propagation models
2213  YansWifiChannelHelper wifiChannel;
2214  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
2215  if (m_lossModel == 3)
2216  {
2217  // two-ray requires antenna height (else defaults to Friss)
2218  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq), "HeightAboveZ", DoubleValue (1.5));
2219  }
2220  else
2221  {
2222  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq));
2223  }
2224 
2225  // Propagation loss models are additive.
2226  if (m_fading != 0)
2227  {
2228  // if no obstacle model, then use Nakagami fading if requested
2229  wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
2230  }
2231 
2232  // the channel
2233  Ptr<YansWifiChannel> channel = wifiChannel.Create ();
2234 
2235  // The below set of helpers will help us to put together the wifi NICs we want
2236  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
2237  wifiPhy.SetChannel (channel);
2238  // ns-3 supports generate a pcap trace
2239  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2240 
2241  YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
2242  wavePhy.SetChannel (channel);
2243  wavePhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2244 
2245  // Setup WAVE PHY and MAC
2246  NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
2247  WaveHelper waveHelper = WaveHelper::Default ();
2248  Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
2249  if (m_verbose)
2250  {
2251  wifi80211p.EnableLogComponents (); // Turn on all Wifi 802.11p logging
2252  // likewise, turn on WAVE PHY logging
2253  waveHelper.EnableLogComponents ();
2254  }
2255 
2256  WifiHelper wifi;
2257 
2258  // Setup 802.11b stuff
2260 
2261  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2262  "DataMode",StringValue (m_phyModeB),
2263  "ControlMode",StringValue (m_phyModeB));
2264 
2265  // Setup 802.11p stuff
2266  wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2267  "DataMode",StringValue (m_phyMode),
2268  "ControlMode",StringValue (m_phyMode));
2269 
2270  // Setup WAVE-PHY stuff
2271  waveHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2272  "DataMode",StringValue (m_phyMode),
2273  "ControlMode",StringValue (m_phyMode));
2274 
2275  // Set Tx Power
2276  wifiPhy.Set ("TxPowerStart",DoubleValue (m_txp));
2277  wifiPhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2278  wavePhy.Set ("TxPowerStart",DoubleValue (m_txp));
2279  wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2280 
2281  // Add an upper mac and disable rate control
2282  WifiMacHelper wifiMac;
2283  wifiMac.SetType ("ns3::AdhocWifiMac");
2284  QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
2285 
2286  // Setup net devices
2287 
2288  if (m_80211mode == 3)
2289  {
2290  m_adhocTxDevices = waveHelper.Install (wavePhy, waveMac, m_adhocTxNodes);
2291  }
2292  else if (m_80211mode == 1)
2293  {
2294  m_adhocTxDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, m_adhocTxNodes);
2295  }
2296  else
2297  {
2298  m_adhocTxDevices = wifi.Install (wifiPhy, wifiMac, m_adhocTxNodes);
2299  }
2300 
2301  if (m_asciiTrace != 0)
2302  {
2303  AsciiTraceHelper ascii;
2304  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (m_trName + ".tr").c_str ());
2305  wifiPhy.EnableAsciiAll (osw);
2306  wavePhy.EnableAsciiAll (osw);
2307  }
2308  if (m_pcap != 0)
2309  {
2310  wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap");
2311  wavePhy.EnablePcapAll ("vanet-routing-compare-pcap");
2312  }
2313 }
2314 
2315 void
2317 {
2318  // WAVE PHY mode
2319  // 0=continuous channel; 1=channel-switching
2320  int chAccessMode = 0;
2321  if (m_80211mode == 3)
2322  {
2323  chAccessMode = 1;
2324  }
2325 
2330  // GPS accuracy (i.e, clock drift), in number of ns
2333  chAccessMode,
2334  // tx max delay before transmit, in ms
2336 
2337  // fix random number streams
2339 }
2340 
2341 void
2343 {
2348  m_protocol,
2349  m_nSinks,
2350  m_routingTables);
2351 }
2352 
2353 void
2355 {
2356  // member variable parameter use
2357  // defaults or command line overrides,
2358  // except where scenario={1,2,3,...}
2359  // have been specified, in which case
2360  // specify parameters are overwritten
2361  // here to setup for specific scenarios
2362 
2363  // certain parameters may be further overridden
2364  // i.e. specify a scenario, override tx power.
2365 
2366  if (m_scenario == 1)
2367  {
2368  // 40 nodes in RWP 300 m x 1500 m synthetic highway, 10s
2369  m_traceFile = "";
2370  m_logFile = "";
2371  m_mobility = 2;
2372  if (m_nNodes == 156)
2373  {
2374  m_nNodes = 40;
2375  }
2376  if (m_TotalSimTime == 300.01)
2377  {
2378  m_TotalSimTime = 10.0;
2379  }
2380  }
2381  else if (m_scenario == 2)
2382  {
2383  // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
2384  // "low density, 99 total vehicles"
2385  m_traceFile = "src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob";
2386  m_logFile = "low99-ct-unterstrass-1day.filt.7.adj.log";
2387  m_mobility = 1;
2388  m_nNodes = 99;
2389  m_TotalSimTime = 300.01;
2390  m_nodeSpeed = 0;
2391  m_nodePause = 0;
2392  m_CSVfileName = "low_vanet-routing-compare.csv";
2393  m_CSVfileName = "low_vanet-routing-compare2.csv";
2394  }
2395 }
2396 
2397 void
2399 {
2400  //blank out the last output file and write the column headers
2401  std::ofstream out (m_CSVfileName.c_str ());
2402  out << "SimulationSecond," <<
2403  "ReceiveRate," <<
2404  "PacketsReceived," <<
2405  "NumberOfSinks," <<
2406  "RoutingProtocol," <<
2407  "TransmissionPower," <<
2408  "WavePktsSent," <<
2409  "WavePtksReceived," <<
2410  "WavePktsPpr," <<
2411  "ExpectedWavePktsReceived," <<
2412  "ExpectedWavePktsInCoverageReceived," <<
2413  "BSM_PDR1," <<
2414  "BSM_PDR2," <<
2415  "BSM_PDR3," <<
2416  "BSM_PDR4," <<
2417  "BSM_PDR5," <<
2418  "BSM_PDR6," <<
2419  "BSM_PDR7," <<
2420  "BSM_PDR8," <<
2421  "BSM_PDR9," <<
2422  "BSM_PDR10," <<
2423  "MacPhyOverhead" <<
2424  std::endl;
2425  out.close ();
2426 
2427  std::ofstream out2 (m_CSVfileName2.c_str ());
2428  out2 << "BSM_PDR1,"
2429  << "BSM_PDR2,"
2430  << "BSM_PDR3,"
2431  << "BSM_PDR4,"
2432  << "BSM_PDR5,"
2433  << "BSM_PDR6,"
2434  << "BSM_PDR7,"
2435  << "BSM_PDR8,"
2436  << "BSM_PDR9,"
2437  << "BSM_PDR10,"
2438  << "AverageRoutingGoodputKbps,"
2439  << "MacPhyOverhead"
2440  << std::endl;
2441  out2.close ();
2442 }
2443 
2444 int
2445 main (int argc, char *argv[])
2446 {
2448  experiment.Simulate (argc, argv);
2449 }
static ns3::GlobalValue g_gpsAccuracyNs("VRCgpsAccuracyNs","GPS sync accuracy (ns)", ns3::DoubleValue(40), ns3::MakeDoubleChecker< double >())
void AddPropagationLoss(std::string name, 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())
static ns3::GlobalValue g_asciiTrace("VRCasciiTrace","Dump ASCII trace 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:47
tuple channel
Definition: third.py:85
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:112
Ptr< const AttributeChecker > MakeStringChecker(void)
Definition: string.cc:30
holds a vector of ns3::Application pointers.
Introspection did not find any typical Config paths.
Definition: config-store.h:54
static void EnableLogComponents(void)
Helper to enable all WaveNetDevice log components with one statement.
Definition: wave-helper.cc:395
helps to create wifi 802.11p objects of WifiNetDevice class
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
The RoutingStats class manages collects statistics on routing data (application-data packet and byte ...
RoutingHelper()
Constructor.
WifiApp()
Constructor.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Manage ASCII trace files for device models.
Definition: trace-helper.h:161
an Inet address class
Ipv4Address GetIpv4(void) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
std::string Get(void) const
Definition: string.cc:31
static ns3::GlobalValue g_rate("VRCrate","Data rate", ns3::StringValue("2048bps"), ns3::MakeStringChecker())
void WriteCsvHeader()
Write the header line to the CSV file1.
static ns3::GlobalValue g_80211mode("VRC80211mode","802.11 mode (0=802.11a;1=802.11p)", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_nSinks("VRCnSinks","Number of sink nodes for routing non-BSM traffic", ns3::UintegerValue(10), ns3::MakeUintegerChecker< uint32_t >())
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
holds a vector of std::pair of Ptr and interface index.
void SetupRoutingMessages()
Set up generation of packets to be routed through the vehicular network.
Ptr< YansWifiChannel > Create(void) const
static ns3::GlobalValue g_pcap("VRCpcap","Generate PCAP files 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
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
virtual void ConfigureNodes()
Configure nodes.
virtual void ConfigureNodes()
Configure nodes.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:462
Hold variables of type string.
Definition: string.h:41
void SetLogging(int log)
Enable/disable logging.
Make it easy to create and manage PHY objects for the yans model.
static ns3::GlobalValue g_txSafetyRange9("VRCtxSafetyRange9","BSM range for PDR inclusion", ns3::DoubleValue(450.0), ns3::MakeDoubleChecker< double >())
The WifiPhyStats class collects Wifi MAC/PHY statistics.
virtual void ParseCommandLineArguments(int argc, char **argv)
Process command line arguments.
static ns3::GlobalValue g_txSafetyRange3("VRCtxSafetyRange3","BSM range for PDR inclusion", ns3::DoubleValue(150.0), ns3::MakeDoubleChecker< double >())
static std::string PrintReceivedRoutingPacket(Ptr< Socket > socket, Ptr< Packet > packet, Address srcAddress)
void SetRxBytes(uint32_t rxBytes)
Sets the number of bytes received.
uint32_t GetCumulativeTxPkts()
Returns the cumulative number of packets transmitted.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1686
void PhyTxDrop(std::string context, Ptr< const Packet > packet)
Callback signiture for Phy/TxDrop.
static ns3::GlobalValue g_cumulativeBsmCaptureStart("VRCcumulativeBsmCaptureStart","Simulation starte time for capturing cumulative BSM", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
Helper class that adds DSR routing to nodes.
void SetupWaveMessages()
Set up generation of IEEE 1609 WAVE messages, as a Basic Safety Message (BSM).
uint32_t GetCumulativeRxBytes()
Returns the cumulative number of bytes received.
static ns3::GlobalValue g_port("VRCport","Port", ns3::UintegerValue(9), ns3::MakeUintegerChecker< uint32_t >())
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
virtual ~WifiPhyStats()
Destructor.
void IncRxPkts()
Increments the count of packets received.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
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
Ipv4InterfaceContainer m_adhocTxInterfaces
virtual void ParseCommandLineArguments(int argc, char **argv)
Process command line arguments.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:719
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. ...
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the mobility models (inc...
static ns3::GlobalValue g_txSafetyRange10("VRCtxSafetyRange10","BSM range for PDR inclusion", ns3::DoubleValue(500.0), ns3::MakeDoubleChecker< double >())
void IncTxBytes(uint32_t txBytes)
Increment the number of bytes transmitted.
Hold a so-called 'global value'.
Definition: global-value.h:70
static ns3::GlobalValue g_wavePacketSize("VRCwavePacketSize","Size in bytes of WAVE BSM", ns3::UintegerValue(200), ns3::MakeUintegerChecker< uint32_t >())
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wave-helper.cc:330
void CommandSetup(int argc, char **argv)
Run the simulation.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:231
virtual void RunSimulation()
Run the simulation.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
virtual void ConfigureChannels()
Configure channels.
Vector GetVelocity(void) const
tuple cmd
Definition: second.py:35
void ReceiveRoutingPacket(Ptr< Socket > socket)
Process a received routing packet.
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:530
NetDeviceContainer m_adhocTxDevices
void SetGlobalsFromConfig()
Set up the global variables from the configuration parameters.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:712
a polymophic address class
Definition: address.h:90
static ns3::GlobalValue g_totalTime("VRCtotalTime","Total simulation time (s)", ns3::DoubleValue(300.01), ns3::MakeDoubleChecker< double >())
ConfigStoreHelper()
Constructor.
static TypeId GetTypeId(void)
Gets the class TypeId.
static ns3::GlobalValue g_txMaxDelayMs("VRCtxMaxDelayMs","Tx May Delay (ms)", ns3::DoubleValue(10), ns3::MakeDoubleChecker< double >())
virtual void ProcessOutputs()
Process outputs.
static ns3::GlobalValue g_txSafetyRange6("VRCtxSafetyRange6","BSM range for PDR inclusion", ns3::DoubleValue(300.0), ns3::MakeDoubleChecker< double >())
static ns3::GlobalValue g_mobility("VRCmobility","Mobility mode 0=random waypoint;1=mobility trace file", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
uint64_t Get(void) const
Definition: uinteger.cc:35
void SetRxPkts(uint32_t rxPkts)
Sets the number of packets received.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
void SetChannel(Ptr< YansWifiChannel > channel)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
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: wave-helper.cc:284
void SetTxPkts(uint32_t txPkts)
Sets the number of packets transmitted.
void Install(void) const
Read the ns2 trace file and configure the movement patterns of all nodes contained in the global ns3:...
void SetupRoutingMessages(NodeContainer &c, Ipv4InterfaceContainer &adhocTxInterfaces)
Sets up routing messages on the nodes and their interfaces.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
virtual void ProcessOutputs()
Process outputs.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
tuple mobility
Definition: third.py:101
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 ...
Helper class which can read ns-2 movement files and configure nodes mobility.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
static ns3::GlobalValue g_trName("VRCtrName","Trace name", ns3::StringValue("vanet-routing-compare"), ns3::MakeStringChecker())
uint32_t GetCumulativeRxPkts()
Returns the cumulative count of packets received.
void LoadConfig(std::string configFilename)
Loads a saved config-store raw text configuration from a given named file.
Hold an unsigned integer type.
Definition: uinteger.h:44
helps to create WaveNetDevice objects
Definition: wave-helper.h:110
holds a vector of ns3::NetDevice pointers
static ns3::GlobalValue g_txSafetyRange1("VRCtxSafetyRange1","BSM range for PDR inclusion", ns3::DoubleValue(50.0), ns3::MakeDoubleChecker< double >())
virtual void RunSimulation()
Run the simulation.
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:706
void SetupAdhocDevices()
Set up the adhoc devices.
static ns3::GlobalValue g_verbose("VRCverbose","Verbose 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
void ConfigureDefaults()
Configure default attributes.
static ns3::GlobalValue g_traceMobility("VRCtraceMobility","Trace mobility 1=yes;0=no", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_routingTables("VRCroutingTables","Dump routing tables at t=5 seconds 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
virtual void SetDefaultAttributeValues()
Sets default attribute values.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
virtual void ConfigureApplications()
Configure applications.
static ns3::GlobalValue g_waveInterval("VRCwaveInterval","Interval (s) between WAVE BSMs", ns3::DoubleValue(0.1), ns3::MakeDoubleChecker< double >())
static ns3::GlobalValue g_scenario("VRCscenario","Scenario", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
The WaveBsmHelper class manages IEEE 1609 WAVE (Wireless Access in Vehicular Environments) Basic Safe...
RoutingStats()
Constructor.
static ns3::GlobalValue g_nNodes("VRCnNodes","Number of nodes (vehicles)", ns3::UintegerValue(156), ns3::MakeUintegerChecker< uint32_t >())
void Run()
Run the simulation.
void SetupLogging()
Set up logging.
std::string m_protocolName
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
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:835
double Get(void) const
Definition: double.cc:35
#define list
void SetupLogFile()
Set up log file.
void ConfigureDefaults(void)
LOG_DEBUG and above.
Definition: log.h:100
WifiPhyStats()
Constructor.
static ns3::GlobalValue g_phyMode("VRCphyMode","PHY mode (802.11p)", ns3::StringValue("OfdmRate6MbpsBW10MHz"), ns3::MakeStringChecker())
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &macHelper, NodeContainer c) const
virtual void ConfigureChannels()
Configure channels.
static TypeId GetTypeId(void)
Get class TypeId.
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.
keep track of a set of node pointers.
Hold objects of type Ptr.
Definition: pointer.h:36
virtual ~RoutingHelper()
Destructor.
void SetupRoutingProtocol(NodeContainer &c)
Sets up the protocol protocol on the nodes.
virtual void ConfigureMobility()
Configure mobility.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
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())
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream)
prints the routing tables of all nodes at a particular time.
The VanetRoutingExperiment class implements a wifi app that allows VANET routing experiments to be si...
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void IncRxBytes(uint32_t rxBytes)
Increments the number of (application-data) bytes received, not including MAC/PHY overhead...
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
uint32_t GetRxPkts()
Returns the count of packets received.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
bool SetValue(const AttributeValue &value)
Set the value of this GlobalValue.
Ptr< Socket > SetupRoutingPacketReceive(Ipv4Address addr, Ptr< Node > node)
Sets up a routing packet for tranmission.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
void SetTxBytes(uint32_t txBytes)
Sets the number of bytes transmitted.
manage and create wifi channel objects for the yans model.
void OnOffTrace(std::string context, Ptr< const Packet > packet)
Trace the receipt of an on-off-application generated packet.
virtual void ConfigureDevices()
Configure devices.
create MAC layers for a ns3::WifiNetDevice.
Definition: olsr.py:1
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
Definition: wave-helper.h:39
RoutingStats routingStats
virtual void ConfigureApplications()
Configure applications.
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
The ConfigStoreHelper class simplifies config-store raw text load and save.
void IncTxPkts()
Increment the count of packets transmitted.
void AssignIpAddresses(NetDeviceContainer &d, Ipv4InterfaceContainer &adhocTxInterfaces)
Assigns IPv4 addresses to net devices and their interfaces.
std::vector< double > m_txSafetyRanges
void PhyRxDrop(std::string context, Ptr< const Packet > packet)
Callback signiture for Phy/RxDrop.
static void CourseChange(std::ostream *os, std::string foo, Ptr< const MobilityModel > mobility)
void SetupScenario()
Set up a prescribed scenario.
static ns3::GlobalValue g_txSafetyRange7("VRCtxSafetyRange7","BSM range for PDR inclusion", ns3::DoubleValue(350.0), ns3::MakeDoubleChecker< double >())
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())
uint32_t GetTxPkts()
Returns the number of packets transmitted.
Helper class used to assign positions and mobility models to nodes.
static ns3::GlobalValue g_CSVfileName("VRCCSVfileName","CSV filename (for time series data)", ns3::StringValue("vanet-routing.output.csv"), ns3::MakeStringChecker())
Instantiate subclasses of ns3::Object.
uint32_t GetTxBytes()
Returns the number of bytes transmitted.
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...
virtual void ConfigureMobility()
Configure mobility.
uint32_t GetId(void) const
Definition: node.cc:107
static ns3::GlobalValue g_logFile("VRClogFile","Log filename", ns3::StringValue("low99-ct-unterstrass-1day.filt.7.adj.log"), ns3::MakeStringChecker())
virtual void SetDefaultAttributeValues()
Sets default attribute values.
RoutingStats & GetRoutingStats()
Returns the RoutingStats instance.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
static ns3::GlobalValue g_protocol("VRCprotocol","Routing protocol", ns3::UintegerValue(2), ns3::MakeUintegerChecker< uint32_t >())
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Definition: command-line.h:495
void Simulate(int argc, char **argv)
Enacts simulation of an ns-3 wifi application.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
static ns3::GlobalValue g_txp("VRCtxp","Transmission power dBm", ns3::DoubleValue(7.5), ns3::MakeDoubleChecker< double >())
void CheckThroughput()
Checks the throughput and outputs summary to CSV file1.
ApplicationContainer Install(Ipv4InterfaceContainer i) const
Install an ns3::BsmApplication on each node of the input container configured with all the attributes...
A network Node.
Definition: node.h:56
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:774
static ns3::GlobalValue g_txSafetyRange2("VRCtxSafetyRange2","BSM range for PDR inclusion", ns3::DoubleValue(100.0), ns3::MakeDoubleChecker< double >())
Ptr< WaveBsmStats > GetWaveBsmStats()
Returns the WaveBsmStats instance.
static ns3::GlobalValue g_txSafetyRange5("VRCtxSafetyRange5","BSM range for PDR inclusion", ns3::DoubleValue(250.0), ns3::MakeDoubleChecker< double >())
static ns3::GlobalValue g_fading("VRCfading","Fast Fading Model", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_nodeSpeed("VRCnodeSpeed","Node speed (m/s) for RWP model", ns3::UintegerValue(20), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_traceFile("VRCtraceFile","Mobility trace filename", ns3::StringValue("./src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob"), ns3::MakeStringChecker())
virtual void ConfigureTracing()
Configure tracing.
static ns3::GlobalValue g_phyModeB("VRCphyModeB","PHY mode (802.11a)", ns3::StringValue("DsssRate11Mbps"), ns3::MakeStringChecker())
Ptr< WifiPhyStats > m_wifiPhyStats
Helper class that adds ns3::Ipv4ListRouting objects.
static ns3::GlobalValue g_txSafetyRange8("VRCtxSafetyRange8","BSM range for PDR inclusion", ns3::DoubleValue(400.0), ns3::MakeDoubleChecker< double >())
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.
virtual void ConfigureTracing()
Configure tracing.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:340
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:220
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.
void Install(NodeContainer &c, NetDeviceContainer &d, Ipv4InterfaceContainer &i, double totalTime, int protocol, uint32_t nSinks, int routingTables)
Installs routing funcationality on nodes and their devices and interfaces.
virtual void ConfigureDevices()
Configure devices.
uint32_t GetRxBytes()
Returns the number of bytes received.
Helper class that adds AODV routing to nodes.
Definition: aodv-helper.h:35
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
void SetPropagationDelay(std::string name, 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())
uint32_t GetTxBytes()
Returns the number of bytes that have been transmitted (this includes MAC/PHY overhead) ...
void PhyTxTrace(std::string context, Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
Callback signiture for Phy/Tx trace.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
static ns3::GlobalValue g_CSVfileName2("VRCCSVfileName2","CSV filename 2 (for overall simulation scenario results)", ns3::StringValue("vanet-routing.output2.csv"), ns3::MakeStringChecker())
The WifiApp class enforces program flow for ns-3 wifi applications.
uint32_t GetCumulativeTxBytes()
Returns the cumulative number of bytes transmitted.
static ns3::GlobalValue g_lossModel("VRClossModel","Propagation Loss Model", ns3::UintegerValue(3), ns3::MakeUintegerChecker< uint32_t >())
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
The RoutingHelper class generates routing data between nodes (vehicles) and uses the RoutingStats cla...
void SaveConfig(std::string configFilename)
Saves a configuration to a given named config-store raw text configuration file.
Helper class that adds DSDV routing to nodes.
Definition: dsdv-helper.h:45
void Install(DsrHelper &dsrHelper, NodeContainer nodes)
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetupAdhocMobilityNodes()
Set up the adhoc mobility nodes.
virtual ~WifiApp()
Destructor.
a unique identifier for an interface.
Definition: type-id.h:58
static ns3::GlobalValue g_txSafetyRange4("VRCtxSafetyRange4","BSM range for PDR inclusion", ns3::DoubleValue(200.0), ns3::MakeDoubleChecker< double >())
Ptr< RoutingHelper > m_routingHelper
void SetConfigFromGlobals()
Set up configuration parameter from the global variables.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
static ns3::GlobalValue g_nodePause("VRCnodePause","Node pause time (s) for RWP model", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
uint32_t m_nNodes
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Allocate a set of positions.
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model...