A Discrete-Event Network Simulator
API
lte-net-device.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Giuseppe Piro <g.piro@poliba.it>
18 * Nicola Baldo <nbaldo@cttc.es>
19 */
20
21#include "lte-net-device.h"
22
23#include "lte-amc.h"
24
25#include "ns3/callback.h"
26#include "ns3/enum.h"
27#include "ns3/ipv4-header.h"
28#include "ns3/ipv6-header.h"
29#include "ns3/llc-snap-header.h"
30#include "ns3/node.h"
31#include "ns3/packet-burst.h"
32#include "ns3/packet.h"
33#include "ns3/pointer.h"
34#include "ns3/simulator.h"
35#include "ns3/trace-source-accessor.h"
36#include "ns3/uinteger.h"
37#include <ns3/ipv4-l3-protocol.h>
38#include <ns3/ipv6-l3-protocol.h>
39#include <ns3/log.h>
40#include <ns3/lte-radio-bearer-tag.h>
41
42namespace ns3
43{
44
45NS_LOG_COMPONENT_DEFINE("LteNetDevice");
46
47NS_OBJECT_ENSURE_REGISTERED(LteNetDevice);
48
50// LteNetDevice
52
53TypeId
55{
56 static TypeId tid =
57 TypeId("ns3::LteNetDevice")
59
60 .AddAttribute("Mtu",
61 "The MAC-level Maximum Transmission Unit",
62 UintegerValue(30000),
64 MakeUintegerChecker<uint16_t>());
65 return tid;
66}
67
69{
70 NS_LOG_FUNCTION(this);
71}
72
74{
75 NS_LOG_FUNCTION(this);
76}
77
78void
80{
81 NS_LOG_FUNCTION(this);
82
83 m_node = nullptr;
85}
86
89{
90 NS_LOG_FUNCTION(this);
91 // we can't return a meaningful channel here, because LTE devices using FDD have actually two
92 // channels.
93 return nullptr;
94}
95
96void
98{
99 NS_LOG_FUNCTION(this << address);
101}
102
105{
106 NS_LOG_FUNCTION(this);
107 return m_address;
108}
109
110void
112{
113 NS_LOG_FUNCTION(this << node);
114 m_node = node;
115}
116
119{
120 NS_LOG_FUNCTION(this);
121 return m_node;
122}
123
124void
126{
127 NS_LOG_FUNCTION(this);
128 m_rxCallback = cb;
129}
130
131bool
133 const Address& source,
134 const Address& dest,
135 uint16_t protocolNumber)
136{
137 NS_FATAL_ERROR("SendFrom () not supported");
138 return false;
139}
140
141bool
143{
144 NS_LOG_FUNCTION(this);
145 return false;
146}
147
148bool
149LteNetDevice::SetMtu(const uint16_t mtu)
150{
151 NS_LOG_FUNCTION(this << mtu);
152 m_mtu = mtu;
153 return true;
154}
155
156uint16_t
158{
159 NS_LOG_FUNCTION(this);
160 return m_mtu;
161}
162
163void
165{
166 NS_LOG_FUNCTION(this << index);
167 m_ifIndex = index;
168}
169
172{
173 NS_LOG_FUNCTION(this);
174 return m_ifIndex;
175}
176
177bool
179{
180 NS_LOG_FUNCTION(this);
181 return m_linkUp;
182}
183
184bool
186{
187 NS_LOG_FUNCTION(this);
188 return true;
189}
190
193{
194 NS_LOG_FUNCTION(this);
196}
197
198bool
200{
201 NS_LOG_FUNCTION(this);
202 return false;
203}
204
205bool
207{
208 NS_LOG_FUNCTION(this);
209 return false;
210}
211
212bool
214{
215 NS_LOG_FUNCTION(this);
216 return false;
217}
218
219bool
221{
222 NS_LOG_FUNCTION(this);
223 return false;
224}
225
228{
229 NS_LOG_FUNCTION(this << multicastGroup);
230
231 Mac48Address ad = Mac48Address::GetMulticast(multicastGroup);
232
233 //
234 // Implicit conversion (operator Address ()) is defined for Mac48Address, so
235 // use it by just returning the EUI-48 address which is automatically converted
236 // to an Address.
237 //
238 NS_LOG_LOGIC("multicast address is " << ad);
239
240 return ad;
241}
242
245{
246 NS_LOG_FUNCTION(this << addr);
248
249 NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad);
250 return ad;
251}
252
253void
255{
256 NS_LOG_FUNCTION(this);
258}
259
260void
262{
263 NS_LOG_FUNCTION(this);
264 NS_LOG_WARN("Promisc mode not supported");
265}
266
267void
269{
270 NS_LOG_FUNCTION(this << p);
271
272 Ipv4Header ipv4Header;
273 Ipv6Header ipv6Header;
274
275 if (p->PeekHeader(ipv4Header) != 0)
276 {
277 NS_LOG_LOGIC("IPv4 stack...");
279 }
280 else if (p->PeekHeader(ipv6Header) != 0)
281 {
282 NS_LOG_LOGIC("IPv6 stack...");
284 }
285 else
286 {
287 NS_ABORT_MSG("LteNetDevice::Receive - Unknown IP type...");
288 }
289}
290} // namespace ns3
a polymophic address class
Definition: address.h:92
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
Packet header for IPv4.
Definition: ipv4-header.h:34
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Describes an IPv6 address.
Definition: ipv6-address.h:50
Packet header for IPv6.
Definition: ipv6-header.h:36
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
void SetAddress(Address address) override
Set the address of this interface.
Ptr< Channel > GetChannel() const override
bool SupportsSendFrom() const override
bool NeedsArp() const override
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
void AddLinkChangeCallback(Callback< void > callback) override
Address GetMulticast(Ipv4Address addr) const override
Make and return a MAC multicast address using the provided multicast group.
~LteNetDevice() override
bool IsMulticast() const override
void Receive(Ptr< Packet > p)
receive a packet from the lower layers in order to forward it to the upper layers
Address GetBroadcast() const override
bool IsBroadcast() const override
NetDevice::ReceiveCallback m_rxCallback
receive callback
static TypeId GetTypeId()
Get the type ID.
Address GetAddress() const override
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void SetIfIndex(const uint32_t index) override
TracedCallback m_linkChangeCallbacks
link change callback
uint16_t GetMtu() const override
void SetNode(Ptr< Node > node) override
Mac64Address m_address
MAC address - only relevant for UEs.
uint16_t m_mtu
MTU.
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
Ptr< Node > GetNode() const override
uint32_t GetIfIndex() const override
uint32_t m_ifIndex
interface index
bool IsLinkUp() const override
Ptr< Node > m_node
the node
bool IsBridge() const override
Return true if the net device is acting as a bridge.
void DoDispose() override
Destructor implementation.
bool m_linkUp
link uo
bool SetMtu(const uint16_t mtu) override
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetMulticast(Ipv4Address address)
static Mac48Address GetBroadcast()
static Mac64Address ConvertFrom(const Address &address)
Network layer to device interface.
Definition: net-device.h:98
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:305
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Hold an unsigned integer type.
Definition: uinteger.h:45
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:49
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.