author | Nicola Baldo <nbaldo@cttc.es> |
Mon, 04 Feb 2013 18:47:25 +0100 | |
changeset 9653 | 382d27da8905 |
parent 8660 | 4263961772e9 |
child 10410 | 4d4eb8097fa3 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Mileti? <rivanvx@gmail.com>
parents:
7252
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6705 | 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> |
|
7886 | 19 |
* Nicola Baldo <nbaldo@cttc.es> |
6705 | 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" |
|
7887 | 33 |
#include "lte-amc.h" |
6705 | 34 |
#include "ns3/ipv4-header.h" |
8462
cf6a48994db5
renamed LteMacTag --> LteRadioBearerTag
Nicola Baldo <nbaldo@cttc.es>
parents:
8398
diff
changeset
|
35 |
#include <ns3/lte-radio-bearer-tag.h> |
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
36 |
#include <ns3/ipv4-l3-protocol.h> |
8256
629982ba48a8
removed some useless inclusions of log.h
Nicola Baldo <nbaldo@cttc.es>
parents:
8253
diff
changeset
|
37 |
#include <ns3/log.h> |
6705 | 38 |
|
39 |
NS_LOG_COMPONENT_DEFINE ("LteNetDevice"); |
|
40 |
||
41 |
namespace ns3 { |
|
42 |
||
43 |
NS_OBJECT_ENSURE_REGISTERED ( LteNetDevice); |
|
44 |
||
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
45 |
//////////////////////////////// |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
46 |
// LteNetDevice |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
47 |
//////////////////////////////// |
6705 | 48 |
|
49 |
TypeId LteNetDevice::GetTypeId (void) |
|
50 |
{ |
|
51 |
static TypeId |
|
7252
c8200621e252
rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents:
6969
diff
changeset
|
52 |
tid = |
6705 | 53 |
TypeId ("ns3::LteNetDevice") |
54 |
||
55 |
.SetParent<NetDevice> () |
|
56 |
||
57 |
.AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit", |
|
8484
41691cd57fca
changed default MTU of LteNetDevice
Nicola Baldo <nbaldo@cttc.es>
parents:
8462
diff
changeset
|
58 |
UintegerValue (30000), |
6705 | 59 |
MakeUintegerAccessor (&LteNetDevice::SetMtu, |
60 |
&LteNetDevice::GetMtu), |
|
8484
41691cd57fca
changed default MTU of LteNetDevice
Nicola Baldo <nbaldo@cttc.es>
parents:
8462
diff
changeset
|
61 |
MakeUintegerChecker<uint16_t> ()) |
6705 | 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); |
|
7886 | 92 |
// we can't return a meaningful channel here, because LTE devices using FDD have actually two channels. |
93 |
return 0; |
|
6705 | 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 |
{ |
|
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
140 |
NS_FATAL_ERROR ("SendFrom () not supported"); |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
141 |
return false; |
6705 | 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); |
|
7886 | 189 |
return m_linkUp; |
6705 | 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); |
|
8398
407c931b9d27
add uplink to test-lte-epc-e2e-data
Nicola Baldo <nbaldo@cttc.es>
parents:
8390
diff
changeset
|
227 |
return false; |
6705 | 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 |
{ |
|
8597
4505da622d92
proper use of log macros in lte-net-device.cc
Nicola Baldo <nbaldo@cttc.es>
parents:
8484
diff
changeset
|
241 |
NS_LOG_FUNCTION (this << multicastGroup); |
6705 | 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); |
|
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
277 |
NS_LOG_WARN ("Promisc mode not supported"); |
6705 | 278 |
} |
279 |
||
280 |
||
281 |
||
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
282 |
void |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
283 |
LteNetDevice::Receive (Ptr<Packet> p) |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
284 |
{ |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
285 |
NS_LOG_FUNCTION (this << p); |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
286 |
m_rxCallback (this, p, Ipv4L3Protocol::PROT_NUMBER, Address ()); |
6705 | 287 |
} |
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
288 |
|
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
289 |
|
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
290 |
} |