A Discrete-Event Network Simulator
API
mac-messages-test.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 INRIA, UDcast
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18  *
19  */
20 #include "ns3/mac-messages.h"
21 #include "ns3/service-flow.h"
22 #include "ns3/test.h"
23 
24 using namespace ns3;
25 
38 {
39  public:
41  ~DsaRequestTestCase() override;
42 
43  private:
44  void DoRun() override;
45 };
46 
48  : TestCase("Test the DSA request messages")
49 {
50 }
51 
53 {
54 }
55 
56 void
58 {
60  CsParameters csParam(CsParameters::ADD, classifier);
61  ServiceFlow sf = ServiceFlow(ServiceFlow::SF_DIRECTION_DOWN);
62 
63  sf.SetSfid(100);
64  sf.SetConvergenceSublayerParam(csParam);
66  sf.SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS);
67  sf.SetMaxSustainedTrafficRate(1000000);
68  sf.SetMinReservedTrafficRate(1000000);
69  sf.SetMinTolerableTrafficRate(1000000);
70  sf.SetMaximumLatency(10);
71  sf.SetMaxTrafficBurst(1000);
72  sf.SetTrafficPriority(1);
73 
74  DsaReq dsaReq(sf);
75  Ptr<Packet> packet = Create<Packet>();
76  packet->AddHeader(dsaReq);
77 
78  DsaReq dsaReqRecv;
79  packet->RemoveHeader(dsaReqRecv);
80 
81  ServiceFlow sfRecv = dsaReqRecv.GetServiceFlow();
82 
84  ServiceFlow::SF_DIRECTION_DOWN,
85  "The sfRecv had the wrong direction.");
86  NS_TEST_ASSERT_MSG_EQ(sfRecv.GetSfid(), 100, "The sfRecv had the wrong sfid.");
89  "The sfRecv had the wrong cs specification.");
91  ServiceFlow::SF_TYPE_UGS,
92  "The sfRecv had the wrong service scheduling type.");
94  1000000,
95  "The sfRecv had the wrong maximum sustained traffic rate.");
97  1000000,
98  "The sfRecv had the wrong minimum reserved traffic rate.");
100  1000000,
101  "The sfRecv had the wrong minimum tolerable traffic rate.");
103  10,
104  "The sfRecv had the wrong maximum latency.");
106  1000,
107  "The sfRecv had the wrong maximum traffic burst.");
109  1,
110  "The sfRecv had the wrong traffic priority.");
111 }
112 
120 {
121  public:
123 };
124 
126  : TestSuite("wimax-mac-messages", UNIT)
127 {
128  AddTestCase(new DsaRequestTestCase, TestCase::QUICK);
129 }
130 
Test the DSA request message.
void DoRun() override
Implementation to actually run this TestCase.
~DsaRequestTestCase() override
Ns3 Wimax Mac Messages Test Suite.
CsParameters class.
Definition: cs-parameters.h:36
This class implements the DSA-REQ message described by "IEEE Standard for Local and metropolitan area...
Definition: mac-messages.h:386
ServiceFlow GetServiceFlow() const
IpcsClassifierRecord class.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
void SetSfid(uint32_t sfid)
Set SFID.
void SetCsSpecification(CsSpecification spec)
Set CS specification.
ServiceFlow::SchedulingType GetServiceSchedulingType() const
Get service scheduling type.
uint32_t GetMaxSustainedTrafficRate() const
Get max sustained traffic rate.
uint32_t GetMaxTrafficBurst() const
Get max traffic burst.
uint32_t GetSfid() const
Get SFID.
uint32_t GetMaximumLatency() const
Get maximum latency.
void SetMaxTrafficBurst(uint32_t maxTrafficBurst)
Set maximum traffic burst.
void SetServiceSchedulingType(ServiceFlow::SchedulingType schedType)
Set service scheduling type.
void SetMaximumLatency(uint32_t MaximumLatency)
Set maximum latency.
void SetConvergenceSublayerParam(CsParameters csparam)
Set convergence sublayer parameters.
uint8_t GetTrafficPriority() const
Get traffic priority.
uint32_t GetMinReservedTrafficRate() const
Get minimum reserved traffic rate.
void SetTrafficPriority(uint8_t priority)
Set traffic priority.
CsSpecification GetCsSpecification() const
Get CS specification.
void SetMinTolerableTrafficRate(uint32_t minJitter)
Set minimum tolerable traffic rate.
uint32_t GetMinTolerableTrafficRate() const
Get minimum tolerable traffic rate.
void SetMinReservedTrafficRate(uint32_t minResvRate)
Set minimum reserved traffic rate.
Direction GetDirection() const
Get direction.
void SetMaxSustainedTrafficRate(uint32_t maxSustainedRate)
Set max sustained traffic rate.
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:144
static Ns3WimaxMacMessagesTestSuite ns3WimaxMacMessagesTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ IPV4
Definition: packetbb.h:47