A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("LteUeNetDevice");
48 
49 namespace ns3 {
50 
51 NS_OBJECT_ENSURE_REGISTERED ( LteUeNetDevice)
52  ;
53 
54 
56 {
57  static TypeId
58  tid =
59  TypeId ("ns3::LteUeNetDevice")
61  .AddConstructor<LteUeNetDevice> ()
62  .AddAttribute ("EpcUeNas",
63  "The NAS associated to this UeNetDevice",
64  PointerValue (),
65  MakePointerAccessor (&LteUeNetDevice::m_nas),
66  MakePointerChecker <EpcUeNas> ())
67  .AddAttribute ("LteUeRrc",
68  "The RRC associated to this UeNetDevice",
69  PointerValue (),
70  MakePointerAccessor (&LteUeNetDevice::m_rrc),
71  MakePointerChecker <LteUeRrc> ())
72  .AddAttribute ("LteUeMac",
73  "The MAC associated to this UeNetDevice",
74  PointerValue (),
75  MakePointerAccessor (&LteUeNetDevice::m_mac),
76  MakePointerChecker <LteUeMac> ())
77  .AddAttribute ("LteUePhy",
78  "The PHY associated to this UeNetDevice",
79  PointerValue (),
80  MakePointerAccessor (&LteUeNetDevice::m_phy),
81  MakePointerChecker <LteUePhy> ())
82  .AddAttribute ("Imsi",
83  "International Mobile Subscriber Identity assigned to this UE",
84  UintegerValue (0),
85  MakeUintegerAccessor (&LteUeNetDevice::m_imsi),
86  MakeUintegerChecker<uint64_t> ())
87  .AddAttribute ("DlEarfcn",
88  "Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
89  "as per 3GPP 36.101 Section 5.7.3. ",
90  UintegerValue (100),
91  MakeUintegerAccessor (&LteUeNetDevice::SetDlEarfcn,
93  MakeUintegerChecker<uint16_t> (0, 6149))
94  .AddAttribute ("CsgId",
95  "The Closed Subscriber Group (CSG) identity that this UE is associated with, "
96  "i.e., giving the UE access to cells which belong to this particular CSG. "
97  "This restriction only applies to initial cell selection and EPC-enabled simulation. "
98  "This does not revoke the UE's access to non-CSG cells. ",
99  UintegerValue (0),
100  MakeUintegerAccessor (&LteUeNetDevice::SetCsgId,
102  MakeUintegerChecker<uint32_t> ())
103  ;
104 
105  return tid;
106 }
107 
108 
110  : m_isConstructed (false)
111 {
112  NS_LOG_FUNCTION (this);
113 }
114 
116 {
117  NS_LOG_FUNCTION (this);
118 }
119 
120 void
122 {
123  NS_LOG_FUNCTION (this);
124  m_targetEnb = 0;
125  m_mac->Dispose ();
126  m_mac = 0;
127  m_rrc->Dispose ();
128  m_rrc = 0;
129  m_phy->Dispose ();
130  m_phy = 0;
131  m_nas->Dispose ();
132  m_nas = 0;
134 }
135 
136 void
138 {
139  NS_LOG_FUNCTION (this);
140 
141  if (m_isConstructed)
142  {
143  NS_LOG_LOGIC (this << " Updating configuration: IMSI " << m_imsi
144  << " CSG ID " << m_csgId);
145  m_nas->SetImsi (m_imsi);
146  m_rrc->SetImsi (m_imsi);
147  m_nas->SetCsgId (m_csgId); // this also handles propagation to RRC
148  }
149  else
150  {
151  /*
152  * NAS and RRC instances are not be ready yet, so do nothing now and
153  * expect ``DoInitialize`` to re-invoke this function.
154  */
155  }
156 }
157 
158 
159 
162 {
163  NS_LOG_FUNCTION (this);
164  return m_mac;
165 }
166 
167 
170 {
171  NS_LOG_FUNCTION (this);
172  return m_rrc;
173 }
174 
175 
178 {
179  NS_LOG_FUNCTION (this);
180  return m_phy;
181 }
182 
185 {
186  NS_LOG_FUNCTION (this);
187  return m_nas;
188 }
189 
190 uint64_t
192 {
193  NS_LOG_FUNCTION (this);
194  return m_imsi;
195 }
196 
197 uint16_t
199 {
200  NS_LOG_FUNCTION (this);
201  return m_dlEarfcn;
202 }
203 
204 void
206 {
207  NS_LOG_FUNCTION (this << earfcn);
208  m_dlEarfcn = earfcn;
209 }
210 
211 uint32_t
213 {
214  NS_LOG_FUNCTION (this);
215  return m_csgId;
216 }
217 
218 void
219 LteUeNetDevice::SetCsgId (uint32_t csgId)
220 {
221  NS_LOG_FUNCTION (this << csgId);
222  m_csgId = csgId;
223  UpdateConfig (); // propagate the change down to NAS and RRC
224 }
225 
226 void
228 {
229  NS_LOG_FUNCTION (this << enb);
230  m_targetEnb = enb;
231 }
232 
233 
236 {
237  NS_LOG_FUNCTION (this);
238  return m_targetEnb;
239 }
240 
241 void
243 {
244  NS_LOG_FUNCTION (this);
245  m_isConstructed = true;
246  UpdateConfig ();
247  m_phy->Initialize ();
248  m_mac->Initialize ();
249  m_rrc->Initialize ();
250 }
251 
252 bool
253 LteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
254 {
255  NS_LOG_FUNCTION (this << dest << protocolNumber);
256  if (protocolNumber != Ipv4L3Protocol::PROT_NUMBER)
257  {
258  NS_LOG_INFO("unsupported protocol " << protocolNumber << ", only IPv4 is supported");
259  return true;
260  }
261  return m_nas->Send (packet);
262 }
263 
264 
265 } // namespace ns3
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Ptr< LteUeRrc > m_rrc
virtual ~LteUeNetDevice(void)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Ptr< LteUeRrc > GetRrc() const
uint64_t GetImsi() const
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Ptr< LteEnbNetDevice > m_targetEnb
#define NS_LOG_INFO(msg)
Definition: log.h:298
a polymophic address class
Definition: address.h:86
Ptr< EpcUeNas > m_nas
static TypeId GetTypeId(void)
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void SetTargetEnb(Ptr< LteEnbNetDevice > enb)
Set the targer eNB where the UE is registered.
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Hold an unsigned integer type.
Definition: uinteger.h:46
Ptr< LteUePhy > m_phy
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
void SetCsgId(uint32_t csgId)
Enlist the UE device as a member of a particular CSG.
hold objects of type Ptr
Definition: pointer.h:33
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.
NS_LOG_COMPONENT_DEFINE("LteUeNetDevice")
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)
a unique identifier for an interface.
Definition: type-id.h:49
Ptr< LteUeMac > GetMac(void) const
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
static const uint16_t PROT_NUMBER
Protocol number (0x0800)