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 "ns3/callback.h"
24 #include "ns3/channel.h"
25 #include "ns3/enum.h"
26 #include "ns3/ipv4-header.h"
27 #include "ns3/ipv6-header.h"
28 #include "ns3/llc-snap-header.h"
29 #include "ns3/node.h"
30 #include "ns3/packet-burst.h"
31 #include "ns3/packet.h"
32 #include "ns3/pointer.h"
33 #include "ns3/simulator.h"
34 #include "ns3/trace-source-accessor.h"
35 #include "ns3/uinteger.h"
36 #include <ns3/ipv4-l3-protocol.h>
37 #include <ns3/ipv6-l3-protocol.h>
38 #include <ns3/log.h>
39 
40 namespace ns3
41 {
42 
43 NS_LOG_COMPONENT_DEFINE("LteNetDevice");
44 
45 NS_OBJECT_ENSURE_REGISTERED(LteNetDevice);
46 
48 // LteNetDevice
50 
51 TypeId
53 {
54  static TypeId tid =
55  TypeId("ns3::LteNetDevice")
57 
58  .AddAttribute("Mtu",
59  "The MAC-level Maximum Transmission Unit",
60  UintegerValue(30000),
62  MakeUintegerChecker<uint16_t>());
63  return tid;
64 }
65 
67 {
68  NS_LOG_FUNCTION(this);
69 }
70 
72 {
73  NS_LOG_FUNCTION(this);
74 }
75 
76 void
78 {
79  NS_LOG_FUNCTION(this);
80 
81  m_node = nullptr;
83 }
84 
87 {
88  NS_LOG_FUNCTION(this);
89  // we can't return a meaningful channel here, because LTE devices using FDD have actually two
90  // channels.
91  return nullptr;
92 }
93 
94 void
96 {
97  NS_LOG_FUNCTION(this << address);
99 }
100 
101 Address
103 {
104  NS_LOG_FUNCTION(this);
105  return m_address;
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION(this << node);
112  m_node = node;
113 }
114 
115 Ptr<Node>
117 {
118  NS_LOG_FUNCTION(this);
119  return m_node;
120 }
121 
122 void
124 {
125  NS_LOG_FUNCTION(this);
126  m_rxCallback = cb;
127 }
128 
129 bool
131  const Address& source,
132  const Address& dest,
133  uint16_t protocolNumber)
134 {
135  NS_FATAL_ERROR("SendFrom () not supported");
136  return false;
137 }
138 
139 bool
141 {
142  NS_LOG_FUNCTION(this);
143  return false;
144 }
145 
146 bool
147 LteNetDevice::SetMtu(const uint16_t mtu)
148 {
149  NS_LOG_FUNCTION(this << mtu);
150  m_mtu = mtu;
151  return true;
152 }
153 
154 uint16_t
156 {
157  NS_LOG_FUNCTION(this);
158  return m_mtu;
159 }
160 
161 void
162 LteNetDevice::SetIfIndex(const uint32_t index)
163 {
164  NS_LOG_FUNCTION(this << index);
165  m_ifIndex = index;
166 }
167 
168 uint32_t
170 {
171  NS_LOG_FUNCTION(this);
172  return m_ifIndex;
173 }
174 
175 bool
177 {
178  NS_LOG_FUNCTION(this);
179  return m_linkUp;
180 }
181 
182 bool
184 {
185  NS_LOG_FUNCTION(this);
186  return true;
187 }
188 
189 Address
191 {
192  NS_LOG_FUNCTION(this);
194 }
195 
196 bool
198 {
199  NS_LOG_FUNCTION(this);
200  return false;
201 }
202 
203 bool
205 {
206  NS_LOG_FUNCTION(this);
207  return false;
208 }
209 
210 bool
212 {
213  NS_LOG_FUNCTION(this);
214  return false;
215 }
216 
217 bool
219 {
220  NS_LOG_FUNCTION(this);
221  return false;
222 }
223 
224 Address
226 {
227  NS_LOG_FUNCTION(this << multicastGroup);
228 
229  Mac48Address ad = Mac48Address::GetMulticast(multicastGroup);
230 
231  //
232  // Implicit conversion (operator Address ()) is defined for Mac48Address, so
233  // use it by just returning the EUI-48 address which is automatically converted
234  // to an Address.
235  //
236  NS_LOG_LOGIC("multicast address is " << ad);
237 
238  return ad;
239 }
240 
241 Address
243 {
244  NS_LOG_FUNCTION(this << addr);
246 
247  NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad);
248  return ad;
249 }
250 
251 void
253 {
254  NS_LOG_FUNCTION(this);
256 }
257 
258 void
260 {
261  NS_LOG_FUNCTION(this);
262  NS_LOG_WARN("Promisc mode not supported");
263 }
264 
265 void
267 {
268  NS_LOG_FUNCTION(this << p);
269 
270  Ipv4Header ipv4Header;
271  Ipv6Header ipv6Header;
272 
273  if (p->PeekHeader(ipv4Header) != 0)
274  {
275  NS_LOG_LOGIC("IPv4 stack...");
277  }
278  else if (p->PeekHeader(ipv6Header) != 0)
279  {
280  NS_LOG_LOGIC("IPv6 stack...");
282  }
283  else
284  {
285  NS_ABORT_MSG("LteNetDevice::Receive - Unknown IP type...");
286  }
287 }
288 } // namespace ns3
a polymophic address class
Definition: address.h:101
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
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:49
Packet header for IPv6.
Definition: ipv6-header.h:35
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:352
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:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#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:46
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46