70 #include "ns3/core-module.h"
71 #include "ns3/network-module.h"
72 #include "ns3/internet-module.h"
73 #include "ns3/mobility-module.h"
74 #include "ns3/wifi-module.h"
75 #include "ns3/aodv-module.h"
76 #include "ns3/olsr-module.h"
77 #include "ns3/dsdv-module.h"
78 #include "ns3/dsr-module.h"
79 #include "ns3/applications-module.h"
90 void Run (
int nSinks,
double txp, std::string CSVfileName);
93 std::string CommandSetup (
int argc,
char **argv);
98 void CheckThroughput ();
116 m_CSVfileName (
"manet-routing.output.csv"),
117 m_traceMobility (false),
122 static inline std::string
128 std::ostringstream oss;
135 oss <<
" received one packet from " << addr.
GetIpv4 ();
139 oss <<
" received one packet!";
148 while ((packet = socket->
Recv ()))
180 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
181 Ptr<Socket> sink = Socket::CreateSocket (node, tid);
196 cmd.
Parse (argc, argv);
204 std::string CSVfileName = experiment.
CommandSetup (argc,argv);
207 std::ofstream out (CSVfileName.c_str ());
208 out <<
"SimulationSecond," <<
210 "PacketsReceived," <<
212 "RoutingProtocol," <<
213 "TransmissionPower" <<
220 experiment.
Run (nSinks, txp, CSVfileName);
226 Packet::EnablePrinting ();
233 double TotalTime = 200.0;
234 std::string rate (
"2048bps");
235 std::string phyMode (
"DsssRate11Mbps");
236 std::string tr_name (
"manet-routing-compare");
248 adhocNodes.
Create (nWifis);
269 wifiMac.
SetType (
"ns3::AdhocWifiMac");
273 int64_t streamIndex = 0;
276 pos.
SetTypeId (
"ns3::RandomRectanglePositionAllocator");
277 pos.
Set (
"X",
StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
278 pos.
Set (
"Y",
StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
283 std::stringstream ssSpeed;
284 ssSpeed <<
"ns3::UniformRandomVariable[Min=0.0|Max=" << nodeSpeed <<
"]";
285 std::stringstream ssPause;
286 ssPause <<
"ns3::ConstantRandomVariable[Constant=" << nodePause <<
"]";
292 mobilityAdhoc.
Install (adhocNodes);
293 streamIndex += mobilityAdhoc.
AssignStreams (adhocNodes, streamIndex);
306 list.
Add (olsr, 100);
310 list.
Add (aodv, 100);
314 list.
Add (dsdv, 100);
332 dsrMain.
Install (dsr, adhocNodes);
338 addressAdhoc.
SetBase (
"10.1.1.0",
"255.255.255.0");
340 adhocInterfaces = addressAdhoc.
Assign (adhocDevices);
346 for (
int i = 0; i <= nSinks - 1; i++)
356 temp.Stop (Seconds (TotalTime));
359 std::stringstream ss;
361 std::string
nodes = ss.str ();
363 std::stringstream ss2;
365 std::string sNodeSpeed = ss2.str ();
367 std::stringstream ss3;
369 std::string sNodePause = ss3.str ();
371 std::stringstream ss4;
373 std::string sRate = ss4.str ();
393 Simulator::Stop (Seconds (TotalTime));
398 Simulator::Destroy ();