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  SocketAddressTag tag;
668  bool found;
669  found = packet->PeekPacketTag (tag);
670  std::ostringstream oss;
671 
672  oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
673 
674  if (found)
675  {
676  InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ());
677  oss << " received one packet from " << addr.GetIpv4 ();
678  }
679  else
680  {
681  oss << " received one packet!";
682  }
683  return oss.str ();
684 }
685 
686 void
688 {
689  Ptr<Packet> packet;
690  while ((packet = socket->Recv ()))
691  {
692  // application data, for goodput
693  uint32_t RxRoutingBytes = packet->GetSize ();
694  GetRoutingStats ().IncRxBytes (RxRoutingBytes);
696  if (m_log != 0)
697  {
698  NS_LOG_UNCOND (m_protocolName + " " + PrintReceivedRoutingPacket (socket, packet));
699  }
700  }
701 }
702 
703 void
704 RoutingHelper::OnOffTrace (std::string context, Ptr<const Packet> packet)
705 {
706  uint32_t pktBytes = packet->GetSize ();
707  routingStats.IncTxBytes (pktBytes);
708 }
709 
710 RoutingStats &
712 {
713  return routingStats;
714 }
715 
716 void
718 {
719  m_log = log;
720 }
721 
726 class WifiPhyStats : public Object
727 {
728 public:
733  static TypeId GetTypeId (void);
734 
739  WifiPhyStats ();
740 
745  virtual ~WifiPhyStats ();
746 
752  uint32_t GetTxBytes ();
753 
763  void PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower);
764 
771  void PhyTxDrop (std::string context, Ptr<const Packet> packet);
772 
779  void PhyRxDrop (std::string context, Ptr<const Packet> packet);
780 
781 private:
782  uint32_t m_phyTxPkts;
783  uint32_t m_phyTxBytes;
784 };
785 
787 
788 TypeId
790 {
791  static TypeId tid = TypeId ("ns3::WifiPhyStats")
792  .SetParent<Object> ()
793  .AddConstructor<WifiPhyStats> ();
794  return tid;
795 }
796 
798  : m_phyTxPkts (0),
799  m_phyTxBytes (0)
800 {
801 }
802 
804 {
805 }
806 
807 void
808 WifiPhyStats::PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
809 {
810  NS_LOG_FUNCTION (this << context << packet << "PHYTX mode=" << mode );
811  ++m_phyTxPkts;
812  uint32_t pktSize = packet->GetSize ();
813  m_phyTxBytes += pktSize;
814 
815  //NS_LOG_UNCOND ("Received PHY size=" << pktSize);
816 }
817 
818 void
819 WifiPhyStats::PhyTxDrop (std::string context, Ptr<const Packet> packet)
820 {
821  NS_LOG_UNCOND ("PHY Tx Drop");
822 }
823 
824 void
825 WifiPhyStats::PhyRxDrop (std::string context, Ptr<const Packet> packet)
826 {
827  NS_LOG_UNCOND ("PHY Rx Drop");
828 }
829 
830 uint32_t
832 {
833  return m_phyTxBytes;
834 }
835 
840 class WifiApp
841 {
842 public:
847  WifiApp ();
848 
853  virtual ~WifiApp ();
854 
861  void Simulate (int argc, char **argv);
862 
863 protected:
868  virtual void SetDefaultAttributeValues ();
869 
876  virtual void ParseCommandLineArguments (int argc, char **argv);
877 
882  virtual void ConfigureNodes ();
883 
888  virtual void ConfigureChannels ();
889 
894  virtual void ConfigureDevices ();
895 
900  virtual void ConfigureMobility ();
901 
906  virtual void ConfigureApplications ();
907 
912  virtual void ConfigureTracing ();
913 
918  virtual void RunSimulation ();
919 
924  virtual void ProcessOutputs ();
925 };
926 
928 {
929 }
930 
932 {
933 }
934 
935 void
936 WifiApp::Simulate (int argc, char **argv)
937 {
938  // Simulator Program Flow:
939  // (source: NS-3 Annual Meeting, May, 2014, session 2 slides 6, 28)
940  // (HandleProgramInputs:)
941  // SetDefaultAttributeValues
942  // ParseCommandLineArguments
943  // (ConfigureTopology:)
944  // ConfigureNodes
945  // ConfigureChannels
946  // ConfigureDevices
947  // ConfigureMobility
948  // ConfigureApplications
949  // e.g AddInternetStackToNodes
950  // ConfigureIpAddressingAndRouting
951  // configureSendMessages
952  // ConfigureTracing
953  // RunSimulation
954  // ProcessOutputs
955 
957  ParseCommandLineArguments (argc, argv);
958  ConfigureNodes ();
960  ConfigureDevices ();
963  ConfigureTracing ();
964  RunSimulation ();
965  ProcessOutputs ();
966 }
967 
968 void
970 {
971 }
972 
973 void
974 WifiApp::ParseCommandLineArguments (int argc, char **argv)
975 {
976 }
977 
978 void
980 {
981 }
982 
983 void
985 {
986 }
987 
988 void
990 {
991 }
992 
993 void
995 {
996 }
997 
998 void
1000 {
1001 }
1002 
1003 void
1005 {
1006 }
1007 
1008 void
1010 {
1011 }
1012 
1013 void
1015 {
1016 }
1017 
1023 {
1024 public:
1029  ConfigStoreHelper ();
1030 
1036  void LoadConfig (std::string configFilename);
1037 
1043  void SaveConfig (std::string configFilename);
1044 };
1045 
1047 {
1048 }
1049 
1050 void
1051 ConfigStoreHelper::LoadConfig (std::string configFilename)
1052 {
1053  // Input config store from txt format
1054  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1055  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1056  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Load"));
1057  ConfigStore inputConfig;
1058  inputConfig.ConfigureDefaults ();
1059  //inputConfig.ConfigureAttributes ();
1060 }
1061 
1062 void
1063 ConfigStoreHelper::SaveConfig (std::string configFilename)
1064 {
1065  // only save if a non-empty filename has been specified
1066  if (configFilename.compare ("") != 0)
1067  {
1068  // Output config store to txt format
1069  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1070  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1071  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
1072  ConfigStore outputConfig;
1073  outputConfig.ConfigureDefaults ();
1074  //outputConfig.ConfigureAttributes ();
1075  }
1076 }
1077 
1084 {
1085 public:
1091 
1092 protected:
1097  virtual void SetDefaultAttributeValues ();
1098 
1105  virtual void ParseCommandLineArguments (int argc, char **argv);
1106 
1111  virtual void ConfigureNodes ();
1112 
1117  virtual void ConfigureChannels ();
1118 
1123  virtual void ConfigureDevices ();
1124 
1129  virtual void ConfigureMobility ();
1130 
1135  virtual void ConfigureApplications ();
1136 
1141  virtual void ConfigureTracing ();
1142 
1147  virtual void RunSimulation ();
1148 
1153  virtual void ProcessOutputs ();
1154 
1155 private:
1160  void Run ();
1161 
1166  void CommandSetup (int argc, char **argv);
1167 
1173  void CheckThroughput ();
1174 
1179  void SetupLogFile ();
1180 
1185  void SetupLogging ();
1186 
1191  void ConfigureDefaults ();
1192 
1197  void SetupAdhocMobilityNodes ();
1198 
1203  void SetupAdhocDevices ();
1204 
1212  void SetupWaveMessages ();
1213 
1219  void SetupRoutingMessages ();
1220 
1225  void SetupScenario ();
1226 
1231  void WriteCsvHeader ();
1232 
1237  void SetConfigFromGlobals ();
1238 
1243  void SetGlobalsFromConfig ();
1244 
1245  static void
1246  CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobility);
1247 
1248  uint32_t m_port;
1249  std::string m_CSVfileName;
1250  std::string m_CSVfileName2;
1251  uint32_t m_nSinks;
1252  std::string m_protocolName;
1253  double m_txp;
1255  uint32_t m_protocol;
1256 
1257  uint32_t m_lossModel;
1258  uint32_t m_fading;
1259  std::string m_lossModelName;
1260 
1261  std::string m_phyMode;
1262  uint32_t m_80211mode;
1263 
1264  std::string m_traceFile;
1265  std::string m_logFile;
1266  uint32_t m_mobility;
1267  uint32_t m_nNodes;
1269  std::string m_rate;
1270  std::string m_phyModeB;
1271  std::string m_trName;
1272  int m_nodeSpeed; //in m/s
1273  int m_nodePause; //in s
1274  uint32_t m_wavePacketSize; // bytes
1275  double m_waveInterval; // seconds
1277  std::ofstream m_os;
1280  uint32_t m_scenario;
1285  int m_pcap;
1288 
1292  int m_log;
1293  // used to get consistent random numbers across scenarios
1294  int64_t m_streamIndex;
1306  std::vector <double> m_txSafetyRanges;
1307  std::string m_exp;
1309 };
1310 
1312  : m_port (9),
1313  m_CSVfileName ("vanet-routing.output.csv"),
1314  m_CSVfileName2 ("vanet-routing.output2.csv"),
1315  m_nSinks (10),
1316  m_protocolName ("protocol"),
1317  m_txp (20),
1318  m_traceMobility (false),
1319  // AODV
1320  m_protocol (2),
1321  // Two-Ray ground
1322  m_lossModel (3),
1323  m_fading (0),
1324  m_lossModelName (""),
1325  m_phyMode ("OfdmRate6MbpsBW10MHz"),
1326  // 1=802.11p
1327  m_80211mode (1),
1328  m_traceFile (""),
1329  m_logFile ("low_ct-unterstrass-1day.filt.5.adj.log"),
1330  m_mobility (1),
1331  m_nNodes (156),
1332  m_TotalSimTime (300.01),
1333  m_rate ("2048bps"),
1334  m_phyModeB ("DsssRate11Mbps"),
1335  m_trName ("vanet-routing-compare"),
1336  m_nodeSpeed (20),
1337  m_nodePause (0),
1338  m_wavePacketSize (200),
1339  m_waveInterval (0.1),
1340  m_verbose (0),
1341  m_scenario (1),
1342  m_gpsAccuracyNs (40),
1343  m_txMaxDelayMs (10),
1344  m_routingTables (0),
1345  m_asciiTrace (0),
1346  m_pcap (0),
1347  m_loadConfigFilename ("load-config.txt"),
1348  m_saveConfigFilename (""),
1349  m_log (0),
1350  m_streamIndex (0),
1351  m_adhocTxNodes (),
1352  m_txSafetyRange1 (50.0),
1353  m_txSafetyRange2 (100.0),
1354  m_txSafetyRange3 (150.0),
1355  m_txSafetyRange4 (200.0),
1356  m_txSafetyRange5 (250.0),
1357  m_txSafetyRange6 (300.0),
1358  m_txSafetyRange7 (350.0),
1359  m_txSafetyRange8 (400.0),
1360  m_txSafetyRange9 (450.0),
1361  m_txSafetyRange10 (500.0),
1362  m_txSafetyRanges (),
1363  m_exp (""),
1364  m_cumulativeBsmCaptureStart (0)
1365 {
1366  m_wifiPhyStats = CreateObject<WifiPhyStats> ();
1367  m_routingHelper = CreateObject<RoutingHelper> ();
1368 
1369  // set to non-zero value to enable
1370  // simply uncond logging during simulation run
1371  m_log = 1;
1372 }
1373 
1374 void
1376 {
1377  // handled in constructor
1378 }
1379 
1380 // important configuration items stored in global values
1381 static ns3::GlobalValue g_port ("VRCport",
1382  "Port",
1383  ns3::UintegerValue (9),
1384  ns3::MakeUintegerChecker<uint32_t> ());
1385 static ns3::GlobalValue g_nSinks ("VRCnSinks",
1386  "Number of sink nodes for routing non-BSM traffic",
1387  ns3::UintegerValue (10),
1388  ns3::MakeUintegerChecker<uint32_t> ());
1389 static ns3::GlobalValue g_traceMobility ("VRCtraceMobility",
1390  "Trace mobility 1=yes;0=no",
1391  ns3::UintegerValue (0),
1392  ns3::MakeUintegerChecker<uint32_t> ());
1393 static ns3::GlobalValue g_protocol ("VRCprotocol",
1394  "Routing protocol",
1395  ns3::UintegerValue (2),
1396  ns3::MakeUintegerChecker<uint32_t> ());
1397 static ns3::GlobalValue g_lossModel ("VRClossModel",
1398  "Propagation Loss Model",
1399  ns3::UintegerValue (3),
1400  ns3::MakeUintegerChecker<uint32_t> ());
1401 static ns3::GlobalValue g_fading ("VRCfading",
1402  "Fast Fading Model",
1403  ns3::UintegerValue (0),
1404  ns3::MakeUintegerChecker<uint32_t> ());
1405 static ns3::GlobalValue g_80211mode ("VRC80211mode",
1406  "802.11 mode (0=802.11a;1=802.11p)",
1407  ns3::UintegerValue (1),
1408  ns3::MakeUintegerChecker<uint32_t> ());
1409 static ns3::GlobalValue g_mobility ("VRCmobility",
1410  "Mobility mode 0=random waypoint;1=mobility trace file",
1411  ns3::UintegerValue (1),
1412  ns3::MakeUintegerChecker<uint32_t> ());
1413 static ns3::GlobalValue g_nNodes ("VRCnNodes",
1414  "Number of nodes (vehicles)",
1415  ns3::UintegerValue (156),
1416  ns3::MakeUintegerChecker<uint32_t> ());
1417 static ns3::GlobalValue g_nodeSpeed ("VRCnodeSpeed",
1418  "Node speed (m/s) for RWP model",
1419  ns3::UintegerValue (20),
1420  ns3::MakeUintegerChecker<uint32_t> ());
1421 static ns3::GlobalValue g_nodePause ("VRCnodePause",
1422  "Node pause time (s) for RWP model",
1423  ns3::UintegerValue (0),
1424  ns3::MakeUintegerChecker<uint32_t> ());
1425 static ns3::GlobalValue g_wavePacketSize ("VRCwavePacketSize",
1426  "Size in bytes of WAVE BSM",
1427  ns3::UintegerValue (200),
1428  ns3::MakeUintegerChecker<uint32_t> ());
1429 static ns3::GlobalValue g_verbose ("VRCverbose",
1430  "Verbose 0=no;1=yes",
1431  ns3::UintegerValue (0),
1432  ns3::MakeUintegerChecker<uint32_t> ());
1433 static ns3::GlobalValue g_scenario ("VRCscenario",
1434  "Scenario",
1435  ns3::UintegerValue (1),
1436  ns3::MakeUintegerChecker<uint32_t> ());
1437 static ns3::GlobalValue g_routingTables ("VRCroutingTables",
1438  "Dump routing tables at t=5 seconds 0=no;1=yes",
1439  ns3::UintegerValue (0),
1440  ns3::MakeUintegerChecker<uint32_t> ());
1441 static ns3::GlobalValue g_asciiTrace ("VRCasciiTrace",
1442  "Dump ASCII trace 0=no;1=yes",
1443  ns3::UintegerValue (0),
1444  ns3::MakeUintegerChecker<uint32_t> ());
1445 static ns3::GlobalValue g_pcap ("VRCpcap",
1446  "Generate PCAP files 0=no;1=yes",
1447  ns3::UintegerValue (0),
1448  ns3::MakeUintegerChecker<uint32_t> ());
1449 static ns3::GlobalValue g_cumulativeBsmCaptureStart ("VRCcumulativeBsmCaptureStart",
1450  "Simulation starte time for capturing cumulative BSM",
1451  ns3::UintegerValue (0),
1452  ns3::MakeUintegerChecker<uint32_t> ());
1453 
1454 static ns3::GlobalValue g_txSafetyRange1 ("VRCtxSafetyRange1",
1455  "BSM range for PDR inclusion",
1456  ns3::DoubleValue (50.0),
1457  ns3::MakeDoubleChecker<double> ());
1458 
1459 static ns3::GlobalValue g_txSafetyRange2 ("VRCtxSafetyRange2",
1460  "BSM range for PDR inclusion",
1461  ns3::DoubleValue (100.0),
1462  ns3::MakeDoubleChecker<double> ());
1463 
1464 static ns3::GlobalValue g_txSafetyRange3 ("VRCtxSafetyRange3",
1465  "BSM range for PDR inclusion",
1466  ns3::DoubleValue (150.0),
1467  ns3::MakeDoubleChecker<double> ());
1468 
1469 static ns3::GlobalValue g_txSafetyRange4 ("VRCtxSafetyRange4",
1470  "BSM range for PDR inclusion",
1471  ns3::DoubleValue (200.0),
1472  ns3::MakeDoubleChecker<double> ());
1473 
1474 static ns3::GlobalValue g_txSafetyRange5 ("VRCtxSafetyRange5",
1475  "BSM range for PDR inclusion",
1476  ns3::DoubleValue (250.0),
1477  ns3::MakeDoubleChecker<double> ());
1478 static ns3::GlobalValue g_txSafetyRange6 ("VRCtxSafetyRange6",
1479  "BSM range for PDR inclusion",
1480  ns3::DoubleValue (300.0),
1481  ns3::MakeDoubleChecker<double> ());
1482 static ns3::GlobalValue g_txSafetyRange7 ("VRCtxSafetyRange7",
1483  "BSM range for PDR inclusion",
1484  ns3::DoubleValue (350.0),
1485  ns3::MakeDoubleChecker<double> ());
1486 static ns3::GlobalValue g_txSafetyRange8 ("VRCtxSafetyRange8",
1487  "BSM range for PDR inclusion",
1488  ns3::DoubleValue (400.0),
1489  ns3::MakeDoubleChecker<double> ());
1490 static ns3::GlobalValue g_txSafetyRange9 ("VRCtxSafetyRange9",
1491  "BSM range for PDR inclusion",
1492  ns3::DoubleValue (450.0),
1493  ns3::MakeDoubleChecker<double> ());
1494 static ns3::GlobalValue g_txSafetyRange10 ("VRCtxSafetyRange10",
1495  "BSM range for PDR inclusion",
1496  ns3::DoubleValue (500.0),
1497  ns3::MakeDoubleChecker<double> ());
1498 static ns3::GlobalValue g_txp ("VRCtxp",
1499  "Transmission power dBm",
1500  ns3::DoubleValue (7.5),
1501  ns3::MakeDoubleChecker<double> ());
1502 static ns3::GlobalValue g_totalTime ("VRCtotalTime",
1503  "Total simulation time (s)",
1504  ns3::DoubleValue (300.01),
1505  ns3::MakeDoubleChecker<double> ());
1506 static ns3::GlobalValue g_waveInterval ("VRCwaveInterval",
1507  "Interval (s) between WAVE BSMs",
1508  ns3::DoubleValue (0.1),
1509  ns3::MakeDoubleChecker<double> ());
1510 static ns3::GlobalValue g_gpsAccuracyNs ("VRCgpsAccuracyNs",
1511  "GPS sync accuracy (ns)",
1512  ns3::DoubleValue (40),
1513  ns3::MakeDoubleChecker<double> ());
1514 static ns3::GlobalValue g_txMaxDelayMs ("VRCtxMaxDelayMs",
1515  "Tx May Delay (ms)",
1516  ns3::DoubleValue (10),
1517  ns3::MakeDoubleChecker<double> ());
1518 static ns3::GlobalValue g_CSVfileName ("VRCCSVfileName",
1519  "CSV filename (for time series data)",
1520  ns3::StringValue ("vanet-routing.output.csv"),
1522 static ns3::GlobalValue g_CSVfileName2 ("VRCCSVfileName2",
1523  "CSV filename 2 (for overall simulation scenario results)",
1524  ns3::StringValue ("vanet-routing.output2.csv"),
1526 static ns3::GlobalValue g_phyMode ("VRCphyMode",
1527  "PHY mode (802.11p)",
1528  ns3::StringValue ("OfdmRate6MbpsBW10MHz"),
1530 static ns3::GlobalValue g_traceFile ("VRCtraceFile",
1531  "Mobility trace filename",
1532  ns3::StringValue ("./src/wave/examples/low_ct-unterstrass-1day.filt.5.adj.mob"),
1534 static ns3::GlobalValue g_logFile ("VRClogFile",
1535  "Log filename",
1536  ns3::StringValue ("low_ct-unterstrass-1day.filt.5.adj.log"),
1538 static ns3::GlobalValue g_rate ("VRCrate",
1539  "Data rate",
1540  ns3::StringValue ("2048bps"),
1542 static ns3::GlobalValue g_phyModeB ("VRCphyModeB",
1543  "PHY mode (802.11a)",
1544  ns3::StringValue ("DsssRate11Mbps"),
1546 static ns3::GlobalValue g_trName ("VRCtrName",
1547  "Trace name",
1548  ns3::StringValue ("vanet-routing-compare"),
1550 
1551 void
1553 {
1554  CommandSetup (argc, argv);
1555  SetupScenario ();
1556 
1557  // user may specify up to 10 different tx distances
1558  // to be used for calculating different values of Packet
1559  // Delivery Ratio (PDR). Used to see the effects of
1560  // fading over distance
1561  m_txSafetyRanges.resize (10, 0);
1572 
1573  ConfigureDefaults ();
1574 
1575  // we are done with all configuration
1576  // save config-store, if requested
1578  ConfigStoreHelper configStoreHelper;
1579  configStoreHelper.SaveConfig (m_saveConfigFilename);
1580 
1581  m_waveBsmHelper.GetWaveBsmStats ()->SetLogging (m_log);
1583 }
1584 
1585 void
1587 {
1589 }
1590 
1591 void
1593 {
1594  // set up channel and devices
1595  SetupAdhocDevices ();
1596 }
1597 
1598 void
1600 {
1601  // devices are set up in SetupAdhocDevices(),
1602  // called by ConfigureChannels()
1603 
1604  // every device will have PHY callback for tracing
1605  // which is used to determine the total amount of
1606  // data transmitted, and then used to calculate
1607  // the MAC/PHY overhead beyond the app-data
1608  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&WifiPhyStats::PhyTxTrace, m_wifiPhyStats));
1609  // TxDrop, RxDrop not working yet. Not sure what I'm doing wrong.
1610  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback (&WifiPhyStats::PhyTxDrop, m_wifiPhyStats));
1611  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback (&WifiPhyStats::PhyRxDrop, m_wifiPhyStats));
1612 }
1613 
1614 void
1616 {
1618 }
1619 
1620 void
1622 {
1623  // Traffic mix consists of:
1624  // 1. routing data
1625  // 2. Broadcasting of Basic Safety Message (BSM)
1627  SetupWaveMessages ();
1628 
1629  // config trace to capture app-data (bytes) for
1630  // routing data, subtracted and used for
1631  // routing overhead
1632  std::ostringstream oss;
1633  oss.str ("");
1634  oss << "/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx";
1636 }
1637 
1638 void
1640 {
1641  WriteCsvHeader ();
1642  SetupLogFile ();
1643  SetupLogging ();
1644 
1645  AsciiTraceHelper ascii;
1646  MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (m_trName + ".mob"));
1647 }
1648 
1649 void
1651 {
1652  Run ();
1653 }
1654 
1655 void
1657 {
1658  // calculate and output final results
1659  double bsm_pdr1 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (1);
1660  double bsm_pdr2 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (2);
1661  double bsm_pdr3 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (3);
1662  double bsm_pdr4 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (4);
1663  double bsm_pdr5 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (5);
1664  double bsm_pdr6 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (6);
1665  double bsm_pdr7 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (7);
1666  double bsm_pdr8 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (8);
1667  double bsm_pdr9 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (9);
1668  double bsm_pdr10 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (10);
1669 
1670  double averageRoutingGoodputKbps = 0.0;
1671  uint32_t totalBytesTotal = m_routingHelper->GetRoutingStats ().GetCumulativeRxBytes ();
1672  averageRoutingGoodputKbps = (((double) totalBytesTotal * 8.0) / m_TotalSimTime) / 1000.0;
1673 
1674  // calculate MAC/PHY overhead (mac-phy-oh)
1675  // total WAVE BSM bytes sent
1676  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1677  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1678  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1679  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1680  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1681  double mac_phy_oh = 0.0;
1682  if (totalPhyBytes > 0)
1683  {
1684  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1685  }
1686 
1687  if (m_log != 0)
1688  {
1689  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);
1690 
1691  }
1692 
1693  std::ofstream out (m_CSVfileName2.c_str (), std::ios::app);
1694 
1695  out << bsm_pdr1 << ","
1696  << bsm_pdr2 << ","
1697  << bsm_pdr3 << ","
1698  << bsm_pdr4 << ","
1699  << bsm_pdr5 << ","
1700  << bsm_pdr6 << ","
1701  << bsm_pdr7 << ","
1702  << bsm_pdr8 << ","
1703  << bsm_pdr9 << ","
1704  << bsm_pdr10 << ","
1705  << averageRoutingGoodputKbps << ","
1706  << mac_phy_oh << ""
1707  << std::endl;
1708 
1709  out.close ();
1710 
1711  m_os.close (); // close log file
1712 }
1713 
1714 void
1716 {
1717  NS_LOG_INFO ("Run Simulation.");
1718 
1719  CheckThroughput ();
1720 
1721  Simulator::Stop (Seconds (m_TotalSimTime));
1722  Simulator::Run ();
1723  Simulator::Destroy ();
1724 }
1725 
1726 // Prints actual position and velocity when a course change event occurs
1727 void
1729 CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobility)
1730 {
1731  Vector pos = mobility->GetPosition (); // Get position
1732  Vector vel = mobility->GetVelocity (); // Get velocity
1733 
1734  pos.z = 1.5;
1735 
1736  int nodeId = mobility->GetObject<Node> ()->GetId ();
1737  double t = (Simulator::Now ()).GetSeconds ();
1738  if (t >= 1.0)
1739  {
1740  WaveBsmHelper::GetNodesMoving ()[nodeId] = 1;
1741  }
1742 
1743  //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::Now () );
1744 
1745  // Prints position and velocities
1746  *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y
1747  << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
1748  << ", z=" << vel.z << std::endl;
1749 }
1750 
1751 void
1753 {
1754  uint32_t bytesTotal = m_routingHelper->GetRoutingStats ().GetRxBytes ();
1755  uint32_t packetsReceived = m_routingHelper->GetRoutingStats ().GetRxPkts ();
1756  double kbps = (bytesTotal * 8.0) / 1000;
1757  double wavePDR = 0.0;
1758  int wavePktsSent = m_waveBsmHelper.GetWaveBsmStats ()->GetTxPktCount ();
1759  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1760  if (wavePktsSent > 0)
1761  {
1762  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1763  wavePDR = (double) wavePktsReceived / (double) wavePktsSent;
1764  }
1765 
1766  int waveExpectedRxPktCount = m_waveBsmHelper.GetWaveBsmStats ()->GetExpectedRxPktCount (1);
1767  int waveRxPktInRangeCount = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktInRangeCount (1);
1768  double wavePDR1_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (1);
1769  double wavePDR2_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (2);
1770  double wavePDR3_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (3);
1771  double wavePDR4_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (4);
1772  double wavePDR5_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (5);
1773  double wavePDR6_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (6);
1774  double wavePDR7_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (7);
1775  double wavePDR8_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (8);
1776  double wavePDR9_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (9);
1777  double wavePDR10_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (10);
1778 
1779  // calculate MAC/PHY overhead (mac-phy-oh)
1780  // total WAVE BSM bytes sent
1781  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1782  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1783  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1784  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1785  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1786  double mac_phy_oh = 0.0;
1787  if (totalPhyBytes > 0)
1788  {
1789  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1790  }
1791 
1792  std::ofstream out (m_CSVfileName.c_str (), std::ios::app);
1793 
1794  if (m_log != 0 )
1795  {
1796  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*/);
1797  }
1798 
1799  out << (Simulator::Now ()).GetSeconds () << ","
1800  << kbps << ","
1801  << packetsReceived << ","
1802  << m_nSinks << ","
1803  << m_protocolName << ","
1804  << m_txp << ","
1805  << wavePktsSent << ","
1806  << wavePktsReceived << ","
1807  << wavePDR << ","
1808  << waveExpectedRxPktCount << ","
1809  << waveRxPktInRangeCount << ","
1810  << wavePDR1_2 << ","
1811  << wavePDR2_2 << ","
1812  << wavePDR3_2 << ","
1813  << wavePDR4_2 << ","
1814  << wavePDR5_2 << ","
1815  << wavePDR6_2 << ","
1816  << wavePDR7_2 << ","
1817  << wavePDR8_2 << ","
1818  << wavePDR9_2 << ","
1819  << wavePDR10_2 << ","
1820  << mac_phy_oh << ""
1821  << std::endl;
1822 
1823  out.close ();
1824 
1827  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktCount (0);
1828  m_waveBsmHelper.GetWaveBsmStats ()->SetTxPktCount (0);
1829  for (int index = 1; index <= 10; index++)
1830  {
1831  m_waveBsmHelper.GetWaveBsmStats ()->SetExpectedRxPktCount (index, 0);
1832  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktInRangeCount (index, 0);
1833  }
1834 
1835  double currentTime = (Simulator::Now ()).GetSeconds ();
1836  if (currentTime <= (double) m_cumulativeBsmCaptureStart)
1837  {
1838  for (int index = 1; index <= 10; index++)
1839  {
1840  m_waveBsmHelper.GetWaveBsmStats ()->ResetTotalRxPktCounts (index);
1841  }
1842  }
1843 
1844  Simulator::Schedule (Seconds (1.0), &VanetRoutingExperiment::CheckThroughput, this);
1845 }
1846 
1847 void
1849 {
1850  // get settings saved from config-store
1851  UintegerValue uintegerValue;
1852  DoubleValue doubleValue;
1853  StringValue stringValue;
1854 
1855  // This may not be the best way to manage program configuration
1856  // (directing them through global values), but management
1857  // through the config-store here is copied from
1858  // src/lte/examples/lena-dual-stripe.cc
1859 
1860  GlobalValue::GetValueByName ("VRCport", uintegerValue);
1861  m_port = uintegerValue.Get ();
1862  GlobalValue::GetValueByName ("VRCnSinks", uintegerValue);
1863  m_nSinks = uintegerValue.Get ();
1864  GlobalValue::GetValueByName ("VRCtraceMobility", uintegerValue);
1865  m_traceMobility = uintegerValue.Get ();
1866  GlobalValue::GetValueByName ("VRCprotocol", uintegerValue);
1867  m_protocol = uintegerValue.Get ();
1868  GlobalValue::GetValueByName ("VRClossModel", uintegerValue);
1869  m_lossModel = uintegerValue.Get ();
1870  GlobalValue::GetValueByName ("VRCfading", uintegerValue);
1871  m_fading = uintegerValue.Get ();
1872  GlobalValue::GetValueByName ("VRC80211mode", uintegerValue);
1873  m_80211mode = uintegerValue.Get ();
1874  GlobalValue::GetValueByName ("VRCmobility", uintegerValue);
1875  m_mobility = uintegerValue.Get ();
1876  GlobalValue::GetValueByName ("VRCnNodes", uintegerValue);
1877  m_nNodes = uintegerValue.Get ();
1878  GlobalValue::GetValueByName ("VRCnodeSpeed", uintegerValue);
1879  m_nodeSpeed = uintegerValue.Get ();
1880  GlobalValue::GetValueByName ("VRCnodePause", uintegerValue);
1881  m_nodePause = uintegerValue.Get ();
1882  GlobalValue::GetValueByName ("VRCwavePacketSize", uintegerValue);
1883  m_wavePacketSize = uintegerValue.Get ();
1884  GlobalValue::GetValueByName ("VRCverbose", uintegerValue);
1885  m_verbose = uintegerValue.Get ();
1886  GlobalValue::GetValueByName ("VRCscenario", uintegerValue);
1887  m_scenario = uintegerValue.Get ();
1888  GlobalValue::GetValueByName ("VRCroutingTables", uintegerValue);
1889  m_routingTables = uintegerValue.Get ();
1890  GlobalValue::GetValueByName ("VRCasciiTrace", uintegerValue);
1891  m_asciiTrace = uintegerValue.Get ();
1892  GlobalValue::GetValueByName ("VRCpcap", uintegerValue);
1893  m_pcap = uintegerValue.Get ();
1894  GlobalValue::GetValueByName ("VRCcumulativeBsmCaptureStart", uintegerValue);
1895  m_cumulativeBsmCaptureStart = uintegerValue.Get ();
1896 
1897  GlobalValue::GetValueByName ("VRCtxSafetyRange1", doubleValue);
1898  m_txSafetyRange1 = doubleValue.Get ();
1899  GlobalValue::GetValueByName ("VRCtxSafetyRange2", doubleValue);
1900  m_txSafetyRange2 = doubleValue.Get ();
1901  GlobalValue::GetValueByName ("VRCtxSafetyRange3", doubleValue);
1902  m_txSafetyRange3 = doubleValue.Get ();
1903  GlobalValue::GetValueByName ("VRCtxSafetyRange4", doubleValue);
1904  m_txSafetyRange4 = doubleValue.Get ();
1905  GlobalValue::GetValueByName ("VRCtxSafetyRange5", doubleValue);
1906  m_txSafetyRange5 = doubleValue.Get ();
1907  GlobalValue::GetValueByName ("VRCtxSafetyRange6", doubleValue);
1908  m_txSafetyRange6 = doubleValue.Get ();
1909  GlobalValue::GetValueByName ("VRCtxSafetyRange7", doubleValue);
1910  m_txSafetyRange7 = doubleValue.Get ();
1911  GlobalValue::GetValueByName ("VRCtxSafetyRange8", doubleValue);
1912  m_txSafetyRange8 = doubleValue.Get ();
1913  GlobalValue::GetValueByName ("VRCtxSafetyRange9", doubleValue);
1914  m_txSafetyRange9 = doubleValue.Get ();
1915  GlobalValue::GetValueByName ("VRCtxSafetyRange10", doubleValue);
1916  m_txSafetyRange10 = doubleValue.Get ();
1917  GlobalValue::GetValueByName ("VRCtxp", doubleValue);
1918  m_txp = doubleValue.Get ();
1919  GlobalValue::GetValueByName ("VRCtotalTime", doubleValue);
1920  m_TotalSimTime = doubleValue.Get ();
1921  GlobalValue::GetValueByName ("VRCwaveInterval", doubleValue);
1922  m_waveInterval = doubleValue.Get ();
1923  GlobalValue::GetValueByName ("VRCgpsAccuracyNs", doubleValue);
1924  m_gpsAccuracyNs = doubleValue.Get ();
1925  GlobalValue::GetValueByName ("VRCtxMaxDelayMs", doubleValue);
1926  m_txMaxDelayMs = doubleValue.Get ();
1927 
1928  GlobalValue::GetValueByName ("VRCCSVfileName", stringValue);
1929  m_CSVfileName = stringValue.Get ();
1930  GlobalValue::GetValueByName ("VRCCSVfileName2", stringValue);
1931  m_CSVfileName2 = stringValue.Get ();
1932  GlobalValue::GetValueByName ("VRCphyMode", stringValue);
1933  m_phyMode = stringValue.Get ();
1934  GlobalValue::GetValueByName ("VRCtraceFile", stringValue);
1935  m_traceFile = stringValue.Get ();
1936  GlobalValue::GetValueByName ("VRClogFile", stringValue);
1937  m_logFile = stringValue.Get ();
1938  GlobalValue::GetValueByName ("VRCrate", stringValue);
1939  m_rate = stringValue.Get ();
1940  GlobalValue::GetValueByName ("VRCphyModeB", stringValue);
1941  m_phyModeB = stringValue.Get ();
1942  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1943  m_trName = stringValue.Get ();
1944 }
1945 
1946 void
1948 {
1949  // get settings saved from config-store
1950  UintegerValue uintegerValue;
1951  DoubleValue doubleValue;
1952  StringValue stringValue;
1953 
1972 
1988 
1997  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1998  m_trName = stringValue.Get ();
1999 }
2000 
2001 void
2003 {
2004  CommandLine cmd;
2005  double txDist1 = 50.0;
2006  double txDist2 = 100.0;
2007  double txDist3 = 150.0;
2008  double txDist4 = 200.0;
2009  double txDist5 = 250.0;
2010  double txDist6 = 300.0;
2011  double txDist7 = 350.0;
2012  double txDist8 = 350.0;
2013  double txDist9 = 350.0;
2014  double txDist10 = 350.0;
2015 
2016  // allow command line overrides
2017  cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName);
2018  cmd.AddValue ("CSVfileName2", "The name of the CSV output file name2", m_CSVfileName2);
2019  cmd.AddValue ("totaltime", "Simulation end time", m_TotalSimTime);
2020  cmd.AddValue ("nodes", "Number of nodes (i.e. vehicles)", m_nNodes);
2021  cmd.AddValue ("sinks", "Number of routing sinks", m_nSinks);
2022  cmd.AddValue ("txp", "Transmit power (dB), e.g. txp=7.5", m_txp);
2023  cmd.AddValue ("traceMobility", "Enable mobility tracing", m_traceMobility);
2024  cmd.AddValue ("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol);
2025  cmd.AddValue ("lossModel", "1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance", m_lossModel);
2026  cmd.AddValue ("fading", "0=None;1=Nakagami;(buildings=1 overrides)", m_fading);
2027  cmd.AddValue ("phyMode", "Wifi Phy mode", m_phyMode);
2028  cmd.AddValue ("80211Mode", "1=802.11p; 2=802.11b; 3=WAVE-PHY", m_80211mode);
2029  cmd.AddValue ("traceFile", "Ns2 movement trace file", m_traceFile);
2030  cmd.AddValue ("logFile", "Log file", m_logFile);
2031  cmd.AddValue ("mobility", "1=trace;2=RWP", m_mobility);
2032  cmd.AddValue ("rate", "Rate", m_rate);
2033  cmd.AddValue ("phyModeB", "Phy mode 802.11b", m_phyModeB);
2034  cmd.AddValue ("speed", "Node speed (m/s)", m_nodeSpeed);
2035  cmd.AddValue ("pause", "Node pause (s)", m_nodePause);
2036  cmd.AddValue ("verbose", "0=quiet;1=verbose", m_verbose);
2037  cmd.AddValue ("bsm", "(WAVE) BSM size (bytes)", m_wavePacketSize);
2038  cmd.AddValue ("interval", "(WAVE) BSM interval (s)", m_waveInterval);
2039  cmd.AddValue ("scenario", "1=synthetic, 2=playback-trace", m_scenario);
2040  // User is allowed to have up to 10 different PDRs (Packet
2041  // Delivery Ratios) calculate, and so can specify up to
2042  // 10 different tx distances.
2043  cmd.AddValue ("txdist1", "Expected BSM tx range, m", txDist1);
2044  cmd.AddValue ("txdist2", "Expected BSM tx range, m", txDist2);
2045  cmd.AddValue ("txdist3", "Expected BSM tx range, m", txDist3);
2046  cmd.AddValue ("txdist4", "Expected BSM tx range, m", txDist4);
2047  cmd.AddValue ("txdist5", "Expected BSM tx range, m", txDist5);
2048  cmd.AddValue ("txdist6", "Expected BSM tx range, m", txDist6);
2049  cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7);
2050  cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8);
2051  cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9);
2052  cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10);
2053  cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs);
2054  cmd.AddValue ("txmaxdelay", "Tx max delay, in ms", m_txMaxDelayMs);
2055  cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routingTables);
2056  cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace);
2057  cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap);
2058  cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilename);
2059  cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilename);
2060  cmd.AddValue ("exp", "Experiment", m_exp);
2061  cmd.AddValue ("BsmCaptureStart", "Start time to begin capturing pkts for cumulative Bsm", m_cumulativeBsmCaptureStart);
2062  cmd.Parse (argc, argv);
2063 
2064  m_txSafetyRange1 = txDist1;
2065  m_txSafetyRange2 = txDist2;
2066  m_txSafetyRange3 = txDist3;
2067  m_txSafetyRange4 = txDist4;
2068  m_txSafetyRange5 = txDist5;
2069  m_txSafetyRange6 = txDist6;
2070  m_txSafetyRange7 = txDist7;
2071  m_txSafetyRange8 = txDist8;
2072  m_txSafetyRange9 = txDist9;
2073  m_txSafetyRange10 = txDist10;
2074  // load configuration info from config-store
2075  ConfigStoreHelper configStoreHelper;
2076  configStoreHelper.LoadConfig (m_loadConfigFilename);
2077  // transfer config-store values to config parameters
2079 
2080  // parse again so you can override input file default values via command line
2081  cmd.Parse (argc, argv);
2082 
2083  m_txSafetyRange1 = txDist1;
2084  m_txSafetyRange2 = txDist2;
2085  m_txSafetyRange3 = txDist3;
2086  m_txSafetyRange4 = txDist4;
2087  m_txSafetyRange5 = txDist5;
2088  m_txSafetyRange6 = txDist6;
2089  m_txSafetyRange7 = txDist7;
2090  m_txSafetyRange8 = txDist8;
2091  m_txSafetyRange9 = txDist9;
2092  m_txSafetyRange10 = txDist10;
2093 }
2094 
2095 void
2097 {
2098  // open log file for output
2099  m_os.open (m_logFile.c_str ());
2100 }
2101 
2103 {
2104 
2105  // Enable logging from the ns2 helper
2106  LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
2107 
2108  Packet::EnablePrinting ();
2109 }
2110 
2111 void
2113 {
2114  Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64"));
2115  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (m_rate));
2116 
2117  //Set Non-unicastMode rate to unicast mode
2118  if (m_80211mode == 2)
2119  {
2120  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyModeB));
2121  }
2122  else
2123  {
2124  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyMode));
2125  }
2126 }
2127 
2128 void
2130 {
2131  if (m_mobility == 1)
2132  {
2133  // Create Ns2MobilityHelper with the specified trace log file as parameter
2135  ns2.Install (); // configure movements for each node, while reading trace file
2136  // initially assume all nodes are not moving
2137  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 0);
2138  }
2139  else if (m_mobility == 2)
2140  {
2141  MobilityHelper mobilityAdhoc;
2142 
2143  ObjectFactory pos;
2144  pos.SetTypeId ("ns3::RandomBoxPositionAllocator");
2145  pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
2146  pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
2147  // we need antenna height uniform [1.0 .. 2.0] for loss model
2148  pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"));
2149 
2150  Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
2151  m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex);
2152 
2153  std::stringstream ssSpeed;
2154  ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]";
2155  std::stringstream ssPause;
2156  ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]";
2157  mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
2158  "Speed", StringValue (ssSpeed.str ()),
2159  "Pause", StringValue (ssPause.str ()),
2160  "PositionAllocator", PointerValue (taPositionAlloc));
2161  mobilityAdhoc.SetPositionAllocator (taPositionAlloc);
2162  mobilityAdhoc.Install (m_adhocTxNodes);
2163  m_streamIndex += mobilityAdhoc.AssignStreams (m_adhocTxNodes, m_streamIndex);
2164 
2165  // initially assume all nodes are moving
2166  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 1);
2167  }
2168 
2169  // Configure callback for logging
2170  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2172 }
2173 
2174 void
2176 {
2177  if (m_lossModel == 1)
2178  {
2179  m_lossModelName = "ns3::FriisPropagationLossModel";
2180  }
2181  else if (m_lossModel == 2)
2182  {
2183  m_lossModelName = "ns3::ItuR1411LosPropagationLossModel";
2184  }
2185  else if (m_lossModel == 3)
2186  {
2187  m_lossModelName = "ns3::TwoRayGroundPropagationLossModel";
2188  }
2189  else if (m_lossModel == 4)
2190  {
2191  m_lossModelName = "ns3::LogDistancePropagationLossModel";
2192  }
2193  else
2194  {
2195  // Unsupported propagation loss model.
2196  // Treating as ERROR
2197  NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance");
2198  }
2199 
2200  // frequency
2201  double freq = 0.0;
2202  if ((m_80211mode == 1)
2203  || (m_80211mode == 3))
2204  {
2205  // 802.11p 5.9 GHz
2206  freq = 5.9e9;
2207  }
2208  else
2209  {
2210  // 802.11b 2.4 GHz
2211  freq = 2.4e9;
2212  }
2213 
2214  // Setup propagation models
2215  YansWifiChannelHelper wifiChannel;
2216  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
2217  if (m_lossModel == 3)
2218  {
2219  // two-ray requires antenna height (else defaults to Friss)
2220  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq), "HeightAboveZ", DoubleValue (1.5));
2221  }
2222  else
2223  {
2224  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq));
2225  }
2226 
2227  // Propagation loss models are additive.
2228  if (m_fading != 0)
2229  {
2230  // if no obstacle model, then use Nakagami fading if requested
2231  wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
2232  }
2233 
2234  // the channel
2235  Ptr<YansWifiChannel> channel = wifiChannel.Create ();
2236 
2237  // The below set of helpers will help us to put together the wifi NICs we want
2238  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
2239  wifiPhy.SetChannel (channel);
2240  // ns-3 supports generate a pcap trace
2241  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2242 
2243  YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
2244  wavePhy.SetChannel (channel);
2245  wavePhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2246 
2247  // Setup WAVE PHY and MAC
2248  NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
2249  WaveHelper waveHelper = WaveHelper::Default ();
2250  Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
2251  if (m_verbose)
2252  {
2253  wifi80211p.EnableLogComponents (); // Turn on all Wifi 802.11p logging
2254  // likewise, turn on WAVE PHY logging
2255  waveHelper.EnableLogComponents ();
2256  }
2257 
2258  WifiHelper wifi;
2259 
2260  // Setup 802.11b stuff
2262 
2263  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2264  "DataMode",StringValue (m_phyModeB),
2265  "ControlMode",StringValue (m_phyModeB));
2266 
2267  // Setup 802.11p stuff
2268  wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2269  "DataMode",StringValue (m_phyMode),
2270  "ControlMode",StringValue (m_phyMode));
2271 
2272  // Setup WAVE-PHY stuff
2273  waveHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2274  "DataMode",StringValue (m_phyMode),
2275  "ControlMode",StringValue (m_phyMode));
2276 
2277  // Set Tx Power
2278  wifiPhy.Set ("TxPowerStart",DoubleValue (m_txp));
2279  wifiPhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2280  wavePhy.Set ("TxPowerStart",DoubleValue (m_txp));
2281  wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2282 
2283  // Add a non-QoS upper mac, and disable rate control
2284  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
2285  wifiMac.SetType ("ns3::AdhocWifiMac");
2286  QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
2287 
2288  // Setup net devices
2289 
2290  if (m_80211mode == 3)
2291  {
2292  m_adhocTxDevices = waveHelper.Install (wavePhy, waveMac, m_adhocTxNodes);
2293  }
2294  else if (m_80211mode == 1)
2295  {
2296  m_adhocTxDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, m_adhocTxNodes);
2297  }
2298  else
2299  {
2300  m_adhocTxDevices = wifi.Install (wifiPhy, wifiMac, m_adhocTxNodes);
2301  }
2302 
2303  if (m_asciiTrace != 0)
2304  {
2305  AsciiTraceHelper ascii;
2306  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (m_trName + ".tr").c_str ());
2307  wifiPhy.EnableAsciiAll (osw);
2308  wavePhy.EnableAsciiAll (osw);
2309  }
2310  if (m_pcap != 0)
2311  {
2312  wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap");
2313  wavePhy.EnablePcapAll ("vanet-routing-compare-pcap");
2314  }
2315 }
2316 
2317 void
2319 {
2320  // WAVE PHY mode
2321  // 0=continuous channel; 1=channel-switching
2322  int chAccessMode = 0;
2323  if (m_80211mode == 3)
2324  {
2325  chAccessMode = 1;
2326  }
2327 
2332  // GPS accuracy (i.e, clock drift), in number of ns
2335  chAccessMode,
2336  // tx max delay before transmit, in ms
2338 
2339  // fix random number streams
2341 }
2342 
2343 void
2345 {
2350  m_protocol,
2351  m_nSinks,
2352  m_routingTables);
2353 }
2354 
2355 void
2357 {
2358  // member variable parameter use
2359  // defaults or command line overrides,
2360  // except where scenario={1,2,3,...}
2361  // have been specified, in which case
2362  // specify parameters are overwritten
2363  // here to setup for specific scenarios
2364 
2365  // certain parameters may be further overridden
2366  // i.e. specify a scenario, override tx power.
2367 
2368  if (m_scenario == 1)
2369  {
2370  // 40 nodes in RWP 300 m x 1500 m synthetic highway, 10s
2371  m_traceFile = "";
2372  m_logFile = "";
2373  m_mobility = 2;
2374  if (m_nNodes == 156)
2375  {
2376  m_nNodes = 40;
2377  }
2378  if (m_TotalSimTime == 300.01)
2379  {
2380  m_TotalSimTime = 10.0;
2381  }
2382  }
2383  else if (m_scenario == 2)
2384  {
2385  // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
2386  // "low density, 99 total vehicles"
2387  m_traceFile = "src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob";
2388  m_logFile = "low99-ct-unterstrass-1day.filt.7.adj.log";
2389  m_mobility = 1;
2390  m_nNodes = 99;
2391  m_TotalSimTime = 300.01;
2392  m_nodeSpeed = 0;
2393  m_nodePause = 0;
2394  m_CSVfileName = "low_vanet-routing-compare.csv";
2395  m_CSVfileName = "low_vanet-routing-compare2.csv";
2396  }
2397 }
2398 
2399 void
2401 {
2402  //blank out the last output file and write the column headers
2403  std::ofstream out (m_CSVfileName.c_str ());
2404  out << "SimulationSecond," <<
2405  "ReceiveRate," <<
2406  "PacketsReceived," <<
2407  "NumberOfSinks," <<
2408  "RoutingProtocol," <<
2409  "TransmissionPower," <<
2410  "WavePktsSent," <<
2411  "WavePtksReceived," <<
2412  "WavePktsPpr," <<
2413  "ExpectedWavePktsReceived," <<
2414  "ExpectedWavePktsInCoverageReceived," <<
2415  "BSM_PDR1," <<
2416  "BSM_PDR2," <<
2417  "BSM_PDR3," <<
2418  "BSM_PDR4," <<
2419  "BSM_PDR5," <<
2420  "BSM_PDR6," <<
2421  "BSM_PDR7," <<
2422  "BSM_PDR8," <<
2423  "BSM_PDR9," <<
2424  "BSM_PDR10," <<
2425  "MacPhyOverhead" <<
2426  std::endl;
2427  out.close ();
2428 
2429  std::ofstream out2 (m_CSVfileName2.c_str ());
2430  out2 << "BSM_PDR1,"
2431  << "BSM_PDR2,"
2432  << "BSM_PDR3,"
2433  << "BSM_PDR4,"
2434  << "BSM_PDR5,"
2435  << "BSM_PDR6,"
2436  << "BSM_PDR7,"
2437  << "BSM_PDR8,"
2438  << "BSM_PDR9,"
2439  << "BSM_PDR10,"
2440  << "AverageRoutingGoodputKbps,"
2441  << "MacPhyOverhead"
2442  << std::endl;
2443  out2.close ();
2444 }
2445 
2446 int
2447 main (int argc, char *argv[])
2448 {
2450  experiment.Simulate (argc, argv);
2451 }
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< 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:34
static void EnableLogComponents(void)
Helper to enable all WaveNetDevice log components with one statement.
Definition: wave-helper.cc:548
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:141
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:73
virtual void ConfigureNodes()
Configure nodes.
virtual void ConfigureNodes()
Configure nodes.
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 >())
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:1493
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
void 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:874
virtual ~WifiPhyStats()
Destructor.
void IncRxPkts()
Increments the count of packets received.
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
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:38
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:766
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)
Fatal error handling.
Definition: fatal-error.h:100
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 Set(std::string name, const AttributeValue &v)
void IncTxBytes(uint32_t txBytes)
Increment the number of bytes transmitted.
hold a so-called 'global value'.
Definition: global-value.h:54
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:483
void CommandSetup(int argc, char **argv)
Run the simulation.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:92
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:93
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
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...
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:102
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:29
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:334
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:437
void SetTxPkts(uint32_t txPkts)
Sets the number of packets transmitted.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:858
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
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())
static std::string PrintReceivedRoutingPacket(Ptr< Socket > socket, Ptr< Packet > packet)
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:96
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_logFile("VRClogFile","Log filename", ns3::StringValue("low_ct-unterstrass-1day.filt.5.adj.log"), ns3::MakeStringChecker())
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 >())
This class implements a tag that carries an address of a packet across the socket interface...
Definition: socket.h:951
virtual void SetDefaultAttributeValues()
Sets default attribute values.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1296
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...
create non QoS-enabled MAC layers for a ns3::WifiNetDevice.
Parse command-line arguments.
Definition: command-line.h:201
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:744
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 Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
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)
Returns a random double from the uniform distribution with 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)
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.
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 >())
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
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:491
Address GetAddress(void) const
Get the tag's address.
Definition: socket.cc:530
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:55
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:866
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:683
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 >())
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:330
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:220
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
static ns3::GlobalValue g_traceFile("VRCtraceFile","Mobility trace filename", ns3::StringValue("./src/wave/examples/low_ct-unterstrass-1day.filt.5.adj.mob"), ns3::MakeStringChecker())
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)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:455
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:57
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)
Definition: type-id.cc:638
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...