A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Giuseppe Piro <g.piro@poliba.it>
7 * Nicola Baldo <nbaldo@cttc.es>
8 * Marco Miozzo <mmiozzo@cttc.es>
9 * Modified by:
10 * Danilo Abrignani <danilo.abrignani@unibo.it> (Carrier Aggregation - GSoC 2015)
11 * Biljana Bojovic <biljana.bojovic@cttc.es> (Carrier Aggregation)
12 */
13
14#include "lte-ue-net-device.h"
15
16#include "epc-ue-nas.h"
17#include "lte-enb-net-device.h"
18#include "lte-net-device.h"
20#include "lte-ue-mac.h"
21#include "lte-ue-phy.h"
22#include "lte-ue-rrc.h"
23
24#include "ns3/callback.h"
25#include "ns3/enum.h"
26#include "ns3/ipv4-header.h"
27#include "ns3/ipv4.h"
28#include "ns3/ipv6-header.h"
29#include "ns3/ipv6.h"
30#include "ns3/llc-snap-header.h"
31#include "ns3/node.h"
32#include "ns3/packet-burst.h"
33#include "ns3/packet.h"
34#include "ns3/pointer.h"
35#include "ns3/simulator.h"
36#include "ns3/trace-source-accessor.h"
37#include "ns3/uinteger.h"
38#include <ns3/ipv4-l3-protocol.h>
39#include <ns3/ipv6-l3-protocol.h>
40#include <ns3/log.h>
41#include <ns3/object-factory.h>
42#include <ns3/object-map.h>
43
44namespace ns3
45{
46
47NS_LOG_COMPONENT_DEFINE("LteUeNetDevice");
48
49NS_OBJECT_ENSURE_REGISTERED(LteUeNetDevice);
50
51TypeId
53{
54 static TypeId tid =
55 TypeId("ns3::LteUeNetDevice")
57 .AddConstructor<LteUeNetDevice>()
58 .AddAttribute("EpcUeNas",
59 "The NAS associated to this UeNetDevice",
63 .AddAttribute("LteUeRrc",
64 "The RRC associated to this UeNetDevice",
68 .AddAttribute("LteUeComponentCarrierManager",
69 "The ComponentCarrierManager associated to this UeNetDevice",
73 .AddAttribute("ComponentCarrierMapUe",
74 "List of all component Carrier.",
78 .AddAttribute("Imsi",
79 "International Mobile Subscriber Identity assigned to this UE",
83 .AddAttribute(
84 "DlEarfcn",
85 "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
86 "as per 3GPP 36.101 Section 5.7.3.",
87 UintegerValue(100),
90 .AddAttribute(
91 "CsgId",
92 "The Closed Subscriber Group (CSG) identity that this UE is associated with, "
93 "i.e., giving the UE access to cells which belong to this particular CSG. "
94 "This restriction only applies to initial cell selection and EPC-enabled "
95 "simulation. "
96 "This does not revoke the UE's access to non-CSG cells.",
100
101 return tid;
102}
103
105 : m_isConstructed(false)
106{
107 NS_LOG_FUNCTION(this);
108}
109
114
115void
117{
118 NS_LOG_FUNCTION(this);
119 m_targetEnb = nullptr;
120
121 m_rrc->Dispose();
122 m_rrc = nullptr;
123
124 m_nas->Dispose();
125 m_nas = nullptr;
126 for (uint32_t i = 0; i < m_ccMap.size(); i++)
127 {
128 m_ccMap.at(i)->Dispose();
129 }
130 m_componentCarrierManager->Dispose();
132}
133
134void
136{
137 NS_LOG_FUNCTION(this);
138
139 if (m_isConstructed)
140 {
141 NS_LOG_LOGIC(this << " Updating configuration: IMSI " << m_imsi << " CSG ID " << m_csgId);
142 m_nas->SetImsi(m_imsi);
143 m_rrc->SetImsi(m_imsi);
144 m_nas->SetCsgId(m_csgId); // this also handles propagation to RRC
145 }
146 else
147 {
148 /*
149 * NAS and RRC instances are not be ready yet, so do nothing now and
150 * expect ``DoInitialize`` to re-invoke this function.
151 */
152 }
153}
154
157{
158 NS_LOG_FUNCTION(this);
159 return m_ccMap.at(0)->GetMac();
160}
161
164{
165 NS_LOG_FUNCTION(this);
166 return m_rrc;
167}
168
171{
172 NS_LOG_FUNCTION(this);
173 return m_ccMap.at(0)->GetPhy();
174}
175
182
185{
186 NS_LOG_FUNCTION(this);
187 return m_nas;
188}
189
190uint64_t
192{
193 NS_LOG_FUNCTION(this);
194 return m_imsi;
195}
196
199{
200 NS_LOG_FUNCTION(this);
201 return m_dlEarfcn;
202}
203
204void
206{
207 NS_LOG_FUNCTION(this << earfcn);
208 m_dlEarfcn = earfcn;
209}
210
213{
214 NS_LOG_FUNCTION(this);
215 return m_csgId;
216}
217
218void
220{
221 NS_LOG_FUNCTION(this << csgId);
222 m_csgId = csgId;
223 UpdateConfig(); // propagate the change down to NAS and RRC
224}
225
226void
232
239
240std::map<uint8_t, Ptr<ComponentCarrierUe>>
242{
243 return m_ccMap;
244}
245
246void
248{
249 m_ccMap = ccm;
250}
251
252void
254{
255 NS_LOG_FUNCTION(this);
256 m_isConstructed = true;
257 UpdateConfig();
258
259 for (auto it = m_ccMap.begin(); it != m_ccMap.end(); ++it)
260 {
261 it->second->GetPhy()->Initialize();
262 it->second->GetMac()->Initialize();
263 }
264 m_rrc->Initialize();
265}
266
267bool
268LteUeNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
269{
270 NS_LOG_FUNCTION(this << packet << dest << protocolNumber);
272 protocolNumber != Ipv6L3Protocol::PROT_NUMBER,
273 "unsupported protocol " << protocolNumber
274 << ", only IPv4 and IPv6 are supported");
275 return m_nas->Send(packet, protocolNumber);
276}
277
278} // namespace ns3
a polymophic address class
Definition address.h:90
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?
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
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:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#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:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
ObjectPtrContainerValue ObjectMapValue
ObjectMapValue is an alias for ObjectPtrContainerValue.
Definition object-map.h:29
Ptr< const AttributeAccessor > MakeObjectMapAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition object-map.h:65
Ptr< const AttributeChecker > MakeObjectMapChecker()
Definition object-map.h:110