A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-blockack.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 MIRKO BANCHI
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mirko Banchi <mk.banchi@gmail.com>
18 */
19
20/**
21 * This is a simple example in order to show how 802.11n compressed block ack mechanism could be
22 * 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 (minimum number of packets
36 * to use block ack) to 2 so if there are in the BestEffort queue more than 2 packets a block ack
37 * will be negotiated. We also set a timeout for block ack inactivity to 3 blocks of 1024
38 * microseconds. This timer is 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
43#include "ns3/boolean.h"
44#include "ns3/command-line.h"
45#include "ns3/double.h"
46#include "ns3/internet-stack-helper.h"
47#include "ns3/ipv4-address-helper.h"
48#include "ns3/ipv4-global-routing-helper.h"
49#include "ns3/log.h"
50#include "ns3/mobility-helper.h"
51#include "ns3/mobility-model.h"
52#include "ns3/on-off-helper.h"
53#include "ns3/rectangle.h"
54#include "ns3/ssid.h"
55#include "ns3/string.h"
56#include "ns3/uinteger.h"
57#include "ns3/yans-wifi-channel.h"
58#include "ns3/yans-wifi-helper.h"
59
60using namespace ns3;
61
62NS_LOG_COMPONENT_DEFINE("Test-block-ack");
63
64int
65main(int argc, char* argv[])
66{
67 CommandLine cmd(__FILE__);
68 cmd.Parse(argc, argv);
69
71 LogComponentEnable("BlockAckManager", LOG_LEVEL_INFO);
72
73 Ptr<Node> sta = CreateObject<Node>();
74 Ptr<Node> ap = CreateObject<Node>();
75
78 phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
79 phy.SetChannel(channel.Create());
80
82 wifi.SetStandard(WIFI_STANDARD_80211n);
84 /* disable fragmentation */
85 wifi.SetRemoteStationManager("ns3::IdealWifiManager",
86 "FragmentationThreshold",
87 UintegerValue(2500));
88
89 Ssid ssid("My-network");
90
91 mac.SetType("ns3::StaWifiMac",
92 "QosSupported",
93 BooleanValue(true),
94 "Ssid",
95 SsidValue(ssid),
96 /* setting blockack threshold for sta's BE queue */
97 "BE_BlockAckThreshold",
99 /* setting block inactivity timeout to 3*1024 = 3072 microseconds */
100 "BE_BlockAckInactivityTimeout",
101 UintegerValue(3));
102 NetDeviceContainer staDevice = wifi.Install(phy, mac, sta);
103
104 mac.SetType("ns3::ApWifiMac",
105 "QosSupported",
106 BooleanValue(true),
107 "Ssid",
108 SsidValue(ssid),
109 "BE_BlockAckThreshold",
110 UintegerValue(0));
111 NetDeviceContainer apDevice = wifi.Install(phy, mac, ap);
112
113 /* Setting mobility model */
115
116 mobility.SetPositionAllocator("ns3::GridPositionAllocator",
117 "MinX",
118 DoubleValue(0.0),
119 "MinY",
120 DoubleValue(0.0),
121 "DeltaX",
122 DoubleValue(5.0),
123 "DeltaY",
124 DoubleValue(10.0),
125 "GridWidth",
126 UintegerValue(3),
127 "LayoutType",
128 StringValue("RowFirst"));
129
130 mobility.SetMobilityModel("ns3::RandomWalk2dMobilityModel",
131 "Bounds",
132 RectangleValue(Rectangle(-50, 50, -50, 50)));
133 mobility.Install(sta);
134
135 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
136 mobility.Install(ap);
137
138 /* Internet stack*/
140 stack.Install(sta);
141 stack.Install(ap);
142
144
145 address.SetBase("192.168.1.0", "255.255.255.0");
148 staIf = address.Assign(staDevice);
149 apIf = address.Assign(apDevice);
150
151 /* Setting applications */
152
153 uint16_t port = 9;
154 DataRate dataRate("1Mb/s");
155 OnOffHelper onOff("ns3::UdpSocketFactory",
157 onOff.SetAttribute("DataRate", DataRateValue(dataRate));
158 onOff.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=0.01]"));
159 onOff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=8]"));
160 onOff.SetAttribute("PacketSize", UintegerValue(50));
161
162 ApplicationContainer staApps = onOff.Install(sta);
163
164 staApps.Start(Seconds(1.0));
165 staApps.Stop(Seconds(10.0));
166
168
170
171 phy.EnablePcap("test-blockack", ap->GetId(), 0);
174
175 return 0;
176}
a polymophic address class
Definition: address.h:101
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
Parse command-line arguments.
Definition: command-line.h:232
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
Definition: data-rate.h:296
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a 2d rectangle
Definition: rectangle.h:35
AttributeValue implementation for Rectangle.
Definition: rectangle.h:125
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
AttributeValue implementation for Ssid.
Definition: ssid.h:96
Hold variables of type string.
Definition: string.h:56
Hold an unsigned integer type.
Definition: uinteger.h:45
helps to create WifiNetDevice objects
Definition: wifi-helper.h:324
create MAC layers for a ns3::WifiNetDevice.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
Definition: wifi-helper.h:178
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
uint16_t port
Definition: dsdv-manet.cc:44
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
@ WIFI_STANDARD_80211n
ns address
Definition: first.py:47
ns stack
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition: log.h:113
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition: log.h:104
ns cmd
Definition: second.py:40
ns wifi
Definition: third.py:95
ns ssid
Definition: third.py:93
ns mac
Definition: third.py:92
ns channel
Definition: third.py:88
ns mobility
Definition: third.py:105
ns phy
Definition: third.py:89