LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari | 3 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ns3/simulator.h" | 22 #include "ns3/simulator.h" |
23 #include "ns3/callback.h" | 23 #include "ns3/callback.h" |
24 #include "ns3/node.h" | 24 #include "ns3/node.h" |
25 #include "ns3/packet.h" | 25 #include "ns3/packet.h" |
26 #include "lte-net-device.h" | 26 #include "lte-net-device.h" |
27 #include "ns3/packet-burst.h" | 27 #include "ns3/packet-burst.h" |
28 #include "ns3/uinteger.h" | 28 #include "ns3/uinteger.h" |
29 #include "ns3/trace-source-accessor.h" | 29 #include "ns3/trace-source-accessor.h" |
30 #include "ns3/pointer.h" | 30 #include "ns3/pointer.h" |
31 #include "ns3/enum.h" | 31 #include "ns3/enum.h" |
32 #include "bearer.h" | 32 #include "radio-bearer-instance.h" |
33 #include "bearer-manager.h" | |
34 #include "ip-classifier.h" | 33 #include "ip-classifier.h" |
35 #include "ue-record.h" | 34 #include "ue-record.h" |
36 #include "ue-manager.h" | 35 #include "ue-manager.h" |
37 #include "enb-net-device.h" | 36 #include "enb-net-device.h" |
38 #include "ue-net-device.h" | 37 #include "ue-net-device.h" |
39 #include "ue-mac-entity.h" | 38 #include "ue-mac-entity.h" |
40 #include "rlc-entity.h" | 39 #include "rlc-entity.h" |
41 #include "rrc-entity.h" | 40 #include "rrc-entity.h" |
42 #include "lte-mac-header.h" | 41 #include "lte-mac-header.h" |
43 #include "ns3/ipv4-header.h" | 42 #include "ns3/ipv4-header.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 93 } |
95 | 94 |
96 void· | 95 void· |
97 UeNetDevice::InitUeNetDevice (void) | 96 UeNetDevice::InitUeNetDevice (void) |
98 { | 97 { |
99 NS_LOG_FUNCTION (this); | 98 NS_LOG_FUNCTION (this); |
100 m_targetEnb = 0; | 99 m_targetEnb = 0; |
101 SetNode (0); | 100 SetNode (0); |
102 SetPhy (0); | 101 SetPhy (0); |
103 m_macEntity = CreateObject<UeMacEntity> (); | 102 m_macEntity = CreateObject<UeMacEntity> (); |
| 103 m_macEntity->SetDevice (this); |
104 SetIpClassifier (CreateObject<IpClassifier> (this)); | 104 SetIpClassifier (CreateObject<IpClassifier> (this)); |
105 SetRrcEntity (CreateObject<RrcEntity> ()); | 105 SetRrcEntity (CreateObject<RrcEntity> ()); |
106 SetRlcEntity (CreateObject<RlcEntity> ()); | 106 SetRlcEntity (CreateObject<RlcEntity> ()); |
107 SetTti (0.001); | |
108 } | 107 } |
109 | 108 |
110 | 109 |
111 void· | 110 void· |
112 UeNetDevice::SetMacEntity (Ptr<UeMacEntity> m) | 111 UeNetDevice::SetMacEntity (Ptr<UeMacEntity> m) |
113 { | 112 { |
114 NS_LOG_FUNCTION (this); | 113 NS_LOG_FUNCTION (this); |
115 m_macEntity = m; | 114 m_macEntity = m; |
116 } | 115 } |
117 | 116 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 NS_LOG_FUNCTION (this); | 158 NS_LOG_FUNCTION (this); |
160 return m_targetEnb; | 159 return m_targetEnb; |
161 } | 160 } |
162 | 161 |
163 | 162 |
164 bool· | 163 bool· |
165 UeNetDevice::DoSend (Ptr<Packet> packet, const Mac48Address& source, | 164 UeNetDevice::DoSend (Ptr<Packet> packet, const Mac48Address& source, |
166 const Mac48Address& dest, uint16_t protocolNumber) | 165 const Mac48Address& dest, uint16_t protocolNumber) |
167 { | 166 { |
168 NS_LOG_FUNCTION (this); | 167 NS_LOG_FUNCTION (this); |
169 //Ptr<Bearer> bearer = GetIpClassifier ()->Classify (packet); | 168 //Ptr<RadioBearerInstance> bearer = GetIpClassifier ()->Classify (packet); |
170 //return Enqueue (packet, bearer); | 169 //return Enqueue (packet, bearer); |
171 | 170 |
172 /* | 171 /* |
173 * XXX: the uplink is not implemented yet.· | 172 * XXX: the uplink is not implemented yet.· |
174 * For now the UE send the packet as soon as· | 173 * For now the UE send the packet as soon as· |
175 * it arrives from the upper layer | 174 * it arrives from the upper layer |
176 * | 175 * |
177 * For any question, please contact me at g.piro@poliba.it | 176 * For any question, please contact me at g.piro@poliba.it |
178 */ | 177 */ |
179 | 178 |
180 Ptr<PacketBurst> pb = new PacketBurst (); | 179 Ptr<PacketBurst> pb = CreateObject<PacketBurst> (); |
181 pb->AddPacket (packet); | 180 pb->AddPacket (packet); |
182 return SendPacket (pb);· | 181 return SendPacket (pb);· |
183 } | 182 } |
184 | 183 |
185 | 184 |
186 void· | 185 void· |
187 UeNetDevice::DoReceive (Ptr<Packet> p) | 186 UeNetDevice::DoReceive (Ptr<Packet> p) |
188 { | 187 { |
189 NS_LOG_FUNCTION (this); | 188 NS_LOG_FUNCTION (this); |
190 | 189 |
(...skipping 26 matching lines...) Expand all Loading... |
217 NS_LOG_FUNCTION (this); | 216 NS_LOG_FUNCTION (this); |
218 GetPhy ()->SendPacket (GetPacketToSend ()); | 217 GetPhy ()->SendPacket (GetPacketToSend ()); |
219 } | 218 } |
220 | 219 |
221 | 220 |
222 bool | 221 bool |
223 UeNetDevice::SendPacket (Ptr<PacketBurst> p) | 222 UeNetDevice::SendPacket (Ptr<PacketBurst> p) |
224 { | 223 { |
225 return GetPhy ()->GetUplinkSpectrumPhy ()->StartTx (p); | 224 return GetPhy ()->GetUplinkSpectrumPhy ()->StartTx (p); |
226 } | 225 } |
227 | |
228 /* | |
229 void· | |
230 UeNetDevice::SetCqiFeedbacks (LteNetDevice::CqiFeedbacks c) | |
231 { | |
232 NS_LOG_FUNCTION (this); | |
233 } | |
234 | |
235 | |
236 LteNetDevice::CqiFeedbacks· | |
237 UeNetDevice::GetCqiFeedbacks (void) | |
238 { | |
239 return m_cqiFeedbacks; | |
240 } | |
241 | |
242 void· | |
243 UeNetDevice::ReceiveAssignedDLResources (LteNetDevice::AssignedResources r) | |
244 { | |
245 NS_LOG_FUNCTION (this); | |
246 } | |
247 | |
248 | |
249 void· | |
250 UeNetDevice::ReceiveAssignedULResources (LteNetDevice::AssignedResources r) | |
251 { | |
252 NS_LOG_FUNCTION (this); | |
253 } | |
254 | |
255 | |
256 LteNetDevice::AssignedResources· | |
257 UeNetDevice::GetAssignedDLResources (void) | |
258 { | |
259 NS_LOG_FUNCTION (this); | |
260 return m_assignedDLResources; | |
261 } | |
262 | |
263 | |
264 LteNetDevice::AssignedResources· | |
265 UeNetDevice::GetAssignedULResources (void) | |
266 { | |
267 NS_LOG_FUNCTION (this); | |
268 return m_assignedULResources; | |
269 } | |
270 */ | |
271 | |
272 void· | |
273 UeNetDevice::CreateCqiFeedbacks (std::vector<double> sinr) | |
274 { | |
275 NS_LOG_FUNCTION (this); | |
276 Ptr<AmcModule> amc = GetMacEntity ()->GetAmcModule (); | |
277 | |
278 std::vector<int> cqi; | |
279 std::vector<double>::iterator it; | |
280 · | |
281 for (it = sinr.begin (); it != sinr.end (); it++) | |
282 { | |
283 double sinr_ = (*it); | |
284 ···· | |
285 /* | |
286 * Compute the spectral efficiency from the SINR | |
287 * SINR | |
288 * spectralEfficiency = log2 (1 + -------------------- ) | |
289 * -ln(5*BER)/1.5 | |
290 * NB: SINR must be expressed in natural unit: | |
291 * (SINR)dB => 10 ^ (SINR/10) | |
292 */ | |
293 | |
294 double s = log2 ( 1 + ( | |
295 pow (10, sinr_ / 10 ) / | |
296 ( (-log (5.0 * 0.00005 )) / 1.5) )); | |
297 | |
298 int cqi_ = amc->GetCqiFromFromSpectralEfficiency(s); | |
299 | |
300 NS_LOG_FUNCTION (this << "channel_id = " << cqi.size () | |
301 << "sinr = " << sinr_· | |
302 << "spectral efficiency =" << s | |
303 << " ---- CQI = " << cqi_ ); | |
304 · | |
305 cqi.push_back (cqi_); | |
306 } | |
307 | |
308 | |
309 //CREATE CQI FEEDBACKS TO SEND UNDER THE IDEAL CONTROL CHANNEL | |
310 Ptr<CqiIdealControlMessage> msg = new CqiIdealControlMessage (); | |
311 msg->SetSourceDevice (this); | |
312 msg->SetDestinationDevice (GetTargetEnb ()); | |
313 | |
314 int nbSubChannels = cqi.size (); | |
315 for (int i = 0; i < nbSubChannels; i++) | |
316 { | |
317 msg->AddNewRecord (GetPhy ()->GetDownlinkSubChannels ().at (i), cqi.at(i))
; | |
318 } | |
319 ·· | |
320 SendIdealControlMessage (msg); | |
321 } | |
322 | |
323 | |
324 void· | |
325 UeNetDevice::SendIdealControlMessage (Ptr<IdealControlMessage> msg) | |
326 { | |
327 NS_LOG_FUNCTION (this); | |
328 GetTargetEnb ()->ReceiveIdealControlMessage (msg); | |
329 } | |
330 | |
331 | |
332 void· | |
333 UeNetDevice::ReceiveIdealControlMessage (Ptr<IdealControlMessage> msg) | |
334 { | |
335 NS_LOG_FUNCTION (this); | |
336 } | |
337 | |
338 } // namespace ns3 | 226 } // namespace ns3 |
LEFT | RIGHT |