A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
qos-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 */
9#include "ns3/internet-stack-helper.h"
10#include "ns3/ipcs-classifier-record.h"
11#include "ns3/ipv4-address-helper.h"
12#include "ns3/ipv4-address.h"
13#include "ns3/ipv4-interface-container.h"
14#include "ns3/log.h"
15#include "ns3/net-device-container.h"
16#include "ns3/node-container.h"
17#include "ns3/service-flow.h"
18#include "ns3/simulator.h"
19#include "ns3/test.h"
20#include "ns3/wimax-helper.h"
21
22using namespace ns3;
23
24/**
25 * @ingroup wimax-test
26 * @ingroup tests
27 *
28 * @brief Ns3 Wimax Scheduling Test Case
29 */
31{
32 public:
35
36 private:
37 void DoRun() override;
38 /**
39 * Run once function
40 * @param scheduler the wimax scheduler type
41 * @returns true if successful
42 */
44};
45
47 : TestCase("Test the 2 different schedulers")
48{
49}
50
54
55bool
57{
58 NodeContainer ssNodes;
59 NodeContainer bsNodes;
60 ssNodes.Create(2);
61 bsNodes.Create(1);
62 WimaxHelper wimax;
63 NetDeviceContainer ssDevs;
64 NetDeviceContainer bsDevs;
65 ssDevs = wimax.Install(ssNodes,
68 scheduler);
69 bsDevs = wimax.Install(bsNodes,
72 scheduler);
73 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
75 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
77
79 stack.Install(bsNodes);
80 stack.Install(ssNodes);
81
82 Ipv4AddressHelper address;
83 address.SetBase("10.1.1.0", "255.255.255.0");
84
85 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
86 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
87
88 /*------------------------------*/
89 // UdpServerHelper udpServer;
90 // ApplicationContainer serverApps;
91 // UdpClientHelper udpClient;
92 // ApplicationContainer clientApps;
93 //
94 // udpServer = UdpServerHelper (100);
95 // serverApps = udpServer.Install (ssNodes.Get (0));
96 // serverApps.Start (Seconds (1));
97 // serverApps.Stop (Seconds (2));
98 //
99 // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
100 // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
101 // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
102 // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
103 // clientApps = udpClient.Install (ssNodes.Get (1));
104 // clientApps.Start (Seconds (1));
105 // clientApps.Stop (Seconds (2));
106
107 Simulator::Stop(Seconds(2 + 0.1));
108
109 IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"),
110 Ipv4Mask("0.0.0.0"),
111 SSinterfaces.GetAddress(0),
112 Ipv4Mask("255.255.255.255"),
113 0,
114 65000,
115 100,
116 100,
117 17,
118 1);
121 DlClassifierUgs);
122 IpcsClassifierRecord UlClassifierUgs(SSinterfaces.GetAddress(1),
123 Ipv4Mask("255.255.255.255"),
124 Ipv4Address("0.0.0.0"),
125 Ipv4Mask("0.0.0.0"),
126 0,
127 65000,
128 100,
129 100,
130 17,
131 1);
134 UlClassifierUgs);
135 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(DlServiceFlowUgs);
136 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(UlServiceFlowUgs);
137
140 return false;
141}
142
143void
145{
147 {
148 return;
149 }
151 {
152 return;
153 }
154}
155
156/**
157 * @ingroup wimax-test
158 * @ingroup tests
159 *
160 * @brief Ns3 Wimax SF Type Test Case
161 */
163{
164 public:
166 ~Ns3WimaxSFTypeTestCase() override;
167
168 private:
169 void DoRun() override;
170 /**
171 * Run once function
172 * @param schedulingType the scheduling type
173 * @returns true if successful
174 */
175 bool DoRunOnce(ServiceFlow::SchedulingType schedulingType);
176};
177
179 : TestCase("Test the service flow scheduling types")
180{
181}
182
186
187bool
189{
190 NodeContainer ssNodes;
191 NodeContainer bsNodes;
192 ssNodes.Create(2);
193 bsNodes.Create(1);
194 WimaxHelper wimax;
195 NetDeviceContainer ssDevs;
196 NetDeviceContainer bsDevs;
197 ssDevs = wimax.Install(ssNodes,
201 bsDevs = wimax.Install(bsNodes,
205 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
207 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
209
211 stack.Install(bsNodes);
212 stack.Install(ssNodes);
213
214 Ipv4AddressHelper address;
215 address.SetBase("10.1.1.0", "255.255.255.0");
216
217 Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
218 Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
219
220 /*------------------------------*/
221 // UdpServerHelper udpServer;
222 // ApplicationContainer serverApps;
223 // UdpClientHelper udpClient;
224 // ApplicationContainer clientApps;
225 //
226 // udpServer = UdpServerHelper (100);
227 // serverApps = udpServer.Install (ssNodes.Get (0));
228 // serverApps.Start (Seconds (1));
229 // serverApps.Stop (Seconds (2));
230 //
231 // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
232 // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
233 // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
234 // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
235 // clientApps = udpClient.Install (ssNodes.Get (1));
236 // clientApps.Start (Seconds (1));
237 // clientApps.Stop (Seconds (2));
238
239 Simulator::Stop(Seconds(2 + 0.1));
240
241 IpcsClassifierRecord DlClassifier(Ipv4Address("0.0.0.0"),
242 Ipv4Mask("0.0.0.0"),
243 SSinterfaces.GetAddress(0),
244 Ipv4Mask("255.255.255.255"),
245 0,
246 65000,
247 100,
248 100,
249 17,
250 1);
251 ServiceFlow DlServiceFlow =
252 wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier);
253 IpcsClassifierRecord UlClassifier(SSinterfaces.GetAddress(1),
254 Ipv4Mask("255.255.255.255"),
255 Ipv4Address("0.0.0.0"),
256 Ipv4Mask("0.0.0.0"),
257 0,
258 65000,
259 100,
260 100,
261 17,
262 1);
263 ServiceFlow UlServiceFlow =
264 wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier);
265 ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(DlServiceFlow);
266 ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(UlServiceFlow);
267
270 return false;
271}
272
273void
275{
277 {
278 return;
279 }
281 {
282 return;
283 }
285 {
286 return;
287 }
288}
289
290/**
291 * @ingroup wimax-test
292 * @ingroup tests
293 *
294 * @brief Ns3 Wimax QoS Test Suite
295 */
297{
298 public:
300};
301
303 : TestSuite("wimax-qos", Type::SYSTEM)
304{
305 AddTestCase(new Ns3WimaxSFTypeTestCase, TestCase::Duration::QUICK);
306 AddTestCase(new Ns3WimaxSchedulingTestCase, TestCase::Duration::QUICK);
307}
308
Ns3 Wimax QoS Test Suite.
Definition qos-test.cc:297
Ns3 Wimax SF Type Test Case.
Definition qos-test.cc:163
void DoRun() override
Implementation to actually run this TestCase.
Definition qos-test.cc:274
~Ns3WimaxSFTypeTestCase() override
Definition qos-test.cc:183
bool DoRunOnce(ServiceFlow::SchedulingType schedulingType)
Run once function.
Definition qos-test.cc:188
Ns3 Wimax Scheduling Test Case.
Definition qos-test.cc:31
~Ns3WimaxSchedulingTestCase() override
Definition qos-test.cc:51
bool DoRunOnce(WimaxHelper::SchedulerType scheduler)
Run once function.
Definition qos-test.cc:56
void DoRun() override
Implementation to actually run this TestCase.
Definition qos-test.cc:144
aggregate IP/TCP/UDP functionality to existing Nodes.
IpcsClassifierRecord class.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
a class to represent an Ipv4 address mask
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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.
This class implements service flows as described by the IEEE-802.16 standard.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
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
SubscriberStationNetDevice subclass of WimaxNetDevice.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
helps to manage and create WimaxNetDevice objects
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
@ SCHED_TYPE_RTPS
A simple scheduler - rtPS based scheduler.
@ SCHED_TYPE_SIMPLE
A simple priority-based FCFS scheduler.
@ DEVICE_TYPE_SUBSCRIBER_STATION
Subscriber station(SS) device.
@ DEVICE_TYPE_BASE_STATION
Base station(BS) device.
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulingType, IpcsClassifierRecord classifier)
Creates a transport service flow.
@ MODULATION_TYPE_QAM16_12
Definition wimax-phy.h:47
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1344
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite
the test suite
Definition qos-test.cc:309