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
lte-net-device.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
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
* Author: Giuseppe Piro <g.piro@poliba.it>
19
* Nicola Baldo <nbaldo@cttc.es>
20
*/
21
22
#include "ns3/llc-snap-header.h"
23
#include "ns3/simulator.h"
24
#include "ns3/callback.h"
25
#include "ns3/node.h"
26
#include "ns3/packet.h"
27
#include "
lte-net-device.h
"
28
#include "ns3/packet-burst.h"
29
#include "ns3/uinteger.h"
30
#include "ns3/trace-source-accessor.h"
31
#include "ns3/pointer.h"
32
#include "ns3/enum.h"
33
#include "
lte-amc.h
"
34
#include "ns3/ipv4-header.h"
35
#include <ns3/lte-radio-bearer-tag.h>
36
#include <ns3/ipv4-l3-protocol.h>
37
#include <ns3/log.h>
38
39
NS_LOG_COMPONENT_DEFINE
(
"LteNetDevice"
);
40
41
namespace
ns3 {
42
43
NS_OBJECT_ENSURE_REGISTERED
( LteNetDevice);
44
46
// LteNetDevice
48
49
TypeId
LteNetDevice::GetTypeId
(
void
)
50
{
51
static
TypeId
52
tid =
53
TypeId
(
"ns3::LteNetDevice"
)
54
55
.
SetParent
<
NetDevice
> ()
56
57
.AddAttribute (
"Mtu"
,
"The MAC-level Maximum Transmission Unit"
,
58
UintegerValue
(30000),
59
MakeUintegerAccessor (&
LteNetDevice::SetMtu
,
60
&
LteNetDevice::GetMtu
),
61
MakeUintegerChecker<uint16_t> ())
62
;
63
return
tid;
64
}
65
66
LteNetDevice::LteNetDevice
(
void
)
67
{
68
NS_LOG_FUNCTION
(
this
);
69
}
70
71
72
LteNetDevice::~LteNetDevice
(
void
)
73
{
74
NS_LOG_FUNCTION
(
this
);
75
}
76
77
78
void
79
LteNetDevice::DoDispose
(
void
)
80
{
81
NS_LOG_FUNCTION
(
this
);
82
83
m_node
= 0;
84
NetDevice::DoDispose
();
85
}
86
87
88
Ptr<Channel>
89
LteNetDevice::GetChannel
(
void
)
const
90
{
91
NS_LOG_FUNCTION
(
this
);
92
// we can't return a meaningful channel here, because LTE devices using FDD have actually two channels.
93
return
0;
94
}
95
96
97
void
98
LteNetDevice::SetAddress
(
Address
address)
99
{
100
NS_LOG_FUNCTION
(
this
<< address);
101
m_address
=
Mac48Address::ConvertFrom
(address);
102
}
103
104
105
Address
106
LteNetDevice::GetAddress
(
void
)
const
107
{
108
NS_LOG_FUNCTION
(
this
);
109
return
m_address
;
110
}
111
112
113
void
114
LteNetDevice::SetNode
(
Ptr<Node>
node)
115
{
116
NS_LOG_FUNCTION
(
this
<< node);
117
m_node
= node;
118
}
119
120
121
Ptr<Node>
122
LteNetDevice::GetNode
(
void
)
const
123
{
124
NS_LOG_FUNCTION
(
this
);
125
return
m_node
;
126
}
127
128
129
void
130
LteNetDevice::SetReceiveCallback
(
ReceiveCallback
cb)
131
{
132
NS_LOG_FUNCTION
(
this
);
133
m_rxCallback
= cb;
134
}
135
136
137
bool
138
LteNetDevice::SendFrom
(
Ptr<Packet>
packet,
const
Address
& source,
const
Address
& dest, uint16_t protocolNumber)
139
{
140
NS_FATAL_ERROR
(
"SendFrom () not supported"
);
141
return
false
;
142
}
143
144
145
bool
146
LteNetDevice::SupportsSendFrom
(
void
)
const
147
{
148
NS_LOG_FUNCTION
(
this
);
149
return
false
;
150
}
151
152
153
154
bool
155
LteNetDevice::SetMtu
(
const
uint16_t mtu)
156
{
157
NS_LOG_FUNCTION
(
this
<< mtu);
158
m_mtu
= mtu;
159
return
true
;
160
}
161
162
uint16_t
163
LteNetDevice::GetMtu
(
void
)
const
164
{
165
NS_LOG_FUNCTION
(
this
);
166
return
m_mtu
;
167
}
168
169
170
void
171
LteNetDevice::SetIfIndex
(
const
uint32_t index)
172
{
173
NS_LOG_FUNCTION
(
this
<< index);
174
m_ifIndex
= index;
175
}
176
177
uint32_t
178
LteNetDevice::GetIfIndex
(
void
)
const
179
{
180
NS_LOG_FUNCTION
(
this
);
181
return
m_ifIndex
;
182
}
183
184
185
bool
186
LteNetDevice::IsLinkUp
(
void
)
const
187
{
188
NS_LOG_FUNCTION
(
this
);
189
return
m_linkUp
;
190
}
191
192
193
bool
194
LteNetDevice::IsBroadcast
(
void
)
const
195
{
196
NS_LOG_FUNCTION
(
this
);
197
return
true
;
198
}
199
200
Address
201
LteNetDevice::GetBroadcast
(
void
)
const
202
{
203
NS_LOG_FUNCTION
(
this
);
204
return
Mac48Address::GetBroadcast
();
205
}
206
207
bool
208
LteNetDevice::IsMulticast
(
void
)
const
209
{
210
NS_LOG_FUNCTION
(
this
);
211
return
false
;
212
}
213
214
215
bool
216
LteNetDevice::IsPointToPoint
(
void
)
const
217
{
218
NS_LOG_FUNCTION
(
this
);
219
return
false
;
220
}
221
222
223
bool
224
LteNetDevice::NeedsArp
(
void
)
const
225
{
226
NS_LOG_FUNCTION
(
this
);
227
return
false
;
228
}
229
230
231
bool
232
LteNetDevice::IsBridge
(
void
)
const
233
{
234
NS_LOG_FUNCTION
(
this
);
235
return
false
;
236
}
237
238
Address
239
LteNetDevice::GetMulticast
(
Ipv4Address
multicastGroup)
const
240
{
241
NS_LOG_FUNCTION
(
this
<< multicastGroup);
242
243
Mac48Address
ad =
Mac48Address::GetMulticast
(multicastGroup);
244
245
//
246
// Implicit conversion (operator Address ()) is defined for Mac48Address, so
247
// use it by just returning the EUI-48 address which is automagically converted
248
// to an Address.
249
//
250
NS_LOG_LOGIC
(
"multicast address is "
<< ad);
251
252
return
ad;
253
}
254
255
Address
256
LteNetDevice::GetMulticast
(
Ipv6Address
addr)
const
257
{
258
NS_LOG_FUNCTION
(
this
<< addr);
259
Mac48Address
ad =
Mac48Address::GetMulticast
(addr);
260
261
NS_LOG_LOGIC
(
"MAC IPv6 multicast address is "
<< ad);
262
return
ad;
263
}
264
265
void
266
LteNetDevice::AddLinkChangeCallback
(
Callback<void>
callback)
267
{
268
NS_LOG_FUNCTION
(
this
);
269
m_linkChangeCallbacks
.
ConnectWithoutContext
(callback);
270
}
271
272
273
void
274
LteNetDevice::SetPromiscReceiveCallback
(
PromiscReceiveCallback
cb)
275
{
276
NS_LOG_FUNCTION
(
this
);
277
NS_LOG_WARN
(
"Promisc mode not supported"
);
278
}
279
280
281
282
void
283
LteNetDevice::Receive
(
Ptr<Packet>
p)
284
{
285
NS_LOG_FUNCTION
(
this
<< p);
286
m_rxCallback
(
this
, p,
Ipv4L3Protocol::PROT_NUMBER
,
Address
());
287
}
288
289
290
}
src
lte
model
lte-net-device.cc
Generated on Tue Nov 13 2012 10:32:17 for ns-3 by
1.8.1.2