OLD | NEW |
(Empty) | |
| 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 "nist-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/nist-lte-enb-net-device.h" |
| 35 #include "nist-lte-ue-net-device.h" |
| 36 #include "nist-lte-ue-mac.h" |
| 37 #include "nist-lte-ue-rrc.h" |
| 38 #include "ns3/ipv4-header.h" |
| 39 #include "ns3/ipv4.h" |
| 40 #include "nist-lte-amc.h" |
| 41 #include "nist-lte-ue-phy.h" |
| 42 #include "nist-epc-ue-nas.h" |
| 43 #include <ns3/ipv4-l3-protocol.h> |
| 44 #include <ns3/log.h> |
| 45 #include "nist-epc-tft.h" |
| 46 |
| 47 namespace ns3 { |
| 48 |
| 49 NS_LOG_COMPONENT_DEFINE ("NistLteUeNetDevice"); |
| 50 |
| 51 NS_OBJECT_ENSURE_REGISTERED ( NistLteUeNetDevice); |
| 52 |
| 53 |
| 54 TypeId NistLteUeNetDevice::GetTypeId (void) |
| 55 { |
| 56 static TypeId |
| 57 tid = |
| 58 TypeId ("ns3::NistLteUeNetDevice") |
| 59 .SetParent<NistLteNetDevice> () |
| 60 .AddConstructor<NistLteUeNetDevice> () |
| 61 .AddAttribute ("NistEpcUeNas", |
| 62 "The NAS associated to this UeNetDevice", |
| 63 PointerValue (), |
| 64 MakePointerAccessor (&NistLteUeNetDevice::m_nas), |
| 65 MakePointerChecker <NistEpcUeNas> ()) |
| 66 .AddAttribute ("NistLteUeRrc", |
| 67 "The RRC associated to this UeNetDevice", |
| 68 PointerValue (), |
| 69 MakePointerAccessor (&NistLteUeNetDevice::m_rrc), |
| 70 MakePointerChecker <NistLteUeRrc> ()) |
| 71 .AddAttribute ("NistLteUeMac", |
| 72 "The MAC associated to this UeNetDevice", |
| 73 PointerValue (), |
| 74 MakePointerAccessor (&NistLteUeNetDevice::m_mac), |
| 75 MakePointerChecker <NistLteUeMac> ()) |
| 76 .AddAttribute ("NistLteUePhy", |
| 77 "The PHY associated to this UeNetDevice", |
| 78 PointerValue (), |
| 79 MakePointerAccessor (&NistLteUeNetDevice::m_phy), |
| 80 MakePointerChecker <NistLteUePhy> ()) |
| 81 .AddAttribute ("Imsi", |
| 82 "International Mobile Subscriber Identity assigned to this UE
", |
| 83 UintegerValue (0), |
| 84 MakeUintegerAccessor (&NistLteUeNetDevice::m_imsi), |
| 85 MakeUintegerChecker<uint64_t> ()) |
| 86 .AddAttribute ("DlEarfcn", |
| 87 "Downlink E-UTRA Absolute Radio Frequency Channel Number (EAR
FCN) " |
| 88 "as per 3GPP 36.101 Section 5.7.3. ", |
| 89 UintegerValue (100), |
| 90 MakeUintegerAccessor (&NistLteUeNetDevice::SetDlEarfcn, |
| 91 &NistLteUeNetDevice::GetDlEarfcn), |
| 92 MakeUintegerChecker<uint16_t> (0, 6149)) |
| 93 .AddAttribute ("CsgId", |
| 94 "The Closed Subscriber Group (CSG) identity that this UE is a
ssociated with, " |
| 95 "i.e., giving the UE access to cells which belong to this par
ticular 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), |
| 99 MakeUintegerAccessor (&NistLteUeNetDevice::SetCsgId, |
| 100 &NistLteUeNetDevice::GetCsgId), |
| 101 MakeUintegerChecker<uint32_t> ()) |
| 102 ; |
| 103 |
| 104 return tid; |
| 105 } |
| 106 |
| 107 |
| 108 NistLteUeNetDevice::NistLteUeNetDevice (void) |
| 109 : m_isConstructed (false) |
| 110 { |
| 111 NS_LOG_FUNCTION (this); |
| 112 } |
| 113 |
| 114 NistLteUeNetDevice::~NistLteUeNetDevice (void) |
| 115 { |
| 116 NS_LOG_FUNCTION (this); |
| 117 } |
| 118 |
| 119 void |
| 120 NistLteUeNetDevice::DoDispose (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; |
| 132 NistLteNetDevice::DoDispose (); |
| 133 } |
| 134 |
| 135 void |
| 136 NistLteUeNetDevice::UpdateConfig (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 |
| 159 Ptr<NistLteUeMac> |
| 160 NistLteUeNetDevice::GetMac (void) const |
| 161 { |
| 162 NS_LOG_FUNCTION (this); |
| 163 return m_mac; |
| 164 } |
| 165 |
| 166 |
| 167 Ptr<NistLteUeRrc> |
| 168 NistLteUeNetDevice::GetRrc (void) const |
| 169 { |
| 170 NS_LOG_FUNCTION (this); |
| 171 return m_rrc; |
| 172 } |
| 173 |
| 174 |
| 175 Ptr<NistLteUePhy> |
| 176 NistLteUeNetDevice::GetPhy (void) const |
| 177 { |
| 178 NS_LOG_FUNCTION (this); |
| 179 return m_phy; |
| 180 } |
| 181 |
| 182 Ptr<NistEpcUeNas> |
| 183 NistLteUeNetDevice::GetNas (void) const |
| 184 { |
| 185 NS_LOG_FUNCTION (this); |
| 186 return m_nas; |
| 187 } |
| 188 |
| 189 uint64_t |
| 190 NistLteUeNetDevice::GetImsi () const |
| 191 { |
| 192 NS_LOG_FUNCTION (this); |
| 193 return m_imsi; |
| 194 } |
| 195 |
| 196 uint16_t |
| 197 NistLteUeNetDevice::GetDlEarfcn () const |
| 198 { |
| 199 NS_LOG_FUNCTION (this); |
| 200 return m_dlEarfcn; |
| 201 } |
| 202 |
| 203 void |
| 204 NistLteUeNetDevice::SetDlEarfcn (uint16_t earfcn) |
| 205 { |
| 206 NS_LOG_FUNCTION (this << earfcn); |
| 207 m_dlEarfcn = earfcn; |
| 208 } |
| 209 |
| 210 uint32_t |
| 211 NistLteUeNetDevice::GetCsgId () const |
| 212 { |
| 213 NS_LOG_FUNCTION (this); |
| 214 return m_csgId; |
| 215 } |
| 216 |
| 217 void |
| 218 NistLteUeNetDevice::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 |
| 226 NistLteUeNetDevice::SetTargetEnb (Ptr<NistLteEnbNetDevice> enb) |
| 227 { |
| 228 NS_LOG_FUNCTION (this << enb); |
| 229 m_targetEnb = enb; |
| 230 } |
| 231 |
| 232 |
| 233 Ptr<NistLteEnbNetDevice> |
| 234 NistLteUeNetDevice::GetTargetEnb (void) |
| 235 { |
| 236 NS_LOG_FUNCTION (this); |
| 237 return m_targetEnb; |
| 238 } |
| 239 |
| 240 void· |
| 241 NistLteUeNetDevice::DoInitialize (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 NistLteUeNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t prot
ocolNumber) |
| 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 s
upported"); |
| 258 return true; |
| 259 }·· |
| 260 return m_nas->Send (packet); |
| 261 } |
| 262 |
| 263 |
| 264 } // namespace ns3 |
OLD | NEW |