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
wimax-connection.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007,2008, 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
* Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20
*/
21
22
#include "
wimax-connection.h
"
23
#include "ns3/pointer.h"
24
#include "ns3/enum.h"
25
#include "ns3/uinteger.h"
26
#include "
service-flow.h
"
27
28
namespace
ns3 {
29
30
NS_OBJECT_ENSURE_REGISTERED
(WimaxConnection);
31
32
TypeId
WimaxConnection::GetTypeId
(
void
)
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::WimaxConnection"
)
35
36
.
SetParent
<
Object
> ()
37
38
.AddAttribute (
"Type"
,
39
"Connection type"
,
40
EnumValue
(
Cid::INITIAL_RANGING
),
41
MakeEnumAccessor
(&
WimaxConnection::GetType
),
42
MakeEnumChecker
(
Cid::BROADCAST
,
43
"Broadcast"
,
44
Cid::INITIAL_RANGING
,
45
"InitialRanging"
,
46
Cid::BASIC
,
47
"Basic"
,
48
Cid::PRIMARY
,
49
"Primary"
,
50
Cid::TRANSPORT
,
51
"Transport"
,
52
Cid::MULTICAST
,
53
"Multicast"
,
54
Cid::PADDING
,
55
"Padding"
))
56
57
.AddAttribute (
"TxQueue"
,
58
"Transmit queue"
,
59
PointerValue
(),
60
MakePointerAccessor (&
WimaxConnection::GetQueue
),
61
MakePointerChecker<WimaxMacQueue> ());
62
return
tid;
63
}
64
65
WimaxConnection::WimaxConnection
(
Cid
cid,
enum
Cid::Type
type)
66
: m_cid (cid),
67
m_cidType (type),
68
m_queue (
CreateObject
<
WimaxMacQueue
> (1024)),
69
m_serviceFlow (0)
70
{
71
}
72
73
WimaxConnection::~WimaxConnection
(
void
)
74
{
75
}
76
77
void
78
WimaxConnection::DoDispose
(
void
)
79
{
80
m_queue
= 0;
81
// m_serviceFlow = 0;
82
}
83
84
Cid
85
WimaxConnection::GetCid
(
void
)
const
86
{
87
return
m_cid
;
88
}
89
90
enum
Cid::Type
91
WimaxConnection::GetType
(
void
)
const
92
{
93
return
m_cidType
;
94
}
95
96
Ptr<WimaxMacQueue>
97
WimaxConnection::GetQueue
(
void
)
const
98
{
99
return
m_queue
;
100
}
101
102
void
103
WimaxConnection::SetServiceFlow
(
ServiceFlow
*serviceFlow)
104
{
105
m_serviceFlow
= serviceFlow;
106
}
107
108
ServiceFlow
*
109
WimaxConnection::GetServiceFlow
(
void
)
const
110
{
111
return
m_serviceFlow
;
112
}
113
114
uint8_t
115
WimaxConnection::GetSchedulingType
(
void
)
const
116
{
117
return
m_serviceFlow
->
GetSchedulingType
();
118
}
119
120
bool
121
WimaxConnection::Enqueue
(
Ptr<Packet>
packet,
const
MacHeaderType
&hdrType,
const
GenericMacHeader
&hdr)
122
{
123
124
return
m_queue
->
Enqueue
(packet, hdrType, hdr);
125
}
126
127
Ptr<Packet>
128
WimaxConnection::Dequeue
(
MacHeaderType::HeaderType
packetType)
129
{
130
return
m_queue
->
Dequeue
(packetType);
131
}
132
133
Ptr<Packet>
134
WimaxConnection::Dequeue
(
MacHeaderType::HeaderType
packetType, uint32_t availableByte)
135
{
136
return
m_queue
->
Dequeue
(packetType, availableByte);
137
}
138
139
bool
140
WimaxConnection::HasPackets
(
void
)
const
141
{
142
return
!
m_queue
->
IsEmpty
();
143
}
144
145
bool
146
WimaxConnection::HasPackets
(
MacHeaderType::HeaderType
packetType)
const
147
{
148
return
!
m_queue
->
IsEmpty
(packetType);
149
}
150
151
std::string
152
WimaxConnection::GetTypeStr
(
void
)
const
153
{
154
switch
(
m_cidType
)
155
{
156
case
Cid::BROADCAST
:
157
return
"Broadcast"
;
158
break
;
159
case
Cid::INITIAL_RANGING
:
160
return
"Initial Ranging"
;
161
break
;
162
case
Cid::BASIC
:
163
return
"Basic"
;
164
break
;
165
case
Cid::PRIMARY
:
166
return
"Primary"
;
167
break
;
168
case
Cid::TRANSPORT
:
169
return
"Transport"
;
170
break
;
171
case
Cid::MULTICAST
:
172
return
"Multicast"
;
173
break
;
174
default
:
175
NS_FATAL_ERROR
(
"Invalid connection type"
);
176
}
177
178
return
""
;
179
}
180
181
// Defragmentation Function
182
const
183
WimaxConnection::FragmentsQueue
WimaxConnection::GetFragmentsQueue
(
void
)
const
184
{
185
return
m_fragmentsQueue
;
186
}
187
188
void
189
WimaxConnection::FragmentEnqueue
(
Ptr<const Packet>
fragment)
190
{
191
m_fragmentsQueue
.push_back (fragment);
192
}
193
194
void
195
WimaxConnection::ClearFragmentsQueue
(
void
)
196
{
197
m_fragmentsQueue
.clear ();
198
}
199
}
// namespace ns3
src
wimax
model
wimax-connection.cc
Generated on Tue Oct 9 2012 16:45:50 for ns-3 by
1.8.1.2