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 {
266 }
267 
268 uint32_t
270 {
271  return m_RxBytes;
272 }
273 
274 uint32_t
276 {
277  return m_cumulativeRxBytes;
278 }
279 
280 uint32_t
282 {
283  return m_RxPkts;
284 }
285 
286 uint32_t
288 {
289  return m_cumulativeRxPkts;
290 }
291 
292 void
293 RoutingStats::IncRxBytes (uint32_t rxBytes)
294 {
295  m_RxBytes += rxBytes;
296  m_cumulativeRxBytes += rxBytes;
297 }
298 
299 void
301 {
302  m_RxPkts++;
304 }
305 
306 void
307 RoutingStats::SetRxBytes (uint32_t rxBytes)
308 {
309  m_RxBytes = rxBytes;
310 }
311 
312 void
313 RoutingStats::SetRxPkts (uint32_t rxPkts)
314 {
315  m_RxPkts = rxPkts;
316 }
317 
318 uint32_t
320 {
321  return m_TxBytes;
322 }
323 
324 uint32_t
326 {
327  return m_cumulativeTxBytes;
328 }
329 
330 uint32_t
332 {
333  return m_TxPkts;
334 }
335 
336 uint32_t
338 {
339  return m_cumulativeTxPkts;
340 }
341 
342 void
343 RoutingStats::IncTxBytes (uint32_t txBytes)
344 {
345  m_TxBytes += txBytes;
346  m_cumulativeTxBytes += txBytes;
347 }
348 
349 void
351 {
352  m_TxPkts++;
354 }
355 
356 void
357 RoutingStats::SetTxBytes (uint32_t txBytes)
358 {
359  m_TxBytes = txBytes;
360 }
361 
362 void
363 RoutingStats::SetTxPkts (uint32_t txPkts)
364 {
365  m_TxPkts = txPkts;
366 }
367 
378 class RoutingHelper : public Object
379 {
380 public:
385  static TypeId GetTypeId (void);
386 
391  RoutingHelper ();
392 
397  virtual ~RoutingHelper ();
398 
412  void Install (NodeContainer & c,
413  NetDeviceContainer & d,
415  double totalTime,
416  int protocol,
417  uint32_t nSinks,
418  int routingTables);
419 
426  void OnOffTrace (std::string context, Ptr<const Packet> packet);
427 
433 
439  void SetLogging (int log);
440 
441 private:
448 
456  Ipv4InterfaceContainer & adhocTxInterfaces);
457 
465  Ipv4InterfaceContainer & adhocTxInterfaces);
466 
474 
480  void ReceiveRoutingPacket (Ptr<Socket> socket);
481 
482  double m_TotalSimTime; // seconds
483  uint32_t m_protocol; // routing protocol; 0=NONE, 1=OLSR, 2=AODV, 3=DSDV, 4=DSR
484  uint32_t m_port;
485  uint32_t m_nSinks; // number of sink nodes (< all nodes)
486  int m_routingTables; // dump routing table (at t=5 sec). 0=No, 1=Yes
488  std::string m_protocolName;
489  int m_log;
490 };
491 
493 
494 TypeId
496 {
497  static TypeId tid = TypeId ("ns3::RoutingHelper")
498  .SetParent<Object> ()
499  .AddConstructor<RoutingHelper> ();
500  return tid;
501 }
502 
504  : m_TotalSimTime (300.01),
505  m_protocol (0),
506  m_port (9),
507  m_nSinks (0),
508  m_routingTables (0),
509  m_log (0)
510 {
511 }
512 
514 {
515 }
516 
517 void
519  NetDeviceContainer & d,
521  double totalTime,
522  int protocol,
523  uint32_t nSinks,
524  int routingTables)
525 {
526  m_TotalSimTime = totalTime;
527  m_protocol = protocol;
528  m_nSinks = nSinks;
529  m_routingTables = routingTables;
530 
532  AssignIpAddresses (d, i);
533  SetupRoutingMessages (c, i);
534 }
535 
538 {
539  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
540  Ptr<Socket> sink = Socket::CreateSocket (node, tid);
542  sink->Bind (local);
544 
545  return sink;
546 }
547 
548 void
550 {
551  AodvHelper aodv;
553  DsdvHelper dsdv;
554  DsrHelper dsr;
555  DsrMainHelper dsrMain;
557  InternetStackHelper internet;
558 
559  Time rtt = Time (5.0);
560  AsciiTraceHelper ascii;
561  Ptr<OutputStreamWrapper> rtw = ascii.CreateFileStream ("routing_table");
562 
563  switch (m_protocol)
564  {
565  case 1:
566  if (m_routingTables != 0)
567  {
568  olsr.PrintRoutingTableAllAt (rtt, rtw);
569  }
570  list.Add (olsr, 100);
571  m_protocolName = "OLSR";
572  break;
573  case 0:
574  case 2:
575  if (m_routingTables != 0)
576  {
577  aodv.PrintRoutingTableAllAt (rtt, rtw);
578  }
579  list.Add (aodv, 100);
580  if (m_protocol == 0)
581  {
582  m_protocolName = "NONE";
583  }
584  else
585  {
586  m_protocolName = "AODV";
587  }
588  break;
589  case 3:
590  if (m_routingTables != 0)
591  {
592  dsdv.PrintRoutingTableAllAt (rtt, rtw);
593  }
594  list.Add (dsdv, 100);
595  m_protocolName = "DSDV";
596  break;
597  case 4:
598  m_protocolName = "DSR";
599  break;
600  default:
601  NS_FATAL_ERROR ("No such protocol:" << m_protocol);
602  }
603 
604  if (m_protocol < 4)
605  {
606  internet.SetRoutingHelper (list);
607  internet.Install (c);
608  }
609  else if (m_protocol == 4)
610  {
611  internet.Install (c);
612  dsrMain.Install (dsr, c);
613  }
614 
615  if (m_log != 0)
616  {
617  NS_LOG_UNCOND ("Routing Setup for " << m_protocolName);
618  }
619 }
620 
621 void
623  Ipv4InterfaceContainer & adhocTxInterfaces)
624 {
625  NS_LOG_INFO ("Assigning IP addresses");
626  Ipv4AddressHelper addressAdhoc;
627  // we may have a lot of nodes, and want them all
628  // in same subnet, to support broadcast
629  addressAdhoc.SetBase ("10.1.0.0", "255.255.0.0");
630  adhocTxInterfaces = addressAdhoc.Assign (d);
631 }
632 
633 void
635  Ipv4InterfaceContainer & adhocTxInterfaces)
636 {
637  // Setup routing transmissions
638  OnOffHelper onoff1 ("ns3::UdpSocketFactory",Address ());
639  onoff1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
640  onoff1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
641 
642  Ptr<UniformRandomVariable> var = CreateObject<UniformRandomVariable> ();
643  int64_t stream = 2;
644  var->SetStream (stream);
645  for (uint32_t i = 0; i < m_nSinks; i++)
646  {
647  // protocol == 0 means no routing data, WAVE BSM only
648  // so do not set up sink
649  if (m_protocol != 0)
650  {
651  Ptr<Socket> sink = SetupRoutingPacketReceive (adhocTxInterfaces.GetAddress (i), c.Get (i));
652  }
653 
654  AddressValue remoteAddress (InetSocketAddress (adhocTxInterfaces.GetAddress (i), m_port));
655  onoff1.SetAttribute ("Remote", remoteAddress);
656 
657  ApplicationContainer temp = onoff1.Install (c.Get (i + m_nSinks));
658  temp.Start (Seconds (var->GetValue (1.0,2.0)));
659  temp.Stop (Seconds (m_TotalSimTime));
660  }
661 }
662 
663 static inline std::string
665 {
666  SocketAddressTag tag;
667  bool found;
668  found = packet->PeekPacketTag (tag);
669  std::ostringstream oss;
670 
671  oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
672 
673  if (found)
674  {
675  InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ());
676  oss << " received one packet from " << addr.GetIpv4 ();
677  }
678  else
679  {
680  oss << " received one packet!";
681  }
682  return oss.str ();
683 }
684 
685 void
687 {
688  Ptr<Packet> packet;
689  while ((packet = socket->Recv ()))
690  {
691  // application data, for goodput
692  uint32_t RxRoutingBytes = packet->GetSize ();
693  GetRoutingStats ().IncRxBytes (RxRoutingBytes);
695  if (m_log != 0)
696  {
697  NS_LOG_UNCOND (m_protocolName + " " + PrintReceivedRoutingPacket (socket, packet));
698  }
699  }
700 }
701 
702 void
703 RoutingHelper::OnOffTrace (std::string context, Ptr<const Packet> packet)
704 {
705  uint32_t pktBytes = packet->GetSize ();
706  routingStats.IncTxBytes (pktBytes);
707 }
708 
709 RoutingStats &
711 {
712  return routingStats;
713 }
714 
715 void
717 {
718  m_log = log;
719 }
720 
725 class WifiPhyStats : public Object
726 {
727 public:
732  static TypeId GetTypeId (void);
733 
738  WifiPhyStats ();
739 
744  virtual ~WifiPhyStats ();
745 
751  uint32_t GetTxBytes ();
752 
762  void PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower);
763 
770  void PhyTxDrop (std::string context, Ptr<const Packet> packet);
771 
778  void PhyRxDrop (std::string context, Ptr<const Packet> packet);
779 
780 private:
781  uint32_t m_phyTxPkts;
782  uint32_t m_phyTxBytes;
783 };
784 
786 
787 TypeId
789 {
790  static TypeId tid = TypeId ("ns3::WifiPhyStats")
791  .SetParent<Object> ()
792  .AddConstructor<WifiPhyStats> ();
793  return tid;
794 }
795 
797  : m_phyTxPkts (0),
798  m_phyTxBytes (0)
799 {
800 }
801 
803 {
804 }
805 
806 void
807 WifiPhyStats::PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
808 {
809  NS_LOG_FUNCTION (this << context << packet << "PHYTX mode=" << mode );
810  ++m_phyTxPkts;
811  uint32_t pktSize = packet->GetSize ();
812  m_phyTxBytes += pktSize;
813 
814  //NS_LOG_UNCOND ("Received PHY size=" << pktSize);
815 }
816 
817 void
818 WifiPhyStats::PhyTxDrop (std::string context, Ptr<const Packet> packet)
819 {
820  NS_LOG_UNCOND ("PHY Tx Drop");
821 }
822 
823 void
824 WifiPhyStats::PhyRxDrop (std::string context, Ptr<const Packet> packet)
825 {
826  NS_LOG_UNCOND ("PHY Rx Drop");
827 }
828 
829 uint32_t
831 {
832  return m_phyTxBytes;
833 }
834 
839 class WifiApp
840 {
841 public:
846  WifiApp ();
847 
852  virtual ~WifiApp ();
853 
860  void Simulate (int argc, char **argv);
861 
862 protected:
867  virtual void SetDefaultAttributeValues ();
868 
875  virtual void ParseCommandLineArguments (int argc, char **argv);
876 
881  virtual void ConfigureNodes ();
882 
887  virtual void ConfigureChannels ();
888 
893  virtual void ConfigureDevices ();
894 
899  virtual void ConfigureMobility ();
900 
905  virtual void ConfigureApplications ();
906 
911  virtual void ConfigureTracing ();
912 
917  virtual void RunSimulation ();
918 
923  virtual void ProcessOutputs ();
924 };
925 
927 {
928 }
929 
931 {
932 }
933 
934 void
935 WifiApp::Simulate (int argc, char **argv)
936 {
937  // Simulator Program Flow:
938  // (source: NS-3 Annual Meeting, May, 2014, session 2 slides 6, 28)
939  // (HandleProgramInputs:)
940  // SetDefaultAttributeValues
941  // ParseCommandLineArguments
942  // (ConfigureTopology:)
943  // ConfigureNodes
944  // ConfigureChannels
945  // ConfigureDevices
946  // ConfigureMobility
947  // ConfigureApplications
948  // e.g AddInternetStackToNodes
949  // ConfigureIpAddressingAndRouting
950  // configureSendMessages
951  // ConfigureTracing
952  // RunSimulation
953  // ProcessOutputs
954 
956  ParseCommandLineArguments (argc, argv);
957  ConfigureNodes ();
959  ConfigureDevices ();
962  ConfigureTracing ();
963  RunSimulation ();
964  ProcessOutputs ();
965 }
966 
967 void
969 {
970 }
971 
972 void
973 WifiApp::ParseCommandLineArguments (int argc, char **argv)
974 {
975 }
976 
977 void
979 {
980 }
981 
982 void
984 {
985 }
986 
987 void
989 {
990 }
991 
992 void
994 {
995 }
996 
997 void
999 {
1000 }
1001 
1002 void
1004 {
1005 }
1006 
1007 void
1009 {
1010 }
1011 
1012 void
1014 {
1015 }
1016 
1022 {
1023 public:
1028  ConfigStoreHelper ();
1029 
1035  void LoadConfig (std::string configFilename);
1036 
1042  void SaveConfig (std::string configFilename);
1043 };
1044 
1046 {
1047 }
1048 
1049 void
1050 ConfigStoreHelper::LoadConfig (std::string configFilename)
1051 {
1052  // Input config store from txt format
1053  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1054  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1055  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Load"));
1056  ConfigStore inputConfig;
1057  inputConfig.ConfigureDefaults ();
1058  //inputConfig.ConfigureAttributes ();
1059 }
1060 
1061 void
1062 ConfigStoreHelper::SaveConfig (std::string configFilename)
1063 {
1064  // only save if a non-empty filename has been specified
1065  if (configFilename.compare ("") != 0)
1066  {
1067  // Output config store to txt format
1068  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1069  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1070  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
1071  ConfigStore outputConfig;
1072  outputConfig.ConfigureDefaults ();
1073  //outputConfig.ConfigureAttributes ();
1074  }
1075 }
1076 
1083 {
1084 public:
1090 
1091 protected:
1096  virtual void SetDefaultAttributeValues ();
1097 
1104  virtual void ParseCommandLineArguments (int argc, char **argv);
1105 
1110  virtual void ConfigureNodes ();
1111 
1116  virtual void ConfigureChannels ();
1117 
1122  virtual void ConfigureDevices ();
1123 
1128  virtual void ConfigureMobility ();
1129 
1134  virtual void ConfigureApplications ();
1135 
1140  virtual void ConfigureTracing ();
1141 
1146  virtual void RunSimulation ();
1147 
1152  virtual void ProcessOutputs ();
1153 
1154 private:
1159  void Run ();
1160 
1165  void CommandSetup (int argc, char **argv);
1166 
1172  void CheckThroughput ();
1173 
1178  void SetupLogFile ();
1179 
1184  void SetupLogging ();
1185 
1190  void ConfigureDefaults ();
1191 
1196  void SetupAdhocMobilityNodes ();
1197 
1202  void SetupAdhocDevices ();
1203 
1211  void SetupWaveMessages ();
1212 
1218  void SetupRoutingMessages ();
1219 
1224  void SetupScenario ();
1225 
1230  void WriteCsvHeader ();
1231 
1236  void SetConfigFromGlobals ();
1237 
1242  void SetGlobalsFromConfig ();
1243 
1244  static void
1245  CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobility);
1246 
1247  uint32_t m_port;
1248  std::string m_CSVfileName;
1249  std::string m_CSVfileName2;
1250  uint32_t m_nSinks;
1251  std::string m_protocolName;
1252  double m_txp;
1254  uint32_t m_protocol;
1255 
1256  uint32_t m_lossModel;
1257  uint32_t m_fading;
1258  std::string m_lossModelName;
1259 
1260  std::string m_phyMode;
1261  uint32_t m_80211mode;
1262 
1263  std::string m_traceFile;
1264  std::string m_logFile;
1265  uint32_t m_mobility;
1266  uint32_t m_nNodes;
1268  std::string m_rate;
1269  std::string m_phyModeB;
1270  std::string m_trName;
1271  int m_nodeSpeed; //in m/s
1272  int m_nodePause; //in s
1273  uint32_t m_wavePacketSize; // bytes
1274  double m_waveInterval; // seconds
1276  std::ofstream m_os;
1279  uint32_t m_scenario;
1284  int m_pcap;
1287 
1291  int m_log;
1292  // used to get consistent random numbers across scenarios
1293  int64_t m_streamIndex;
1305  std::vector <double> m_txSafetyRanges;
1306  std::string m_exp;
1308 };
1309 
1311  : m_port (9),
1312  m_CSVfileName ("vanet-routing.output.csv"),
1313  m_CSVfileName2 ("vanet-routing.output2.csv"),
1314  m_nSinks (10),
1315  m_protocolName ("protocol"),
1316  m_txp (20),
1317  m_traceMobility (false),
1318  // AODV
1319  m_protocol (2),
1320  // Two-Ray ground
1321  m_lossModel (3),
1322  m_fading (0),
1323  m_lossModelName (""),
1324  m_phyMode ("OfdmRate6MbpsBW10MHz"),
1325  // 1=802.11p
1326  m_80211mode (1),
1327  m_traceFile (""),
1328  m_logFile ("low_ct-unterstrass-1day.filt.5.adj.log"),
1329  m_mobility (1),
1330  m_nNodes (156),
1331  m_TotalSimTime (300.01),
1332  m_rate ("2048bps"),
1333  m_phyModeB ("DsssRate11Mbps"),
1334  m_trName ("vanet-routing-compare"),
1335  m_nodeSpeed (20),
1336  m_nodePause (0),
1337  m_wavePacketSize (200),
1338  m_waveInterval (0.1),
1339  m_verbose (0),
1340  m_scenario (1),
1341  m_gpsAccuracyNs (40),
1342  m_txMaxDelayMs (10),
1343  m_routingTables (0),
1344  m_asciiTrace (0),
1345  m_pcap (0),
1346  m_loadConfigFilename ("load-config.txt"),
1347  m_saveConfigFilename (""),
1348  m_log (0),
1349  m_streamIndex (0),
1350  m_adhocTxNodes (),
1351  m_txSafetyRange1 (50.0),
1352  m_txSafetyRange2 (100.0),
1353  m_txSafetyRange3 (150.0),
1354  m_txSafetyRange4 (200.0),
1355  m_txSafetyRange5 (250.0),
1356  m_txSafetyRange6 (300.0),
1357  m_txSafetyRange7 (350.0),
1358  m_txSafetyRange8 (400.0),
1359  m_txSafetyRange9 (450.0),
1360  m_txSafetyRange10 (500.0),
1361  m_txSafetyRanges (),
1362  m_exp (""),
1363  m_cumulativeBsmCaptureStart (0)
1364 {
1365  m_wifiPhyStats = CreateObject<WifiPhyStats> ();
1366  m_routingHelper = CreateObject<RoutingHelper> ();
1367 
1368  // set to non-zero value to enable
1369  // simply uncond logging during simulation run
1370  m_log = 1;
1371 }
1372 
1373 void
1375 {
1376  // handled in constructor
1377 }
1378 
1379 // important configuration items stored in global values
1380 static ns3::GlobalValue g_port ("VRCport",
1381  "Port",
1382  ns3::UintegerValue (9),
1383  ns3::MakeUintegerChecker<uint32_t> ());
1384 static ns3::GlobalValue g_nSinks ("VRCnSinks",
1385  "Number of sink nodes for routing non-BSM traffic",
1386  ns3::UintegerValue (10),
1387  ns3::MakeUintegerChecker<uint32_t> ());
1388 static ns3::GlobalValue g_traceMobility ("VRCtraceMobility",
1389  "Trace mobility 1=yes;0=no",
1390  ns3::UintegerValue (0),
1391  ns3::MakeUintegerChecker<uint32_t> ());
1392 static ns3::GlobalValue g_protocol ("VRCprotocol",
1393  "Routing protocol",
1394  ns3::UintegerValue (2),
1395  ns3::MakeUintegerChecker<uint32_t> ());
1396 static ns3::GlobalValue g_lossModel ("VRClossModel",
1397  "Propagation Loss Model",
1398  ns3::UintegerValue (3),
1399  ns3::MakeUintegerChecker<uint32_t> ());
1400 static ns3::GlobalValue g_fading ("VRCfading",
1401  "Fast Fading Model",
1402  ns3::UintegerValue (0),
1403  ns3::MakeUintegerChecker<uint32_t> ());
1404 static ns3::GlobalValue g_80211mode ("VRC80211mode",
1405  "802.11 mode (0=802.11a;1=802.11p)",
1406  ns3::UintegerValue (1),
1407  ns3::MakeUintegerChecker<uint32_t> ());
1408 static ns3::GlobalValue g_mobility ("VRCmobility",
1409  "Mobility mode 0=random waypoint;1=mobility trace file",
1410  ns3::UintegerValue (1),
1411  ns3::MakeUintegerChecker<uint32_t> ());
1412 static ns3::GlobalValue g_nNodes ("VRCnNodes",
1413  "Number of nodes (vehicles)",
1414  ns3::UintegerValue (156),
1415  ns3::MakeUintegerChecker<uint32_t> ());
1416 static ns3::GlobalValue g_nodeSpeed ("VRCnodeSpeed",
1417  "Node speed (m/s) for RWP model",
1418  ns3::UintegerValue (20),
1419  ns3::MakeUintegerChecker<uint32_t> ());
1420 static ns3::GlobalValue g_nodePause ("VRCnodePause",
1421  "Node pause time (s) for RWP model",
1422  ns3::UintegerValue (0),
1423  ns3::MakeUintegerChecker<uint32_t> ());
1424 static ns3::GlobalValue g_wavePacketSize ("VRCwavePacketSize",
1425  "Size in bytes of WAVE BSM",
1426  ns3::UintegerValue (200),
1427  ns3::MakeUintegerChecker<uint32_t> ());
1428 static ns3::GlobalValue g_verbose ("VRCverbose",
1429  "Verbose 0=no;1=yes",
1430  ns3::UintegerValue (0),
1431  ns3::MakeUintegerChecker<uint32_t> ());
1432 static ns3::GlobalValue g_scenario ("VRCscenario",
1433  "Scenario",
1434  ns3::UintegerValue (1),
1435  ns3::MakeUintegerChecker<uint32_t> ());
1436 static ns3::GlobalValue g_routingTables ("VRCroutingTables",
1437  "Dump routing tables at t=5 seconds 0=no;1=yes",
1438  ns3::UintegerValue (0),
1439  ns3::MakeUintegerChecker<uint32_t> ());
1440 static ns3::GlobalValue g_asciiTrace ("VRCasciiTrace",
1441  "Dump ASCII trace 0=no;1=yes",
1442  ns3::UintegerValue (0),
1443  ns3::MakeUintegerChecker<uint32_t> ());
1444 static ns3::GlobalValue g_pcap ("VRCpcap",
1445  "Generate PCAP files 0=no;1=yes",
1446  ns3::UintegerValue (0),
1447  ns3::MakeUintegerChecker<uint32_t> ());
1448 static ns3::GlobalValue g_cumulativeBsmCaptureStart ("VRCcumulativeBsmCaptureStart",
1449  "Simulation starte time for capturing cumulative BSM",
1450  ns3::UintegerValue (0),
1451  ns3::MakeUintegerChecker<uint32_t> ());
1452 
1453 static ns3::GlobalValue g_txSafetyRange1 ("VRCtxSafetyRange1",
1454  "BSM range for PDR inclusion",
1455  ns3::DoubleValue (50.0),
1456  ns3::MakeDoubleChecker<double> ());
1457 
1458 static ns3::GlobalValue g_txSafetyRange2 ("VRCtxSafetyRange2",
1459  "BSM range for PDR inclusion",
1460  ns3::DoubleValue (100.0),
1461  ns3::MakeDoubleChecker<double> ());
1462 
1463 static ns3::GlobalValue g_txSafetyRange3 ("VRCtxSafetyRange3",
1464  "BSM range for PDR inclusion",
1465  ns3::DoubleValue (150.0),
1466  ns3::MakeDoubleChecker<double> ());
1467 
1468 static ns3::GlobalValue g_txSafetyRange4 ("VRCtxSafetyRange4",
1469  "BSM range for PDR inclusion",
1470  ns3::DoubleValue (200.0),
1471  ns3::MakeDoubleChecker<double> ());
1472 
1473 static ns3::GlobalValue g_txSafetyRange5 ("VRCtxSafetyRange5",
1474  "BSM range for PDR inclusion",
1475  ns3::DoubleValue (250.0),
1476  ns3::MakeDoubleChecker<double> ());
1477 static ns3::GlobalValue g_txSafetyRange6 ("VRCtxSafetyRange6",
1478  "BSM range for PDR inclusion",
1479  ns3::DoubleValue (300.0),
1480  ns3::MakeDoubleChecker<double> ());
1481 static ns3::GlobalValue g_txSafetyRange7 ("VRCtxSafetyRange7",
1482  "BSM range for PDR inclusion",
1483  ns3::DoubleValue (350.0),
1484  ns3::MakeDoubleChecker<double> ());
1485 static ns3::GlobalValue g_txSafetyRange8 ("VRCtxSafetyRange8",
1486  "BSM range for PDR inclusion",
1487  ns3::DoubleValue (400.0),
1488  ns3::MakeDoubleChecker<double> ());
1489 static ns3::GlobalValue g_txSafetyRange9 ("VRCtxSafetyRange9",
1490  "BSM range for PDR inclusion",
1491  ns3::DoubleValue (450.0),
1492  ns3::MakeDoubleChecker<double> ());
1493 static ns3::GlobalValue g_txSafetyRange10 ("VRCtxSafetyRange10",
1494  "BSM range for PDR inclusion",
1495  ns3::DoubleValue (500.0),
1496  ns3::MakeDoubleChecker<double> ());
1497 static ns3::GlobalValue g_txp ("VRCtxp",
1498  "Transmission power dBm",
1499  ns3::DoubleValue (7.5),
1500  ns3::MakeDoubleChecker<double> ());
1501 static ns3::GlobalValue g_totalTime ("VRCtotalTime",
1502  "Total simulation time (s)",
1503  ns3::DoubleValue (300.01),
1504  ns3::MakeDoubleChecker<double> ());
1505 static ns3::GlobalValue g_waveInterval ("VRCwaveInterval",
1506  "Interval (s) between WAVE BSMs",
1507  ns3::DoubleValue (0.1),
1508  ns3::MakeDoubleChecker<double> ());
1509 static ns3::GlobalValue g_gpsAccuracyNs ("VRCgpsAccuracyNs",
1510  "GPS sync accuracy (ns)",
1511  ns3::DoubleValue (40),
1512  ns3::MakeDoubleChecker<double> ());
1513 static ns3::GlobalValue g_txMaxDelayMs ("VRCtxMaxDelayMs",
1514  "Tx May Delay (ms)",
1515  ns3::DoubleValue (10),
1516  ns3::MakeDoubleChecker<double> ());
1517 static ns3::GlobalValue g_CSVfileName ("VRCCSVfileName",
1518  "CSV filename (for time series data)",
1519  ns3::StringValue ("vanet-routing.output.csv"),
1521 static ns3::GlobalValue g_CSVfileName2 ("VRCCSVfileName2",
1522  "CSV filename 2 (for overall simulation scenario results)",
1523  ns3::StringValue ("vanet-routing.output2.csv"),
1525 static ns3::GlobalValue g_phyMode ("VRCphyMode",
1526  "PHY mode (802.11p)",
1527  ns3::StringValue ("OfdmRate6MbpsBW10MHz"),
1529 static ns3::GlobalValue g_traceFile ("VRCtraceFile",
1530  "Mobility trace filename",
1531  ns3::StringValue ("./src/wave/examples/low_ct-unterstrass-1day.filt.5.adj.mob"),
1533 static ns3::GlobalValue g_logFile ("VRClogFile",
1534  "Log filename",
1535  ns3::StringValue ("low_ct-unterstrass-1day.filt.5.adj.log"),
1537 static ns3::GlobalValue g_rate ("VRCrate",
1538  "Data rate",
1539  ns3::StringValue ("2048bps"),
1541 static ns3::GlobalValue g_phyModeB ("VRCphyModeB",
1542  "PHY mode (802.11a)",
1543  ns3::StringValue ("DsssRate11Mbps"),
1545 static ns3::GlobalValue g_trName ("VRCtrName",
1546  "Trace name",
1547  ns3::StringValue ("vanet-routing-compare"),
1549 
1550 void
1552 {
1553  CommandSetup (argc, argv);
1554  SetupScenario ();
1555 
1556  // user may specify up to 10 different tx distances
1557  // to be used for calculating different values of Packet
1558  // Delivery Ratio (PDR). Used to see the effects of
1559  // fading over distance
1560  m_txSafetyRanges.resize (10, 0);
1571 
1572  ConfigureDefaults ();
1573 
1574  // we are done with all configuration
1575  // save config-store, if requested
1577  ConfigStoreHelper configStoreHelper;
1578  configStoreHelper.SaveConfig (m_saveConfigFilename);
1579 
1580  m_waveBsmHelper.GetWaveBsmStats ()->SetLogging (m_log);
1582 }
1583 
1584 void
1586 {
1588 }
1589 
1590 void
1592 {
1593  // set up channel and devices
1594  SetupAdhocDevices ();
1595 }
1596 
1597 void
1599 {
1600  // devices are set up in SetupAdhocDevices(),
1601  // called by ConfigureChannels()
1602 
1603  // every device will have PHY callback for tracing
1604  // which is used to determine the total amount of
1605  // data transmitted, and then used to calculate
1606  // the MAC/PHY overhead beyond the app-data
1607  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&WifiPhyStats::PhyTxTrace, m_wifiPhyStats));
1608  // TxDrop, RxDrop not working yet. Not sure what I'm doing wrong.
1609  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback (&WifiPhyStats::PhyTxDrop, m_wifiPhyStats));
1610  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback (&WifiPhyStats::PhyRxDrop, m_wifiPhyStats));
1611 }
1612 
1613 void
1615 {
1617 }
1618 
1619 void
1621 {
1622  // Traffic mix consists of:
1623  // 1. routing data
1624  // 2. Broadcasting of Basic Safety Message (BSM)
1626  SetupWaveMessages ();
1627 
1628  // config trace to capture app-data (bytes) for
1629  // routing data, subtracted and used for
1630  // routing overhead
1631  std::ostringstream oss;
1632  oss.str ("");
1633  oss << "/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx";
1635 }
1636 
1637 void
1639 {
1640  WriteCsvHeader ();
1641  SetupLogFile ();
1642  SetupLogging ();
1643 
1644  AsciiTraceHelper ascii;
1645  MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (m_trName + ".mob"));
1646 }
1647 
1648 void
1650 {
1651  Run ();
1652 }
1653 
1654 void
1656 {
1657  // calculate and output final results
1658  double bsm_pdr1 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (1);
1659  double bsm_pdr2 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (2);
1660  double bsm_pdr3 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (3);
1661  double bsm_pdr4 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (4);
1662  double bsm_pdr5 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (5);
1663  double bsm_pdr6 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (6);
1664  double bsm_pdr7 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (7);
1665  double bsm_pdr8 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (8);
1666  double bsm_pdr9 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (9);
1667  double bsm_pdr10 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (10);
1668 
1669  double averageRoutingGoodputKbps = 0.0;
1670  uint32_t totalBytesTotal = m_routingHelper->GetRoutingStats ().GetCumulativeRxBytes ();
1671  averageRoutingGoodputKbps = (((double) totalBytesTotal * 8.0) / m_TotalSimTime) / 1000.0;
1672 
1673  // calculate MAC/PHY overhead (mac-phy-oh)
1674  // total WAVE BSM bytes sent
1675  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1676  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1677  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1678  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1679  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1680  double mac_phy_oh = 0.0;
1681  if (totalPhyBytes > 0)
1682  {
1683  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1684  }
1685 
1686  if (m_log != 0)
1687  {
1688  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);
1689 
1690  }
1691 
1692  std::ofstream out (m_CSVfileName2.c_str (), std::ios::app);
1693 
1694  out << bsm_pdr1 << ","
1695  << bsm_pdr2 << ","
1696  << bsm_pdr3 << ","
1697  << bsm_pdr4 << ","
1698  << bsm_pdr5 << ","
1699  << bsm_pdr6 << ","
1700  << bsm_pdr7 << ","
1701  << bsm_pdr8 << ","
1702  << bsm_pdr9 << ","
1703  << bsm_pdr10 << ","
1704  << averageRoutingGoodputKbps << ","
1705  << mac_phy_oh << ""
1706  << std::endl;
1707 
1708  out.close ();
1709 
1710  m_os.close (); // close log file
1711 }
1712 
1713 void
1715 {
1716  NS_LOG_INFO ("Run Simulation.");
1717 
1718  CheckThroughput ();
1719 
1720  Simulator::Stop (Seconds (m_TotalSimTime));
1721  Simulator::Run ();
1722  Simulator::Destroy ();
1723 }
1724 
1725 // Prints actual position and velocity when a course change event occurs
1726 void
1728 CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobility)
1729 {
1730  Vector pos = mobility->GetPosition (); // Get position
1731  Vector vel = mobility->GetVelocity (); // Get velocity
1732 
1733  pos.z = 1.5;
1734 
1735  int nodeId = mobility->GetObject<Node> ()->GetId ();
1736  double t = (Simulator::Now ()).GetSeconds ();
1737  if (t >= 1.0)
1738  {
1739  WaveBsmHelper::GetNodesMoving ()[nodeId] = 1;
1740  }
1741 
1742  //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::Now () );
1743 
1744  // Prints position and velocities
1745  *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y
1746  << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
1747  << ", z=" << vel.z << std::endl;
1748 }
1749 
1750 void
1752 {
1753  uint32_t bytesTotal = m_routingHelper->GetRoutingStats ().GetRxBytes ();
1754  uint32_t packetsReceived = m_routingHelper->GetRoutingStats ().GetRxPkts ();
1755  double kbps = (bytesTotal * 8.0) / 1000;
1756  double wavePDR = 0.0;
1757  int wavePktsSent = m_waveBsmHelper.GetWaveBsmStats ()->GetTxPktCount ();
1758  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1759  if (wavePktsSent > 0)
1760  {
1761  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1762  wavePDR = (double) wavePktsReceived / (double) wavePktsSent;
1763  }
1764 
1765  int waveExpectedRxPktCount = m_waveBsmHelper.GetWaveBsmStats ()->GetExpectedRxPktCount (1);
1766  int waveRxPktInRangeCount = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktInRangeCount (1);
1767  double wavePDR1_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (1);
1768  double wavePDR2_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (2);
1769  double wavePDR3_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (3);
1770  double wavePDR4_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (4);
1771  double wavePDR5_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (5);
1772  double wavePDR6_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (6);
1773  double wavePDR7_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (7);
1774  double wavePDR8_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (8);
1775  double wavePDR9_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (9);
1776  double wavePDR10_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (10);
1777 
1778  // calculate MAC/PHY overhead (mac-phy-oh)
1779  // total WAVE BSM bytes sent
1780  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1781  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1782  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1783  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1784  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1785  double mac_phy_oh = 0.0;
1786  if (totalPhyBytes > 0)
1787  {
1788  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1789  }
1790 
1791  std::ofstream out (m_CSVfileName.c_str (), std::ios::app);
1792 
1793  if (m_log != 0 )
1794  {
1795  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*/);
1796  }
1797 
1798  out << (Simulator::Now ()).GetSeconds () << ","
1799  << kbps << ","
1800  << packetsReceived << ","
1801  << m_nSinks << ","
1802  << m_protocolName << ","
1803  << m_txp << ","
1804  << wavePktsSent << ","
1805  << wavePktsReceived << ","
1806  << wavePDR << ","
1807  << waveExpectedRxPktCount << ","
1808  << waveRxPktInRangeCount << ","
1809  << wavePDR1_2 << ","
1810  << wavePDR2_2 << ","
1811  << wavePDR3_2 << ","
1812  << wavePDR4_2 << ","
1813  << wavePDR5_2 << ","
1814  << wavePDR6_2 << ","
1815  << wavePDR7_2 << ","
1816  << wavePDR8_2 << ","
1817  << wavePDR9_2 << ","
1818  << wavePDR10_2 << ","
1819  << mac_phy_oh << ""
1820  << std::endl;
1821 
1822  out.close ();
1823 
1826  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktCount (0);
1827  m_waveBsmHelper.GetWaveBsmStats ()->SetTxPktCount (0);
1828  for (int index = 1; index <= 10; index++)
1829  {
1830  m_waveBsmHelper.GetWaveBsmStats ()->SetExpectedRxPktCount (index, 0);
1831  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktInRangeCount (index, 0);
1832  }
1833 
1834  double currentTime = (Simulator::Now ()).GetSeconds ();
1835  if (currentTime <= (double) m_cumulativeBsmCaptureStart)
1836  {
1837  for (int index = 1; index <= 10; index++)
1838  {
1839  m_waveBsmHelper.GetWaveBsmStats ()->ResetTotalRxPktCounts (index);
1840  }
1841  }
1842 
1843  Simulator::Schedule (Seconds (1.0), &VanetRoutingExperiment::CheckThroughput, this);
1844 }
1845 
1846 void
1848 {
1849  // get settings saved from config-store
1850  UintegerValue uintegerValue;
1851  DoubleValue doubleValue;
1852  StringValue stringValue;
1853 
1854  // This may not be the best way to manage program configuration
1855  // (directing them through global values), but management
1856  // through the config-store here is copied from
1857  // src/lte/examples/lena-dual-stripe.cc
1858 
1859  GlobalValue::GetValueByName ("VRCport", uintegerValue);
1860  m_port = uintegerValue.Get ();
1861  GlobalValue::GetValueByName ("VRCnSinks", uintegerValue);
1862  m_nSinks = uintegerValue.Get ();
1863  GlobalValue::GetValueByName ("VRCtraceMobility", uintegerValue);
1864  m_traceMobility = uintegerValue.Get ();
1865  GlobalValue::GetValueByName ("VRCprotocol", uintegerValue);
1866  m_protocol = uintegerValue.Get ();
1867  GlobalValue::GetValueByName ("VRClossModel", uintegerValue);
1868  m_lossModel = uintegerValue.Get ();
1869  GlobalValue::GetValueByName ("VRCfading", uintegerValue);
1870  m_fading = uintegerValue.Get ();
1871  GlobalValue::GetValueByName ("VRC80211mode", uintegerValue);
1872  m_80211mode = uintegerValue.Get ();
1873  GlobalValue::GetValueByName ("VRCmobility", uintegerValue);
1874  m_mobility = uintegerValue.Get ();
1875  GlobalValue::GetValueByName ("VRCnNodes", uintegerValue);
1876  m_nNodes = uintegerValue.Get ();
1877  GlobalValue::GetValueByName ("VRCnodeSpeed", uintegerValue);
1878  m_nodeSpeed = uintegerValue.Get ();
1879  GlobalValue::GetValueByName ("VRCnodePause", uintegerValue);
1880  m_nodePause = uintegerValue.Get ();
1881  GlobalValue::GetValueByName ("VRCwavePacketSize", uintegerValue);
1882  m_wavePacketSize = uintegerValue.Get ();
1883  GlobalValue::GetValueByName ("VRCverbose", uintegerValue);
1884  m_verbose = uintegerValue.Get ();
1885  GlobalValue::GetValueByName ("VRCscenario", uintegerValue);
1886  m_scenario = uintegerValue.Get ();
1887  GlobalValue::GetValueByName ("VRCroutingTables", uintegerValue);
1888  m_routingTables = uintegerValue.Get ();
1889  GlobalValue::GetValueByName ("VRCasciiTrace", uintegerValue);
1890  m_asciiTrace = uintegerValue.Get ();
1891  GlobalValue::GetValueByName ("VRCpcap", uintegerValue);
1892  m_pcap = uintegerValue.Get ();
1893  GlobalValue::GetValueByName ("VRCcumulativeBsmCaptureStart", uintegerValue);
1894  m_cumulativeBsmCaptureStart = uintegerValue.Get ();
1895 
1896  GlobalValue::GetValueByName ("VRCtxSafetyRange1", doubleValue);
1897  m_txSafetyRange1 = doubleValue.Get ();
1898  GlobalValue::GetValueByName ("VRCtxSafetyRange2", doubleValue);
1899  m_txSafetyRange2 = doubleValue.Get ();
1900  GlobalValue::GetValueByName ("VRCtxSafetyRange3", doubleValue);
1901  m_txSafetyRange3 = doubleValue.Get ();
1902  GlobalValue::GetValueByName ("VRCtxSafetyRange4", doubleValue);
1903  m_txSafetyRange4 = doubleValue.Get ();
1904  GlobalValue::GetValueByName ("VRCtxSafetyRange5", doubleValue);
1905  m_txSafetyRange5 = doubleValue.Get ();
1906  GlobalValue::GetValueByName ("VRCtxSafetyRange6", doubleValue);
1907  m_txSafetyRange6 = doubleValue.Get ();
1908  GlobalValue::GetValueByName ("VRCtxSafetyRange7", doubleValue);
1909  m_txSafetyRange7 = doubleValue.Get ();
1910  GlobalValue::GetValueByName ("VRCtxSafetyRange8", doubleValue);
1911  m_txSafetyRange8 = doubleValue.Get ();
1912  GlobalValue::GetValueByName ("VRCtxSafetyRange9", doubleValue);
1913  m_txSafetyRange9 = doubleValue.Get ();
1914  GlobalValue::GetValueByName ("VRCtxSafetyRange10", doubleValue);
1915  m_txSafetyRange10 = doubleValue.Get ();
1916  GlobalValue::GetValueByName ("VRCtxp", doubleValue);
1917  m_txp = doubleValue.Get ();
1918  GlobalValue::GetValueByName ("VRCtotalTime", doubleValue);
1919  m_TotalSimTime = doubleValue.Get ();
1920  GlobalValue::GetValueByName ("VRCwaveInterval", doubleValue);
1921  m_waveInterval = doubleValue.Get ();
1922  GlobalValue::GetValueByName ("VRCgpsAccuracyNs", doubleValue);
1923  m_gpsAccuracyNs = doubleValue.Get ();
1924  GlobalValue::GetValueByName ("VRCtxMaxDelayMs", doubleValue);
1925  m_txMaxDelayMs = doubleValue.Get ();
1926 
1927  GlobalValue::GetValueByName ("VRCCSVfileName", stringValue);
1928  m_CSVfileName = stringValue.Get ();
1929  GlobalValue::GetValueByName ("VRCCSVfileName2", stringValue);
1930  m_CSVfileName2 = stringValue.Get ();
1931  GlobalValue::GetValueByName ("VRCphyMode", stringValue);
1932  m_phyMode = stringValue.Get ();
1933  GlobalValue::GetValueByName ("VRCtraceFile", stringValue);
1934  m_traceFile = stringValue.Get ();
1935  GlobalValue::GetValueByName ("VRClogFile", stringValue);
1936  m_logFile = stringValue.Get ();
1937  GlobalValue::GetValueByName ("VRCrate", stringValue);
1938  m_rate = stringValue.Get ();
1939  GlobalValue::GetValueByName ("VRCphyModeB", stringValue);
1940  m_phyModeB = stringValue.Get ();
1941  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1942  m_trName = stringValue.Get ();
1943 }
1944 
1945 void
1947 {
1948  // get settings saved from config-store
1949  UintegerValue uintegerValue;
1950  DoubleValue doubleValue;
1951  StringValue stringValue;
1952 
1971 
1987 
1996  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1997  m_trName = stringValue.Get ();
1998 }
1999 
2000 void
2002 {
2003  CommandLine cmd;
2004  double txDist1 = 50.0;
2005  double txDist2 = 100.0;
2006  double txDist3 = 150.0;
2007  double txDist4 = 200.0;
2008  double txDist5 = 250.0;
2009  double txDist6 = 300.0;
2010  double txDist7 = 350.0;
2011  double txDist8 = 350.0;
2012  double txDist9 = 350.0;
2013  double txDist10 = 350.0;
2014 
2015  // allow command line overrides
2016  cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName);
2017  cmd.AddValue ("CSVfileName2", "The name of the CSV output file name2", m_CSVfileName2);
2018  cmd.AddValue ("totaltime", "Simulation end time", m_TotalSimTime);
2019  cmd.AddValue ("nodes", "Number of nodes (i.e. vehicles)", m_nNodes);
2020  cmd.AddValue ("sinks", "Number of routing sinks", m_nSinks);
2021  cmd.AddValue ("txp", "Transmit power (dB), e.g. txp=7.5", m_txp);
2022  cmd.AddValue ("traceMobility", "Enable mobility tracing", m_traceMobility);
2023  cmd.AddValue ("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol);
2024  cmd.AddValue ("lossModel", "1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance", m_lossModel);
2025  cmd.AddValue ("fading", "0=None;1=Nakagami;(buildings=1 overrides)", m_fading);
2026  cmd.AddValue ("phyMode", "Wifi Phy mode", m_phyMode);
2027  cmd.AddValue ("80211Mode", "1=802.11p; 2=802.11b; 3=WAVE-PHY", m_80211mode);
2028  cmd.AddValue ("traceFile", "Ns2 movement trace file", m_traceFile);
2029  cmd.AddValue ("logFile", "Log file", m_logFile);
2030  cmd.AddValue ("mobility", "1=trace;2=RWP", m_mobility);
2031  cmd.AddValue ("rate", "Rate", m_rate);
2032  cmd.AddValue ("phyModeB", "Phy mode 802.11b", m_phyModeB);
2033  cmd.AddValue ("speed", "Node speed (m/s)", m_nodeSpeed);
2034  cmd.AddValue ("pause", "Node pause (s)", m_nodePause);
2035  cmd.AddValue ("verbose", "0=quiet;1=verbose", m_verbose);
2036  cmd.AddValue ("bsm", "(WAVE) BSM size (bytes)", m_wavePacketSize);
2037  cmd.AddValue ("interval", "(WAVE) BSM interval (s)", m_waveInterval);
2038  cmd.AddValue ("scenario", "1=synthetic, 2=playback-trace", m_scenario);
2039  // User is allowed to have up to 10 different PDRs (Packet
2040  // Delivery Ratios) calculate, and so can specify up to
2041  // 10 different tx distances.
2042  cmd.AddValue ("txdist1", "Expected BSM tx range, m", txDist1);
2043  cmd.AddValue ("txdist2", "Expected BSM tx range, m", txDist2);
2044  cmd.AddValue ("txdist3", "Expected BSM tx range, m", txDist3);
2045  cmd.AddValue ("txdist4", "Expected BSM tx range, m", txDist4);
2046  cmd.AddValue ("txdist5", "Expected BSM tx range, m", txDist5);
2047  cmd.AddValue ("txdist6", "Expected BSM tx range, m", txDist6);
2048  cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7);
2049  cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8);
2050  cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9);
2051  cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10);
2052  cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs);
2053  cmd.AddValue ("txmaxdelay", "Tx max delay, in ms", m_txMaxDelayMs);
2054  cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routingTables);
2055  cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace);
2056  cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap);
2057  cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilename);
2058  cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilename);
2059  cmd.AddValue ("exp", "Experiment", m_exp);
2060  cmd.AddValue ("BsmCaptureStart", "Start time to begin capturing pkts for cumulative Bsm", m_cumulativeBsmCaptureStart);
2061  cmd.Parse (argc, argv);
2062 
2063  m_txSafetyRange1 = txDist1;
2064  m_txSafetyRange2 = txDist2;
2065  m_txSafetyRange3 = txDist3;
2066  m_txSafetyRange4 = txDist4;
2067  m_txSafetyRange5 = txDist5;
2068  m_txSafetyRange6 = txDist6;
2069  m_txSafetyRange7 = txDist7;
2070  m_txSafetyRange8 = txDist8;
2071  m_txSafetyRange9 = txDist9;
2072  m_txSafetyRange10 = txDist10;
2073  // load configuration info from config-store
2074  ConfigStoreHelper configStoreHelper;
2075  configStoreHelper.LoadConfig (m_loadConfigFilename);
2076  // transfer config-store values to config parameters
2078 
2079  // parse again so you can override input file default values via command line
2080  cmd.Parse (argc, argv);
2081 
2082  m_txSafetyRange1 = txDist1;
2083  m_txSafetyRange2 = txDist2;
2084  m_txSafetyRange3 = txDist3;
2085  m_txSafetyRange4 = txDist4;
2086  m_txSafetyRange5 = txDist5;
2087  m_txSafetyRange6 = txDist6;
2088  m_txSafetyRange7 = txDist7;
2089  m_txSafetyRange8 = txDist8;
2090  m_txSafetyRange9 = txDist9;
2091  m_txSafetyRange10 = txDist10;
2092 }
2093 
2094 void
2096 {
2097  // open log file for output
2098  m_os.open (m_logFile.c_str ());
2099 }
2100 
2102 {
2103 
2104  // Enable logging from the ns2 helper
2105  LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
2106 
2107  Packet::EnablePrinting ();
2108 }
2109 
2110 void
2112 {
2113  Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64"));
2114  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (m_rate));
2115 
2116  //Set Non-unicastMode rate to unicast mode
2117  if (m_80211mode == 2)
2118  {
2119  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyModeB));
2120  }
2121  else
2122  {
2123  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyMode));
2124  }
2125 }
2126 
2127 void
2129 {
2130  if (m_mobility == 1)
2131  {
2132  // Create Ns2MobilityHelper with the specified trace log file as parameter
2134  ns2.Install (); // configure movements for each node, while reading trace file
2135  // initially assume all nodes are not moving
2136  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 0);
2137  }
2138  else if (m_mobility == 2)
2139  {
2140  MobilityHelper mobilityAdhoc;
2141 
2142  ObjectFactory pos;
2143  pos.SetTypeId ("ns3::RandomBoxPositionAllocator");
2144  pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
2145  pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
2146  // we need antenna height uniform [1.0 .. 2.0] for loss model
2147  pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"));
2148 
2149  Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
2150  m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex);
2151 
2152  std::stringstream ssSpeed;
2153  ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]";
2154  std::stringstream ssPause;
2155  ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]";
2156  mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
2157  "Speed", StringValue (ssSpeed.str ()),
2158  "Pause", StringValue (ssPause.str ()),
2159  "PositionAllocator", PointerValue (taPositionAlloc));
2160  mobilityAdhoc.SetPositionAllocator (taPositionAlloc);
2161  mobilityAdhoc.Install (m_adhocTxNodes);
2162  m_streamIndex += mobilityAdhoc.AssignStreams (m_adhocTxNodes, m_streamIndex);
2163 
2164  // initially assume all nodes are moving
2165  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 1);
2166  }
2167 
2168  // Configure callback for logging
2169  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2171 }
2172 
2173 void
2175 {
2176  if (m_lossModel == 1)
2177  {
2178  m_lossModelName = "ns3::FriisPropagationLossModel";
2179  }
2180  else if (m_lossModel == 2)
2181  {
2182  m_lossModelName = "ns3::ItuR1411LosPropagationLossModel";
2183  }
2184  else if (m_lossModel == 3)
2185  {
2186  m_lossModelName = "ns3::TwoRayGroundPropagationLossModel";
2187  }
2188  else if (m_lossModel == 4)
2189  {
2190  m_lossModelName = "ns3::LogDistancePropagationLossModel";
2191  }
2192  else
2193  {
2194  // Unsupported propagation loss model.
2195  // Treating as ERROR
2196  NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance");
2197  }
2198 
2199  // frequency
2200  double freq = 0.0;
2201  if ((m_80211mode == 1)
2202  || (m_80211mode == 3))
2203  {
2204  // 802.11p 5.9 GHz
2205  freq = 5.9e9;
2206  }
2207  else
2208  {
2209  // 802.11b 2.4 GHz
2210  freq = 2.4e9;
2211  }
2212 
2213  // Setup propagation models
2214  YansWifiChannelHelper wifiChannel;
2215  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
2216  if (m_lossModel == 3)
2217  {
2218  // two-ray requires antenna height (else defaults to Friss)
2219  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq), "HeightAboveZ", DoubleValue (1.5));
2220  }
2221  else
2222  {
2223  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq));
2224  }
2225 
2226  // Propagation loss models are additive.
2227  if (m_fading != 0)
2228  {
2229  // if no obstacle model, then use Nakagami fading if requested
2230  wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
2231  }
2232 
2233  // the channel
2234  Ptr<YansWifiChannel> channel = wifiChannel.Create ();
2235 
2236  // The below set of helpers will help us to put together the wifi NICs we want
2237  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
2238  wifiPhy.SetChannel (channel);
2239  // ns-3 supports generate a pcap trace
2240  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2241 
2242  YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
2243  wavePhy.SetChannel (channel);
2244  wavePhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2245 
2246  // Setup WAVE PHY and MAC
2247  NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
2248  WaveHelper waveHelper = WaveHelper::Default ();
2249  Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
2250  if (m_verbose)
2251  {
2252  wifi80211p.EnableLogComponents (); // Turn on all Wifi 802.11p logging
2253  // likewise, turn on WAVE PHY logging
2254  waveHelper.EnableLogComponents ();
2255  }
2256 
2257  WifiHelper wifi;
2258 
2259  // Setup 802.11b stuff
2261 
2262  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2263  "DataMode",StringValue (m_phyModeB),
2264  "ControlMode",StringValue (m_phyModeB));
2265 
2266  // Setup 802.11p stuff
2267  wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2268  "DataMode",StringValue (m_phyMode),
2269  "ControlMode",StringValue (m_phyMode));
2270 
2271  // Setup WAVE-PHY stuff
2272  waveHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2273  "DataMode",StringValue (m_phyMode),
2274  "ControlMode",StringValue (m_phyMode));
2275 
2276  // Set Tx Power
2277  wifiPhy.Set ("TxPowerStart",DoubleValue (m_txp));
2278  wifiPhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2279  wavePhy.Set ("TxPowerStart",DoubleValue (m_txp));
2280  wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2281 
2282  // Add a non-QoS upper mac, and disable rate control
2283  NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
2284  wifiMac.SetType ("ns3::AdhocWifiMac");
2285  QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
2286 
2287  // Setup net devices
2288 
2289  if (m_80211mode == 3)
2290  {
2291  m_adhocTxDevices = waveHelper.Install (wavePhy, waveMac, m_adhocTxNodes);
2292  }
2293  else if (m_80211mode == 1)
2294  {
2295  m_adhocTxDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, m_adhocTxNodes);
2296  }
2297  else
2298  {
2299  m_adhocTxDevices = wifi.Install (wifiPhy, wifiMac, m_adhocTxNodes);
2300  }
2301 
2302  if (m_asciiTrace != 0)
2303  {
2304  AsciiTraceHelper ascii;
2305  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (m_trName + ".tr").c_str ());
2306  wifiPhy.EnableAsciiAll (osw);
2307  wavePhy.EnableAsciiAll (osw);
2308  }
2309  if (m_pcap != 0)
2310  {
2311  wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap");
2312  wavePhy.EnablePcapAll ("vanet-routing-compare-pcap");
2313  }
2314 }
2315 
2316 void
2318 {
2319  // WAVE PHY mode
2320  // 0=continuous channel; 1=channel-switching
2321  int chAccessMode = 0;
2322  if (m_80211mode == 3)
2323  {
2324  chAccessMode = 1;
2325  }
2326 
2331  // GPS accuracy (i.e, clock drift), in number of ns
2334  chAccessMode,
2335  // tx max delay before transmit, in ms
2337 
2338  // fix random number streams
2340 }
2341 
2342 void
2344 {
2349  m_protocol,
2350  m_nSinks,
2351  m_routingTables);
2352 }
2353 
2354 void
2356 {
2357  // member variable parameter use
2358  // defaults or command line overrides,
2359  // except where scenario={1,2,3,...}
2360  // have been specified, in which case
2361  // specify parameters are overwritten
2362  // here to setup for specific scenarios
2363 
2364  // certain parameters may be further overridden
2365  // i.e. specify a scenario, override tx power.
2366 
2367  if (m_scenario == 1)
2368  {
2369  // 40 nodes in RWP 300 m x 1500 m synthetic highway, 10s
2370  m_traceFile = "";
2371  m_logFile = "";
2372  m_mobility = 2;
2373  if (m_nNodes == 156)
2374  {
2375  m_nNodes = 40;
2376  }
2377  if (m_TotalSimTime == 300.01)
2378  {
2379  m_TotalSimTime = 10.0;
2380  }
2381  }
2382  else if (m_scenario == 2)
2383  {
2384  // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
2385  // "low density, 99 total vehicles"
2386  m_traceFile = "src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob";
2387  m_logFile = "low99-ct-unterstrass-1day.filt.7.adj.log";
2388  m_mobility = 1;
2389  m_nNodes = 99;
2390  m_TotalSimTime = 300.01;
2391  m_nodeSpeed = 0;
2392  m_nodePause = 0;
2393  m_CSVfileName = "low_vanet-routing-compare.csv";
2394  m_CSVfileName = "low_vanet-routing-compare2.csv";
2395  }
2396 }
2397 
2398 void
2400 {
2401  //blank out the last output file and write the column headers
2402  std::ofstream out (m_CSVfileName.c_str ());
2403  out << "SimulationSecond," <<
2404  "ReceiveRate," <<
2405  "PacketsReceived," <<
2406  "NumberOfSinks," <<
2407  "RoutingProtocol," <<
2408  "TransmissionPower," <<
2409  "WavePktsSent," <<
2410  "WavePtksReceived," <<
2411  "WavePktsPpr," <<
2412  "ExpectedWavePktsReceived," <<
2413  "ExpectedWavePktsInCoverageReceived," <<
2414  "BSM_PDR1," <<
2415  "BSM_PDR2," <<
2416  "BSM_PDR3," <<
2417  "BSM_PDR4," <<
2418  "BSM_PDR5," <<
2419  "BSM_PDR6," <<
2420  "BSM_PDR7," <<
2421  "BSM_PDR8," <<
2422  "BSM_PDR9," <<
2423  "BSM_PDR10," <<
2424  "MacPhyOverhead" <<
2425  std::endl;
2426  out.close ();
2427 
2428  std::ofstream out2 (m_CSVfileName2.c_str ());
2429  out2 << "BSM_PDR1,"
2430  << "BSM_PDR2,"
2431  << "BSM_PDR3,"
2432  << "BSM_PDR4,"
2433  << "BSM_PDR5,"
2434  << "BSM_PDR6,"
2435  << "BSM_PDR7,"
2436  << "BSM_PDR8,"
2437  << "BSM_PDR9,"
2438  << "BSM_PDR10,"
2439  << "AverageRoutingGoodputKbps,"
2440  << "MacPhyOverhead"
2441  << std::endl;
2442  out2.close ();
2443 }
2444 
2445 int
2446 main (int argc, char *argv[])
2447 {
2449  experiment.Simulate (argc, argv);
2450 }
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:552
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:95
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:1487
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:867
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:48
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:738
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:482
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:327
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:436
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:1290
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:127
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
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
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:677
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:106
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:529
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:859
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:51
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:631
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...