A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-net-device.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Giuseppe Piro <g.piro@poliba.it>
7 * Nicola Baldo <nbaldo@cttc.es>
8 */
9
10#include "lte-net-device.h"
11
12#include "ns3/callback.h"
13#include "ns3/channel.h"
14#include "ns3/enum.h"
15#include "ns3/ipv4-header.h"
16#include "ns3/ipv6-header.h"
17#include "ns3/llc-snap-header.h"
18#include "ns3/node.h"
19#include "ns3/packet-burst.h"
20#include "ns3/packet.h"
21#include "ns3/pointer.h"
22#include "ns3/simulator.h"
23#include "ns3/trace-source-accessor.h"
24#include "ns3/uinteger.h"
25#include <ns3/ipv4-l3-protocol.h>
26#include <ns3/ipv6-l3-protocol.h>
27#include <ns3/log.h>
28
29namespace ns3
30{
31
32NS_LOG_COMPONENT_DEFINE("LteNetDevice");
33
34NS_OBJECT_ENSURE_REGISTERED(LteNetDevice);
35
36////////////////////////////////
37// LteNetDevice
38////////////////////////////////
39
40TypeId
42{
43 static TypeId tid =
44 TypeId("ns3::LteNetDevice")
46
47 .AddAttribute("Mtu",
48 "The MAC-level Maximum Transmission Unit",
49 UintegerValue(30000),
52 return tid;
53}
54
59
64
65void
67{
68 NS_LOG_FUNCTION(this);
69
70 m_node = nullptr;
72}
73
76{
77 NS_LOG_FUNCTION(this);
78 // we can't return a meaningful channel here, because LTE devices using FDD have actually two
79 // channels.
80 return nullptr;
81}
82
83void
85{
86 NS_LOG_FUNCTION(this << address);
88}
89
92{
93 NS_LOG_FUNCTION(this);
94 return m_address;
95}
96
97void
99{
100 NS_LOG_FUNCTION(this << node);
101 m_node = node;
102}
103
106{
107 NS_LOG_FUNCTION(this);
108 return m_node;
109}
110
111void
117
118bool
120 const Address& source,
121 const Address& dest,
122 uint16_t protocolNumber)
123{
124 NS_FATAL_ERROR("SendFrom () not supported");
125 return false;
126}
127
128bool
130{
131 NS_LOG_FUNCTION(this);
132 return false;
133}
134
135bool
136LteNetDevice::SetMtu(const uint16_t mtu)
137{
138 NS_LOG_FUNCTION(this << mtu);
139 m_mtu = mtu;
140 return true;
141}
142
143uint16_t
145{
146 NS_LOG_FUNCTION(this);
147 return m_mtu;
148}
149
150void
152{
153 NS_LOG_FUNCTION(this << index);
154 m_ifIndex = index;
155}
156
159{
160 NS_LOG_FUNCTION(this);
161 return m_ifIndex;
162}
163
164bool
166{
167 NS_LOG_FUNCTION(this);
168 return m_linkUp;
169}
170
171bool
173{
174 NS_LOG_FUNCTION(this);
175 return true;
176}
177
184
185bool
187{
188 NS_LOG_FUNCTION(this);
189 return false;
190}
191
192bool
194{
195 NS_LOG_FUNCTION(this);
196 return false;
197}
198
199bool
201{
202 NS_LOG_FUNCTION(this);
203 return false;
204}
205
206bool
208{
209 NS_LOG_FUNCTION(this);
210 return false;
211}
212
215{
216 NS_LOG_FUNCTION(this << multicastGroup);
217
218 Mac48Address ad = Mac48Address::GetMulticast(multicastGroup);
219
220 //
221 // Implicit conversion (operator Address ()) is defined for Mac48Address, so
222 // use it by just returning the EUI-48 address which is automatically converted
223 // to an Address.
224 //
225 NS_LOG_LOGIC("multicast address is " << ad);
226
227 return ad;
228}
229
232{
233 NS_LOG_FUNCTION(this << addr);
235
236 NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad);
237 return ad;
238}
239
240void
246
247void
249{
250 NS_LOG_FUNCTION(this);
251 NS_LOG_WARN("Promisc mode not supported");
252}
253
254void
256{
257 NS_LOG_FUNCTION(this << p);
258
259 Ipv4Header ipv4Header;
260 Ipv6Header ipv6Header;
261
262 if (p->PeekHeader(ipv4Header) != 0)
263 {
264 NS_LOG_LOGIC("IPv4 stack...");
266 }
267 else if (p->PeekHeader(ipv6Header) != 0)
268 {
269 NS_LOG_LOGIC("IPv6 stack...");
271 }
272 else
273 {
274 NS_ABORT_MSG("LteNetDevice::Receive - Unknown IP type...");
275 }
276}
277} // namespace ns3
a polymophic address class
Definition address.h:90
Ipv4 addresses are stored in host order in this class.
Packet header for IPv4.
Definition ipv4-header.h:23
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Describes an IPv6 address.
Packet header for IPv6.
Definition ipv6-header.h:24
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
static Mac48Address GetMulticast(Ipv4Address address)
static Mac48Address GetBroadcast()
static Mac64Address ConvertFrom(const Address &address)
Network layer to device interface.
Definition net-device.h:87
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#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:250
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35