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  ;
45 
47 // LteNetDevice
49 
51 {
52  static TypeId
53  tid =
54  TypeId ("ns3::LteNetDevice")
55 
56  .SetParent<NetDevice> ()
57 
58  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
59  UintegerValue (30000),
60  MakeUintegerAccessor (&LteNetDevice::SetMtu,
62  MakeUintegerChecker<uint16_t> ())
63  ;
64  return tid;
65 }
66 
68 {
69  NS_LOG_FUNCTION (this);
70 }
71 
72 
74 {
75  NS_LOG_FUNCTION (this);
76 }
77 
78 
79 void
81 {
82  NS_LOG_FUNCTION (this);
83 
84  m_node = 0;
86 }
87 
88 
91 {
92  NS_LOG_FUNCTION (this);
93  // we can't return a meaningful channel here, because LTE devices using FDD have actually two channels.
94  return 0;
95 }
96 
97 
98 void
100 {
101  NS_LOG_FUNCTION (this << address);
103 }
104 
105 
106 Address
108 {
109  NS_LOG_FUNCTION (this);
110  return m_address;
111 }
112 
113 
114 void
116 {
117  NS_LOG_FUNCTION (this << node);
118  m_node = node;
119 }
120 
121 
122 Ptr<Node>
124 {
125  NS_LOG_FUNCTION (this);
126  return m_node;
127 }
128 
129 
130 void
132 {
133  NS_LOG_FUNCTION (this);
134  m_rxCallback = cb;
135 }
136 
137 
138 bool
139 LteNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
140 {
141  NS_FATAL_ERROR ("SendFrom () not supported");
142  return false;
143 }
144 
145 
146 bool
148 {
149  NS_LOG_FUNCTION (this);
150  return false;
151 }
152 
153 
154 
155 bool
156 LteNetDevice::SetMtu (const uint16_t mtu)
157 {
158  NS_LOG_FUNCTION (this << mtu);
159  m_mtu = mtu;
160  return true;
161 }
162 
163 uint16_t
165 {
166  NS_LOG_FUNCTION (this);
167  return m_mtu;
168 }
169 
170 
171 void
172 LteNetDevice::SetIfIndex (const uint32_t index)
173 {
174  NS_LOG_FUNCTION (this << index);
175  m_ifIndex = index;
176 }
177 
178 uint32_t
180 {
181  NS_LOG_FUNCTION (this);
182  return m_ifIndex;
183 }
184 
185 
186 bool
188 {
189  NS_LOG_FUNCTION (this);
190  return m_linkUp;
191 }
192 
193 
194 bool
196 {
197  NS_LOG_FUNCTION (this);
198  return true;
199 }
200 
201 Address
203 {
204  NS_LOG_FUNCTION (this);
205  return Mac48Address::GetBroadcast ();
206 }
207 
208 bool
210 {
211  NS_LOG_FUNCTION (this);
212  return false;
213 }
214 
215 
216 bool
218 {
219  NS_LOG_FUNCTION (this);
220  return false;
221 }
222 
223 
224 bool
226 {
227  NS_LOG_FUNCTION (this);
228  return false;
229 }
230 
231 
232 bool
234 {
235  NS_LOG_FUNCTION (this);
236  return false;
237 }
238 
239 Address
241 {
242  NS_LOG_FUNCTION (this << multicastGroup);
243 
244  Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
245 
246  //
247  // Implicit conversion (operator Address ()) is defined for Mac48Address, so
248  // use it by just returning the EUI-48 address which is automagically converted
249  // to an Address.
250  //
251  NS_LOG_LOGIC ("multicast address is " << ad);
252 
253  return ad;
254 }
255 
256 Address
258 {
259  NS_LOG_FUNCTION (this << addr);
261 
262  NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad);
263  return ad;
264 }
265 
266 void
268 {
269  NS_LOG_FUNCTION (this);
271 }
272 
273 
274 void
276 {
277  NS_LOG_FUNCTION (this);
278  NS_LOG_WARN ("Promisc mode not supported");
279 }
280 
281 
282 
283 void
285 {
286  NS_LOG_FUNCTION (this << p);
288 }
289 
290 
291 }
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
virtual bool IsLinkUp(void) const
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)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:336
virtual Address GetMulticast(Ipv4Address addr) const
Make and return a MAC multicast address using the provided multicast group.
virtual Address GetBroadcast(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
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)
Definition: log.h:368
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)
Definition: log.h:280
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
NS_LOG_COMPONENT_DEFINE("LteNetDevice")
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
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)