Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 #include "ns3/core-module.h" | |
2 #include "ns3/network-module.h" | |
3 #include "ns3/applications-module.h" | |
4 #include "ns3/mobility-module.h" | |
5 #include "ns3/wifi-module.h" | |
6 #include "ns3/internet-module.h" | |
7 #include <iostream> | |
8 #include "ns3/epidemic-helper.h" | |
9 using namespace ns3; | |
10 | |
11 /** | |
12 This example creates the scenarios presented the the paper titled 'Epidemic Rout ing | |
13 for Partially-Connected Ad Hoc Networks.'. We have 50 nodes in an area of 1500 m x 300 m. | |
Peter Barnes
2014/03/10 22:36:53
"…Networks.'
We have…"
This will use the first s
mjf.alenazi
2014/05/28 21:57:41
I did not understand
On 2014/03/10 22:36:53, Peter
| |
14 45 nodes are selected to send a message of size 1KB to the other 44 nodes. | |
15 The total messages are 45 * 44 = 1980 messages. The buffer size is 2000 which is infinite | |
16 in these scenarios. The ranges for the transmission are from 10 m to 250 m while | |
17 the default is set to 50 m. | |
18 */ | |
19 | |
20 | |
21 NS_LOG_COMPONENT_DEFINE ("EpidemicBenchmark"); | |
Peter Barnes
2014/03/10 22:36:53
You define a log component, but you never use it.
mjf.alenazi
2014/05/28 21:57:41
Done.
| |
22 int main (int argc, char *argv[]) | |
23 { | |
24 // General parameters | |
25 uint32_t nWifis = 50; | |
26 NodeContainer nodeContainer; | |
27 NetDeviceContainer devices; | |
28 double txpDistance = 50.0; | |
29 double nodeSpeed = 10.0; | |
30 bool appLogging = true; | |
31 | |
32 // Application parameters | |
33 double TotalTime = 200.0; | |
34 double dataStart = 10.0; | |
35 double dataEnd = 14.0; | |
36 uint32_t packetSize = 512; | |
37 | |
38 // Epidemic routing parameters | |
39 uint32_t hopCount = 50; | |
40 uint32_t queueLength = 200; | |
41 Time queueEntryExpireTime = Seconds (1000); | |
42 Time beaconInterval = Seconds (5); | |
43 | |
44 | |
45 CommandLine cmd; | |
Peter Barnes
2014/03/10 22:36:53
Consider adding a usage message: cmd.Usage (…)
mjf.alenazi
2014/05/28 21:57:41
Done.
| |
46 cmd.AddValue ("nWifis", "Number of \"extra\" Wifi nodes/devices", nWifis); | |
47 cmd.AddValue ("appLogging", "Tell echo applications to log if true", appLoggin g); | |
48 cmd.AddValue ("nodeSpeed", "Node speed in RandomWayPoint model, Default:20", n odeSpeed); | |
49 cmd.AddValue ("packetSize", "The packet size", packetSize); | |
50 cmd.AddValue ("txpDistance", "Specify node's transmit range, Default:300", txp Distance); | |
51 cmd.AddValue ("hopCount", "Specify number of hopCount, Default:50", hopCount); | |
52 cmd.AddValue ("queueLength", "Specify queue Length, Default:50", queueLength); | |
53 cmd.AddValue ("queueEntryExpireTime", "Specify queue Entry Expire Time, Defaul t:100", queueEntryExpireTime); | |
54 cmd.AddValue ("beaconInterval", "Specify beaconInterval, Default:20", beaconIn terval); | |
55 | |
56 | |
57 cmd.Parse (argc,argv); | |
58 | |
59 | |
60 | |
61 | |
62 | |
63 /* | |
64 * Enabling OnOffApplication and PacketSink logging | |
65 * */ | |
66 if (appLogging) | |
67 { | |
68 LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO); | |
69 //LogComponentEnable ("EpidemicRoutingProtocol", LOG_LEVEL_INFO); | |
70 LogComponentEnable ("PacketSink", LOG_LEVEL_INFO); | |
71 LogComponentEnableAll (LOG_PREFIX_TIME); | |
72 LogComponentEnableAll (LOG_PREFIX_NODE); | |
73 LogComponentEnableAll (LOG_PREFIX_FUNC); | |
74 } | |
75 | |
76 | |
77 | |
78 LogComponentEnable ("EpidemicBenchmark", LOG_LEVEL_ALL); | |
79 nodeContainer.Create (nWifis); | |
80 | |
81 | |
82 /* | |
83 * Mobility model Setup | |
84 * */ | |
85 MobilityHelper mobility; | |
86 ObjectFactory pos; | |
87 mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator", | |
88 "X", StringValue ("100.0"), | |
89 "Y", StringValue ("100.0"), | |
90 "Rho", StringValue ("ns3::UniformRandomVariable [Min=0|Max=30]")); | |
91 | |
92 mobility.SetMobilityModel ("ns3::SteadyStateRandomWaypointMobilityModel", | |
93 "MinSpeed", DoubleValue (0.01), | |
94 "MaxSpeed", DoubleValue (nodeSpeed), | |
95 "MinX", DoubleValue (0.0), | |
96 "MaxX", DoubleValue (300.0), | |
97 "MinPause", DoubleValue (10), | |
98 "MaxPause", DoubleValue (20), | |
99 "MinY", DoubleValue (0.0), | |
100 "MaxY", DoubleValue (1500.0) | |
101 ); | |
102 mobility.Install (nodeContainer); | |
103 | |
104 | |
105 /* | |
106 * Physical and link Layers Setup | |
107 * */ | |
108 | |
109 NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); | |
110 wifiMac.SetType ("ns3::AdhocWifiMac"); | |
111 YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); | |
112 YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); | |
113 | |
114 wifiChannel.AddPropagationLoss ("ns3::RangePropagationLossModel","MaxRange",Do ubleValue (txpDistance)); | |
115 wifiPhy.SetChannel (wifiChannel.Create ()); | |
116 WifiHelper wifi = WifiHelper::Default (); | |
117 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", Stri ngValue ("OfdmRate6Mbps"), "RtsCtsThreshold", UintegerValue (0)); | |
118 devices = wifi.Install (wifiPhy, wifiMac, nodeContainer); | |
119 | |
120 | |
121 /* | |
122 * Epidemic Routing Setup | |
123 * */ | |
124 EpidemicHelper epidemic; | |
125 epidemic.Set ("HopCount", UintegerValue (hopCount)); | |
126 epidemic.Set ("QueueLength", UintegerValue (queueLength)); | |
127 epidemic.Set ("QueueEntryExpireTime", TimeValue (queueEntryExpireTime)); | |
128 epidemic.Set ("BeaconInterval", TimeValue (beaconInterval)); | |
129 | |
130 /* | |
131 * Internet Stack Setup | |
132 * */ | |
133 Ipv4ListRoutingHelper list; | |
134 InternetStackHelper internet; | |
135 internet.SetRoutingHelper (epidemic); | |
136 internet.Install (nodeContainer); | |
137 Ipv4AddressHelper ipv4; | |
138 ipv4.SetBase ("10.1.1.0", "255.255.255.0"); | |
139 Ipv4InterfaceContainer interfaces = ipv4.Assign (devices); | |
140 | |
141 | |
142 /* | |
143 * Application Setup | |
144 * */ | |
145 | |
146 | |
147 // Sink or server setup | |
148 for (uint32_t i = 0; i < 45; ++i) | |
149 { | |
150 PacketSinkHelper sink ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Add ress::GetAny (), 80)); | |
151 ApplicationContainer apps_sink = sink.Install (nodeContainer.Get (i)); | |
152 apps_sink.Start (Seconds (0.0)); | |
153 apps_sink.Stop (Seconds (TotalTime)); | |
154 } | |
155 | |
156 | |
157 | |
158 // Client setup | |
159 for (uint32_t source = 0; source < 45; ++source) | |
160 { | |
161 for (uint32_t sink = 0; sink < 45; ++sink) | |
162 { | |
163 if (sink != source) | |
164 { | |
165 OnOffHelper onoff1 ("ns3::UdpSocketFactory", Address (InetSocketAd dress (interfaces.GetAddress (sink), 80))); | |
166 onoff1.SetConstantRate (DataRate ("512B/s")); | |
167 onoff1.SetAttribute ("PacketSize",UintegerValue (packetSize)); | |
168 ApplicationContainer apps1 = onoff1.Install (nodeContainer.Get (so urce)); | |
169 apps1.Start (Seconds (dataStart)); | |
170 apps1.Stop (Seconds (dataEnd)); | |
171 } | |
172 | |
173 } | |
174 } | |
175 | |
176 | |
177 | |
178 Simulator::Stop (Seconds (TotalTime)); | |
179 Simulator::Run (); | |
180 Simulator::Destroy (); | |
181 return 0; | |
182 } | |
183 | |
OLD | NEW |