A Discrete-Event Network Simulator
API
vanet-routing-compare.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 North Carolina State University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Scott E. Carpenter <scarpen@ncsu.edu>
19  *
20  */
21 
22 /*
23  * This example program allows one to run vehicular ad hoc
24  * network (VANET) simulation scenarios in ns-3 to assess
25  * performance by evaluating different 802.11p MAC/PHY
26  * characteristics, propagation loss models (e.g. Friss,
27  * Two-Ray Ground, or ITU R-P.1411), and application traffic
28  * (e.g. Basic Safety Message) and/or routing traffic (e.g.
29  * DSDV, AODV, OLSR, or DSR) under either a synthetic highway
30  * scenario (i.e. a random waypoint mobility model) or by
31  * playing back mobility trace files (i.e. ns-2 movement files).
32  *
33  * The script draws from several ns-3 examples, including:
34  * /examples/routing/manet-routing-compare.cc
35  * /src/propagation/model/itu-r-1411-los-propagation-loss-model.cc
36  * /src/mobility/examples/ns2-mobility-trace.cc
37  * /src/wave/examples/wave-simple-80211p.cc
38  *
39  * The script allows many parameters to be modified and
40  * includes two predefined scenarios. By default
41  * scenario=1 runs for 10 simulated seconds with 40 nodes
42  * (i.e. vehicles) moving according to RandomWaypointMobilityModel
43  * with a speed of 20 m/s and no pause time within a 300x1500 m
44  * region. The WiFi is 802.11p with continuous access to a 10 MHz
45  * Control Channel (CH) for all traffic. All nodes transmit a
46  * 200-byte safety message 10 times per second at 6 Mbps.
47  * Additionally, all nodes (optionally) attempt to
48  * continuously route 64-byte packets at an application
49  * rate of 2.048 Kbps to one of 10 other nodes,
50  * selected as sink nodes. The default routing protocol is AODV
51  * and the Two-Ray Ground loss model is used.
52  * The transmit power is set to 20 dBm and the transmission range
53  * for safety message packet delivery is 145 m.
54  *
55  * Scenario 2 plays back vehicular trace files in
56  * ns-2 movement format, and are taken from:
57  * http://www.lst.inf.ethz.ch/research/ad-hoc/car-traces/
58  * This scenario is 300 simulation seconds of 99
59  * vehicles respectively within the Unterstrass
60  * section of Zurich Switzerland that travel based on
61  * models derived from real traffic data. Note that these
62  * scenarios can require a lot of clock time to complete.
63  *
64  * All parameters can be changed from their defaults (see
65  * --help) and changing simulation parameters can have dramatic
66  * impact on network performance.
67  *
68  * Several items can be output:
69  * - a CSV file of data reception statistics, output once per
70  * second
71  * - final statistics, in a CSV file
72  * - dump of routing tables at 5 seconds into the simulation
73  * - ASCII trace file
74  * - PCAP trace files for each node
75  *
76  * Simulation scenarios can be defined and configuration
77  * settings can be saved using config-store (raw text)
78  * which can they be replayed again. This is an easy way
79  * to define and save the settings for a scenario, and then
80  * re-execute the same scenario exactly, or to set up
81  * several different simulation scenarios.
82  * For example, to set up a scenario and save the configuration
83  * as "scenario1.txt":
84  * ./waf --run "vanet-routing-compare --scenario=1 --saveconfig=scenario1.txt"
85  * Then, to re-play the scenario using the save configuration
86  * settings:
87  * ./waf --run "vanet-routing-compare --loadconfig=scenario1.txt"
88  *
89  * Class Diagram:
90  * main()
91  * +--uses-- VanetRoutingExperiment
92  * +--is_a--- WifiApp
93  * +--uses--- ConfigStoreHelper
94  * +--has_a-- WaveBsmHelper
95  * | +--has_a-- WaveBsmStats
96  * +--has_a-- RoutingHelper
97  * | +--has_a--RoutingStats
98  * +--has_a-- WifiPhyStats
99  *
100  */
101 
102 #include <fstream>
103 #include <iostream>
104 #include "ns3/core-module.h"
105 #include "ns3/network-module.h"
106 #include "ns3/internet-module.h"
107 #include "ns3/mobility-module.h"
108 #include "ns3/wifi-module.h"
109 #include "ns3/aodv-module.h"
110 #include "ns3/olsr-module.h"
111 #include "ns3/dsdv-module.h"
112 #include "ns3/dsr-module.h"
113 #include "ns3/applications-module.h"
114 #include "ns3/itu-r-1411-los-propagation-loss-model.h"
115 #include "ns3/ocb-wifi-mac.h"
116 #include "ns3/wifi-80211p-helper.h"
117 #include "ns3/wave-mac-helper.h"
118 #include "ns3/flow-monitor-module.h"
119 #include "ns3/config-store-module.h"
120 #include "ns3/integer.h"
121 #include "ns3/wave-bsm-helper.h"
122 #include "ns3/wave-helper.h"
123 // future #include "ns3/topology.h"
124 
125 using namespace ns3;
126 using namespace dsr;
127 
128 NS_LOG_COMPONENT_DEFINE ("vanet-routing-compare");
129 
137 {
138 public:
143  RoutingStats ();
144 
149  uint32_t GetRxBytes ();
150 
155  uint32_t GetCumulativeRxBytes ();
156 
161  uint32_t GetRxPkts ();
162 
167  uint32_t GetCumulativeRxPkts ();
168 
175  void IncRxBytes (uint32_t rxBytes);
176 
181  void IncRxPkts ();
182 
188  void SetRxBytes (uint32_t rxBytes);
189 
195  void SetRxPkts (uint32_t rxPkts);
196 
201  uint32_t GetTxBytes ();
202 
207  uint32_t GetCumulativeTxBytes ();
208 
213  uint32_t GetTxPkts ();
214 
219  uint32_t GetCumulativeTxPkts ();
220 
226  void IncTxBytes (uint32_t txBytes);
227 
232  void IncTxPkts ();
233 
239  void SetTxBytes (uint32_t txBytes);
240 
246  void SetTxPkts (uint32_t txPkts);
247 
248 private:
249  uint32_t m_RxBytes;
251  uint32_t m_RxPkts;
253  uint32_t m_TxBytes;
255  uint32_t m_TxPkts;
257 };
258 
260  : m_RxBytes (0),
261  m_cumulativeRxBytes (0),
262  m_RxPkts (0),
263  m_cumulativeRxPkts (0),
264  m_TxBytes (0),
265  m_cumulativeTxBytes (0),
266  m_TxPkts (0),
267  m_cumulativeTxPkts (0)
268 {
269 }
270 
271 uint32_t
273 {
274  return m_RxBytes;
275 }
276 
277 uint32_t
279 {
280  return m_cumulativeRxBytes;
281 }
282 
283 uint32_t
285 {
286  return m_RxPkts;
287 }
288 
289 uint32_t
291 {
292  return m_cumulativeRxPkts;
293 }
294 
295 void
296 RoutingStats::IncRxBytes (uint32_t rxBytes)
297 {
298  m_RxBytes += rxBytes;
299  m_cumulativeRxBytes += rxBytes;
300 }
301 
302 void
304 {
305  m_RxPkts++;
307 }
308 
309 void
310 RoutingStats::SetRxBytes (uint32_t rxBytes)
311 {
312  m_RxBytes = rxBytes;
313 }
314 
315 void
316 RoutingStats::SetRxPkts (uint32_t rxPkts)
317 {
318  m_RxPkts = rxPkts;
319 }
320 
321 uint32_t
323 {
324  return m_TxBytes;
325 }
326 
327 uint32_t
329 {
330  return m_cumulativeTxBytes;
331 }
332 
333 uint32_t
335 {
336  return m_TxPkts;
337 }
338 
339 uint32_t
341 {
342  return m_cumulativeTxPkts;
343 }
344 
345 void
346 RoutingStats::IncTxBytes (uint32_t txBytes)
347 {
348  m_TxBytes += txBytes;
349  m_cumulativeTxBytes += txBytes;
350 }
351 
352 void
354 {
355  m_TxPkts++;
357 }
358 
359 void
360 RoutingStats::SetTxBytes (uint32_t txBytes)
361 {
362  m_TxBytes = txBytes;
363 }
364 
365 void
366 RoutingStats::SetTxPkts (uint32_t txPkts)
367 {
368  m_TxPkts = txPkts;
369 }
370 
381 class RoutingHelper : public Object
382 {
383 public:
388  static TypeId GetTypeId (void);
389 
394  RoutingHelper ();
395 
400  virtual ~RoutingHelper ();
401 
415  void Install (NodeContainer & c,
416  NetDeviceContainer & d,
418  double totalTime,
419  int protocol,
420  uint32_t nSinks,
421  int routingTables);
422 
429  void OnOffTrace (std::string context, Ptr<const Packet> packet);
430 
436 
442  void SetLogging (int log);
443 
444 private:
451 
459  Ipv4InterfaceContainer & adhocTxInterfaces);
460 
468  Ipv4InterfaceContainer & adhocTxInterfaces);
469 
477 
483  void ReceiveRoutingPacket (Ptr<Socket> socket);
484 
485  double m_TotalSimTime;
486  uint32_t m_protocol;
487  uint32_t m_port;
488  uint32_t m_nSinks;
491  std::string m_protocolName;
492  int m_log;
493 };
494 
496 
497 TypeId
499 {
500  static TypeId tid = TypeId ("ns3::RoutingHelper")
501  .SetParent<Object> ()
502  .AddConstructor<RoutingHelper> ();
503  return tid;
504 }
505 
507  : m_TotalSimTime (300.01),
508  m_protocol (0),
509  m_port (9),
510  m_nSinks (0),
511  m_routingTables (0),
512  m_log (0)
513 {
514 }
515 
517 {
518 }
519 
520 void
522  NetDeviceContainer & d,
524  double totalTime,
525  int protocol,
526  uint32_t nSinks,
527  int routingTables)
528 {
529  m_TotalSimTime = totalTime;
530  m_protocol = protocol;
531  m_nSinks = nSinks;
532  m_routingTables = routingTables;
533 
535  AssignIpAddresses (d, i);
536  SetupRoutingMessages (c, i);
537 }
538 
541 {
542  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
543  Ptr<Socket> sink = Socket::CreateSocket (node, tid);
545  sink->Bind (local);
547 
548  return sink;
549 }
550 
551 void
553 {
554  AodvHelper aodv;
556  DsdvHelper dsdv;
557  DsrHelper dsr;
558  DsrMainHelper dsrMain;
560  InternetStackHelper internet;
561 
562  Time rtt = Time (5.0);
563  AsciiTraceHelper ascii;
564  Ptr<OutputStreamWrapper> rtw = ascii.CreateFileStream ("routing_table");
565 
566  switch (m_protocol)
567  {
568  case 0:
569  m_protocolName = "NONE";
570  break;
571  case 1:
572  if (m_routingTables != 0)
573  {
574  olsr.PrintRoutingTableAllAt (rtt, rtw);
575  }
576  list.Add (olsr, 100);
577  m_protocolName = "OLSR";
578  break;
579  case 2:
580  if (m_routingTables != 0)
581  {
582  aodv.PrintRoutingTableAllAt (rtt, rtw);
583  }
584  list.Add (aodv, 100);
585  m_protocolName = "AODV";
586  break;
587  case 3:
588  if (m_routingTables != 0)
589  {
590  dsdv.PrintRoutingTableAllAt (rtt, rtw);
591  }
592  list.Add (dsdv, 100);
593  m_protocolName = "DSDV";
594  break;
595  case 4:
596  // setup is later
597  m_protocolName = "DSR";
598  break;
599  default:
600  NS_FATAL_ERROR ("No such protocol:" << m_protocol);
601  break;
602  }
603 
604  if (m_protocol < 4)
605  {
606  internet.SetRoutingHelper (list);
607  internet.Install (c);
608  }
609  else if (m_protocol == 4)
610  {
611  internet.Install (c);
612  dsrMain.Install (dsr, c);
613  }
614 
615  if (m_log != 0)
616  {
617  NS_LOG_UNCOND ("Routing Setup for " << m_protocolName);
618  }
619 }
620 
621 void
623  Ipv4InterfaceContainer & adhocTxInterfaces)
624 {
625  NS_LOG_INFO ("Assigning IP addresses");
626  Ipv4AddressHelper addressAdhoc;
627  // we may have a lot of nodes, and want them all
628  // in same subnet, to support broadcast
629  addressAdhoc.SetBase ("10.1.0.0", "255.255.0.0");
630  adhocTxInterfaces = addressAdhoc.Assign (d);
631 }
632 
633 void
635  Ipv4InterfaceContainer & adhocTxInterfaces)
636 {
637  // Setup routing transmissions
638  OnOffHelper onoff1 ("ns3::UdpSocketFactory",Address ());
639  onoff1.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"));
640  onoff1.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.0]"));
641 
642  Ptr<UniformRandomVariable> var = CreateObject<UniformRandomVariable> ();
643  int64_t stream = 2;
644  var->SetStream (stream);
645  for (uint32_t i = 0; i < m_nSinks; i++)
646  {
647  // protocol == 0 means no routing data, WAVE BSM only
648  // so do not set up sink
649  if (m_protocol != 0)
650  {
651  Ptr<Socket> sink = SetupRoutingPacketReceive (adhocTxInterfaces.GetAddress (i), c.Get (i));
652  }
653 
654  AddressValue remoteAddress (InetSocketAddress (adhocTxInterfaces.GetAddress (i), m_port));
655  onoff1.SetAttribute ("Remote", remoteAddress);
656 
657  ApplicationContainer temp = onoff1.Install (c.Get (i + m_nSinks));
658  temp.Start (Seconds (var->GetValue (1.0,2.0)));
659  temp.Stop (Seconds (m_TotalSimTime));
660  }
661 }
662 
663 static inline std::string
665 {
666  std::ostringstream oss;
667 
668  oss << Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId ();
669 
670  if (InetSocketAddress::IsMatchingType (srcAddress))
671  {
672  InetSocketAddress addr = InetSocketAddress::ConvertFrom (srcAddress);
673  oss << " received one packet from " << addr.GetIpv4 ();
674  }
675  else
676  {
677  oss << " received one packet!";
678  }
679  return oss.str ();
680 }
681 
682 void
684 {
685  Ptr<Packet> packet;
686  Address srcAddress;
687  while ((packet = socket->RecvFrom (srcAddress)))
688  {
689  // application data, for goodput
690  uint32_t RxRoutingBytes = packet->GetSize ();
691  GetRoutingStats ().IncRxBytes (RxRoutingBytes);
693  if (m_log != 0)
694  {
695  NS_LOG_UNCOND (m_protocolName + " " + PrintReceivedRoutingPacket (socket, packet, srcAddress));
696  }
697  }
698 }
699 
700 void
701 RoutingHelper::OnOffTrace (std::string context, Ptr<const Packet> packet)
702 {
703  uint32_t pktBytes = packet->GetSize ();
704  routingStats.IncTxBytes (pktBytes);
705 }
706 
707 RoutingStats &
709 {
710  return routingStats;
711 }
712 
713 void
715 {
716  m_log = log;
717 }
718 
723 class WifiPhyStats : public Object
724 {
725 public:
730  static TypeId GetTypeId (void);
731 
736  WifiPhyStats ();
737 
742  virtual ~WifiPhyStats ();
743 
749  uint32_t GetTxBytes ();
750 
760  void PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower);
761 
768  void PhyTxDrop (std::string context, Ptr<const Packet> packet);
769 
776  void PhyRxDrop (std::string context, Ptr<const Packet> packet);
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 ();
810  m_phyTxBytes += pktSize;
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
822 WifiPhyStats::PhyRxDrop (std::string context, Ptr<const Packet> packet)
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 starte time for capturing cumulative BSM",
1456  ns3::UintegerValue (0),
1457  ns3::MakeUintegerChecker<uint32_t> ());
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  // every device will have PHY callback for tracing
1610  // which is used to determine the total amount of
1611  // data transmitted, and then used to calculate
1612  // the MAC/PHY overhead beyond the app-data
1613  Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&WifiPhyStats::PhyTxTrace, m_wifiPhyStats));
1614  // TxDrop, RxDrop not working yet. Not sure what I'm doing wrong.
1615  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback (&WifiPhyStats::PhyTxDrop, m_wifiPhyStats));
1616  Config::Connect ("/NodeList/*/DeviceList/*/ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback (&WifiPhyStats::PhyRxDrop, m_wifiPhyStats));
1617 }
1618 
1619 void
1621 {
1623 }
1624 
1625 void
1627 {
1628  // Traffic mix consists of:
1629  // 1. routing data
1630  // 2. Broadcasting of Basic Safety Message (BSM)
1632  SetupWaveMessages ();
1633 
1634  // config trace to capture app-data (bytes) for
1635  // routing data, subtracted and used for
1636  // routing overhead
1637  std::ostringstream oss;
1638  oss.str ("");
1639  oss << "/NodeList/*/ApplicationList/*/$ns3::OnOffApplication/Tx";
1641 }
1642 
1643 void
1645 {
1646  WriteCsvHeader ();
1647  SetupLogFile ();
1648  SetupLogging ();
1649 
1650  AsciiTraceHelper ascii;
1651  MobilityHelper::EnableAsciiAll (ascii.CreateFileStream (m_trName + ".mob"));
1652 }
1653 
1654 void
1656 {
1657  Run ();
1658 }
1659 
1660 void
1662 {
1663  // calculate and output final results
1664  double bsm_pdr1 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (1);
1665  double bsm_pdr2 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (2);
1666  double bsm_pdr3 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (3);
1667  double bsm_pdr4 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (4);
1668  double bsm_pdr5 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (5);
1669  double bsm_pdr6 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (6);
1670  double bsm_pdr7 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (7);
1671  double bsm_pdr8 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (8);
1672  double bsm_pdr9 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (9);
1673  double bsm_pdr10 = m_waveBsmHelper.GetWaveBsmStats ()->GetCumulativeBsmPdr (10);
1674 
1675  double averageRoutingGoodputKbps = 0.0;
1676  uint32_t totalBytesTotal = m_routingHelper->GetRoutingStats ().GetCumulativeRxBytes ();
1677  averageRoutingGoodputKbps = (((double) totalBytesTotal * 8.0) / m_TotalSimTime) / 1000.0;
1678 
1679  // calculate MAC/PHY overhead (mac-phy-oh)
1680  // total WAVE BSM bytes sent
1681  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1682  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1683  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1684  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1685  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1686  double mac_phy_oh = 0.0;
1687  if (totalPhyBytes > 0)
1688  {
1689  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1690  }
1691 
1692  if (m_log != 0)
1693  {
1694  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);
1695 
1696  }
1697 
1698  std::ofstream out (m_CSVfileName2.c_str (), std::ios::app);
1699 
1700  out << bsm_pdr1 << ","
1701  << bsm_pdr2 << ","
1702  << bsm_pdr3 << ","
1703  << bsm_pdr4 << ","
1704  << bsm_pdr5 << ","
1705  << bsm_pdr6 << ","
1706  << bsm_pdr7 << ","
1707  << bsm_pdr8 << ","
1708  << bsm_pdr9 << ","
1709  << bsm_pdr10 << ","
1710  << averageRoutingGoodputKbps << ","
1711  << mac_phy_oh << ""
1712  << std::endl;
1713 
1714  out.close ();
1715 
1716  m_os.close (); // close log file
1717 }
1718 
1719 void
1721 {
1722  NS_LOG_INFO ("Run Simulation.");
1723 
1724  CheckThroughput ();
1725 
1726  Simulator::Stop (Seconds (m_TotalSimTime));
1727  Simulator::Run ();
1728  Simulator::Destroy ();
1729 }
1730 
1731 // Prints actual position and velocity when a course change event occurs
1732 void
1734 CourseChange (std::ostream *os, std::string context, Ptr<const MobilityModel> mobility)
1735 {
1736  Vector pos = mobility->GetPosition (); // Get position
1737  Vector vel = mobility->GetVelocity (); // Get velocity
1738 
1739  pos.z = 1.5;
1740 
1741  int nodeId = mobility->GetObject<Node> ()->GetId ();
1742  double t = (Simulator::Now ()).GetSeconds ();
1743  if (t >= 1.0)
1744  {
1745  WaveBsmHelper::GetNodesMoving ()[nodeId] = 1;
1746  }
1747 
1748  //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::Now () );
1749 
1750  // Prints position and velocities
1751  *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y
1752  << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
1753  << ", z=" << vel.z << std::endl;
1754 }
1755 
1756 void
1758 {
1759  uint32_t bytesTotal = m_routingHelper->GetRoutingStats ().GetRxBytes ();
1760  uint32_t packetsReceived = m_routingHelper->GetRoutingStats ().GetRxPkts ();
1761  double kbps = (bytesTotal * 8.0) / 1000;
1762  double wavePDR = 0.0;
1763  int wavePktsSent = m_waveBsmHelper.GetWaveBsmStats ()->GetTxPktCount ();
1764  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1765  if (wavePktsSent > 0)
1766  {
1767  int wavePktsReceived = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktCount ();
1768  wavePDR = (double) wavePktsReceived / (double) wavePktsSent;
1769  }
1770 
1771  int waveExpectedRxPktCount = m_waveBsmHelper.GetWaveBsmStats ()->GetExpectedRxPktCount (1);
1772  int waveRxPktInRangeCount = m_waveBsmHelper.GetWaveBsmStats ()->GetRxPktInRangeCount (1);
1773  double wavePDR1_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (1);
1774  double wavePDR2_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (2);
1775  double wavePDR3_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (3);
1776  double wavePDR4_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (4);
1777  double wavePDR5_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (5);
1778  double wavePDR6_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (6);
1779  double wavePDR7_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (7);
1780  double wavePDR8_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (8);
1781  double wavePDR9_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (9);
1782  double wavePDR10_2 = m_waveBsmHelper.GetWaveBsmStats ()->GetBsmPdr (10);
1783 
1784  // calculate MAC/PHY overhead (mac-phy-oh)
1785  // total WAVE BSM bytes sent
1786  uint32_t cumulativeWaveBsmBytes = m_waveBsmHelper.GetWaveBsmStats ()->GetTxByteCount ();
1787  uint32_t cumulativeRoutingBytes = m_routingHelper->GetRoutingStats ().GetCumulativeTxBytes ();
1788  uint32_t totalAppBytes = cumulativeWaveBsmBytes + cumulativeRoutingBytes;
1789  uint32_t totalPhyBytes = m_wifiPhyStats->GetTxBytes ();
1790  // mac-phy-oh = (total-phy-bytes - total-app-bytes) / total-phy-bytes
1791  double mac_phy_oh = 0.0;
1792  if (totalPhyBytes > 0)
1793  {
1794  mac_phy_oh = (double) (totalPhyBytes - totalAppBytes) / (double) totalPhyBytes;
1795  }
1796 
1797  std::ofstream out (m_CSVfileName.c_str (), std::ios::app);
1798 
1799  if (m_log != 0 )
1800  {
1801  NS_LOG_UNCOND ("At t=" << (Simulator::Now ()).GetSeconds () << "s BSM_PDR1=" << wavePDR1_2 << " BSM_PDR1=" << wavePDR2_2 << " BSM_PDR3=" << wavePDR3_2 << " BSM_PDR4=" << wavePDR4_2 << " BSM_PDR5=" << wavePDR5_2 << " BSM_PDR6=" << wavePDR6_2 << " BSM_PDR7=" << wavePDR7_2 << " BSM_PDR8=" << wavePDR8_2 << " BSM_PDR9=" << wavePDR9_2 << " BSM_PDR10=" << wavePDR10_2 << " Goodput=" << kbps << "Kbps" /*<< " MAC/PHY-OH=" << mac_phy_oh*/);
1802  }
1803 
1804  out << (Simulator::Now ()).GetSeconds () << ","
1805  << kbps << ","
1806  << packetsReceived << ","
1807  << m_nSinks << ","
1808  << m_protocolName << ","
1809  << m_txp << ","
1810  << wavePktsSent << ","
1811  << wavePktsReceived << ","
1812  << wavePDR << ","
1813  << waveExpectedRxPktCount << ","
1814  << waveRxPktInRangeCount << ","
1815  << wavePDR1_2 << ","
1816  << wavePDR2_2 << ","
1817  << wavePDR3_2 << ","
1818  << wavePDR4_2 << ","
1819  << wavePDR5_2 << ","
1820  << wavePDR6_2 << ","
1821  << wavePDR7_2 << ","
1822  << wavePDR8_2 << ","
1823  << wavePDR9_2 << ","
1824  << wavePDR10_2 << ","
1825  << mac_phy_oh << ""
1826  << std::endl;
1827 
1828  out.close ();
1829 
1832  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktCount (0);
1833  m_waveBsmHelper.GetWaveBsmStats ()->SetTxPktCount (0);
1834  for (int index = 1; index <= 10; index++)
1835  {
1836  m_waveBsmHelper.GetWaveBsmStats ()->SetExpectedRxPktCount (index, 0);
1837  m_waveBsmHelper.GetWaveBsmStats ()->SetRxPktInRangeCount (index, 0);
1838  }
1839 
1840  double currentTime = (Simulator::Now ()).GetSeconds ();
1841  if (currentTime <= (double) m_cumulativeBsmCaptureStart)
1842  {
1843  for (int index = 1; index <= 10; index++)
1844  {
1845  m_waveBsmHelper.GetWaveBsmStats ()->ResetTotalRxPktCounts (index);
1846  }
1847  }
1848 
1849  Simulator::Schedule (Seconds (1.0), &VanetRoutingExperiment::CheckThroughput, this);
1850 }
1851 
1852 void
1854 {
1855  // get settings saved from config-store
1856  UintegerValue uintegerValue;
1857  DoubleValue doubleValue;
1858  StringValue stringValue;
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", uintegerValue);
1900  m_cumulativeBsmCaptureStart = uintegerValue.Get ();
1901 
1902  GlobalValue::GetValueByName ("VRCtxSafetyRange1", doubleValue);
1903  m_txSafetyRange1 = doubleValue.Get ();
1904  GlobalValue::GetValueByName ("VRCtxSafetyRange2", doubleValue);
1905  m_txSafetyRange2 = doubleValue.Get ();
1906  GlobalValue::GetValueByName ("VRCtxSafetyRange3", doubleValue);
1907  m_txSafetyRange3 = doubleValue.Get ();
1908  GlobalValue::GetValueByName ("VRCtxSafetyRange4", doubleValue);
1909  m_txSafetyRange4 = doubleValue.Get ();
1910  GlobalValue::GetValueByName ("VRCtxSafetyRange5", doubleValue);
1911  m_txSafetyRange5 = doubleValue.Get ();
1912  GlobalValue::GetValueByName ("VRCtxSafetyRange6", doubleValue);
1913  m_txSafetyRange6 = doubleValue.Get ();
1914  GlobalValue::GetValueByName ("VRCtxSafetyRange7", doubleValue);
1915  m_txSafetyRange7 = doubleValue.Get ();
1916  GlobalValue::GetValueByName ("VRCtxSafetyRange8", doubleValue);
1917  m_txSafetyRange8 = doubleValue.Get ();
1918  GlobalValue::GetValueByName ("VRCtxSafetyRange9", doubleValue);
1919  m_txSafetyRange9 = doubleValue.Get ();
1920  GlobalValue::GetValueByName ("VRCtxSafetyRange10", doubleValue);
1921  m_txSafetyRange10 = doubleValue.Get ();
1922  GlobalValue::GetValueByName ("VRCtxp", doubleValue);
1923  m_txp = doubleValue.Get ();
1924  GlobalValue::GetValueByName ("VRCtotalTime", doubleValue);
1925  m_TotalSimTime = doubleValue.Get ();
1926  GlobalValue::GetValueByName ("VRCwaveInterval", doubleValue);
1927  m_waveInterval = doubleValue.Get ();
1928  GlobalValue::GetValueByName ("VRCgpsAccuracyNs", doubleValue);
1929  m_gpsAccuracyNs = doubleValue.Get ();
1930  GlobalValue::GetValueByName ("VRCtxMaxDelayMs", doubleValue);
1931  m_txMaxDelayMs = doubleValue.Get ();
1932 
1933  GlobalValue::GetValueByName ("VRCCSVfileName", stringValue);
1934  m_CSVfileName = stringValue.Get ();
1935  GlobalValue::GetValueByName ("VRCCSVfileName2", stringValue);
1936  m_CSVfileName2 = stringValue.Get ();
1937  GlobalValue::GetValueByName ("VRCphyMode", stringValue);
1938  m_phyMode = stringValue.Get ();
1939  GlobalValue::GetValueByName ("VRCtraceFile", stringValue);
1940  m_traceFile = stringValue.Get ();
1941  GlobalValue::GetValueByName ("VRClogFile", stringValue);
1942  m_logFile = stringValue.Get ();
1943  GlobalValue::GetValueByName ("VRCrate", stringValue);
1944  m_rate = stringValue.Get ();
1945  GlobalValue::GetValueByName ("VRCphyModeB", stringValue);
1946  m_phyModeB = stringValue.Get ();
1947  GlobalValue::GetValueByName ("VRCtrName", stringValue);
1948  m_trName = stringValue.Get ();
1949 }
1950 
1951 void
1953 {
1954  // get settings saved from config-store
1955  UintegerValue uintegerValue;
1956  DoubleValue doubleValue;
1957  StringValue stringValue;
1958 
1977 
1993 
2002  GlobalValue::GetValueByName ("VRCtrName", stringValue);
2003  m_trName = stringValue.Get ();
2004 }
2005 
2006 void
2008 {
2009  CommandLine cmd;
2010  double txDist1 = 50.0;
2011  double txDist2 = 100.0;
2012  double txDist3 = 150.0;
2013  double txDist4 = 200.0;
2014  double txDist5 = 250.0;
2015  double txDist6 = 300.0;
2016  double txDist7 = 350.0;
2017  double txDist8 = 350.0;
2018  double txDist9 = 350.0;
2019  double txDist10 = 350.0;
2020 
2021  // allow command line overrides
2022  cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName);
2023  cmd.AddValue ("CSVfileName2", "The name of the CSV output file name2", m_CSVfileName2);
2024  cmd.AddValue ("totaltime", "Simulation end time", m_TotalSimTime);
2025  cmd.AddValue ("nodes", "Number of nodes (i.e. vehicles)", m_nNodes);
2026  cmd.AddValue ("sinks", "Number of routing sinks", m_nSinks);
2027  cmd.AddValue ("txp", "Transmit power (dB), e.g. txp=7.5", m_txp);
2028  cmd.AddValue ("traceMobility", "Enable mobility tracing", m_traceMobility);
2029  cmd.AddValue ("protocol", "1=OLSR;2=AODV;3=DSDV;4=DSR", m_protocol);
2030  cmd.AddValue ("lossModel", "1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance", m_lossModel);
2031  cmd.AddValue ("fading", "0=None;1=Nakagami;(buildings=1 overrides)", m_fading);
2032  cmd.AddValue ("phyMode", "Wifi Phy mode", m_phyMode);
2033  cmd.AddValue ("80211Mode", "1=802.11p; 2=802.11b; 3=WAVE-PHY", m_80211mode);
2034  cmd.AddValue ("traceFile", "Ns2 movement trace file", m_traceFile);
2035  cmd.AddValue ("logFile", "Log file", m_logFile);
2036  cmd.AddValue ("mobility", "1=trace;2=RWP", m_mobility);
2037  cmd.AddValue ("rate", "Rate", m_rate);
2038  cmd.AddValue ("phyModeB", "Phy mode 802.11b", m_phyModeB);
2039  cmd.AddValue ("speed", "Node speed (m/s)", m_nodeSpeed);
2040  cmd.AddValue ("pause", "Node pause (s)", m_nodePause);
2041  cmd.AddValue ("verbose", "0=quiet;1=verbose", m_verbose);
2042  cmd.AddValue ("bsm", "(WAVE) BSM size (bytes)", m_wavePacketSize);
2043  cmd.AddValue ("interval", "(WAVE) BSM interval (s)", m_waveInterval);
2044  cmd.AddValue ("scenario", "1=synthetic, 2=playback-trace", m_scenario);
2045  // User is allowed to have up to 10 different PDRs (Packet
2046  // Delivery Ratios) calculate, and so can specify up to
2047  // 10 different tx distances.
2048  cmd.AddValue ("txdist1", "Expected BSM tx range, m", txDist1);
2049  cmd.AddValue ("txdist2", "Expected BSM tx range, m", txDist2);
2050  cmd.AddValue ("txdist3", "Expected BSM tx range, m", txDist3);
2051  cmd.AddValue ("txdist4", "Expected BSM tx range, m", txDist4);
2052  cmd.AddValue ("txdist5", "Expected BSM tx range, m", txDist5);
2053  cmd.AddValue ("txdist6", "Expected BSM tx range, m", txDist6);
2054  cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7);
2055  cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8);
2056  cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9);
2057  cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10);
2058  cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs);
2059  cmd.AddValue ("txmaxdelay", "Tx max delay, in ms", m_txMaxDelayMs);
2060  cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routingTables);
2061  cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace);
2062  cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap);
2063  cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilename);
2064  cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilename);
2065  cmd.AddValue ("exp", "Experiment", m_exp);
2066  cmd.AddValue ("BsmCaptureStart", "Start time to begin capturing pkts for cumulative Bsm", m_cumulativeBsmCaptureStart);
2067  cmd.Parse (argc, argv);
2068 
2069  m_txSafetyRange1 = txDist1;
2070  m_txSafetyRange2 = txDist2;
2071  m_txSafetyRange3 = txDist3;
2072  m_txSafetyRange4 = txDist4;
2073  m_txSafetyRange5 = txDist5;
2074  m_txSafetyRange6 = txDist6;
2075  m_txSafetyRange7 = txDist7;
2076  m_txSafetyRange8 = txDist8;
2077  m_txSafetyRange9 = txDist9;
2078  m_txSafetyRange10 = txDist10;
2079  // load configuration info from config-store
2080  ConfigStoreHelper configStoreHelper;
2081  configStoreHelper.LoadConfig (m_loadConfigFilename);
2082  // transfer config-store values to config parameters
2084 
2085  // parse again so you can override input file default values via command line
2086  cmd.Parse (argc, argv);
2087 
2088  m_txSafetyRange1 = txDist1;
2089  m_txSafetyRange2 = txDist2;
2090  m_txSafetyRange3 = txDist3;
2091  m_txSafetyRange4 = txDist4;
2092  m_txSafetyRange5 = txDist5;
2093  m_txSafetyRange6 = txDist6;
2094  m_txSafetyRange7 = txDist7;
2095  m_txSafetyRange8 = txDist8;
2096  m_txSafetyRange9 = txDist9;
2097  m_txSafetyRange10 = txDist10;
2098 }
2099 
2100 void
2102 {
2103  // open log file for output
2104  m_os.open (m_logFile.c_str ());
2105 }
2106 
2108 {
2109 
2110  // Enable logging from the ns2 helper
2111  LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
2112 
2113  Packet::EnablePrinting ();
2114 }
2115 
2116 void
2118 {
2119  Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64"));
2120  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (m_rate));
2121 
2122  //Set Non-unicastMode rate to unicast mode
2123  if (m_80211mode == 2)
2124  {
2125  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyModeB));
2126  }
2127  else
2128  {
2129  Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (m_phyMode));
2130  }
2131 }
2132 
2133 void
2135 {
2136  if (m_mobility == 1)
2137  {
2138  // Create Ns2MobilityHelper with the specified trace log file as parameter
2140  ns2.Install (); // configure movements for each node, while reading trace file
2141  // initially assume all nodes are not moving
2142  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 0);
2143  }
2144  else if (m_mobility == 2)
2145  {
2146  MobilityHelper mobilityAdhoc;
2147 
2148  ObjectFactory pos;
2149  pos.SetTypeId ("ns3::RandomBoxPositionAllocator");
2150  pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
2151  pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
2152  // we need antenna height uniform [1.0 .. 2.0] for loss model
2153  pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"));
2154 
2155  Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
2156  m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex);
2157 
2158  std::stringstream ssSpeed;
2159  ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]";
2160  std::stringstream ssPause;
2161  ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]";
2162  mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel",
2163  "Speed", StringValue (ssSpeed.str ()),
2164  "Pause", StringValue (ssPause.str ()),
2165  "PositionAllocator", PointerValue (taPositionAlloc));
2166  mobilityAdhoc.SetPositionAllocator (taPositionAlloc);
2167  mobilityAdhoc.Install (m_adhocTxNodes);
2168  m_streamIndex += mobilityAdhoc.AssignStreams (m_adhocTxNodes, m_streamIndex);
2169 
2170  // initially assume all nodes are moving
2171  WaveBsmHelper::GetNodesMoving ().resize (m_nNodes, 1);
2172  }
2173 
2174  // Configure callback for logging
2175  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2177 }
2178 
2179 void
2181 {
2182  if (m_lossModel == 1)
2183  {
2184  m_lossModelName = "ns3::FriisPropagationLossModel";
2185  }
2186  else if (m_lossModel == 2)
2187  {
2188  m_lossModelName = "ns3::ItuR1411LosPropagationLossModel";
2189  }
2190  else if (m_lossModel == 3)
2191  {
2192  m_lossModelName = "ns3::TwoRayGroundPropagationLossModel";
2193  }
2194  else if (m_lossModel == 4)
2195  {
2196  m_lossModelName = "ns3::LogDistancePropagationLossModel";
2197  }
2198  else
2199  {
2200  // Unsupported propagation loss model.
2201  // Treating as ERROR
2202  NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance");
2203  }
2204 
2205  // frequency
2206  double freq = 0.0;
2207  if ((m_80211mode == 1)
2208  || (m_80211mode == 3))
2209  {
2210  // 802.11p 5.9 GHz
2211  freq = 5.9e9;
2212  }
2213  else
2214  {
2215  // 802.11b 2.4 GHz
2216  freq = 2.4e9;
2217  }
2218 
2219  // Setup propagation models
2220  YansWifiChannelHelper wifiChannel;
2221  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
2222  if (m_lossModel == 3)
2223  {
2224  // two-ray requires antenna height (else defaults to Friss)
2225  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq), "HeightAboveZ", DoubleValue (1.5));
2226  }
2227  else
2228  {
2229  wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue (freq));
2230  }
2231 
2232  // Propagation loss models are additive.
2233  if (m_fading != 0)
2234  {
2235  // if no obstacle model, then use Nakagami fading if requested
2236  wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel");
2237  }
2238 
2239  // the channel
2240  Ptr<YansWifiChannel> channel = wifiChannel.Create ();
2241 
2242  // The below set of helpers will help us to put together the wifi NICs we want
2243  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
2244  wifiPhy.SetChannel (channel);
2245  // ns-3 supports generate a pcap trace
2246  wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2247 
2248  YansWavePhyHelper wavePhy = YansWavePhyHelper::Default ();
2249  wavePhy.SetChannel (channel);
2250  wavePhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11);
2251 
2252  // Setup WAVE PHY and MAC
2253  NqosWaveMacHelper wifi80211pMac = NqosWaveMacHelper::Default ();
2254  WaveHelper waveHelper = WaveHelper::Default ();
2255  Wifi80211pHelper wifi80211p = Wifi80211pHelper::Default ();
2256  if (m_verbose)
2257  {
2258  wifi80211p.EnableLogComponents (); // Turn on all Wifi 802.11p logging
2259  // likewise, turn on WAVE PHY logging
2260  waveHelper.EnableLogComponents ();
2261  }
2262 
2263  WifiHelper wifi;
2264 
2265  // Setup 802.11b stuff
2267 
2268  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2269  "DataMode",StringValue (m_phyModeB),
2270  "ControlMode",StringValue (m_phyModeB));
2271 
2272  // Setup 802.11p stuff
2273  wifi80211p.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2274  "DataMode",StringValue (m_phyMode),
2275  "ControlMode",StringValue (m_phyMode));
2276 
2277  // Setup WAVE-PHY stuff
2278  waveHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2279  "DataMode",StringValue (m_phyMode),
2280  "ControlMode",StringValue (m_phyMode));
2281 
2282  // Set Tx Power
2283  wifiPhy.Set ("TxPowerStart",DoubleValue (m_txp));
2284  wifiPhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2285  wavePhy.Set ("TxPowerStart",DoubleValue (m_txp));
2286  wavePhy.Set ("TxPowerEnd", DoubleValue (m_txp));
2287 
2288  // Add an upper mac and disable rate control
2289  WifiMacHelper wifiMac;
2290  wifiMac.SetType ("ns3::AdhocWifiMac");
2291  QosWaveMacHelper waveMac = QosWaveMacHelper::Default ();
2292 
2293  // Setup net devices
2294 
2295  if (m_80211mode == 3)
2296  {
2297  m_adhocTxDevices = waveHelper.Install (wavePhy, waveMac, m_adhocTxNodes);
2298  }
2299  else if (m_80211mode == 1)
2300  {
2301  m_adhocTxDevices = wifi80211p.Install (wifiPhy, wifi80211pMac, m_adhocTxNodes);
2302  }
2303  else
2304  {
2305  m_adhocTxDevices = wifi.Install (wifiPhy, wifiMac, m_adhocTxNodes);
2306  }
2307 
2308  if (m_asciiTrace != 0)
2309  {
2310  AsciiTraceHelper ascii;
2311  Ptr<OutputStreamWrapper> osw = ascii.CreateFileStream ( (m_trName + ".tr").c_str ());
2312  wifiPhy.EnableAsciiAll (osw);
2313  wavePhy.EnableAsciiAll (osw);
2314  }
2315  if (m_pcap != 0)
2316  {
2317  wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap");
2318  wavePhy.EnablePcapAll ("vanet-routing-compare-pcap");
2319  }
2320 }
2321 
2322 void
2324 {
2325  // WAVE PHY mode
2326  // 0=continuous channel; 1=channel-switching
2327  int chAccessMode = 0;
2328  if (m_80211mode == 3)
2329  {
2330  chAccessMode = 1;
2331  }
2332 
2337  // GPS accuracy (i.e, clock drift), in number of ns
2340  chAccessMode,
2341  // tx max delay before transmit, in ms
2343 
2344  // fix random number streams
2346 }
2347 
2348 void
2350 {
2355  m_protocol,
2356  m_nSinks,
2357  m_routingTables);
2358 }
2359 
2360 void
2362 {
2363  // member variable parameter use
2364  // defaults or command line overrides,
2365  // except where scenario={1,2,3,...}
2366  // have been specified, in which case
2367  // specify parameters are overwritten
2368  // here to setup for specific scenarios
2369 
2370  // certain parameters may be further overridden
2371  // i.e. specify a scenario, override tx power.
2372 
2373  if (m_scenario == 1)
2374  {
2375  // 40 nodes in RWP 300 m x 1500 m synthetic highway, 10s
2376  m_traceFile = "";
2377  m_logFile = "";
2378  m_mobility = 2;
2379  if (m_nNodes == 156)
2380  {
2381  m_nNodes = 40;
2382  }
2383  if (m_TotalSimTime == 300.01)
2384  {
2385  m_TotalSimTime = 10.0;
2386  }
2387  }
2388  else if (m_scenario == 2)
2389  {
2390  // Realistic vehicular trace in 4.6 km x 3.0 km suburban Zurich
2391  // "low density, 99 total vehicles"
2392  m_traceFile = "src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob";
2393  m_logFile = "low99-ct-unterstrass-1day.filt.7.adj.log";
2394  m_mobility = 1;
2395  m_nNodes = 99;
2396  m_TotalSimTime = 300.01;
2397  m_nodeSpeed = 0;
2398  m_nodePause = 0;
2399  m_CSVfileName = "low_vanet-routing-compare.csv";
2400  m_CSVfileName = "low_vanet-routing-compare2.csv";
2401  }
2402 }
2403 
2404 void
2406 {
2407  //blank out the last output file and write the column headers
2408  std::ofstream out (m_CSVfileName.c_str ());
2409  out << "SimulationSecond," <<
2410  "ReceiveRate," <<
2411  "PacketsReceived," <<
2412  "NumberOfSinks," <<
2413  "RoutingProtocol," <<
2414  "TransmissionPower," <<
2415  "WavePktsSent," <<
2416  "WavePtksReceived," <<
2417  "WavePktsPpr," <<
2418  "ExpectedWavePktsReceived," <<
2419  "ExpectedWavePktsInCoverageReceived," <<
2420  "BSM_PDR1," <<
2421  "BSM_PDR2," <<
2422  "BSM_PDR3," <<
2423  "BSM_PDR4," <<
2424  "BSM_PDR5," <<
2425  "BSM_PDR6," <<
2426  "BSM_PDR7," <<
2427  "BSM_PDR8," <<
2428  "BSM_PDR9," <<
2429  "BSM_PDR10," <<
2430  "MacPhyOverhead" <<
2431  std::endl;
2432  out.close ();
2433 
2434  std::ofstream out2 (m_CSVfileName2.c_str ());
2435  out2 << "BSM_PDR1,"
2436  << "BSM_PDR2,"
2437  << "BSM_PDR3,"
2438  << "BSM_PDR4,"
2439  << "BSM_PDR5,"
2440  << "BSM_PDR6,"
2441  << "BSM_PDR7,"
2442  << "BSM_PDR8,"
2443  << "BSM_PDR9,"
2444  << "BSM_PDR10,"
2445  << "AverageRoutingGoodputKbps,"
2446  << "MacPhyOverhead"
2447  << std::endl;
2448  out2.close ();
2449 }
2450 
2451 int
2452 main (int argc, char *argv[])
2453 {
2455  experiment.Simulate (argc, argv);
2456 }
static ns3::GlobalValue g_gpsAccuracyNs("VRCgpsAccuracyNs","GPS sync accuracy (ns)", ns3::DoubleValue(40), ns3::MakeDoubleChecker< double >())
void AddPropagationLoss(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
static ns3::GlobalValue g_asciiTrace("VRCasciiTrace","Dump ASCII trace 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
Ptr< PacketSink > sink
Definition: wifi-tcp.cc:45
tuple channel
Definition: third.py:85
void Set(std::string name, const AttributeValue &v)
Definition: wifi-helper.cc:132
Ptr< const AttributeChecker > MakeStringChecker(void)
Definition: string.cc:30
holds a vector of ns3::Application pointers.
Introspection did not find any typical Config paths.
Definition: config-store.h:59
std::string m_logFile
log file
static void EnableLogComponents(void)
Helper to enable all WaveNetDevice log components with one statement.
Definition: wave-helper.cc:429
helps to create wifi 802.11p objects of WifiNetDevice class
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
The RoutingStats class manages collects statistics on routing data (application-data packet and byte ...
RoutingHelper()
Constructor.
WifiApp()
Constructor.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Manage ASCII trace files for device models.
Definition: trace-helper.h:161
an Inet address class
Ipv4Address GetIpv4(void) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
std::string Get(void) const
Definition: string.cc:31
int m_routingTables
dump routing table (at t=5 sec). 0=No, 1=Yes
static ns3::GlobalValue g_rate("VRCrate","Data rate", ns3::StringValue("2048bps"), ns3::MakeStringChecker())
NodeContainer m_adhocTxNodes
adhoc transmit nodes
void WriteCsvHeader()
Write the header line to the CSV file1.
static ns3::GlobalValue g_80211mode("VRC80211mode","802.11 mode (0=802.11a;1=802.11p)", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
std::string m_CSVfileName
CSV file name.
static ns3::GlobalValue g_nSinks("VRCnSinks","Number of sink nodes for routing non-BSM traffic", ns3::UintegerValue(10), ns3::MakeUintegerChecker< uint32_t >())
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
holds a vector of std::pair of Ptr and interface index.
void SetupRoutingMessages()
Set up generation of packets to be routed through the vehicular network.
std::string m_saveConfigFilename
save configi file name
Ptr< YansWifiChannel > Create(void) const
static ns3::GlobalValue g_pcap("VRCpcap","Generate PCAP files 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
void SetRemoteStationManager(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition: wifi-helper.cc:719
virtual void ConfigureNodes()
Configure nodes.
virtual void ConfigureNodes()
Configure nodes.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
Hold variables of type string.
Definition: string.h:41
void SetLogging(int log)
Enable/disable logging.
Make it easy to create and manage PHY objects for the yans model.
static ns3::GlobalValue g_txSafetyRange9("VRCtxSafetyRange9","BSM range for PDR inclusion", ns3::DoubleValue(450.0), ns3::MakeDoubleChecker< double >())
The WifiPhyStats class collects Wifi MAC/PHY statistics.
virtual void ParseCommandLineArguments(int argc, char **argv)
Process command line arguments.
static ns3::GlobalValue g_txSafetyRange3("VRCtxSafetyRange3","BSM range for PDR inclusion", ns3::DoubleValue(150.0), ns3::MakeDoubleChecker< double >())
static std::string PrintReceivedRoutingPacket(Ptr< Socket > socket, Ptr< Packet > packet, Address srcAddress)
void SetRxBytes(uint32_t rxBytes)
Sets the number of bytes received.
uint32_t GetCumulativeTxPkts()
Returns the cumulative number of packets transmitted.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1686
uint32_t m_TxPkts
transmit packets
void PhyTxDrop(std::string context, Ptr< const Packet > packet)
Callback signiture for Phy/TxDrop.
static ns3::GlobalValue g_cumulativeBsmCaptureStart("VRCcumulativeBsmCaptureStart","Simulation starte time for capturing cumulative BSM", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
Helper class that adds DSR routing to nodes.
void SetupWaveMessages()
Set up generation of IEEE 1609 WAVE messages, as a Basic Safety Message (BSM).
std::string m_traceFile
trace file
uint32_t GetCumulativeRxBytes()
Returns the cumulative number of bytes received.
static ns3::GlobalValue g_port("VRCport","Port", ns3::UintegerValue(9), ns3::MakeUintegerChecker< uint32_t >())
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1001
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
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:796
Vector GetPosition(void) const
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:277
int m_routingTables
routing tables
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:719
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits. ...
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the mobility models (inc...
static ns3::GlobalValue g_txSafetyRange10("VRCtxSafetyRange10","BSM range for PDR inclusion", ns3::DoubleValue(500.0), ns3::MakeDoubleChecker< double >())
void IncTxBytes(uint32_t txBytes)
Increment the number of bytes transmitted.
uint32_t m_cumulativeRxBytes
cumulative receive bytes
Hold a so-called 'global value'.
Definition: global-value.h:73
std::string m_phyMode
phy mode
uint32_t m_TxBytes
transmit bytes
std::string m_phyModeB
phy mode
static ns3::GlobalValue g_wavePacketSize("VRCwavePacketSize","Size in bytes of WAVE BSM", ns3::UintegerValue(200), ns3::MakeUintegerChecker< uint32_t >())
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wave-helper.cc:364
void CommandSetup(int argc, char **argv)
Run the simulation.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:213
virtual void RunSimulation()
Run the simulation.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
virtual void ConfigureChannels()
Configure channels.
Vector GetVelocity(void) const
tuple cmd
Definition: second.py:35
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...
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:566
NetDeviceContainer m_adhocTxDevices
adhoc transmit devices
void SetGlobalsFromConfig()
Set up the global variables from the configuration parameters.
a polymophic address class
Definition: address.h:90
static ns3::GlobalValue g_totalTime("VRCtotalTime","Total simulation time (s)", ns3::DoubleValue(300.01), ns3::MakeDoubleChecker< double >())
ConfigStoreHelper()
Constructor.
static TypeId GetTypeId(void)
Gets the class TypeId.
static ns3::GlobalValue g_txMaxDelayMs("VRCtxMaxDelayMs","Tx May Delay (ms)", ns3::DoubleValue(10), ns3::MakeDoubleChecker< double >())
virtual void ProcessOutputs()
Process outputs.
static ns3::GlobalValue g_txSafetyRange6("VRCtxSafetyRange6","BSM range for PDR inclusion", ns3::DoubleValue(300.0), ns3::MakeDoubleChecker< double >())
static ns3::GlobalValue g_mobility("VRCmobility","Mobility mode 0=random waypoint;1=mobility trace file", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
uint64_t Get(void) const
Definition: uinteger.cc:35
WaveBsmHelper m_waveBsmHelper
helper
void SetRxPkts(uint32_t rxPkts)
Sets the number of packets received.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
void SetChannel(Ptr< YansWifiChannel > channel)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
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:318
std::string m_trName
trace file name
void SetTxPkts(uint32_t txPkts)
Sets the 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:...
void SetupRoutingMessages(NodeContainer &c, Ipv4InterfaceContainer &adhocTxInterfaces)
Sets up routing messages on the nodes and their interfaces.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
virtual void ProcessOutputs()
Process outputs.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:369
tuple mobility
Definition: third.py:101
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
bool m_traceMobility
trace mobility
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
static ns3::GlobalValue g_trName("VRCtrName","Trace name", ns3::StringValue("vanet-routing-compare"), ns3::MakeStringChecker())
uint32_t GetCumulativeRxPkts()
Returns the cumulative count of packets received.
void LoadConfig(std::string configFilename)
Loads a saved config-store raw text configuration from a given named file.
Hold an unsigned integer type.
Definition: uinteger.h:44
helps to create WaveNetDevice objects
Definition: wave-helper.h:112
holds a vector of ns3::NetDevice pointers
static ns3::GlobalValue g_txSafetyRange1("VRCtxSafetyRange1","BSM range for PDR inclusion", ns3::DoubleValue(50.0), ns3::MakeDoubleChecker< double >())
virtual void RunSimulation()
Run the simulation.
virtual void SetStandard(enum WifiPhyStandard standard)
Definition: wifi-helper.cc:742
void SetupAdhocDevices()
Set up the adhoc devices.
std::string m_protocolName
protocol name
static ns3::GlobalValue g_verbose("VRCverbose","Verbose 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
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
static ns3::GlobalValue g_traceMobility("VRCtraceMobility","Trace mobility 1=yes;0=no", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_routingTables("VRCroutingTables","Dump routing tables at t=5 seconds 0=no;1=yes", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Definition: wifi-helper.cc:748
virtual void SetDefaultAttributeValues()
Sets default attribute values.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
virtual void ConfigureApplications()
Configure applications.
static ns3::GlobalValue g_waveInterval("VRCwaveInterval","Interval (s) between WAVE BSMs", ns3::DoubleValue(0.1), ns3::MakeDoubleChecker< double >())
uint32_t m_phyTxBytes
phy transmit bytes
static ns3::GlobalValue g_scenario("VRCscenario","Scenario", ns3::UintegerValue(1), ns3::MakeUintegerChecker< uint32_t >())
double m_txMaxDelayMs
transmit maximum delay
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
The WaveBsmHelper class manages IEEE 1609 WAVE (Wireless Access in Vehicular Environments) Basic Safe...
RoutingStats()
Constructor.
static ns3::GlobalValue g_nNodes("VRCnNodes","Number of nodes (vehicles)", ns3::UintegerValue(156), ns3::MakeUintegerChecker< uint32_t >())
void Run()
Run the simulation.
void SetupLogging()
Set up logging.
std::string m_protocolName
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:205
std::string m_CSVfileName2
CSV file name.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:843
uint32_t m_nSinks
number of sinks
double Get(void) const
Definition: double.cc:35
#define list
void SetupLogFile()
Set up log file.
void ConfigureDefaults(void)
Configure the default values.
LOG_DEBUG and above.
Definition: log.h:100
WifiPhyStats()
Constructor.
static ns3::GlobalValue g_phyMode("VRCphyMode","PHY mode (802.11p)", ns3::StringValue("OfdmRate6MbpsBW10MHz"), ns3::MakeStringChecker())
std::string m_loadConfigFilename
load config file name
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &macHelper, NodeContainer c) const
virtual void ConfigureChannels()
Configure channels.
static TypeId GetTypeId(void)
Get class TypeId.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr.
Definition: pointer.h:36
virtual ~RoutingHelper()
Destructor.
void SetupRoutingProtocol(NodeContainer &c)
Sets up the protocol protocol on the nodes.
double m_TotalSimTime
seconds
virtual void ConfigureMobility()
Configure mobility.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
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...
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
uint32_t GetRxPkts()
Returns the count of packets received.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
bool SetValue(const AttributeValue &value)
Set the value of this GlobalValue.
Ptr< Socket > SetupRoutingPacketReceive(Ipv4Address addr, Ptr< Node > node)
Sets up a routing packet for tranmission.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
void SetTxBytes(uint32_t txBytes)
Sets the number of bytes transmitted.
manage and create wifi channel objects for the yans model.
void OnOffTrace(std::string context, Ptr< const Packet > packet)
Trace the receipt of an on-off-application generated packet.
virtual void ConfigureDevices()
Configure devices.
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 Add(const Ipv4RoutingHelper &routing, int16_t priority)
The ConfigStoreHelper class simplifies config-store raw text load and save.
void IncTxPkts()
Increment the count of packets transmitted.
int64_t m_streamIndex
used to get consistent random numbers across scenarios
Nqos Wave Mac Helper class.
void AssignIpAddresses(NetDeviceContainer &d, Ipv4InterfaceContainer &adhocTxInterfaces)
Assigns IPv4 addresses to net devices and their interfaces.
std::vector< double > m_txSafetyRanges
list of ranges
void PhyRxDrop(std::string context, Ptr< const Packet > packet)
Callback signiture for Phy/RxDrop.
int m_cumulativeBsmCaptureStart
capture start
void SetupScenario()
Set up a prescribed scenario.
uint32_t m_RxBytes
reeive bytes
static ns3::GlobalValue g_txSafetyRange7("VRCtxSafetyRange7","BSM range for PDR inclusion", ns3::DoubleValue(350.0), ns3::MakeDoubleChecker< double >())
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())
uint32_t GetTxPkts()
Returns the number of packets transmitted.
std::string m_lossModelName
loss model name
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_CSVfileName("VRCCSVfileName","CSV filename (for time series data)", ns3::StringValue("vanet-routing.output.csv"), ns3::MakeStringChecker())
Instantiate subclasses of ns3::Object.
uint32_t GetTxBytes()
Returns the number of bytes transmitted.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
AttributeValue implementation for Address.
Definition: address.h:278
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
virtual void ConfigureMobility()
Configure mobility.
uint32_t GetId(void) const
Definition: node.cc:107
static ns3::GlobalValue g_logFile("VRClogFile","Log filename", ns3::StringValue("low99-ct-unterstrass-1day.filt.7.adj.log"), ns3::MakeStringChecker())
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.
static ns3::GlobalValue g_protocol("VRCprotocol","Routing protocol", ns3::UintegerValue(2), ns3::MakeUintegerChecker< uint32_t >())
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Definition: command-line.h:498
void Simulate(int argc, char **argv)
Enacts simulation of an ns-3 wifi application.
uint32_t m_cumulativeTxPkts
cumulative transmit packets
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
static ns3::GlobalValue g_txp("VRCtxp","Transmission power dBm", ns3::DoubleValue(7.5), ns3::MakeDoubleChecker< double >())
void CheckThroughput()
Checks the throughput and outputs summary to CSV file1.
ApplicationContainer Install(Ipv4InterfaceContainer i) const
Install an ns3::BsmApplication on each node of the input container configured with all the attributes...
A network Node.
Definition: node.h: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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:782
static ns3::GlobalValue g_txSafetyRange2("VRCtxSafetyRange2","BSM range for PDR inclusion", ns3::DoubleValue(100.0), ns3::MakeDoubleChecker< double >())
Ptr< WaveBsmStats > GetWaveBsmStats()
Returns the WaveBsmStats instance.
static ns3::GlobalValue g_txSafetyRange5("VRCtxSafetyRange5","BSM range for PDR inclusion", ns3::DoubleValue(250.0), ns3::MakeDoubleChecker< double >())
static ns3::GlobalValue g_fading("VRCfading","Fast Fading Model", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_nodeSpeed("VRCnodeSpeed","Node speed (m/s) for RWP model", ns3::UintegerValue(20), ns3::MakeUintegerChecker< uint32_t >())
static ns3::GlobalValue g_traceFile("VRCtraceFile","Mobility trace filename", ns3::StringValue("./src/wave/examples/low99-ct-unterstrass-1day.filt.7.adj.mob"), ns3::MakeStringChecker())
virtual void ConfigureTracing()
Configure tracing.
static ns3::GlobalValue g_phyModeB("VRCphyModeB","PHY mode (802.11a)", ns3::StringValue("DsssRate11Mbps"), ns3::MakeStringChecker())
Ptr< WifiPhyStats > m_wifiPhyStats
wifi phy statistics
Helper class that adds ns3::Ipv4ListRouting objects.
static ns3::GlobalValue g_txSafetyRange8("VRCtxSafetyRange8","BSM range for PDR inclusion", ns3::DoubleValue(400.0), ns3::MakeDoubleChecker< double >())
void Parse(int argc, char *argv[])
Parse the program arguments.
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:365
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:253
tuple wifi
Definition: third.py:89
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Install(NodeContainer &c, NetDeviceContainer &d, Ipv4InterfaceContainer &i, double totalTime, int protocol, uint32_t nSinks, int routingTables)
Installs routing funcationality on nodes and their devices and interfaces.
virtual void ConfigureDevices()
Configure devices.
uint32_t GetRxBytes()
Returns the number of bytes received.
std::ofstream m_os
output stream
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...
static ns3::GlobalValue g_CSVfileName2("VRCCSVfileName2","CSV filename 2 (for overall simulation scenario results)", ns3::StringValue("vanet-routing.output2.csv"), ns3::MakeStringChecker())
The WifiApp class enforces program flow for ns-3 wifi applications.
uint32_t GetCumulativeTxBytes()
Returns the cumulative number of bytes transmitted.
static ns3::GlobalValue g_lossModel("VRClossModel","Propagation Loss Model", ns3::UintegerValue(3), ns3::MakeUintegerChecker< uint32_t >())
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
The RoutingHelper class generates routing data between nodes (vehicles) and uses the RoutingStats cla...
void SaveConfig(std::string configFilename)
Saves a configuration to a given named config-store raw text configuration file.
Helper class that adds DSDV routing to nodes.
Definition: dsdv-helper.h:45
void Install(DsrHelper &dsrHelper, NodeContainer nodes)
Install routing to the nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetupAdhocMobilityNodes()
Set up the adhoc mobility nodes.
virtual ~WifiApp()
Destructor.
a unique identifier for an interface.
Definition: type-id.h:58
static ns3::GlobalValue g_txSafetyRange4("VRCtxSafetyRange4","BSM range for PDR inclusion", ns3::DoubleValue(200.0), ns3::MakeDoubleChecker< double >())
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:914
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
uint32_t m_nNodes
number of nodes
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
uint32_t m_phyTxPkts
phy transmit packets
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
static ns3::GlobalValue g_nodePause("VRCnodePause","Node pause time (s) for RWP model", ns3::UintegerValue(0), ns3::MakeUintegerChecker< uint32_t >())
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
uint32_t m_nNodes
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Allocate a set of positions.
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model...