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 
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 ();
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 ();
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 ()).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*/);
1801  }
1802 
1803  out << (Simulator::Now ()).As (Time::S) << ","
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  Time currentTime = Simulator::Now ();
1840  if (currentTime <= 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  TimeValue timeValue;
1859 
1860  // This may not be the best way to manage program configuration
1861  // (directing them through global values), but management
1862  // through the config-store here is copied from
1863  // src/lte/examples/lena-dual-stripe.cc
1864 
1865  GlobalValue::GetValueByName ("VRCport", uintegerValue);
1866  m_port = uintegerValue.Get ();
1867  GlobalValue::GetValueByName ("VRCnSinks", uintegerValue);
1868  m_nSinks = uintegerValue.Get ();
1869  GlobalValue::GetValueByName ("VRCtraceMobility", uintegerValue);
1870  m_traceMobility = uintegerValue.Get ();
1871  GlobalValue::GetValueByName ("VRCprotocol", uintegerValue);
1872  m_protocol = uintegerValue.Get ();
1873  GlobalValue::GetValueByName ("VRClossModel", uintegerValue);
1874  m_lossModel = uintegerValue.Get ();
1875  GlobalValue::GetValueByName ("VRCfading", uintegerValue);
1876  m_fading = uintegerValue.Get ();
1877  GlobalValue::GetValueByName ("VRC80211mode", uintegerValue);
1878  m_80211mode = uintegerValue.Get ();
1879  GlobalValue::GetValueByName ("VRCmobility", uintegerValue);
1880  m_mobility = uintegerValue.Get ();
1881  GlobalValue::GetValueByName ("VRCnNodes", uintegerValue);
1882  m_nNodes = uintegerValue.Get ();
1883  GlobalValue::GetValueByName ("VRCnodeSpeed", uintegerValue);
1884  m_nodeSpeed = uintegerValue.Get ();
1885  GlobalValue::GetValueByName ("VRCnodePause", uintegerValue);
1886  m_nodePause = uintegerValue.Get ();
1887  GlobalValue::GetValueByName ("VRCwavePacketSize", uintegerValue);
1888  m_wavePacketSize = uintegerValue.Get ();
1889  GlobalValue::GetValueByName ("VRCverbose", uintegerValue);
1890  m_verbose = uintegerValue.Get ();
1891  GlobalValue::GetValueByName ("VRCscenario", uintegerValue);
1892  m_scenario = uintegerValue.Get ();
1893  GlobalValue::GetValueByName ("VRCroutingTables", uintegerValue);
1894  m_routingTables = uintegerValue.Get ();
1895  GlobalValue::GetValueByName ("VRCasciiTrace", uintegerValue);
1896  m_asciiTrace = uintegerValue.Get ();
1897  GlobalValue::GetValueByName ("VRCpcap", uintegerValue);
1898  m_pcap = uintegerValue.Get ();
1899  GlobalValue::GetValueByName ("VRCcumulativeBsmCaptureStart", timeValue);
1900  m_cumulativeBsmCaptureStart = timeValue.Get ();
1901 
1902 
1903  GlobalValue::GetValueByName ("VRCtxSafetyRange1", doubleValue);
1904  m_txSafetyRange1 = doubleValue.Get ();
1905  GlobalValue::GetValueByName ("VRCtxSafetyRange2", doubleValue);
1906  m_txSafetyRange2 = doubleValue.Get ();
1907  GlobalValue::GetValueByName ("VRCtxSafetyRange3", doubleValue);
1908  m_txSafetyRange3 = doubleValue.Get ();
1909  GlobalValue::GetValueByName ("VRCtxSafetyRange4", doubleValue);
1910  m_txSafetyRange4 = doubleValue.Get ();
1911  GlobalValue::GetValueByName ("VRCtxSafetyRange5", doubleValue);
1912  m_txSafetyRange5 = doubleValue.Get ();
1913  GlobalValue::GetValueByName ("VRCtxSafetyRange6", doubleValue);
1914  m_txSafetyRange6 = doubleValue.Get ();
1915  GlobalValue::GetValueByName ("VRCtxSafetyRange7", doubleValue);
1916  m_txSafetyRange7 = doubleValue.Get ();
1917  GlobalValue::GetValueByName ("VRCtxSafetyRange8", doubleValue);
1918  m_txSafetyRange8 = doubleValue.Get ();
1919  GlobalValue::GetValueByName ("VRCtxSafetyRange9", doubleValue);
1920  m_txSafetyRange9 = doubleValue.Get ();
1921  GlobalValue::GetValueByName ("VRCtxSafetyRange10", doubleValue);
1922  m_txSafetyRange10 = doubleValue.Get ();
1923  GlobalValue::GetValueByName ("VRCtxp", doubleValue);
1924  m_txp = doubleValue.Get ();
1925  GlobalValue::GetValueByName ("VRCtotalTime", doubleValue);
1926  m_TotalSimTime = doubleValue.Get ();
1927  GlobalValue::GetValueByName ("VRCwaveInterval", doubleValue);
1928  m_waveInterval = doubleValue.Get ();
1929  GlobalValue::GetValueByName ("VRCgpsAccuracyNs", doubleValue);
1930  m_gpsAccuracyNs = doubleValue.Get ();
1931  GlobalValue::GetValueByName ("VRCtxMaxDelayMs", doubleValue);
1932  m_txMaxDelayMs = doubleValue.Get ();
1933 
1934  GlobalValue::GetValueByName ("VRCCSVfileName", stringValue);
1935  m_CSVfileName = stringValue.Get ();
1936  GlobalValue::GetValueByName ("VRCCSVfileName2", stringValue);
1937  m_CSVfileName2 = stringValue.Get ();
1938  GlobalValue::GetValueByName ("VRCphyMode", stringValue);
1939  m_phyMode = stringValue.Get ();
1940  GlobalValue::GetValueByName ("VRCtraceFile", stringValue);
1941  m_traceFile = stringValue.Get ();
1942  GlobalValue::GetValueByName ("VRClogFile", stringValue);
1943  m_logFile = stringValue.Get ();
1944  GlobalValue::GetValueByName ("VRCrate", stringValue);
1945  m_rate = stringValue.Get ();
1946  GlobalValue::GetValueByName ("VRCphyModeB", stringValue);
1947  m_phyModeB = stringValue.Get ();
1948  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1949  m_trName = stringValue.Get ();
1950 }
1951 
1952 void
1954 {
1955  // get settings saved from config-store
1956  UintegerValue uintegerValue;
1957  DoubleValue doubleValue;
1958  StringValue stringValue;
1959 
1978 
1994 
2003  GlobalValue::GetValueByName ("VRCtrName", stringValue);
2004  m_trName = stringValue.Get ();
2005 }
2006 
2007 void
2009 {
2010  CommandLine cmd (__FILE__);
2011  double txDist1 = 50.0;
2012  double txDist2 = 100.0;
2013  double txDist3 = 150.0;
2014  double txDist4 = 200.0;
2015  double txDist5 = 250.0;
2016  double txDist6 = 300.0;
2017  double txDist7 = 350.0;
2018  double txDist8 = 350.0;
2019  double txDist9 = 350.0;
2020  double txDist10 = 350.0;
2021 
2022  // allow command line overrides
2023  cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName);
2024  cmd.AddValue ("CSVfileName2", "The name of the CSV output file name2", m_CSVfileName2);
2025  cmd.AddValue ("totaltime", "Simulation end time", m_TotalSimTime);
2026  cmd.AddValue ("nodes", "Number of nodes (i.e. vehicles)", m_nNodes);
2027  cmd.AddValue ("sinks", "Number of routing sinks", m_nSinks);
2028  cmd.AddValue ("txp", "Transmit power (dB), e.g. txp=7.5", m_txp);
2029  cmd.AddValue ("traceMobility", "Enable mobility tracing", m_traceMobility);
2030  cmd.AddValue ("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol);
2031  cmd.AddValue ("lossModel", "1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance", m_lossModel);
2032  cmd.AddValue ("fading", "0=None;1=Nakagami;(buildings=1 overrides)", m_fading);
2033  cmd.AddValue ("phyMode", "Wifi Phy mode", m_phyMode);
2034  cmd.AddValue ("80211Mode", "1=802.11p; 2=802.11b; 3=WAVE-PHY", m_80211mode);
2035  cmd.AddValue ("traceFile", "Ns2 movement trace file", m_traceFile);
2036  cmd.AddValue ("logFile", "Log file", m_logFile);
2037  cmd.AddValue ("mobility", "1=trace;2=RWP", m_mobility);
2038  cmd.AddValue ("rate", "Rate", m_rate);
2039  cmd.AddValue ("phyModeB", "Phy mode 802.11b", m_phyModeB);
2040  cmd.AddValue ("speed", "Node speed (m/s)", m_nodeSpeed);
2041  cmd.AddValue ("pause", "Node pause (s)", m_nodePause);
2042  cmd.AddValue ("verbose", "0=quiet;1=verbose", m_verbose);
2043  cmd.AddValue ("bsm", "(WAVE) BSM size (bytes)", m_wavePacketSize);
2044  cmd.AddValue ("interval", "(WAVE) BSM interval (s)", m_waveInterval);
2045  cmd.AddValue ("scenario", "1=synthetic, 2=playback-trace", m_scenario);
2046  // User is allowed to have up to 10 different PDRs (Packet
2047  // Delivery Ratios) calculate, and so can specify up to
2048  // 10 different tx distances.
2049  cmd.AddValue ("txdist1", "Expected BSM tx range, m", txDist1);
2050  cmd.AddValue ("txdist2", "Expected BSM tx range, m", txDist2);
2051  cmd.AddValue ("txdist3", "Expected BSM tx range, m", txDist3);
2052  cmd.AddValue ("txdist4", "Expected BSM tx range, m", txDist4);
2053  cmd.AddValue ("txdist5", "Expected BSM tx range, m", txDist5);
2054  cmd.AddValue ("txdist6", "Expected BSM tx range, m", txDist6);
2055  cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7);
2056  cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8);
2057  cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9);
2058  cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10);
2059  cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs);
2060  cmd.AddValue ("txmaxdelay", "Tx max delay, in ms", m_txMaxDelayMs);
2061  cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routingTables);
2062  cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace);
2063  cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap);
2064  cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilename);
2065  cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilename);
2066  cmd.AddValue ("exp", "Experiment", m_exp);
2067  cmd.AddValue ("BsmCaptureStart", "Start time to begin capturing pkts for cumulative Bsm", m_cumulativeBsmCaptureStart);
2068  cmd.Parse (argc, argv);
2069 
2070  m_txSafetyRange1 = txDist1;
2071  m_txSafetyRange2 = txDist2;
2072  m_txSafetyRange3 = txDist3;
2073  m_txSafetyRange4 = txDist4;
2074  m_txSafetyRange5 = txDist5;
2075  m_txSafetyRange6 = txDist6;
2076  m_txSafetyRange7 = txDist7;
2077  m_txSafetyRange8 = txDist8;
2078  m_txSafetyRange9 = txDist9;
2079  m_txSafetyRange10 = txDist10;
2080  // load configuration info from config-store
2081  ConfigStoreHelper configStoreHelper;
2082  configStoreHelper.LoadConfig (m_loadConfigFilename);
2083  // transfer config-store values to config parameters
2085 
2086  // parse again so you can override input file default values via command line
2087  cmd.Parse (argc, argv);
2088 
2089  m_txSafetyRange1 = txDist1;
2090  m_txSafetyRange2 = txDist2;
2091  m_txSafetyRange3 = txDist3;
2092  m_txSafetyRange4 = txDist4;
2093  m_txSafetyRange5 = txDist5;
2094  m_txSafetyRange6 = txDist6;
2095  m_txSafetyRange7 = txDist7;
2096  m_txSafetyRange8 = txDist8;
2097  m_txSafetyRange9 = txDist9;
2098  m_txSafetyRange10 = txDist10;
2099 }
2100 
2101 void
2103 {
2104  // open log file for output
2105  m_os.open (m_logFile.c_str ());
2106 }
2107 
2109 {
2110 
2111  // Enable logging from the ns2 helper
2112  LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
2113 
2114  Packet::EnablePrinting ();
2115 }
2116 
2117 void
2119 {
2120  Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64"));
2121  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (m_rate));
2122 
2123  //Set Non-unicastMode rate to unicast mode
2124  if (m_80211mode == 2)
2125  {
2126  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyModeB));
2127  }
2128  else
2129  {
2130  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyMode));
2131  }
2132 }
2133 
2134 void
2136 {
2137  if (m_mobility == 1)
2138  {
2139  // Create Ns2MobilityHelper with the specified trace log file as parameter
2141  ns2.Install (); // configure movements for each node, while reading trace file
2142  // initially assume all nodes are not moving
2143  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 0);
2144  }
2145  else if (m_mobility == 2)
2146  {
2147  MobilityHelper mobilityAdhoc;
2148 
2149  ObjectFactory pos;
2150  pos.SetTypeId ("ns3::RandomBoxPositionAllocator");
2151  pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
2152  pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
2153  // we need antenna height uniform [1.0 .. 2.0] for loss model
2154  pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"));
2155 
2156  Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
2157  m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex);
2158 
2159  std::stringstream ssSpeed;
2160  ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]";
2161  std::stringstream ssPause;
2162  ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]";
2163  mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
2164  "Speed", StringValue (ssSpeed.str ()),
2165  "Pause", StringValue (ssPause.str ()),
2166  "PositionAllocator", PointerValue (taPositionAlloc));
2167  mobilityAdhoc.SetPositionAllocator (taPositionAlloc);
2168  mobilityAdhoc.Install (m_adhocTxNodes);
2170 
2171  // initially assume all nodes are moving
2172  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 1);
2173  }
2174 
2175  // Configure callback for logging
2176  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2178 }
2179 
2180 void
2182 {
2183  if (m_lossModel == 1)
2184  {
2185  m_lossModelName = "ns3::FriisPropagationLossModel";
2186  }
2187  else if (m_lossModel == 2)
2188  {
2189  m_lossModelName = "ns3::ItuR1411LosPropagationLossModel";
2190  }
2191  else if (m_lossModel == 3)
2192  {
2193  m_lossModelName = "ns3::TwoRayGroundPropagationLossModel";
2194  }
2195  else if (m_lossModel == 4)
2196  {
2197  m_lossModelName = "ns3::LogDistancePropagationLossModel";
2198  }
2199  else
2200  {
2201  // Unsupported propagation loss model.
2202  // Treating as ERROR
2203  NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance");
2204  }
2205 
2206  // frequency
2207  double freq = 0.0;
2208  if ((m_80211mode == 1)
2209  || (m_80211mode == 3))
2210  {
2211  // 802.11p 5.9 GHz
2212  freq = 5.9e9;
2213  }
2214  else
2215  {
2216  // 802.11b 2.4 GHz
2217  freq = 2.4e9;
2218  }
2219 
2220  // Setup propagation models
2221  YansWifiChannelHelper wifiChannel;
2222  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
2223  if (m_lossModel == 3)
2224  {
2225  // two-ray requires antenna height (else defaults to Friss)
2226  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq), "HeightAboveZ", DoubleValue (1.5));
2227  }
2228  else
2229  {
2230  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq));
2231  }
2232 
2233  // Propagation loss models are additive.
2234  if (m_fading != 0)
2235  {
2236  // if no obstacle model, then use Nakagami fading if requested
2237  wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
2238  }
2239 
2240  // the channel
2241  Ptr<YansWifiChannel> channel = wifiChannel.Create ();
2242 
2243  // The below set of helpers will help us to put together the wifi NICs we want
2244  YansWifiPhyHelper wifiPhy;
2245  wifiPhy.SetChannel (channel);
2246  // ns-3 supports generate a pcap trace
2247  wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11);
2248 
2249  YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
2250  wavePhy.SetChannel (channel);
2251  wavePhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11);
2252 
2253  // Setup WAVE PHY and MAC
2254  NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
2255  WaveHelper waveHelper = WaveHelper::Default ();
2256  Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
2257  if (m_verbose)
2258  {
2259  wifi80211p.EnableLogComponents (); // Turn on all Wifi 802.11p logging
2260  // likewise, turn on WAVE PHY logging
2261  waveHelper.EnableLogComponents ();
2262  }
2263 
2264  WifiHelper wifi;
2265 
2266  // Setup 802.11b stuff
2267  wifi.SetStandard (WIFI_STANDARD_80211b);
2268 
2269  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2270  "DataMode",StringValue (m_phyModeB),
2271  "ControlMode",StringValue (m_phyModeB));
2272 
2273  // Setup 802.11p stuff
2274  wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2275  "DataMode",StringValue (m_phyMode),
2276  "ControlMode",StringValue (m_phyMode));
2277 
2278  // Setup WAVE-PHY stuff
2279  waveHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2280  "DataMode",StringValue (m_phyMode),
2281  "ControlMode",StringValue (m_phyMode));
2282 
2283  // Set Tx Power
2284  wifiPhy.Set ("TxPowerStart",DoubleValue (m_txp));
2285  wifiPhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2286  wavePhy.Set ("TxPowerStart",DoubleValue (m_txp));
2287  wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2288 
2289  // Add an upper mac and disable rate control
2290  WifiMacHelper wifiMac;
2291  wifiMac.SetType ("ns3::AdhocWifiMac");
2292  QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
2293 
2294  // Setup net devices
2295 
2296  if (m_80211mode == 3)
2297  {
2298  m_adhocTxDevices = waveHelper.Install (wavePhy, waveMac, m_adhocTxNodes);
2299  }
2300  else if (m_80211mode == 1)
2301  {
2302  m_adhocTxDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, m_adhocTxNodes);
2303  }
2304  else
2305  {
2306  m_adhocTxDevices = wifi.Install (wifiPhy, wifiMac, m_adhocTxNodes);
2307  }
2308 
2309  if (m_asciiTrace != 0)
2310  {
2311  AsciiTraceHelper ascii;
2312  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (m_trName + ".tr").c_str ());
2313  wifiPhy.EnableAsciiAll (osw);
2314  wavePhy.EnableAsciiAll (osw);
2315  }
2316  if (m_pcap != 0)
2317  {
2318  wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap");
2319  wavePhy.EnablePcapAll ("vanet-routing-compare-pcap");
2320  }
2321 }
2322 
2323 void
2325 {
2326  // WAVE PHY mode
2327  // 0=continuous channel; 1=channel-switching
2328  int chAccessMode = 0;
2329  if (m_80211mode == 3)
2330  {
2331  chAccessMode = 1;
2332  }
2333 
2338  // GPS accuracy (i.e, clock drift), in number of ns
2341  chAccessMode,
2342  // tx max delay before transmit, in ms
2344 
2345  // fix random number streams
2347 }
2348 
2349 void
2351 {
2356  m_protocol,
2357  m_nSinks,
2358  m_routingTables);
2359 }
2360 
2361 void
2363 {
2364  // member variable parameter use
2365  // defaults or command line overrides,
2366  // except where scenario={1,2,3,...}
2367  // have been specified, in which case
2368  // specify parameters are overwritten
2369  // here to setup for specific scenarios
2370 
2371  // certain parameters may be further overridden
2372  // i.e. specify a scenario, override tx power.
2373 
2374  if (m_scenario == 1)
2375  {
2376  // 40 nodes in RWP 300 m x 1500 m synthetic highway, 10s
2377  m_traceFile = "";
2378  m_logFile = "";
2379  m_mobility = 2;
2380  if (m_nNodes == 156)
2381  {
2382  m_nNodes = 40;
2383  }
2384  if (m_TotalSimTime == 300.01)
2385  {
2386  m_TotalSimTime = 10.0;
2387  }
2388  }
2389  else if (m_scenario == 2)
2390  {
2391  // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
2392  // "low density, 99 total vehicles"
2393  m_traceFile = "src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob";
2394  m_logFile = "low99-ct-unterstrass-1day.filt.7.adj.log";
2395  m_mobility = 1;
2396  m_nNodes = 99;
2397  m_TotalSimTime = 300.01;
2398  m_nodeSpeed = 0;
2399  m_nodePause = 0;
2400  m_CSVfileName = "low_vanet-routing-compare.csv";
2401  m_CSVfileName = "low_vanet-routing-compare2.csv";
2402  }
2403 }
2404 
2405 void
2407 {
2408  //blank out the last output file and write the column headers
2409  std::ofstream out (m_CSVfileName.c_str ());
2410  out << "SimulationSecond," <<
2411  "ReceiveRate," <<
2412  "PacketsReceived," <<
2413  "NumberOfSinks," <<
2414  "RoutingProtocol," <<
2415  "TransmissionPower," <<
2416  "WavePktsSent," <<
2417  "WavePtksReceived," <<
2418  "WavePktsPpr," <<
2419  "ExpectedWavePktsReceived," <<
2420  "ExpectedWavePktsInCoverageReceived," <<
2421  "BSM_PDR1," <<
2422  "BSM_PDR2," <<
2423  "BSM_PDR3," <<
2424  "BSM_PDR4," <<
2425  "BSM_PDR5," <<
2426  "BSM_PDR6," <<
2427  "BSM_PDR7," <<
2428  "BSM_PDR8," <<
2429  "BSM_PDR9," <<
2430  "BSM_PDR10," <<
2431  "MacPhyOverhead" <<
2432  std::endl;
2433  out.close ();
2434 
2435  std::ofstream out2 (m_CSVfileName2.c_str ());
2436  out2 << "BSM_PDR1,"
2437  << "BSM_PDR2,"
2438  << "BSM_PDR3,"
2439  << "BSM_PDR4,"
2440  << "BSM_PDR5,"
2441  << "BSM_PDR6,"
2442  << "BSM_PDR7,"
2443  << "BSM_PDR8,"
2444  << "BSM_PDR9,"
2445  << "BSM_PDR10,"
2446  << "AverageRoutingGoodputKbps,"
2447  << "MacPhyOverhead"
2448  << std::endl;
2449  out2.close ();
2450 }
2451 
2452 int
2453 main (int argc, char *argv[])
2454 {
2456  experiment.Simulate (argc, argv);
2457 }
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:143
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:482
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 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.
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:732
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.
#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:99
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
virtual void ConfigureChannels()
Configure channels.
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
static ns3::GlobalValue g_cumulativeBsmCaptureStart("VRCcumulativeBsmCaptureStart", "Simulation starte time for capturing cumulative BSM", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
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.
Definition: wifi-preamble.h:32
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:320
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
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:918
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:389
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:580
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.
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: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.
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...