author | Nicola Baldo <nbaldo@cttc.es> |
Fri, 23 Nov 2012 12:47:04 +0100 | |
changeset 9422 | e0388ce05fcc |
parent 9414 | 7b0db3dbf19b |
child 9430 | e8b87593ee5b |
permissions | -rw-r--r-- |
7886 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
9406 | 3 |
* Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
7886 | 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: Nicola Baldo <nbaldo@cttc.es> |
|
19 |
*/ |
|
20 |
||
21 |
#include <ns3/fatal-error.h> |
|
22 |
#include <ns3/log.h> |
|
9406 | 23 |
#include <ns3/object-map.h> |
24 |
#include <ns3/object-factory.h> |
|
25 |
#include <ns3/node-list.h> |
|
26 |
#include <ns3/node.h> |
|
7886 | 27 |
|
28 |
#include "lte-ue-rrc.h" |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
29 |
#include "lte-enb-rrc.h" |
7886 | 30 |
#include "lte-rlc.h" |
9406 | 31 |
#include "lte-rlc-tm.h" |
32 |
#include "lte-rlc-um.h" |
|
33 |
#include "lte-rlc-am.h" |
|
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8160
diff
changeset
|
34 |
#include "lte-pdcp.h" |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8160
diff
changeset
|
35 |
#include "lte-pdcp-sap.h" |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8160
diff
changeset
|
36 |
#include "lte-radio-bearer-info.h" |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
37 |
#include "lte-as-sap.h" |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
38 |
#include "lte-enb-net-device.h" |
7886 | 39 |
|
40 |
NS_LOG_COMPONENT_DEFINE ("LteUeRrc"); |
|
41 |
||
42 |
namespace ns3 { |
|
43 |
||
44 |
||
45 |
||
46 |
///////////////////////////// |
|
47 |
// CMAC SAP forwarder |
|
48 |
///////////////////////////// |
|
49 |
||
50 |
class UeMemberLteUeCmacSapUser : public LteUeCmacSapUser |
|
51 |
{ |
|
52 |
public: |
|
53 |
UeMemberLteUeCmacSapUser (LteUeRrc* rrc); |
|
54 |
||
9406 | 55 |
virtual void SetTemporaryCellRnti (uint16_t rnti); |
56 |
virtual void NotifyRandomAccessSuccessful (); |
|
57 |
virtual void NotifyRandomAccessFailed (); |
|
58 |
||
7886 | 59 |
private: |
60 |
LteUeRrc* m_rrc; |
|
61 |
}; |
|
62 |
||
63 |
UeMemberLteUeCmacSapUser::UeMemberLteUeCmacSapUser (LteUeRrc* rrc) |
|
64 |
: m_rrc (rrc) |
|
65 |
{ |
|
66 |
} |
|
67 |
||
68 |
void |
|
9406 | 69 |
UeMemberLteUeCmacSapUser::SetTemporaryCellRnti (uint16_t rnti) |
7886 | 70 |
{ |
9406 | 71 |
m_rrc->DoSetTemporaryCellRnti (rnti); |
72 |
} |
|
73 |
||
74 |
||
75 |
void |
|
76 |
UeMemberLteUeCmacSapUser::NotifyRandomAccessSuccessful () |
|
77 |
{ |
|
78 |
m_rrc->DoNotifyRandomAccessSuccessful (); |
|
79 |
} |
|
80 |
||
81 |
void |
|
82 |
UeMemberLteUeCmacSapUser::NotifyRandomAccessFailed () |
|
83 |
{ |
|
84 |
m_rrc->DoNotifyRandomAccessFailed (); |
|
7886 | 85 |
} |
86 |
||
87 |
||
88 |
||
89 |
||
90 |
||
9406 | 91 |
|
92 |
||
93 |
const char* g_ueRrcStateName[LteUeRrc::NUM_STATES] = |
|
94 |
{ |
|
95 |
"IDLE_CELL_SELECTION", |
|
96 |
"IDLE_WAIT_SYSTEM_INFO", |
|
97 |
"IDLE_CAMPED_NORMALLY", |
|
98 |
"IDLE_RANDOM_ACCESS", |
|
99 |
"IDLE_CONNECTING", |
|
100 |
"CONNECTED_NORMALLY", |
|
101 |
"CONNECTED_REESTABLISHING", |
|
102 |
"CONNECTED_HANDOVER" |
|
103 |
}; |
|
104 |
||
105 |
std::string ToString (LteUeRrc::State s) |
|
106 |
{ |
|
107 |
return std::string (g_ueRrcStateName[s]); |
|
108 |
} |
|
109 |
||
110 |
||
7886 | 111 |
///////////////////////////// |
112 |
// ue RRC methods |
|
113 |
///////////////////////////// |
|
114 |
||
7905
80557b09aa7f
Added missing NS_OBJECT_ENSURE_REGISTERED to all ns3::Objects created.
jnin
parents:
7886
diff
changeset
|
115 |
NS_OBJECT_ENSURE_REGISTERED (LteUeRrc); |
7886 | 116 |
|
9406 | 117 |
|
7886 | 118 |
LteUeRrc::LteUeRrc () |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
119 |
: m_cphySapProvider (0), |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
120 |
m_cmacSapProvider (0), |
9406 | 121 |
m_rrcSapUser (0), |
8160 | 122 |
m_macSapProvider (0), |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
123 |
m_asSapUser (0), |
9406 | 124 |
m_state (IDLE_CELL_SELECTION), |
125 |
m_imsi (0), |
|
9375
ffe27626a3e5
fixed valgrind error in LteUeRrc
Nicola Baldo <nbaldo@cttc.es>
parents:
9346
diff
changeset
|
126 |
m_rnti (0), |
9406 | 127 |
m_cellId (0), |
128 |
m_useRlcSm (true), |
|
129 |
m_connectionPending (0), |
|
130 |
m_receivedMib (0), |
|
131 |
m_receivedSib2 (0) |
|
132 |
||
7886 | 133 |
{ |
134 |
NS_LOG_FUNCTION (this); |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
135 |
m_cphySapUser = new MemberLteUeCphySapUser<LteUeRrc> (this); |
7886 | 136 |
m_cmacSapUser = new UeMemberLteUeCmacSapUser (this); |
9406 | 137 |
m_rrcSapProvider = new MemberLteUeRrcSapProvider<LteUeRrc> (this); |
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8160
diff
changeset
|
138 |
m_pdcpSapUser = new LtePdcpSpecificLtePdcpSapUser<LteUeRrc> (this); |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
139 |
m_asSapProvider = new MemberLteAsSapProvider<LteUeRrc> (this); |
7886 | 140 |
} |
141 |
||
142 |
||
143 |
LteUeRrc::~LteUeRrc () |
|
144 |
{ |
|
145 |
NS_LOG_FUNCTION (this); |
|
146 |
} |
|
147 |
||
148 |
void |
|
149 |
LteUeRrc::DoDispose () |
|
150 |
{ |
|
151 |
NS_LOG_FUNCTION (this); |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
152 |
delete m_cphySapUser; |
7886 | 153 |
delete m_cmacSapUser; |
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8160
diff
changeset
|
154 |
delete m_pdcpSapUser; |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
155 |
delete m_asSapProvider; |
9406 | 156 |
m_drbMap.clear (); |
7886 | 157 |
} |
158 |
||
159 |
TypeId |
|
160 |
LteUeRrc::GetTypeId (void) |
|
161 |
{ |
|
162 |
static TypeId tid = TypeId ("ns3::LteUeRrc") |
|
163 |
.SetParent<Object> () |
|
7954 | 164 |
.AddConstructor<LteUeRrc> () |
9406 | 165 |
.AddAttribute ("DataRadioBearerMap", "List of UE RadioBearerInfo for Data Radio Bearers by LCID.", |
7954 | 166 |
ObjectMapValue (), |
9406 | 167 |
MakeObjectMapAccessor (&LteUeRrc::m_drbMap), |
168 |
MakeObjectMapChecker<LteDataRadioBearerInfo> ()) |
|
8007 | 169 |
.AddAttribute ("CellId", |
170 |
"Serving cell identifier", |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
171 |
UintegerValue (0), // unused, read-only attribute |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
172 |
MakeUintegerAccessor (&LteUeRrc::GetCellId), |
8007 | 173 |
MakeUintegerChecker<uint16_t> ()) |
174 |
.AddAttribute ("C-RNTI", |
|
175 |
"Cell Radio Network Temporary Identifier", |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
176 |
UintegerValue (0), // unused, read-only attribute |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
177 |
MakeUintegerAccessor (&LteUeRrc::GetRnti), |
8007 | 178 |
MakeUintegerChecker<uint16_t> ()) |
9406 | 179 |
.AddTraceSource ("StateTransition", |
180 |
"fired upon every UE RRC state transition", |
|
181 |
MakeTraceSourceAccessor (&LteUeRrc::m_stateTransitionCallback)) |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
182 |
; |
7886 | 183 |
return tid; |
184 |
} |
|
185 |
||
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
186 |
|
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
187 |
void |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
188 |
LteUeRrc::SetLteUeCphySapProvider (LteUeCphySapProvider * s) |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
189 |
{ |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
190 |
NS_LOG_FUNCTION (this << s); |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
191 |
m_cphySapProvider = s; |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
192 |
} |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
193 |
|
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
194 |
LteUeCphySapUser* |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
195 |
LteUeRrc::GetLteUeCphySapUser () |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
196 |
{ |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
197 |
NS_LOG_FUNCTION (this); |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
198 |
return m_cphySapUser; |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
199 |
} |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
200 |
|
7886 | 201 |
void |
202 |
LteUeRrc::SetLteUeCmacSapProvider (LteUeCmacSapProvider * s) |
|
203 |
{ |
|
204 |
NS_LOG_FUNCTION (this << s); |
|
205 |
m_cmacSapProvider = s; |
|
206 |
} |
|
207 |
||
208 |
LteUeCmacSapUser* |
|
209 |
LteUeRrc::GetLteUeCmacSapUser () |
|
210 |
{ |
|
211 |
NS_LOG_FUNCTION (this); |
|
212 |
return m_cmacSapUser; |
|
213 |
} |
|
214 |
||
215 |
void |
|
9406 | 216 |
LteUeRrc::SetLteUeRrcSapUser (LteUeRrcSapUser * s) |
217 |
{ |
|
218 |
NS_LOG_FUNCTION (this << s); |
|
219 |
m_rrcSapUser = s; |
|
220 |
} |
|
221 |
||
222 |
LteUeRrcSapProvider* |
|
223 |
LteUeRrc::GetLteUeRrcSapProvider () |
|
224 |
{ |
|
225 |
NS_LOG_FUNCTION (this); |
|
226 |
return m_rrcSapProvider; |
|
227 |
} |
|
228 |
||
229 |
void |
|
7886 | 230 |
LteUeRrc::SetLteMacSapProvider (LteMacSapProvider * s) |
231 |
{ |
|
232 |
NS_LOG_FUNCTION (this << s); |
|
233 |
m_macSapProvider = s; |
|
234 |
} |
|
235 |
||
236 |
void |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
237 |
LteUeRrc::SetAsSapUser (LteAsSapUser* s) |
7886 | 238 |
{ |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
239 |
m_asSapUser = s; |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
240 |
} |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
241 |
|
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
242 |
LteAsSapProvider* |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
243 |
LteUeRrc::GetAsSapProvider () |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
244 |
{ |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
245 |
return m_asSapProvider; |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
246 |
} |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
247 |
|
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
248 |
void |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
249 |
LteUeRrc::SetImsi (uint64_t imsi) |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
250 |
{ |
9406 | 251 |
NS_LOG_FUNCTION (this << imsi); |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
252 |
m_imsi = imsi; |
7886 | 253 |
} |
254 |
||
255 |
uint16_t |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
256 |
LteUeRrc::GetRnti () const |
7886 | 257 |
{ |
258 |
NS_LOG_FUNCTION (this); |
|
259 |
return m_rnti; |
|
260 |
} |
|
261 |
||
8160 | 262 |
uint16_t |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8714
diff
changeset
|
263 |
LteUeRrc::GetCellId () const |
8160 | 264 |
{ |
265 |
NS_LOG_FUNCTION (this); |
|
266 |
return m_cellId; |
|
267 |
} |
|
268 |
||
9406 | 269 |
|
270 |
uint8_t |
|
271 |
LteUeRrc::GetUlBandwidth () const |
|
272 |
{ |
|
273 |
NS_LOG_FUNCTION (this); |
|
274 |
return m_ulBandwidth; |
|
275 |
} |
|
276 |
||
277 |
uint8_t |
|
278 |
LteUeRrc::GetDlBandwidth () const |
|
279 |
{ |
|
280 |
NS_LOG_FUNCTION (this); |
|
281 |
return m_dlBandwidth; |
|
282 |
} |
|
283 |
||
284 |
uint16_t |
|
285 |
LteUeRrc::GetDlEarfcn () const |
|
8055 | 286 |
{ |
9406 | 287 |
return m_dlEarfcn; |
288 |
} |
|
289 |
||
290 |
uint16_t |
|
291 |
LteUeRrc::GetUlEarfcn () const |
|
292 |
{ |
|
293 |
NS_LOG_FUNCTION (this); |
|
294 |
return m_ulEarfcn; |
|
295 |
} |
|
296 |
||
297 |
||
298 |
LteUeRrc::State |
|
299 |
LteUeRrc::GetState (void) |
|
300 |
{ |
|
301 |
NS_LOG_FUNCTION (this); |
|
302 |
return m_state; |
|
303 |
} |
|
304 |
||
305 |
void |
|
306 |
LteUeRrc::SetUseRlcSm (bool val) |
|
307 |
{ |
|
308 |
NS_LOG_FUNCTION (this); |
|
309 |
m_useRlcSm = val; |
|
8055 | 310 |
} |
311 |
||
9406 | 312 |
|
313 |
void |
|
314 |
LteUeRrc::DoStart (void) |
|
315 |
{ |
|
316 |
NS_LOG_FUNCTION (this); |
|
317 |
||
318 |
// setup the UE side of SRB0 |
|
319 |
uint8_t lcid = 0; |
|
320 |
||
321 |
Ptr<LteRlc> rlc = CreateObject<LteRlcTm> ()->GetObject<LteRlc> (); |
|
322 |
rlc->SetLteMacSapProvider (m_macSapProvider); |
|
323 |
rlc->SetRnti (m_rnti); |
|
324 |
rlc->SetLcId (lcid); |
|
325 |
||
326 |
m_srb0 = CreateObject<LteSignalingRadioBearerInfo> (); |
|
327 |
m_srb0->m_rlc = rlc; |
|
328 |
m_srb0->m_srbIdentity = 1; |
|
329 |
||
330 |
// CCCH (LCID 0) is pre-configured, here is the hardcoded configuration: |
|
331 |
LteUeCmacSapProvider::LogicalChannelConfig lcConfig; |
|
332 |
lcConfig.priority = 0; // highest priority |
|
333 |
lcConfig.prioritizedBitRateKbps = 65535; // maximum |
|
334 |
lcConfig.bucketSizeDurationMs = 65535; // maximum |
|
335 |
lcConfig.logicalChannelGroup = 0; // all SRBs mapped to LCG 0 |
|
336 |
||
337 |
m_cmacSapProvider->AddLc (lcid, lcConfig, rlc->GetLteMacSapUser ()); |
|
338 |
||
339 |
} |
|
9346 | 340 |
|
341 |
||
9406 | 342 |
void |
343 |
LteUeRrc::DoSendData (Ptr<Packet> packet, uint8_t bid) |
|
344 |
{ |
|
345 |
NS_LOG_FUNCTION (this << packet); |
|
346 |
||
347 |
||
348 |
uint8_t drbid = Bid2Drbid (bid); |
|
349 |
||
350 |
std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid); |
|
351 |
NS_ASSERT_MSG (it != m_drbMap.end (), "could not find bearer with drbid == " << drbid); |
|
352 |
||
353 |
LtePdcpSapProvider::TransmitPdcpSduParameters params; |
|
354 |
params.pdcpSdu = packet; |
|
355 |
params.rnti = m_rnti; |
|
356 |
params.lcid = it->second->m_logicalChannelIdentity; |
|
357 |
||
358 |
NS_LOG_LOGIC (this << " RNTI=" << m_rnti << " sending " << packet << "on DRBID " << (uint32_t) drbid << " (LCID" << params.lcid << ")" << " (" << packet->GetSize () << " bytes)"); |
|
359 |
it->second->m_pdcp->GetLtePdcpSapProvider ()->TransmitPdcpSdu (params); |
|
9346 | 360 |
} |
361 |
||
8714
398bbcbb3f42
Add MIMO model, test and documentation
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8583
diff
changeset
|
362 |
void |
9406 | 363 |
LteUeRrc::DoDisconnect () |
364 |
{ |
|
365 |
NS_LOG_FUNCTION (this); |
|
366 |
||
367 |
switch (m_state) |
|
368 |
{ |
|
369 |
case IDLE_CELL_SELECTION: |
|
370 |
case IDLE_CAMPED_NORMALLY: |
|
371 |
NS_LOG_INFO ("already disconnected"); |
|
372 |
break; |
|
373 |
||
374 |
case IDLE_CONNECTING: |
|
375 |
NS_LOG_INFO ("aborting connection setup procedure"); |
|
376 |
SwitchToState (IDLE_CAMPED_NORMALLY); |
|
377 |
break; |
|
378 |
||
379 |
case CONNECTED_NORMALLY: |
|
380 |
case CONNECTED_REESTABLISHING: |
|
381 |
case CONNECTED_HANDOVER: |
|
382 |
LeaveConnectedMode (); |
|
383 |
break; |
|
384 |
||
385 |
default: |
|
386 |
NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state)); |
|
387 |
break; |
|
388 |
} |
|
389 |
} |
|
390 |
||
391 |
void |
|
392 |
LteUeRrc::DoReceivePdcpSdu (LtePdcpSapUser::ReceivePdcpSduParameters params) |
|
393 |
{ |
|
394 |
NS_LOG_FUNCTION (this); |
|
395 |
m_asSapUser->RecvData (params.pdcpSdu); |
|
396 |
} |
|
397 |
||
398 |
||
399 |
void |
|
400 |
LteUeRrc::DoSetTemporaryCellRnti (uint16_t rnti) |
|
8714
398bbcbb3f42
Add MIMO model, test and documentation
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8583
diff
changeset
|
401 |
{ |
9406 | 402 |
NS_LOG_FUNCTION (this << rnti); |
403 |
m_rnti = rnti; |
|
404 |
m_rrcSapUser->Reestablish (); |
|
405 |
m_cphySapProvider->SetRnti (m_rnti); |
|
406 |
} |
|
9346 | 407 |
|
9406 | 408 |
void |
409 |
LteUeRrc::DoNotifyRandomAccessSuccessful () |
|
410 |
{ |
|
411 |
NS_LOG_FUNCTION (this << m_imsi << ToString (m_state)); |
|
412 |
switch (m_state) |
|
413 |
{ |
|
414 |
case IDLE_RANDOM_ACCESS: |
|
415 |
{ |
|
416 |
// we just received a RAR with a T-C-RNTI and an UL grant |
|
417 |
// send RRC connection request as message 3 of the random access procedure |
|
418 |
SwitchToState (IDLE_CONNECTING); |
|
419 |
LteRrcSap::RrcConnectionRequest msg; |
|
420 |
msg.ueIdentity = m_imsi; |
|
421 |
m_rrcSapUser->SendRrcConnectionRequest (msg); |
|
422 |
} |
|
423 |
break; |
|
424 |
||
425 |
case CONNECTED_HANDOVER: |
|
426 |
{ |
|
427 |
LteRrcSap::RrcConnectionReconfigurationCompleted msg; |
|
428 |
msg.rrcTransactionIdentifier = m_lastRrcTransactionIdentifier; |
|
429 |
m_rrcSapUser->SendRrcConnectionReconfigurationCompleted (msg); |
|
430 |
SwitchToState (CONNECTED_NORMALLY); |
|
431 |
} |
|
432 |
break; |
|
433 |
||
434 |
default: |
|
435 |
NS_FATAL_ERROR ("unexpected event in state " << ToString (m_state)); |
|
436 |
break; |
|
437 |
} |
|
438 |
} |
|
439 |
||
440 |
void |
|
441 |
LteUeRrc::DoNotifyRandomAccessFailed () |
|
442 |
{ |
|
443 |
NS_LOG_FUNCTION (this); |
|
444 |
} |
|
445 |
||
446 |
||
447 |
void |
|
448 |
LteUeRrc::DoForceCampedOnEnb (Ptr<LteEnbNetDevice> enbLteDevice, uint16_t cellId) |
|
449 |
{ |
|
450 |
NS_LOG_FUNCTION (this << cellId); |
|
451 |
||
452 |
m_cellId = cellId; |
|
453 |
m_dlEarfcn = enbLteDevice->GetDlEarfcn (); |
|
454 |
m_cphySapProvider->SyncronizeWithEnb (m_cellId, m_dlEarfcn); |
|
455 |
SwitchToState (IDLE_WAIT_SYSTEM_INFO); |
|
8714
398bbcbb3f42
Add MIMO model, test and documentation
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8583
diff
changeset
|
456 |
} |
398bbcbb3f42
Add MIMO model, test and documentation
Marco Miozzo <marco.miozzo@cttc.es>
parents:
8583
diff
changeset
|
457 |
|
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
458 |
void |
9406 | 459 |
LteUeRrc::DoConnect () |
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
460 |
{ |
9406 | 461 |
NS_LOG_FUNCTION (this); |
462 |
switch (m_state) |
|
463 |
{ |
|
464 |
case IDLE_CELL_SELECTION: |
|
465 |
case IDLE_WAIT_SYSTEM_INFO: |
|
466 |
m_connectionPending = true; |
|
467 |
break; |
|
468 |
||
469 |
case IDLE_CAMPED_NORMALLY: |
|
470 |
StartConnection (); |
|
471 |
break; |
|
472 |
||
473 |
case IDLE_RANDOM_ACCESS: |
|
474 |
case IDLE_CONNECTING: |
|
475 |
NS_LOG_WARN ("already connecting (state " << ToString (m_state) << ")"); |
|
476 |
break; |
|
477 |
||
478 |
case CONNECTED_NORMALLY: |
|
479 |
case CONNECTED_REESTABLISHING: |
|
480 |
case CONNECTED_HANDOVER: |
|
481 |
NS_LOG_WARN ("already connected (state " << ToString (m_state) << ")"); |
|
482 |
break; |
|
483 |
||
484 |
default: |
|
485 |
NS_FATAL_ERROR ("cannot connect while in state " << ToString (m_state)); |
|
486 |
break; |
|
487 |
} |
|
488 |
||
489 |
||
490 |
} |
|
491 |
||
492 |
||
493 |
||
494 |
// CPHY SAP methods |
|
495 |
||
496 |
void |
|
497 |
LteUeRrc::DoRecvMasterInformationBlock (LteRrcSap::MasterInformationBlock msg) |
|
498 |
{ |
|
499 |
NS_LOG_FUNCTION (this); |
|
500 |
m_dlBandwidth = msg.dlBandwidth; |
|
501 |
m_cphySapProvider->SetDlBandwidth (msg.dlBandwidth); |
|
502 |
m_receivedMib = true; |
|
503 |
if (m_state == IDLE_WAIT_SYSTEM_INFO && m_receivedMib && m_receivedSib2) |
|
504 |
{ |
|
505 |
SwitchToState (IDLE_CAMPED_NORMALLY); |
|
506 |
} |
|
507 |
} |
|
508 |
||
509 |
||
510 |
||
511 |
// RRC SAP methods |
|
512 |
||
513 |
void |
|
514 |
LteUeRrc::DoRecvSystemInformationBlockType1 (LteRrcSap::SystemInformationBlockType1 msg) |
|
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
515 |
{ |
9406 | 516 |
NS_LOG_FUNCTION (this); |
517 |
// to be implemented |
|
518 |
} |
|
519 |
||
520 |
||
521 |
void |
|
522 |
LteUeRrc::DoRecvSystemInformation (LteRrcSap::SystemInformation msg) |
|
523 |
{ |
|
524 |
NS_LOG_FUNCTION (this); |
|
525 |
if (msg.haveSib2) |
|
526 |
{ |
|
527 |
m_receivedSib2 = true; |
|
528 |
m_ulBandwidth = msg.sib2.freqInfo.ulBandwidth; |
|
529 |
m_ulEarfcn = msg.sib2.freqInfo.ulCarrierFreq; |
|
9413
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
530 |
LteUeCmacSapProvider::RachConfig rc; |
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
531 |
rc.numberOfRaPreambles = msg.sib2.radioResourceConfigCommon.rachConfigCommon.preambleInfo.numberOfRaPreambles; |
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
532 |
rc.preambleTransMax = msg.sib2.radioResourceConfigCommon.rachConfigCommon.raSupervisionInfo.preambleTransMax; |
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
533 |
rc.raResponseWindowSize = msg.sib2.radioResourceConfigCommon.rachConfigCommon.raSupervisionInfo.raResponseWindowSize; |
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
534 |
m_cmacSapProvider->ConfigureRach (rc); |
9406 | 535 |
m_cphySapProvider->ConfigureUplink (m_ulEarfcn, m_ulBandwidth); |
536 |
} |
|
537 |
if (m_state == IDLE_WAIT_SYSTEM_INFO && m_receivedMib && m_receivedSib2) |
|
538 |
{ |
|
539 |
SwitchToState (IDLE_CAMPED_NORMALLY); |
|
540 |
} |
|
541 |
} |
|
542 |
||
543 |
||
544 |
void |
|
545 |
LteUeRrc::DoRecvRrcConnectionSetup (LteRrcSap::RrcConnectionSetup msg) |
|
546 |
{ |
|
547 |
NS_LOG_FUNCTION (this); |
|
548 |
switch (m_state) |
|
549 |
{ |
|
550 |
case IDLE_CONNECTING: |
|
551 |
{ |
|
552 |
ApplyRadioResourceConfigDedicated (msg.radioResourceConfigDedicated); |
|
553 |
SwitchToState (CONNECTED_NORMALLY); |
|
554 |
LteRrcSap::RrcConnectionSetupCompleted msg2; |
|
555 |
msg2.rrcTransactionIdentifier = msg.rrcTransactionIdentifier; |
|
556 |
m_rrcSapUser->SendRrcConnectionSetupCompleted (msg2); |
|
557 |
m_asSapUser->NotifyConnectionSuccessful (); |
|
558 |
} |
|
559 |
break; |
|
560 |
||
561 |
default: |
|
562 |
NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state)); |
|
563 |
break; |
|
564 |
} |
|
565 |
} |
|
566 |
||
567 |
void |
|
568 |
LteUeRrc::DoRecvRrcConnectionReconfiguration (LteRrcSap::RrcConnectionReconfiguration msg) |
|
569 |
{ |
|
570 |
NS_LOG_FUNCTION (this << " RNTI " << m_rnti); |
|
571 |
switch (m_state) |
|
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
572 |
{ |
9406 | 573 |
case CONNECTED_NORMALLY: |
574 |
if (msg.haveRadioResourceConfigDedicated) |
|
575 |
{ |
|
576 |
ApplyRadioResourceConfigDedicated (msg.radioResourceConfigDedicated); |
|
577 |
} |
|
578 |
if (msg.haveMobilityControlInfo) |
|
579 |
{ |
|
9413
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
580 |
NS_LOG_INFO ("haveMobilityControlInfo == true"); |
9406 | 581 |
SwitchToState (CONNECTED_HANDOVER); |
582 |
const LteRrcSap::MobilityControlInfo& mci = msg.mobilityControlInfo; |
|
583 |
m_cellId = mci.targetPhysCellId; |
|
584 |
NS_ASSERT (mci.haveCarrierFreq); |
|
585 |
NS_ASSERT (mci.haveCarrierBandwidth); |
|
586 |
m_cphySapProvider->SyncronizeWithEnb (m_cellId, mci.carrierFreq.dlCarrierFreq); |
|
587 |
m_cphySapProvider->SetDlBandwidth ( mci.carrierBandwidth.dlBandwidth); |
|
588 |
m_cphySapProvider->ConfigureUplink (mci.carrierFreq.ulCarrierFreq, mci.carrierBandwidth.ulBandwidth); |
|
589 |
m_rnti = msg.mobilityControlInfo.newUeIdentity; |
|
590 |
NS_ASSERT_MSG (mci.haveRachConfigDedicated, "handover is only supported with non-contention-based random access procedure"); |
|
591 |
m_cmacSapProvider->StartNonContentionBasedRandomAccessProcedure (m_rnti, mci.rachConfigDedicated.raPreambleIndex, mci.rachConfigDedicated.raPrachMaskIndex); |
|
592 |
m_cphySapProvider->SetRnti (m_rnti); |
|
593 |
m_lastRrcTransactionIdentifier = msg.rrcTransactionIdentifier; |
|
594 |
// RRC connection reconfiguration completed will be sent |
|
595 |
// after handover is completed |
|
596 |
} |
|
597 |
else |
|
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
598 |
{ |
9413
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
599 |
NS_LOG_INFO ("haveMobilityControlInfo == false"); |
9406 | 600 |
LteRrcSap::RrcConnectionReconfigurationCompleted msg2; |
601 |
msg2.rrcTransactionIdentifier = msg.rrcTransactionIdentifier; |
|
602 |
m_rrcSapUser->SendRrcConnectionReconfigurationCompleted (msg2); |
|
603 |
} |
|
604 |
break; |
|
605 |
||
606 |
default: |
|
607 |
NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state)); |
|
608 |
break; |
|
609 |
} |
|
610 |
} |
|
611 |
||
612 |
void |
|
613 |
LteUeRrc::DoRecvRrcConnectionReestablishment (LteRrcSap::RrcConnectionReestablishment msg) |
|
614 |
{ |
|
615 |
switch (m_state) |
|
616 |
{ |
|
617 |
case CONNECTED_REESTABLISHING: |
|
618 |
{ |
|
619 |
} |
|
620 |
break; |
|
621 |
||
622 |
default: |
|
623 |
NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state)); |
|
624 |
break; |
|
625 |
} |
|
626 |
} |
|
627 |
||
628 |
void |
|
629 |
LteUeRrc::DoRecvRrcConnectionReestablishmentReject (LteRrcSap::RrcConnectionReestablishmentReject msg) |
|
630 |
{ |
|
631 |
NS_LOG_FUNCTION (this); |
|
632 |
switch (m_state) |
|
633 |
{ |
|
634 |
case CONNECTED_REESTABLISHING: |
|
635 |
{ |
|
636 |
LeaveConnectedMode (); |
|
637 |
} |
|
638 |
break; |
|
639 |
||
640 |
default: |
|
641 |
NS_FATAL_ERROR ("method unexpected in state " << ToString (m_state)); |
|
642 |
break; |
|
643 |
} |
|
644 |
} |
|
645 |
||
646 |
void |
|
647 |
LteUeRrc::DoRecvRrcConnectionRelease (LteRrcSap::RrcConnectionRelease msg) |
|
648 |
{ |
|
649 |
NS_LOG_FUNCTION (this); |
|
650 |
} |
|
651 |
||
652 |
||
653 |
||
654 |
||
655 |
void |
|
656 |
LteUeRrc::ApplyRadioResourceConfigDedicated (LteRrcSap::RadioResourceConfigDedicated rrcd) |
|
657 |
{ |
|
658 |
NS_LOG_FUNCTION (this); |
|
659 |
const struct LteRrcSap::PhysicalConfigDedicated& pcd = rrcd.physicalConfigDedicated; |
|
660 |
||
661 |
if (pcd.haveAntennaInfoDedicated) |
|
662 |
{ |
|
663 |
m_cphySapProvider->SetTransmissionMode (pcd.antennaInfo.transmissionMode); |
|
664 |
} |
|
665 |
if (pcd.haveSoundingRsUlConfigDedicated) |
|
666 |
{ |
|
667 |
m_cphySapProvider->SetSrsConfigurationIndex (pcd.soundingRsUlConfigDedicated.srsConfigIndex); |
|
668 |
} |
|
669 |
||
670 |
std::list<LteRrcSap::SrbToAddMod>::const_iterator stamIt = rrcd.srbToAddModList.begin (); |
|
671 |
if (stamIt != rrcd.srbToAddModList.end ()) |
|
672 |
{ |
|
673 |
if (m_srb1 == 0) |
|
674 |
{ |
|
675 |
// SRB1 not setup yet |
|
676 |
NS_ASSERT_MSG (m_state == IDLE_CONNECTING, "expected state IDLE_CONNECTING, actual state " << ToString (m_state)); |
|
677 |
NS_ASSERT_MSG (stamIt->srbIdentity == 1, "only SRB1 supported"); |
|
678 |
||
679 |
const uint8_t lcid = 1; // fixed LCID for SRB1 |
|
680 |
||
681 |
Ptr<LteRlc> rlc = CreateObject<LteRlcAm> (); |
|
682 |
rlc->SetLteMacSapProvider (m_macSapProvider); |
|
683 |
rlc->SetRnti (m_rnti); |
|
684 |
rlc->SetLcId (lcid); |
|
685 |
||
686 |
Ptr<LtePdcp> pdcp = CreateObject<LtePdcp> (); |
|
687 |
pdcp->SetRnti (m_rnti); |
|
688 |
pdcp->SetLcId (lcid); |
|
689 |
pdcp->SetLtePdcpSapUser (m_pdcpSapUser); |
|
690 |
pdcp->SetLteRlcSapProvider (rlc->GetLteRlcSapProvider ()); |
|
691 |
rlc->SetLteRlcSapUser (pdcp->GetLteRlcSapUser ()); |
|
692 |
||
693 |
m_srb1 = CreateObject<LteSignalingRadioBearerInfo> (); |
|
694 |
m_srb1->m_rlc = rlc; |
|
695 |
m_srb1->m_pdcp = pdcp; |
|
696 |
m_srb1->m_srbIdentity = 1; |
|
697 |
||
698 |
m_srb1->m_logicalChannelConfig.priority = stamIt->logicalChannelConfig.priority; |
|
699 |
m_srb1->m_logicalChannelConfig.prioritizedBitRateKbps = stamIt->logicalChannelConfig.prioritizedBitRateKbps; |
|
700 |
m_srb1->m_logicalChannelConfig.bucketSizeDurationMs = stamIt->logicalChannelConfig.bucketSizeDurationMs; |
|
701 |
m_srb1->m_logicalChannelConfig.logicalChannelGroup = stamIt->logicalChannelConfig.logicalChannelGroup; |
|
702 |
||
703 |
struct LteUeCmacSapProvider::LogicalChannelConfig lcConfig; |
|
704 |
lcConfig.priority = stamIt->logicalChannelConfig.priority; |
|
705 |
lcConfig.prioritizedBitRateKbps = stamIt->logicalChannelConfig.prioritizedBitRateKbps; |
|
706 |
lcConfig.bucketSizeDurationMs = stamIt->logicalChannelConfig.bucketSizeDurationMs; |
|
707 |
lcConfig.logicalChannelGroup = stamIt->logicalChannelConfig.logicalChannelGroup; |
|
708 |
||
709 |
m_cmacSapProvider->AddLc (lcid, lcConfig, rlc->GetLteMacSapUser ()); |
|
710 |
||
711 |
++stamIt; |
|
712 |
NS_ASSERT_MSG (stamIt == rrcd.srbToAddModList.end (), "at most one SrbToAdd supported"); |
|
713 |
} |
|
714 |
else |
|
715 |
{ |
|
716 |
NS_LOG_INFO ("request to modify SRB1 (skipping as currently not implemented)"); |
|
717 |
// would need to modify m_srb1, and then propagate changes to the MAC |
|
718 |
} |
|
719 |
} |
|
720 |
||
721 |
||
722 |
std::list<LteRrcSap::DrbToAddMod>::const_iterator dtamIt; |
|
723 |
for (dtamIt = rrcd.drbToAddModList.begin (); |
|
724 |
dtamIt != rrcd.drbToAddModList.end (); |
|
725 |
++dtamIt) |
|
726 |
{ |
|
9413
20f1c6678ee2
improved LTE Random Access model
Nicola Baldo <nbaldo@cttc.es>
parents:
9406
diff
changeset
|
727 |
NS_LOG_INFO (this << " IMSI " << m_imsi << " adding/modifying DRBID " << (uint32_t) dtamIt->drbIdentity << " LC " << (uint32_t) dtamIt->logicalChannelIdentity); |
9406 | 728 |
NS_ASSERT_MSG (dtamIt->logicalChannelIdentity > 2, "LCID value " << dtamIt->logicalChannelIdentity << " is reserved for SRBs"); |
729 |
||
730 |
std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator drbMapIt = m_drbMap.find (dtamIt->drbIdentity); |
|
731 |
if (drbMapIt == m_drbMap.end ()) |
|
732 |
{ |
|
733 |
NS_LOG_INFO ("New Data Radio Bearer"); |
|
734 |
||
735 |
TypeId rlcTypeId; |
|
736 |
if (m_useRlcSm) |
|
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
737 |
{ |
9406 | 738 |
rlcTypeId = LteRlcSm::GetTypeId (); |
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
739 |
} |
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
740 |
else |
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
741 |
{ |
9406 | 742 |
switch (dtamIt->rlcConfig.choice) |
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
743 |
{ |
9406 | 744 |
case LteRrcSap::RlcConfig::AM: |
745 |
rlcTypeId = LteRlcAm::GetTypeId (); |
|
746 |
break; |
|
747 |
||
748 |
case LteRrcSap::RlcConfig::UM_BI_DIRECTIONAL: |
|
749 |
rlcTypeId = LteRlcUm::GetTypeId (); |
|
750 |
break; |
|
751 |
||
752 |
default: |
|
753 |
NS_FATAL_ERROR ("unsupported RLC configuration"); |
|
754 |
break; |
|
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
755 |
} |
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
756 |
} |
9406 | 757 |
|
758 |
ObjectFactory rlcObjectFactory; |
|
759 |
rlcObjectFactory.SetTypeId (rlcTypeId); |
|
760 |
Ptr<LteRlc> rlc = rlcObjectFactory.Create ()->GetObject<LteRlc> (); |
|
761 |
rlc->SetLteMacSapProvider (m_macSapProvider); |
|
762 |
rlc->SetRnti (m_rnti); |
|
763 |
rlc->SetLcId (dtamIt->logicalChannelIdentity); |
|
764 |
||
9422
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
765 |
Ptr<LteDataRadioBearerInfo> drbInfo = CreateObject<LteDataRadioBearerInfo> (); |
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
766 |
drbInfo->m_rlc = rlc; |
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
767 |
drbInfo->m_epsBearerIdentity = dtamIt->epsBearerIdentity; |
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
768 |
drbInfo->m_logicalChannelIdentity = dtamIt->logicalChannelIdentity; |
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
769 |
drbInfo->m_drbIdentity = dtamIt->drbIdentity; |
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
770 |
|
9406 | 771 |
// we need PDCP only for real RLC, i.e., RLC/UM or RLC/AM |
772 |
// if we are using RLC/SM we don't care of anything above RLC |
|
773 |
if (rlcTypeId != LteRlcSm::GetTypeId ()) |
|
774 |
{ |
|
775 |
Ptr<LtePdcp> pdcp = CreateObject<LtePdcp> (); |
|
776 |
pdcp->SetRnti (m_rnti); |
|
777 |
pdcp->SetLcId (dtamIt->logicalChannelIdentity); |
|
778 |
pdcp->SetLtePdcpSapUser (m_pdcpSapUser); |
|
779 |
pdcp->SetLteRlcSapProvider (rlc->GetLteRlcSapProvider ()); |
|
780 |
rlc->SetLteRlcSapUser (pdcp->GetLteRlcSapUser ()); |
|
9422
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
781 |
drbInfo->m_pdcp = pdcp; |
9406 | 782 |
} |
783 |
||
784 |
m_bid2DrbidMap[dtamIt->epsBearerIdentity] = dtamIt->drbIdentity; |
|
785 |
||
9422
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
786 |
m_drbMap.insert (std::pair<uint8_t, Ptr<LteDataRadioBearerInfo> > (dtamIt->drbIdentity, drbInfo)); |
9406 | 787 |
|
788 |
||
789 |
struct LteUeCmacSapProvider::LogicalChannelConfig lcConfig; |
|
790 |
lcConfig.priority = dtamIt->logicalChannelConfig.priority; |
|
791 |
lcConfig.prioritizedBitRateKbps = dtamIt->logicalChannelConfig.prioritizedBitRateKbps; |
|
792 |
lcConfig.bucketSizeDurationMs = dtamIt->logicalChannelConfig.bucketSizeDurationMs; |
|
793 |
lcConfig.logicalChannelGroup = dtamIt->logicalChannelConfig.logicalChannelGroup; |
|
794 |
||
795 |
m_cmacSapProvider->AddLc (dtamIt->logicalChannelIdentity, |
|
796 |
lcConfig, |
|
797 |
rlc->GetLteMacSapUser ()); |
|
798 |
} |
|
799 |
else |
|
800 |
{ |
|
9422
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
801 |
NS_LOG_INFO ("request to modify existing DRBID"); |
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
802 |
Ptr<LteDataRadioBearerInfo> drbInfo = drbMapIt->second; |
e0388ce05fcc
check bearer structs in lte-rrc test
Nicola Baldo <nbaldo@cttc.es>
parents:
9414
diff
changeset
|
803 |
// TODO: currently not implemented. Would need to modify drbInfo, and then propagate changes to the MAC |
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
804 |
} |
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
805 |
} |
9406 | 806 |
|
807 |
std::list<uint8_t>::iterator dtdmIt; |
|
808 |
for (dtdmIt = rrcd.drbToReleaseList.begin (); |
|
809 |
dtdmIt != rrcd.drbToReleaseList.end (); |
|
810 |
++dtdmIt) |
|
811 |
{ |
|
812 |
uint8_t drbid = *dtdmIt; |
|
813 |
NS_LOG_INFO (this << " IMSI " << m_imsi << " releasing DRB " << (uint32_t) drbid << drbid); |
|
814 |
std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it = m_drbMap.find (drbid); |
|
815 |
NS_ASSERT_MSG (it != m_drbMap.end (), "could not find bearer with given lcid"); |
|
816 |
m_drbMap.erase (it); |
|
817 |
m_bid2DrbidMap.erase (drbid); |
|
818 |
} |
|
819 |
} |
|
820 |
||
821 |
||
822 |
void |
|
823 |
LteUeRrc::StartConnection () |
|
824 |
{ |
|
825 |
NS_LOG_FUNCTION (this); |
|
826 |
m_connectionPending = false; |
|
827 |
SwitchToState (IDLE_RANDOM_ACCESS); |
|
828 |
m_cmacSapProvider->StartContentionBasedRandomAccessProcedure (); |
|
829 |
} |
|
830 |
||
831 |
void |
|
832 |
LteUeRrc::LeaveConnectedMode () |
|
833 |
{ |
|
834 |
NS_LOG_FUNCTION (this << m_imsi); |
|
835 |
m_asSapUser->NotifyConnectionReleased (); |
|
836 |
m_cmacSapProvider->RemoveLc (1); |
|
837 |
std::map<uint8_t, Ptr<LteDataRadioBearerInfo> >::iterator it; |
|
838 |
for (it = m_drbMap.begin (); it != m_drbMap.end (); ++it) |
|
839 |
{ |
|
840 |
m_cmacSapProvider->RemoveLc (it->second->m_logicalChannelIdentity); |
|
841 |
} |
|
842 |
m_drbMap.clear (); |
|
843 |
m_bid2DrbidMap.clear (); |
|
844 |
m_srb1 = 0; |
|
845 |
SwitchToState (IDLE_CAMPED_NORMALLY); |
|
846 |
} |
|
847 |
||
7886 | 848 |
|
9406 | 849 |
uint8_t |
850 |
LteUeRrc::Bid2Drbid (uint8_t bid) |
|
851 |
{ |
|
852 |
std::map<uint8_t, uint8_t>::iterator it = m_bid2DrbidMap.find (bid); |
|
853 |
NS_ASSERT_MSG (it != m_bid2DrbidMap.end (), "could not find BID " << bid); |
|
854 |
return it->second; |
|
855 |
} |
|
856 |
||
857 |
||
858 |
void |
|
859 |
LteUeRrc::SwitchToState (State newState) |
|
860 |
{ |
|
861 |
NS_LOG_FUNCTION (this << newState); |
|
862 |
State oldState = m_state; |
|
863 |
m_state = newState; |
|
864 |
NS_LOG_INFO ("IMSI " << m_imsi << " RNTI " << m_rnti << " UeRrc " << ToString (oldState) << " --> " << ToString (newState)); |
|
865 |
m_stateTransitionCallback (oldState, newState); |
|
866 |
||
867 |
switch (newState) |
|
868 |
{ |
|
869 |
case IDLE_CELL_SELECTION: |
|
870 |
break; |
|
871 |
||
872 |
case IDLE_WAIT_SYSTEM_INFO: |
|
873 |
break; |
|
874 |
||
875 |
case IDLE_CAMPED_NORMALLY: |
|
876 |
if (m_connectionPending) |
|
877 |
{ |
|
878 |
StartConnection (); |
|
879 |
} |
|
880 |
break; |
|
881 |
||
882 |
case IDLE_RANDOM_ACCESS: |
|
883 |
break; |
|
884 |
||
885 |
case IDLE_CONNECTING: |
|
886 |
break; |
|
887 |
||
888 |
case CONNECTED_NORMALLY: |
|
889 |
break; |
|
890 |
||
891 |
case CONNECTED_REESTABLISHING: |
|
892 |
break; |
|
893 |
||
894 |
case CONNECTED_HANDOVER: |
|
895 |
break; |
|
896 |
||
897 |
default: |
|
898 |
break; |
|
899 |
} |
|
900 |
} |
|
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
901 |
|
9406 | 902 |
|
903 |
||
9345
8290ae6cab62
add/remove UEs and bearers upon handover
Nicola Baldo <nicola@baldo.biz>
parents:
9337
diff
changeset
|
904 |
|
7886 | 905 |
} // namespace ns3 |
906 |