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/aodv-module.h"
109 #include "ns3/olsr-module.h"
110 #include "ns3/dsdv-module.h"
111 #include "ns3/dsr-module.h"
112 #include "ns3/applications-module.h"
113 #include "ns3/itu-r-1411-los-propagation-loss-model.h"
114 #include "ns3/ocb-wifi-mac.h"
115 #include "ns3/wifi-80211p-helper.h"
116 #include "ns3/wave-mac-helper.h"
117 #include "ns3/flow-monitor-module.h"
118 #include "ns3/config-store-module.h"
119 #include "ns3/integer.h"
120 #include "ns3/wave-bsm-helper.h"
121 #include "ns3/wave-helper.h"
122 #include "ns3/yans-wifi-helper.h"
123 
124 using namespace ns3;
125 using namespace dsr;
126 
127 NS_LOG_COMPONENT_DEFINE ("vanet-routing-compare");
128 
136 {
137 public:
142  RoutingStats ();
143 
148  uint32_t GetRxBytes ();
149 
154  uint32_t GetCumulativeRxBytes ();
155 
160  uint32_t GetRxPkts ();
161 
166  uint32_t GetCumulativeRxPkts ();
167 
174  void IncRxBytes (uint32_t rxBytes);
175 
180  void IncRxPkts ();
181 
187  void SetRxBytes (uint32_t rxBytes);
188 
194  void SetRxPkts (uint32_t rxPkts);
195 
200  uint32_t GetTxBytes ();
201 
206  uint32_t GetCumulativeTxBytes ();
207 
212  uint32_t GetTxPkts ();
213 
218  uint32_t GetCumulativeTxPkts ();
219 
225  void IncTxBytes (uint32_t txBytes);
226 
231  void IncTxPkts ();
232 
238  void SetTxBytes (uint32_t txBytes);
239 
245  void SetTxPkts (uint32_t txPkts);
246 
247 private:
248  uint32_t m_RxBytes;
250  uint32_t m_RxPkts;
252  uint32_t m_TxBytes;
254  uint32_t m_TxPkts;
256 };
257 
259  : m_RxBytes (0),
260  m_cumulativeRxBytes (0),
261  m_RxPkts (0),
262  m_cumulativeRxPkts (0),
263  m_TxBytes (0),
264  m_cumulativeTxBytes (0),
265  m_TxPkts (0),
266  m_cumulativeTxPkts (0)
267 {
268 }
269 
270 uint32_t
272 {
273  return m_RxBytes;
274 }
275 
276 uint32_t
278 {
279  return m_cumulativeRxBytes;
280 }
281 
282 uint32_t
284 {
285  return m_RxPkts;
286 }
287 
288 uint32_t
290 {
291  return m_cumulativeRxPkts;
292 }
293 
294 void
295 RoutingStats::IncRxBytes (uint32_t rxBytes)
296 {
297  m_RxBytes += rxBytes;
298  m_cumulativeRxBytes += rxBytes;
299 }
300 
301 void
303 {
304  m_RxPkts++;
306 }
307 
308 void
309 RoutingStats::SetRxBytes (uint32_t rxBytes)
310 {
311  m_RxBytes = rxBytes;
312 }
313 
314 void
315 RoutingStats::SetRxPkts (uint32_t rxPkts)
316 {
317  m_RxPkts = rxPkts;
318 }
319 
320 uint32_t
322 {
323  return m_TxBytes;
324 }
325 
326 uint32_t
328 {
329  return m_cumulativeTxBytes;
330 }
331 
332 uint32_t
334 {
335  return m_TxPkts;
336 }
337 
338 uint32_t
340 {
341  return m_cumulativeTxPkts;
342 }
343 
344 void
345 RoutingStats::IncTxBytes (uint32_t txBytes)
346 {
347  m_TxBytes += txBytes;
348  m_cumulativeTxBytes += txBytes;
349 }
350 
351 void
353 {
354  m_TxPkts++;
356 }
357 
358 void
359 RoutingStats::SetTxBytes (uint32_t txBytes)
360 {
361  m_TxBytes = txBytes;
362 }
363 
364 void
365 RoutingStats::SetTxPkts (uint32_t txPkts)
366 {
367  m_TxPkts = txPkts;
368 }
369 
380 class RoutingHelper : public Object
381 {
382 public:
387  static TypeId GetTypeId (void);
388 
393  RoutingHelper ();
394 
399  virtual ~RoutingHelper ();
400 
414  void Install (NodeContainer & c,
415  NetDeviceContainer & d,
417  double totalTime,
418  int protocol,
419  uint32_t nSinks,
420  int routingTables);
421 
428  void OnOffTrace (std::string context, Ptr<const Packet> packet);
429 
435 
441  void SetLogging (int log);
442 
443 private:
450 
458  Ipv4InterfaceContainer & adhocTxInterfaces);
459 
467  Ipv4InterfaceContainer & adhocTxInterfaces);
468 
476 
482  void ReceiveRoutingPacket (Ptr<Socket> socket);
483 
484  double m_TotalSimTime;
485  uint32_t m_protocol;
486  uint32_t m_port;
487  uint32_t m_nSinks;
490  std::string m_protocolName;
491  int m_log;
492 };
493 
495 
496 TypeId
498 {
499  static TypeId tid = TypeId ("ns3::RoutingHelper")
500  .SetParent<Object> ()
501  .AddConstructor<RoutingHelper> ();
502  return tid;
503 }
504 
506  : m_TotalSimTime (300.01),
507  m_protocol (0),
508  m_port (9),
509  m_nSinks (0),
510  m_routingTables (0),
511  m_log (0)
512 {
513 }
514 
516 {
517 }
518 
519 void
521  NetDeviceContainer & d,
523  double totalTime,
524  int protocol,
525  uint32_t nSinks,
526  int routingTables)
527 {
528  m_TotalSimTime = totalTime;
529  m_protocol = protocol;
530  m_nSinks = nSinks;
531  m_routingTables = routingTables;
532 
534  AssignIpAddresses (d, i);
535  SetupRoutingMessages (c, i);
536 }
537 
540 {
541  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
542  Ptr<Socket> sink = Socket::CreateSocket (node, tid);
544  sink->Bind (local);
545  sink->SetRecvCallback (MakeCallback (&RoutingHelper::ReceiveRoutingPacket, this));
546 
547  return sink;
548 }
549 
550 void
552 {
553  AodvHelper aodv;
555  DsdvHelper dsdv;
556  DsrHelper dsr;
557  DsrMainHelper dsrMain;
559  InternetStackHelper internet;
560 
561  Time rtt = Time (5.0);
562  AsciiTraceHelper ascii;
563  Ptr<OutputStreamWrapper> rtw = ascii.CreateFileStream ("routing_table");
564 
565  switch (m_protocol)
566  {
567  case 0:
568  m_protocolName = "NONE";
569  break;
570  case 1:
571  if (m_routingTables != 0)
572  {
573  olsr.PrintRoutingTableAllAt (rtt, rtw);
574  }
575  list.Add (olsr, 100);
576  m_protocolName = "OLSR";
577  break;
578  case 2:
579  if (m_routingTables != 0)
580  {
581  aodv.PrintRoutingTableAllAt (rtt, rtw);
582  }
583  list.Add (aodv, 100);
584  m_protocolName = "AODV";
585  break;
586  case 3:
587  if (m_routingTables != 0)
588  {
589  dsdv.PrintRoutingTableAllAt (rtt, rtw);
590  }
591  list.Add (dsdv, 100);
592  m_protocolName = "DSDV";
593  break;
594  case 4:
595  // setup is later
596  m_protocolName = "DSR";
597  break;
598  default:
599  NS_FATAL_ERROR ("No such protocol:" << m_protocol);
600  break;
601  }
602 
603  if (m_protocol < 4)
604  {
605  internet.SetRoutingHelper (list);
606  internet.Install (c);
607  }
608  else if (m_protocol == 4)
609  {
610  internet.Install (c);
611  dsrMain.Install (dsr, c);
612  }
613 
614  if (m_log != 0)
615  {
616  NS_LOG_UNCOND ("Routing Setup for " << m_protocolName);
617  }
618 }
619 
620 void
622  Ipv4InterfaceContainer & adhocTxInterfaces)
623 {
624  NS_LOG_INFO ("Assigning IP addresses");
625  Ipv4AddressHelper addressAdhoc;
626  // we may have a lot of nodes, and want them all
627  // in same subnet, to support broadcast
628  addressAdhoc.SetBase ("10.1.0.0", "255.255.0.0");
629  adhocTxInterfaces = addressAdhoc.Assign (d);
630 }
631 
632 void
634  Ipv4InterfaceContainer & adhocTxInterfaces)
635 {
636  // Setup routing transmissions
637  OnOffHelper onoff1 ("ns3::UdpSocketFactory",Address ());
638  onoff1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
639  onoff1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
640 
641  Ptr<UniformRandomVariable> var = CreateObject<UniformRandomVariable> ();
642  int64_t stream = 2;
643  var->SetStream (stream);
644  for (uint32_t i = 0; i < m_nSinks; i++)
645  {
646  // protocol == 0 means no routing data, WAVE BSM only
647  // so do not set up sink
648  if (m_protocol != 0)
649  {
650  Ptr<Socket> sink = SetupRoutingPacketReceive (adhocTxInterfaces.GetAddress (i), c.Get (i));
651  }
652 
653  AddressValue remoteAddress (InetSocketAddress (adhocTxInterfaces.GetAddress (i), m_port));
654  onoff1.SetAttribute ("Remote", remoteAddress);
655 
656  ApplicationContainer temp = onoff1.Install (c.Get (i + m_nSinks));
657  temp.Start (Seconds (var->GetValue (1.0,2.0)));
658  temp.Stop (Seconds (m_TotalSimTime));
659  }
660 }
661 
662 static inline std::string
664 {
665  std::ostringstream oss;
666 
667  oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
668 
669  if (InetSocketAddress::IsMatchingType (srcAddress))
670  {
671  InetSocketAddress addr = InetSocketAddress::ConvertFrom (srcAddress);
672  oss << " received one packet from " << addr.GetIpv4 ();
673  }
674  else
675  {
676  oss << " received one packet!";
677  }
678  return oss.str ();
679 }
680 
681 void
683 {
684  Ptr<Packet> packet;
685  Address srcAddress;
686  while ((packet = socket->RecvFrom (srcAddress)))
687  {
688  // application data, for goodput
689  uint32_t RxRoutingBytes = packet->GetSize ();
690  GetRoutingStats ().IncRxBytes (RxRoutingBytes);
692  if (m_log != 0)
693  {
694  NS_LOG_UNCOND (m_protocolName + " " + PrintReceivedRoutingPacket (socket, packet, srcAddress));
695  }
696  }
697 }
698 
699 void
700 RoutingHelper::OnOffTrace (std::string context, Ptr<const Packet> packet)
701 {
702  uint32_t pktBytes = packet->GetSize ();
703  routingStats.IncTxBytes (pktBytes);
704 }
705 
706 RoutingStats &
708 {
709  return routingStats;
710 }
711 
712 void
714 {
715  m_log = log;
716 }
717 
722 class WifiPhyStats : public Object
723 {
724 public:
729  static TypeId GetTypeId (void);
730 
735  WifiPhyStats ();
736 
741  virtual ~WifiPhyStats ();
742 
748  uint32_t GetTxBytes ();
749 
759  void PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower);
760 
767  void PhyTxDrop (std::string context, Ptr<const Packet> packet);
768 
775  void PhyRxDrop (std::string context, Ptr<const Packet> packet);
776 
777 private:
778  uint32_t m_phyTxPkts;
779  uint32_t m_phyTxBytes;
780 };
781 
783 
784 TypeId
786 {
787  static TypeId tid = TypeId ("ns3::WifiPhyStats")
788  .SetParent<Object> ()
789  .AddConstructor<WifiPhyStats> ();
790  return tid;
791 }
792 
794  : m_phyTxPkts (0),
795  m_phyTxBytes (0)
796 {
797 }
798 
800 {
801 }
802 
803 void
804 WifiPhyStats::PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
805 {
806  NS_LOG_FUNCTION (this << context << packet << "PHYTX mode=" << mode );
807  ++m_phyTxPkts;
808  uint32_t pktSize = packet->GetSize ();
809  m_phyTxBytes += pktSize;
810 
811  //NS_LOG_UNCOND ("Received PHY size=" << pktSize);
812 }
813 
814 void
815 WifiPhyStats::PhyTxDrop (std::string context, Ptr<const Packet> packet)
816 {
817  NS_LOG_UNCOND ("PHY Tx Drop");
818 }
819 
820 void
821 WifiPhyStats::PhyRxDrop (std::string context, Ptr<const Packet> packet)
822 {
823  NS_LOG_UNCOND ("PHY Rx Drop");
824 }
825 
826 uint32_t
828 {
829  return m_phyTxBytes;
830 }
831 
836 class WifiApp
837 {
838 public:
843  WifiApp ();
844 
849  virtual ~WifiApp ();
850 
857  void Simulate (int argc, char **argv);
858 
859 protected:
864  virtual void SetDefaultAttributeValues ();
865 
872  virtual void ParseCommandLineArguments (int argc, char **argv);
873 
878  virtual void ConfigureNodes ();
879 
884  virtual void ConfigureChannels ();
885 
890  virtual void ConfigureDevices ();
891 
896  virtual void ConfigureMobility ();
897 
902  virtual void ConfigureApplications ();
903 
908  virtual void ConfigureTracing ();
909 
914  virtual void RunSimulation ();
915 
920  virtual void ProcessOutputs ();
921 };
922 
924 {
925 }
926 
928 {
929 }
930 
931 void
932 WifiApp::Simulate (int argc, char **argv)
933 {
934  // Simulator Program Flow:
935  // (source: NS-3 Annual Meeting, May, 2014, session 2 slides 6, 28)
936  // (HandleProgramInputs:)
937  // SetDefaultAttributeValues
938  // ParseCommandLineArguments
939  // (ConfigureTopology:)
940  // ConfigureNodes
941  // ConfigureChannels
942  // ConfigureDevices
943  // ConfigureMobility
944  // ConfigureApplications
945  // e.g AddInternetStackToNodes
946  // ConfigureIpAddressingAndRouting
947  // configureSendMessages
948  // ConfigureTracing
949  // RunSimulation
950  // ProcessOutputs
951 
953  ParseCommandLineArguments (argc, argv);
954  ConfigureNodes ();
956  ConfigureDevices ();
959  ConfigureTracing ();
960  RunSimulation ();
961  ProcessOutputs ();
962 }
963 
964 void
966 {
967 }
968 
969 void
970 WifiApp::ParseCommandLineArguments (int argc, char **argv)
971 {
972 }
973 
974 void
976 {
977 }
978 
979 void
981 {
982 }
983 
984 void
986 {
987 }
988 
989 void
991 {
992 }
993 
994 void
996 {
997 }
998 
999 void
1001 {
1002 }
1003 
1004 void
1006 {
1007 }
1008 
1009 void
1011 {
1012 }
1013 
1019 {
1020 public:
1025  ConfigStoreHelper ();
1026 
1032  void LoadConfig (std::string configFilename);
1033 
1039  void SaveConfig (std::string configFilename);
1040 };
1041 
1043 {
1044 }
1045 
1046 void
1047 ConfigStoreHelper::LoadConfig (std::string configFilename)
1048 {
1049  // Input config store from txt format
1050  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1051  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1052  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Load"));
1053  ConfigStore inputConfig;
1054  inputConfig.ConfigureDefaults ();
1055  //inputConfig.ConfigureAttributes ();
1056 }
1057 
1058 void
1059 ConfigStoreHelper::SaveConfig (std::string configFilename)
1060 {
1061  // only save if a non-empty filename has been specified
1062  if (configFilename.compare ("") != 0)
1063  {
1064  // Output config store to txt format
1065  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1066  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1067  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
1068  ConfigStore outputConfig;
1069  outputConfig.ConfigureDefaults ();
1070  //outputConfig.ConfigureAttributes ();
1071  }
1072 }
1073 
1080 {
1081 public:
1087 
1088 protected:
1093  virtual void SetDefaultAttributeValues ();
1094 
1101  virtual void ParseCommandLineArguments (int argc, char **argv);
1102 
1107  virtual void ConfigureNodes ();
1108 
1113  virtual void ConfigureChannels ();
1114 
1119  virtual void ConfigureDevices ();
1120 
1125  virtual void ConfigureMobility ();
1126 
1131  virtual void ConfigureApplications ();
1132 
1137  virtual void ConfigureTracing ();
1138 
1143  virtual void RunSimulation ();
1144 
1149  virtual void ProcessOutputs ();
1150 
1151 private:
1156  void Run ();
1157 
1164  void CommandSetup (int argc, char **argv);
1165 
1171  void CheckThroughput ();
1172 
1177  void SetupLogFile ();
1178 
1183  void SetupLogging ();
1184 
1189  void ConfigureDefaults ();
1190 
1195  void SetupAdhocMobilityNodes ();
1196 
1201  void SetupAdhocDevices ();
1202 
1210  void SetupWaveMessages ();
1211 
1217  void SetupRoutingMessages ();
1218 
1223  void SetupScenario ();
1224 
1229  void WriteCsvHeader ();
1230 
1235  void SetConfigFromGlobals ();
1236 
1241  void SetGlobalsFromConfig ();
1242 
1249  static void
1250  CourseChange (std::ostream *os, std::string context, Ptr<const MobilityModel> mobility);
1251 
1252  uint32_t m_port;
1253  std::string m_CSVfileName;
1254  std::string m_CSVfileName2;
1255  uint32_t m_nSinks;
1256  std::string m_protocolName;
1257  double m_txp;
1259  uint32_t m_protocol;
1260 
1261  uint32_t m_lossModel;
1262  uint32_t m_fading;
1263  std::string m_lossModelName;
1264 
1265  std::string m_phyMode;
1266  uint32_t m_80211mode;
1267 
1268  std::string m_traceFile;
1269  std::string m_logFile;
1270  uint32_t m_mobility;
1271  uint32_t m_nNodes;
1273  std::string m_rate;
1274  std::string m_phyModeB;
1275  std::string m_trName;
1278  uint32_t m_wavePacketSize;
1281  std::ofstream m_os;
1284  uint32_t m_scenario;
1289  int m_pcap;
1290  std::string m_loadConfigFilename;
1291  std::string m_saveConfigFilename;
1292 
1296  int m_log;
1297  int64_t m_streamIndex;
1310  std::vector <double> m_txSafetyRanges;
1311  std::string m_exp;
1313 };
1314 
1316  : m_port (9),
1317  m_CSVfileName ("vanet-routing.output.csv"),
1318  m_CSVfileName2 ("vanet-routing.output2.csv"),
1319  m_nSinks (10),
1320  m_protocolName ("protocol"),
1321  m_txp (20),
1322  m_traceMobility (false),
1323  // AODV
1324  m_protocol (2),
1325  // Two-Ray ground
1326  m_lossModel (3),
1327  m_fading (0),
1328  m_lossModelName (""),
1329  m_phyMode ("OfdmRate6MbpsBW10MHz"),
1330  // 1=802.11p
1331  m_80211mode (1),
1332  m_traceFile (""),
1333  m_logFile ("low99-ct-unterstrass-1day.filt.7.adj.log"),
1334  m_mobility (1),
1335  m_nNodes (156),
1336  m_TotalSimTime (300.01),
1337  m_rate ("2048bps"),
1338  m_phyModeB ("DsssRate11Mbps"),
1339  m_trName ("vanet-routing-compare"),
1340  m_nodeSpeed (20),
1341  m_nodePause (0),
1342  m_wavePacketSize (200),
1343  m_waveInterval (0.1),
1344  m_verbose (0),
1345  m_scenario (1),
1346  m_gpsAccuracyNs (40),
1347  m_txMaxDelayMs (10),
1348  m_routingTables (0),
1349  m_asciiTrace (0),
1350  m_pcap (0),
1351  m_loadConfigFilename ("load-config.txt"),
1352  m_saveConfigFilename (""),
1353  m_log (0),
1354  m_streamIndex (0),
1355  m_adhocTxNodes (),
1356  m_txSafetyRange1 (50.0),
1357  m_txSafetyRange2 (100.0),
1358  m_txSafetyRange3 (150.0),
1359  m_txSafetyRange4 (200.0),
1360  m_txSafetyRange5 (250.0),
1361  m_txSafetyRange6 (300.0),
1362  m_txSafetyRange7 (350.0),
1363  m_txSafetyRange8 (400.0),
1364  m_txSafetyRange9 (450.0),
1365  m_txSafetyRange10 (500.0),
1366  m_txSafetyRanges (),
1367  m_exp (""),
1368  m_cumulativeBsmCaptureStart (0)
1369 {
1370  m_wifiPhyStats = CreateObject<WifiPhyStats> ();
1371  m_routingHelper = CreateObject<RoutingHelper> ();
1372 
1373  // set to non-zero value to enable
1374  // simply uncond logging during simulation run
1375  m_log = 1;
1376 }
1377 
1378 void
1380 {
1381  // handled in constructor
1382 }
1383 
1384 // important configuration items stored in global values
1385 static ns3::GlobalValue g_port ("VRCport",
1386  "Port",
1387  ns3::UintegerValue (9),
1388  ns3::MakeUintegerChecker<uint32_t> ());
1389 static ns3::GlobalValue g_nSinks ("VRCnSinks",
1390  "Number of sink nodes for routing non-BSM traffic",
1391  ns3::UintegerValue (10),
1392  ns3::MakeUintegerChecker<uint32_t> ());
1393 static ns3::GlobalValue g_traceMobility ("VRCtraceMobility",
1394  "Trace mobility 1=yes;0=no",
1395  ns3::UintegerValue (0),
1396  ns3::MakeUintegerChecker<uint32_t> ());
1397 static ns3::GlobalValue g_protocol ("VRCprotocol",
1398  "Routing protocol",
1399  ns3::UintegerValue (2),
1400  ns3::MakeUintegerChecker<uint32_t> ());
1401 static ns3::GlobalValue g_lossModel ("VRClossModel",
1402  "Propagation Loss Model",
1403  ns3::UintegerValue (3),
1404  ns3::MakeUintegerChecker<uint32_t> ());
1405 static ns3::GlobalValue g_fading ("VRCfading",
1406  "Fast Fading Model",
1407  ns3::UintegerValue (0),
1408  ns3::MakeUintegerChecker<uint32_t> ());
1409 static ns3::GlobalValue g_80211mode ("VRC80211mode",
1410  "802.11 mode (0=802.11a;1=802.11p)",
1411  ns3::UintegerValue (1),
1412  ns3::MakeUintegerChecker<uint32_t> ());
1413 static ns3::GlobalValue g_mobility ("VRCmobility",
1414  "Mobility mode 0=random waypoint;1=mobility trace file",
1415  ns3::UintegerValue (1),
1416  ns3::MakeUintegerChecker<uint32_t> ());
1417 static ns3::GlobalValue g_nNodes ("VRCnNodes",
1418  "Number of nodes (vehicles)",
1419  ns3::UintegerValue (156),
1420  ns3::MakeUintegerChecker<uint32_t> ());
1421 static ns3::GlobalValue g_nodeSpeed ("VRCnodeSpeed",
1422  "Node speed (m/s) for RWP model",
1423  ns3::UintegerValue (20),
1424  ns3::MakeUintegerChecker<uint32_t> ());
1425 static ns3::GlobalValue g_nodePause ("VRCnodePause",
1426  "Node pause time (s) for RWP model",
1427  ns3::UintegerValue (0),
1428  ns3::MakeUintegerChecker<uint32_t> ());
1429 static ns3::GlobalValue g_wavePacketSize ("VRCwavePacketSize",
1430  "Size in bytes of WAVE BSM",
1431  ns3::UintegerValue (200),
1432  ns3::MakeUintegerChecker<uint32_t> ());
1433 static ns3::GlobalValue g_verbose ("VRCverbose",
1434  "Verbose 0=no;1=yes",
1435  ns3::UintegerValue (0),
1436  ns3::MakeUintegerChecker<uint32_t> ());
1437 static ns3::GlobalValue g_scenario ("VRCscenario",
1438  "Scenario",
1439  ns3::UintegerValue (1),
1440  ns3::MakeUintegerChecker<uint32_t> ());
1441 static ns3::GlobalValue g_routingTables ("VRCroutingTables",
1442  "Dump routing tables at t=5 seconds 0=no;1=yes",
1443  ns3::UintegerValue (0),
1444  ns3::MakeUintegerChecker<uint32_t> ());
1445 static ns3::GlobalValue g_asciiTrace ("VRCasciiTrace",
1446  "Dump ASCII trace 0=no;1=yes",
1447  ns3::UintegerValue (0),
1448  ns3::MakeUintegerChecker<uint32_t> ());
1449 static ns3::GlobalValue g_pcap ("VRCpcap",
1450  "Generate PCAP files 0=no;1=yes",
1451  ns3::UintegerValue (0),
1452  ns3::MakeUintegerChecker<uint32_t> ());
1453 static ns3::GlobalValue g_cumulativeBsmCaptureStart ("VRCcumulativeBsmCaptureStart",
1454  "Simulation starte time for capturing cumulative BSM",
1455  ns3::UintegerValue (0),
1456  ns3::MakeUintegerChecker<uint32_t> ());
1457 
1458 static ns3::GlobalValue g_txSafetyRange1 ("VRCtxSafetyRange1",
1459  "BSM range for PDR inclusion",
1460  ns3::DoubleValue (50.0),
1461  ns3::MakeDoubleChecker<double> ());
1462 
1463 static ns3::GlobalValue g_txSafetyRange2 ("VRCtxSafetyRange2",
1464  "BSM range for PDR inclusion",
1465  ns3::DoubleValue (100.0),
1466  ns3::MakeDoubleChecker<double> ());
1467 
1468 static ns3::GlobalValue g_txSafetyRange3 ("VRCtxSafetyRange3",
1469  "BSM range for PDR inclusion",
1470  ns3::DoubleValue (150.0),
1471  ns3::MakeDoubleChecker<double> ());
1472 
1473 static ns3::GlobalValue g_txSafetyRange4 ("VRCtxSafetyRange4",
1474  "BSM range for PDR inclusion",
1475  ns3::DoubleValue (200.0),
1476  ns3::MakeDoubleChecker<double> ());
1477 
1478 static ns3::GlobalValue g_txSafetyRange5 ("VRCtxSafetyRange5",
1479  "BSM range for PDR inclusion",
1480  ns3::DoubleValue (250.0),
1481  ns3::MakeDoubleChecker<double> ());
1482 static ns3::GlobalValue g_txSafetyRange6 ("VRCtxSafetyRange6",
1483  "BSM range for PDR inclusion",
1484  ns3::DoubleValue (300.0),
1485  ns3::MakeDoubleChecker<double> ());
1486 static ns3::GlobalValue g_txSafetyRange7 ("VRCtxSafetyRange7",
1487  "BSM range for PDR inclusion",
1488  ns3::DoubleValue (350.0),
1489  ns3::MakeDoubleChecker<double> ());
1490 static ns3::GlobalValue g_txSafetyRange8 ("VRCtxSafetyRange8",
1491  "BSM range for PDR inclusion",
1492  ns3::DoubleValue (400.0),
1493  ns3::MakeDoubleChecker<double> ());
1494 static ns3::GlobalValue g_txSafetyRange9 ("VRCtxSafetyRange9",
1495  "BSM range for PDR inclusion",
1496  ns3::DoubleValue (450.0),
1497  ns3::MakeDoubleChecker<double> ());
1498 static ns3::GlobalValue g_txSafetyRange10 ("VRCtxSafetyRange10",
1499  "BSM range for PDR inclusion",
1500  ns3::DoubleValue (500.0),
1501  ns3::MakeDoubleChecker<double> ());
1502 static ns3::GlobalValue g_txp ("VRCtxp",
1503  "Transmission power dBm",
1504  ns3::DoubleValue (7.5),
1505  ns3::MakeDoubleChecker<double> ());
1506 static ns3::GlobalValue g_totalTime ("VRCtotalTime",
1507  "Total simulation time (s)",
1508  ns3::DoubleValue (300.01),
1509  ns3::MakeDoubleChecker<double> ());
1510 static ns3::GlobalValue g_waveInterval ("VRCwaveInterval",
1511  "Interval (s) between WAVE BSMs",
1512  ns3::DoubleValue (0.1),
1513  ns3::MakeDoubleChecker<double> ());
1514 static ns3::GlobalValue g_gpsAccuracyNs ("VRCgpsAccuracyNs",
1515  "GPS sync accuracy (ns)",
1516  ns3::DoubleValue (40),
1517  ns3::MakeDoubleChecker<double> ());
1518 static ns3::GlobalValue g_txMaxDelayMs ("VRCtxMaxDelayMs",
1519  "Tx May Delay (ms)",
1520  ns3::DoubleValue (10),
1521  ns3::MakeDoubleChecker<double> ());
1522 static ns3::GlobalValue g_CSVfileName ("VRCCSVfileName",
1523  "CSV filename (for time series data)",
1524  ns3::StringValue ("vanet-routing.output.csv"),
1526 static ns3::GlobalValue g_CSVfileName2 ("VRCCSVfileName2",
1527  "CSV filename 2 (for overall simulation scenario results)",
1528  ns3::StringValue ("vanet-routing.output2.csv"),
1530 static ns3::GlobalValue g_phyMode ("VRCphyMode",
1531  "PHY mode (802.11p)",
1532  ns3::StringValue ("OfdmRate6MbpsBW10MHz"),
1534 static ns3::GlobalValue g_traceFile ("VRCtraceFile",
1535  "Mobility trace filename",
1536  ns3::StringValue ("./src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob"),
1538 static ns3::GlobalValue g_logFile ("VRClogFile",
1539  "Log filename",
1540  ns3::StringValue ("low99-ct-unterstrass-1day.filt.7.adj.log"),
1542 static ns3::GlobalValue g_rate ("VRCrate",
1543  "Data rate",
1544  ns3::StringValue ("2048bps"),
1546 static ns3::GlobalValue g_phyModeB ("VRCphyModeB",
1547  "PHY mode (802.11a)",
1548  ns3::StringValue ("DsssRate11Mbps"),
1550 static ns3::GlobalValue g_trName ("VRCtrName",
1551  "Trace name",
1552  ns3::StringValue ("vanet-routing-compare"),
1554 
1555 void
1557 {
1558  CommandSetup (argc, argv);
1559  SetupScenario ();
1560 
1561  // user may specify up to 10 different tx distances
1562  // to be used for calculating different values of Packet
1563  // Delivery Ratio (PDR). Used to see the effects of
1564  // fading over distance
1565  m_txSafetyRanges.resize (10, 0);
1576 
1577  ConfigureDefaults ();
1578 
1579  // we are done with all configuration
1580  // save config-store, if requested
1582  ConfigStoreHelper configStoreHelper;
1583  configStoreHelper.SaveConfig (m_saveConfigFilename);
1584 
1585  m_waveBsmHelper.GetWaveBsmStats ()->SetLogging (m_log);
1587 }
1588 
1589 void
1591 {
1593 }
1594 
1595 void
1597 {
1598  // set up channel and devices
1599  SetupAdhocDevices ();
1600 }
1601 
1602 void
1604 {
1605  // devices are set up in SetupAdhocDevices(),
1606  // called by ConfigureChannels()
1607 
1608  // every device will have PHY callback for tracing
1609  // which is used to determine the total amount of
1610  // data transmitted, and then used to calculate
1611  // the MAC/PHY overhead beyond the app-data
1612  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&WifiPhyStats::PhyTxTrace, m_wifiPhyStats));
1613  // TxDrop, RxDrop not working yet. Not sure what I'm doing wrong.
1614  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback (&WifiPhyStats::PhyTxDrop, m_wifiPhyStats));
1615  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback (&WifiPhyStats::PhyRxDrop, m_wifiPhyStats));
1616 }
1617 
1618 void
1620 {
1622 }
1623 
1624 void
1626 {
1627  // Traffic mix consists of:
1628  // 1. routing data
1629  // 2. Broadcasting of Basic Safety Message (BSM)
1631  SetupWaveMessages ();
1632 
1633  // config trace to capture app-data (bytes) for
1634  // routing data, subtracted and used for
1635  // routing overhead
1636  std::ostringstream oss;
1637  oss.str ("");
1638  oss << "/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx";
1640 }
1641 
1642 void
1644 {
1645  WriteCsvHeader ();
1646  SetupLogFile ();
1647  SetupLogging ();
1648 
1649  AsciiTraceHelper ascii;
1650  MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (m_trName + ".mob"));
1651 }
1652 
1653 void
1655 {
1656  Run ();
1657 }
1658 
1659 void
1661 {
1662  // calculate and output final results
1663  double bsm_pdr1 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (1);
1664  double bsm_pdr2 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (2);
1665  double bsm_pdr3 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (3);
1666  double bsm_pdr4 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (4);
1667  double bsm_pdr5 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (5);
1668  double bsm_pdr6 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (6);
1669  double bsm_pdr7 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (7);
1670  double bsm_pdr8 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (8);
1671  double bsm_pdr9 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (9);
1672  double bsm_pdr10 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (10);
1673 
1674  double averageRoutingGoodputKbps = 0.0;
1675  uint32_t totalBytesTotal = m_routingHelper->GetRoutingStats ().GetCumulativeRxBytes ();
1676  averageRoutingGoodputKbps = (((double) totalBytesTotal * 8.0) / m_TotalSimTime) / 1000.0;
1677 
1678  // calculate MAC/PHY overhead (mac-phy-oh)
1679  // total WAVE BSM bytes sent
1680  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1681  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1682  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1683  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1684  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1685  double mac_phy_oh = 0.0;
1686  if (totalPhyBytes > 0)
1687  {
1688  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1689  }
1690 
1691  if (m_log != 0)
1692  {
1693  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);
1694 
1695  }
1696 
1697  std::ofstream out (m_CSVfileName2.c_str (), std::ios::app);
1698 
1699  out << bsm_pdr1 << ","
1700  << bsm_pdr2 << ","
1701  << bsm_pdr3 << ","
1702  << bsm_pdr4 << ","
1703  << bsm_pdr5 << ","
1704  << bsm_pdr6 << ","
1705  << bsm_pdr7 << ","
1706  << bsm_pdr8 << ","
1707  << bsm_pdr9 << ","
1708  << bsm_pdr10 << ","
1709  << averageRoutingGoodputKbps << ","
1710  << mac_phy_oh << ""
1711  << std::endl;
1712 
1713  out.close ();
1714 
1715  m_os.close (); // close log file
1716 }
1717 
1718 void
1720 {
1721  NS_LOG_INFO ("Run Simulation.");
1722 
1723  CheckThroughput ();
1724 
1725  Simulator::Stop (Seconds (m_TotalSimTime));
1726  Simulator::Run ();
1727  Simulator::Destroy ();
1728 }
1729 
1730 // Prints actual position and velocity when a course change event occurs
1731 void
1733 CourseChange (std::ostream *os, std::string context, Ptr<const MobilityModel> mobility)
1734 {
1735  Vector pos = mobility->GetPosition (); // Get position
1736  Vector vel = mobility->GetVelocity (); // Get velocity
1737 
1738  pos.z = 1.5;
1739 
1740  int nodeId = mobility->GetObject<Node> ()->GetId ();
1741  double t = (Simulator::Now ()).GetSeconds ();
1742  if (t >= 1.0)
1743  {
1744  WaveBsmHelper::GetNodesMoving ()[nodeId] = 1;
1745  }
1746 
1747  //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::Now () );
1748 
1749  // Prints position and velocities
1750  *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y
1751  << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
1752  << ", z=" << vel.z << std::endl;
1753 }
1754 
1755 void
1757 {
1758  uint32_t bytesTotal = m_routingHelper->GetRoutingStats ().GetRxBytes ();
1759  uint32_t packetsReceived = m_routingHelper->GetRoutingStats ().GetRxPkts ();
1760  double kbps = (bytesTotal * 8.0) / 1000;
1761  double wavePDR = 0.0;
1762  int wavePktsSent = m_waveBsmHelper.GetWaveBsmStats ()->GetTxPktCount ();
1763  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1764  if (wavePktsSent > 0)
1765  {
1766  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1767  wavePDR = (double) wavePktsReceived / (double) wavePktsSent;
1768  }
1769 
1770  int waveExpectedRxPktCount = m_waveBsmHelper.GetWaveBsmStats ()->GetExpectedRxPktCount (1);
1771  int waveRxPktInRangeCount = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktInRangeCount (1);
1772  double wavePDR1_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (1);
1773  double wavePDR2_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (2);
1774  double wavePDR3_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (3);
1775  double wavePDR4_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (4);
1776  double wavePDR5_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (5);
1777  double wavePDR6_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (6);
1778  double wavePDR7_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (7);
1779  double wavePDR8_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (8);
1780  double wavePDR9_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (9);
1781  double wavePDR10_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (10);
1782 
1783  // calculate MAC/PHY overhead (mac-phy-oh)
1784  // total WAVE BSM bytes sent
1785  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1786  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1787  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1788  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1789  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1790  double mac_phy_oh = 0.0;
1791  if (totalPhyBytes > 0)
1792  {
1793  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1794  }
1795 
1796  std::ofstream out (m_CSVfileName.c_str (), std::ios::app);
1797 
1798  if (m_log != 0 )
1799  {
1800  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*/);
1801  }
1802 
1803  out << (Simulator::Now ()).GetSeconds () << ","
1804  << kbps << ","
1805  << packetsReceived << ","
1806  << m_nSinks << ","
1807  << m_protocolName << ","
1808  << m_txp << ","
1809  << wavePktsSent << ","
1810  << wavePktsReceived << ","
1811  << wavePDR << ","
1812  << waveExpectedRxPktCount << ","
1813  << waveRxPktInRangeCount << ","
1814  << wavePDR1_2 << ","
1815  << wavePDR2_2 << ","
1816  << wavePDR3_2 << ","
1817  << wavePDR4_2 << ","
1818  << wavePDR5_2 << ","
1819  << wavePDR6_2 << ","
1820  << wavePDR7_2 << ","
1821  << wavePDR8_2 << ","
1822  << wavePDR9_2 << ","
1823  << wavePDR10_2 << ","
1824  << mac_phy_oh << ""
1825  << std::endl;
1826 
1827  out.close ();
1828 
1831  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktCount (0);
1832  m_waveBsmHelper.GetWaveBsmStats ()->SetTxPktCount (0);
1833  for (int index = 1; index <= 10; index++)
1834  {
1835  m_waveBsmHelper.GetWaveBsmStats ()->SetExpectedRxPktCount (index, 0);
1836  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktInRangeCount (index, 0);
1837  }
1838 
1839  double currentTime = (Simulator::Now ()).GetSeconds ();
1840  if (currentTime <= (double) m_cumulativeBsmCaptureStart)
1841  {
1842  for (int index = 1; index <= 10; index++)
1843  {
1844  m_waveBsmHelper.GetWaveBsmStats ()->ResetTotalRxPktCounts (index);
1845  }
1846  }
1847 
1848  Simulator::Schedule (Seconds (1.0), &VanetRoutingExperiment::CheckThroughput, this);
1849 }
1850 
1851 void
1853 {
1854  // get settings saved from config-store
1855  UintegerValue uintegerValue;
1856  DoubleValue doubleValue;
1857  StringValue stringValue;
1858 
1859  // This may not be the best way to manage program configuration
1860  // (directing them through global values), but management
1861  // through the config-store here is copied from
1862  // src/lte/examples/lena-dual-stripe.cc
1863 
1864  GlobalValue::GetValueByName ("VRCport", uintegerValue);
1865  m_port = uintegerValue.Get ();
1866  GlobalValue::GetValueByName ("VRCnSinks", uintegerValue);
1867  m_nSinks = uintegerValue.Get ();
1868  GlobalValue::GetValueByName ("VRCtraceMobility", uintegerValue);
1869  m_traceMobility = uintegerValue.Get ();
1870  GlobalValue::GetValueByName ("VRCprotocol", uintegerValue);
1871  m_protocol = uintegerValue.Get ();
1872  GlobalValue::GetValueByName ("VRClossModel", uintegerValue);
1873  m_lossModel = uintegerValue.Get ();
1874  GlobalValue::GetValueByName ("VRCfading", uintegerValue);
1875  m_fading = uintegerValue.Get ();
1876  GlobalValue::GetValueByName ("VRC80211mode", uintegerValue);
1877  m_80211mode = uintegerValue.Get ();
1878  GlobalValue::GetValueByName ("VRCmobility", uintegerValue);
1879  m_mobility = uintegerValue.Get ();
1880  GlobalValue::GetValueByName ("VRCnNodes", uintegerValue);
1881  m_nNodes = uintegerValue.Get ();
1882  GlobalValue::GetValueByName ("VRCnodeSpeed", uintegerValue);
1883  m_nodeSpeed = uintegerValue.Get ();
1884  GlobalValue::GetValueByName ("VRCnodePause", uintegerValue);
1885  m_nodePause = uintegerValue.Get ();
1886  GlobalValue::GetValueByName ("VRCwavePacketSize", uintegerValue);
1887  m_wavePacketSize = uintegerValue.Get ();
1888  GlobalValue::GetValueByName ("VRCverbose", uintegerValue);
1889  m_verbose = uintegerValue.Get ();
1890  GlobalValue::GetValueByName ("VRCscenario", uintegerValue);
1891  m_scenario = uintegerValue.Get ();
1892  GlobalValue::GetValueByName ("VRCroutingTables", uintegerValue);
1893  m_routingTables = uintegerValue.Get ();
1894  GlobalValue::GetValueByName ("VRCasciiTrace", uintegerValue);
1895  m_asciiTrace = uintegerValue.Get ();
1896  GlobalValue::GetValueByName ("VRCpcap", uintegerValue);
1897  m_pcap = uintegerValue.Get ();
1898  GlobalValue::GetValueByName ("VRCcumulativeBsmCaptureStart", uintegerValue);
1899  m_cumulativeBsmCaptureStart = uintegerValue.Get ();
1900 
1901  GlobalValue::GetValueByName ("VRCtxSafetyRange1", doubleValue);
1902  m_txSafetyRange1 = doubleValue.Get ();
1903  GlobalValue::GetValueByName ("VRCtxSafetyRange2", doubleValue);
1904  m_txSafetyRange2 = doubleValue.Get ();
1905  GlobalValue::GetValueByName ("VRCtxSafetyRange3", doubleValue);
1906  m_txSafetyRange3 = doubleValue.Get ();
1907  GlobalValue::GetValueByName ("VRCtxSafetyRange4", doubleValue);
1908  m_txSafetyRange4 = doubleValue.Get ();
1909  GlobalValue::GetValueByName ("VRCtxSafetyRange5", doubleValue);
1910  m_txSafetyRange5 = doubleValue.Get ();
1911  GlobalValue::GetValueByName ("VRCtxSafetyRange6", doubleValue);
1912  m_txSafetyRange6 = doubleValue.Get ();
1913  GlobalValue::GetValueByName ("VRCtxSafetyRange7", doubleValue);
1914  m_txSafetyRange7 = doubleValue.Get ();
1915  GlobalValue::GetValueByName ("VRCtxSafetyRange8", doubleValue);
1916  m_txSafetyRange8 = doubleValue.Get ();
1917  GlobalValue::GetValueByName ("VRCtxSafetyRange9", doubleValue);
1918  m_txSafetyRange9 = doubleValue.Get ();
1919  GlobalValue::GetValueByName ("VRCtxSafetyRange10", doubleValue);
1920  m_txSafetyRange10 = doubleValue.Get ();
1921  GlobalValue::GetValueByName ("VRCtxp", doubleValue);
1922  m_txp = doubleValue.Get ();
1923  GlobalValue::GetValueByName ("VRCtotalTime", doubleValue);
1924  m_TotalSimTime = doubleValue.Get ();
1925  GlobalValue::GetValueByName ("VRCwaveInterval", doubleValue);
1926  m_waveInterval = doubleValue.Get ();
1927  GlobalValue::GetValueByName ("VRCgpsAccuracyNs", doubleValue);
1928  m_gpsAccuracyNs = doubleValue.Get ();
1929  GlobalValue::GetValueByName ("VRCtxMaxDelayMs", doubleValue);
1930  m_txMaxDelayMs = doubleValue.Get ();
1931 
1932  GlobalValue::GetValueByName ("VRCCSVfileName", stringValue);
1933  m_CSVfileName = stringValue.Get ();
1934  GlobalValue::GetValueByName ("VRCCSVfileName2", stringValue);
1935  m_CSVfileName2 = stringValue.Get ();
1936  GlobalValue::GetValueByName ("VRCphyMode", stringValue);
1937  m_phyMode = stringValue.Get ();
1938  GlobalValue::GetValueByName ("VRCtraceFile", stringValue);
1939  m_traceFile = stringValue.Get ();
1940  GlobalValue::GetValueByName ("VRClogFile", stringValue);
1941  m_logFile = stringValue.Get ();
1942  GlobalValue::GetValueByName ("VRCrate", stringValue);
1943  m_rate = stringValue.Get ();
1944  GlobalValue::GetValueByName ("VRCphyModeB", stringValue);
1945  m_phyModeB = stringValue.Get ();
1946  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1947  m_trName = stringValue.Get ();
1948 }
1949 
1950 void
1952 {
1953  // get settings saved from config-store
1954  UintegerValue uintegerValue;
1955  DoubleValue doubleValue;
1956  StringValue stringValue;
1957 
1976 
1992 
2001  GlobalValue::GetValueByName ("VRCtrName", stringValue);
2002  m_trName = stringValue.Get ();
2003 }
2004 
2005 void
2007 {
2008  CommandLine cmd;
2009  double txDist1 = 50.0;
2010  double txDist2 = 100.0;
2011  double txDist3 = 150.0;
2012  double txDist4 = 200.0;
2013  double txDist5 = 250.0;
2014  double txDist6 = 300.0;
2015  double txDist7 = 350.0;
2016  double txDist8 = 350.0;
2017  double txDist9 = 350.0;
2018  double txDist10 = 350.0;
2019 
2020  // allow command line overrides
2021  cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName);
2022  cmd.AddValue ("CSVfileName2", "The name of the CSV output file name2", m_CSVfileName2);
2023  cmd.AddValue ("totaltime", "Simulation end time", m_TotalSimTime);
2024  cmd.AddValue ("nodes", "Number of nodes (i.e. vehicles)", m_nNodes);
2025  cmd.AddValue ("sinks", "Number of routing sinks", m_nSinks);
2026  cmd.AddValue ("txp", "Transmit power (dB), e.g. txp=7.5", m_txp);
2027  cmd.AddValue ("traceMobility", "Enable mobility tracing", m_traceMobility);
2028  cmd.AddValue ("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol);
2029  cmd.AddValue ("lossModel", "1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance", m_lossModel);
2030  cmd.AddValue ("fading", "0=None;1=Nakagami;(buildings=1 overrides)", m_fading);
2031  cmd.AddValue ("phyMode", "Wifi Phy mode", m_phyMode);
2032  cmd.AddValue ("80211Mode", "1=802.11p; 2=802.11b; 3=WAVE-PHY", m_80211mode);
2033  cmd.AddValue ("traceFile", "Ns2 movement trace file", m_traceFile);
2034  cmd.AddValue ("logFile", "Log file", m_logFile);
2035  cmd.AddValue ("mobility", "1=trace;2=RWP", m_mobility);
2036  cmd.AddValue ("rate", "Rate", m_rate);
2037  cmd.AddValue ("phyModeB", "Phy mode 802.11b", m_phyModeB);
2038  cmd.AddValue ("speed", "Node speed (m/s)", m_nodeSpeed);
2039  cmd.AddValue ("pause", "Node pause (s)", m_nodePause);
2040  cmd.AddValue ("verbose", "0=quiet;1=verbose", m_verbose);
2041  cmd.AddValue ("bsm", "(WAVE) BSM size (bytes)", m_wavePacketSize);
2042  cmd.AddValue ("interval", "(WAVE) BSM interval (s)", m_waveInterval);
2043  cmd.AddValue ("scenario", "1=synthetic, 2=playback-trace", m_scenario);
2044  // User is allowed to have up to 10 different PDRs (Packet
2045  // Delivery Ratios) calculate, and so can specify up to
2046  // 10 different tx distances.
2047  cmd.AddValue ("txdist1", "Expected BSM tx range, m", txDist1);
2048  cmd.AddValue ("txdist2", "Expected BSM tx range, m", txDist2);
2049  cmd.AddValue ("txdist3", "Expected BSM tx range, m", txDist3);
2050  cmd.AddValue ("txdist4", "Expected BSM tx range, m", txDist4);
2051  cmd.AddValue ("txdist5", "Expected BSM tx range, m", txDist5);
2052  cmd.AddValue ("txdist6", "Expected BSM tx range, m", txDist6);
2053  cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7);
2054  cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8);
2055  cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9);
2056  cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10);
2057  cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs);
2058  cmd.AddValue ("txmaxdelay", "Tx max delay, in ms", m_txMaxDelayMs);
2059  cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routingTables);
2060  cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace);
2061  cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap);
2062  cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilename);
2063  cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilename);
2064  cmd.AddValue ("exp", "Experiment", m_exp);
2065  cmd.AddValue ("BsmCaptureStart", "Start time to begin capturing pkts for cumulative Bsm", m_cumulativeBsmCaptureStart);
2066  cmd.Parse (argc, argv);
2067 
2068  m_txSafetyRange1 = txDist1;
2069  m_txSafetyRange2 = txDist2;
2070  m_txSafetyRange3 = txDist3;
2071  m_txSafetyRange4 = txDist4;
2072  m_txSafetyRange5 = txDist5;
2073  m_txSafetyRange6 = txDist6;
2074  m_txSafetyRange7 = txDist7;
2075  m_txSafetyRange8 = txDist8;
2076  m_txSafetyRange9 = txDist9;
2077  m_txSafetyRange10 = txDist10;
2078  // load configuration info from config-store
2079  ConfigStoreHelper configStoreHelper;
2080  configStoreHelper.LoadConfig (m_loadConfigFilename);
2081  // transfer config-store values to config parameters
2083 
2084  // parse again so you can override input file default values via command line
2085  cmd.Parse (argc, argv);
2086 
2087  m_txSafetyRange1 = txDist1;
2088  m_txSafetyRange2 = txDist2;
2089  m_txSafetyRange3 = txDist3;
2090  m_txSafetyRange4 = txDist4;
2091  m_txSafetyRange5 = txDist5;
2092  m_txSafetyRange6 = txDist6;
2093  m_txSafetyRange7 = txDist7;
2094  m_txSafetyRange8 = txDist8;
2095  m_txSafetyRange9 = txDist9;
2096  m_txSafetyRange10 = txDist10;
2097 }
2098 
2099 void
2101 {
2102  // open log file for output
2103  m_os.open (m_logFile.c_str ());
2104 }
2105 
2107 {
2108 
2109  // Enable logging from the ns2 helper
2110  LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
2111 
2112  Packet::EnablePrinting ();
2113 }
2114 
2115 void
2117 {
2118  Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64"));
2119  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (m_rate));
2120 
2121  //Set Non-unicastMode rate to unicast mode
2122  if (m_80211mode == 2)
2123  {
2124  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyModeB));
2125  }
2126  else
2127  {
2128  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyMode));
2129  }
2130 }
2131 
2132 void
2134 {
2135  if (m_mobility == 1)
2136  {
2137  // Create Ns2MobilityHelper with the specified trace log file as parameter
2139  ns2.Install (); // configure movements for each node, while reading trace file
2140  // initially assume all nodes are not moving
2141  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 0);
2142  }
2143  else if (m_mobility == 2)
2144  {
2145  MobilityHelper mobilityAdhoc;
2146 
2147  ObjectFactory pos;
2148  pos.SetTypeId ("ns3::RandomBoxPositionAllocator");
2149  pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
2150  pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
2151  // we need antenna height uniform [1.0 .. 2.0] for loss model
2152  pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"));
2153 
2154  Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
2155  m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex);
2156 
2157  std::stringstream ssSpeed;
2158  ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]";
2159  std::stringstream ssPause;
2160  ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]";
2161  mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
2162  "Speed", StringValue (ssSpeed.str ()),
2163  "Pause", StringValue (ssPause.str ()),
2164  "PositionAllocator", PointerValue (taPositionAlloc));
2165  mobilityAdhoc.SetPositionAllocator (taPositionAlloc);
2166  mobilityAdhoc.Install (m_adhocTxNodes);
2168 
2169  // initially assume all nodes are moving
2170  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 1);
2171  }
2172 
2173  // Configure callback for logging
2174  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2176 }
2177 
2178 void
2180 {
2181  if (m_lossModel == 1)
2182  {
2183  m_lossModelName = "ns3::FriisPropagationLossModel";
2184  }
2185  else if (m_lossModel == 2)
2186  {
2187  m_lossModelName = "ns3::ItuR1411LosPropagationLossModel";
2188  }
2189  else if (m_lossModel == 3)
2190  {
2191  m_lossModelName = "ns3::TwoRayGroundPropagationLossModel";
2192  }
2193  else if (m_lossModel == 4)
2194  {
2195  m_lossModelName = "ns3::LogDistancePropagationLossModel";
2196  }
2197  else
2198  {
2199  // Unsupported propagation loss model.
2200  // Treating as ERROR
2201  NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance");
2202  }
2203 
2204  // frequency
2205  double freq = 0.0;
2206  if ((m_80211mode == 1)
2207  || (m_80211mode == 3))
2208  {
2209  // 802.11p 5.9 GHz
2210  freq = 5.9e9;
2211  }
2212  else
2213  {
2214  // 802.11b 2.4 GHz
2215  freq = 2.4e9;
2216  }
2217 
2218  // Setup propagation models
2219  YansWifiChannelHelper wifiChannel;
2220  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
2221  if (m_lossModel == 3)
2222  {
2223  // two-ray requires antenna height (else defaults to Friss)
2224  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq), "HeightAboveZ", DoubleValue (1.5));
2225  }
2226  else
2227  {
2228  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq));
2229  }
2230 
2231  // Propagation loss models are additive.
2232  if (m_fading != 0)
2233  {
2234  // if no obstacle model, then use Nakagami fading if requested
2235  wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
2236  }
2237 
2238  // the channel
2239  Ptr<YansWifiChannel> channel = wifiChannel.Create ();
2240 
2241  // The below set of helpers will help us to put together the wifi NICs we want
2242  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
2243  wifiPhy.SetChannel (channel);
2244  // ns-3 supports generate a pcap trace
2245  wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11);
2246 
2247  YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
2248  wavePhy.SetChannel (channel);
2249  wavePhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11);
2250 
2251  // Setup WAVE PHY and MAC
2252  NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
2253  WaveHelper waveHelper = WaveHelper::Default ();
2254  Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
2255  if (m_verbose)
2256  {
2257  wifi80211p.EnableLogComponents (); // Turn on all Wifi 802.11p logging
2258  // likewise, turn on WAVE PHY logging
2259  waveHelper.EnableLogComponents ();
2260  }
2261 
2262  WifiHelper wifi;
2263 
2264  // Setup 802.11b stuff
2265  wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
2266 
2267  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2268  "DataMode",StringValue (m_phyModeB),
2269  "ControlMode",StringValue (m_phyModeB));
2270 
2271  // Setup 802.11p stuff
2272  wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2273  "DataMode",StringValue (m_phyMode),
2274  "ControlMode",StringValue (m_phyMode));
2275 
2276  // Setup WAVE-PHY stuff
2277  waveHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2278  "DataMode",StringValue (m_phyMode),
2279  "ControlMode",StringValue (m_phyMode));
2280 
2281  // Set Tx Power
2282  wifiPhy.Set ("TxPowerStart",DoubleValue (m_txp));
2283  wifiPhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2284  wavePhy.Set ("TxPowerStart",DoubleValue (m_txp));
2285  wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2286 
2287  // Add an upper mac and disable rate control
2288  WifiMacHelper wifiMac;
2289  wifiMac.SetType ("ns3::AdhocWifiMac");
2290  QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
2291 
2292  // Setup net devices
2293 
2294  if (m_80211mode == 3)
2295  {
2296  m_adhocTxDevices = waveHelper.Install (wavePhy, waveMac, m_adhocTxNodes);
2297  }
2298  else if (m_80211mode == 1)
2299  {
2300  m_adhocTxDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, m_adhocTxNodes);
2301  }
2302  else
2303  {
2304  m_adhocTxDevices = wifi.Install (wifiPhy, wifiMac, m_adhocTxNodes);
2305  }
2306 
2307  if (m_asciiTrace != 0)
2308  {
2309  AsciiTraceHelper ascii;
2310  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (m_trName + ".tr").c_str ());
2311  wifiPhy.EnableAsciiAll (osw);
2312  wavePhy.EnableAsciiAll (osw);
2313  }
2314  if (m_pcap != 0)
2315  {
2316  wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap");
2317  wavePhy.EnablePcapAll ("vanet-routing-compare-pcap");
2318  }
2319 }
2320 
2321 void
2323 {
2324  // WAVE PHY mode
2325  // 0=continuous channel; 1=channel-switching
2326  int chAccessMode = 0;
2327  if (m_80211mode == 3)
2328  {
2329  chAccessMode = 1;
2330  }
2331 
2336  // GPS accuracy (i.e, clock drift), in number of ns
2339  chAccessMode,
2340  // tx max delay before transmit, in ms
2342 
2343  // fix random number streams
2345 }
2346 
2347 void
2349 {
2354  m_protocol,
2355  m_nSinks,
2356  m_routingTables);
2357 }
2358 
2359 void
2361 {
2362  // member variable parameter use
2363  // defaults or command line overrides,
2364  // except where scenario={1,2,3,...}
2365  // have been specified, in which case
2366  // specify parameters are overwritten
2367  // here to setup for specific scenarios
2368 
2369  // certain parameters may be further overridden
2370  // i.e. specify a scenario, override tx power.
2371 
2372  if (m_scenario == 1)
2373  {
2374  // 40 nodes in RWP 300 m x 1500 m synthetic highway, 10s
2375  m_traceFile = "";
2376  m_logFile = "";
2377  m_mobility = 2;
2378  if (m_nNodes == 156)
2379  {
2380  m_nNodes = 40;
2381  }
2382  if (m_TotalSimTime == 300.01)
2383  {
2384  m_TotalSimTime = 10.0;
2385  }
2386  }
2387  else if (m_scenario == 2)
2388  {
2389  // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
2390  // "low density, 99 total vehicles"
2391  m_traceFile = "src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob";
2392  m_logFile = "low99-ct-unterstrass-1day.filt.7.adj.log";
2393  m_mobility = 1;
2394  m_nNodes = 99;
2395  m_TotalSimTime = 300.01;
2396  m_nodeSpeed = 0;
2397  m_nodePause = 0;
2398  m_CSVfileName = "low_vanet-routing-compare.csv";
2399  m_CSVfileName = "low_vanet-routing-compare2.csv";
2400  }
2401 }
2402 
2403 void
2405 {
2406  //blank out the last output file and write the column headers
2407  std::ofstream out (m_CSVfileName.c_str ());
2408  out << "SimulationSecond," <<
2409  "ReceiveRate," <<
2410  "PacketsReceived," <<
2411  "NumberOfSinks," <<
2412  "RoutingProtocol," <<
2413  "TransmissionPower," <<
2414  "WavePktsSent," <<
2415  "WavePtksReceived," <<
2416  "WavePktsPpr," <<
2417  "ExpectedWavePktsReceived," <<
2418  "ExpectedWavePktsInCoverageReceived," <<
2419  "BSM_PDR1," <<
2420  "BSM_PDR2," <<
2421  "BSM_PDR3," <<
2422  "BSM_PDR4," <<
2423  "BSM_PDR5," <<
2424  "BSM_PDR6," <<
2425  "BSM_PDR7," <<
2426  "BSM_PDR8," <<
2427  "BSM_PDR9," <<
2428  "BSM_PDR10," <<
2429  "MacPhyOverhead" <<
2430  std::endl;
2431  out.close ();
2432 
2433  std::ofstream out2 (m_CSVfileName2.c_str ());
2434  out2 << "BSM_PDR1,"
2435  << "BSM_PDR2,"
2436  << "BSM_PDR3,"
2437  << "BSM_PDR4,"
2438  << "BSM_PDR5,"
2439  << "BSM_PDR6,"
2440  << "BSM_PDR7,"
2441  << "BSM_PDR8,"
2442  << "BSM_PDR9,"
2443  << "BSM_PDR10,"
2444  << "AverageRoutingGoodputKbps,"
2445  << "MacPhyOverhead"
2446  << std::endl;
2447  out2.close ();
2448 }
2449 
2450 int
2451 main (int argc, char *argv[])
2452 {
2454  experiment.Simulate (argc, argv);
2455 }
static ns3::GlobalValue g_waveInterval("VRCwaveInterval", "Interval (s) between WAVE BSMs", ns3::DoubleValue(0.1), 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())
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:56
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:142
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:59
static ns3::GlobalValue g_CSVfileName("VRCCSVfileName", "CSV filename (for time series data)", ns3::StringValue("vanet-routing.output.csv"), ns3::MakeStringChecker())
std::string m_logFile
log file
static void EnableLogComponents(void)
Helper to enable all WaveNetDevice log components with one statement.
Definition: wave-helper.cc:426
helps to create wifi 802.11p objects of WifiNetDevice class
The RoutingStats class manages collects statistics on routing data (application-data packet and byte ...
RoutingHelper()
Constructor.
static ns3::GlobalValue g_nNodes("VRCnNodes", "Number of nodes (vehicles)", ns3::UintegerValue(156), ns3::MakeUintegerChecker< uint32_t >())
WifiApp()
Constructor.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Manage ASCII trace files for device models.
Definition: trace-helper.h:161
an Inet address class
static ns3::GlobalValue g_asciiTrace("VRCasciiTrace", "Dump ASCII trace 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
#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 the RngStream.
int m_routingTables
dump routing table (at t=5 sec). 0=No, 1=Yes
NodeContainer m_adhocTxNodes
adhoc transmit nodes
void WriteCsvHeader()
Write the header line to the CSV file1.
static ns3::GlobalValue g_txSafetyRange2("VRCtxSafetyRange2", "BSM range for PDR inclusion", ns3::DoubleValue(100.0), ns3::MakeDoubleChecker< double >())
uint32_t GetId(void) const
Definition: node.cc:107
std::string m_CSVfileName
CSV file name.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void SetupRoutingMessages()
Set up generation of packets to be routed through the vehicular network.
static ns3::GlobalValue g_wavePacketSize("VRCwavePacketSize", "Size in bytes of WAVE BSM", ns3::UintegerValue(200), ns3::MakeUintegerChecker< uint32_t >())
std::string m_saveConfigFilename
save configi file name
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
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:661
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.
The WifiPhyStats class collects Wifi MAC/PHY statistics.
virtual void ParseCommandLineArguments(int argc, char **argv)
Process command line arguments.
static std::string PrintReceivedRoutingPacket(Ptr< Socket > socket, Ptr< Packet > packet, Address srcAddress)
void SetRxBytes(uint32_t rxBytes)
Sets the number of bytes received.
static ns3::GlobalValue g_txSafetyRange7("VRCtxSafetyRange7", "BSM range for PDR inclusion", ns3::DoubleValue(350.0), ns3::MakeDoubleChecker< double >())
uint32_t GetCumulativeTxPkts()
Returns the cumulative number of packets transmitted.
void Install(void) const
Read the ns2 trace file and configure the movement patterns of all nodes contained in the global ns3:...
static ns3::GlobalValue g_rate("VRCrate", "Data rate", ns3::StringValue("2048bps"), ns3::MakeStringChecker())
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1686
static ns3::GlobalValue g_traceFile("VRCtraceFile", "Mobility trace filename", ns3::StringValue("./src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob"), ns3::MakeStringChecker())
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
static ns3::GlobalValue g_mobility("VRCmobility", "Mobility mode 0=random waypoint;1=mobility trace file", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
uint32_t m_TxPkts
transmit packets
void PhyTxDrop(std::string context, Ptr< const Packet > packet)
Callback signiture for Phy/TxDrop.
Helper class that adds DSR routing to nodes.
void SetupWaveMessages()
Set up generation of IEEE 1609 WAVE messages, as a Basic Safety Message (BSM).
std::string m_traceFile
trace file
uint32_t GetCumulativeRxBytes()
Returns the cumulative number of bytes received.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
virtual ~WifiPhyStats()
Destructor.
void IncRxPkts()
Increments the count of packets received.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
aggregate IP/TCP/UDP functionality to existing Nodes.
Helper class that adds OLSR routing to nodes.
Definition: olsr-helper.h:40
Ipv4InterfaceContainer m_adhocTxInterfaces
adhoc transmit interfaces
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:280
int m_routingTables
routing tables
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
cmd
Definition: second.py:35
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:743
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we&#39;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...
void IncTxBytes(uint32_t txBytes)
Increment the number of bytes transmitted.
uint32_t m_cumulativeRxBytes
cumulative receive bytes
Hold a so-called &#39;global value&#39;.
Definition: global-value.h:73
std::string m_phyMode
phy mode
uint32_t m_TxBytes
transmit bytes
std::string m_phyModeB
phy mode
void CommandSetup(int argc, char **argv)
Run the simulation.
static ns3::GlobalValue g_CSVfileName2("VRCCSVfileName2", "CSV filename 2 (for overall simulation scenario results)", ns3::StringValue("vanet-routing.output2.csv"), ns3::MakeStringChecker())
helps to create WifiNetDevice objects
Definition: wifi-helper.h:299
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:97
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.
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...
static ns3::GlobalValue g_gpsAccuracyNs("VRCgpsAccuracyNs", "GPS sync accuracy (ns)", ns3::DoubleValue(40), ns3::MakeDoubleChecker< double >())
NetDeviceContainer m_adhocTxDevices
adhoc transmit devices
void SetGlobalsFromConfig()
Set up the global variables from the configuration parameters.
static ns3::GlobalValue g_verbose("VRCverbose", "Verbose 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
a polymophic address class
Definition: address.h:90
Ptr< YansWifiChannel > Create(void) const
ConfigStoreHelper()
Constructor.
channel
Definition: third.py:85
static ns3::GlobalValue g_cumulativeBsmCaptureStart("VRCcumulativeBsmCaptureStart", "Simulation starte time for capturing cumulative BSM", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
mobility
Definition: third.py:101
static TypeId GetTypeId(void)
Gets the class TypeId.
virtual void ProcessOutputs()
Process outputs.
static ns3::GlobalValue g_txSafetyRange10("VRCtxSafetyRange10", "BSM range for PDR inclusion", ns3::DoubleValue(500.0), ns3::MakeDoubleChecker< double >())
WaveBsmHelper m_waveBsmHelper
helper
void SetRxPkts(uint32_t rxPkts)
Sets the number of packets received.
static ns3::GlobalValue g_nodePause("VRCnodePause", "Node pause time (s) for RWP model", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
void SetChannel(Ptr< YansWifiChannel > channel)
static ns3::GlobalValue g_fading("VRCfading", "Fast Fading Model", 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: wave-helper.cc:315
std::string m_trName
trace file name
static ns3::GlobalValue g_txp("VRCtxp", "Transmission power dBm", ns3::DoubleValue(7.5), ns3::MakeDoubleChecker< double >())
void SetTxPkts(uint32_t txPkts)
Sets the number of packets transmitted.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetupRoutingMessages(NodeContainer &c, Ipv4InterfaceContainer &adhocTxInterfaces)
Sets up routing messages on the nodes and their interfaces.
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:369
std::string Get(void) const
Definition: string.cc:31
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.
uint32_t m_cumulativeTxBytes
cumulative transmit bytes
static ns3::GlobalValue g_logFile("VRClogFile", "Log filename", ns3::StringValue("low99-ct-unterstrass-1day.filt.7.adj.log"), ns3::MakeStringChecker())
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
bool m_traceMobility
trace mobility
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
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
static ns3::GlobalValue g_nSinks("VRCnSinks", "Number of sink nodes for routing non-BSM traffic", ns3::UintegerValue(10), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_protocol("VRCprotocol", "Routing protocol", ns3::UintegerValue(2), ns3::MakeUintegerChecker< uint32_t >())
helps to create WaveNetDevice objects
Definition: wave-helper.h:112
static ns3::GlobalValue g_routingTables("VRCroutingTables", "Dump routing tables at t=5 seconds 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_txMaxDelayMs("VRCtxMaxDelayMs", "Tx May Delay (ms)", ns3::DoubleValue(10), ns3::MakeDoubleChecker< double >())
holds a vector of ns3::NetDevice pointers
virtual void RunSimulation()
Run the simulation.
void SetupAdhocDevices()
Set up the adhoc devices.
std::string m_protocolName
protocol name
static ns3::GlobalValue g_trName("VRCtrName", "Trace name", ns3::StringValue("vanet-routing-compare"), ns3::MakeStringChecker())
uint32_t m_80211mode
80211 mode
void ConfigureDefaults()
Configure default attributes.
uint32_t m_protocol
routing protocol; 0=NONE, 1=OLSR, 2=AODV, 3=DSDV, 4=DSR
virtual void SetDefaultAttributeValues()
Sets default attribute values.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
virtual void ConfigureApplications()
Configure applications.
uint32_t m_phyTxBytes
phy transmit bytes
double m_txMaxDelayMs
transmit maximum delay
static ns3::GlobalValue g_txSafetyRange3("VRCtxSafetyRange3", "BSM range for PDR inclusion", ns3::DoubleValue(150.0), ns3::MakeDoubleChecker< double >())
The WaveBsmHelper class manages IEEE 1609 WAVE (Wireless Access in Vehicular Environments) Basic Safe...
RoutingStats()
Constructor.
void Run()
Run the simulation.
void SetupLogging()
Set up logging.
std::string m_protocolName
protocol name
Qos Wave Mac Helper class.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
Definition: command-line.h:213
std::string m_CSVfileName2
CSV file name.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:871
uint32_t m_nSinks
number of sinks
#define list
static ns3::GlobalValue g_port("VRCport", "Port", ns3::UintegerValue(9), ns3::MakeUintegerChecker< uint32_t >())
void SetupLogFile()
Set up log file.
void ConfigureDefaults(void)
Configure the default values.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
uint64_t Get(void) const
Definition: uinteger.cc:35
double Get(void) const
Definition: double.cc:35
WifiPhyStats()
Constructor.
std::string m_loadConfigFilename
load config file name
virtual void ConfigureChannels()
Configure channels.
static TypeId GetTypeId(void)
Get class TypeId.
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<T>.
Definition: pointer.h:36
virtual ~RoutingHelper()
Destructor.
void SetupRoutingProtocol(NodeContainer &c)
Sets up the protocol protocol on the nodes.
double m_TotalSimTime
seconds
virtual void ConfigureMobility()
Configure mobility.
static ns3::GlobalValue g_phyModeB("VRCphyModeB", "PHY mode (802.11a)", ns3::StringValue("DsssRate11Mbps"), ns3::MakeStringChecker())
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())
The VanetRoutingExperiment class implements a wifi app that allows VANET routing experiments to be si...
uint32_t m_RxPkts
receive packets
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void IncRxBytes(uint32_t rxBytes)
Increments the number of (application-data) bytes received, not including MAC/PHY overhead...
static ns3::GlobalValue g_80211mode("VRC80211mode", "802.11 mode (0=802.11a;1=802.11p)", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
uint32_t GetRxPkts()
Returns the count of packets received.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
bool SetValue(const AttributeValue &value)
Set the value of this GlobalValue.
Ptr< Socket > SetupRoutingPacketReceive(Ipv4Address addr, Ptr< Node > node)
Sets up a routing packet for tranmission.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
void SetTxBytes(uint32_t txBytes)
Sets the number of bytes transmitted.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wave-helper.cc:361
manage and create wifi channel objects for the yans model.
static ns3::GlobalValue g_txSafetyRange6("VRCtxSafetyRange6", "BSM range for PDR inclusion", ns3::DoubleValue(300.0), ns3::MakeDoubleChecker< double >())
void OnOffTrace(std::string context, Ptr< const Packet > packet)
Trace the receipt of an on-off-application generated packet.
virtual void ConfigureDevices()
Configure devices.
create MAC layers for a ns3::WifiNetDevice.
Definition: olsr.py:1
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
Definition: wave-helper.h:40
RoutingStats routingStats
routing statistics
virtual void ConfigureApplications()
Configure applications.
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:513
The ConfigStoreHelper class simplifies config-store raw text load and save.
void IncTxPkts()
Increment the count of packets transmitted.
int64_t m_streamIndex
used to get consistent random numbers across scenarios
Nqos Wave Mac Helper class.
void AssignIpAddresses(NetDeviceContainer &d, Ipv4InterfaceContainer &adhocTxInterfaces)
Assigns IPv4 addresses to net devices and their interfaces.
std::vector< double > m_txSafetyRanges
list of ranges
void PhyRxDrop(std::string context, Ptr< const Packet > packet)
Callback signiture for Phy/RxDrop.
int m_cumulativeBsmCaptureStart
capture start
void SetupScenario()
Set up a prescribed scenario.
uint32_t m_RxBytes
reeive bytes
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
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 GetTxPkts()
Returns the number of packets transmitted.
std::string m_lossModelName
loss model name
wifi
Definition: third.py:89
static ns3::GlobalValue g_txSafetyRange8("VRCtxSafetyRange8", "BSM range for PDR inclusion", ns3::DoubleValue(400.0), ns3::MakeDoubleChecker< double >())
uint32_t m_nSinks
number of sink nodes (< all nodes)
Helper class used to assign positions and mobility models to nodes.
static ns3::GlobalValue g_totalTime("VRCtotalTime", "Total simulation time (s)", ns3::DoubleValue(300.01), ns3::MakeDoubleChecker< double >())
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
static ns3::GlobalValue g_phyMode("VRCphyMode", "PHY mode (802.11p)", ns3::StringValue("OfdmRate6MbpsBW10MHz"), ns3::MakeStringChecker())
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...
static ns3::GlobalValue g_txSafetyRange4("VRCtxSafetyRange4", "BSM range for PDR inclusion", ns3::DoubleValue(200.0), ns3::MakeDoubleChecker< double >())
LOG_DEBUG and above.
Definition: log.h:103
void experiment(std::string queue_disc_type)
static ns3::GlobalValue g_lossModel("VRClossModel", "Propagation Loss Model", ns3::UintegerValue(3), ns3::MakeUintegerChecker< uint32_t >())
virtual void ConfigureMobility()
Configure mobility.
double m_gpsAccuracyNs
GPS accuracy.
virtual void SetDefaultAttributeValues()
Sets default attribute values.
uint32_t m_lossModel
loss model
RoutingStats & GetRoutingStats()
Returns the RoutingStats instance.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void Simulate(int argc, char **argv)
Enacts simulation of an ns-3 wifi application.
static ns3::GlobalValue g_txSafetyRange9("VRCtxSafetyRange9", "BSM range for PDR inclusion", ns3::DoubleValue(450.0), ns3::MakeDoubleChecker< double >())
uint32_t m_cumulativeTxPkts
cumulative transmit packets
void CheckThroughput()
Checks the throughput and outputs summary to CSV file1.
A network Node.
Definition: node.h:56
DSR helper class to manage creation of DSR routing instance and to insert it on a node as a sublayer ...
Definition: dsr-helper.h:52
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &macHelper, NodeContainer c) const
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:810
Ptr< WaveBsmStats > GetWaveBsmStats()
Returns the WaveBsmStats instance.
virtual void ConfigureTracing()
Configure tracing.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< WifiPhyStats > m_wifiPhyStats
wifi phy statistics
Helper class that adds ns3::Ipv4ListRouting objects.
static ns3::GlobalValue g_txSafetyRange5("VRCtxSafetyRange5", "BSM range for PDR inclusion", ns3::DoubleValue(250.0), ns3::MakeDoubleChecker< double >())
double m_TotalSimTime
total sim time
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:309
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:256
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 functionality on nodes and their devices and interfaces.
virtual void ConfigureDevices()
Configure devices.
uint32_t GetRxBytes()
Returns the number of bytes received.
ApplicationContainer Install(Ipv4InterfaceContainer i) const
Install an ns3::BsmApplication on each node of the input container configured with all the attributes...
std::ofstream m_os
output stream
static ns3::GlobalValue g_nodeSpeed("VRCnodeSpeed", "Node speed (m/s) for RWP model", ns3::UintegerValue(20), ns3::MakeUintegerChecker< uint32_t >())
Helper class that adds AODV routing to nodes.
Definition: aodv-helper.h:34
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
void SetPropagationDelay(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
uint32_t GetTxBytes()
Returns the number of bytes that have been transmitted (this includes MAC/PHY overhead) ...
void PhyTxTrace(std::string context, Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
Callback signiture for Phy/Tx trace.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
The WifiApp class enforces program flow for ns-3 wifi applications.
static ns3::GlobalValue g_pcap("VRCpcap", "Generate PCAP files 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_scenario("VRCscenario", "Scenario", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
uint32_t GetCumulativeTxBytes()
Returns the cumulative number of bytes transmitted.
static ns3::GlobalValue g_traceMobility("VRCtraceMobility", "Trace mobility 1=yes;0=no", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
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)
Install routing to the nodes.
void SetupAdhocMobilityNodes()
Set up the adhoc mobility nodes.
virtual ~WifiApp()
Destructor.
a unique identifier for an interface.
Definition: type-id.h:58
static void CourseChange(std::ostream *os, std::string context, Ptr< const MobilityModel > mobility)
Course change function.
Ptr< RoutingHelper > m_routingHelper
routing helper
void SetConfigFromGlobals()
Set up configuration parameter from the global variables.
uint32_t m_cumulativeRxPkts
cumulative receive packets
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
uint32_t m_nNodes
number of nodes
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
uint32_t m_phyTxPkts
phy transmit packets
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
static ns3::GlobalValue g_txSafetyRange1("VRCtxSafetyRange1", "BSM range for PDR inclusion", ns3::DoubleValue(50.0), ns3::MakeDoubleChecker< double >())
Ipv4Address GetIpv4(void) const
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
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...