A Discrete-Event Network Simulator
API
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/test.h"
23 #include "ns3/simulator.h"
24 #include "ns3/wimax-helper.h"
25 #include "ns3/net-device-container.h"
26 #include "ns3/node-container.h"
27 
28 using namespace ns3;
29 
30 /*
31  * Test the network entry procedure.
32  * Create a network with a BS and 10 SS and check that all the SS perform the
33  * network entry correctly
34  *
35  */
37 {
38 public:
40  virtual ~Ns3WimaxNetworkEntryTestCase ();
41 
42 private:
43  virtual void DoRun (void);
44 
45 };
46 
48  : TestCase ("Test the network entry procedure")
49 {
50 }
51 
53 {
54 }
55 
56 void
58 {
59  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
60  NodeContainer ssNodes;
61  NodeContainer bsNodes;
62 
63  ssNodes.Create (10);
64  bsNodes.Create (1);
65 
66  WimaxHelper wimax;
67 
68  NetDeviceContainer ssDevs, bsDevs;
69 
70  ssDevs = wimax.Install (ssNodes,
71  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
72  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
73  scheduler);
74  bsDevs = wimax.Install (bsNodes,
75  WimaxHelper::DEVICE_TYPE_BASE_STATION,
76  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
77  scheduler);
78  Simulator::Stop (Seconds (1));
79  Simulator::Run ();
80  for (int i = 0; i < 10; i++)
81  {
82  NS_TEST_EXPECT_MSG_EQ (ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ()->IsRegistered (),true,
83  "SS[" << i << "] IsNotRegistered");
84  }
85  Simulator::Destroy ();
86 }
87 
88 /*
89  * Test if the management connections are correctly setup.
90  * Create a network with a BS and 10 SS and check that the management
91  * connections are correctly setup for all SS
92  *
93  */
94 
96 {
97 public:
100 
101 private:
102  virtual void DoRun (void);
103 
104 };
105 
107  : TestCase ("Test if the management connections are correctly setup")
108 {
109 }
110 
112 {
113 }
114 
115 void
117 {
118  WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
119  NodeContainer ssNodes;
120  NodeContainer bsNodes;
121 
122  ssNodes.Create (10);
123  bsNodes.Create (1);
124 
125  WimaxHelper wimax;
126 
127  NetDeviceContainer ssDevs, bsDevs;
128 
129  ssDevs = wimax.Install (ssNodes,
130  WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
131  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
132  scheduler);
133  bsDevs = wimax.Install (bsNodes,
134  WimaxHelper::DEVICE_TYPE_BASE_STATION,
135  WimaxHelper::SIMPLE_PHY_TYPE_OFDM,
136  scheduler);
137  Simulator::Stop (Seconds (1));
138  Simulator::Run ();
139  for (int i = 0; i < 10; i++)
140  {
141  NS_TEST_EXPECT_MSG_EQ (ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ()->GetAreManagementConnectionsAllocated (),
142  true, "Management connections for SS[" << i << "] are not allocated");
143  }
144  Simulator::Destroy ();
145 }
147 {
148 public:
150 };
151 
153  : TestSuite ("wimax-ss-mac-layer", UNIT)
154 {
155  AddTestCase (new Ns3WimaxNetworkEntryTestCase, TestCase::QUICK);
156  AddTestCase (new Ns3WimaxManagementConnectionsTestCase, TestCase::QUICK);
157 }
158 
Ns3WimaxNetworkEntryTestCase()
Definition: ss-mac-test.cc:47
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:1333
SchedulerType
Scheduler Type Different implementations of uplink/downlink scheduler.
Definition: wimax-helper.h:85
#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:278
virtual ~Ns3WimaxNetworkEntryTestCase()
Definition: ss-mac-test.cc:52
encapsulates test code
Definition: test.h:1147
NetDeviceContainer Install(NodeContainer c, NetDeviceType type, PhyType phyType, SchedulerType schedulerType)
static Ns3WimaxSSMacTestSuite ns3WimaxSSMacTestSuite
Definition: ss-mac-test.cc:159
Definition: ss-mac-test.cc:36
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: ss-mac-test.cc:57
holds a vector of ns3::NetDevice pointers
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: ss-mac-test.cc:116
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
helps to manage and create WimaxNetDevice objects
Definition: wimax-helper.h:58
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.