LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2014 North Carolina State University | 3 * Copyright (c) 2014 North Carolina State University |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 #include "ns3/dsr-module.h" | 112 #include "ns3/dsr-module.h" |
113 #include "ns3/applications-module.h" | 113 #include "ns3/applications-module.h" |
114 #include "ns3/itu-r-1411-los-propagation-loss-model.h" | 114 #include "ns3/itu-r-1411-los-propagation-loss-model.h" |
115 #include "ns3/ocb-wifi-mac.h" | 115 #include "ns3/ocb-wifi-mac.h" |
116 #include "ns3/wifi-80211p-helper.h" | 116 #include "ns3/wifi-80211p-helper.h" |
117 #include "ns3/wave-mac-helper.h" | 117 #include "ns3/wave-mac-helper.h" |
118 #include "ns3/flow-monitor-module.h" | 118 #include "ns3/flow-monitor-module.h" |
119 #include "ns3/config-store-module.h" | 119 #include "ns3/config-store-module.h" |
120 #include "ns3/integer.h" | 120 #include "ns3/integer.h" |
121 #include "ns3/wave-bsm-helper.h" | 121 #include "ns3/wave-bsm-helper.h" |
| 122 // future #include "ns3/topology.h" |
122 | 123 |
123 using namespace ns3; | 124 using namespace ns3; |
124 using namespace dsr; | 125 using namespace dsr; |
125 | 126 |
126 NS_LOG_COMPONENT_DEFINE ("vanet-routing-compare"); | 127 NS_LOG_COMPONENT_DEFINE ("vanet-routing-compare"); |
127 | 128 |
128 /** | 129 /** |
129 * \ingroup wave | 130 * \ingroup wave |
130 * \brief The RoutingStats class manages collects statistics | 131 * \brief The RoutingStats class manages collects statistics |
131 * on routing data (application-data packet and byte counts) | 132 * on routing data (application-data packet and byte counts) |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 std::string m_logFile; | 1263 std::string m_logFile; |
1263 uint32_t m_mobility; | 1264 uint32_t m_mobility; |
1264 uint32_t m_nNodes; | 1265 uint32_t m_nNodes; |
1265 double m_TotalSimTime; | 1266 double m_TotalSimTime; |
1266 std::string m_rate; | 1267 std::string m_rate; |
1267 std::string m_phyModeB; | 1268 std::string m_phyModeB; |
1268 std::string m_trName; | 1269 std::string m_trName; |
1269 int m_nodeSpeed; //in m/s | 1270 int m_nodeSpeed; //in m/s |
1270 int m_nodePause; //in s | 1271 int m_nodePause; //in s |
1271 uint32_t m_wavePacketSize; // bytes | 1272 uint32_t m_wavePacketSize; // bytes |
1272 uint32_t m_numWavePackets; | |
1273 double m_waveInterval; // seconds | 1273 double m_waveInterval; // seconds |
1274 int m_verbose; | 1274 int m_verbose; |
1275 std::ofstream m_os; | 1275 std::ofstream m_os; |
1276 NetDeviceContainer m_adhocTxDevices; | 1276 NetDeviceContainer m_adhocTxDevices; |
1277 Ipv4InterfaceContainer m_adhocTxInterfaces; | 1277 Ipv4InterfaceContainer m_adhocTxInterfaces; |
1278 uint32_t m_scenario; | 1278 uint32_t m_scenario; |
1279 double m_gpsAccuracyNs; | 1279 double m_gpsAccuracyNs; |
1280 int m_routingTables; | 1280 int m_routingTables; |
1281 int m_asciiTrace; | 1281 int m_asciiTrace; |
1282 int m_pcap; | 1282 int m_pcap; |
(...skipping 11 matching lines...) Expand all Loading... |
1294 double m_txSafetyRange2; | 1294 double m_txSafetyRange2; |
1295 double m_txSafetyRange3; | 1295 double m_txSafetyRange3; |
1296 double m_txSafetyRange4; | 1296 double m_txSafetyRange4; |
1297 double m_txSafetyRange5; | 1297 double m_txSafetyRange5; |
1298 double m_txSafetyRange6; | 1298 double m_txSafetyRange6; |
1299 double m_txSafetyRange7; | 1299 double m_txSafetyRange7; |
1300 double m_txSafetyRange8; | 1300 double m_txSafetyRange8; |
1301 double m_txSafetyRange9; | 1301 double m_txSafetyRange9; |
1302 double m_txSafetyRange10; | 1302 double m_txSafetyRange10; |
1303 std::vector <double> m_txSafetyRanges; | 1303 std::vector <double> m_txSafetyRanges; |
| 1304 std::string m_exp; |
1304 }; | 1305 }; |
1305 | 1306 |
1306 VanetRoutingExperiment::VanetRoutingExperiment () | 1307 VanetRoutingExperiment::VanetRoutingExperiment () |
1307 : m_port (9), | 1308 : m_port (9), |
1308 m_CSVfileName ("vanet-routing.output.csv"), | 1309 m_CSVfileName ("vanet-routing.output.csv"), |
1309 m_CSVfileName2 ("vanet-routing.output2.csv"), | 1310 m_CSVfileName2 ("vanet-routing.output2.csv"), |
1310 m_nSinks (10), | 1311 m_nSinks (10), |
1311 m_protocolName ("protocol"), | 1312 m_protocolName ("protocol"), |
1312 m_txp (20), | 1313 m_txp (20), |
1313 m_traceMobility (false), | 1314 m_traceMobility (false), |
(...skipping 10 matching lines...) Expand all Loading... |
1324 m_logFile ("low_ct-unterstrass-1day.filt.5.adj.log"), | 1325 m_logFile ("low_ct-unterstrass-1day.filt.5.adj.log"), |
1325 m_mobility (1), | 1326 m_mobility (1), |
1326 m_nNodes (156), | 1327 m_nNodes (156), |
1327 m_TotalSimTime (300.01), | 1328 m_TotalSimTime (300.01), |
1328 m_rate ("2048bps"), | 1329 m_rate ("2048bps"), |
1329 m_phyModeB ("DsssRate11Mbps"), | 1330 m_phyModeB ("DsssRate11Mbps"), |
1330 m_trName ("vanet-routing-compare"), | 1331 m_trName ("vanet-routing-compare"), |
1331 m_nodeSpeed (20), | 1332 m_nodeSpeed (20), |
1332 m_nodePause (0), | 1333 m_nodePause (0), |
1333 m_wavePacketSize (200), | 1334 m_wavePacketSize (200), |
1334 m_numWavePackets (1), | |
1335 m_waveInterval (0.1), | 1335 m_waveInterval (0.1), |
1336 m_verbose (0), | 1336 m_verbose (0), |
1337 m_scenario (1), | 1337 m_scenario (1), |
1338 m_gpsAccuracyNs (10000), | 1338 m_gpsAccuracyNs (10000), |
1339 m_routingTables (0), | 1339 m_routingTables (0), |
1340 m_asciiTrace (0), | 1340 m_asciiTrace (0), |
1341 m_pcap (0), | 1341 m_pcap (0), |
1342 m_loadConfigFilename ("load-config.txt"), | 1342 m_loadConfigFilename ("load-config.txt"), |
1343 m_saveConfigFilename (""), | 1343 m_saveConfigFilename (""), |
1344 m_log (0), | 1344 m_log (0), |
1345 m_streamIndex (0), | 1345 m_streamIndex (0), |
1346 m_adhocTxNodes (), | 1346 m_adhocTxNodes (), |
1347 m_txSafetyRange1 (50.0), | 1347 m_txSafetyRange1 (50.0), |
1348 m_txSafetyRange2 (100.0), | 1348 m_txSafetyRange2 (100.0), |
1349 m_txSafetyRange3 (150.0), | 1349 m_txSafetyRange3 (150.0), |
1350 m_txSafetyRange4 (200.0), | 1350 m_txSafetyRange4 (200.0), |
1351 m_txSafetyRange5 (250.0), | 1351 m_txSafetyRange5 (250.0), |
1352 m_txSafetyRange6 (300.0), | 1352 m_txSafetyRange6 (300.0), |
1353 m_txSafetyRange7 (350.0), | 1353 m_txSafetyRange7 (350.0), |
1354 m_txSafetyRange8 (400.0), | 1354 m_txSafetyRange8 (400.0), |
1355 m_txSafetyRange9 (450.0), | 1355 m_txSafetyRange9 (450.0), |
1356 m_txSafetyRange10 (500.0), | 1356 m_txSafetyRange10 (500.0), |
1357 m_txSafetyRanges () | 1357 m_txSafetyRanges (), |
| 1358 m_exp ("") |
1358 { | 1359 { |
1359 m_wifiPhyStats = CreateObject<WifiPhyStats> (); | 1360 m_wifiPhyStats = CreateObject<WifiPhyStats> (); |
1360 m_routingHelper = CreateObject<RoutingHelper> (); | 1361 m_routingHelper = CreateObject<RoutingHelper> (); |
1361 | 1362 |
1362 // set to non-zero value to enable | 1363 // set to non-zero value to enable |
1363 // simply uncond logging during simulation run | 1364 // simply uncond logging during simulation run |
1364 m_log = 1; | 1365 m_log = 1; |
1365 } | 1366 } |
1366 | 1367 |
1367 void | 1368 void |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 { | 1701 { |
1701 NS_LOG_INFO ("Run Simulation."); | 1702 NS_LOG_INFO ("Run Simulation."); |
1702 | 1703 |
1703 CheckThroughput (); | 1704 CheckThroughput (); |
1704 | 1705 |
1705 Simulator::Stop (Seconds (m_TotalSimTime)); | 1706 Simulator::Stop (Seconds (m_TotalSimTime)); |
1706 Simulator::Run (); | 1707 Simulator::Run (); |
1707 Simulator::Destroy (); | 1708 Simulator::Destroy (); |
1708 } | 1709 } |
1709 | 1710 |
1710 extern std::vector <int> nodesMoving; | |
1711 | |
1712 // Prints actual position and velocity when a course change event occurs | 1711 // Prints actual position and velocity when a course change event occurs |
1713 void | 1712 void |
1714 VanetRoutingExperiment:: | 1713 VanetRoutingExperiment:: |
1715 CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobili
ty) | 1714 CourseChange (std::ostream *os, std::string foo, Ptr<const MobilityModel> mobili
ty) |
1716 { | 1715 { |
1717 Vector pos = mobility->GetPosition (); // Get position | 1716 Vector pos = mobility->GetPosition (); // Get position |
1718 Vector vel = mobility->GetVelocity (); // Get velocity | 1717 Vector vel = mobility->GetVelocity (); // Get velocity |
1719 | 1718 |
1720 pos.z = 1.5; | 1719 pos.z = 1.5; |
1721 | 1720 |
1722 int nodeId = mobility->GetObject<Node> ()->GetId (); | 1721 int nodeId = mobility->GetObject<Node> ()->GetId (); |
1723 double t = (Simulator::Now ()).GetSeconds (); | 1722 double t = (Simulator::Now ()).GetSeconds (); |
1724 if (t >= 1.0) | 1723 if (t >= 1.0) |
1725 { | 1724 { |
1726 nodesMoving[nodeId] = 1; | 1725 WaveBsmHelper::GetNodesMoving()[nodeId] = 1; |
1727 } | 1726 } |
1728 | 1727 |
1729 //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::No
w () ); | 1728 //NS_LOG_UNCOND ("Changing pos for node=" << nodeId << " at " << Simulator::No
w () ); |
1730 | 1729 |
1731 // Prints position and velocities | 1730 // Prints position and velocities |
1732 *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y | 1731 *os << Simulator::Now () << " POS: x=" << pos.x << ", y=" << pos.y |
1733 << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y | 1732 << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y |
1734 << ", z=" << vel.z << std::endl; | 1733 << ", z=" << vel.z << std::endl; |
1735 } | 1734 } |
1736 | 1735 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 { | 1780 { |
1782 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=" << wave
PDR6_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*/); | 1781 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=" << wave
PDR6_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*/); |
1783 } | 1782 } |
1784 | 1783 |
1785 out << (Simulator::Now ()).GetSeconds () << "," | 1784 out << (Simulator::Now ()).GetSeconds () << "," |
1786 << kbps << "," | 1785 << kbps << "," |
1787 << packetsReceived << "," | 1786 << packetsReceived << "," |
1788 << m_nSinks << "," | 1787 << m_nSinks << "," |
1789 << m_protocolName << "," | 1788 << m_protocolName << "," |
1790 << m_txp << "," | 1789 << m_txp << "," |
| 1790 << wavePktsSent << "," |
1791 << wavePktsReceived << "," | 1791 << wavePktsReceived << "," |
1792 << wavePktsSent << "," | |
1793 << wavePDR << "," | 1792 << wavePDR << "," |
1794 << waveExpectedRxPktCount << "," | 1793 << waveExpectedRxPktCount << "," |
1795 << waveRxPktInRangeCount << "," | 1794 << waveRxPktInRangeCount << "," |
1796 << wavePDR1_2 << "," | 1795 << wavePDR1_2 << "," |
1797 << wavePDR2_2 << "," | 1796 << wavePDR2_2 << "," |
1798 << wavePDR3_2 << "," | 1797 << wavePDR3_2 << "," |
1799 << wavePDR4_2 << "," | 1798 << wavePDR4_2 << "," |
1800 << wavePDR5_2 << "," | 1799 << wavePDR5_2 << "," |
1801 << wavePDR6_2 << "," | 1800 << wavePDR6_2 << "," |
1802 << wavePDR7_2 << "," | 1801 << wavePDR7_2 << "," |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7); | 2014 cmd.AddValue ("txdist7", "Expected BSM tx range, m", txDist7); |
2016 cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8); | 2015 cmd.AddValue ("txdist8", "Expected BSM tx range, m", txDist8); |
2017 cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9); | 2016 cmd.AddValue ("txdist9", "Expected BSM tx range, m", txDist9); |
2018 cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10); | 2017 cmd.AddValue ("txdist10", "Expected BSM tx range, m", txDist10); |
2019 cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs); | 2018 cmd.AddValue ("gpsaccuracy", "GPS time accuracy, in ns", m_gpsAccuracyNs); |
2020 cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routing
Tables); | 2019 cmd.AddValue ("routingTables", "Dump routing tables at t=5 seconds", m_routing
Tables); |
2021 cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace); | 2020 cmd.AddValue ("asciiTrace", "Dump ASCII Trace data", m_asciiTrace); |
2022 cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap); | 2021 cmd.AddValue ("pcap", "Create PCAP files for all nodes", m_pcap); |
2023 cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilen
ame); | 2022 cmd.AddValue ("loadconfig", "Config-store filename to load", m_loadConfigFilen
ame); |
2024 cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilen
ame); | 2023 cmd.AddValue ("saveconfig", "Config-store filename to save", m_saveConfigFilen
ame); |
| 2024 cmd.AddValue ("exp", "Experiment", m_exp); |
2025 cmd.Parse (argc, argv); | 2025 cmd.Parse (argc, argv); |
2026 | 2026 |
2027 m_txSafetyRange1 = txDist1; | 2027 m_txSafetyRange1 = txDist1; |
2028 m_txSafetyRange2 = txDist2; | 2028 m_txSafetyRange2 = txDist2; |
2029 m_txSafetyRange3 = txDist3; | 2029 m_txSafetyRange3 = txDist3; |
2030 m_txSafetyRange4 = txDist4; | 2030 m_txSafetyRange4 = txDist4; |
2031 m_txSafetyRange5 = txDist5; | 2031 m_txSafetyRange5 = txDist5; |
2032 m_txSafetyRange6 = txDist6; | 2032 m_txSafetyRange6 = txDist6; |
2033 m_txSafetyRange7 = txDist7; | 2033 m_txSafetyRange7 = txDist7; |
2034 m_txSafetyRange8 = txDist8; | 2034 m_txSafetyRange8 = txDist8; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 | 2090 |
2091 void | 2091 void |
2092 VanetRoutingExperiment::SetupAdhocMobilityNodes () | 2092 VanetRoutingExperiment::SetupAdhocMobilityNodes () |
2093 { | 2093 { |
2094 if (m_mobility == 1) | 2094 if (m_mobility == 1) |
2095 { | 2095 { |
2096 // Create Ns2MobilityHelper with the specified trace log file as parameter | 2096 // Create Ns2MobilityHelper with the specified trace log file as parameter |
2097 Ns2MobilityHelper ns2 = Ns2MobilityHelper (m_traceFile); | 2097 Ns2MobilityHelper ns2 = Ns2MobilityHelper (m_traceFile); |
2098 ns2.Install (); // configure movements for each node, while reading trace
file | 2098 ns2.Install (); // configure movements for each node, while reading trace
file |
2099 // initially assume all nodes are not moving | 2099 // initially assume all nodes are not moving |
2100 nodesMoving.resize (m_nNodes, 0); | 2100 WaveBsmHelper::GetNodesMoving().resize (m_nNodes, 0); |
2101 } | 2101 } |
2102 else if (m_mobility == 2) | 2102 else if (m_mobility == 2) |
2103 { | 2103 { |
2104 MobilityHelper mobilityAdhoc; | 2104 MobilityHelper mobilityAdhoc; |
2105 | 2105 |
2106 ObjectFactory pos; | 2106 ObjectFactory pos; |
2107 pos.SetTypeId ("ns3::RandomBoxPositionAllocator"); | 2107 pos.SetTypeId ("ns3::RandomBoxPositionAllocator"); |
2108 pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]
")); | 2108 pos.Set ("X", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1500.0]
")); |
2109 pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"
)); | 2109 pos.Set ("Y", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=300.0]"
)); |
2110 // we need antenna height uniform [1.0 .. 2.0] for loss model | 2110 // we need antenna height uniform [1.0 .. 2.0] for loss model |
2111 pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"))
; | 2111 pos.Set ("Z", StringValue ("ns3::UniformRandomVariable[Min=1.0|Max=2.0]"))
; |
2112 | 2112 |
2113 Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<Position
Allocator> (); | 2113 Ptr<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<Position
Allocator> (); |
2114 m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex); | 2114 m_streamIndex += taPositionAlloc->AssignStreams (m_streamIndex); |
2115 | 2115 |
2116 std::stringstream ssSpeed; | 2116 std::stringstream ssSpeed; |
2117 ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]"
; | 2117 ssSpeed << "ns3::UniformRandomVariable[Min=0.0|Max=" << m_nodeSpeed << "]"
; |
2118 std::stringstream ssPause; | 2118 std::stringstream ssPause; |
2119 ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]"; | 2119 ssPause << "ns3::ConstantRandomVariable[Constant=" << m_nodePause << "]"; |
2120 mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel", | 2120 mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel", |
2121 "Speed", StringValue (ssSpeed.str ()), | 2121 "Speed", StringValue (ssSpeed.str ()), |
2122 "Pause", StringValue (ssPause.str ()), | 2122 "Pause", StringValue (ssPause.str ()), |
2123 "PositionAllocator", PointerValue (taPosit
ionAlloc)); | 2123 "PositionAllocator", PointerValue (taPosit
ionAlloc)); |
2124 mobilityAdhoc.SetPositionAllocator (taPositionAlloc); | 2124 mobilityAdhoc.SetPositionAllocator (taPositionAlloc); |
2125 mobilityAdhoc.Install (m_adhocTxNodes); | 2125 mobilityAdhoc.Install (m_adhocTxNodes); |
2126 m_streamIndex += mobilityAdhoc.AssignStreams (m_adhocTxNodes, m_streamInde
x); | 2126 m_streamIndex += mobilityAdhoc.AssignStreams (m_adhocTxNodes, m_streamInde
x); |
2127 | 2127 |
2128 // initially assume all nodes are moving | 2128 // initially assume all nodes are moving |
2129 nodesMoving.resize (m_nNodes, 1); | 2129 WaveBsmHelper::GetNodesMoving().resize (m_nNodes, 1); |
2130 } | 2130 } |
2131 | 2131 |
2132 // Configure callback for logging | 2132 // Configure callback for logging |
2133 Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange", | 2133 Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange", |
2134 MakeBoundCallback (&VanetRoutingExperiment::CourseChange, &m_
os)); | 2134 MakeBoundCallback (&VanetRoutingExperiment::CourseChange, &m_
os)); |
2135 } | 2135 } |
2136 | 2136 |
2137 void | 2137 void |
2138 VanetRoutingExperiment::SetupAdhocDevices () | 2138 VanetRoutingExperiment::SetupAdhocDevices () |
2139 { | 2139 { |
2140 if (m_lossModel == 1) | 2140 if (m_lossModel == 1) |
2141 { | 2141 { |
2142 m_lossModelName = "ns3::FriisPropagationLossModel"; | 2142 m_lossModelName = "ns3::FriisPropagationLossModel"; |
2143 } | 2143 } |
2144 else if (m_lossModel == 2) | 2144 else if (m_lossModel == 2) |
2145 { | 2145 { |
2146 m_lossModelName = "ns3::ItuR1411LosPropagationLossModel"; | 2146 m_lossModelName = "ns3::ItuR1411LosPropagationLossModel"; |
2147 } | 2147 } |
2148 else if (m_lossModel == 3) | 2148 else if (m_lossModel == 3) |
2149 { | 2149 { |
2150 m_lossModelName = "ns3::TwoRayGroundPropagationLossModel"; | 2150 m_lossModelName = "ns3::TwoRayGroundPropagationLossModel"; |
2151 } | 2151 } |
2152 else if (m_lossModel == 4) | 2152 else if (m_lossModel == 4) |
2153 { | 2153 { |
2154 m_lossModelName = "ns3::LogDistancePropagationLossModel"; | 2154 m_lossModelName = "ns3::LogDistancePropagationLossModel"; |
| 2155 } |
| 2156 else |
| 2157 { |
| 2158 // Unsupported propagation loss model. |
| 2159 // Treating as ERROR |
| 2160 NS_LOG_ERROR ("Invalid propagation loss model specified. Values must be [
1-4], where 1=Friis;2=ItuR1411Los;3=TwoRayGround;4=LogDistance"); |
2155 } | 2161 } |
2156 | 2162 |
2157 // frequency | 2163 // frequency |
2158 double freq = 0.0; | 2164 double freq = 0.0; |
2159 if (m_80211mode == 1) | 2165 if (m_80211mode == 1) |
2160 { | 2166 { |
2161 // 802.11p 5.9 GHz | 2167 // 802.11p 5.9 GHz |
2162 freq = 5.9e9; | 2168 freq = 5.9e9; |
2163 } | 2169 } |
2164 else | 2170 else |
2165 { | 2171 { |
2166 // 802.11b 2.4 GHz | 2172 // 802.11b 2.4 GHz |
2167 freq = 2.4e9; | 2173 freq = 2.4e9; |
2168 } | 2174 } |
2169 | 2175 |
2170 // Setup propagation models | 2176 // Setup propagation models |
2171 YansWifiChannelHelper wifiChannel; | 2177 YansWifiChannelHelper wifiChannel; |
2172 wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); | 2178 wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); |
2173 if (m_lossModel == 3) | 2179 if (m_lossModel == 3) |
2174 { | 2180 { |
2175 // two-ray requires antenna height (else defaults to Friss) | 2181 // two-ray requires antenna height (else defaults to Friss) |
2176 wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue
(freq), "HeightAboveZ", DoubleValue(1.5)); | 2182 wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue
(freq), "HeightAboveZ", DoubleValue(1.5)); |
2177 } | 2183 } |
2178 else | 2184 else |
2179 { | 2185 { |
2180 wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue
(freq)); | 2186 wifiChannel.AddPropagationLoss (m_lossModelName, "Frequency", DoubleValue
(freq)); |
2181 } | 2187 } |
2182 | 2188 |
2183 // Propagation loss models are additive. | 2189 // Propagation loss models are additive. |
2184 if (m_fading != 0) | 2190 if (m_fading != 0) |
2185 { | 2191 { |
2186 // use Nakagami fading | 2192 // if no obstacle model, then use Nakagami fading if requested |
2187 wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel"); | 2193 wifiChannel.AddPropagationLoss ("ns3::NakagamiPropagationLossModel"); |
2188 } | 2194 } |
2189 | 2195 |
2190 // The below set of helpers will help us to put together the wifi NICs we want | 2196 // The below set of helpers will help us to put together the wifi NICs we want |
2191 YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); | 2197 YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
2192 wifiPhy.SetChannel (wifiChannel.Create ()); | 2198 wifiPhy.SetChannel (wifiChannel.Create ()); |
2193 // ns-3 supports generate a pcap trace | 2199 // ns-3 supports generate a pcap trace |
2194 wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11); | 2200 wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11); |
2195 | 2201 |
2196 // Setup WAVE PHY and MAC | 2202 // Setup WAVE PHY and MAC |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap"); | 2251 wifiPhy.EnablePcapAll ("vanet-routing-compare-pcap"); |
2246 } | 2252 } |
2247 } | 2253 } |
2248 | 2254 |
2249 void | 2255 void |
2250 VanetRoutingExperiment::SetupWaveMessages () | 2256 VanetRoutingExperiment::SetupWaveMessages () |
2251 { | 2257 { |
2252 m_waveBsmHelper.Install (m_adhocTxNodes, | 2258 m_waveBsmHelper.Install (m_adhocTxNodes, |
2253 m_adhocTxDevices, | 2259 m_adhocTxDevices, |
2254 m_adhocTxInterfaces, | 2260 m_adhocTxInterfaces, |
2255 m_TotalSimTime, | 2261 Seconds(m_TotalSimTime), |
2256 m_wavePacketSize, | 2262 m_wavePacketSize, |
2257 m_waveInterval, | 2263 Seconds(m_waveInterval), |
2258 m_gpsAccuracyNs, | 2264 // convert GPS accuracy, in ns, to Time |
| 2265 Seconds(m_gpsAccuracyNs / 1000000.0), |
2259 m_txSafetyRanges); | 2266 m_txSafetyRanges); |
2260 | 2267 |
2261 // fix random number streams | 2268 // fix random number streams |
2262 m_streamIndex += m_waveBsmHelper.AssignStreams (m_streamIndex);· | 2269 m_streamIndex += m_waveBsmHelper.AssignStreams (m_streamIndex);· |
2263 } | 2270 } |
2264 | 2271 |
2265 void | 2272 void |
2266 VanetRoutingExperiment::SetupRoutingMessages () | 2273 VanetRoutingExperiment::SetupRoutingMessages () |
2267 { | 2274 { |
2268 m_routingHelper->Install (m_adhocTxNodes, | 2275 m_routingHelper->Install (m_adhocTxNodes, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 << std::endl; | 2371 << std::endl; |
2365 out2.close (); | 2372 out2.close (); |
2366 } | 2373 } |
2367 | 2374 |
2368 int | 2375 int |
2369 main (int argc, char *argv[]) | 2376 main (int argc, char *argv[]) |
2370 { | 2377 { |
2371 VanetRoutingExperiment experiment; | 2378 VanetRoutingExperiment experiment; |
2372 experiment.Simulate (argc, argv); | 2379 experiment.Simulate (argc, argv); |
2373 } | 2380 } |
LEFT | RIGHT |