A Discrete-Event Network Simulator
API
mac-messages-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  *
20  */
21 #include "ns3/test.h"
22 #include "ns3/service-flow.h"
23 #include "ns3/mac-messages.h"
24 
25 using namespace ns3;
26 /*
27  * Test the DSA request message.
28  */
30 {
31 public:
33  virtual ~DsaRequestTestCase ();
34 
35 private:
36  virtual void DoRun (void);
37 
38 };
39 
41  : TestCase ("Test the DSA request messages")
42 {
43 }
44 
46 {
47 }
48 
49 void
51 {
53  CsParameters csParam (CsParameters::ADD, classifier);
54  ServiceFlow sf = ServiceFlow (ServiceFlow::SF_DIRECTION_DOWN);
55 
56  sf.SetSfid (100);
57  sf.SetConvergenceSublayerParam (csParam);
59  sf.SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
60  sf.SetMaxSustainedTrafficRate (1000000);
61  sf.SetMinReservedTrafficRate (1000000);
62  sf.SetMinTolerableTrafficRate (1000000);
63  sf.SetMaximumLatency (10);
64  sf.SetMaxTrafficBurst (1000);
65  sf.SetTrafficPriority (1);
66 
67  DsaReq dsaReq (sf);
68  Ptr<Packet> packet = Create<Packet> ();
69  packet->AddHeader (dsaReq);
70 
71  DsaReq dsaReqRecv;
72  packet->RemoveHeader (dsaReqRecv);
73 
74  ServiceFlow sfRecv = dsaReqRecv.GetServiceFlow ();
75 
76  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetDirection (), ServiceFlow::SF_DIRECTION_DOWN, "The sfRecv had the wrong direction.");
77  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetSfid (), 100, "The sfRecv had the wrong sfid.");
78  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetCsSpecification (), ServiceFlow::IPV4, "The sfRecv had the wrong cs specification.");
79  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetServiceSchedulingType (), ServiceFlow::SF_TYPE_UGS, "The sfRecv had the wrong service scheduling type.");
80  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaxSustainedTrafficRate (), 1000000, "The sfRecv had the wrong maximum sustained traffic rate.");
81  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMinReservedTrafficRate (), 1000000, "The sfRecv had the wrong minimum reserved traffic rate.");
82  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMinTolerableTrafficRate (), 1000000, "The sfRecv had the wrong minimum tolerable traffic rate.");
83  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaximumLatency (), 10, "The sfRecv had the wrong maximum latency.");
84  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaxTrafficBurst (), 1000, "The sfRecv had the wrong maximum traffic burst.");
85  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetTrafficPriority (), 1, "The sfRecv had the wrong traffic priority.");
86 }
87 
88 // ==============================================================================
90 {
91 public:
93 };
94 
96  : TestSuite ("wimax-mac-messages", UNIT)
97 {
98  AddTestCase (new DsaRequestTestCase, TestCase::QUICK);
99 }
100 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
uint32_t GetMinTolerableTrafficRate(void) const
void SetMaxSustainedTrafficRate(uint32_t)
uint32_t GetMaxTrafficBurst(void) const
A suite of tests to run.
Definition: test.h:1333
ServiceFlow GetServiceFlow(void) const
uint32_t GetSfid(void) const
encapsulates test code
Definition: test.h:1147
void SetMinReservedTrafficRate(uint32_t)
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType)
uint32_t GetMinReservedTrafficRate(void) const
void SetMaxTrafficBurst(uint32_t)
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:298
#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:161
virtual void DoRun(void)
Implementation to actually run this TestCase.
enum CsSpecification GetCsSpecification(void) const
uint32_t GetMaximumLatency(void) const
void SetTrafficPriority(uint8_t)
void SetConvergenceSublayerParam(CsParameters)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t GetTrafficPriority(void) const
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
void SetMaximumLatency(uint32_t)
enum Direction GetDirection(void) const
void SetMinTolerableTrafficRate(uint32_t)
static Ns3WimaxMacMessagesTestSuite ns3WimaxMacMessagesTestSuite
uint32_t GetMaxSustainedTrafficRate(void) const
void SetSfid(uint32_t)
Introspection did not find any typical Config paths.
Definition: mac-messages.h:262
void SetCsSpecification(enum CsSpecification)
enum ServiceFlow::SchedulingType GetServiceSchedulingType(void) const
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:257