author | Tom Henderson <tomh@tomh.org> |
Thu, 01 Oct 2015 11:07:22 -0700 | |
changeset 11677 | 1e2add816314 |
parent 8997 | 9222fc5291ca |
permissions | -rw-r--r-- |
5966 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2009 MIRKO BANCHI |
|
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: Mirko Banchi <mk.banchi@gmail.com> |
|
19 |
*/ |
|
20 |
||
21 |
/** |
|
22 |
* This is a simple example in order to show how 802.11n compressed block ack mechanism could be used. |
|
23 |
* |
|
24 |
* Network topology: |
|
25 |
* |
|
26 |
* Wifi 192.168.1.0 |
|
27 |
* |
|
28 |
* AP |
|
29 |
* * * |
|
30 |
* | | |
|
31 |
* n1 n2 |
|
32 |
* |
|
33 |
* In this example a QoS sta sends UDP datagram packets to access point. On the access point |
|
34 |
* there is no application installed so it replies to every packet with an ICMP frame. However |
|
35 |
* our attention is on originator sta n1. We have set blockAckThreshold (mininum number of packets to use |
|
36 |
* block ack) to 2 so if there are in the BestEffort queue more than 2 packets a block ack will be |
|
37 |
* negotiated. We also set a timeout for block ack inactivity to 3 blocks of 1024 microseconds. This timer is |
|
38 |
* reset when: |
|
39 |
* - the originator receives a block ack frame. |
|
40 |
* - the recipient receives a block ack request or a MPDU with ack policy Block Ack. |
|
41 |
*/ |
|
42 |
#include "ns3/core-module.h" |
|
6834
036f9a0b9899
Rename internet-stack to internet, and organize module
Tom Henderson <tomh@tomh.org>
parents:
6823
diff
changeset
|
43 |
#include "ns3/internet-module.h" |
6823
a27f86fb4e55
Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents:
6821
diff
changeset
|
44 |
#include "ns3/network-module.h" |
6847
138f00c56381
Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents:
6834
diff
changeset
|
45 |
#include "ns3/applications-module.h" |
5966 | 46 |
#include "ns3/wifi-module.h" |
47 |
#include "ns3/mobility-module.h" |
|
48 |
||
49 |
using namespace ns3; |
|
50 |
||
51 |
NS_LOG_COMPONENT_DEFINE ("Test-block-ack"); |
|
52 |
||
53 |
int main (int argc, char const* argv[]) |
|
54 |
{ |
|
55 |
LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG); |
|
56 |
LogComponentEnable ("BlockAckManager", LOG_LEVEL_INFO); |
|
57 |
||
58 |
Ptr<Node> sta = CreateObject<Node> (); |
|
59 |
Ptr<Node> ap = CreateObject<Node> (); |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
60 |
|
5966 | 61 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
62 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
|
63 |
phy.SetChannel (channel.Create ()); |
|
64 |
||
65 |
WifiHelper wifi = WifiHelper::Default (); |
|
66 |
QosWifiMacHelper mac = QosWifiMacHelper::Default (); |
|
67 |
/* disable fragmentation */ |
|
68 |
wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500)); |
|
69 |
||
70 |
Ssid ssid ("My-network"); |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
71 |
|
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6309
diff
changeset
|
72 |
mac.SetType ("ns3::StaWifiMac", |
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
73 |
"Ssid", SsidValue (ssid), |
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6309
diff
changeset
|
74 |
"ActiveProbing", BooleanValue (false)); |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
75 |
/* setting blockack threshold for sta's BE queue */ |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
76 |
mac.SetBlockAckThresholdForAc (AC_BE, 2); |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
77 |
/* setting block inactivity timeout to 3*1024 = 3072 microseconds */ |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
78 |
//mac.SetBlockAckInactivityTimeoutForAc (AC_BE, 3); |
5966 | 79 |
NetDeviceContainer staDevice = wifi.Install (phy, mac, sta); |
80 |
||
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6309
diff
changeset
|
81 |
mac.SetType ("ns3::ApWifiMac", |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6309
diff
changeset
|
82 |
"Ssid", SsidValue (ssid)); |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
83 |
mac.SetBlockAckThresholdForAc (AC_BE, 0); |
5966 | 84 |
NetDeviceContainer apDevice = wifi.Install (phy, mac, ap); |
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
85 |
|
5966 | 86 |
/* Setting mobility model */ |
87 |
MobilityHelper mobility; |
|
88 |
||
89 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
90 |
"MinX", DoubleValue (0.0), |
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
91 |
"MinY", DoubleValue (0.0), |
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
92 |
"DeltaX", DoubleValue (5.0), |
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
93 |
"DeltaY", DoubleValue (10.0), |
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
94 |
"GridWidth", UintegerValue (3), |
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
95 |
"LayoutType", StringValue ("RowFirst")); |
5966 | 96 |
|
97 |
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
98 |
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); |
5966 | 99 |
mobility.Install (sta); |
100 |
||
101 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
|
102 |
mobility.Install (ap); |
|
103 |
||
104 |
/* Internet stack*/ |
|
105 |
InternetStackHelper stack; |
|
106 |
stack.Install (sta); |
|
107 |
stack.Install (ap); |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
108 |
|
5966 | 109 |
Ipv4AddressHelper address; |
110 |
||
111 |
address.SetBase ("192.168.1.0", "255.255.255.0"); |
|
112 |
Ipv4InterfaceContainer staIf; |
|
113 |
Ipv4InterfaceContainer apIf; |
|
114 |
staIf = address.Assign (staDevice); |
|
115 |
apIf = address.Assign (apDevice); |
|
116 |
||
117 |
/* Setting applications */ |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
118 |
|
5966 | 119 |
uint16_t port = 9; |
120 |
||
121 |
DataRate dataRate ("1Mb/s"); |
|
122 |
OnOffHelper onOff ("ns3::UdpSocketFactory", Address (InetSocketAddress (apIf.GetAddress (0), port))); |
|
123 |
onOff.SetAttribute ("DataRate", DataRateValue (dataRate)); |
|
8997
9222fc5291ca
Replace more instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
6865
diff
changeset
|
124 |
onOff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.01]")); |
9222fc5291ca
Replace more instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
6865
diff
changeset
|
125 |
onOff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=8]")); |
5966 | 126 |
onOff.SetAttribute ("PacketSize", UintegerValue (50)); |
127 |
||
128 |
ApplicationContainer staApps = onOff.Install (sta); |
|
129 |
||
130 |
staApps.Start (Seconds (1.0)); |
|
131 |
staApps.Stop (Seconds (10.0)); |
|
132 |
||
133 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
|
134 |
||
135 |
Simulator::Stop (Seconds (10.0)); |
|
136 |
||
137 |
phy.EnablePcap ("test-blockack-2", ap->GetId (), 0); |
|
138 |
Simulator::Run (); |
|
139 |
Simulator::Destroy (); |
|
140 |
||
141 |
return 0; |
|
142 |
} |