Left: | ||
Right: |
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) 2013 Mohammed J.F. Alenazi | 3 * Copyright (c) 2013 Mohammed J.F. Alenazi |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Mohammed J.F. Alenazi <malenazi@ittc.ku.edu> | 18 * Author: Mohammed J.F. Alenazi <malenazi@ittc.ku.edu> |
19 * | 19 * |
20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director | 20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director |
21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets | 21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets |
22 * Information and Telecommunication Technology Center (ITTC) | 22 * Information and Telecommunication Technology Center (ITTC) |
23 * and Department of Electrical Engineering and Computer Science | 23 * and Department of Electrical Engineering and Computer Science |
24 * The University of Kansas Lawrence, KS USA. | 24 * The University of Kansas Lawrence, KS USA. |
25 * | 25 * |
26 * Work supported by King Saud University and the ITTC at The University of Kans as. | 26 * Work supported by King Saud University and |
27 * the ITTC at The University of Kansas. | |
27 */ | 28 */ |
28 | 29 |
29 | 30 |
30 #include "ns3/core-module.h" | 31 #include "ns3/core-module.h" |
31 #include "ns3/network-module.h" | 32 #include "ns3/network-module.h" |
32 #include "ns3/applications-module.h" | 33 #include "ns3/applications-module.h" |
33 #include "ns3/mobility-module.h" | 34 #include "ns3/mobility-module.h" |
34 #include "ns3/wifi-module.h" | 35 #include "ns3/wifi-module.h" |
35 #include "ns3/internet-module.h" | 36 #include "ns3/internet-module.h" |
36 #include <iostream> | 37 #include <iostream> |
37 #include "ns3/epidemic-helper.h" | 38 #include "ns3/epidemic-helper.h" |
39 | |
38 using namespace ns3; | 40 using namespace ns3; |
39 | 41 |
40 /** | 42 /** |
43 \file | |
44 \ingroup epidemic | |
41 This example creates the scenarios presented the paper titled 'Epidemic Routing | 45 This example creates the scenarios presented the paper titled 'Epidemic Routing |
42 for Partially-Connected Ad Hoc Networks.' | 46 for Partially-Connected Ad Hoc Networks.' |
43 | 47 |
44 We have 50 nodes in an area of 1500 m x 300 m. | 48 We have 50 nodes in an area of 1500 m x 300 m. |
45 45 nodes are selected to send a message of size 1KB to the other 44 nodes. | 49 45 nodes are selected to send a message of size 1KB to the other 44 nodes. |
46 The total messages are 45 * 44 = 1980 messages. The buffer size is 2000 which is infinite | 50 The total messages are 45 * 44 = 1980 messages. The buffer size is 2000 which |
47 in these scenarios. The ranges for the transmission are from 10 m to 250 m while | 51 is infinite in these scenarios. The ranges for the transmission are from |
48 the default is set to 50 m. The expected results are shown in the paper. | 52 10 m to 250 m while the default is set to 50 m. The expected results are shown |
49 \todo Compare to Vahdat paper | 53 in the paper Mohammed Alenazi, Yufei Cheng, Dongsheng Zhang, and James Sterbenz, |
54 "Epidemic Routing Protocol Implementation in ns-3", WNS32015. | |
50 */ | 55 */ |
51 | 56 |
52 | 57 |
53 int main (int argc, char *argv[]) | 58 int main (int argc, char *argv[]) |
54 { | 59 { |
55 // General parameters | 60 // General parameters |
56 uint32_t nWifis = 50; | 61 uint32_t nWifis = 50; |
57 NodeContainer nodeContainer; | 62 NodeContainer nodeContainer; |
58 NetDeviceContainer devices; | 63 NetDeviceContainer devices; |
59 double txpDistance = 50.0; | 64 double txpDistance = 50.0; |
60 double nodeSpeed = 10.0; | 65 double nodeSpeed = 10.0; |
61 bool appLogging = true; | 66 bool appLogging = true; |
62 | 67 |
63 // Application parameters | 68 // Application parameters |
64 double TotalTime = 200.0; | 69 double TotalTime = 200.0; |
65 double dataStart = 10.0; | 70 double dataStart = 10.0; |
66 double dataEnd = 14.0; | 71 double dataEnd = 14.0; |
67 uint32_t packetSize = 512; | 72 uint32_t packetSize = 1024; |
68 | 73 |
69 // Epidemic routing parameters | 74 // Epidemic routing parameters |
70 uint32_t hopCount = 50; | 75 uint32_t hopCount = 50; |
71 uint32_t queueLength = 200; | 76 uint32_t queueLength = 200; |
72 Time queueEntryExpireTime = Seconds (1000); | 77 Time queueEntryExpireTime = Seconds (1000); |
73 Time beaconInterval = Seconds (5); | 78 Time beaconInterval = Seconds (5); |
74 | 79 |
75 | 80 |
76 CommandLine cmd; | 81 CommandLine cmd; |
77 cmd.Usage ("Benchmark example shows epidemic routing scenario presented in the original paper." | 82 cmd.Usage ("Benchmark example shows epidemic routing scenario presented " |
Peter Barnes
2014/12/17 00:15:46
paper. "
(Need two spaces after periods. Please
mjf.alenazi
2014/12/19 13:23:59
Done.
| |
78 "There are 50 nodes in an area of 1500 m x 300 m. 45 nodes are sele cted to send a message of size " | 83 "in the original paper. There are 50 nodes in an area of 1500 m x 300 m." |
79 "1KB to the other 44 nodes. The total messages are 45 * 44 = 1980 m essages." | 84 " 45 nodes are selected to send a message of size 1KB to the other " |
80 " The buffer size is 2000 which is infinite in these scenarios. The ranges for " | 85 "44 nodes. The total messages are 45 * 44 = 1980 messages. The buf fer " |
81 "the transmission are from 10 m to 250 m while the default is set t o 50 m.\n"); | 86 "size is 2000 which is infinite in these scenarios. The ranges for " |
87 "the transmission are from 10 m to 250 m while the default is set t o " | |
88 "50 m.\n"); | |
82 cmd.AddValue ("nWifis", "Number of \"extra\" Wifi nodes/devices", nWifis); | 89 cmd.AddValue ("nWifis", "Number of \"extra\" Wifi nodes/devices", nWifis); |
83 cmd.AddValue ("appLogging", "Tell echo applications to log if true", appLoggin g); | 90 cmd.AddValue ("appLogging", "Tell echo applications to log if true", |
91 appLogging); | |
84 cmd.AddValue ("nodeSpeed", "Node speed in RandomWayPoint model", nodeSpeed); | 92 cmd.AddValue ("nodeSpeed", "Node speed in RandomWayPoint model", nodeSpeed); |
85 cmd.AddValue ("packetSize", "The packet size", packetSize); | 93 cmd.AddValue ("packetSize", "The packet size", packetSize); |
86 cmd.AddValue ("txpDistance", "Specify node's transmit range", txpDistance); | 94 cmd.AddValue ("txpDistance", "Specify node's transmit range", txpDistance); |
87 cmd.AddValue ("hopCount", "Specify number of hopCount", hopCount); | 95 cmd.AddValue ("hopCount", "Specify number of hopCount", hopCount); |
88 cmd.AddValue ("queueLength", "Specify queue Length", queueLength); | 96 cmd.AddValue ("queueLength", "Specify queue Length", queueLength); |
89 cmd.AddValue ("queueEntryExpireTime", "Specify queue Entry Expire Time", queue EntryExpireTime); | 97 cmd.AddValue ("queueEntryExpireTime", "Specify queue Entry Expire Time", |
98 queueEntryExpireTime); | |
90 cmd.AddValue ("beaconInterval", "Specify beaconInterval", beaconInterval); | 99 cmd.AddValue ("beaconInterval", "Specify beaconInterval", beaconInterval); |
91 | 100 |
92 cmd.Parse (argc, argv); | 101 cmd.Parse (argc, argv); |
93 | 102 |
94 | 103 |
95 std::cout << "Number of wifi nodes: " << nWifis << std::endl; | 104 std::cout << "Number of wifi nodes: " << nWifis << std::endl; |
96 std::cout << "Node speed: " << nodeSpeed << " m/s" << std::endl; | 105 std::cout << "Node speed: " << nodeSpeed << " m/s" << std::endl; |
97 std::cout << "Packet size: " << packetSize << " b" << std::endl; | 106 std::cout << "Packet size: " << packetSize << " b" << std::endl; |
98 std::cout << "Transmission distance: " << txpDistance << " m" << std::endl; | 107 std::cout << "Transmission distance: " << txpDistance << " m" << std::endl; |
99 std::cout << "Hop count: " << hopCount << std::endl; | 108 std::cout << "Hop count: " << hopCount << std::endl; |
100 std::cout << "Queue length: " << queueLength << " packets" << std::endl; | 109 std::cout << "Queue length: " << queueLength << " packets" << std::endl; |
101 std::cout << "Queue entry expire time: " << queueEntryExpireTime.GetSeconds () << " s" << std::endl; | 110 std::cout << "Queue entry expire time: " << queueEntryExpireTime.GetSeconds |
102 std::cout << "Beacon interval: " << beaconInterval.GetSeconds () << " s" << st d::endl; | 111 () << " s" << std::endl; |
112 std::cout << "Beacon interval: " << beaconInterval.GetSeconds () << " s" << | |
113 std::endl; | |
103 | 114 |
104 | 115 |
105 | 116 |
106 /* | 117 /* |
107 * Enabling OnOffApplication and PacketSink logging | 118 * Enabling OnOffApplication and PacketSink logging |
108 * */ | 119 * */ |
109 if (appLogging) | 120 if (appLogging) |
110 { | 121 { |
111 LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO); | 122 LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO); |
112 LogComponentEnable ("PacketSink", LOG_LEVEL_INFO); | 123 LogComponentEnable ("PacketSink", LOG_LEVEL_INFO); |
113 LogComponentEnableAll (LOG_PREFIX_TIME); | 124 LogComponentEnableAll (LOG_PREFIX_TIME); |
114 LogComponentEnableAll (LOG_PREFIX_NODE); | 125 LogComponentEnableAll (LOG_PREFIX_NODE); |
115 LogComponentEnableAll (LOG_PREFIX_FUNC); | 126 LogComponentEnableAll (LOG_PREFIX_FUNC); |
116 } | 127 } |
117 | 128 |
118 | 129 |
119 | 130 |
120 | 131 |
121 nodeContainer.Create (nWifis); | 132 nodeContainer.Create (nWifis); |
122 | 133 |
123 | 134 |
124 /* | 135 /* |
125 * Mobility model Setup | 136 * Mobility model Setup |
126 * The parameters for mobility model matches the epidemic routing paper. | 137 * The parameters for mobility model matches the epidemic routing paper. |
127 */ | 138 */ |
128 MobilityHelper mobility; | 139 MobilityHelper mobility; |
129 ObjectFactory pos; | 140 ObjectFactory pos; |
130 mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator", | 141 mobility.SetPositionAllocator ("ns3::RandomRectanglePositionAllocator", |
131 "X", StringValue ("300.0"), | 142 "X", StringValue ("ns3::UniformRandomVariable[M in=0.0|Max=300.0]"), |
132 "Y", StringValue ("1500.0"), | 143 "Y", StringValue ("ns3::UniformRandomVariable[M in=0.0|Max=1500.0]")); |
133 "Rho", StringValue ("ns3::UniformRandomVariable [Min=0|Max=30]")); | 144 |
134 | 145 |
135 mobility.SetMobilityModel ("ns3::SteadyStateRandomWaypointMobilityModel", | 146 mobility.SetMobilityModel ("ns3::SteadyStateRandomWaypointMobilityModel", |
136 "MinSpeed", DoubleValue (0.01), | 147 "MinSpeed", DoubleValue (0.01), |
137 "MaxSpeed", DoubleValue (nodeSpeed), | 148 "MaxSpeed", DoubleValue (nodeSpeed), |
138 "MinX", DoubleValue (0.0), | 149 "MinX", DoubleValue (0.0), |
139 "MaxX", DoubleValue (300.0), | 150 "MaxX", DoubleValue (300.0), |
140 "MinPause", DoubleValue (10), | 151 "MinPause", DoubleValue (10), |
141 "MaxPause", DoubleValue (20), | 152 "MaxPause", DoubleValue (20), |
142 "MinY", DoubleValue (0.0), | 153 "MinY", DoubleValue (0.0), |
143 "MaxY", DoubleValue (1500.0) | 154 "MaxY", DoubleValue (1500.0) |
144 ); | 155 ); |
145 mobility.Install (nodeContainer); | 156 mobility.Install (nodeContainer); |
146 | 157 |
147 | 158 |
148 /* | 159 /* |
149 * Physical and link Layers Setup | 160 * Physical and link Layers Setup |
150 */ | 161 */ |
151 | 162 |
152 NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); | 163 NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); |
153 wifiMac.SetType ("ns3::AdhocWifiMac"); | 164 wifiMac.SetType ("ns3::AdhocWifiMac"); |
154 YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); | 165 YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
155 YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); | 166 YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); |
156 | 167 |
157 wifiChannel.AddPropagationLoss ("ns3::RangePropagationLossModel", "MaxRange", DoubleValue (txpDistance)); | 168 wifiChannel.AddPropagationLoss ("ns3::RangePropagationLossModel", |
169 "MaxRange", DoubleValue (txpDistance)); | |
158 wifiPhy.SetChannel (wifiChannel.Create ()); | 170 wifiPhy.SetChannel (wifiChannel.Create ()); |
159 WifiHelper wifi = WifiHelper::Default (); | 171 WifiHelper wifi = WifiHelper::Default (); |
160 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", Stri ngValue ("OfdmRate6Mbps"), "RtsCtsThreshold", UintegerValue (0)); | 172 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
173 "DataMode", StringValue ("OfdmRate6Mbps"), | |
174 "RtsCtsThreshold", UintegerValue (0)); | |
161 devices = wifi.Install (wifiPhy, wifiMac, nodeContainer); | 175 devices = wifi.Install (wifiPhy, wifiMac, nodeContainer); |
162 | 176 |
163 | 177 |
164 /* | 178 /* |
165 * Epidemic Routing Setup | 179 * Epidemic Routing Setup |
166 * */ | 180 * */ |
167 EpidemicHelper epidemic; | 181 EpidemicHelper epidemic; |
168 epidemic.Set ("HopCount", UintegerValue (hopCount)); | 182 epidemic.Set ("HopCount", UintegerValue (hopCount)); |
169 epidemic.Set ("QueueLength", UintegerValue (queueLength)); | 183 epidemic.Set ("QueueLength", UintegerValue (queueLength)); |
170 epidemic.Set ("QueueEntryExpireTime", TimeValue (queueEntryExpireTime)); | 184 epidemic.Set ("QueueEntryExpireTime", TimeValue (queueEntryExpireTime)); |
(...skipping 12 matching lines...) Expand all Loading... | |
183 | 197 |
184 | 198 |
185 /* | 199 /* |
186 * Application Setup | 200 * Application Setup |
187 * */ | 201 * */ |
188 | 202 |
189 | 203 |
190 // Sink or server setup | 204 // Sink or server setup |
191 for (uint32_t i = 0; i < 45; ++i) | 205 for (uint32_t i = 0; i < 45; ++i) |
192 { | 206 { |
193 PacketSinkHelper sink ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Add ress::GetAny (), 80)); | 207 PacketSinkHelper sink ("ns3::UdpSocketFactory", |
208 InetSocketAddress (Ipv4Address::GetAny (), 80)); | |
194 ApplicationContainer apps_sink = sink.Install (nodeContainer.Get (i)); | 209 ApplicationContainer apps_sink = sink.Install (nodeContainer.Get (i)); |
195 apps_sink.Start (Seconds (0.0)); | 210 apps_sink.Start (Seconds (0.0)); |
196 apps_sink.Stop (Seconds (TotalTime)); | 211 apps_sink.Stop (Seconds (TotalTime)); |
197 } | 212 } |
198 | 213 |
199 | 214 |
200 | 215 |
201 // Client setup | 216 // Client setup |
202 for (uint32_t source = 0; source < 45; ++source) | 217 for (uint32_t source = 0; source < 45; ++source) |
203 { | 218 { |
204 for (uint32_t sink = 0; sink < 45; ++sink) | 219 for (uint32_t sink = 0; sink < 45; ++sink) |
205 { | 220 { |
206 if (sink != source) | 221 if (sink != source) |
207 { | 222 { |
208 OnOffHelper onoff1 ("ns3::UdpSocketFactory", Address (InetSocketAd dress (interfaces.GetAddress (sink), 80))); | 223 OnOffHelper onoff1 ("ns3::UdpSocketFactory", |
209 onoff1.SetConstantRate (DataRate ("512B/s")); | 224 Address (InetSocketAddress |
225 (interfaces.GetAddress (sink), 80)) ); | |
226 onoff1.SetConstantRate (DataRate ("1024B/s")); | |
210 onoff1.SetAttribute ("PacketSize", UintegerValue (packetSize)); | 227 onoff1.SetAttribute ("PacketSize", UintegerValue (packetSize)); |
211 ApplicationContainer apps1 = onoff1.Install (nodeContainer.Get (so urce)); | 228 ApplicationContainer apps1 = onoff1.Install ( |
229 nodeContainer.Get (source)); | |
212 apps1.Start (Seconds (dataStart)); | 230 apps1.Start (Seconds (dataStart)); |
213 apps1.Stop (Seconds (dataEnd)); | 231 apps1.Stop (Seconds (dataEnd)); |
214 } | 232 } |
215 | 233 |
216 } | 234 } |
217 } | 235 } |
218 | 236 |
219 | 237 |
220 | 238 |
221 Simulator::Stop (Seconds (TotalTime)); | 239 Simulator::Stop (Seconds (TotalTime)); |
222 Simulator::Run (); | 240 Simulator::Run (); |
223 Simulator::Destroy (); | 241 Simulator::Destroy (); |
224 return 0; | 242 return 0; |
225 } | 243 } |
226 | 244 |
LEFT | RIGHT |