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 ().As (Time::S) << " " << 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 
776  void PhyRxDrop (std::string context, Ptr<const Packet> packet, WifiPhyRxfailureReason reason);
777 
778 private:
779  uint32_t m_phyTxPkts;
780  uint32_t m_phyTxBytes;
781 };
782 
784 
785 TypeId
787 {
788  static TypeId tid = TypeId ("ns3::WifiPhyStats")
789  .SetParent<Object> ()
790  .AddConstructor<WifiPhyStats> ();
791  return tid;
792 }
793 
795  : m_phyTxPkts (0),
796  m_phyTxBytes (0)
797 {
798 }
799 
801 {
802 }
803 
804 void
805 WifiPhyStats::PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
806 {
807  NS_LOG_FUNCTION (this << context << packet << "PHYTX mode=" << mode );
808  ++m_phyTxPkts;
809  uint32_t pktSize = packet->GetSize ();
811 
812  //NS_LOG_UNCOND ("Received PHY size=" << pktSize);
813 }
814 
815 void
816 WifiPhyStats::PhyTxDrop (std::string context, Ptr<const Packet> packet)
817 {
818  NS_LOG_UNCOND ("PHY Tx Drop");
819 }
820 
821 void
823 {
824  NS_LOG_UNCOND ("PHY Rx Drop");
825 }
826 
827 uint32_t
829 {
830  return m_phyTxBytes;
831 }
832 
837 class WifiApp
838 {
839 public:
844  WifiApp ();
845 
850  virtual ~WifiApp ();
851 
858  void Simulate (int argc, char **argv);
859 
860 protected:
865  virtual void SetDefaultAttributeValues ();
866 
873  virtual void ParseCommandLineArguments (int argc, char **argv);
874 
879  virtual void ConfigureNodes ();
880 
885  virtual void ConfigureChannels ();
886 
891  virtual void ConfigureDevices ();
892 
897  virtual void ConfigureMobility ();
898 
903  virtual void ConfigureApplications ();
904 
909  virtual void ConfigureTracing ();
910 
915  virtual void RunSimulation ();
916 
921  virtual void ProcessOutputs ();
922 };
923 
925 {
926 }
927 
929 {
930 }
931 
932 void
933 WifiApp::Simulate (int argc, char **argv)
934 {
935  // Simulator Program Flow:
936  // (source: NS-3 Annual Meeting, May, 2014, session 2 slides 6, 28)
937  // (HandleProgramInputs:)
938  // SetDefaultAttributeValues
939  // ParseCommandLineArguments
940  // (ConfigureTopology:)
941  // ConfigureNodes
942  // ConfigureChannels
943  // ConfigureDevices
944  // ConfigureMobility
945  // ConfigureApplications
946  // e.g AddInternetStackToNodes
947  // ConfigureIpAddressingAndRouting
948  // configureSendMessages
949  // ConfigureTracing
950  // RunSimulation
951  // ProcessOutputs
952 
954  ParseCommandLineArguments (argc, argv);
955  ConfigureNodes ();
957  ConfigureDevices ();
960  ConfigureTracing ();
961  RunSimulation ();
962  ProcessOutputs ();
963 }
964 
965 void
967 {
968 }
969 
970 void
971 WifiApp::ParseCommandLineArguments (int argc, char **argv)
972 {
973 }
974 
975 void
977 {
978 }
979 
980 void
982 {
983 }
984 
985 void
987 {
988 }
989 
990 void
992 {
993 }
994 
995 void
997 {
998 }
999 
1000 void
1002 {
1003 }
1004 
1005 void
1007 {
1008 }
1009 
1010 void
1012 {
1013 }
1014 
1020 {
1021 public:
1026  ConfigStoreHelper ();
1027 
1033  void LoadConfig (std::string configFilename);
1034 
1040  void SaveConfig (std::string configFilename);
1041 };
1042 
1044 {
1045 }
1046 
1047 void
1048 ConfigStoreHelper::LoadConfig (std::string configFilename)
1049 {
1050  // Input config store from txt format
1051  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1052  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1053  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Load"));
1054  ConfigStore inputConfig;
1055  inputConfig.ConfigureDefaults ();
1056  //inputConfig.ConfigureAttributes ();
1057 }
1058 
1059 void
1060 ConfigStoreHelper::SaveConfig (std::string configFilename)
1061 {
1062  // only save if a non-empty filename has been specified
1063  if (configFilename.compare ("") != 0)
1064  {
1065  // Output config store to txt format
1066  Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (configFilename));
1067  Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("RawText"));
1068  Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
1069  ConfigStore outputConfig;
1070  outputConfig.ConfigureDefaults ();
1071  //outputConfig.ConfigureAttributes ();
1072  }
1073 }
1074 
1081 {
1082 public:
1088 
1089 protected:
1094  virtual void SetDefaultAttributeValues ();
1095 
1102  virtual void ParseCommandLineArguments (int argc, char **argv);
1103 
1108  virtual void ConfigureNodes ();
1109 
1114  virtual void ConfigureChannels ();
1115 
1120  virtual void ConfigureDevices ();
1121 
1126  virtual void ConfigureMobility ();
1127 
1132  virtual void ConfigureApplications ();
1133 
1138  virtual void ConfigureTracing ();
1139 
1144  virtual void RunSimulation ();
1145 
1150  virtual void ProcessOutputs ();
1151 
1152 private:
1157  void Run ();
1158 
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 
1250  static void
1251  CourseChange (std::ostream *os, std::string context, Ptr<const MobilityModel> mobility);
1252 
1253  uint32_t m_port;
1254  std::string m_CSVfileName;
1255  std::string m_CSVfileName2;
1256  uint32_t m_nSinks;
1257  std::string m_protocolName;
1258  double m_txp;
1260  uint32_t m_protocol;
1261 
1262  uint32_t m_lossModel;
1263  uint32_t m_fading;
1264  std::string m_lossModelName;
1265 
1266  std::string m_phyMode;
1267  uint32_t m_80211mode;
1268 
1269  std::string m_traceFile;
1270  std::string m_logFile;
1271  uint32_t m_mobility;
1272  uint32_t m_nNodes;
1274  std::string m_rate;
1275  std::string m_phyModeB;
1276  std::string m_trName;
1279  uint32_t m_wavePacketSize;
1282  std::ofstream m_os;
1285  uint32_t m_scenario;
1290  int m_pcap;
1291  std::string m_loadConfigFilename;
1292  std::string m_saveConfigFilename;
1293 
1297  int m_log;
1298  int64_t m_streamIndex;
1311  std::vector <double> m_txSafetyRanges;
1312  std::string m_exp;
1314 };
1315 
1317  : m_port (9),
1318  m_CSVfileName ("vanet-routing.output.csv"),
1319  m_CSVfileName2 ("vanet-routing.output2.csv"),
1320  m_nSinks (10),
1321  m_protocolName ("protocol"),
1322  m_txp (20),
1323  m_traceMobility (false),
1324  // AODV
1325  m_protocol (2),
1326  // Two-Ray ground
1327  m_lossModel (3),
1328  m_fading (0),
1329  m_lossModelName (""),
1330  m_phyMode ("OfdmRate6MbpsBW10MHz"),
1331  // 1=802.11p
1332  m_80211mode (1),
1333  m_traceFile (""),
1334  m_logFile ("low99-ct-unterstrass-1day.filt.7.adj.log"),
1335  m_mobility (1),
1336  m_nNodes (156),
1337  m_TotalSimTime (300.01),
1338  m_rate ("2048bps"),
1339  m_phyModeB ("DsssRate11Mbps"),
1340  m_trName ("vanet-routing-compare"),
1341  m_nodeSpeed (20),
1342  m_nodePause (0),
1343  m_wavePacketSize (200),
1344  m_waveInterval (0.1),
1345  m_verbose (0),
1346  m_scenario (1),
1347  m_gpsAccuracyNs (40),
1348  m_txMaxDelayMs (10),
1349  m_routingTables (0),
1350  m_asciiTrace (0),
1351  m_pcap (0),
1352  m_loadConfigFilename ("load-config.txt"),
1353  m_saveConfigFilename (""),
1354  m_log (0),
1355  m_streamIndex (0),
1356  m_adhocTxNodes (),
1357  m_txSafetyRange1 (50.0),
1358  m_txSafetyRange2 (100.0),
1359  m_txSafetyRange3 (150.0),
1360  m_txSafetyRange4 (200.0),
1361  m_txSafetyRange5 (250.0),
1362  m_txSafetyRange6 (300.0),
1363  m_txSafetyRange7 (350.0),
1364  m_txSafetyRange8 (400.0),
1365  m_txSafetyRange9 (450.0),
1366  m_txSafetyRange10 (500.0),
1367  m_txSafetyRanges (),
1368  m_exp (""),
1369  m_cumulativeBsmCaptureStart (0)
1370 {
1371  m_wifiPhyStats = CreateObject<WifiPhyStats> ();
1372  m_routingHelper = CreateObject<RoutingHelper> ();
1373 
1374  // set to non-zero value to enable
1375  // simply uncond logging during simulation run
1376  m_log = 1;
1377 }
1378 
1379 void
1381 {
1382  // handled in constructor
1383 }
1384 
1385 // important configuration items stored in global values
1386 static ns3::GlobalValue g_port ("VRCport",
1387  "Port",
1388  ns3::UintegerValue (9),
1389  ns3::MakeUintegerChecker<uint32_t> ());
1390 static ns3::GlobalValue g_nSinks ("VRCnSinks",
1391  "Number of sink nodes for routing non-BSM traffic",
1392  ns3::UintegerValue (10),
1393  ns3::MakeUintegerChecker<uint32_t> ());
1394 static ns3::GlobalValue g_traceMobility ("VRCtraceMobility",
1395  "Trace mobility 1=yes;0=no",
1396  ns3::UintegerValue (0),
1397  ns3::MakeUintegerChecker<uint32_t> ());
1398 static ns3::GlobalValue g_protocol ("VRCprotocol",
1399  "Routing protocol",
1400  ns3::UintegerValue (2),
1401  ns3::MakeUintegerChecker<uint32_t> ());
1402 static ns3::GlobalValue g_lossModel ("VRClossModel",
1403  "Propagation Loss Model",
1404  ns3::UintegerValue (3),
1405  ns3::MakeUintegerChecker<uint32_t> ());
1406 static ns3::GlobalValue g_fading ("VRCfading",
1407  "Fast Fading Model",
1408  ns3::UintegerValue (0),
1409  ns3::MakeUintegerChecker<uint32_t> ());
1410 static ns3::GlobalValue g_80211mode ("VRC80211mode",
1411  "802.11 mode (0=802.11a;1=802.11p)",
1412  ns3::UintegerValue (1),
1413  ns3::MakeUintegerChecker<uint32_t> ());
1414 static ns3::GlobalValue g_mobility ("VRCmobility",
1415  "Mobility mode 0=random waypoint;1=mobility trace file",
1416  ns3::UintegerValue (1),
1417  ns3::MakeUintegerChecker<uint32_t> ());
1418 static ns3::GlobalValue g_nNodes ("VRCnNodes",
1419  "Number of nodes (vehicles)",
1420  ns3::UintegerValue (156),
1421  ns3::MakeUintegerChecker<uint32_t> ());
1422 static ns3::GlobalValue g_nodeSpeed ("VRCnodeSpeed",
1423  "Node speed (m/s) for RWP model",
1424  ns3::UintegerValue (20),
1425  ns3::MakeUintegerChecker<uint32_t> ());
1426 static ns3::GlobalValue g_nodePause ("VRCnodePause",
1427  "Node pause time (s) for RWP model",
1428  ns3::UintegerValue (0),
1429  ns3::MakeUintegerChecker<uint32_t> ());
1430 static ns3::GlobalValue g_wavePacketSize ("VRCwavePacketSize",
1431  "Size in bytes of WAVE BSM",
1432  ns3::UintegerValue (200),
1433  ns3::MakeUintegerChecker<uint32_t> ());
1434 static ns3::GlobalValue g_verbose ("VRCverbose",
1435  "Verbose 0=no;1=yes",
1436  ns3::UintegerValue (0),
1437  ns3::MakeUintegerChecker<uint32_t> ());
1438 static ns3::GlobalValue g_scenario ("VRCscenario",
1439  "Scenario",
1440  ns3::UintegerValue (1),
1441  ns3::MakeUintegerChecker<uint32_t> ());
1442 static ns3::GlobalValue g_routingTables ("VRCroutingTables",
1443  "Dump routing tables at t=5 seconds 0=no;1=yes",
1444  ns3::UintegerValue (0),
1445  ns3::MakeUintegerChecker<uint32_t> ());
1446 static ns3::GlobalValue g_asciiTrace ("VRCasciiTrace",
1447  "Dump ASCII trace 0=no;1=yes",
1448  ns3::UintegerValue (0),
1449  ns3::MakeUintegerChecker<uint32_t> ());
1450 static ns3::GlobalValue g_pcap ("VRCpcap",
1451  "Generate PCAP files 0=no;1=yes",
1452  ns3::UintegerValue (0),
1453  ns3::MakeUintegerChecker<uint32_t> ());
1454 static ns3::GlobalValue g_cumulativeBsmCaptureStart ("VRCcumulativeBsmCaptureStart",
1455  "Simulation start time for capturing cumulative BSM",
1456  ns3::TimeValue (Seconds (0)),
1458 
1459 static ns3::GlobalValue g_txSafetyRange1 ("VRCtxSafetyRange1",
1460  "BSM range for PDR inclusion",
1461  ns3::DoubleValue (50.0),
1462  ns3::MakeDoubleChecker<double> ());
1463 
1464 static ns3::GlobalValue g_txSafetyRange2 ("VRCtxSafetyRange2",
1465  "BSM range for PDR inclusion",
1466  ns3::DoubleValue (100.0),
1467  ns3::MakeDoubleChecker<double> ());
1468 
1469 static ns3::GlobalValue g_txSafetyRange3 ("VRCtxSafetyRange3",
1470  "BSM range for PDR inclusion",
1471  ns3::DoubleValue (150.0),
1472  ns3::MakeDoubleChecker<double> ());
1473 
1474 static ns3::GlobalValue g_txSafetyRange4 ("VRCtxSafetyRange4",
1475  "BSM range for PDR inclusion",
1476  ns3::DoubleValue (200.0),
1477  ns3::MakeDoubleChecker<double> ());
1478 
1479 static ns3::GlobalValue g_txSafetyRange5 ("VRCtxSafetyRange5",
1480  "BSM range for PDR inclusion",
1481  ns3::DoubleValue (250.0),
1482  ns3::MakeDoubleChecker<double> ());
1483 static ns3::GlobalValue g_txSafetyRange6 ("VRCtxSafetyRange6",
1484  "BSM range for PDR inclusion",
1485  ns3::DoubleValue (300.0),
1486  ns3::MakeDoubleChecker<double> ());
1487 static ns3::GlobalValue g_txSafetyRange7 ("VRCtxSafetyRange7",
1488  "BSM range for PDR inclusion",
1489  ns3::DoubleValue (350.0),
1490  ns3::MakeDoubleChecker<double> ());
1491 static ns3::GlobalValue g_txSafetyRange8 ("VRCtxSafetyRange8",
1492  "BSM range for PDR inclusion",
1493  ns3::DoubleValue (400.0),
1494  ns3::MakeDoubleChecker<double> ());
1495 static ns3::GlobalValue g_txSafetyRange9 ("VRCtxSafetyRange9",
1496  "BSM range for PDR inclusion",
1497  ns3::DoubleValue (450.0),
1498  ns3::MakeDoubleChecker<double> ());
1499 static ns3::GlobalValue g_txSafetyRange10 ("VRCtxSafetyRange10",
1500  "BSM range for PDR inclusion",
1501  ns3::DoubleValue (500.0),
1502  ns3::MakeDoubleChecker<double> ());
1503 static ns3::GlobalValue g_txp ("VRCtxp",
1504  "Transmission power dBm",
1505  ns3::DoubleValue (7.5),
1506  ns3::MakeDoubleChecker<double> ());
1507 static ns3::GlobalValue g_totalTime ("VRCtotalTime",
1508  "Total simulation time (s)",
1509  ns3::DoubleValue (300.01),
1510  ns3::MakeDoubleChecker<double> ());
1511 static ns3::GlobalValue g_waveInterval ("VRCwaveInterval",
1512  "Interval (s) between WAVE BSMs",
1513  ns3::DoubleValue (0.1),
1514  ns3::MakeDoubleChecker<double> ());
1515 static ns3::GlobalValue g_gpsAccuracyNs ("VRCgpsAccuracyNs",
1516  "GPS sync accuracy (ns)",
1517  ns3::DoubleValue (40),
1518  ns3::MakeDoubleChecker<double> ());
1519 static ns3::GlobalValue g_txMaxDelayMs ("VRCtxMaxDelayMs",
1520  "Tx May Delay (ms)",
1521  ns3::DoubleValue (10),
1522  ns3::MakeDoubleChecker<double> ());
1523 static ns3::GlobalValue g_CSVfileName ("VRCCSVfileName",
1524  "CSV filename (for time series data)",
1525  ns3::StringValue ("vanet-routing.output.csv"),
1527 static ns3::GlobalValue g_CSVfileName2 ("VRCCSVfileName2",
1528  "CSV filename 2 (for overall simulation scenario results)",
1529  ns3::StringValue ("vanet-routing.output2.csv"),
1531 static ns3::GlobalValue g_phyMode ("VRCphyMode",
1532  "PHY mode (802.11p)",
1533  ns3::StringValue ("OfdmRate6MbpsBW10MHz"),
1535 static ns3::GlobalValue g_traceFile ("VRCtraceFile",
1536  "Mobility trace filename",
1537  ns3::StringValue ("./src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob"),
1539 static ns3::GlobalValue g_logFile ("VRClogFile",
1540  "Log filename",
1541  ns3::StringValue ("low99-ct-unterstrass-1day.filt.7.adj.log"),
1543 static ns3::GlobalValue g_rate ("VRCrate",
1544  "Data rate",
1545  ns3::StringValue ("2048bps"),
1547 static ns3::GlobalValue g_phyModeB ("VRCphyModeB",
1548  "PHY mode (802.11a)",
1549  ns3::StringValue ("DsssRate11Mbps"),
1551 static ns3::GlobalValue g_trName ("VRCtrName",
1552  "Trace name",
1553  ns3::StringValue ("vanet-routing-compare"),
1555 
1556 void
1558 {
1559  CommandSetup (argc, argv);
1560  SetupScenario ();
1561 
1562  // user may specify up to 10 different tx distances
1563  // to be used for calculating different values of Packet
1564  // Delivery Ratio (PDR). Used to see the effects of
1565  // fading over distance
1566  m_txSafetyRanges.resize (10, 0);
1577 
1578  ConfigureDefaults ();
1579 
1580  // we are done with all configuration
1581  // save config-store, if requested
1583  ConfigStoreHelper configStoreHelper;
1584  configStoreHelper.SaveConfig (m_saveConfigFilename);
1585 
1586  m_waveBsmHelper.GetWaveBsmStats ()->SetLogging (m_log);
1588 }
1589 
1590 void
1592 {
1594 }
1595 
1596 void
1598 {
1599  // set up channel and devices
1600  SetupAdhocDevices ();
1601 }
1602 
1603 void
1605 {
1606  // devices are set up in SetupAdhocDevices(),
1607  // called by ConfigureChannels()
1608 
1609  // use a PHY callback for tracing
1610  // to determine the total amount of
1611  // data transmitted, and then used to calculate
1612  // the MAC/PHY overhead beyond the app-data
1613  if (m_80211mode == 3)
1614  {
1615  // WAVE
1616  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/State/Tx", MakeCallback (&WifiPhyStats::PhyTxTrace, m_wifiPhyStats));
1617  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/PhyTxDrop", MakeCallback (&WifiPhyStats::PhyTxDrop, m_wifiPhyStats));
1618  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/PhyRxDrop", MakeCallback (&WifiPhyStats::PhyRxDrop, m_wifiPhyStats));
1619  }
1620  else
1621  {
1622  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&WifiPhyStats::PhyTxTrace, m_wifiPhyStats));
1623  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback (&WifiPhyStats::PhyTxDrop, m_wifiPhyStats));
1624  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback (&WifiPhyStats::PhyRxDrop, m_wifiPhyStats));
1625 }
1626  }
1627 
1628 void
1630 {
1632 }
1633 
1634 void
1636 {
1637  // Traffic mix consists of:
1638  // 1. routing data
1639  // 2. Broadcasting of Basic Safety Message (BSM)
1641  SetupWaveMessages ();
1642 
1643  // config trace to capture app-data (bytes) for
1644  // routing data, subtracted and used for
1645  // routing overhead
1646  std::ostringstream oss;
1647  oss.str ("");
1648  oss << "/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx";
1650 }
1651 
1652 void
1654 {
1655  WriteCsvHeader ();
1656  SetupLogFile ();
1657  SetupLogging ();
1658 
1659  AsciiTraceHelper ascii;
1660  MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (m_trName + ".mob"));
1661 }
1662 
1663 void
1665 {
1666  Run ();
1667 }
1668 
1669 void
1671 {
1672  // calculate and output final results
1673  double bsm_pdr1 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (1);
1674  double bsm_pdr2 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (2);
1675  double bsm_pdr3 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (3);
1676  double bsm_pdr4 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (4);
1677  double bsm_pdr5 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (5);
1678  double bsm_pdr6 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (6);
1679  double bsm_pdr7 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (7);
1680  double bsm_pdr8 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (8);
1681  double bsm_pdr9 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (9);
1682  double bsm_pdr10 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (10);
1683 
1684  double averageRoutingGoodputKbps = 0.0;
1685  uint32_t totalBytesTotal = m_routingHelper->GetRoutingStats ().GetCumulativeRxBytes ();
1686  averageRoutingGoodputKbps = (((double) totalBytesTotal * 8.0) / m_TotalSimTime) / 1000.0;
1687 
1688  // calculate MAC/PHY overhead (mac-phy-oh)
1689  // total WAVE BSM bytes sent
1690  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1691  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1692  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1693  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1694  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1695  double mac_phy_oh = 0.0;
1696  if (totalPhyBytes > 0)
1697  {
1698  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1699  }
1700 
1701  if (m_log != 0)
1702  {
1703  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);
1704 
1705  }
1706 
1707  std::ofstream out (m_CSVfileName2.c_str (), std::ios::app);
1708 
1709  out << bsm_pdr1 << ","
1710  << bsm_pdr2 << ","
1711  << bsm_pdr3 << ","
1712  << bsm_pdr4 << ","
1713  << bsm_pdr5 << ","
1714  << bsm_pdr6 << ","
1715  << bsm_pdr7 << ","
1716  << bsm_pdr8 << ","
1717  << bsm_pdr9 << ","
1718  << bsm_pdr10 << ","
1719  << averageRoutingGoodputKbps << ","
1720  << mac_phy_oh << ""
1721  << std::endl;
1722 
1723  out.close ();
1724 
1725  m_os.close (); // close log file
1726 }
1727 
1728 void
1730 {
1731  NS_LOG_INFO ("Run Simulation.");
1732 
1733  CheckThroughput ();
1734 
1735  Simulator::Stop (Seconds (m_TotalSimTime));
1736  Simulator::Run ();
1737  Simulator::Destroy ();
1738 }
1739 
1740 // Prints actual position and velocity when a course change event occurs
1741 void
1743 CourseChange (std::ostream *os, std::string context, Ptr<const MobilityModel> mobility)
1744 {
1745  Vector pos = mobility->GetPosition (); // Get position
1746  Vector vel = mobility->GetVelocity (); // Get velocity
1747 
1748  pos.z = 1.5;
1749 
1750  int nodeId = mobility->GetObject<Node> ()->GetId ();
1751  double t = (Simulator::Now ()).GetSeconds ();
1752  if (t >= 1.0)
1753  {
1754  WaveBsmHelper::GetNodesMoving ()[nodeId] = 1;
1755  }
1756 
1757  //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::Now () );
1758 
1759  // Prints position and velocities
1760  *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y
1761  << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
1762  << ", z=" << vel.z << std::endl;
1763 }
1764 
1765 void
1767 {
1768  uint32_t bytesTotal = m_routingHelper->GetRoutingStats ().GetRxBytes ();
1770  double kbps = (bytesTotal * 8.0) / 1000;
1771  double wavePDR = 0.0;
1772  int wavePktsSent = m_waveBsmHelper.GetWaveBsmStats ()->GetTxPktCount ();
1773  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1774  if (wavePktsSent > 0)
1775  {
1776  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1777  wavePDR = (double) wavePktsReceived / (double) wavePktsSent;
1778  }
1779 
1780  int waveExpectedRxPktCount = m_waveBsmHelper.GetWaveBsmStats ()->GetExpectedRxPktCount (1);
1781  int waveRxPktInRangeCount = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktInRangeCount (1);
1782  double wavePDR1_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (1);
1783  double wavePDR2_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (2);
1784  double wavePDR3_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (3);
1785  double wavePDR4_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (4);
1786  double wavePDR5_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (5);
1787  double wavePDR6_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (6);
1788  double wavePDR7_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (7);
1789  double wavePDR8_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (8);
1790  double wavePDR9_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (9);
1791  double wavePDR10_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (10);
1792 
1793  // calculate MAC/PHY overhead (mac-phy-oh)
1794  // total WAVE BSM bytes sent
1795  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1796  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1797  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1798  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1799  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1800  double mac_phy_oh = 0.0;
1801  if (totalPhyBytes > 0)
1802  {
1803  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1804  }
1805 
1806  std::ofstream out (m_CSVfileName.c_str (), std::ios::app);
1807 
1808  if (m_log != 0 )
1809  {
1810  NS_LOG_UNCOND ("At t=" << (Simulator::Now ()).As (Time::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*/);
1811  }
1812 
1813  out << (Simulator::Now ()).As (Time::S) << ","
1814  << kbps << ","
1815  << packetsReceived << ","
1816  << m_nSinks << ","
1817  << m_protocolName << ","
1818  << m_txp << ","
1819  << wavePktsSent << ","
1820  << wavePktsReceived << ","
1821  << wavePDR << ","
1822  << waveExpectedRxPktCount << ","
1823  << waveRxPktInRangeCount << ","
1824  << wavePDR1_2 << ","
1825  << wavePDR2_2 << ","
1826  << wavePDR3_2 << ","
1827  << wavePDR4_2 << ","
1828  << wavePDR5_2 << ","
1829  << wavePDR6_2 << ","
1830  << wavePDR7_2 << ","
1831  << wavePDR8_2 << ","
1832  << wavePDR9_2 << ","
1833  << wavePDR10_2 << ","
1834  << mac_phy_oh << ""
1835  << std::endl;
1836 
1837  out.close ();
1838 
1841  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktCount (0);
1842  m_waveBsmHelper.GetWaveBsmStats ()->SetTxPktCount (0);
1843  for (int index = 1; index <= 10; index++)
1844  {
1845  m_waveBsmHelper.GetWaveBsmStats ()->SetExpectedRxPktCount (index, 0);
1846  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktInRangeCount (index, 0);
1847  }
1848 
1849  Time currentTime = Simulator::Now ();
1850  if (currentTime <= m_cumulativeBsmCaptureStart)
1851  {
1852  for (int index = 1; index <= 10; index++)
1853  {
1854  m_waveBsmHelper.GetWaveBsmStats ()->ResetTotalRxPktCounts (index);
1855  }
1856  }
1857 
1858  Simulator::Schedule (Seconds (1.0), &VanetRoutingExperiment::CheckThroughput, this);
1859 }
1860 
1861 void
1863 {
1864  // get settings saved from config-store
1865  UintegerValue uintegerValue;
1866  DoubleValue doubleValue;
1867  StringValue stringValue;
1868  TimeValue timeValue;
1869 
1870  // This may not be the best way to manage program configuration
1871  // (directing them through global values), but management
1872  // through the config-store here is copied from
1873  // src/lte/examples/lena-dual-stripe.cc
1874 
1875  GlobalValue::GetValueByName ("VRCport", uintegerValue);
1876  m_port = uintegerValue.Get ();
1877  GlobalValue::GetValueByName ("VRCnSinks", uintegerValue);
1878  m_nSinks = uintegerValue.Get ();
1879  GlobalValue::GetValueByName ("VRCtraceMobility", uintegerValue);
1880  m_traceMobility = uintegerValue.Get ();
1881  GlobalValue::GetValueByName ("VRCprotocol", uintegerValue);
1882  m_protocol = uintegerValue.Get ();
1883  GlobalValue::GetValueByName ("VRClossModel", uintegerValue);
1884  m_lossModel = uintegerValue.Get ();
1885  GlobalValue::GetValueByName ("VRCfading", uintegerValue);
1886  m_fading = uintegerValue.Get ();
1887  GlobalValue::GetValueByName ("VRC80211mode", uintegerValue);
1888  m_80211mode = uintegerValue.Get ();
1889  GlobalValue::GetValueByName ("VRCmobility", uintegerValue);
1890  m_mobility = uintegerValue.Get ();
1891  GlobalValue::GetValueByName ("VRCnNodes", uintegerValue);
1892  m_nNodes = uintegerValue.Get ();
1893  GlobalValue::GetValueByName ("VRCnodeSpeed", uintegerValue);
1894  m_nodeSpeed = uintegerValue.Get ();
1895  GlobalValue::GetValueByName ("VRCnodePause", uintegerValue);
1896  m_nodePause = uintegerValue.Get ();
1897  GlobalValue::GetValueByName ("VRCwavePacketSize", uintegerValue);
1898  m_wavePacketSize = uintegerValue.Get ();
1899  GlobalValue::GetValueByName ("VRCverbose", uintegerValue);
1900  m_verbose = uintegerValue.Get ();
1901  GlobalValue::GetValueByName ("VRCscenario", uintegerValue);
1902  m_scenario = uintegerValue.Get ();
1903  GlobalValue::GetValueByName ("VRCroutingTables", uintegerValue);
1904  m_routingTables = uintegerValue.Get ();
1905  GlobalValue::GetValueByName ("VRCasciiTrace", uintegerValue);
1906  m_asciiTrace = uintegerValue.Get ();
1907  GlobalValue::GetValueByName ("VRCpcap", uintegerValue);
1908  m_pcap = uintegerValue.Get ();
1909  GlobalValue::GetValueByName ("VRCcumulativeBsmCaptureStart", timeValue);
1910  m_cumulativeBsmCaptureStart = timeValue.Get ();
1911 
1912 
1913  GlobalValue::GetValueByName ("VRCtxSafetyRange1", doubleValue);
1914  m_txSafetyRange1 = doubleValue.Get ();
1915  GlobalValue::GetValueByName ("VRCtxSafetyRange2", doubleValue);
1916  m_txSafetyRange2 = doubleValue.Get ();
1917  GlobalValue::GetValueByName ("VRCtxSafetyRange3", doubleValue);
1918  m_txSafetyRange3 = doubleValue.Get ();
1919  GlobalValue::GetValueByName ("VRCtxSafetyRange4", doubleValue);
1920  m_txSafetyRange4 = doubleValue.Get ();
1921  GlobalValue::GetValueByName ("VRCtxSafetyRange5", doubleValue);
1922  m_txSafetyRange5 = doubleValue.Get ();
1923  GlobalValue::GetValueByName ("VRCtxSafetyRange6", doubleValue);
1924  m_txSafetyRange6 = doubleValue.Get ();
1925  GlobalValue::GetValueByName ("VRCtxSafetyRange7", doubleValue);
1926  m_txSafetyRange7 = doubleValue.Get ();
1927  GlobalValue::GetValueByName ("VRCtxSafetyRange8", doubleValue);
1928  m_txSafetyRange8 = doubleValue.Get ();
1929  GlobalValue::GetValueByName ("VRCtxSafetyRange9", doubleValue);
1930  m_txSafetyRange9 = doubleValue.Get ();
1931  GlobalValue::GetValueByName ("VRCtxSafetyRange10", doubleValue);
1932  m_txSafetyRange10 = doubleValue.Get ();
1933  GlobalValue::GetValueByName ("VRCtxp", doubleValue);
1934  m_txp = doubleValue.Get ();
1935  GlobalValue::GetValueByName ("VRCtotalTime", doubleValue);
1936  m_TotalSimTime = doubleValue.Get ();
1937  GlobalValue::GetValueByName ("VRCwaveInterval", doubleValue);
1938  m_waveInterval = doubleValue.Get ();
1939  GlobalValue::GetValueByName ("VRCgpsAccuracyNs", doubleValue);
1940  m_gpsAccuracyNs = doubleValue.Get ();
1941  GlobalValue::GetValueByName ("VRCtxMaxDelayMs", doubleValue);
1942  m_txMaxDelayMs = doubleValue.Get ();
1943 
1944  GlobalValue::GetValueByName ("VRCCSVfileName", stringValue);
1945  m_CSVfileName = stringValue.Get ();
1946  GlobalValue::GetValueByName ("VRCCSVfileName2", stringValue);
1947  m_CSVfileName2 = stringValue.Get ();
1948  GlobalValue::GetValueByName ("VRCphyMode", stringValue);
1949  m_phyMode = stringValue.Get ();
1950  GlobalValue::GetValueByName ("VRCtraceFile", stringValue);
1951  m_traceFile = stringValue.Get ();
1952  GlobalValue::GetValueByName ("VRClogFile", stringValue);
1953  m_logFile = stringValue.Get ();
1954  GlobalValue::GetValueByName ("VRCrate", stringValue);
1955  m_rate = stringValue.Get ();
1956  GlobalValue::GetValueByName ("VRCphyModeB", stringValue);
1957  m_phyModeB = stringValue.Get ();
1958  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1959  m_trName = stringValue.Get ();
1960 }
1961 
1962 void
1964 {
1965  // get settings saved from config-store
1966  UintegerValue uintegerValue;
1967  DoubleValue doubleValue;
1968  StringValue stringValue;
1969 
1988 
2004 
2013  GlobalValue::GetValueByName ("VRCtrName", stringValue);
2014  m_trName = stringValue.Get ();
2015 }
2016 
2017 void
2019 {
2020  CommandLine cmd (__FILE__);
2021  double txDist1 = 50.0;
2022  double txDist2 = 100.0;
2023  double txDist3 = 150.0;
2024  double txDist4 = 200.0;
2025  double txDist5 = 250.0;
2026  double txDist6 = 300.0;
2027  double txDist7 = 350.0;
2028  double txDist8 = 350.0;
2029  double txDist9 = 350.0;
2030  double txDist10 = 350.0;
2031 
2032  // allow command line overrides
2033  cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName);
2034  cmd.AddValue ("CSVfileName2", "The name of the CSV output file name2", m_CSVfileName2);
2035  cmd.AddValue ("totaltime", "Simulation end time", m_TotalSimTime);
2036  cmd.AddValue ("nodes", "Number of nodes (i.e. vehicles)", m_nNodes);
2037  cmd.AddValue ("sinks", "Number of routing sinks", m_nSinks);
2038  cmd.AddValue ("txp", "Transmit power (dB), e.g. txp=7.5", m_txp);
2039  cmd.AddValue ("traceMobility", "Enable mobility tracing", m_traceMobility);
2040  cmd.AddValue ("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol);
2041  cmd.AddValue ("lossModel", "1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance", m_lossModel);
2042  cmd.AddValue ("fading", "0=None;1=Nakagami;(buildings=1 overrides)", m_fading);
2043  cmd.AddValue ("phyMode", "Wifi Phy mode", m_phyMode);
2044  cmd.AddValue ("80211Mode", "1=802.11p; 2=802.11b; 3=WAVE-PHY", m_80211mode);
2045  cmd.AddValue ("traceFile", "Ns2 movement trace file", m_traceFile);
2046  cmd.AddValue ("logFile", "Log file", m_logFile);
2047  cmd.AddValue ("mobility", "1=trace;2=RWP", m_mobility);
2048  cmd.AddValue ("rate", "Rate", m_rate);
2049  cmd.AddValue ("phyModeB", "Phy mode 802.11b", m_phyModeB);
2050  cmd.AddValue ("speed", "Node speed (m/s)", m_nodeSpeed);
2051  cmd.AddValue ("pause", "Node pause (s)", m_nodePause);
2052  cmd.AddValue ("verbose", "0=quiet;1=verbose", m_verbose);
2053  cmd.AddValue ("bsm", "(WAVE) BSM size (bytes)", m_wavePacketSize);
2054  cmd.AddValue ("interval", "(WAVE) BSM interval (s)", m_waveInterval);
2055  cmd.AddValue ("scenario", "1=synthetic, 2=playback-trace", m_scenario);
2056  // User is allowed to have up to 10 different PDRs (Packet
2057  // Delivery Ratios) calculate, and so can specify up to
2058  // 10 different tx distances.
2059  cmd.AddValue ("txdist1", "Expected BSM tx range, m", txDist1);
2060  cmd.AddValue ("txdist2", "Expected BSM tx range, m", txDist2);
2061  cmd.AddValue ("txdist3", "Expected BSM tx range, m", txDist3);
2062  cmd.AddValue ("txdist4", "Expected BSM tx range, m", txDist4);
2063  cmd.AddValue ("txdist5", "Expected BSM tx range, m", txDist5);
2064  cmd.AddValue ("txdist6", "Expected BSM tx range, m", txDist6);
2065  cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7);
2066  cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8);
2067  cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9);
2068  cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10);
2069  cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs);
2070  cmd.AddValue ("txmaxdelay", "Tx max delay, in ms", m_txMaxDelayMs);
2071  cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routingTables);
2072  cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace);
2073  cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap);
2074  cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilename);
2075  cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilename);
2076  cmd.AddValue ("exp", "Experiment", m_exp);
2077  cmd.AddValue ("BsmCaptureStart", "Start time to begin capturing pkts for cumulative Bsm", m_cumulativeBsmCaptureStart);
2078  cmd.Parse (argc, argv);
2079 
2080  m_txSafetyRange1 = txDist1;
2081  m_txSafetyRange2 = txDist2;
2082  m_txSafetyRange3 = txDist3;
2083  m_txSafetyRange4 = txDist4;
2084  m_txSafetyRange5 = txDist5;
2085  m_txSafetyRange6 = txDist6;
2086  m_txSafetyRange7 = txDist7;
2087  m_txSafetyRange8 = txDist8;
2088  m_txSafetyRange9 = txDist9;
2089  m_txSafetyRange10 = txDist10;
2090  // load configuration info from config-store
2091  ConfigStoreHelper configStoreHelper;
2092  configStoreHelper.LoadConfig (m_loadConfigFilename);
2093  // transfer config-store values to config parameters
2095 
2096  // parse again so you can override input file default values via command line
2097  cmd.Parse (argc, argv);
2098 
2099  m_txSafetyRange1 = txDist1;
2100  m_txSafetyRange2 = txDist2;
2101  m_txSafetyRange3 = txDist3;
2102  m_txSafetyRange4 = txDist4;
2103  m_txSafetyRange5 = txDist5;
2104  m_txSafetyRange6 = txDist6;
2105  m_txSafetyRange7 = txDist7;
2106  m_txSafetyRange8 = txDist8;
2107  m_txSafetyRange9 = txDist9;
2108  m_txSafetyRange10 = txDist10;
2109 }
2110 
2111 void
2113 {
2114  // open log file for output
2115  m_os.open (m_logFile.c_str ());
2116 }
2117 
2119 {
2120 
2121  // Enable logging from the ns2 helper
2122  LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
2123 
2124  Packet::EnablePrinting ();
2125 }
2126 
2127 void
2129 {
2130  Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64"));
2131  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (m_rate));
2132 
2133  //Set Non-unicastMode rate to unicast mode
2134  if (m_80211mode == 2)
2135  {
2136  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyModeB));
2137  }
2138  else
2139  {
2140  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyMode));
2141  }
2142 }
2143 
2144 void
2146 {
2147  if (m_mobility == 1)
2148  {
2149  // Create Ns2MobilityHelper with the specified trace log file as parameter
2151  ns2.Install (); // configure movements for each node, while reading trace file
2152  // initially assume all nodes are not moving
2153  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 0);
2154  }
2155  else if (m_mobility == 2)
2156  {
2157  MobilityHelper mobilityAdhoc;
2158 
2159  ObjectFactory pos;
2160  pos.SetTypeId ("ns3::RandomBoxPositionAllocator");
2161  pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
2162  pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
2163  // we need antenna height uniform [1.0 .. 2.0] for loss model
2164  pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"));
2165 
2166  Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
2167  m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex);
2168 
2169  std::stringstream ssSpeed;
2170  ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]";
2171  std::stringstream ssPause;
2172  ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]";
2173  mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
2174  "Speed", StringValue (ssSpeed.str ()),
2175  "Pause", StringValue (ssPause.str ()),
2176  "PositionAllocator", PointerValue (taPositionAlloc));
2177  mobilityAdhoc.SetPositionAllocator (taPositionAlloc);
2178  mobilityAdhoc.Install (m_adhocTxNodes);
2180 
2181  // initially assume all nodes are moving
2182  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 1);
2183  }
2184 
2185  // Configure callback for logging
2186  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2188 }
2189 
2190 void
2192 {
2193  if (m_lossModel == 1)
2194  {
2195  m_lossModelName = "ns3::FriisPropagationLossModel";
2196  }
2197  else if (m_lossModel == 2)
2198  {
2199  m_lossModelName = "ns3::ItuR1411LosPropagationLossModel";
2200  }
2201  else if (m_lossModel == 3)
2202  {
2203  m_lossModelName = "ns3::TwoRayGroundPropagationLossModel";
2204  }
2205  else if (m_lossModel == 4)
2206  {
2207  m_lossModelName = "ns3::LogDistancePropagationLossModel";
2208  }
2209  else
2210  {
2211  // Unsupported propagation loss model.
2212  // Treating as ERROR
2213  NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance");
2214  }
2215 
2216  // frequency
2217  double freq = 0.0;
2218  if ((m_80211mode == 1)
2219  || (m_80211mode == 3))
2220  {
2221  // 802.11p 5.9 GHz
2222  freq = 5.9e9;
2223  }
2224  else
2225  {
2226  // 802.11b 2.4 GHz
2227  freq = 2.4e9;
2228  }
2229 
2230  // Setup propagation models
2231  YansWifiChannelHelper wifiChannel;
2232  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
2233  if (m_lossModel == 3)
2234  {
2235  // two-ray requires antenna height (else defaults to Friss)
2236  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq), "HeightAboveZ", DoubleValue (1.5));
2237  }
2238  else
2239  {
2240  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq));
2241  }
2242 
2243  // Propagation loss models are additive.
2244  if (m_fading != 0)
2245  {
2246  // if no obstacle model, then use Nakagami fading if requested
2247  wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
2248  }
2249 
2250  // the channel
2251  Ptr<YansWifiChannel> channel = wifiChannel.Create ();
2252 
2253  // The below set of helpers will help us to put together the wifi NICs we want
2254  YansWifiPhyHelper wifiPhy;
2255  wifiPhy.SetChannel (channel);
2256  // ns-3 supports generate a pcap trace
2257  wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11);
2258 
2259  YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
2260  wavePhy.SetChannel (channel);
2261  wavePhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11);
2262 
2263  // Setup WAVE PHY and MAC
2264  NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
2265  WaveHelper waveHelper = WaveHelper::Default ();
2266  Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
2267  if (m_verbose)
2268  {
2269  wifi80211p.EnableLogComponents (); // Turn on all Wifi 802.11p logging
2270  // likewise, turn on WAVE PHY logging
2271  waveHelper.EnableLogComponents ();
2272  }
2273 
2274  WifiHelper wifi;
2275 
2276  // Setup 802.11b stuff
2277  wifi.SetStandard (WIFI_STANDARD_80211b);
2278 
2279  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2280  "DataMode",StringValue (m_phyModeB),
2281  "ControlMode",StringValue (m_phyModeB));
2282 
2283  // Setup 802.11p stuff
2284  wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2285  "DataMode",StringValue (m_phyMode),
2286  "ControlMode",StringValue (m_phyMode));
2287 
2288  // Setup WAVE-PHY stuff
2289  waveHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2290  "DataMode",StringValue (m_phyMode),
2291  "ControlMode",StringValue (m_phyMode));
2292 
2293  // Set Tx Power
2294  wifiPhy.Set ("TxPowerStart",DoubleValue (m_txp));
2295  wifiPhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2296  wavePhy.Set ("TxPowerStart",DoubleValue (m_txp));
2297  wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2298 
2299  // Add an upper mac and disable rate control
2300  WifiMacHelper wifiMac;
2301  wifiMac.SetType ("ns3::AdhocWifiMac");
2302  QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
2303 
2304  // Setup net devices
2305 
2306  if (m_80211mode == 3)
2307  {
2308  m_adhocTxDevices = waveHelper.Install (wavePhy, waveMac, m_adhocTxNodes);
2309  }
2310  else if (m_80211mode == 1)
2311  {
2312  m_adhocTxDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, m_adhocTxNodes);
2313  }
2314  else
2315  {
2316  m_adhocTxDevices = wifi.Install (wifiPhy, wifiMac, m_adhocTxNodes);
2317  }
2318 
2319  if (m_asciiTrace != 0)
2320  {
2321  AsciiTraceHelper ascii;
2322  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (m_trName + ".tr").c_str ());
2323  wifiPhy.EnableAsciiAll (osw);
2324  wavePhy.EnableAsciiAll (osw);
2325  }
2326  if (m_pcap != 0)
2327  {
2328  wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap");
2329  wavePhy.EnablePcapAll ("vanet-routing-compare-pcap");
2330  }
2331 }
2332 
2333 void
2335 {
2336  // WAVE PHY mode
2337  // 0=continuous channel; 1=channel-switching
2338  int chAccessMode = 0;
2339  if (m_80211mode == 3)
2340  {
2341  chAccessMode = 1;
2342  }
2343 
2348  // GPS accuracy (i.e, clock drift), in number of ns
2351  chAccessMode,
2352  // tx max delay before transmit, in ms
2354 
2355  // fix random number streams
2357 }
2358 
2359 void
2361 {
2366  m_protocol,
2367  m_nSinks,
2368  m_routingTables);
2369 }
2370 
2371 void
2373 {
2374  // member variable parameter use
2375  // defaults or command line overrides,
2376  // except where scenario={1,2,3,...}
2377  // have been specified, in which case
2378  // specify parameters are overwritten
2379  // here to setup for specific scenarios
2380 
2381  // certain parameters may be further overridden
2382  // i.e. specify a scenario, override tx power.
2383 
2384  if (m_scenario == 1)
2385  {
2386  // 40 nodes in RWP 300 m x 1500 m synthetic highway, 10s
2387  m_traceFile = "";
2388  m_logFile = "";
2389  m_mobility = 2;
2390  if (m_nNodes == 156)
2391  {
2392  m_nNodes = 40;
2393  }
2394  if (m_TotalSimTime == 300.01)
2395  {
2396  m_TotalSimTime = 10.0;
2397  }
2398  }
2399  else if (m_scenario == 2)
2400  {
2401  // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
2402  // "low density, 99 total vehicles"
2403  m_traceFile = "src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob";
2404  m_logFile = "low99-ct-unterstrass-1day.filt.7.adj.log";
2405  m_mobility = 1;
2406  m_nNodes = 99;
2407  m_TotalSimTime = 300.01;
2408  m_nodeSpeed = 0;
2409  m_nodePause = 0;
2410  m_CSVfileName = "low_vanet-routing-compare.csv";
2411  m_CSVfileName = "low_vanet-routing-compare2.csv";
2412  }
2413 }
2414 
2415 void
2417 {
2418  //blank out the last output file and write the column headers
2419  std::ofstream out (m_CSVfileName.c_str ());
2420  out << "SimulationSecond," <<
2421  "ReceiveRate," <<
2422  "PacketsReceived," <<
2423  "NumberOfSinks," <<
2424  "RoutingProtocol," <<
2425  "TransmissionPower," <<
2426  "WavePktsSent," <<
2427  "WavePtksReceived," <<
2428  "WavePktsPpr," <<
2429  "ExpectedWavePktsReceived," <<
2430  "ExpectedWavePktsInCoverageReceived," <<
2431  "BSM_PDR1," <<
2432  "BSM_PDR2," <<
2433  "BSM_PDR3," <<
2434  "BSM_PDR4," <<
2435  "BSM_PDR5," <<
2436  "BSM_PDR6," <<
2437  "BSM_PDR7," <<
2438  "BSM_PDR8," <<
2439  "BSM_PDR9," <<
2440  "BSM_PDR10," <<
2441  "MacPhyOverhead" <<
2442  std::endl;
2443  out.close ();
2444 
2445  std::ofstream out2 (m_CSVfileName2.c_str ());
2446  out2 << "BSM_PDR1,"
2447  << "BSM_PDR2,"
2448  << "BSM_PDR3,"
2449  << "BSM_PDR4,"
2450  << "BSM_PDR5,"
2451  << "BSM_PDR6,"
2452  << "BSM_PDR7,"
2453  << "BSM_PDR8,"
2454  << "BSM_PDR9,"
2455  << "BSM_PDR10,"
2456  << "AverageRoutingGoodputKbps,"
2457  << "MacPhyOverhead"
2458  << std::endl;
2459  out2.close ();
2460 }
2461 
2462 int
2463 main (int argc, char *argv[])
2464 {
2466  experiment.Simulate (argc, argv);
2467 }
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:140
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())
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:429
std::string m_logFile
log file
static void EnableLogComponents(void)
Helper to enable all WaveNetDevice log components with one statement.
Definition: wave-helper.cc:424
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:103
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 SetType(std::string type, Args &&... args)
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:109
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.
static ns3::GlobalValue g_cumulativeBsmCaptureStart("VRCcumulativeBsmCaptureStart", "Simulation start time for capturing cumulative BSM", ns3::TimeValue(Seconds(0)), ns3::MakeTimeChecker())
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:721
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:1703
static ns3::GlobalValue g_traceFile("VRCtraceFile", "Mobility trace filename", ns3::StringValue("./src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob"), ns3::MakeStringChecker())
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).
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
std::string m_traceFile
trace file
uint32_t GetCumulativeRxBytes()
Returns the cumulative number of bytes received.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
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:281
int m_routingTables
routing tables
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
cmd
Definition: second.py:35
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:813
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:326
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:47
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:92
mobility
Definition: third.py:108
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.
Ptr< const AttributeChecker > MakeStringChecker(void)
Definition: string.cc:30
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.
Time m_cumulativeBsmCaptureStart
capture start
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:361
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())
AttributeValue implementation for Time.
Definition: nstime.h:1353
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
void PhyRxDrop(std::string context, Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Callback signiture for Phy/RxDrop.
std::map< Mac48Address, uint64_t > packetsReceived
Map that stores the total packets received per STA (and addressed to that STA)
Definition: wifi-bianchi.cc:64
virtual void SetDefaultAttributeValues()
Sets default attribute values.
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:227
std::string m_CSVfileName2
CSV file name.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
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:470
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())
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 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:573
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 SetupScenario()
Set up a prescribed scenario.
uint32_t m_RxBytes
reeive bytes
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:96
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:41
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:104
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.
Time Get(void) const
Definition: time.cc:530
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:1289
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
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:287
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:257
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 >())
uint32_t pktSize
packet size used for the simulation (in bytes)
Definition: wifi-bianchi.cc:83
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:923
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
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...