A Discrete-Event Network Simulator
API
wifi-blockack.cc
Go to the documentation of this file.
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
43#include "ns3/command-line.h"
44#include "ns3/uinteger.h"
45#include "ns3/boolean.h"
46#include "ns3/double.h"
47#include "ns3/string.h"
48#include "ns3/log.h"
49#include "ns3/yans-wifi-helper.h"
50#include "ns3/ssid.h"
51#include "ns3/mobility-helper.h"
52#include "ns3/on-off-helper.h"
53#include "ns3/yans-wifi-channel.h"
54#include "ns3/mobility-model.h"
55#include "ns3/rectangle.h"
56#include "ns3/internet-stack-helper.h"
57#include "ns3/ipv4-address-helper.h"
58#include "ns3/ipv4-global-routing-helper.h"
59
60using namespace ns3;
61
62NS_LOG_COMPONENT_DEFINE ("Test-block-ack");
63
64int main (int argc, char * argv[])
65{
66 CommandLine cmd (__FILE__);
67 cmd.Parse (argc, argv);
68
70 LogComponentEnable ("BlockAckManager", LOG_LEVEL_INFO);
71
72 Ptr<Node> sta = CreateObject<Node> ();
73 Ptr<Node> ap = CreateObject<Node> ();
74
75 YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
77 phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
78 phy.SetChannel (channel.Create ());
79
81 wifi.SetStandard (WIFI_STANDARD_80211n);
83 /* disable fragmentation */
84 wifi.SetRemoteStationManager ("ns3::IdealWifiManager", "FragmentationThreshold", UintegerValue (2500));
85
86 Ssid ssid ("My-network");
87
88 mac.SetType ("ns3::StaWifiMac",
89 "QosSupported", BooleanValue (true),
90 "Ssid", SsidValue (ssid),
91 /* setting blockack threshold for sta's BE queue */
92 "BE_BlockAckThreshold", UintegerValue (2),
93 /* setting block inactivity timeout to 3*1024 = 3072 microseconds */
94 "BE_BlockAckInactivityTimeout", UintegerValue (3));
95 NetDeviceContainer staDevice = wifi.Install (phy, mac, sta);
96
97 mac.SetType ("ns3::ApWifiMac",
98 "QosSupported", BooleanValue (true),
99 "Ssid", SsidValue (ssid),
100 "BE_BlockAckThreshold", UintegerValue (0));
101 NetDeviceContainer apDevice = wifi.Install (phy, mac, ap);
102
103 /* Setting mobility model */
105
106 mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
107 "MinX", DoubleValue (0.0),
108 "MinY", DoubleValue (0.0),
109 "DeltaX", DoubleValue (5.0),
110 "DeltaY", DoubleValue (10.0),
111 "GridWidth", UintegerValue (3),
112 "LayoutType", StringValue ("RowFirst"));
113
114 mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
115 "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
116 mobility.Install (sta);
117
118 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
119 mobility.Install (ap);
120
121 /* Internet stack*/
123 stack.Install (sta);
124 stack.Install (ap);
125
127
128 address.SetBase ("192.168.1.0", "255.255.255.0");
131 staIf = address.Assign (staDevice);
132 apIf = address.Assign (apDevice);
133
134 /* Setting applications */
135
136 uint16_t port = 9;
137 DataRate dataRate ("1Mb/s");
138 OnOffHelper onOff ("ns3::UdpSocketFactory", Address (InetSocketAddress (apIf.GetAddress (0), port)));
139 onOff.SetAttribute ("DataRate", DataRateValue (dataRate));
140 onOff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.01]"));
141 onOff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=8]"));
142 onOff.SetAttribute ("PacketSize", UintegerValue (50));
143
144 ApplicationContainer staApps = onOff.Install (sta);
145
146 staApps.Start (Seconds (1.0));
147 staApps.Stop (Seconds (10.0));
148
149 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
150
151 Simulator::Stop (Seconds (10.0));
152
153 phy.EnablePcap ("test-blockack", ap->GetId (), 0);
154 Simulator::Run ();
155 Simulator::Destroy ();
156
157 return 0;
158}
a polymophic address class
Definition: address.h:91
holds a vector of ns3::Application pointers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
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:229
Class for representing data rates.
Definition: data-rate.h:89
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
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.
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
uint32_t GetId(void) const
Definition: node.cc:109
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:43
a 2d rectangle
Definition: rectangle.h:35
AttributeValue implementation for Rectangle.
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
AttributeValue implementation for Ssid.
Hold variables of type string.
Definition: string.h:41
Hold an unsigned integer type.
Definition: uinteger.h:44
helps to create WifiNetDevice objects
Definition: wifi-helper.h:323
create MAC layers for a ns3::WifiNetDevice.
manage and create wifi channel objects for the YANS model.
Make it easy to create and manage PHY objects for the YANS model.
uint16_t port
Definition: dsdv-manet.cc:45
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
@ WIFI_STANDARD_80211n
address
Definition: first.py:44
stack
Definition: first.py:41
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition: log.h:104
@ LOG_LEVEL_INFO
LOG_INFO and above.
Definition: log.h:107
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361
cmd
Definition: second.py:35
ssid
Definition: third.py:97
channel
Definition: third.py:92
mac
Definition: third.py:96
wifi
Definition: third.py:99
mobility
Definition: third.py:107
phy
Definition: third.py:93