A Discrete-Event Network Simulator
API
qos-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008, 2009 INRIA, UDcast
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: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@udcast.com>
20  */
21 #include "ns3/log.h"
22 #include "ns3/test.h"
23 #include "ns3/simulator.h"
24 #include "ns3/node-container.h"
25 #include "ns3/wimax-helper.h"
26 #include "ns3/net-device-container.h"
27 #include "ns3/internet-stack-helper.h"
28 #include "ns3/ipv4-address-helper.h"
29 #include "ns3/ipv4-interface-container.h"
30 #include "ns3/ipv4-address.h"
31 #include "ns3/service-flow.h"
32 #include "ns3/ipcs-classifier-record.h"
33 
34 using namespace ns3;
35 
37 {
38 public:
40  virtual ~Ns3WimaxSchedulingTestCase ();
41 
42 private:
43  virtual void DoRun (void);
44  bool DoRunOnce (WimaxHelper::SchedulerType scheduler);
45 
46 };
47 
49  : TestCase ("Test the 2 different schedulers")
50 {
51 }
52 
54 {
55 }
56 
57 bool
59 {
60  NodeContainer ssNodes;
61  NodeContainer bsNodes;
62  ssNodes.Create (2);
63  bsNodes.Create (1);
64  WimaxHelper wimax;
65  NetDeviceContainer ssDevs, bsDevs;
66  ssDevs = wimax.Install (ssNodes,
67  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
68  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
69  scheduler);
70  bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
71  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
72  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
73 
75  stack.Install (bsNodes);
76  stack.Install (ssNodes);
77 
79  address.SetBase ("10.1.1.0", "255.255.255.0");
80 
81  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
82  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
83 
84  /*------------------------------*/
85  // UdpServerHelper udpServer;
86  // ApplicationContainer serverApps;
87  // UdpClientHelper udpClient;
88  // ApplicationContainer clientApps;
89  //
90  // udpServer = UdpServerHelper (100);
91  // serverApps = udpServer.Install (ssNodes.Get (0));
92  // serverApps.Start (Seconds (1));
93  // serverApps.Stop (Seconds (2));
94  //
95  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
96  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
97  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
98  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
99  // clientApps = udpClient.Install (ssNodes.Get (1));
100  // clientApps.Start (Seconds (1));
101  // clientApps.Stop (Seconds (2));
102 
103  Simulator::Stop (Seconds (2 + 0.1));
104 
105  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
106  Ipv4Mask ("0.0.0.0"),
107  SSinterfaces.GetAddress (0),
108  Ipv4Mask ("255.255.255.255"),
109  0,
110  65000,
111  100,
112  100,
113  17,
114  1);
115  ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN,
116  ServiceFlow::SF_TYPE_RTPS,
117  DlClassifierUgs);
118  IpcsClassifierRecord UlClassifierUgs (SSinterfaces.GetAddress (1),
119  Ipv4Mask ("255.255.255.255"),
120  Ipv4Address ("0.0.0.0"),
121  Ipv4Mask ("0.0.0.0"),
122  0,
123  65000,
124  100,
125  100,
126  17,
127  1);
128  ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP,
129  ServiceFlow::SF_TYPE_RTPS,
130  UlClassifierUgs);
131  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlowUgs);
132  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlowUgs);
133 
134  Simulator::Run ();
135  Simulator::Destroy ();
136  return false;
137 
138 }
139 
140 void
142 {
143  if (DoRunOnce (WimaxHelper::SCHED_TYPE_SIMPLE) == true)
144  {
145  return;
146  }
147  if (DoRunOnce (WimaxHelper::SCHED_TYPE_RTPS) == true)
148  {
149  return;
150  }
151 }
152 
153 
154 // =============================================================================
156 {
157 public:
159  virtual ~Ns3WimaxSFTypeTestCase ();
160 
161 private:
162  virtual void DoRun (void);
164 
165 };
166 
168  : TestCase ("Test the service flow scheduling types")
169 {
170 }
171 
173 {
174 }
175 
176 bool
178 {
179  NodeContainer ssNodes;
180  NodeContainer bsNodes;
181  ssNodes.Create (2);
182  bsNodes.Create (1);
183  WimaxHelper wimax;
184  NetDeviceContainer ssDevs, bsDevs;
185  ssDevs = wimax.Install (ssNodes,
186  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
187  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
188  WimaxHelper::SCHED_TYPE_SIMPLE);
189  bsDevs = wimax.Install (bsNodes,
190  WimaxHelper::DEVICE_TYPE_BASE_STATION,
191  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
192  WimaxHelper::SCHED_TYPE_SIMPLE);
193  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
194  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
195 
197  stack.Install (bsNodes);
198  stack.Install (ssNodes);
199 
201  address.SetBase ("10.1.1.0", "255.255.255.0");
202 
203  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
204  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
205 
206  /*------------------------------*/
207  // UdpServerHelper udpServer;
208  // ApplicationContainer serverApps;
209  // UdpClientHelper udpClient;
210  // ApplicationContainer clientApps;
211  //
212  // udpServer = UdpServerHelper (100);
213  // serverApps = udpServer.Install (ssNodes.Get (0));
214  // serverApps.Start (Seconds (1));
215  // serverApps.Stop (Seconds (2));
216  //
217  // udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
218  // udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
219  // udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
220  // udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
221  // clientApps = udpClient.Install (ssNodes.Get (1));
222  // clientApps.Start (Seconds (1));
223  // clientApps.Stop (Seconds (2));
224 
225  Simulator::Stop (Seconds (2 + 0.1));
226 
227  IpcsClassifierRecord DlClassifier (Ipv4Address ("0.0.0.0"),
228  Ipv4Mask ("0.0.0.0"),
229  SSinterfaces.GetAddress (0),
230  Ipv4Mask ("255.255.255.255"),
231  0,
232  65000,
233  100,
234  100,
235  17,
236  1);
237  ServiceFlow DlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier);
238  IpcsClassifierRecord UlClassifier (SSinterfaces.GetAddress (1),
239  Ipv4Mask ("255.255.255.255"),
240  Ipv4Address ("0.0.0.0"),
241  Ipv4Mask ("0.0.0.0"),
242  0,
243  65000,
244  100,
245  100,
246  17,
247  1);
248  ServiceFlow UlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier);
249  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlow);
250  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlow);
251 
252  Simulator::Run ();
253  Simulator::Destroy ();
254  return false;
255 
256 }
257 
258 void
260 {
261  if (DoRunOnce (ServiceFlow::SF_TYPE_UGS) == true)
262  {
263  return;
264  }
265  if (DoRunOnce (ServiceFlow::SF_TYPE_RTPS) == true)
266  {
267  return;
268  }
269  if (DoRunOnce (ServiceFlow::SF_TYPE_BE) == true)
270  {
271  return;
272  }
273 }
274 
276 {
277 public:
279 };
280 
282  : TestSuite ("wimax-qos", SYSTEM)
283 {
284  AddTestCase (new Ns3WimaxSFTypeTestCase, TestCase::QUICK);
285  AddTestCase (new Ns3WimaxSchedulingTestCase, TestCase::QUICK);
286 }
287 
holds a vector of std::pair of Ptr and interface index.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
A suite of tests to run.
Definition: test.h:1333
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:85
aggregate IP/TCP/UDP functionality to existing Nodes.
encapsulates test code
Definition: test.h:1147
bool DoRunOnce(ServiceFlow::SchedulingType)
Definition: qos-test.cc:177
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
virtual ~Ns3WimaxSchedulingTestCase()
Definition: qos-test.cc:53
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: qos-test.cc:259
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
holds a vector of ns3::NetDevice pointers
static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite
Definition: qos-test.cc:288
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: qos-test.cc:141
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
virtual ~Ns3WimaxSFTypeTestCase()
Definition: qos-test.cc:172
tuple stack
Definition: first.py:34
bool DoRunOnce(WimaxHelper::SchedulerType scheduler)
Definition: qos-test.cc:58
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
ServiceFlow CreateServiceFlow(ServiceFlow::Direction direction, ServiceFlow::SchedulingType schedulinType, IpcsClassifierRecord classifier)
Creates a transport service flow.
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:58
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
tuple address
Definition: first.py:37
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