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
54  tid =
55  TypeId ("ns3::LteNetDevice")
56 
57  .SetParent<NetDevice> ()
58 
59  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
60  UintegerValue (30000),
63  MakeUintegerChecker<uint16_t> ())
64  ;
65  return tid;
66 }
67 
69 {
70  NS_LOG_FUNCTION (this);
71 }
72 
73 
75 {
76  NS_LOG_FUNCTION (this);
77 }
78 
79 
80 void
82 {
83  NS_LOG_FUNCTION (this);
84 
85  m_node = 0;
87 }
88 
89 
92 {
93  NS_LOG_FUNCTION (this);
94  // we can't return a meaningful channel here, because LTE devices using FDD have actually two channels.
95  return 0;
96 }
97 
98 
99 void
101 {
102  NS_LOG_FUNCTION (this << address);
104 }
105 
106 
107 Address
109 {
110  NS_LOG_FUNCTION (this);
111  return m_address;
112 }
113 
114 
115 void
117 {
118  NS_LOG_FUNCTION (this << node);
119  m_node = node;
120 }
121 
122 
123 Ptr<Node>
125 {
126  NS_LOG_FUNCTION (this);
127  return m_node;
128 }
129 
130 
131 void
133 {
134  NS_LOG_FUNCTION (this);
135  m_rxCallback = cb;
136 }
137 
138 
139 bool
140 LteNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
141 {
142  NS_FATAL_ERROR ("SendFrom () not supported");
143  return false;
144 }
145 
146 
147 bool
149 {
150  NS_LOG_FUNCTION (this);
151  return false;
152 }
153 
154 
155 
156 bool
157 LteNetDevice::SetMtu (const uint16_t mtu)
158 {
159  NS_LOG_FUNCTION (this << mtu);
160  m_mtu = mtu;
161  return true;
162 }
163 
164 uint16_t
166 {
167  NS_LOG_FUNCTION (this);
168  return m_mtu;
169 }
170 
171 
172 void
173 LteNetDevice::SetIfIndex (const uint32_t index)
174 {
175  NS_LOG_FUNCTION (this << index);
176  m_ifIndex = index;
177 }
178 
179 uint32_t
181 {
182  NS_LOG_FUNCTION (this);
183  return m_ifIndex;
184 }
185 
186 
187 bool
189 {
190  NS_LOG_FUNCTION (this);
191  return m_linkUp;
192 }
193 
194 
195 bool
197 {
198  NS_LOG_FUNCTION (this);
199  return true;
200 }
201 
202 Address
204 {
205  NS_LOG_FUNCTION (this);
206  return Mac48Address::GetBroadcast ();
207 }
208 
209 bool
211 {
212  NS_LOG_FUNCTION (this);
213  return false;
214 }
215 
216 
217 bool
219 {
220  NS_LOG_FUNCTION (this);
221  return false;
222 }
223 
224 
225 bool
227 {
228  NS_LOG_FUNCTION (this);
229  return false;
230 }
231 
232 
233 bool
235 {
236  NS_LOG_FUNCTION (this);
237  return false;
238 }
239 
240 Address
242 {
243  NS_LOG_FUNCTION (this << multicastGroup);
244 
245  Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
246 
247  //
248  // Implicit conversion (operator Address ()) is defined for Mac48Address, so
249  // use it by just returning the EUI-48 address which is automagically converted
250  // to an Address.
251  //
252  NS_LOG_LOGIC ("multicast address is " << ad);
253 
254  return ad;
255 }
256 
257 Address
259 {
260  NS_LOG_FUNCTION (this << addr);
262 
263  NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad);
264  return ad;
265 }
266 
267 void
269 {
270  NS_LOG_FUNCTION (this);
272 }
273 
274 
275 void
277 {
278  NS_LOG_FUNCTION (this);
279  NS_LOG_WARN ("Promisc mode not supported");
280 }
281 
282 
283 
284 void
286 {
287  NS_LOG_FUNCTION (this << p);
288  uint8_t ipType;
289 
290  p->CopyData (&ipType, 1);
291  ipType = (ipType>>4) & 0x0f;
292 
293  if (ipType == 0x04)
295  else if (ipType == 0x06)
297  else
298  NS_ABORT_MSG ("LteNetDevice::Receive - Unknown IP type...");
299 }
300 
301 
302 }
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 "...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
virtual bool IsLinkUp(void) const
#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)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
uint16_t m_mtu
MTU.
virtual Address GetBroadcast(void) const
a polymophic address class
Definition: address.h:90
virtual Ptr< Node > GetNode(void) const
virtual void SetIfIndex(const uint32_t index)
virtual uint32_t GetIfIndex(void) const
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
NetDevice::ReceiveCallback m_rxCallback
receive callback
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
static Mac48Address GetBroadcast(void)
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Node > m_node
the node
virtual uint16_t GetMtu(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual bool NeedsArp(void) const
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual bool IsMulticast(void) const
an EUI-48 address
Definition: mac48-address.h:43
virtual bool IsBroadcast(void) const
virtual Address GetAddress(void) const
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:40
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:261
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SetMtu(const uint16_t mtu)
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition: packet.cc:378
uint32_t m_ifIndex
interface index
tuple address
Definition: first.py:37
virtual Ptr< Channel > GetChannel(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:914
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 SupportsSendFrom(void) const
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)