A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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/abort.h"
23 #include "ns3/test.h"
24 #include "ns3/config.h"
25 #include "ns3/string.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/inet-socket-address.h"
28 #include "ns3/point-to-point-helper.h"
29 #include "ns3/internet-stack-helper.h"
30 #include "ns3/ipv4-address-helper.h"
31 #include "ns3/ipv4-header.h"
32 #include "ns3/packet-sink-helper.h"
33 #include "ns3/udp-client-server-helper.h"
34 #include "ns3/simulator.h"
35 #include "ns3/wimax-helper.h"
36 #include "ns3/mobility-helper.h"
37 #include <iostream>
38 #include "ns3/global-route-manager.h"
39 
40 using namespace ns3;
41 
43 {
44 public:
46  virtual ~Ns3WimaxSchedulingTestCase ();
47 
48 private:
49  virtual void DoRun (void);
50  bool DoRunOnce (WimaxHelper::SchedulerType scheduler);
51 
52 };
53 
55  : TestCase ("Test the 2 different schedulers")
56 {
57 }
58 
60 {
61 }
62 
63 bool
65 {
66  NodeContainer ssNodes;
67  NodeContainer bsNodes;
68  ssNodes.Create (2);
69  bsNodes.Create (1);
70  WimaxHelper wimax;
71  NetDeviceContainer ssDevs, bsDevs;
72  ssDevs = wimax.Install (ssNodes,
73  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
74  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
75  scheduler);
76  bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
77  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
78  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
79 
81  stack.Install (bsNodes);
82  stack.Install (ssNodes);
83 
85  address.SetBase ("10.1.1.0", "255.255.255.0");
86 
87  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
88  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
89 
90  /*------------------------------*/
91  UdpServerHelper udpServer;
93  UdpClientHelper udpClient;
95 
96  udpServer = UdpServerHelper (100);
97  serverApps = udpServer.Install (ssNodes.Get (0));
98  serverApps.Start (Seconds (1));
99  serverApps.Stop (Seconds (2));
100 
101  udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
102  udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
103  udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
104  udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
105  clientApps = udpClient.Install (ssNodes.Get (1));
106  clientApps.Start (Seconds (1));
107  clientApps.Stop (Seconds (2));
108 
109  Simulator::Stop (Seconds (2 + 0.1));
110 
111  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
112  Ipv4Mask ("0.0.0.0"),
113  SSinterfaces.GetAddress (0),
114  Ipv4Mask ("255.255.255.255"),
115  0,
116  65000,
117  100,
118  100,
119  17,
120  1);
121  ServiceFlow DlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN,
122  ServiceFlow::SF_TYPE_RTPS,
123  DlClassifierUgs);
124  IpcsClassifierRecord UlClassifierUgs (SSinterfaces.GetAddress (1),
125  Ipv4Mask ("255.255.255.255"),
126  Ipv4Address ("0.0.0.0"),
127  Ipv4Mask ("0.0.0.0"),
128  0,
129  65000,
130  100,
131  100,
132  17,
133  1);
134  ServiceFlow UlServiceFlowUgs = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP,
135  ServiceFlow::SF_TYPE_RTPS,
136  UlClassifierUgs);
137  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlowUgs);
138  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlowUgs);
139 
140  Simulator::Run ();
141  Simulator::Destroy ();
142  return false;
143 
144 }
145 
146 void
148 {
149  if (DoRunOnce (WimaxHelper::SCHED_TYPE_SIMPLE) == true)
150  {
151  return;
152  }
153  if (DoRunOnce (WimaxHelper::SCHED_TYPE_RTPS) == true)
154  {
155  return;
156  }
157 }
158 
159 
160 // =============================================================================
162 {
163 public:
165  virtual ~Ns3WimaxSFTypeTestCase ();
166 
167 private:
168  virtual void DoRun (void);
170 
171 };
172 
174  : TestCase ("Test the service flow scheduling types")
175 {
176 }
177 
179 {
180 }
181 
182 bool
184 {
185  NodeContainer ssNodes;
186  NodeContainer bsNodes;
187  ssNodes.Create (2);
188  bsNodes.Create (1);
189  WimaxHelper wimax;
190  NetDeviceContainer ssDevs, bsDevs;
191  ssDevs = wimax.Install (ssNodes,
192  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
193  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
194  WimaxHelper::SCHED_TYPE_SIMPLE);
195  bsDevs = wimax.Install (bsNodes,
196  WimaxHelper::DEVICE_TYPE_BASE_STATION,
197  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
198  WimaxHelper::SCHED_TYPE_SIMPLE);
199  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
200  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
201 
203  stack.Install (bsNodes);
204  stack.Install (ssNodes);
205 
207  address.SetBase ("10.1.1.0", "255.255.255.0");
208 
209  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
210  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
211 
212  /*------------------------------*/
213  UdpServerHelper udpServer;
215  UdpClientHelper udpClient;
217 
218  udpServer = UdpServerHelper (100);
219  serverApps = udpServer.Install (ssNodes.Get (0));
220  serverApps.Start (Seconds (1));
221  serverApps.Stop (Seconds (2));
222 
223  udpClient = UdpClientHelper (SSinterfaces.GetAddress (0), 100);
224  udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
225  udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.12)));
226  udpClient.SetAttribute ("PacketSize", UintegerValue (1024));
227  clientApps = udpClient.Install (ssNodes.Get (1));
228  clientApps.Start (Seconds (1));
229  clientApps.Stop (Seconds (2));
230 
231  Simulator::Stop (Seconds (2 + 0.1));
232 
233  IpcsClassifierRecord DlClassifier (Ipv4Address ("0.0.0.0"),
234  Ipv4Mask ("0.0.0.0"),
235  SSinterfaces.GetAddress (0),
236  Ipv4Mask ("255.255.255.255"),
237  0,
238  65000,
239  100,
240  100,
241  17,
242  1);
243  ServiceFlow DlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_DOWN, schedulingType, DlClassifier);
244  IpcsClassifierRecord UlClassifier (SSinterfaces.GetAddress (1),
245  Ipv4Mask ("255.255.255.255"),
246  Ipv4Address ("0.0.0.0"),
247  Ipv4Mask ("0.0.0.0"),
248  0,
249  65000,
250  100,
251  100,
252  17,
253  1);
254  ServiceFlow UlServiceFlow = wimax.CreateServiceFlow (ServiceFlow::SF_DIRECTION_UP, schedulingType, UlClassifier);
255  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlow);
256  ssDevs.Get (1)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlow);
257 
258  Simulator::Run ();
259  Simulator::Destroy ();
260  return false;
261 
262 }
263 
264 void
266 {
267  if (DoRunOnce (ServiceFlow::SF_TYPE_UGS) == true)
268  {
269  return;
270  }
271  if (DoRunOnce (ServiceFlow::SF_TYPE_RTPS) == true)
272  {
273  return;
274  }
275  if (DoRunOnce (ServiceFlow::SF_TYPE_BE) == true)
276  {
277  return;
278  }
279 }
280 
282 {
283 public:
285 };
286 
288  : TestSuite ("wimax-qos", SYSTEM)
289 {
290  AddTestCase (new Ns3WimaxSFTypeTestCase, TestCase::QUICK);
291  AddTestCase (new Ns3WimaxSchedulingTestCase, TestCase::QUICK);
292 }
293 
holds a vector of ns3::Application pointers.
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:222
A suite of tests to run.
Definition: test.h:1105
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
aggregate IP/TCP/UDP functionality to existing Nodes.
encapsulates test code
Definition: test.h:929
bool DoRunOnce(ServiceFlow::SchedulingType)
Definition: qos-test.cc:183
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
ApplicationContainer Install(NodeContainer c)
virtual ~Ns3WimaxSchedulingTestCase()
Definition: qos-test.cc:59
tuple clientApps
Definition: first.py:53
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: qos-test.cc:265
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
hold objects of type ns3::Time
Definition: nstime.h:1008
Hold an unsigned integer type.
Definition: uinteger.h:46
holds a vector of ns3::NetDevice pointers
Create a server application which waits for input UDP packets and uses the information carried into t...
static Ns3WimaxQoSTestSuite ns3WimaxQoSTestSuite
Definition: qos-test.cc:294
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
tuple serverApps
Definition: first.py:44
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
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:147
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
virtual ~Ns3WimaxSFTypeTestCase()
Definition: qos-test.cc:178
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
tuple stack
Definition: first.py:34
bool DoRunOnce(WimaxHelper::SchedulerType scheduler)
Definition: qos-test.cc:64
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
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:59
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