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 
42 #include "ns3/core-module.h"
43 #include "ns3/internet-module.h"
44 #include "ns3/network-module.h"
45 #include "ns3/applications-module.h"
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> ();
60 
63  phy.SetChannel (channel.Create ());
64 
67  /* disable fragmentation */
68  wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500));
69 
70  Ssid ssid ("My-network");
71 
72  mac.SetType ("ns3::StaWifiMac",
73  "Ssid", SsidValue (ssid),
74  "ActiveProbing", BooleanValue (false));
75  /* setting blockack threshold for sta's BE queue */
77  /* setting block inactivity timeout to 3*1024 = 3072 microseconds */
78  //mac.SetBlockAckInactivityTimeoutForAc (AC_BE, 3);
79  NetDeviceContainer staDevice = wifi.Install (phy, mac, sta);
80 
81  mac.SetType ("ns3::ApWifiMac",
82  "Ssid", SsidValue (ssid));
84  NetDeviceContainer apDevice = wifi.Install (phy, mac, ap);
85 
86  /* Setting mobility model */
88 
89  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
90  "MinX", DoubleValue (0.0),
91  "MinY", DoubleValue (0.0),
92  "DeltaX", DoubleValue (5.0),
93  "DeltaY", DoubleValue (10.0),
94  "GridWidth", UintegerValue (3),
95  "LayoutType", StringValue ("RowFirst"));
96 
97  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
98  "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
99  mobility.Install (sta);
100 
101  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
102  mobility.Install (ap);
103 
104  /* Internet stack*/
106  stack.Install (sta);
107  stack.Install (ap);
108 
110 
111  address.SetBase ("192.168.1.0", "255.255.255.0");
114  staIf = address.Assign (staDevice);
115  apIf = address.Assign (apDevice);
116 
117  /* Setting applications */
118 
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));
124  onOff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=0.01]"));
125  onOff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=8]"));
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 
134 
135  Simulator::Stop (Seconds (10.0));
136 
137  phy.EnablePcap ("test-blockack-2", ap->GetId (), 0);
138  Simulator::Run ();
140 
141  return 0;
142 }
tuple channel
Definition: third.py:85
holds a vector of ns3::Application pointers.
an Inet address class
AttributeValue implementation for Boolean.
Definition: boolean.h:34
holds a vector of std::pair of Ptr and interface index.
void SetRemoteStationManager(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Definition: wifi-helper.cc:74
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
Hold variables of type string.
Definition: string.h:41
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Set the underlying type of the MAC and its attributes.
static void Run(void)
Run the simulation.
Definition: simulator.cc:200
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
aggregate IP/TCP/UDP functionality to existing Nodes.
LOG_INFO and above.
Definition: log.h:103
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:96
Best Effort.
Definition: qos-utils.h:39
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:42
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
Definition: wifi-helper.cc:103
uint16_t port
Definition: dsdv-manet.cc:44
a polymophic address class
Definition: address.h:90
AttributeValue implementation for Rectangle.
Definition: rectangle.h:97
Class for representing data rates.
Definition: data-rate.h:88
void SetChannel(Ptr< YansWifiChannel > channel)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void SetBlockAckThresholdForAc(enum AcIndex ac, uint8_t threshold)
This method sets value of block ack threshold for a specific access class.
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
tuple mobility
Definition: third.py:101
tuple phy
Definition: third.py:86
Hold an unsigned integer type.
Definition: uinteger.h:44
holds a vector of ns3::NetDevice pointers
static QosWifiMacHelper Default(void)
Create a mac helper in a default working state.
tuple mac
Definition: third.py:92
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:164
LOG_DEBUG and above.
Definition: log.h:100
create QoS-enabled MAC layers for a ns3::WifiNetDevice.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
tuple ssid
Definition: third.py:93
manage and create wifi channel objects for the yans model.
tuple stack
Definition: first.py:34
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:38
Helper class used to assign positions and mobility models to nodes.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
AttributeValue implementation for DataRate.
Definition: data-rate.h:241
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:208
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
AttributeValue implementation for Ssid.
Definition: ssid.h:95
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
tuple wifi
Definition: third.py:89
tuple address
Definition: first.py:37
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
a 2d rectangle
Definition: rectangle.h:34
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static WifiHelper Default(void)
Definition: wifi-helper.cc:66