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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mirko Banchi <mk.banchi@gmail.com>
7 */
8
9/**
10 * This is a simple example in order to show how 802.11n compressed block ack mechanism could be
11 * used.
12 *
13 * Network topology:
14 *
15 * Wifi 192.168.1.0
16 *
17 * AP
18 * * *
19 * | |
20 * n1 n2
21 *
22 * In this example a QoS sta sends UDP datagram packets to access point. On the access point
23 * there is no application installed so it replies to every packet with an ICMP frame. However
24 * our attention is on originator sta n1. We have set blockAckThreshold (minimum number of packets
25 * to use block ack) to 2 so if there are in the BestEffort queue more than 2 packets a block ack
26 * will be negotiated. We also set a timeout for block ack inactivity to 3 blocks of 1024
27 * microseconds. This timer is reset when:
28 * - the originator receives a block ack frame.
29 * - the recipient receives a block ack request or a MPDU with ack policy Block Ack.
30 */
31
32#include "ns3/boolean.h"
33#include "ns3/command-line.h"
34#include "ns3/double.h"
35#include "ns3/internet-stack-helper.h"
36#include "ns3/ipv4-address-helper.h"
37#include "ns3/ipv4-global-routing-helper.h"
38#include "ns3/log.h"
39#include "ns3/mobility-helper.h"
40#include "ns3/mobility-model.h"
41#include "ns3/on-off-helper.h"
42#include "ns3/rectangle.h"
43#include "ns3/ssid.h"
44#include "ns3/string.h"
45#include "ns3/uinteger.h"
46#include "ns3/yans-wifi-channel.h"
47#include "ns3/yans-wifi-helper.h"
48
49using namespace ns3;
50
51NS_LOG_COMPONENT_DEFINE("Test-block-ack");
52
53int
54main(int argc, char* argv[])
55{
56 CommandLine cmd(__FILE__);
57 cmd.Parse(argc, argv);
58
60 LogComponentEnable("BlockAckManager", LOG_LEVEL_INFO);
61
64
67 phy.SetPcapDataLinkType(WifiPhyHelper::DLT_IEEE802_11_RADIO);
68 phy.SetChannel(channel.Create());
69
71 wifi.SetStandard(WIFI_STANDARD_80211n);
73 /* disable fragmentation */
74 wifi.SetRemoteStationManager("ns3::IdealWifiManager",
75 "FragmentationThreshold",
76 UintegerValue(2500));
77
78 Ssid ssid("My-network");
79
80 mac.SetType("ns3::StaWifiMac",
81 "QosSupported",
82 BooleanValue(true),
83 "Ssid",
84 SsidValue(ssid),
85 /* setting blockack threshold for sta's BE queue */
86 "BE_BlockAckThreshold",
88 /* setting block inactivity timeout to 3*1024 = 3072 microseconds */
89 "BE_BlockAckInactivityTimeout",
90 UintegerValue(3));
91 NetDeviceContainer staDevice = wifi.Install(phy, mac, sta);
92
93 mac.SetType("ns3::ApWifiMac",
94 "QosSupported",
95 BooleanValue(true),
96 "Ssid",
97 SsidValue(ssid),
98 "BE_BlockAckThreshold",
99 UintegerValue(0));
100 NetDeviceContainer apDevice = wifi.Install(phy, mac, ap);
101
102 /* Setting mobility model */
104
105 mobility.SetPositionAllocator("ns3::GridPositionAllocator",
106 "MinX",
107 DoubleValue(0.0),
108 "MinY",
109 DoubleValue(0.0),
110 "DeltaX",
111 DoubleValue(5.0),
112 "DeltaY",
113 DoubleValue(10.0),
114 "GridWidth",
115 UintegerValue(3),
116 "LayoutType",
117 StringValue("RowFirst"));
118
119 mobility.SetMobilityModel("ns3::RandomWalk2dMobilityModel",
120 "Bounds",
121 RectangleValue(Rectangle(-50, 50, -50, 50)));
122 mobility.Install(sta);
123
124 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
125 mobility.Install(ap);
126
127 /* Internet stack*/
129 stack.Install(sta);
130 stack.Install(ap);
131
133
134 address.SetBase("192.168.1.0", "255.255.255.0");
137 staIf = address.Assign(staDevice);
138 apIf = address.Assign(apDevice);
139
140 /* Setting applications */
141
142 uint16_t port = 9;
143 DataRate dataRate("1Mb/s");
144 OnOffHelper onOff("ns3::UdpSocketFactory",
146 onOff.SetAttribute("DataRate", DataRateValue(dataRate));
147 onOff.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=0.01]"));
148 onOff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=8]"));
149 onOff.SetAttribute("PacketSize", UintegerValue(50));
150
151 ApplicationContainer staApps = onOff.Install(sta);
152
153 staApps.Start(Seconds(1.0));
154 staApps.Stop(Seconds(10.0));
155
157
159
160 phy.EnablePcap("test-blockack", ap->GetId(), 0);
163
164 return 0;
165}
a polymophic address class
Definition address.h:90
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.
Parse command-line arguments.
Class for representing data rates.
Definition data-rate.h:78
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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.
Smart pointer class similar to boost::intrusive_ptr.
a 2d rectangle
Definition rectangle.h:24
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static void Run()
Run the simulation.
Definition simulator.cc:167
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:175
The IEEE 802.11 SSID Information Element.
Definition ssid.h:25
Hold variables of type string.
Definition string.h:45
Hold an unsigned integer type.
Definition uinteger.h:34
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
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:33
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
@ WIFI_STANDARD_80211n
address
Definition first.py:36
stack
Definition first.py:33
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:291
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition log.h:102
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition log.h:93
ssid
Definition third.py:82
channel
Definition third.py:77
mac
Definition third.py:81
wifi
Definition third.py:84
mobility
Definition third.py:92
phy
Definition third.py:78