A Discrete-Event Network Simulator
API
lte-ue-net-device.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Giuseppe Piro <g.piro@poliba.it>
18 * Nicola Baldo <nbaldo@cttc.es>
19 * Marco Miozzo <mmiozzo@cttc.es>
20 * Modified by:
21 * Danilo Abrignani <danilo.abrignani@unibo.it> (Carrier Aggregation - GSoC 2015)
22 * Biljana Bojovic <biljana.bojovic@cttc.es> (Carrier Aggregation)
23 */
24
25#include "lte-ue-net-device.h"
26
27#include "epc-tft.h"
28#include "epc-ue-nas.h"
29#include "lte-amc.h"
30#include "lte-net-device.h"
31#include "lte-ue-mac.h"
32#include "lte-ue-phy.h"
33#include "lte-ue-rrc.h"
34
35#include "ns3/callback.h"
36#include "ns3/enum.h"
37#include "ns3/ipv4-header.h"
38#include "ns3/ipv4.h"
39#include "ns3/ipv6-header.h"
40#include "ns3/ipv6.h"
41#include "ns3/llc-snap-header.h"
42#include "ns3/lte-enb-net-device.h"
43#include "ns3/node.h"
44#include "ns3/packet-burst.h"
45#include "ns3/packet.h"
46#include "ns3/pointer.h"
47#include "ns3/simulator.h"
48#include "ns3/trace-source-accessor.h"
49#include "ns3/uinteger.h"
50#include <ns3/ipv4-l3-protocol.h>
51#include <ns3/ipv6-l3-protocol.h>
52#include <ns3/log.h>
53#include <ns3/lte-ue-component-carrier-manager.h>
54#include <ns3/object-factory.h>
55#include <ns3/object-map.h>
56
57namespace ns3
58{
59
60NS_LOG_COMPONENT_DEFINE("LteUeNetDevice");
61
62NS_OBJECT_ENSURE_REGISTERED(LteUeNetDevice);
63
64TypeId
66{
67 static TypeId tid =
68 TypeId("ns3::LteUeNetDevice")
70 .AddConstructor<LteUeNetDevice>()
71 .AddAttribute("EpcUeNas",
72 "The NAS associated to this UeNetDevice",
75 MakePointerChecker<EpcUeNas>())
76 .AddAttribute("LteUeRrc",
77 "The RRC associated to this UeNetDevice",
80 MakePointerChecker<LteUeRrc>())
81 .AddAttribute("LteUeComponentCarrierManager",
82 "The ComponentCarrierManager associated to this UeNetDevice",
85 MakePointerChecker<LteUeComponentCarrierManager>())
86 .AddAttribute("ComponentCarrierMapUe",
87 "List of all component Carrier.",
90 MakeObjectMapChecker<ComponentCarrierUe>())
91 .AddAttribute("Imsi",
92 "International Mobile Subscriber Identity assigned to this UE",
95 MakeUintegerChecker<uint64_t>())
96 .AddAttribute(
97 "DlEarfcn",
98 "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
99 "as per 3GPP 36.101 Section 5.7.3.",
100 UintegerValue(100),
102 MakeUintegerChecker<uint32_t>(0, 262143))
103 .AddAttribute(
104 "CsgId",
105 "The Closed Subscriber Group (CSG) identity that this UE is associated with, "
106 "i.e., giving the UE access to cells which belong to this particular CSG. "
107 "This restriction only applies to initial cell selection and EPC-enabled "
108 "simulation. "
109 "This does not revoke the UE's access to non-CSG cells.",
110 UintegerValue(0),
112 MakeUintegerChecker<uint32_t>());
113
114 return tid;
115}
116
118 : m_isConstructed(false)
119{
120 NS_LOG_FUNCTION(this);
121}
122
124{
125 NS_LOG_FUNCTION(this);
126}
127
128void
130{
131 NS_LOG_FUNCTION(this);
132 m_targetEnb = nullptr;
133
134 m_rrc->Dispose();
135 m_rrc = nullptr;
136
137 m_nas->Dispose();
138 m_nas = nullptr;
139 for (uint32_t i = 0; i < m_ccMap.size(); i++)
140 {
141 m_ccMap.at(i)->Dispose();
142 }
143 m_componentCarrierManager->Dispose();
145}
146
147void
149{
150 NS_LOG_FUNCTION(this);
151
152 if (m_isConstructed)
153 {
154 NS_LOG_LOGIC(this << " Updating configuration: IMSI " << m_imsi << " 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
170{
171 NS_LOG_FUNCTION(this);
172 return m_ccMap.at(0)->GetMac();
173}
174
177{
178 NS_LOG_FUNCTION(this);
179 return m_rrc;
180}
181
184{
185 NS_LOG_FUNCTION(this);
186 return m_ccMap.at(0)->GetPhy();
187}
188
191{
192 NS_LOG_FUNCTION(this);
194}
195
198{
199 NS_LOG_FUNCTION(this);
200 return m_nas;
201}
202
203uint64_t
205{
206 NS_LOG_FUNCTION(this);
207 return m_imsi;
208}
209
212{
213 NS_LOG_FUNCTION(this);
214 return m_dlEarfcn;
215}
216
217void
219{
220 NS_LOG_FUNCTION(this << earfcn);
221 m_dlEarfcn = earfcn;
222}
223
226{
227 NS_LOG_FUNCTION(this);
228 return m_csgId;
229}
230
231void
233{
234 NS_LOG_FUNCTION(this << csgId);
235 m_csgId = csgId;
236 UpdateConfig(); // propagate the change down to NAS and RRC
237}
238
239void
241{
242 NS_LOG_FUNCTION(this << enb);
243 m_targetEnb = enb;
244}
245
248{
249 NS_LOG_FUNCTION(this);
250 return m_targetEnb;
251}
252
253std::map<uint8_t, Ptr<ComponentCarrierUe>>
255{
256 return m_ccMap;
257}
258
259void
261{
262 m_ccMap = ccm;
263}
264
265void
267{
268 NS_LOG_FUNCTION(this);
269 m_isConstructed = true;
270 UpdateConfig();
271
272 std::map<uint8_t, Ptr<ComponentCarrierUe>>::iterator it;
273 for (it = m_ccMap.begin(); it != m_ccMap.end(); ++it)
274 {
275 it->second->GetPhy()->Initialize();
276 it->second->GetMac()->Initialize();
277 }
278 m_rrc->Initialize();
279}
280
281bool
282LteUeNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
283{
284 NS_LOG_FUNCTION(this << packet << dest << protocolNumber);
286 protocolNumber != Ipv6L3Protocol::PROT_NUMBER,
287 "unsupported protocol " << protocolNumber
288 << ", only IPv4 and IPv6 are supported");
289 return m_nas->Send(packet, protocolNumber);
290}
291
292} // namespace ns3
a polymophic address class
Definition: address.h:92
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.
void DoDispose() override
Destructor implementation.
uint32_t m_csgId
the CSG ID
void DoInitialize() override
Initialize() implementation.
Ptr< LteUeRrc > m_rrc
the RRC
uint64_t m_imsi
the IMSI
static TypeId GetTypeId()
Get the type ID.
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
std::map< uint8_t, Ptr< ComponentCarrierUe > > m_ccMap
CC map.
Ptr< LteUeComponentCarrierManager > GetComponentCarrierManager() const
Get the componentn carrier manager.
Ptr< LteEnbNetDevice > GetTargetEnb()
Get the target eNB where the UE is registered.
Ptr< LteUeRrc > GetRrc() const
Get the RRC.
Ptr< EpcUeNas > GetNas() const
Get the NAS.
uint64_t GetImsi() const
Get the IMSI.
void SetCsgId(uint32_t csgId)
Enlist the UE device as a member of a particular CSG.
Ptr< LteUeComponentCarrierManager > m_componentCarrierManager
the component carrier manager
Ptr< LteUePhy > GetPhy() const
Get the Phy.
uint32_t m_dlEarfcn
downlink carrier frequency
void SetDlEarfcn(uint32_t earfcn)
Ptr< LteUeMac > GetMac() const
Get the MAC.
Ptr< EpcUeNas > m_nas
the NAS
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
std::map< uint8_t, Ptr< ComponentCarrierUe > > GetCcMap()
Get the ComponentCarrier Map for the UE.
void SetTargetEnb(Ptr< LteEnbNetDevice > enb)
Set the target eNB where the UE is registered.
void DoDispose() override
Destructor implementation.
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?
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Hold an unsigned integer type.
Definition: uinteger.h:45
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
Definition: object-map.h:40
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-map.h:76
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:230
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#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:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#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.