A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ss-mac-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/udp-header.h"
35 #include "ns3/simulator.h"
36 #include "ns3/wimax-helper.h"
37 #include "ns3/mobility-helper.h"
38 #include <iostream>
39 #include "ns3/global-route-manager.h"
40 
41 using namespace ns3;
42 
43 /*
44  * Test the network entry procedure.
45  * Create a network with a BS and 10 SS and check that all the SS perform the
46  * network entry correctly
47  *
48  */
50 {
51 public:
53  virtual ~Ns3WimaxNetworkEntryTestCase ();
54 
55 private:
56  virtual void DoRun (void);
57 
58 };
59 
61  : TestCase ("Test the network entry procedure")
62 {
63 }
64 
66 {
67 }
68 
69 void
71 {
72  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
73  NodeContainer ssNodes;
74  NodeContainer bsNodes;
75 
76  ssNodes.Create (10);
77  bsNodes.Create (1);
78 
79  WimaxHelper wimax;
80 
81  NetDeviceContainer ssDevs, bsDevs;
82 
83  ssDevs = wimax.Install (ssNodes,
84  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
85  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
86  scheduler);
87  bsDevs = wimax.Install (bsNodes,
88  WimaxHelper::DEVICE_TYPE_BASE_STATION,
89  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
90  scheduler);
91  Simulator::Stop (Seconds (1));
92  Simulator::Run ();
93  for (int i = 0; i < 10; i++)
94  {
95  NS_TEST_EXPECT_MSG_EQ (ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ()->IsRegistered (),true,
96  "SS[" << i << "] IsNotRegistered");
97  }
98  Simulator::Destroy ();
99 }
100 
101 /*
102  * Test if the management connections are correctly setup.
103  * Create a network with a BS and 10 SS and check that the management
104  * connections are correctly setup for all SS
105  *
106  */
107 
109 {
110 public:
113 
114 private:
115  virtual void DoRun (void);
116 
117 };
118 
120  : TestCase ("Test if the management connections are correctly setup")
121 {
122 }
123 
125 {
126 }
127 
128 void
130 {
131  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
132  NodeContainer ssNodes;
133  NodeContainer bsNodes;
134 
135  ssNodes.Create (10);
136  bsNodes.Create (1);
137 
138  WimaxHelper wimax;
139 
140  NetDeviceContainer ssDevs, bsDevs;
141 
142  ssDevs = wimax.Install (ssNodes,
143  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
144  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
145  scheduler);
146  bsDevs = wimax.Install (bsNodes,
147  WimaxHelper::DEVICE_TYPE_BASE_STATION,
148  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
149  scheduler);
150  Simulator::Stop (Seconds (1));
151  Simulator::Run ();
152  for (int i = 0; i < 10; i++)
153  {
154  NS_TEST_EXPECT_MSG_EQ (ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ()->GetAreManagementConnectionsAllocated (),
155  true, "Management connections for SS[" << i << "] are not allocated");
156  }
157  Simulator::Destroy ();
158 }
160 {
161 public:
163 };
164 
166  : TestSuite ("wimax-ss-mac-layer", UNIT)
167 {
168  AddTestCase (new Ns3WimaxNetworkEntryTestCase, TestCase::QUICK);
169  AddTestCase (new Ns3WimaxManagementConnectionsTestCase, TestCase::QUICK);
170 }
171 
Ns3WimaxNetworkEntryTestCase()
Definition: ss-mac-test.cc:60
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
A suite of tests to run.
Definition: test.h:1025
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:86
virtual ~Ns3WimaxNetworkEntryTestCase()
Definition: ss-mac-test.cc:65
encapsulates test code
Definition: test.h:849
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
static Ns3WimaxSSMacTestSuite ns3WimaxSSMacTestSuite
Definition: ss-mac-test.cc:172
Definition: ss-mac-test.cc:49
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: ss-mac-test.cc:70
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:244
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: ss-mac-test.cc:129
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:59
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.