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 
41 namespace ns3 {
42 
43 NS_LOG_COMPONENT_DEFINE ("LteNetDevice");
44 
45 NS_OBJECT_ENSURE_REGISTERED (LteNetDevice);
46 
48 // LteNetDevice
50 
52 {
53  static TypeId tid = TypeId ("ns3::LteNetDevice")
54  .SetParent<NetDevice> ()
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 
77 void
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 
96 void
98 {
99  NS_LOG_FUNCTION (this << address);
101 }
102 
103 
104 Address
106 {
107  NS_LOG_FUNCTION (this);
108  return m_address;
109 }
110 
111 void
113 {
114  NS_LOG_FUNCTION (this << node);
115  m_node = node;
116 }
117 
118 
119 Ptr<Node>
121 {
122  NS_LOG_FUNCTION (this);
123  return m_node;
124 }
125 
126 
127 void
129 {
130  NS_LOG_FUNCTION (this);
131  m_rxCallback = cb;
132 }
133 
134 
135 bool
136 LteNetDevice::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 
143 bool
145 {
146  NS_LOG_FUNCTION (this);
147  return false;
148 }
149 
150 
151 
152 bool
153 LteNetDevice::SetMtu (const uint16_t mtu)
154 {
155  NS_LOG_FUNCTION (this << mtu);
156  m_mtu = mtu;
157  return true;
158 }
159 
160 uint16_t
162 {
163  NS_LOG_FUNCTION (this);
164  return m_mtu;
165 }
166 
167 
168 void
169 LteNetDevice::SetIfIndex (const uint32_t index)
170 {
171  NS_LOG_FUNCTION (this << index);
172  m_ifIndex = index;
173 }
174 
175 uint32_t
177 {
178  NS_LOG_FUNCTION (this);
179  return m_ifIndex;
180 }
181 
182 
183 bool
185 {
186  NS_LOG_FUNCTION (this);
187  return m_linkUp;
188 }
189 
190 
191 bool
193 {
194  NS_LOG_FUNCTION (this);
195  return true;
196 }
197 
198 Address
200 {
201  NS_LOG_FUNCTION (this);
202  return Mac48Address::GetBroadcast ();
203 }
204 
205 bool
207 {
208  NS_LOG_FUNCTION (this);
209  return false;
210 }
211 
212 
213 bool
215 {
216  NS_LOG_FUNCTION (this);
217  return false;
218 }
219 
220 
221 bool
223 {
224  NS_LOG_FUNCTION (this);
225  return false;
226 }
227 
228 
229 bool
231 {
232  NS_LOG_FUNCTION (this);
233  return false;
234 }
235 
236 Address
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 
253 Address
255 {
256  NS_LOG_FUNCTION (this << addr);
258 
259  NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad);
260  return ad;
261 }
262 
263 void
265 {
266  NS_LOG_FUNCTION (this);
268 }
269 
270 void
272 {
273  NS_LOG_FUNCTION (this);
274  NS_LOG_WARN ("Promisc mode not supported");
275 }
276 
277 void
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 }
Packet header for IPv6.
Definition: ipv6-header.h:34
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Callback template class.
Definition: callback.h:1273
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
virtual void DoDispose(void)
Destructor implementation.
virtual void SetNode(Ptr< Node > node)
virtual Address GetAddress(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
virtual uint32_t GetIfIndex(void) const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
uint16_t m_mtu
MTU.
a polymophic address class
Definition: address.h:90
Packet header for IPv4.
Definition: ipv4-header.h:33
virtual void SetIfIndex(const uint32_t index)
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
static Mac48Address GetMulticast(Ipv4Address address)
virtual void SetAddress(Address address)
Set the address of this interface.
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual bool IsMulticast(void) const
NetDevice::ReceiveCallback m_rxCallback
receive callback
static Mac48Address GetBroadcast(void)
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
static TypeId GetTypeId(void)
Get the type ID.
virtual bool SupportsSendFrom(void) const
Ptr< Node > m_node
the node
Every class exported by the ns3 library is enclosed in the ns3 namespace.
address
Definition: first.py:44
an EUI-48 address
Definition: mac48-address.h:43
TracedCallback m_linkChangeCallbacks
link change callback
virtual void AddLinkChangeCallback(Callback< void > callback)
void Receive(Ptr< Packet > p)
receive a packet from the lower layers in order to forward it to the upper layers ...
Mac64Address m_address
MAC address - only relevant for UEs.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
bool m_linkUp
link uo
virtual ~LteNetDevice(void)
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
virtual Address GetBroadcast(void) const
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
static Mac64Address ConvertFrom(const Address &address)
Network layer to device interface.
Definition: net-device.h:95
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
virtual Ptr< Channel > GetChannel(void) const
virtual Ptr< Node > GetNode(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SetMtu(const uint16_t mtu)
uint32_t m_ifIndex
interface index
virtual bool IsBroadcast(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
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool NeedsArp(void) const
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
virtual bool IsLinkUp(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.