A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-tlv-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 *
9 */
10#include "ns3/cs-parameters.h"
11#include "ns3/ipcs-classifier-record.h"
12#include "ns3/log.h"
13#include "ns3/packet.h"
14#include "ns3/ptr.h"
15#include "ns3/service-flow.h"
16#include "ns3/test.h"
17#include "ns3/wimax-helper.h"
18#include "ns3/wimax-tlv.h"
19
20using namespace ns3;
21
22/**
23 * @ingroup wimax-test
24 * @ingroup tests
25 *
26 * @brief Test the wimax tlv implementation.
27 */
29{
30 public:
33
34 private:
35 void DoRun() override;
36};
37
39 : TestCase("Test the CS parameters tlv implementation.")
40{
41}
42
46
47void
49{
51 Ipv4Mask("255.0.0.0"),
52 Ipv4Address("11.0.0.0"),
53 Ipv4Mask("255.0.0.0"),
54 1000,
55 1100,
56 3000,
57 3100,
58 17,
59 1);
60
61 classifier.AddSrcAddr(Ipv4Address("1.0.0.0"), Ipv4Mask("255.0.0.0"));
62 classifier.AddDstAddr(Ipv4Address("16.0.0.0"), Ipv4Mask("255.0.0.0"));
63 classifier.AddProtocol(6);
64 classifier.AddSrcPortRange(1, 2);
65 classifier.AddDstPortRange(4000, 4100);
66 classifier.SetIndex(1);
67
69
72
73 Tlv tlvSent(145, sfVectorTlvValue.GetSerializedSize(), sfVectorTlvValue);
74 Ptr<Packet> packet = Create<Packet>();
75 packet->AddHeader(tlvSent);
76
78 packet->RemoveHeader(tlvReceived);
80 {
81 auto sfVecValue = (SfVectorTlvValue*)tlvReceived.PeekValue();
82 for (auto iter = sfVecValue->Begin(); iter != sfVecValue->End(); ++iter)
83 {
84 if ((*iter)->GetType() == SfVectorTlvValue::IPV4_CS_Parameters)
85 {
87 IpcsClassifierRecord classifier = csParamsRecv.GetPacketClassifierRule();
88
89 NS_TEST_ASSERT_MSG_EQ(!classifier.CheckMatch(Ipv4Address("10.1.1.1"),
90 Ipv4Address("16.1.1.1"),
91 1050,
92 3050,
93 17),
94 false,
95 "The classifier address did not match.");
96 NS_TEST_ASSERT_MSG_EQ(!classifier.CheckMatch(Ipv4Address("10.1.5.1"),
97 Ipv4Address("11.1.1.23"),
98 1070,
99 3040,
100 6),
101 false,
102 "The classifier address did not match.");
103 NS_TEST_ASSERT_MSG_EQ(classifier.CheckMatch(Ipv4Address("11.1.1.1"),
104 Ipv4Address("17.1.1.1"),
105 1050,
106 3050,
107 17),
108 false,
109 "The classifier addresses matched.");
110 NS_TEST_ASSERT_MSG_EQ(classifier.CheckMatch(Ipv4Address("10.1.1.1"),
111 Ipv4Address("16.1.1.1"),
112 1050,
113 3050,
114 8),
115 false,
116 "The classifier addresses matched.");
117 }
118 }
119 }
120}
121
122/**
123 * @ingroup wimax-test
124 * @ingroup tests
125 *
126 * @brief Test the service flow tlv implementation.
127 */
129{
130 public:
132 ~Ns3WimaxSfTlvTestCase() override;
133
134 private:
135 void DoRun() override;
136};
137
139 : TestCase("Test the service flow tlv implementation.")
140{
141}
142
146
147void
149{
153
154 sf.SetSfid(100);
155 sf.SetConvergenceSublayerParam(csParam);
156 sf.SetCsSpecification(ServiceFlow::IPV4);
157 sf.SetServiceSchedulingType(ServiceFlow::SF_TYPE_UGS);
158 sf.SetMaxSustainedTrafficRate(1000000);
159 sf.SetMinReservedTrafficRate(1000000);
160 sf.SetMinTolerableTrafficRate(1000000);
161 sf.SetMaximumLatency(10);
162 sf.SetMaxTrafficBurst(1000);
163 sf.SetTrafficPriority(1);
164
165 Ptr<Packet> packet = Create<Packet>();
166 packet->AddHeader(sf.ToTlv());
167
169 packet->RemoveHeader(tlvReceived);
170
172
173 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetDirection(),
175 "The sfRecv had the wrong direction.");
176 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetSfid(), 100, "The sfRecv had the wrong sfid.");
177 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetCsSpecification(),
179 "The sfRecv had the wrong cs specification.");
180 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetServiceSchedulingType(),
182 "The sfRecv had the wrong service scheduling type.");
183 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaxSustainedTrafficRate(),
184 1000000,
185 "The sfRecv had the wrong maximum sustained traffic rate.");
186 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMinReservedTrafficRate(),
187 1000000,
188 "The sfRecv had the wrong minimum reserved traffic rate.");
189 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMinTolerableTrafficRate(),
190 1000000,
191 "The sfRecv had the wrong minimum tolerable traffic rate.");
192 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaximumLatency(),
193 10,
194 "The sfRecv had the wrong maximum latency.");
195 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetMaxTrafficBurst(),
196 1000,
197 "The sfRecv had the wrong maximum traffic burst.");
198 NS_TEST_ASSERT_MSG_EQ(sfRecv.GetTrafficPriority(),
199 1,
200 "The sfRecv had the wrong traffic priority.");
201}
202
203/**
204 * @ingroup wimax-test
205 * @ingroup tests
206 *
207 * @brief Ns3 Wimax Tlv Test Suite
208 */
210{
211 public:
213};
214
216 : TestSuite("wimax-tlv", Type::UNIT)
217{
218 AddTestCase(new Ns3WimaxCsParamTlvTestCase, TestCase::Duration::QUICK);
219 AddTestCase(new Ns3WimaxSfTlvTestCase, TestCase::Duration::QUICK);
220}
221
Test the wimax tlv implementation.
void DoRun() override
Implementation to actually run this TestCase.
Test the service flow tlv implementation.
~Ns3WimaxSfTlvTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
Ns3 Wimax Tlv Test Suite.
CsParameters class.
IpcsClassifierRecord class.
Ipv4 addresses are stored in host order in this class.
a class to represent an Ipv4 address mask
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
This class implements service flows as described by the IEEE-802.16 standard.
SfVectorTlvValue class.
Definition wimax-tlv.h:326
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
This class implements the Type-Len-Value structure channel encodings as described by "IEEE Standard f...
Definition wimax-tlv.h:76
@ UPLINK_SERVICE_FLOW
Definition wimax-tlv.h:85
void Add(const Tlv &val)
Add a TLV.
Definition wimax-tlv.cc:273
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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:134
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ns3WimaxTlvTestSuite ns3WimaxTlvTestSuite
the test suite