A Discrete-Event Network Simulator
API
qos-test.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007,2008, 2009 INRIA, UDcast
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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18  * <amine.ismail@udcast.com>
19  */
20 #include "ns3/internet-stack-helper.h"
21 #include "ns3/ipcs-classifier-record.h"
22 #include "ns3/ipv4-address-helper.h"
23 #include "ns3/ipv4-address.h"
24 #include "ns3/ipv4-interface-container.h"
25 #include "ns3/log.h"
26 #include "ns3/net-device-container.h"
27 #include "ns3/node-container.h"
28 #include "ns3/service-flow.h"
29 #include "ns3/simulator.h"
30 #include "ns3/test.h"
31 #include "ns3/wimax-helper.h"
32 
33 using namespace ns3;
34 
42 {
43  public:
45  ~Ns3WimaxSchedulingTestCase() override;
46 
47  private:
48  void DoRun() override;
54  bool DoRunOnce(WimaxHelper::SchedulerType scheduler);
55 };
56 
58  : TestCase("Test the 2 different schedulers")
59 {
60 }
61 
63 {
64 }
65 
66 bool
68 {
69  NodeContainer ssNodes;
70  NodeContainer bsNodes;
71  ssNodes.Create(2);
72  bsNodes.Create(1);
73  WimaxHelper wimax;
74  NetDeviceContainer ssDevs;
75  NetDeviceContainer bsDevs;
76  ssDevs = wimax.Install(ssNodes,
77  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
78  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
79  scheduler);
80  bsDevs = wimax.Install(bsNodes,
81  WimaxHelper::DEVICE_TYPE_BASE_STATION,
82  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
83  scheduler);
84  ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
85  WimaxPhy::MODULATION_TYPE_QAM16_12);
86  ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
87  WimaxPhy::MODULATION_TYPE_QAM16_12);
88 
90  stack.Install(bsNodes);
91  stack.Install(ssNodes);
92 
94  address.SetBase("10.1.1.0", "255.255.255.0");
95 
96  Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
97  Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
98 
99  /*------------------------------*/
100  // UdpServerHelper udpServer;
101  // ApplicationContainer serverApps;
102  // UdpClientHelper udpClient;
103  // ApplicationContainer clientApps;
104  //
105  // udpServer = UdpServerHelper (100);
106  // serverApps = udpServer.Install (ssNodes.Get (0));
107  // serverApps.Start (Seconds (1));
108  // serverApps.Stop (Seconds (2));
109  //
110  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
111  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
112  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
113  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
114  // clientApps = udpClient.Install (ssNodes.Get (1));
115  // clientApps.Start (Seconds (1));
116  // clientApps.Stop (Seconds (2));
117 
118  Simulator::Stop(Seconds(2 + 0.1));
119 
120  IpcsClassifierRecord DlClassifierUgs(Ipv4Address("0.0.0.0"),
121  Ipv4Mask("0.0.0.0"),
122  SSinterfaces.GetAddress(0),
123  Ipv4Mask("255.255.255.255"),
124  0,
125  65000,
126  100,
127  100,
128  17,
129  1);
130  ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN,
131  ServiceFlow::SF_TYPE_RTPS,
132  DlClassifierUgs);
133  IpcsClassifierRecord UlClassifierUgs(SSinterfaces.GetAddress(1),
134  Ipv4Mask("255.255.255.255"),
135  Ipv4Address("0.0.0.0"),
136  Ipv4Mask("0.0.0.0"),
137  0,
138  65000,
139  100,
140  100,
141  17,
142  1);
143  ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP,
144  ServiceFlow::SF_TYPE_RTPS,
145  UlClassifierUgs);
146  ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(DlServiceFlowUgs);
147  ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(UlServiceFlowUgs);
148 
149  Simulator::Run();
150  Simulator::Destroy();
151  return false;
152 }
153 
154 void
156 {
157  if (DoRunOnce(WimaxHelper::SCHED_TYPE_SIMPLE))
158  {
159  return;
160  }
161  if (DoRunOnce(WimaxHelper::SCHED_TYPE_RTPS))
162  {
163  return;
164  }
165 }
166 
174 {
175  public:
177  ~Ns3WimaxSFTypeTestCase() override;
178 
179  private:
180  void DoRun() override;
186  bool DoRunOnce(ServiceFlow::SchedulingType schedulingType);
187 };
188 
190  : TestCase("Test the service flow scheduling types")
191 {
192 }
193 
195 {
196 }
197 
198 bool
200 {
201  NodeContainer ssNodes;
202  NodeContainer bsNodes;
203  ssNodes.Create(2);
204  bsNodes.Create(1);
205  WimaxHelper wimax;
206  NetDeviceContainer ssDevs;
207  NetDeviceContainer bsDevs;
208  ssDevs = wimax.Install(ssNodes,
209  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
210  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
211  WimaxHelper::SCHED_TYPE_SIMPLE);
212  bsDevs = wimax.Install(bsNodes,
213  WimaxHelper::DEVICE_TYPE_BASE_STATION,
214  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
215  WimaxHelper::SCHED_TYPE_SIMPLE);
216  ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
217  WimaxPhy::MODULATION_TYPE_QAM16_12);
218  ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->SetModulationType(
219  WimaxPhy::MODULATION_TYPE_QAM16_12);
220 
222  stack.Install(bsNodes);
223  stack.Install(ssNodes);
224 
226  address.SetBase("10.1.1.0", "255.255.255.0");
227 
228  Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
229  Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
230 
231  /*------------------------------*/
232  // UdpServerHelper udpServer;
233  // ApplicationContainer serverApps;
234  // UdpClientHelper udpClient;
235  // ApplicationContainer clientApps;
236  //
237  // udpServer = UdpServerHelper (100);
238  // serverApps = udpServer.Install (ssNodes.Get (0));
239  // serverApps.Start (Seconds (1));
240  // serverApps.Stop (Seconds (2));
241  //
242  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
243  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
244  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
245  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
246  // clientApps = udpClient.Install (ssNodes.Get (1));
247  // clientApps.Start (Seconds (1));
248  // clientApps.Stop (Seconds (2));
249 
250  Simulator::Stop(Seconds(2 + 0.1));
251 
252  IpcsClassifierRecord DlClassifier(Ipv4Address("0.0.0.0"),
253  Ipv4Mask("0.0.0.0"),
254  SSinterfaces.GetAddress(0),
255  Ipv4Mask("255.255.255.255"),
256  0,
257  65000,
258  100,
259  100,
260  17,
261  1);
262  ServiceFlow DlServiceFlow =
263  wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier);
264  IpcsClassifierRecord UlClassifier(SSinterfaces.GetAddress(1),
265  Ipv4Mask("255.255.255.255"),
266  Ipv4Address("0.0.0.0"),
267  Ipv4Mask("0.0.0.0"),
268  0,
269  65000,
270  100,
271  100,
272  17,
273  1);
274  ServiceFlow UlServiceFlow =
275  wimax.CreateServiceFlow(ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier);
276  ssDevs.Get(0)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(DlServiceFlow);
277  ssDevs.Get(1)->GetObject<SubscriberStationNetDevice>()->AddServiceFlow(UlServiceFlow);
278 
279  Simulator::Run();
280  Simulator::Destroy();
281  return false;
282 }
283 
284 void
286 {
287  if (DoRunOnce(ServiceFlow::SF_TYPE_UGS))
288  {
289  return;
290  }
291  if (DoRunOnce(ServiceFlow::SF_TYPE_RTPS))
292  {
293  return;
294  }
295  if (DoRunOnce(ServiceFlow::SF_TYPE_BE))
296  {
297  return;
298  }
299 }
300 
308 {
309  public:
311 };
312 
314  : TestSuite("wimax-qos", SYSTEM)
315 {
316  AddTestCase(new Ns3WimaxSFTypeTestCase, TestCase::QUICK);
317  AddTestCase(new Ns3WimaxSchedulingTestCase, TestCase::QUICK);
318 }
319 
Ns3 Wimax QoS Test Suite.
Definition: qos-test.cc:308
Ns3 Wimax SF Type Test Case.
Definition: qos-test.cc:174
void DoRun() override
Implementation to actually run this TestCase.
Definition: qos-test.cc:285
~Ns3WimaxSFTypeTestCase() override
Definition: qos-test.cc:194
bool DoRunOnce(ServiceFlow::SchedulingType schedulingType)
Run once function.
Definition: qos-test.cc:199
Ns3 Wimax Scheduling Test Case.
Definition: qos-test.cc:42
~Ns3WimaxSchedulingTestCase() override
Definition: qos-test.cc:62
bool DoRunOnce(WimaxHelper::SchedulerType scheduler)
Run once function.
Definition: qos-test.cc:67
void DoRun() override
Implementation to actually run this TestCase.
Definition: qos-test.cc:155
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.
Definition: ipv4-address.h:42
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
Definition: ipv4-address.h:257
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.
Definition: service-flow.h:43
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition: service-flow.h:62
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:50
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:59
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
address
Definition: first.py:47
stack
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite
the test suite
Definition: qos-test.cc:320