A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-msdu-aggregator-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Dean Armstrong
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: Dean Armstrong <deanarm@gmail.com>
18 */
19
20#include "ns3/boolean.h"
21#include "ns3/double.h"
22#include "ns3/internet-stack-helper.h"
23#include "ns3/ipv4-address-helper.h"
24#include "ns3/mobility-helper.h"
25#include "ns3/on-off-helper.h"
26#include "ns3/packet-sink-helper.h"
27#include "ns3/packet-sink.h"
28#include "ns3/ssid.h"
29#include "ns3/string.h"
30#include "ns3/test.h"
31#include "ns3/uinteger.h"
32#include "ns3/yans-wifi-helper.h"
33
34using namespace ns3;
35
36/**
37 * \ingroup wifi-test
38 * \ingroup tests
39 *
40 * \brief Throughput test for MsduAggregator
41 */
43{
44 public:
46 void DoRun() override;
47
48 private:
49 bool m_writeResults; //!< flag whether to generate pcap
50};
51
53 : TestCase("MsduAggregator throughput test"),
54 m_writeResults(false)
55{
56}
57
58void
60{
61 WifiHelper wifi;
62 WifiMacHelper wifiMac;
63 YansWifiPhyHelper wifiPhy;
65 wifiPhy.SetChannel(wifiChannel.Create());
66
67 Ssid ssid = Ssid("wifi-amsdu-throughput");
68 // It may seem a little farcical running an 802.11n aggregation
69 // scenario with 802.11b rates (transmit rate fixed to 1 Mbps, no
70 // less), but this approach tests the bit we need to without unduly
71 // increasing the complexity of the simulation.
72 std::string phyMode("DsssRate1Mbps");
73 wifi.SetStandard(WIFI_STANDARD_80211b);
74 wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
75 "DataMode",
76 StringValue(phyMode),
77 "ControlMode",
78 StringValue(phyMode));
79
80 // Setup the AP, which will be the source of traffic for this test
81 // and thus has an aggregator on AC_BE.
83 ap.Create(1);
84 wifiMac.SetType("ns3::ApWifiMac",
85 "QosSupported",
86 BooleanValue(true),
87 "Ssid",
88 SsidValue(ssid),
89 "BeaconGeneration",
90 BooleanValue(true),
91 "BeaconInterval",
92 TimeValue(MicroSeconds(102400)),
93 "BE_MaxAmsduSize",
94 UintegerValue(4000));
95
96 NetDeviceContainer apDev = wifi.Install(wifiPhy, wifiMac, ap);
97
98 // Setup one STA, which will be the sink for traffic in this test.
99 NodeContainer sta;
100 sta.Create(1);
101 wifiMac.SetType("ns3::StaWifiMac",
102 "QosSupported",
103 BooleanValue(true),
104 "Ssid",
105 SsidValue(ssid),
106 "ActiveProbing",
107 BooleanValue(false));
108 NetDeviceContainer staDev = wifi.Install(wifiPhy, wifiMac, sta);
109
110 // Our devices will have fixed positions
111 MobilityHelper mobility;
112 mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
113 mobility.SetPositionAllocator("ns3::GridPositionAllocator",
114 "MinX",
115 DoubleValue(0.0),
116 "MinY",
117 DoubleValue(0.0),
118 "DeltaX",
119 DoubleValue(5.0),
120 "DeltaY",
121 DoubleValue(10.0),
122 "GridWidth",
123 UintegerValue(2),
124 "LayoutType",
125 StringValue("RowFirst"));
126 mobility.Install(sta);
127 mobility.Install(ap);
128
129 // Now we install internet stacks on our devices
131 stack.Install(ap);
132 stack.Install(sta);
133
134 Ipv4AddressHelper address;
135 address.SetBase("192.168.0.0", "255.255.255.0");
136 Ipv4InterfaceContainer staNodeInterface;
137 Ipv4InterfaceContainer apNodeInterface;
138 staNodeInterface = address.Assign(staDev);
139 apNodeInterface = address.Assign(apDev);
140
141 // The applications for this test will see a unidirectional UDP
142 // stream from the AP to the STA. The following UDP port will be
143 // used (arbitrary choice).
144 uint16_t udpPort = 50000;
145
146 // The packet sink application is on the STA device, and is running
147 // right from the start. The traffic source will turn on at 1 second
148 // and then off at 9 seconds, so we turn the sink off at 9 seconds
149 // too in order to measure throughput in a fixed window.
150 PacketSinkHelper packetSink("ns3::UdpSocketFactory",
152 ApplicationContainer sinkApp = packetSink.Install(sta.Get(0));
153 sinkApp.Start(Seconds(0));
154 sinkApp.Stop(Seconds(9.0));
155
156 // The packet source is an on-off application on the AP
157 // device. Given that we have fixed the transmit rate at 1 Mbps
158 // above, a 1 Mbps stream at the transport layer should be sufficient
159 // to determine whether aggregation is working or not.
160 //
161 // We configure this traffic stream to operate between 1 and 9 seconds.
162 OnOffHelper onoff("ns3::UdpSocketFactory",
163 InetSocketAddress(staNodeInterface.GetAddress(0), udpPort));
164 onoff.SetAttribute("PacketSize", UintegerValue(100));
165 onoff.SetConstantRate(DataRate("1Mbps"));
166 ApplicationContainer sourceApp = onoff.Install(ap.Get(0));
167 sourceApp.Start(Seconds(1.0));
168 sourceApp.Stop(Seconds(9.0));
169
170 // Enable tracing at the AP
171 if (m_writeResults)
172 {
174 wifiPhy.EnablePcap("wifi-amsdu-throughput", sta.Get(0)->GetId(), 0);
175 }
176
180
181 // Now the simulation is complete we note the total number of octets
182 // receive at the packet sink so that we can shortly test that this
183 // is plausible.
184 uint32_t totalOctetsThrough = DynamicCast<PacketSink>(sinkApp.Get(0))->GetTotalRx();
185
186 // Check that throughput was acceptable. This threshold is set based
187 // on inspection of a trace where things are working. Basically, we
188 // there get 26 UDP packets (of size 100, as specified above)
189 // aggregated per A-MSDU, for which the complete frame exchange
190 // (including RTS/CTS and plus medium access) takes around 32
191 // ms. Over the eight seconds of the test this means we expect about
192 // 650 kilobytes, so a pass threshold of 600000 seems to provide a
193 // fair amount of margin to account for reduced utilisation around
194 // stream startup, and contention around AP beacon transmission.
195 //
196 // If aggregation is turned off, then we get about 350 kilobytes in
197 // the same test, so we'll definitely catch the major failures.
198 NS_TEST_ASSERT_MSG_GT(totalOctetsThrough,
199 600000,
200 "A-MSDU test fails for low throughput of " << totalOctetsThrough
201 << " octets");
202}
203
204/**
205 * \ingroup wifi-test
206 * \ingroup tests
207 *
208 * \brief MsduAggregator Test Suite
209 *
210 * For now the MSDU Aggregator Test Suite contains only the one test
211 * that is defined in this file, so it's class definition and
212 * instantiation can live here.
213 */
215{
216 public:
218};
219
221 : TestSuite("wifi-msdu-aggregator", Type::SYSTEM)
222{
223 AddTestCase(new WifiMsduAggregatorThroughputTest, TestCase::Duration::QUICK);
224}
225
Throughput test for MsduAggregator.
void DoRun() override
Implementation to actually run this TestCase.
bool m_writeResults
flag whether to generate pcap
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.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
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: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 Ipv4Address GetAny()
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() const
Definition: node.cc:117
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Definition: on-off-helper.h:37
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
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
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
AttributeValue implementation for Time.
Definition: nstime.h:1413
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.
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:543
@ 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.
Ptr< YansWifiChannel > Create() 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:875
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
@ WIFI_STANDARD_80211b
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static WifiMsduAggregatorTestSuite wifiMsduAggregatorTestSuite