author | Tom Henderson <tomh@tomh.org> |
Fri, 20 Aug 2010 12:17:19 -0700 | |
changeset 6589 | 9c325569fb01 |
parent 6309 | 8d46400b959e |
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" |
|
43 |
#include "ns3/simulator-module.h" |
|
44 |
#include "ns3/node-module.h" |
|
45 |
#include "ns3/helper-module.h" |
|
46 |
#include "ns3/global-routing-module.h" |
|
47 |
#include "ns3/wifi-module.h" |
|
48 |
#include "ns3/mobility-module.h" |
|
49 |
||
50 |
using namespace ns3; |
|
51 |
||
52 |
NS_LOG_COMPONENT_DEFINE ("Test-block-ack"); |
|
53 |
||
54 |
int main (int argc, char const* argv[]) |
|
55 |
{ |
|
56 |
LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG); |
|
57 |
LogComponentEnable ("BlockAckManager", LOG_LEVEL_INFO); |
|
58 |
||
59 |
Ptr<Node> sta = CreateObject<Node> (); |
|
60 |
Ptr<Node> ap = CreateObject<Node> (); |
|
61 |
||
62 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
|
63 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
|
64 |
phy.SetChannel (channel.Create ()); |
|
65 |
||
66 |
WifiHelper wifi = WifiHelper::Default (); |
|
67 |
QosWifiMacHelper mac = QosWifiMacHelper::Default (); |
|
68 |
/* disable fragmentation */ |
|
69 |
wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500)); |
|
70 |
||
71 |
Ssid ssid ("My-network"); |
|
72 |
||
73 |
mac.SetType ("ns3::QstaWifiMac", "Ssid" , SsidValue (ssid), "ActiveProbing", BooleanValue (false)); |
|
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
74 |
/* 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
|
75 |
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
|
76 |
/* 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
|
77 |
//mac.SetBlockAckInactivityTimeoutForAc (AC_BE, 3); |
5966 | 78 |
NetDeviceContainer staDevice = wifi.Install (phy, mac, sta); |
79 |
||
6309 | 80 |
mac.SetType ("ns3::QapWifiMac", "Ssid", SsidValue (ssid)); |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
81 |
mac.SetBlockAckThresholdForAc (AC_BE, 0); |
5966 | 82 |
NetDeviceContainer apDevice = wifi.Install (phy, mac, ap); |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5966
diff
changeset
|
83 |
|
5966 | 84 |
/* Setting mobility model */ |
85 |
MobilityHelper mobility; |
|
86 |
||
87 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
|
88 |
"MinX", DoubleValue (0.0), |
|
89 |
"MinY", DoubleValue (0.0), |
|
90 |
"DeltaX", DoubleValue (5.0), |
|
91 |
"DeltaY", DoubleValue (10.0), |
|
92 |
"GridWidth", UintegerValue (3), |
|
93 |
"LayoutType", StringValue ("RowFirst")); |
|
94 |
||
95 |
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", |
|
96 |
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); |
|
97 |
mobility.Install (sta); |
|
98 |
||
99 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
|
100 |
mobility.Install (ap); |
|
101 |
||
102 |
/* Internet stack*/ |
|
103 |
InternetStackHelper stack; |
|
104 |
stack.Install (sta); |
|
105 |
stack.Install (ap); |
|
106 |
||
107 |
Ipv4AddressHelper address; |
|
108 |
||
109 |
address.SetBase ("192.168.1.0", "255.255.255.0"); |
|
110 |
Ipv4InterfaceContainer staIf; |
|
111 |
Ipv4InterfaceContainer apIf; |
|
112 |
staIf = address.Assign (staDevice); |
|
113 |
apIf = address.Assign (apDevice); |
|
114 |
||
115 |
/* Setting applications */ |
|
116 |
||
117 |
uint16_t port = 9; |
|
118 |
||
119 |
DataRate dataRate ("1Mb/s"); |
|
120 |
OnOffHelper onOff ("ns3::UdpSocketFactory", Address (InetSocketAddress (apIf.GetAddress (0), port))); |
|
121 |
onOff.SetAttribute ("DataRate", DataRateValue (dataRate)); |
|
122 |
onOff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.01))); |
|
123 |
onOff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (8))); |
|
124 |
onOff.SetAttribute ("PacketSize", UintegerValue (50)); |
|
125 |
||
126 |
ApplicationContainer staApps = onOff.Install (sta); |
|
127 |
||
128 |
staApps.Start (Seconds (1.0)); |
|
129 |
staApps.Stop (Seconds (10.0)); |
|
130 |
||
131 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
|
132 |
||
133 |
Simulator::Stop (Seconds (10.0)); |
|
134 |
||
135 |
phy.EnablePcap ("test-blockack-2", ap->GetId (), 0); |
|
136 |
Simulator::Run (); |
|
137 |
Simulator::Destroy (); |
|
138 |
||
139 |
return 0; |
|
140 |
} |