A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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/lte-radio-bearer-tag.h>
36 #include <ns3/ipv4-l3-protocol.h>
37 #include <ns3/log.h>
38 
39 NS_LOG_COMPONENT_DEFINE ("LteNetDevice");
40 
41 namespace ns3 {
42 
43 NS_OBJECT_ENSURE_REGISTERED ( LteNetDevice);
44 
46 // LteNetDevice
48 
50 {
51  static TypeId
52  tid =
53  TypeId ("ns3::LteNetDevice")
54 
55  .SetParent<NetDevice> ()
56 
57  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
58  UintegerValue (30000),
59  MakeUintegerAccessor (&LteNetDevice::SetMtu,
61  MakeUintegerChecker<uint16_t> ())
62  ;
63  return tid;
64 }
65 
67 {
68  NS_LOG_FUNCTION (this);
69 }
70 
71 
73 {
74  NS_LOG_FUNCTION (this);
75 }
76 
77 
78 void
80 {
81  NS_LOG_FUNCTION (this);
82 
83  m_node = 0;
85 }
86 
87 
90 {
91  NS_LOG_FUNCTION (this);
92  // we can't return a meaningful channel here, because LTE devices using FDD have actually two channels.
93  return 0;
94 }
95 
96 
97 void
99 {
100  NS_LOG_FUNCTION (this << address);
102 }
103 
104 
105 Address
107 {
108  NS_LOG_FUNCTION (this);
109  return m_address;
110 }
111 
112 
113 void
115 {
116  NS_LOG_FUNCTION (this << node);
117  m_node = node;
118 }
119 
120 
121 Ptr<Node>
123 {
124  NS_LOG_FUNCTION (this);
125  return m_node;
126 }
127 
128 
129 void
131 {
132  NS_LOG_FUNCTION (this);
133  m_rxCallback = cb;
134 }
135 
136 
137 bool
138 LteNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
139 {
140  NS_FATAL_ERROR ("SendFrom () not supported");
141  return false;
142 }
143 
144 
145 bool
147 {
148  NS_LOG_FUNCTION (this);
149  return false;
150 }
151 
152 
153 
154 bool
155 LteNetDevice::SetMtu (const uint16_t mtu)
156 {
157  NS_LOG_FUNCTION (this << mtu);
158  m_mtu = mtu;
159  return true;
160 }
161 
162 uint16_t
164 {
165  NS_LOG_FUNCTION (this);
166  return m_mtu;
167 }
168 
169 
170 void
171 LteNetDevice::SetIfIndex (const uint32_t index)
172 {
173  NS_LOG_FUNCTION (this << index);
174  m_ifIndex = index;
175 }
176 
177 uint32_t
179 {
180  NS_LOG_FUNCTION (this);
181  return m_ifIndex;
182 }
183 
184 
185 bool
187 {
188  NS_LOG_FUNCTION (this);
189  return m_linkUp;
190 }
191 
192 
193 bool
195 {
196  NS_LOG_FUNCTION (this);
197  return true;
198 }
199 
200 Address
202 {
203  NS_LOG_FUNCTION (this);
204  return Mac48Address::GetBroadcast ();
205 }
206 
207 bool
209 {
210  NS_LOG_FUNCTION (this);
211  return false;
212 }
213 
214 
215 bool
217 {
218  NS_LOG_FUNCTION (this);
219  return false;
220 }
221 
222 
223 bool
225 {
226  NS_LOG_FUNCTION (this);
227  return false;
228 }
229 
230 
231 bool
233 {
234  NS_LOG_FUNCTION (this);
235  return false;
236 }
237 
238 Address
240 {
241  NS_LOG_FUNCTION (this << multicastGroup);
242 
243  Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
244 
245  //
246  // Implicit conversion (operator Address ()) is defined for Mac48Address, so
247  // use it by just returning the EUI-48 address which is automagically converted
248  // to an Address.
249  //
250  NS_LOG_LOGIC ("multicast address is " << ad);
251 
252  return ad;
253 }
254 
255 Address
257 {
258  NS_LOG_FUNCTION (this << addr);
260 
261  NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad);
262  return ad;
263 }
264 
265 void
267 {
268  NS_LOG_FUNCTION (this);
270 }
271 
272 
273 void
275 {
276  NS_LOG_FUNCTION (this);
277  NS_LOG_WARN ("Promisc mode not supported");
278 }
279 
280 
281 
282 void
284 {
285  NS_LOG_FUNCTION (this << p);
287 }
288 
289 
290 }
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual bool IsLinkUp(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual void SetNode(Ptr< Node > node)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:335
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
virtual Address GetBroadcast(void) const
a polymophic address class
Definition: address.h:86
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:46
NetDevice::ReceiveCallback m_rxCallback
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)
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
Ptr< Node > m_node
static Mac48Address ConvertFrom(const Address &address)
virtual uint16_t GetMtu(void) const
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:41
virtual bool IsBroadcast(void) const
virtual Address GetAddress(void) const
TracedCallback m_linkChangeCallbacks
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 ...
virtual ~LteNetDevice(void)
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
void ConnectWithoutContext(const CallbackBase &callback)
Network layer to device interface.
Definition: net-device.h:75
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:203
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SetMtu(const uint16_t mtu)
tuple address
Definition: first.py:37
Mac48Address m_address
virtual Ptr< Channel > GetChannel(void) const
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
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)