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  */
22 
23 #include "ns3/llc-snap-header.h"
24 #include "ns3/simulator.h"
25 #include "ns3/callback.h"
26 #include "ns3/node.h"
27 #include "ns3/packet.h"
28 #include "lte-net-device.h"
29 #include "ns3/packet-burst.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/trace-source-accessor.h"
32 #include "ns3/pointer.h"
33 #include "ns3/enum.h"
34 #include "ns3/lte-enb-net-device.h"
35 #include "lte-ue-net-device.h"
36 #include "lte-ue-mac.h"
37 #include "lte-ue-rrc.h"
38 #include "ns3/ipv4-header.h"
39 #include "ns3/ipv4.h"
40 #include "lte-amc.h"
41 #include "lte-ue-phy.h"
42 #include "epc-ue-nas.h"
43 #include <ns3/ipv4-l3-protocol.h>
44 #include <ns3/log.h>
45 #include "epc-tft.h"
46 
47 namespace ns3 {
48 
49 NS_LOG_COMPONENT_DEFINE ("LteUeNetDevice");
50 
51 NS_OBJECT_ENSURE_REGISTERED ( LteUeNetDevice);
52 
53 
55 {
56  static TypeId
57  tid =
58  TypeId ("ns3::LteUeNetDevice")
60  .AddConstructor<LteUeNetDevice> ()
61  .AddAttribute ("EpcUeNas",
62  "The NAS associated to this UeNetDevice",
63  PointerValue (),
65  MakePointerChecker <EpcUeNas> ())
66  .AddAttribute ("LteUeRrc",
67  "The RRC associated to this UeNetDevice",
68  PointerValue (),
70  MakePointerChecker <LteUeRrc> ())
71  .AddAttribute ("LteUeMac",
72  "The MAC associated to this UeNetDevice",
73  PointerValue (),
75  MakePointerChecker <LteUeMac> ())
76  .AddAttribute ("LteUePhy",
77  "The PHY associated to this UeNetDevice",
78  PointerValue (),
80  MakePointerChecker <LteUePhy> ())
81  .AddAttribute ("Imsi",
82  "International Mobile Subscriber Identity assigned to this UE",
83  UintegerValue (0),
85  MakeUintegerChecker<uint64_t> ())
86  .AddAttribute ("DlEarfcn",
87  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
88  "as per 3GPP 36.101 Section 5.7.3. ",
89  UintegerValue (100),
92  MakeUintegerChecker<uint16_t> (0, 6149))
93  .AddAttribute ("CsgId",
94  "The Closed Subscriber Group (CSG) identity that this UE is associated with, "
95  "i.e., giving the UE access to cells which belong to this particular CSG. "
96  "This restriction only applies to initial cell selection and EPC-enabled simulation. "
97  "This does not revoke the UE's access to non-CSG cells. ",
98  UintegerValue (0),
101  MakeUintegerChecker<uint32_t> ())
102  ;
103 
104  return tid;
105 }
106 
107 
109  : m_isConstructed (false)
110 {
111  NS_LOG_FUNCTION (this);
112 }
113 
115 {
116  NS_LOG_FUNCTION (this);
117 }
118 
119 void
121 {
122  NS_LOG_FUNCTION (this);
123  m_targetEnb = 0;
124  m_mac->Dispose ();
125  m_mac = 0;
126  m_rrc->Dispose ();
127  m_rrc = 0;
128  m_phy->Dispose ();
129  m_phy = 0;
130  m_nas->Dispose ();
131  m_nas = 0;
133 }
134 
135 void
137 {
138  NS_LOG_FUNCTION (this);
139 
140  if (m_isConstructed)
141  {
142  NS_LOG_LOGIC (this << " Updating configuration: IMSI " << m_imsi
143  << " CSG ID " << m_csgId);
144  m_nas->SetImsi (m_imsi);
145  m_rrc->SetImsi (m_imsi);
146  m_nas->SetCsgId (m_csgId); // this also handles propagation to RRC
147  }
148  else
149  {
150  /*
151  * NAS and RRC instances are not be ready yet, so do nothing now and
152  * expect ``DoInitialize`` to re-invoke this function.
153  */
154  }
155 }
156 
157 
158 
161 {
162  NS_LOG_FUNCTION (this);
163  return m_mac;
164 }
165 
166 
169 {
170  NS_LOG_FUNCTION (this);
171  return m_rrc;
172 }
173 
174 
177 {
178  NS_LOG_FUNCTION (this);
179  return m_phy;
180 }
181 
184 {
185  NS_LOG_FUNCTION (this);
186  return m_nas;
187 }
188 
189 uint64_t
191 {
192  NS_LOG_FUNCTION (this);
193  return m_imsi;
194 }
195 
196 uint16_t
198 {
199  NS_LOG_FUNCTION (this);
200  return m_dlEarfcn;
201 }
202 
203 void
205 {
206  NS_LOG_FUNCTION (this << earfcn);
207  m_dlEarfcn = earfcn;
208 }
209 
210 uint32_t
212 {
213  NS_LOG_FUNCTION (this);
214  return m_csgId;
215 }
216 
217 void
218 LteUeNetDevice::SetCsgId (uint32_t csgId)
219 {
220  NS_LOG_FUNCTION (this << csgId);
221  m_csgId = csgId;
222  UpdateConfig (); // propagate the change down to NAS and RRC
223 }
224 
225 void
227 {
228  NS_LOG_FUNCTION (this << enb);
229  m_targetEnb = enb;
230 }
231 
232 
235 {
236  NS_LOG_FUNCTION (this);
237  return m_targetEnb;
238 }
239 
240 void
242 {
243  NS_LOG_FUNCTION (this);
244  m_isConstructed = true;
245  UpdateConfig ();
246  m_phy->Initialize ();
247  m_mac->Initialize ();
248  m_rrc->Initialize ();
249 }
250 
251 bool
252 LteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
253 {
254  NS_LOG_FUNCTION (this << dest << protocolNumber);
255  if (protocolNumber != Ipv4L3Protocol::PROT_NUMBER)
256  {
257  NS_LOG_INFO("unsupported protocol " << protocolNumber << ", only IPv4 is supported");
258  return true;
259  }
260  return m_nas->Send (packet);
261 }
262 
263 
264 } // 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
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual ~LteUeNetDevice(void)
virtual void DoDispose(void)
Destructor implementation.
Ptr< LteUeRrc > GetRrc() const
uint64_t GetImsi() const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Ptr< LteEnbNetDevice > m_targetEnb
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
a polymophic address class
Definition: address.h:90
Ptr< EpcUeNas > m_nas
static TypeId GetTypeId(void)
virtual void DoDispose()
Destructor implementation.
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
Ptr< LteUePhy > m_phy
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
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.
Hold objects of type Ptr.
Definition: pointer.h:36
uint16_t m_dlEarfcn
downlink carrier frequency
Ptr< LteEnbNetDevice > GetTargetEnb(void)
Get the targer eNB where the UE is registered.
Ptr< EpcUeNas > GetNas(void) const
uint16_t GetDlEarfcn() const
void SetDlEarfcn(uint16_t earfcn)
Ptr< LteUeMac > m_mac
void UpdateConfig()
Propagate attributes and configuration to sub-modules.
Ptr< LteUePhy > GetPhy(void) const
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
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
static const uint16_t PROT_NUMBER
Protocol number (0x0800)