author | Manuel Requena <manuel.requena@cttc.es> |
Tue, 26 Mar 2013 10:41:49 +0100 | |
changeset 10019 | 6efd95740e39 |
parent 9439 | 5107601b7a75 |
child 9653 | 382d27da8905 |
permissions | -rw-r--r-- |
6705 | 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> |
|
7886 | 19 |
* Nicola Baldo <nbaldo@cttc.es> |
20 |
* Marco Miozzo <mmiozzo@cttc.es> |
|
6705 | 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" |
|
9327
6f8d10f0fb94
Add CellId info to X2 SAP
Manuel Requena <manuel.requena@cttc.es>
parents:
8395
diff
changeset
|
34 |
#include "ns3/lte-enb-net-device.h" |
7887 | 35 |
#include "lte-ue-net-device.h" |
7886 | 36 |
#include "lte-ue-mac.h" |
37 |
#include "lte-ue-rrc.h" |
|
6705 | 38 |
#include "ns3/ipv4-header.h" |
39 |
#include "ns3/ipv4.h" |
|
7887 | 40 |
#include "lte-amc.h" |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
41 |
#include "lte-ue-phy.h" |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
42 |
#include "epc-ue-nas.h" |
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
43 |
#include <ns3/ipv4-l3-protocol.h> |
8256
629982ba48a8
removed some useless inclusions of log.h
Nicola Baldo <nbaldo@cttc.es>
parents:
8253
diff
changeset
|
44 |
#include <ns3/log.h> |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
45 |
#include "epc-tft.h" |
6705 | 46 |
|
7887 | 47 |
NS_LOG_COMPONENT_DEFINE ("LteUeNetDevice"); |
6705 | 48 |
|
49 |
namespace ns3 { |
|
50 |
||
7887 | 51 |
NS_OBJECT_ENSURE_REGISTERED ( LteUeNetDevice); |
6705 | 52 |
|
53 |
||
7887 | 54 |
TypeId LteUeNetDevice::GetTypeId (void) |
6705 | 55 |
{ |
56 |
static TypeId |
|
7252
c8200621e252
rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents:
6852
diff
changeset
|
57 |
tid = |
7887 | 58 |
TypeId ("ns3::LteUeNetDevice") |
7954 | 59 |
.SetParent<LteNetDevice> () |
60 |
.AddAttribute ("LteUeRrc", |
|
61 |
"The RRC associated to this UeNetDevice", |
|
62 |
PointerValue (), |
|
63 |
MakePointerAccessor (&LteUeNetDevice::m_rrc), |
|
64 |
MakePointerChecker <LteUeRrc> ()) |
|
8329 | 65 |
.AddAttribute ("LteUeMac", |
66 |
"The MAC associated to this UeNetDevice", |
|
67 |
PointerValue (), |
|
68 |
MakePointerAccessor (&LteUeNetDevice::m_mac), |
|
69 |
MakePointerChecker <LteUeMac> ()) |
|
70 |
.AddAttribute ("LteUePhy", |
|
71 |
"The PHY associated to this UeNetDevice", |
|
72 |
PointerValue (), |
|
73 |
MakePointerAccessor (&LteUeNetDevice::m_phy), |
|
74 |
MakePointerChecker <LteUePhy> ()) |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
75 |
.AddAttribute ("Imsi", |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8032
diff
changeset
|
76 |
"International Mobile Subscriber Identity assigned to this UE", |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
77 |
UintegerValue (0), // unused, read-only attribute |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
78 |
MakeUintegerAccessor (&LteUeNetDevice::GetImsi), |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
79 |
MakeUintegerChecker<uint64_t> ()) |
8148
09e2d03022a2
run check-style on src/lte/model
Nicola Baldo <nbaldo@cttc.es>
parents:
8032
diff
changeset
|
80 |
; |
7954 | 81 |
|
6705 | 82 |
return tid; |
83 |
} |
|
84 |
||
85 |
||
7887 | 86 |
LteUeNetDevice::LteUeNetDevice (void) |
6705 | 87 |
{ |
88 |
NS_LOG_FUNCTION (this); |
|
7886 | 89 |
NS_FATAL_ERROR ("This constructor should not be called"); |
6705 | 90 |
} |
91 |
||
92 |
||
9439
5107601b7a75
added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents:
9430
diff
changeset
|
93 |
LteUeNetDevice::LteUeNetDevice (Ptr<Node> node, Ptr<LteUePhy> phy, Ptr<LteUeMac> mac, Ptr<LteUeRrc> rrc, Ptr<EpcUeNas> nas, uint64_t imsi) |
6705 | 94 |
{ |
95 |
NS_LOG_FUNCTION (this); |
|
7906
d58de34e41d3
MAC, RRC and Scheduler created by LenaHelper
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7903
diff
changeset
|
96 |
m_phy = phy; |
d58de34e41d3
MAC, RRC and Scheduler created by LenaHelper
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7903
diff
changeset
|
97 |
m_mac = mac; |
d58de34e41d3
MAC, RRC and Scheduler created by LenaHelper
Marco Miozzo <marco.miozzo@cttc.es>
parents:
7903
diff
changeset
|
98 |
m_rrc = rrc; |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
99 |
m_nas = nas; |
6705 | 100 |
SetNode (node); |
9439
5107601b7a75
added S1 path switch + S11 modify bearer for X2 handover
Nicola Baldo <nbaldo@cttc.es>
parents:
9430
diff
changeset
|
101 |
m_imsi = imsi; |
6705 | 102 |
} |
103 |
||
7887 | 104 |
LteUeNetDevice::~LteUeNetDevice (void) |
6705 | 105 |
{ |
106 |
NS_LOG_FUNCTION (this); |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
107 |
} |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
108 |
|
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
109 |
void |
7887 | 110 |
LteUeNetDevice::DoDispose (void) |
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
111 |
{ |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
112 |
NS_LOG_FUNCTION (this); |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
113 |
m_targetEnb = 0; |
7921 | 114 |
m_mac->Dispose (); |
115 |
m_mac = 0; |
|
116 |
m_rrc->Dispose (); |
|
117 |
m_rrc = 0; |
|
118 |
m_phy->Dispose (); |
|
119 |
m_phy = 0; |
|
9370
3d5962a58440
Dispose EpcUeNas within LteUeNetDevice
Nicola Baldo <nbaldo@cttc.es>
parents:
9338
diff
changeset
|
120 |
m_nas->Dispose (); |
3d5962a58440
Dispose EpcUeNas within LteUeNetDevice
Nicola Baldo <nbaldo@cttc.es>
parents:
9338
diff
changeset
|
121 |
m_nas = 0; |
6709
4f3100141560
fixed some valgrind errors
Giuseppe Piro <g.piro@poliba.it>
parents:
6705
diff
changeset
|
122 |
LteNetDevice::DoDispose (); |
6705 | 123 |
} |
124 |
||
125 |
void |
|
7945
dbab335f9eea
connection of SAPs moved from UeNetDevice to LenaHelper
Nicola Baldo <nbaldo@cttc.es>
parents:
7924
diff
changeset
|
126 |
LteUeNetDevice::UpdateConfig (void) |
6705 | 127 |
{ |
128 |
NS_LOG_FUNCTION (this); |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
129 |
m_nas->SetImsi (m_imsi); |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
130 |
m_rrc->SetImsi (m_imsi); |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
131 |
|
6705 | 132 |
} |
133 |
||
134 |
||
7886 | 135 |
|
136 |
Ptr<LteUeMac> |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
137 |
LteUeNetDevice::GetMac (void) const |
6705 | 138 |
{ |
139 |
NS_LOG_FUNCTION (this); |
|
7886 | 140 |
return m_mac; |
6705 | 141 |
} |
142 |
||
143 |
||
7886 | 144 |
Ptr<LteUeRrc> |
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
145 |
LteUeNetDevice::GetRrc (void) const |
6705 | 146 |
{ |
147 |
NS_LOG_FUNCTION (this); |
|
7886 | 148 |
return m_rrc; |
6705 | 149 |
} |
150 |
||
151 |
||
7887 | 152 |
Ptr<LteUePhy> |
153 |
LteUeNetDevice::GetPhy (void) const |
|
7886 | 154 |
{ |
155 |
NS_LOG_FUNCTION (this); |
|
156 |
return m_phy; |
|
157 |
} |
|
158 |
||
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
159 |
Ptr<EpcUeNas> |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
160 |
LteUeNetDevice::GetNas (void) const |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
161 |
{ |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
162 |
NS_LOG_FUNCTION (this); |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
163 |
return m_nas; |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
164 |
} |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
165 |
|
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
166 |
uint64_t |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
167 |
LteUeNetDevice::GetImsi () const |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
168 |
{ |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
169 |
NS_LOG_FUNCTION (this); |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
170 |
return m_imsi; |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
171 |
} |
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
172 |
|
6705 | 173 |
void |
7887 | 174 |
LteUeNetDevice::SetTargetEnb (Ptr<LteEnbNetDevice> enb) |
6705 | 175 |
{ |
176 |
NS_LOG_FUNCTION (this << enb); |
|
177 |
m_targetEnb = enb; |
|
178 |
} |
|
179 |
||
180 |
||
7887 | 181 |
Ptr<LteEnbNetDevice> |
182 |
LteUeNetDevice::GetTargetEnb (void) |
|
6705 | 183 |
{ |
184 |
NS_LOG_FUNCTION (this); |
|
185 |
return m_targetEnb; |
|
186 |
} |
|
187 |
||
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
188 |
void |
7976
541eee38ac12
fixed LENA-78 m_dlBandwidth not initialized
Nicola Baldo <nbaldo@cttc.es>
parents:
7955
diff
changeset
|
189 |
LteUeNetDevice::DoStart (void) |
541eee38ac12
fixed LENA-78 m_dlBandwidth not initialized
Nicola Baldo <nbaldo@cttc.es>
parents:
7955
diff
changeset
|
190 |
{ |
8032 | 191 |
NS_LOG_FUNCTION (this); |
7976
541eee38ac12
fixed LENA-78 m_dlBandwidth not initialized
Nicola Baldo <nbaldo@cttc.es>
parents:
7955
diff
changeset
|
192 |
UpdateConfig (); |
8015 | 193 |
m_phy->Start (); |
194 |
m_mac->Start (); |
|
195 |
m_rrc->Start (); |
|
7976
541eee38ac12
fixed LENA-78 m_dlBandwidth not initialized
Nicola Baldo <nbaldo@cttc.es>
parents:
7955
diff
changeset
|
196 |
} |
541eee38ac12
fixed LENA-78 m_dlBandwidth not initialized
Nicola Baldo <nbaldo@cttc.es>
parents:
7955
diff
changeset
|
197 |
|
6705 | 198 |
bool |
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
199 |
LteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) |
6705 | 200 |
{ |
8389
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
201 |
NS_LOG_FUNCTION (this << dest << protocolNumber); |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
202 |
NS_ASSERT_MSG (protocolNumber == Ipv4L3Protocol::PROT_NUMBER, "unsupported protocol " << protocolNumber << ", only IPv4 is supported"); |
cb215987eb77
LTE-EPC end-to-end data plane imlemented and partially working
Nicola Baldo <nbaldo@cttc.es>
parents:
8167
diff
changeset
|
203 |
|
9337
ae7126b266ce
revised LTE protocol stack for new RRC model
Nicola Baldo <nbaldo@cttc.es>
parents:
8395
diff
changeset
|
204 |
return m_nas->Send (packet); |
6705 | 205 |
} |
206 |
||
207 |
||
208 |
} // namespace ns3 |