A Discrete-Event Network Simulator
API
lte-ue-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  * Marco Miozzo <mmiozzo@cttc.es>
21  * Modified by:
22  * Danilo Abrignani <danilo.abrignani@unibo.it> (Carrier Aggregation - GSoC 2015)
23  * Biljana Bojovic <biljana.bojovic@cttc.es> (Carrier Aggregation)
24  */
25 
26 #include "ns3/llc-snap-header.h"
27 #include "ns3/simulator.h"
28 #include "ns3/callback.h"
29 #include "ns3/node.h"
30 #include "ns3/packet.h"
31 #include "lte-net-device.h"
32 #include "ns3/packet-burst.h"
33 #include "ns3/uinteger.h"
34 #include "ns3/trace-source-accessor.h"
35 #include "ns3/pointer.h"
36 #include "ns3/enum.h"
37 #include "ns3/lte-enb-net-device.h"
38 #include "lte-ue-net-device.h"
39 #include "lte-ue-mac.h"
40 #include "lte-ue-rrc.h"
41 #include "ns3/ipv4-header.h"
42 #include "ns3/ipv4.h"
43 #include "lte-amc.h"
44 #include "lte-ue-phy.h"
45 #include "epc-ue-nas.h"
46 #include <ns3/ipv4-l3-protocol.h>
47 #include <ns3/log.h>
48 #include "epc-tft.h"
49 #include <ns3/lte-ue-component-carrier-manager.h>
50 #include <ns3/object-map.h>
51 #include <ns3/object-factory.h>
52 
53 namespace ns3 {
54 
55 NS_LOG_COMPONENT_DEFINE ("LteUeNetDevice");
56 
57 NS_OBJECT_ENSURE_REGISTERED ( LteUeNetDevice);
58 
59 
61 {
62  static TypeId
63  tid =
64  TypeId ("ns3::LteUeNetDevice")
66  .AddConstructor<LteUeNetDevice> ()
67  .AddAttribute ("EpcUeNas",
68  "The NAS associated to this UeNetDevice",
69  PointerValue (),
71  MakePointerChecker <EpcUeNas> ())
72  .AddAttribute ("LteUeRrc",
73  "The RRC associated to this UeNetDevice",
74  PointerValue (),
76  MakePointerChecker <LteUeRrc> ())
77  .AddAttribute ("LteUeComponentCarrierManager",
78  "The ComponentCarrierManager associated to this UeNetDevice",
79  PointerValue (),
81  MakePointerChecker <LteUeComponentCarrierManager> ())
82  .AddAttribute ("ComponentCarrierMapUe", "List of all component Carrier.",
83  ObjectMapValue (),
85  MakeObjectMapChecker<ComponentCarrierUe> ())
86  .AddAttribute ("Imsi",
87  "International Mobile Subscriber Identity assigned to this UE",
88  UintegerValue (0),
90  MakeUintegerChecker<uint64_t> ())
91  .AddAttribute ("DlEarfcn",
92  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
93  "as per 3GPP 36.101 Section 5.7.3. ",
94  UintegerValue (100),
97  MakeUintegerChecker<uint32_t> (0, 262143))
98  .AddAttribute ("CsgId",
99  "The Closed Subscriber Group (CSG) identity that this UE is associated with, "
100  "i.e., giving the UE access to cells which belong to this particular CSG. "
101  "This restriction only applies to initial cell selection and EPC-enabled simulation. "
102  "This does not revoke the UE's access to non-CSG cells. ",
103  UintegerValue (0),
106  MakeUintegerChecker<uint32_t> ())
107  ;
108 
109  return tid;
110 }
111 
112 
114  : m_isConstructed (false)
115 {
116  NS_LOG_FUNCTION (this);
117 }
118 
120 {
121  NS_LOG_FUNCTION (this);
122 }
123 
124 void
126 {
127  NS_LOG_FUNCTION (this);
128  m_targetEnb = 0;
129 
130  m_rrc->Dispose ();
131  m_rrc = 0;
132 
133  m_nas->Dispose ();
134  m_nas = 0;
135  for (uint32_t i = 0; i < m_ccMap.size (); i++)
136  {
137  m_ccMap.at (i)->Dispose ();
138  }
139  m_componentCarrierManager->Dispose ();
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION (this);
147 
148  if (m_isConstructed)
149  {
150  NS_LOG_LOGIC (this << " Updating configuration: IMSI " << m_imsi
151  << " CSG ID " << m_csgId);
152  m_nas->SetImsi (m_imsi);
153  m_rrc->SetImsi (m_imsi);
154  m_nas->SetCsgId (m_csgId); // this also handles propagation to RRC
155  }
156  else
157  {
158  /*
159  * NAS and RRC instances are not be ready yet, so do nothing now and
160  * expect ``DoInitialize`` to re-invoke this function.
161  */
162  }
163 }
164 
165 
166 
169 {
170  NS_LOG_FUNCTION (this);
171  return m_ccMap.at (0)->GetMac ();
172 }
173 
174 
177 {
178  NS_LOG_FUNCTION (this);
179  return m_rrc;
180 }
181 
182 
185 {
186  NS_LOG_FUNCTION (this);
187  return m_ccMap.at (0)->GetPhy ();
188 }
189 
192 {
193  NS_LOG_FUNCTION (this);
195 }
196 
199 {
200  NS_LOG_FUNCTION (this);
201  return m_nas;
202 }
203 
204 uint64_t
206 {
207  NS_LOG_FUNCTION (this);
208  return m_imsi;
209 }
210 
211 uint32_t
213 {
214  NS_LOG_FUNCTION (this);
215  return m_dlEarfcn;
216 }
217 
218 void
220 {
221  NS_LOG_FUNCTION (this << earfcn);
222  m_dlEarfcn = earfcn;
223 }
224 
225 uint32_t
227 {
228  NS_LOG_FUNCTION (this);
229  return m_csgId;
230 }
231 
232 void
233 LteUeNetDevice::SetCsgId (uint32_t csgId)
234 {
235  NS_LOG_FUNCTION (this << csgId);
236  m_csgId = csgId;
237  UpdateConfig (); // propagate the change down to NAS and RRC
238 }
239 
240 void
242 {
243  NS_LOG_FUNCTION (this << enb);
244  m_targetEnb = enb;
245 }
246 
247 
250 {
251  NS_LOG_FUNCTION (this);
252  return m_targetEnb;
253 }
254 
255 std::map < uint8_t, Ptr<ComponentCarrierUe> >
257 {
258  return m_ccMap;
259 }
260 
261 void
263 {
264  m_ccMap = ccm;
265 }
266 
267 void
269 {
270  NS_LOG_FUNCTION (this);
271  m_isConstructed = true;
272  UpdateConfig ();
273 
274  std::map< uint8_t, Ptr<ComponentCarrierUe> >::iterator it;
275  for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
276  {
277  it->second->GetPhy ()->Initialize ();
278  it->second->GetMac ()->Initialize ();
279  }
280  m_rrc->Initialize ();
281 }
282 
283 bool
284 LteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
285 {
286  NS_LOG_FUNCTION (this << dest << protocolNumber);
287  if (protocolNumber != Ipv4L3Protocol::PROT_NUMBER)
288  {
289  NS_LOG_INFO ("unsupported protocol " << protocolNumber << ", only IPv4 is supported");
290  return true;
291  }
292  return m_nas->Send (packet);
293 }
294 
295 
296 } // namespace ns3
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 "...
Ptr< LteUeRrc > m_rrc
the RRC
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
virtual ~LteUeNetDevice(void)
virtual void DoDispose(void)
Destructor implementation.
Ptr< LteUeRrc > GetRrc() const
Get the RRC.
uint64_t GetImsi() const
Get the IMSI.
std::map< uint8_t, Ptr< ComponentCarrierUe > > GetCcMap(void)
Get the ComponentCarrier Map for the UE.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Ptr< LteEnbNetDevice > m_targetEnb
target ENB
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:277
uint64_t m_imsi
the IMSI
uint32_t m_csgId
the CSG ID
std::map< uint8_t, Ptr< ComponentCarrierUe > > m_ccMap
CC map.
a polymophic address class
Definition: address.h:90
Ptr< EpcUeNas > m_nas
the NAS
static TypeId GetTypeId(void)
Get the type ID.
virtual void DoDispose()
Destructor implementation.
Ptr< LteUeComponentCarrierManager > GetComponentCarrierManager(void) const
Get the componentn carrier manager.
void SetTargetEnb(Ptr< LteEnbNetDevice > enb)
Set the targer eNB where the UE is registered.
virtual void DoInitialize(void)
Initialize() implementation.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
Hold an unsigned integer type.
Definition: uinteger.h:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetCsgId(uint32_t csgId)
Enlist the UE device as a member of a particular CSG.
uint32_t m_dlEarfcn
downlink carrier frequency
Hold objects of type Ptr.
Definition: pointer.h:36
void SetDlEarfcn(uint32_t earfcn)
Ptr< LteEnbNetDevice > GetTargetEnb(void)
Get the targer eNB where the UE is registered.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Ptr< EpcUeNas > GetNas(void) const
Get the NAS.
uint32_t GetDlEarfcn() const
void SetCcMap(std::map< uint8_t, Ptr< ComponentCarrierUe > > ccm)
Set the ComponentCarrier Map for the UE.
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-map.h:80
Container for a set of ns3::Object pointers.
Ptr< LteUePhy > GetPhy(void) const
Get the Phy.
LteNetDevice provides basic implementation for all LTE network devices.
uint32_t GetCsgId() const
Returns the CSG ID the UE is currently a member of.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
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
Ptr< LteUeMac > GetMac(void) const
Get the MAC.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
bool m_isConstructed
is constructed?
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
Ptr< LteUeComponentCarrierManager > m_componentCarrierManager
the component carrier manager