A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wimax-service-flow-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 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  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  * <amine.ismail@udcast.com>
20  *
21  */
22 #include "ns3/log.h"
23 #include "ns3/abort.h"
24 #include "ns3/test.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/inet-socket-address.h"
27 #include "ns3/point-to-point-helper.h"
28 #include "ns3/internet-stack-helper.h"
29 #include "ns3/ipv4-address-helper.h"
30 #include "ns3/ipv4-header.h"
31 #include "ns3/packet-sink-helper.h"
32 #include "ns3/udp-client-server-helper.h"
33 #include "ns3/udp-header.h"
34 #include "ns3/simulator.h"
35 #include "ns3/wimax-helper.h"
36 #include "ns3/mobility-helper.h"
37 #include "ns3/global-route-manager.h"
38 #include "ns3/wimax-tlv.h"
39 #include "ns3/ipcs-classifier-record.h"
40 #include "ns3/service-flow.h"
41 #include <iostream>
42 
43 using namespace ns3;
44 
45 /*
46  * Test the service flow creation.
47  */
49 {
50 public:
52  virtual ~Ns3WimaxSfCreationTestCase ();
53 
54 private:
55  virtual void DoRun (void);
56 
57 };
58 
60  : TestCase ("Test the service flow tlv implementation.")
61 {
62 }
63 
65 {
66 }
67 
68 void
70 {
71 
72  // default values
73  int duration = 2;
74  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
75 
76  NodeContainer ssNodes;
77  NodeContainer bsNodes;
78 
79  ssNodes.Create (1);
80  bsNodes.Create (1);
81 
82  WimaxHelper wimax;
83 
84  NetDeviceContainer ssDevs, bsDevs;
85 
86  ssDevs = wimax.Install (ssNodes,
87  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
88  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
89  scheduler);
90  bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler);
91 
92  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->SetModulationType (WimaxPhy::MODULATION_TYPE_QAM16_12);
93  bsDevs.Get (0)->GetObject<BaseStationNetDevice> ();
94 
96  stack.Install (bsNodes);
97  stack.Install (ssNodes);
98 
100  address.SetBase ("10.1.1.0", "255.255.255.0");
101 
102  Ipv4InterfaceContainer SSinterfaces = address.Assign (ssDevs);
103  Ipv4InterfaceContainer BSinterface = address.Assign (bsDevs);
104 
105  // Create one UGS Downlink service flow between the ss and the bs
106  ServiceFlow * DlServiceFlowUgs = new ServiceFlow (ServiceFlow::SF_DIRECTION_DOWN);
107  IpcsClassifierRecord DlClassifierUgs (Ipv4Address ("0.0.0.0"),
108  Ipv4Mask ("0.0.0.0"),
109  Ipv4Address ("0.0.0.0"),
110  Ipv4Mask ("0.0.0.0"),
111  3000,
112  3000,
113  0,
114  35000,
115  17,
116  1);
117  CsParameters DlcsParam (CsParameters::ADD, DlClassifierUgs);
118  DlServiceFlowUgs->SetConvergenceSublayerParam (DlcsParam);
119  DlServiceFlowUgs->SetCsSpecification (ServiceFlow::IPV4);
120  DlServiceFlowUgs->SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
121  DlServiceFlowUgs->SetMaxSustainedTrafficRate (1000000);
122  DlServiceFlowUgs->SetMinReservedTrafficRate (1000000);
123  DlServiceFlowUgs->SetMinTolerableTrafficRate (1000000);
124  DlServiceFlowUgs->SetMaximumLatency (10);
125  DlServiceFlowUgs->SetMaxTrafficBurst (1000);
126  DlServiceFlowUgs->SetTrafficPriority (1);
127 
128  // Create one UGS Uplink service flow between the ss and the bs
129  ServiceFlow * UlServiceFlowUgs = new ServiceFlow (ServiceFlow::SF_DIRECTION_UP);
130  IpcsClassifierRecord UlClassifierUgs (Ipv4Address ("0.0.0.0"),
131  Ipv4Mask ("0.0.0.0"),
132  Ipv4Address ("0.0.0.0"),
133  Ipv4Mask ("0.0.0.0"),
134  0,
135  35000,
136  3000,
137  3000,
138  17,
139  1);
140  CsParameters UlcsParam (CsParameters::ADD, UlClassifierUgs);
141  UlServiceFlowUgs->SetConvergenceSublayerParam (UlcsParam);
142  UlServiceFlowUgs->SetCsSpecification (ServiceFlow::IPV4);
143  UlServiceFlowUgs->SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
144  UlServiceFlowUgs->SetMaxSustainedTrafficRate (1000000);
145  UlServiceFlowUgs->SetMinReservedTrafficRate (1000000);
146  UlServiceFlowUgs->SetMinTolerableTrafficRate (1000000);
147  UlServiceFlowUgs->SetMaximumLatency (10);
148  UlServiceFlowUgs->SetMaxTrafficBurst (1000);
149  UlServiceFlowUgs->SetTrafficPriority (1);
150  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (DlServiceFlowUgs);
151  ssDevs.Get (0)->GetObject<SubscriberStationNetDevice> ()->AddServiceFlow (UlServiceFlowUgs);
152 
153  Simulator::Stop (Seconds (duration));
154  Simulator::Run ();
155  Simulator::Destroy ();
156 }
157 
158 // ==============================================================================
160 {
161 public:
163 };
164 
166  : TestSuite ("wimax-service-flow", UNIT)
167 {
168  AddTestCase (new Ns3WimaxSfCreationTestCase, TestCase::QUICK);
169 }
170 
holds a vector of std::pair of Ptr and interface index.
void SetMaxSustainedTrafficRate(uint32_t)
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:210
A suite of tests to run.
Definition: test.h:1025
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:849
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
void SetMinReservedTrafficRate(uint32_t)
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType)
void SetMaxTrafficBurst(uint32_t)
holds a vector of ns3::NetDevice pointers
void SetTrafficPriority(uint8_t)
void SetConvergenceSublayerParam(CsParameters)
keep track of a set of node pointers.
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
void SetMaximumLatency(uint32_t)
static Ns3WimaxServiceFlowTestSuite ns3WimaxServiceFlowTestSuite
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
tuple stack
Definition: first.py:34
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void SetMinTolerableTrafficRate(uint32_t)
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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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 SetCsSpecification(enum CsSpecification)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.