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/ipv6-header.h"
43#include "ns3/ipv4.h"
44#include "ns3/ipv6.h"
45#include "lte-amc.h"
46#include "lte-ue-phy.h"
47#include "epc-ue-nas.h"
48#include <ns3/ipv4-l3-protocol.h>
49#include <ns3/ipv6-l3-protocol.h>
50#include <ns3/log.h>
51#include "epc-tft.h"
52#include <ns3/lte-ue-component-carrier-manager.h>
53#include <ns3/object-map.h>
54#include <ns3/object-factory.h>
55
56namespace ns3 {
57
58NS_LOG_COMPONENT_DEFINE ("LteUeNetDevice");
59
60NS_OBJECT_ENSURE_REGISTERED ( LteUeNetDevice);
61
62
64{
65 static TypeId
66 tid =
67 TypeId ("ns3::LteUeNetDevice")
69 .AddConstructor<LteUeNetDevice> ()
70 .AddAttribute ("EpcUeNas",
71 "The NAS associated to this UeNetDevice",
72 PointerValue (),
74 MakePointerChecker <EpcUeNas> ())
75 .AddAttribute ("LteUeRrc",
76 "The RRC associated to this UeNetDevice",
77 PointerValue (),
79 MakePointerChecker <LteUeRrc> ())
80 .AddAttribute ("LteUeComponentCarrierManager",
81 "The ComponentCarrierManager associated to this UeNetDevice",
82 PointerValue (),
84 MakePointerChecker <LteUeComponentCarrierManager> ())
85 .AddAttribute ("ComponentCarrierMapUe", "List of all component Carrier.",
88 MakeObjectMapChecker<ComponentCarrierUe> ())
89 .AddAttribute ("Imsi",
90 "International Mobile Subscriber Identity assigned to this UE",
91 UintegerValue (0),
93 MakeUintegerChecker<uint64_t> ())
94 .AddAttribute ("DlEarfcn",
95 "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
96 "as per 3GPP 36.101 Section 5.7.3. ",
97 UintegerValue (100),
100 MakeUintegerChecker<uint32_t> (0, 262143))
101 .AddAttribute ("CsgId",
102 "The Closed Subscriber Group (CSG) identity that this UE is associated with, "
103 "i.e., giving the UE access to cells which belong to this particular CSG. "
104 "This restriction only applies to initial cell selection and EPC-enabled simulation. "
105 "This does not revoke the UE's access to non-CSG cells. ",
106 UintegerValue (0),
109 MakeUintegerChecker<uint32_t> ())
110 ;
111
112 return tid;
113}
114
115
117 : m_isConstructed (false)
118{
119 NS_LOG_FUNCTION (this);
120}
121
123{
124 NS_LOG_FUNCTION (this);
125}
126
127void
129{
130 NS_LOG_FUNCTION (this);
131 m_targetEnb = 0;
132
133 m_rrc->Dispose ();
134 m_rrc = 0;
135
136 m_nas->Dispose ();
137 m_nas = 0;
138 for (uint32_t i = 0; i < m_ccMap.size (); i++)
139 {
140 m_ccMap.at (i)->Dispose ();
141 }
142 m_componentCarrierManager->Dispose ();
144}
145
146void
148{
149 NS_LOG_FUNCTION (this);
150
151 if (m_isConstructed)
152 {
153 NS_LOG_LOGIC (this << " Updating configuration: IMSI " << m_imsi
154 << " CSG ID " << m_csgId);
155 m_nas->SetImsi (m_imsi);
156 m_rrc->SetImsi (m_imsi);
157 m_nas->SetCsgId (m_csgId); // this also handles propagation to RRC
158 }
159 else
160 {
161 /*
162 * NAS and RRC instances are not be ready yet, so do nothing now and
163 * expect ``DoInitialize`` to re-invoke this function.
164 */
165 }
166}
167
168
169
172{
173 NS_LOG_FUNCTION (this);
174 return m_ccMap.at (0)->GetMac ();
175}
176
177
180{
181 NS_LOG_FUNCTION (this);
182 return m_rrc;
183}
184
185
188{
189 NS_LOG_FUNCTION (this);
190 return m_ccMap.at (0)->GetPhy ();
191}
192
195{
196 NS_LOG_FUNCTION (this);
198}
199
202{
203 NS_LOG_FUNCTION (this);
204 return m_nas;
205}
206
207uint64_t
209{
210 NS_LOG_FUNCTION (this);
211 return m_imsi;
212}
213
216{
217 NS_LOG_FUNCTION (this);
218 return m_dlEarfcn;
219}
220
221void
223{
224 NS_LOG_FUNCTION (this << earfcn);
225 m_dlEarfcn = earfcn;
226}
227
230{
231 NS_LOG_FUNCTION (this);
232 return m_csgId;
233}
234
235void
237{
238 NS_LOG_FUNCTION (this << csgId);
239 m_csgId = csgId;
240 UpdateConfig (); // propagate the change down to NAS and RRC
241}
242
243void
245{
246 NS_LOG_FUNCTION (this << enb);
247 m_targetEnb = enb;
248}
249
250
253{
254 NS_LOG_FUNCTION (this);
255 return m_targetEnb;
256}
257
258std::map < uint8_t, Ptr<ComponentCarrierUe> >
260{
261 return m_ccMap;
262}
263
264void
266{
267 m_ccMap = ccm;
268}
269
270void
272{
273 NS_LOG_FUNCTION (this);
274 m_isConstructed = true;
275 UpdateConfig ();
276
277 std::map< uint8_t, Ptr<ComponentCarrierUe> >::iterator it;
278 for (it = m_ccMap.begin (); it != m_ccMap.end (); ++it)
279 {
280 it->second->GetPhy ()->Initialize ();
281 it->second->GetMac ()->Initialize ();
282 }
283 m_rrc->Initialize ();
284}
285
286bool
287LteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
288{
289 NS_LOG_FUNCTION (this << packet << dest << protocolNumber);
291 && protocolNumber != Ipv6L3Protocol::PROT_NUMBER,
292 "unsupported protocol " << protocolNumber << ", only IPv4 and IPv6 are supported");
293 return m_nas->Send (packet, protocolNumber);
294}
295
296
297} // namespace ns3
a polymophic address class
Definition: address.h:91
static const uint16_t PROT_NUMBER
Protocol number (0x0800)
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
LteNetDevice provides basic implementation for all LTE network devices.
virtual void DoDispose(void)
Destructor implementation.
Ptr< LteUeComponentCarrierManager > GetComponentCarrierManager(void) const
Get the componentn carrier manager.
uint32_t m_csgId
the CSG ID
Ptr< LteUeRrc > m_rrc
the RRC
uint64_t m_imsi
the IMSI
std::map< uint8_t, Ptr< ComponentCarrierUe > > m_ccMap
CC map.
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
Ptr< LteUePhy > GetPhy(void) const
Get the Phy.
std::map< uint8_t, Ptr< ComponentCarrierUe > > GetCcMap(void)
Get the ComponentCarrier Map for the UE.
virtual void DoInitialize(void)
Initialize() implementation.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< LteUeRrc > GetRrc() const
Get the RRC.
uint64_t GetImsi() const
Get the IMSI.
Ptr< LteEnbNetDevice > GetTargetEnb(void)
Get the target eNB where the UE is registered.
void SetCsgId(uint32_t csgId)
Enlist the UE device as a member of a particular CSG.
Ptr< LteUeMac > GetMac(void) const
Get the MAC.
Ptr< LteUeComponentCarrierManager > m_componentCarrierManager
the component carrier manager
uint32_t m_dlEarfcn
downlink carrier frequency
void SetDlEarfcn(uint32_t earfcn)
Ptr< EpcUeNas > m_nas
the NAS
virtual void DoDispose()
Destructor implementation.
void SetTargetEnb(Ptr< LteEnbNetDevice > enb)
Set the target eNB where the UE is registered.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void SetCcMap(std::map< uint8_t, Ptr< ComponentCarrierUe > > ccm)
Set the ComponentCarrier Map for the UE.
uint32_t GetDlEarfcn() const
Ptr< LteEnbNetDevice > m_targetEnb
target ENB
uint32_t GetCsgId() const
Returns the CSG ID the UE is currently a member of.
bool m_isConstructed
is constructed?
Ptr< EpcUeNas > GetNas(void) const
Get the NAS.
virtual ~LteUeNetDevice(void)
Container for a set of ns3::Object pointers.
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-map.h:80
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.