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
);
116
}
117
118
static
Ns3WimaxMacMessagesTestSuite
ns3WimaxMacMessagesTestSuite
;
src
wimax
test
mac-messages-test.cc
Generated on Tue Nov 13 2012 10:32:26 for ns-3 by
1.8.1.2