A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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/log.h"
22 #include "ns3/abort.h"
23 #include "ns3/test.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/inet-socket-address.h"
26 #include "ns3/point-to-point-helper.h"
27 #include "ns3/internet-stack-helper.h"
28 #include "ns3/ipv4-address-helper.h"
29 #include "ns3/ipv4-header.h"
30 #include "ns3/packet-sink-helper.h"
31 #include "ns3/udp-client-server-helper.h"
32 #include "ns3/udp-header.h"
33 #include "ns3/simulator.h"
34 #include "ns3/wimax-helper.h"
35 #include "ns3/mobility-helper.h"
36 #include "ns3/global-route-manager.h"
37 #include "ns3/wimax-tlv.h"
38 #include "ns3/ipcs-classifier-record.h"
39 #include "ns3/service-flow.h"
40 #include <iostream>
41 
42 using namespace ns3;
43 /*
44  * Test the DSA request message.
45  */
47 {
48 public:
50  virtual ~DsaRequestTestCase ();
51 
52 private:
53  virtual void DoRun (void);
54 
55 };
56 
58  : TestCase ("Test the DSA request messages")
59 {
60 }
61 
63 {
64 }
65 
66 void
68 {
70  CsParameters csParam (CsParameters::ADD, classifier);
71  ServiceFlow sf = ServiceFlow (ServiceFlow::SF_DIRECTION_DOWN);
72 
73  sf.SetSfid (100);
74  sf.SetConvergenceSublayerParam (csParam);
76  sf.SetServiceSchedulingType (ServiceFlow::SF_TYPE_UGS);
77  sf.SetMaxSustainedTrafficRate (1000000);
78  sf.SetMinReservedTrafficRate (1000000);
79  sf.SetMinTolerableTrafficRate (1000000);
80  sf.SetMaximumLatency (10);
81  sf.SetMaxTrafficBurst (1000);
82  sf.SetTrafficPriority (1);
83 
84  DsaReq dsaReq (sf);
85  Ptr<Packet> packet = Create<Packet> ();
86  packet->AddHeader (dsaReq);
87 
88  DsaReq dsaReqRecv;
89  packet->RemoveHeader (dsaReqRecv);
90 
91  ServiceFlow sfRecv = dsaReqRecv.GetServiceFlow ();
92 
93  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetDirection (), ServiceFlow::SF_DIRECTION_DOWN, "The sfRecv had the wrong direction.");
94  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetSfid (), 100, "The sfRecv had the wrong sfid.");
95  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetCsSpecification (), ServiceFlow::IPV4, "The sfRecv had the wrong cs specification.");
96  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetServiceSchedulingType (), ServiceFlow::SF_TYPE_UGS, "The sfRecv had the wrong service scheduling type.");
97  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaxSustainedTrafficRate (), 1000000, "The sfRecv had the wrong maximum sustained traffic rate.");
98  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMinReservedTrafficRate (), 1000000, "The sfRecv had the wrong minimum reserved traffic rate.");
99  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMinTolerableTrafficRate (), 1000000, "The sfRecv had the wrong minimum tolerable traffic rate.");
100  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaximumLatency (), 10, "The sfRecv had the wrong maximum latency.");
101  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetMaxTrafficBurst (), 1000, "The sfRecv had the wrong maximum traffic burst.");
102  NS_TEST_ASSERT_MSG_EQ (sfRecv.GetTrafficPriority (), 1, "The sfRecv had the wrong traffic priority.");
103 }
104 
105 // ==============================================================================
107 {
108 public:
110 };
111 
113  : TestSuite ("wimax-mac-messages", UNIT)
114 {
115  AddTestCase (new DsaRequestTestCase, TestCase::QUICK);
116 }
117 
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:1105
ServiceFlow GetServiceFlow(void) const
uint32_t GetSfid(void) const
encapsulates test code
Definition: test.h:929
void SetMinReservedTrafficRate(uint32_t)
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType)
uint32_t GetMinReservedTrafficRate(void) const
void SetMaxTrafficBurst(uint32_t)
#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:148
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)
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)
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
enum Direction GetDirection(void) const
void SetMinTolerableTrafficRate(uint32_t)
static Ns3WimaxMacMessagesTestSuite ns3WimaxMacMessagesTestSuite
uint32_t GetMaxSustainedTrafficRate(void) const
void SetSfid(uint32_t)
Doxygen 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:253