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
25using namespace ns3;
26
40{
41public:
43 virtual ~DsaRequestTestCase ();
44
45private:
46 virtual void DoRun (void);
47
48};
49
51 : TestCase ("Test the DSA request messages")
52{
53}
54
56{
57}
58
59void
61{
63 CsParameters csParam (CsParameters::ADD, classifier);
64 ServiceFlow sf = ServiceFlow (ServiceFlow::SF_DIRECTION_DOWN);
65
66 sf.SetSfid (100);
67 sf.SetConvergenceSublayerParam (csParam);
69 sf.SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
70 sf.SetMaxSustainedTrafficRate (1000000);
71 sf.SetMinReservedTrafficRate (1000000);
72 sf.SetMinTolerableTrafficRate (1000000);
73 sf.SetMaximumLatency (10);
74 sf.SetMaxTrafficBurst (1000);
75 sf.SetTrafficPriority (1);
76
77 DsaReq dsaReq (sf);
78 Ptr<Packet> packet = Create<Packet> ();
79 packet->AddHeader (dsaReq);
80
81 DsaReq dsaReqRecv;
82 packet->RemoveHeader (dsaReqRecv);
83
84 ServiceFlow sfRecv = dsaReqRecv.GetServiceFlow ();
85
86 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetDirection (), ServiceFlow::SF_DIRECTION_DOWN, "The sfRecv had the wrong direction.");
87 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetSfid (), 100, "The sfRecv had the wrong sfid.");
88 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetCsSpecification (), ServiceFlow::IPV4, "The sfRecv had the wrong cs specification.");
89 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetServiceSchedulingType (), ServiceFlow::SF_TYPE_UGS, "The sfRecv had the wrong service scheduling type.");
90 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaxSustainedTrafficRate (), 1000000, "The sfRecv had the wrong maximum sustained traffic rate.");
91 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMinReservedTrafficRate (), 1000000, "The sfRecv had the wrong minimum reserved traffic rate.");
92 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMinTolerableTrafficRate (), 1000000, "The sfRecv had the wrong minimum tolerable traffic rate.");
93 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaximumLatency (), 10, "The sfRecv had the wrong maximum latency.");
94 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaxTrafficBurst (), 1000, "The sfRecv had the wrong maximum traffic burst.");
95 NS_TEST_ASSERT_MSG_EQ (sfRecv.GetTrafficPriority (), 1, "The sfRecv had the wrong traffic priority.");
96}
97
105{
106public:
108};
109
111 : TestSuite ("wimax-mac-messages", UNIT)
112{
113 AddTestCase (new DsaRequestTestCase, TestCase::QUICK);
114}
115
Test the DSA request message.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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:374
ServiceFlow GetServiceFlow(void) const
IpcsClassifierRecord class.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:40
void SetSfid(uint32_t sfid)
Set SFID.
uint32_t GetMinReservedTrafficRate(void) const
Get minimum reserved traffic rate.
enum ServiceFlow::SchedulingType GetServiceSchedulingType(void) const
Get service scheduling type.
void SetMaxTrafficBurst(uint32_t maxTrafficBurst)
Set maximum traffic burst.
void SetMaximumLatency(uint32_t MaximumLatency)
Set maximum latency.
enum Direction GetDirection(void) const
Get direction.
uint32_t GetMaxTrafficBurst(void) const
Get max traffic burst.
void SetCsSpecification(enum CsSpecification spec)
Set CS specification.
void SetConvergenceSublayerParam(CsParameters csparam)
Set convergence sublayer parameters.
uint32_t GetMinTolerableTrafficRate(void) const
Get minimum tolerable traffic rate.
uint8_t GetTrafficPriority(void) const
Get traffic priority.
void SetTrafficPriority(uint8_t priority)
Set traffic priority.
void SetMinTolerableTrafficRate(uint32_t minJitter)
Set minimum tolerable traffic rate.
uint32_t GetMaximumLatency(void) const
Get maximum latency.
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType schedType)
Set service scheduling type.
enum CsSpecification GetCsSpecification(void) const
Get CS specification.
void SetMinReservedTrafficRate(uint32_t minResvRate)
Set minimum reserved traffic rate.
void SetMaxSustainedTrafficRate(uint32_t maxSustainedRate)
Set max sustained traffic rate.
uint32_t GetMaxSustainedTrafficRate(void) const
Get max sustained traffic rate.
uint32_t GetSfid(void) const
Get SFID.
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
#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:141
static Ns3WimaxMacMessagesTestSuite ns3WimaxMacMessagesTestSuite
the test suite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ IPV4
Definition: packetbb.h:46