A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
*/
46
class
DsaRequestTestCase
:
public
TestCase
47
{
48
public
:
49
DsaRequestTestCase
();
50
virtual
~
DsaRequestTestCase
();
51
52
private
:
53
virtual
void
DoRun (
void
);
54
55
};
56
57
DsaRequestTestCase::DsaRequestTestCase
()
58
:
TestCase
(
"Test the DSA request messages"
)
59
{
60
}
61
62
DsaRequestTestCase::~DsaRequestTestCase
()
63
{
64
}
65
66
void
67
DsaRequestTestCase::DoRun
(
void
)
68
{
69
IpcsClassifierRecord
classifier =
IpcsClassifierRecord
();
70
CsParameters
csParam (CsParameters::ADD, classifier);
71
ServiceFlow
sf =
ServiceFlow
(ServiceFlow::SF_DIRECTION_DOWN);
72
73
sf.
SetSfid
(100);
74
sf.
SetConvergenceSublayerParam
(csParam);
75
sf.
SetCsSpecification
(
ServiceFlow::IPV4
);
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
// ==============================================================================
106
class
Ns3WimaxMacMessagesTestSuite
:
public
TestSuite
107
{
108
public
:
109
Ns3WimaxMacMessagesTestSuite
();
110
};
111
112
Ns3WimaxMacMessagesTestSuite::Ns3WimaxMacMessagesTestSuite
()
113
:
TestSuite
(
"wimax-mac-messages"
, UNIT)
114
{
115
AddTestCase
(
new
DsaRequestTestCase
, TestCase::QUICK);
116
}
117
118
static
Ns3WimaxMacMessagesTestSuite
ns3WimaxMacMessagesTestSuite
;
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Definition:
packet.cc:268
ns3::ServiceFlow::GetMinTolerableTrafficRate
uint32_t GetMinTolerableTrafficRate(void) const
Definition:
service-flow.cc:364
ns3::Ptr< Packet >
Ns3WimaxMacMessagesTestSuite
Definition:
mac-messages-test.cc:106
ns3::ServiceFlow::SetMaxSustainedTrafficRate
void SetMaxSustainedTrafficRate(uint32_t)
Definition:
service-flow.cc:505
ns3::ServiceFlow::GetMaxTrafficBurst
uint32_t GetMaxTrafficBurst(void) const
Definition:
service-flow.cc:354
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1025
ns3::DsaReq::GetServiceFlow
ServiceFlow GetServiceFlow(void) const
Definition:
mac-messages.cc:621
ns3::ServiceFlow::GetSfid
uint32_t GetSfid(void) const
Definition:
service-flow.cc:320
ns3::TestCase
encapsulates test code
Definition:
test.h:849
ns3::ServiceFlow::SetMinReservedTrafficRate
void SetMinReservedTrafficRate(uint32_t)
Definition:
service-flow.cc:515
ns3::IpcsClassifierRecord
Definition:
ipcs-classifier-record.h:34
ns3::ServiceFlow::SetServiceSchedulingType
void SetServiceSchedulingType(enum ServiceFlow::SchedulingType)
Definition:
service-flow.cc:525
ns3::ServiceFlow::GetMinReservedTrafficRate
uint32_t GetMinReservedTrafficRate(void) const
Definition:
service-flow.cc:359
ns3::ServiceFlow::SetMaxTrafficBurst
void SetMaxTrafficBurst(uint32_t)
Definition:
service-flow.cc:510
ns3::CsParameters
Definition:
cs-parameters.h:34
DsaRequestTestCase::DsaRequestTestCase
DsaRequestTestCase()
Definition:
mac-messages-test.cc:57
DsaRequestTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
mac-messages-test.cc:67
ns3::IPV4
Definition:
packetbb.h:46
ns3::ServiceFlow::GetCsSpecification
enum CsSpecification GetCsSpecification(void) const
Definition:
service-flow.cc:450
ns3::ServiceFlow::GetMaximumLatency
uint32_t GetMaximumLatency(void) const
Definition:
service-flow.cc:384
ns3::ServiceFlow::SetTrafficPriority
void SetTrafficPriority(uint8_t)
Definition:
service-flow.cc:500
ns3::ServiceFlow::SetConvergenceSublayerParam
void SetConvergenceSublayerParam(CsParameters)
Definition:
service-flow.cc:610
ns3::ServiceFlow::GetTrafficPriority
uint8_t GetTrafficPriority(void) const
Definition:
service-flow.cc:344
DsaRequestTestCase::~DsaRequestTestCase
virtual ~DsaRequestTestCase()
Definition:
mac-messages-test.cc:62
ns3::ServiceFlow
Definition:
service-flow.h:39
ns3::ServiceFlow::SetMaximumLatency
void SetMaximumLatency(uint32_t)
Definition:
service-flow.cc:540
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition:
test.cc:172
Ns3WimaxMacMessagesTestSuite::Ns3WimaxMacMessagesTestSuite
Ns3WimaxMacMessagesTestSuite()
Definition:
mac-messages-test.cc:112
ns3::ServiceFlow::GetDirection
enum Direction GetDirection(void) const
Definition:
service-flow.cc:197
ns3::ServiceFlow::SetMinTolerableTrafficRate
void SetMinTolerableTrafficRate(uint32_t)
Definition:
service-flow.cc:520
DsaRequestTestCase
Definition:
mac-messages-test.cc:46
ns3WimaxMacMessagesTestSuite
static Ns3WimaxMacMessagesTestSuite ns3WimaxMacMessagesTestSuite
Definition:
mac-messages-test.cc:118
ns3::ServiceFlow::GetMaxSustainedTrafficRate
uint32_t GetMaxSustainedTrafficRate(void) const
Definition:
service-flow.cc:349
ns3::ServiceFlow::SetSfid
void SetSfid(uint32_t)
Definition:
service-flow.cc:485
ns3::DsaReq
Definition:
mac-messages.h:262
ns3::ServiceFlow::SetCsSpecification
void SetCsSpecification(enum CsSpecification)
Definition:
service-flow.cc:605
ns3::ServiceFlow::GetServiceSchedulingType
enum ServiceFlow::SchedulingType GetServiceSchedulingType(void) const
Definition:
service-flow.cc:369
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Definition:
packet.cc:253
NS_TEST_ASSERT_MSG_EQ
#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:137
src
wimax
test
mac-messages-test.cc
Generated on Sun Apr 20 2014 11:15:07 for ns-3 by
1.8.6