A Discrete-Event Network Simulator
API
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/ipv6-header.h"
36#include <ns3/lte-radio-bearer-tag.h>
37#include <ns3/ipv4-l3-protocol.h>
38#include <ns3/ipv6-l3-protocol.h>
39#include <ns3/log.h>
40
41namespace ns3 {
42
43NS_LOG_COMPONENT_DEFINE ("LteNetDevice");
44
45NS_OBJECT_ENSURE_REGISTERED (LteNetDevice);
46
48// LteNetDevice
50
52{
53 static TypeId tid = TypeId ("ns3::LteNetDevice")
55
56 .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
57 UintegerValue (30000),
60 MakeUintegerChecker<uint16_t> ())
61 ;
62 return tid;
63}
64
66{
67 NS_LOG_FUNCTION (this);
68}
69
70
72{
73 NS_LOG_FUNCTION (this);
74}
75
76
77void
79{
80 NS_LOG_FUNCTION (this);
81
82 m_node = 0;
84}
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 channels.
92 return 0;
93}
94
95
96void
98{
99 NS_LOG_FUNCTION (this << address);
101}
102
103
106{
107 NS_LOG_FUNCTION (this);
108 return m_address;
109}
110
111void
113{
114 NS_LOG_FUNCTION (this << node);
115 m_node = node;
116}
117
118
121{
122 NS_LOG_FUNCTION (this);
123 return m_node;
124}
125
126
127void
129{
130 NS_LOG_FUNCTION (this);
131 m_rxCallback = cb;
132}
133
134
135bool
136LteNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
137{
138 NS_FATAL_ERROR ("SendFrom () not supported");
139 return false;
140}
141
142
143bool
145{
146 NS_LOG_FUNCTION (this);
147 return false;
148}
149
150
151
152bool
153LteNetDevice::SetMtu (const uint16_t mtu)
154{
155 NS_LOG_FUNCTION (this << mtu);
156 m_mtu = mtu;
157 return true;
158}
159
160uint16_t
162{
163 NS_LOG_FUNCTION (this);
164 return m_mtu;
165}
166
167
168void
170{
171 NS_LOG_FUNCTION (this << index);
172 m_ifIndex = index;
173}
174
177{
178 NS_LOG_FUNCTION (this);
179 return m_ifIndex;
180}
181
182
183bool
185{
186 NS_LOG_FUNCTION (this);
187 return m_linkUp;
188}
189
190
191bool
193{
194 NS_LOG_FUNCTION (this);
195 return true;
196}
197
200{
201 NS_LOG_FUNCTION (this);
203}
204
205bool
207{
208 NS_LOG_FUNCTION (this);
209 return false;
210}
211
212
213bool
215{
216 NS_LOG_FUNCTION (this);
217 return false;
218}
219
220
221bool
223{
224 NS_LOG_FUNCTION (this);
225 return false;
226}
227
228
229bool
231{
232 NS_LOG_FUNCTION (this);
233 return false;
234}
235
238{
239 NS_LOG_FUNCTION (this << multicastGroup);
240
241 Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
242
243 //
244 // Implicit conversion (operator Address ()) is defined for Mac48Address, so
245 // use it by just returning the EUI-48 address which is automatically converted
246 // to an Address.
247 //
248 NS_LOG_LOGIC ("multicast address is " << ad);
249
250 return ad;
251}
252
255{
256 NS_LOG_FUNCTION (this << addr);
258
259 NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad);
260 return ad;
261}
262
263void
265{
266 NS_LOG_FUNCTION (this);
268}
269
270void
272{
273 NS_LOG_FUNCTION (this);
274 NS_LOG_WARN ("Promisc mode not supported");
275}
276
277void
279{
280 NS_LOG_FUNCTION (this << p);
281
282 Ipv4Header ipv4Header;
283 Ipv6Header ipv6Header;
284
285 if (p->PeekHeader (ipv4Header) != 0)
286 {
287 NS_LOG_LOGIC ("IPv4 stack...");
289 }
290 else if (p->PeekHeader (ipv6Header) != 0)
291 {
292 NS_LOG_LOGIC ("IPv6 stack...");
294 }
295 else
296 {
297 NS_ABORT_MSG ("LteNetDevice::Receive - Unknown IP type...");
298 }
299}
300}
a polymophic address class
Definition: address.h:91
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
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).
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual bool SetMtu(const uint16_t mtu)
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
virtual uint32_t GetIfIndex(void) const
void Receive(Ptr< Packet > p)
receive a packet from the lower layers in order to forward it to the upper layers
virtual void DoDispose(void)
Destructor implementation.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
NetDevice::ReceiveCallback m_rxCallback
receive callback
virtual bool IsMulticast(void) const
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual uint16_t GetMtu(void) const
virtual bool IsBroadcast(void) const
TracedCallback m_linkChangeCallbacks
link change callback
virtual Ptr< Node > GetNode(void) const
virtual void SetAddress(Address address)
Set the address of this interface.
virtual Ptr< Channel > GetChannel(void) const
static TypeId GetTypeId(void)
Get the type ID.
virtual void SetNode(Ptr< Node > node)
virtual ~LteNetDevice(void)
virtual void AddLinkChangeCallback(Callback< void > callback)
Mac64Address m_address
MAC address - only relevant for UEs.
uint16_t m_mtu
MTU.
virtual void SetIfIndex(const uint32_t index)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
uint32_t m_ifIndex
interface index
Ptr< Node > m_node
the node
virtual Address GetAddress(void) const
virtual bool IsLinkUp(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SupportsSendFrom(void) const
virtual Address GetBroadcast(void) const
bool m_linkUp
link uo
virtual bool NeedsArp(void) const
an EUI-48 address
Definition: mac48-address.h:44
static Mac48Address GetMulticast(Ipv4Address address)
static Mac48Address GetBroadcast(void)
static Mac64Address ConvertFrom(const Address &address)
Network layer to device interface.
Definition: net-device.h:96
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#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:265
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.