31 #include "ns3/core-module.h"
32 #include "ns3/network-module.h"
33 #include "ns3/applications-module.h"
34 #include "ns3/mobility-module.h"
35 #include "ns3/config-store-module.h"
36 #include "ns3/wifi-module.h"
37 #include "ns3/internet-module.h"
38 #include "ns3/dsdv-helper.h"
52 void CaseRun (uint32_t nWifis,
58 uint32_t periodicUpdateInterval,
59 uint32_t settlingTime,
62 std::string CSVfileName);
85 void CreateDevices (std::string tr_name);
86 void InstallInternetStack (std::string tr_name);
87 void InstallApplications ();
88 void SetupMobility ();
91 void CheckThroughput ();
95 int main (
int argc,
char **argv)
100 double totalTime = 100.0;
101 std::string rate (
"8kbps");
102 std::string phyMode (
"DsssRate11Mbps");
103 uint32_t nodeSpeed = 10;
104 std::string appl =
"all";
105 uint32_t periodicUpdateInterval = 15;
106 uint32_t settlingTime = 6;
107 double dataStart = 50.0;
108 bool printRoutingTable =
true;
109 std::string CSVfileName =
"DsdvManetExample.csv";
112 cmd.
AddValue (
"nWifis",
"Number of wifi nodes[Default:30]", nWifis);
113 cmd.
AddValue (
"nSinks",
"Number of wifi sink nodes[Default:10]", nSinks);
114 cmd.
AddValue (
"totalTime",
"Total Simulation time[Default:100]", totalTime);
115 cmd.
AddValue (
"phyMode",
"Wifi Phy mode[Default:DsssRate11Mbps]", phyMode);
116 cmd.
AddValue (
"rate",
"CBR traffic rate[Default:8kbps]", rate);
117 cmd.
AddValue (
"nodeSpeed",
"Node speed in RandomWayPoint model[Default:10]", nodeSpeed);
118 cmd.
AddValue (
"periodicUpdateInterval",
"Periodic Interval Time[Default=15]", periodicUpdateInterval);
119 cmd.
AddValue (
"settlingTime",
"Settling Time before sending out an update for changed metric[Default=6]", settlingTime);
120 cmd.
AddValue (
"dataStart",
"Time at which nodes start to transmit data[Default=50.0]", dataStart);
121 cmd.
AddValue (
"printRoutingTable",
"print routing table for nodes[Default:1]", printRoutingTable);
122 cmd.
AddValue (
"CSVfileName",
"The name of the CSV output file name[Default:DsdvManetExample.csv]", CSVfileName);
123 cmd.
Parse (argc, argv);
125 std::ofstream out (CSVfileName.c_str ());
126 out <<
"SimulationSecond," <<
128 "PacketsReceived," <<
141 test.
CaseRun (nWifis, nSinks, totalTime, rate, phyMode, nodeSpeed, periodicUpdateInterval,
142 settlingTime, dataStart, printRoutingTable, CSVfileName);
158 while ((packet = socket->
Recv ()))
184 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
195 std::string phyMode, uint32_t nodeSpeed, uint32_t periodicUpdateInterval, uint32_t settlingTime,
196 double dataStart,
bool printRoutes, std::string CSVfileName)
210 std::stringstream ss;
212 std::string t_nodes = ss.str ();
214 std::stringstream ss3;
216 std::string sTotalTime = ss3.str ();
218 std::string tr_name =
"Dsdv_Manet_" + t_nodes +
"Nodes_" + sTotalTime +
"SimTime";
219 std::cout <<
"Trace file generated is " << tr_name <<
".tr\n";
227 std::cout <<
"\nStarting simulation for " << m_totalTime <<
" s ...\n";
231 Simulator::Stop (Seconds (m_totalTime));
233 Simulator::Destroy ();
239 std::cout <<
"Creating " << (unsigned)
m_nWifis <<
" nodes.\n";
249 pos.
SetTypeId (
"ns3::RandomRectanglePositionAllocator");
250 pos.
Set (
"X",
StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1000.0]"));
251 pos.
Set (
"Y",
StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1000.0]"));
253 std::ostringstream speedConstantRandomVariableStream;
254 speedConstantRandomVariableStream <<
"ns3::ConstantRandomVariable[Constant="
260 "Pause",
StringValue (
"ns3::ConstantRandomVariable[Constant=2.0]"),
"PositionAllocator",
PointerValue (taPositionAlloc));
269 wifiMac.
SetType (
"ns3::AdhocWifiMac");
296 address.
SetBase (
"10.1.1.0",
"255.255.255.0");
308 for (uint32_t i = 0; i <=
m_nSinks - 1; i++ )
315 for (uint32_t clientNode = 0; clientNode <=
m_nWifis - 1; clientNode++ )
317 for (uint32_t j = 0; j <=
m_nSinks - 1; j++ )
321 onoff1.SetAttribute (
"OffTime",
StringValue (
"ns3::ConstantRandomVariable[Constant=0.0]"));