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) 2016 Sébastien Deronne | 3 * Copyright (c) 2016 Sébastien Deronne |
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 28 matching lines...) Expand all Loading... | |
39 // AP A STA A AP B STA B AP C STA C AP D STA D | 39 // AP A STA A AP B STA B AP C STA C AP D STA D |
40 // | 40 // |
41 // The configuration is the following on the 4 networks: | 41 // The configuration is the following on the 4 networks: |
42 // - STA A sends AC_BE traffic to AP A with default AC_BE TXOP value of 0 (1 MSD U); | 42 // - STA A sends AC_BE traffic to AP A with default AC_BE TXOP value of 0 (1 MSD U); |
43 // - STA B sends AC_BE traffic to AP B with non-default AC_BE TXOP of 3.008 ms; | 43 // - STA B sends AC_BE traffic to AP B with non-default AC_BE TXOP of 3.008 ms; |
44 // - STA C sends AC_VI traffic to AP C with default AC_VI TXOP of 3.008 ms; | 44 // - STA C sends AC_VI traffic to AP C with default AC_VI TXOP of 3.008 ms; |
45 // - STA D sends AC_VI traffic to AP D with non-default AC_VI TXOP value of 0 (1 MSDU); | 45 // - STA D sends AC_VI traffic to AP D with non-default AC_VI TXOP value of 0 (1 MSDU); |
46 // | 46 // |
47 // The user can select the distance between the stations and the APs, can enable /disable the RTS/CTS mechanism | 47 // The user can select the distance between the stations and the APs, can enable /disable the RTS/CTS mechanism |
48 // and can choose the payload size and the simulation duration. | 48 // and can choose the payload size and the simulation duration. |
49 // Example: ./waf --run "80211e-txop --distance=10 --enableRts=0 --simulationTim e=20 --payloadSize=1000" | 49 // Example: ./waf --run "80211e-txop --distance=10 --simulationTime=20 --payload Size=1000" |
50 // | 50 // |
51 // The output prints the throughput measured for the 4 cases/networks decribed a bove. When TXOP is enabled, results show | 51 // The output prints the throughput measured for the 4 cases/networks decribed a bove. When TXOP is enabled, results show |
52 // increased throughput since the channel is granted for a longer duration. TXOP is enabled by default for AC_VI and AC_VO, | 52 // increased throughput since the channel is granted for a longer duration. TXOP is enabled by default for AC_VI and AC_VO, |
53 // so that they can use the channel for a longer duration than AC_BE and AC_BK. | 53 // so that they can use the channel for a longer duration than AC_BE and AC_BK. |
54 | 54 |
55 using namespace ns3; | 55 using namespace ns3; |
56 | 56 |
57 NS_LOG_COMPONENT_DEFINE ("80211eTxop"); | 57 NS_LOG_COMPONENT_DEFINE ("80211eTxop"); |
58 | 58 |
59 int main (int argc, char *argv[]) | 59 int main (int argc, char *argv[]) |
60 { | 60 { |
61 uint32_t payloadSize = 1472; //bytes | 61 uint32_t payloadSize = 1472; //bytes |
62 uint64_t simulationTime = 10; //seconds | 62 double simulationTime = 10.0; //seconds |
S. Deronne
2018/03/27 10:36:17
is .0 needed? If yes, then the following argument
| |
63 double distance = 5; //meters | 63 double distance = 5; //meters |
64 bool enablePcap = 0; | 64 bool enablePcap = 0; |
65 bool verifyResults = 0; //used for regression | 65 bool verifyResults = 0; //used for regression |
66 | 66 |
67 CommandLine cmd; | 67 CommandLine cmd; |
68 cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize); | 68 cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize); |
69 cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime); | 69 cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime); |
70 cmd.AddValue ("distance", "Distance in meters between the station and the acce ss point", distance); | 70 cmd.AddValue ("distance", "Distance in meters between the station and the acce ss point", distance); |
71 cmd.AddValue ("enablePcap", "Enable/disable pcap file generation", enablePcap) ; | 71 cmd.AddValue ("enablePcap", "Enable/disable pcap file generation", enablePcap) ; |
72 cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults); | 72 cmd.AddValue ("verifyResults", "Enable/disable results verification at the end of the simulation", verifyResults); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 Ipv4InterfaceContainer StaInterfaceD; | 216 Ipv4InterfaceContainer StaInterfaceD; |
217 StaInterfaceD = address.Assign (staDeviceD); | 217 StaInterfaceD = address.Assign (staDeviceD); |
218 Ipv4InterfaceContainer ApInterfaceD; | 218 Ipv4InterfaceContainer ApInterfaceD; |
219 ApInterfaceD = address.Assign (apDeviceD); | 219 ApInterfaceD = address.Assign (apDeviceD); |
220 | 220 |
221 /* Setting applications */ | 221 /* Setting applications */ |
222 uint16_t port = 5001; | 222 uint16_t port = 5001; |
223 UdpServerHelper serverA (port); | 223 UdpServerHelper serverA (port); |
224 ApplicationContainer serverAppA = serverA.Install (wifiApNodes.Get (0)); | 224 ApplicationContainer serverAppA = serverA.Install (wifiApNodes.Get (0)); |
225 serverAppA.Start (Seconds (0.0)); | 225 serverAppA.Start (Seconds (0.0)); |
226 serverAppA.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 226 serverAppA.Stop (Seconds (simulationTime + 1)); |
Tom Henderson
2018/03/09 16:56:40
This cast can be avoided by changing the type of s
ammo6818-vandals.uidaho.edu
2018/03/11 19:01:18
Changed to eliminate cast
| |
227 | 227 |
228 InetSocketAddress destA (ApInterfaceA.GetAddress (0), port); | 228 InetSocketAddress destA (ApInterfaceA.GetAddress (0), port); |
229 destA.SetTos (0x70); //AC_BE | 229 destA.SetTos (0x70); //AC_BE |
230 | 230 |
231 OnOffHelper clientA ("ns3::UdpSocketFactory", destA); | 231 OnOffHelper clientA ("ns3::UdpSocketFactory", destA); |
232 clientA.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); | 232 clientA.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); |
233 clientA.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); | 233 clientA.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); |
234 clientA.SetAttribute ("DataRate", StringValue ("100000kb/s")); | 234 clientA.SetAttribute ("DataRate", StringValue ("100000kb/s")); |
235 clientA.SetAttribute ("PacketSize", UintegerValue (payloadSize)); | 235 clientA.SetAttribute ("PacketSize", UintegerValue (payloadSize)); |
236 | 236 |
237 ApplicationContainer clientAppA = clientA.Install (wifiStaNodes.Get (0)); | 237 ApplicationContainer clientAppA = clientA.Install (wifiStaNodes.Get (0)); |
238 clientAppA.Start (Seconds (1.0)); | 238 clientAppA.Start (Seconds (1.0)); |
239 clientAppA.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 239 clientAppA.Stop (Seconds (simulationTime + 1)); |
240 | 240 |
241 UdpServerHelper serverB (port); | 241 UdpServerHelper serverB (port); |
242 ApplicationContainer serverAppB = serverB.Install (wifiApNodes.Get (1)); | 242 ApplicationContainer serverAppB = serverB.Install (wifiApNodes.Get (1)); |
243 serverAppB.Start (Seconds (0.0)); | 243 serverAppB.Start (Seconds (0.0)); |
244 serverAppB.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 244 serverAppB.Stop (Seconds (simulationTime + 1)); |
245 | 245 |
246 InetSocketAddress destB (ApInterfaceB.GetAddress (0), port); | 246 InetSocketAddress destB (ApInterfaceB.GetAddress (0), port); |
247 destB.SetTos (0x70); //AC_BE | 247 destB.SetTos (0x70); //AC_BE |
248 | 248 |
249 OnOffHelper clientB ("ns3::UdpSocketFactory", destB); | 249 OnOffHelper clientB ("ns3::UdpSocketFactory", destB); |
250 clientB.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); | 250 clientB.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); |
251 clientB.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); | 251 clientB.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); |
252 clientB.SetAttribute ("DataRate", StringValue ("100000kb/s")); | 252 clientB.SetAttribute ("DataRate", StringValue ("100000kb/s")); |
253 clientB.SetAttribute ("PacketSize", UintegerValue (payloadSize)); | 253 clientB.SetAttribute ("PacketSize", UintegerValue (payloadSize)); |
254 | 254 |
255 ApplicationContainer clientAppB = clientB.Install (wifiStaNodes.Get (1)); | 255 ApplicationContainer clientAppB = clientB.Install (wifiStaNodes.Get (1)); |
256 clientAppB.Start (Seconds (1.0)); | 256 clientAppB.Start (Seconds (1.0)); |
257 clientAppB.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 257 clientAppB.Stop (Seconds (simulationTime + 1)); |
258 | 258 |
259 UdpServerHelper serverC (port); | 259 UdpServerHelper serverC (port); |
260 ApplicationContainer serverAppC = serverC.Install (wifiApNodes.Get (2)); | 260 ApplicationContainer serverAppC = serverC.Install (wifiApNodes.Get (2)); |
261 serverAppC.Start (Seconds (0.0)); | 261 serverAppC.Start (Seconds (0.0)); |
262 serverAppC.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 262 serverAppC.Stop (Seconds (simulationTime + 1)); |
263 | 263 |
264 InetSocketAddress destC (ApInterfaceC.GetAddress (0), port); | 264 InetSocketAddress destC (ApInterfaceC.GetAddress (0), port); |
265 destC.SetTos (0xb8); //AC_VI | 265 destC.SetTos (0xb8); //AC_VI |
266 | 266 |
267 OnOffHelper clientC ("ns3::UdpSocketFactory", destC); | 267 OnOffHelper clientC ("ns3::UdpSocketFactory", destC); |
268 clientC.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); | 268 clientC.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); |
269 clientC.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); | 269 clientC.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); |
270 clientC.SetAttribute ("DataRate", StringValue ("100000kb/s")); | 270 clientC.SetAttribute ("DataRate", StringValue ("100000kb/s")); |
271 clientC.SetAttribute ("PacketSize", UintegerValue (payloadSize)); | 271 clientC.SetAttribute ("PacketSize", UintegerValue (payloadSize)); |
272 | 272 |
273 ApplicationContainer clientAppC = clientC.Install (wifiStaNodes.Get (2)); | 273 ApplicationContainer clientAppC = clientC.Install (wifiStaNodes.Get (2)); |
274 clientAppC.Start (Seconds (1.0)); | 274 clientAppC.Start (Seconds (1.0)); |
275 clientAppC.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 275 clientAppC.Stop (Seconds (simulationTime + 1)); |
276 | 276 |
277 UdpServerHelper serverD (port); | 277 UdpServerHelper serverD (port); |
278 ApplicationContainer serverAppD = serverD.Install (wifiApNodes.Get (3)); | 278 ApplicationContainer serverAppD = serverD.Install (wifiApNodes.Get (3)); |
279 serverAppD.Start (Seconds (0.0)); | 279 serverAppD.Start (Seconds (0.0)); |
280 serverAppD.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 280 serverAppD.Stop (Seconds (simulationTime + 1)); |
281 | 281 |
282 InetSocketAddress destD (ApInterfaceD.GetAddress (0), port); | 282 InetSocketAddress destD (ApInterfaceD.GetAddress (0), port); |
283 destD.SetTos (0xb8); //AC_VI | 283 destD.SetTos (0xb8); //AC_VI |
284 | 284 |
285 OnOffHelper clientD ("ns3::UdpSocketFactory", destD); | 285 OnOffHelper clientD ("ns3::UdpSocketFactory", destD); |
286 clientD.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); | 286 clientD.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Cons tant=1]")); |
287 clientD.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); | 287 clientD.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Con stant=0]")); |
288 clientD.SetAttribute ("DataRate", StringValue ("100000kb/s")); | 288 clientD.SetAttribute ("DataRate", StringValue ("100000kb/s")); |
289 clientD.SetAttribute ("PacketSize", UintegerValue (payloadSize)); | 289 clientD.SetAttribute ("PacketSize", UintegerValue (payloadSize)); |
290 | 290 |
291 ApplicationContainer clientAppD = clientD.Install (wifiStaNodes.Get (3)); | 291 ApplicationContainer clientAppD = clientD.Install (wifiStaNodes.Get (3)); |
292 clientAppD.Start (Seconds (1.0)); | 292 clientAppD.Start (Seconds (1.0)); |
293 clientAppD.Stop (Seconds (static_cast<double> (simulationTime + 1))); | 293 clientAppD.Stop (Seconds (simulationTime + 1)); |
294 | 294 |
295 if (enablePcap) | 295 if (enablePcap) |
296 { | 296 { |
297 phy.EnablePcap ("AP_A", apDeviceA.Get (0)); | 297 phy.EnablePcap ("AP_A", apDeviceA.Get (0)); |
298 phy.EnablePcap ("STA_A", staDeviceA.Get (0)); | 298 phy.EnablePcap ("STA_A", staDeviceA.Get (0)); |
299 phy.EnablePcap ("AP_B", apDeviceB.Get (0)); | 299 phy.EnablePcap ("AP_B", apDeviceB.Get (0)); |
300 phy.EnablePcap ("STA_B", staDeviceB.Get (0)); | 300 phy.EnablePcap ("STA_B", staDeviceB.Get (0)); |
301 phy.EnablePcap ("AP_C", apDeviceC.Get (0)); | 301 phy.EnablePcap ("AP_C", apDeviceC.Get (0)); |
302 phy.EnablePcap ("STA_C", staDeviceC.Get (0)); | 302 phy.EnablePcap ("STA_C", staDeviceC.Get (0)); |
303 phy.EnablePcap ("AP_D", apDeviceD.Get (0)); | 303 phy.EnablePcap ("AP_D", apDeviceD.Get (0)); |
304 phy.EnablePcap ("STA_D", staDeviceD.Get (0)); | 304 phy.EnablePcap ("STA_D", staDeviceD.Get (0)); |
305 } | 305 } |
306 | 306 |
307 Simulator::Stop (Seconds (static_cast<double> (simulationTime + 1))); | 307 Simulator::Stop (Seconds (simulationTime + 1)); |
308 Simulator::Run (); | 308 Simulator::Run (); |
309 Simulator::Destroy (); | 309 Simulator::Destroy (); |
310 | 310 |
311 /* Show results */ | 311 /* Show results */ |
312 uint32_t totalPacketsThrough = static_cast<uint32_t> (DynamicCast<UdpServer> ( serverAppA.Get (0))->GetReceived ()); | 312 uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverAppA.Get (0))->Ge tReceived (); |
Tom Henderson
2018/03/09 16:56:40
This type can be avoided by changing the type of t
ammo6818-vandals.uidaho.edu
2018/03/11 19:01:18
Changed to eliminate cast
| |
313 double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); | 313 double throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0); |
314 std::cout << "Throughput for AC_BE with default TXOP limit (0ms): " << through put << " Mbit/s" << '\n'; | 314 std::cout << "Throughput for AC_BE with default TXOP limit (0ms): " << through put << " Mbit/s" << '\n'; |
315 if (verifyResults && (throughput < 28 || throughput > 29)) | 315 if (verifyResults && (throughput < 28 || throughput > 29)) |
316 { | 316 { |
317 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); | 317 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); |
318 exit (1); | 318 exit (1); |
319 } | 319 } |
320 | 320 |
321 totalPacketsThrough = (uint32_t)DynamicCast<UdpServer> (serverAppB.Get (0))->G etReceived (); | 321 totalPacketsThrough = DynamicCast<UdpServer> (serverAppB.Get (0))->GetReceived (); |
322 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000 .0); | 322 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000 .0); |
323 std::cout << "Throughput for AC_BE with non-default TXOP limit (3.008ms): " << throughput << " Mbit/s" << '\n'; | 323 std::cout << "Throughput for AC_BE with non-default TXOP limit (3.008ms): " << throughput << " Mbit/s" << '\n'; |
324 if (verifyResults && (throughput < 35.5 || throughput > 36.5)) | 324 if (verifyResults && (throughput < 35.5 || throughput > 36.5)) |
325 { | 325 { |
326 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); | 326 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); |
327 exit (1); | 327 exit (1); |
328 } | 328 } |
329 | 329 |
330 totalPacketsThrough = static_cast<uint32_t> (DynamicCast<UdpServer> (serverApp C.Get (0))->GetReceived ()); | 330 totalPacketsThrough = DynamicCast<UdpServer> (serverAppC.Get (0))->GetReceived (); |
331 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000 .0); | 331 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000 .0); |
332 std::cout << "Throughput for AC_VI with default TXOP limit (3.008ms): " << thr oughput << " Mbit/s" << '\n'; | 332 std::cout << "Throughput for AC_VI with default TXOP limit (3.008ms): " << thr oughput << " Mbit/s" << '\n'; |
333 if (verifyResults && (throughput < 36 || throughput > 37)) | 333 if (verifyResults && (throughput < 36 || throughput > 37)) |
334 { | 334 { |
335 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); | 335 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); |
336 exit (1); | 336 exit (1); |
337 } | 337 } |
338 | 338 |
339 totalPacketsThrough = static_cast<uint32_t> (DynamicCast<UdpServer> (serverApp D.Get (0))->GetReceived ()); | 339 totalPacketsThrough = DynamicCast<UdpServer> (serverAppD.Get (0))->GetReceived (); |
340 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000 .0); | 340 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000 .0); |
341 std::cout << "Throughput for AC_VI with non-default TXOP limit (0ms): " << thr oughput << " Mbit/s" << '\n'; | 341 std::cout << "Throughput for AC_VI with non-default TXOP limit (0ms): " << thr oughput << " Mbit/s" << '\n'; |
342 if (verifyResults && (throughput < 31.5 || throughput > 32.5)) | 342 if (verifyResults && (throughput < 31.5 || throughput > 32.5)) |
343 { | 343 { |
344 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); | 344 NS_LOG_ERROR ("Obtained throughput " << throughput << " is not in the expe cted boundaries!"); |
345 exit (1); | 345 exit (1); |
346 } | 346 } |
347 | 347 |
348 return 0; | 348 return 0; |
349 } | 349 } |
LEFT | RIGHT |