A Discrete-Event Network Simulator
API
wifi-msdu-aggregator-test-suite.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2010 Dean Armstrong
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: Dean Armstrong <deanarm@gmail.com>
19 */
20
21#include "ns3/string.h"
22#include "ns3/test.h"
23#include "ns3/uinteger.h"
24#include "ns3/boolean.h"
25#include "ns3/double.h"
26#include "ns3/ssid.h"
27#include "ns3/packet-sink.h"
28#include "ns3/yans-wifi-helper.h"
29#include "ns3/mobility-helper.h"
30#include "ns3/internet-stack-helper.h"
31#include "ns3/ipv4-address-helper.h"
32#include "ns3/packet-sink-helper.h"
33#include "ns3/on-off-helper.h"
34
35using namespace ns3;
36
44{
45public:
47 virtual void DoRun (void);
48
49private:
51};
52
54 : TestCase ("MsduAggregator throughput test"),
55 m_writeResults (false)
56{
57}
58
59void
61{
63 WifiMacHelper wifiMac;
64 YansWifiPhyHelper wifiPhy;
65 YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
66 wifiPhy.SetChannel (wifiChannel.Create ());
67
68 Ssid ssid = Ssid ("wifi-amsdu-throughput");
69 // It may seem a little farcical running an 802.11n aggregation
70 // scenario with 802.11b rates (transmit rate fixed to 1 Mbps, no
71 // less), but this approach tests the bit we need to without unduly
72 // increasing the complexity of the simulation.
73 std::string phyMode ("DsssRate1Mbps");
74 wifi.SetStandard (WIFI_STANDARD_80211b);
75 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
76 "DataMode", StringValue (phyMode),
77 "ControlMode", StringValue (phyMode));
78
79 // Setup the AP, which will be the source of traffic for this test
80 // and thus has an aggregator on AC_BE.
82 ap.Create (1);
83 wifiMac.SetType ("ns3::ApWifiMac",
84 "QosSupported", BooleanValue (true),
85 "Ssid", SsidValue (ssid),
86 "BeaconGeneration", BooleanValue (true),
87 "BeaconInterval", TimeValue (MicroSeconds (102400)),
88 "BE_MaxAmsduSize", UintegerValue (4000));
89
90 NetDeviceContainer apDev = wifi.Install (wifiPhy, wifiMac, ap);
91
92 // Setup one STA, which will be the sink for traffic in this test.
93 NodeContainer sta;
94 sta.Create (1);
95 wifiMac.SetType ("ns3::StaWifiMac",
96 "QosSupported", BooleanValue (true),
97 "Ssid", SsidValue (ssid),
98 "ActiveProbing", BooleanValue (false));
99 NetDeviceContainer staDev = wifi.Install (wifiPhy, wifiMac, sta);
100
101 // Our devices will have fixed positions
103 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
104 mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
105 "MinX", DoubleValue (0.0),
106 "MinY", DoubleValue (0.0),
107 "DeltaX", DoubleValue (5.0),
108 "DeltaY", DoubleValue (10.0),
109 "GridWidth", UintegerValue (2),
110 "LayoutType", StringValue ("RowFirst"));
111 mobility.Install (sta);
112 mobility.Install (ap);
113
114 // Now we install internet stacks on our devices
116 stack.Install (ap);
117 stack.Install (sta);
118
120 address.SetBase ("192.168.0.0", "255.255.255.0");
121 Ipv4InterfaceContainer staNodeInterface, apNodeInterface;
122 staNodeInterface = address.Assign (staDev);
123 apNodeInterface = address.Assign (apDev);
124
125 // The applications for this test will see a unidirectional UDP
126 // stream from the AP to the STA. The following UDP port will be
127 // used (arbitrary choice).
128 uint16_t udpPort = 50000;
129
130 // The packet sink application is on the STA device, and is running
131 // right from the start. The traffic source will turn on at 1 second
132 // and then off at 9 seconds, so we turn the sink off at 9 seconds
133 // too in order to measure throughput in a fixed window.
134 PacketSinkHelper packetSink ("ns3::UdpSocketFactory",
135 InetSocketAddress (Ipv4Address::GetAny (),
136 udpPort));
137 ApplicationContainer sinkApp = packetSink.Install (sta.Get (0));
138 sinkApp.Start (Seconds (0));
139 sinkApp.Stop (Seconds (9.0));
140
141 // The packet source is an on-off application on the AP
142 // device. Given that we have fixed the transmit rate at 1 Mbps
143 // above, a 1 Mbps stream at the transport layer should be sufficient
144 // to determine whether aggregation is working or not.
145 //
146 // We configure this traffic stream to operate between 1 and 9 seconds.
147 OnOffHelper onoff ("ns3::UdpSocketFactory",
148 InetSocketAddress (staNodeInterface.GetAddress (0),
149 udpPort));
150 onoff.SetAttribute ("PacketSize", UintegerValue (100));
151 onoff.SetConstantRate (DataRate ("1Mbps"));
152 ApplicationContainer sourceApp = onoff.Install (ap.Get (0));
153 sourceApp.Start (Seconds (1.0));
154 sourceApp.Stop (Seconds (9.0));
155
156 // Enable tracing at the AP
157 if (m_writeResults)
158 {
159 wifiPhy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
160 wifiPhy.EnablePcap ("wifi-amsdu-throughput", sta.Get (0)->GetId (), 0);
161 }
162
163 Simulator::Stop (Seconds (10.0));
165 Simulator::Destroy ();
166
167 // Now the simulation is complete we note the total number of octets
168 // receive at the packet sink so that we can shortly test that this
169 // is plausible.
170 uint32_t totalOctetsThrough =
171 DynamicCast<PacketSink>(sinkApp.Get (0))->GetTotalRx ();
172
173 // Check that throughput was acceptable. This threshold is set based
174 // on inspection of a trace where things are working. Basically, we
175 // there get 26 UDP packets (of size 100, as specified above)
176 // aggregated per A-MSDU, for which the complete frame exchange
177 // (including RTS/CTS and plus medium access) takes around 32
178 // ms. Over the eight seconds of the test this means we expect about
179 // 650 kilobytes, so a pass threshold of 600000 seems to provide a
180 // fair amount of margin to account for reduced utilisation around
181 // stream startup, and contention around AP beacon transmission.
182 //
183 // If aggregation is turned off, then we get about 350 kilobytes in
184 // the same test, so we'll definitely catch the major failures.
185 NS_TEST_ASSERT_MSG_GT (totalOctetsThrough, 600000,
186 "A-MSDU test fails for low throughput of "
187 << totalOctetsThrough << " octets");
188}
189
190
202{
203public:
205};
206
208 : TestSuite ("wifi-msdu-aggregator", SYSTEM)
209{
210 AddTestCase (new WifiMsduAggregatorThroughputTest, TestCase::QUICK);
211}
212
void Run(ObjectFactory &factory, uint32_t pop, uint32_t total, uint32_t runs, Ptr< RandomVariableStream > eventStream, bool calRev)
Perform the runs for a single scheduler type.
Throughput test for MsduAggregator.
virtual void DoRun(void)
Implementation to actually run this TestCase.
bool m_writeResults
flag whether to generate pcap
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
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
Class for representing data rates.
Definition: data-rate.h:89
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
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
AttributeValue implementation for Ssid.
Hold variables of type string.
Definition: string.h:41
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
AttributeValue implementation for Time.
Definition: nstime.h:1309
Hold an unsigned integer type.
Definition: uinteger.h:44
helps to create WifiNetDevice objects
Definition: wifi-helper.h:322
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
Definition: wifi-helper.cc:537
manage and create wifi channel objects for the YANS model.
Ptr< YansWifiChannel > Create(void) const
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition: test.h:825
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1261
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
@ WIFI_STANDARD_80211b
address
Definition: first.py:40
stack
Definition: first.py:37
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ssid
Definition: third.py:88
wifi
Definition: third.py:90
mobility
Definition: third.py:98
static WifiMsduAggregatorTestSuite wifiMsduAggregatorTestSuite