author | Nicola Baldo <nbaldo@cttc.es> |
Thu, 31 Mar 2011 11:59:57 +0200 | |
changeset 7927 | c8d380a263ec |
parent 7926 | ed6a21cccb25 |
child 7928 | b736f63e9bdf |
permissions | -rw-r--r-- |
6705 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
7886 | 3 |
* Copyright (c) 2009, 2011 CTTC |
6705 | 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 |
* Giuseppe Piro <g.piro@poliba.it> |
|
20 |
*/ |
|
21 |
||
22 |
||
23 |
#include <ns3/object-factory.h> |
|
24 |
#include <ns3/log.h> |
|
25 |
#include <math.h> |
|
26 |
#include <ns3/simulator.h> |
|
27 |
#include <ns3/trace-source-accessor.h> |
|
28 |
#include "lte-spectrum-phy.h" |
|
29 |
#include "lte-net-device.h" |
|
7886 | 30 |
#include "lte-mac-tag.h" |
31 |
#include "lte-sinr-chunk-processor.h" |
|
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
32 |
#include "lte-phy-tag.h" |
6705 | 33 |
|
34 |
NS_LOG_COMPONENT_DEFINE ("LteSpectrumPhy"); |
|
35 |
||
36 |
namespace ns3 { |
|
37 |
||
38 |
||
39 |
NS_OBJECT_ENSURE_REGISTERED (LteSpectrumPhy); |
|
40 |
||
41 |
LteSpectrumPhy::LteSpectrumPhy () |
|
7911 | 42 |
: m_state (IDLE) |
6705 | 43 |
{ |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7911
diff
changeset
|
44 |
NS_LOG_FUNCTION (this); |
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
45 |
m_interference = CreateObject<LteInterference> (); |
6705 | 46 |
} |
47 |
||
48 |
||
49 |
LteSpectrumPhy::~LteSpectrumPhy () |
|
50 |
{ |
|
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
51 |
NS_LOG_FUNCTION (this); |
6705 | 52 |
} |
53 |
||
7911 | 54 |
void LteSpectrumPhy::DoDispose () |
55 |
{ |
|
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7911
diff
changeset
|
56 |
NS_LOG_FUNCTION (this); |
7911 | 57 |
m_channel = 0; |
58 |
m_mobility = 0; |
|
59 |
m_device = 0; |
|
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
60 |
m_interference->Dispose (); |
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
61 |
m_interference = 0; |
7913
ed3a9f8a76d7
added DoDispose to lte-phy and lte-spectrum-phy
Nicola Baldo <nbaldo@cttc.es>
parents:
7911
diff
changeset
|
62 |
SpectrumPhy::DoDispose (); |
7911 | 63 |
} |
64 |
||
6705 | 65 |
std::ostream& operator<< (std::ostream& os, LteSpectrumPhy::State s) |
66 |
{ |
|
67 |
switch (s) |
|
68 |
{ |
|
69 |
case LteSpectrumPhy::IDLE: |
|
70 |
os << "IDLE"; |
|
71 |
break; |
|
72 |
case LteSpectrumPhy::RX: |
|
73 |
os << "RX"; |
|
74 |
break; |
|
75 |
case LteSpectrumPhy::TX: |
|
76 |
os << "TX"; |
|
77 |
break; |
|
78 |
default: |
|
79 |
os << "UNKNOWN"; |
|
80 |
break; |
|
81 |
} |
|
82 |
return os; |
|
83 |
} |
|
84 |
||
85 |
||
86 |
TypeId |
|
87 |
LteSpectrumPhy::GetTypeId (void) |
|
88 |
{ |
|
89 |
static TypeId tid = TypeId ("ns3::LteSpectrumPhy") |
|
90 |
.SetParent<SpectrumPhy> () |
|
91 |
.AddTraceSource ("TxStart", |
|
92 |
"Trace fired when a new transmission is started", |
|
93 |
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyTxStartTrace)) |
|
94 |
.AddTraceSource ("TxEnd", |
|
95 |
"Trace fired when a previosuly started transmission is finished", |
|
96 |
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyTxEndTrace)) |
|
97 |
.AddTraceSource ("RxStart", |
|
98 |
"Trace fired when the start of a signal is detected", |
|
99 |
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyRxStartTrace)) |
|
100 |
.AddTraceSource ("RxEndOk", |
|
101 |
"Trace fired when a previosuly started RX terminates successfully", |
|
102 |
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyRxEndOkTrace)) |
|
103 |
.AddTraceSource ("RxEndError", |
|
104 |
"Trace fired when a previosuly started RX terminates with an error (packet is corrupted)", |
|
105 |
MakeTraceSourceAccessor (&LteSpectrumPhy::m_phyRxEndErrorTrace)) |
|
106 |
; |
|
107 |
return tid; |
|
108 |
} |
|
109 |
||
110 |
||
111 |
||
112 |
Ptr<Object> |
|
113 |
LteSpectrumPhy::GetDevice () |
|
114 |
{ |
|
115 |
NS_LOG_FUNCTION (this); |
|
116 |
return m_device; |
|
117 |
} |
|
118 |
||
119 |
||
120 |
Ptr<Object> |
|
121 |
LteSpectrumPhy::GetMobility () |
|
122 |
{ |
|
123 |
NS_LOG_FUNCTION (this); |
|
124 |
return m_mobility; |
|
125 |
} |
|
126 |
||
127 |
||
128 |
void |
|
129 |
LteSpectrumPhy::SetDevice (Ptr<Object> d) |
|
130 |
{ |
|
131 |
NS_LOG_FUNCTION (this << d); |
|
132 |
m_device = d; |
|
133 |
} |
|
134 |
||
135 |
||
136 |
void |
|
137 |
LteSpectrumPhy::SetMobility (Ptr<Object> m) |
|
138 |
{ |
|
139 |
NS_LOG_FUNCTION (this << m); |
|
140 |
m_mobility = m; |
|
141 |
} |
|
142 |
||
143 |
||
144 |
void |
|
145 |
LteSpectrumPhy::SetChannel (Ptr<SpectrumChannel> c) |
|
146 |
{ |
|
147 |
NS_LOG_FUNCTION (this << c); |
|
148 |
m_channel = c; |
|
149 |
} |
|
150 |
||
151 |
Ptr<const SpectrumModel> |
|
152 |
LteSpectrumPhy::GetRxSpectrumModel () const |
|
153 |
{ |
|
154 |
if (m_txPsd) |
|
155 |
{ |
|
156 |
return m_txPsd->GetSpectrumModel (); |
|
157 |
} |
|
158 |
else |
|
159 |
{ |
|
160 |
return 0; |
|
161 |
} |
|
162 |
} |
|
163 |
||
164 |
||
165 |
SpectrumType |
|
166 |
LteSpectrumPhy::GetSpectrumType () |
|
167 |
{ |
|
168 |
NS_LOG_FUNCTION (this); |
|
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
169 |
static SpectrumType st = SpectrumTypeFactory::Create ("Lte"); |
6705 | 170 |
return st; |
171 |
} |
|
172 |
||
7886 | 173 |
|
6705 | 174 |
void |
175 |
LteSpectrumPhy::SetTxPowerSpectralDensity (Ptr<SpectrumValue> txPsd) |
|
176 |
{ |
|
177 |
NS_LOG_FUNCTION (this << txPsd); |
|
178 |
NS_ASSERT (txPsd); |
|
179 |
m_txPsd = txPsd; |
|
180 |
} |
|
181 |
||
182 |
||
183 |
void |
|
184 |
LteSpectrumPhy::SetNoisePowerSpectralDensity (Ptr<const SpectrumValue> noisePsd) |
|
185 |
{ |
|
186 |
NS_LOG_FUNCTION (this << noisePsd); |
|
187 |
NS_ASSERT (noisePsd); |
|
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
188 |
m_interference->SetNoisePowerSpectralDensity (noisePsd); |
6705 | 189 |
} |
190 |
||
191 |
||
192 |
||
193 |
void |
|
194 |
LteSpectrumPhy::SetPhyMacTxEndCallback (PhyMacTxEndCallback c) |
|
195 |
{ |
|
196 |
NS_LOG_FUNCTION (this); |
|
197 |
m_phyMacTxEndCallback = c; |
|
198 |
} |
|
199 |
||
200 |
||
201 |
void |
|
202 |
LteSpectrumPhy::SetPhyMacRxEndErrorCallback (PhyMacRxEndErrorCallback c) |
|
203 |
{ |
|
204 |
NS_LOG_FUNCTION (this); |
|
205 |
m_phyMacRxEndErrorCallback = c; |
|
206 |
} |
|
207 |
||
208 |
||
209 |
void |
|
210 |
LteSpectrumPhy::SetPhyMacRxEndOkCallback (PhyMacRxEndOkCallback c) |
|
211 |
{ |
|
212 |
NS_LOG_FUNCTION (this); |
|
213 |
m_phyMacRxEndOkCallback = c; |
|
214 |
} |
|
215 |
||
216 |
||
217 |
void |
|
218 |
LteSpectrumPhy::SetState (State newState) |
|
219 |
{ |
|
220 |
ChangeState (newState); |
|
221 |
} |
|
222 |
||
223 |
||
224 |
void |
|
225 |
LteSpectrumPhy::ChangeState (State newState) |
|
226 |
{ |
|
227 |
NS_LOG_LOGIC (this << " state: " << m_state << " -> " << newState); |
|
228 |
m_state = newState; |
|
229 |
} |
|
230 |
||
231 |
||
232 |
bool |
|
233 |
LteSpectrumPhy::StartTx (Ptr<PacketBurst> pb) |
|
234 |
{ |
|
235 |
NS_LOG_FUNCTION (this << pb); |
|
7893 | 236 |
NS_LOG_LOGIC (this << " state: " << m_state); |
6705 | 237 |
|
238 |
||
239 |
for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter |
|
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
240 |
!= pb->End (); ++iter) |
6705 | 241 |
{ |
242 |
Ptr<Packet> packet = (*iter)->Copy (); |
|
243 |
m_phyTxStartTrace (packet); |
|
244 |
} |
|
245 |
||
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
246 |
switch (m_state) |
6705 | 247 |
{ |
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
248 |
case RX: |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
249 |
NS_FATAL_ERROR ("cannot TX while RX: according to FDD channel acces, the physical layer for transmission cannot be used for reception"); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
250 |
break; |
6705 | 251 |
|
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
252 |
case TX: |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
253 |
NS_FATAL_ERROR ("cannot TX while already TX: the MAC should avoid this"); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
254 |
break; |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
255 |
|
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
256 |
case IDLE: |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
257 |
{ |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
258 |
/* |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
259 |
m_txPsd must be setted by the device, according to |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
260 |
(i) the available subchannel for transmission |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
261 |
(ii) the power transmission |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
262 |
*/ |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
263 |
NS_ASSERT (m_txPsd); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
264 |
m_txPacketBurst = pb; |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
265 |
|
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
266 |
// we need to convey some PHY meta information to the receiver |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
267 |
// to be used for simulation purposes (e.g., the CellId). This |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
268 |
// is done by adding an LtePhyTag to the first packet in the |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
269 |
// burst. |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
270 |
NS_ASSERT (pb->Begin () != pb->End ()); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
271 |
LtePhyTag tag (m_cellId); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
272 |
Ptr<Packet> firstPacketInBurst = *(pb->Begin ()); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
273 |
firstPacketInBurst->AddPacketTag (tag); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
274 |
|
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
275 |
ChangeState (TX); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
276 |
NS_ASSERT (m_channel); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
277 |
double tti = 0.001; |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
278 |
m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (tti), GetObject<SpectrumPhy> ()); |
7894
ed34ceddb62f
added distance parameter to inter-cell-interference program
Nicola Baldo <nicola@baldo.biz>
parents:
7893
diff
changeset
|
279 |
NS_LOG_LOGIC (this << " scheduling EndTx ()"); |
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
280 |
Simulator::Schedule (Seconds (tti), &LteSpectrumPhy::EndTx, this); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
281 |
} |
6705 | 282 |
return true; |
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
283 |
break; |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
284 |
|
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
285 |
default: |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
286 |
NS_FATAL_ERROR ("uknown state"); |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
287 |
return true; |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
288 |
break; |
6705 | 289 |
} |
290 |
} |
|
291 |
||
292 |
||
293 |
void |
|
294 |
LteSpectrumPhy::EndTx () |
|
295 |
{ |
|
296 |
NS_LOG_FUNCTION (this); |
|
7893 | 297 |
NS_LOG_LOGIC (this << " state: " << m_state); |
6705 | 298 |
|
299 |
NS_ASSERT (m_state == TX); |
|
300 |
||
7886 | 301 |
for (std::list<Ptr<Packet> >::const_iterator iter = m_txPacketBurst->Begin (); iter |
302 |
!= m_txPacketBurst->End (); ++iter) |
|
6705 | 303 |
{ |
304 |
Ptr<Packet> packet = (*iter)->Copy (); |
|
305 |
m_phyTxEndTrace (packet); |
|
306 |
} |
|
307 |
||
308 |
if (!m_phyMacTxEndCallback.IsNull ()) |
|
309 |
{ |
|
7886 | 310 |
for (std::list<Ptr<Packet> >::const_iterator iter = m_txPacketBurst->Begin (); iter |
311 |
!= m_txPacketBurst->End (); ++iter) |
|
6705 | 312 |
{ |
313 |
Ptr<Packet> packet = (*iter)->Copy (); |
|
314 |
m_phyMacTxEndCallback (packet); |
|
315 |
} |
|
316 |
} |
|
317 |
||
7886 | 318 |
m_txPacketBurst = 0; |
6705 | 319 |
ChangeState (IDLE); |
320 |
} |
|
321 |
||
322 |
||
323 |
void |
|
324 |
LteSpectrumPhy::StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration) |
|
325 |
{ |
|
326 |
NS_LOG_FUNCTION (this << pb << rxPsd << st << duration); |
|
7893 | 327 |
NS_LOG_LOGIC (this << " state: " << m_state); |
6705 | 328 |
|
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
329 |
m_interference->AddSignal (rxPsd, duration); |
6705 | 330 |
|
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
331 |
// the device might start RX only if the signal is of a type |
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
332 |
// understood by this device - in this case, an LTE signal. |
6705 | 333 |
if (st == GetSpectrumType ()) |
334 |
{ |
|
335 |
switch (m_state) |
|
336 |
{ |
|
337 |
case TX: |
|
7893 | 338 |
NS_FATAL_ERROR ("cannot RX while TX: according to FDD channel acces, the physical layer for transmission cannot be used for reception"); |
6705 | 339 |
break; |
340 |
||
341 |
case IDLE: |
|
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
342 |
case RX: |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
343 |
// the behavior is similar when |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
344 |
// we're IDLE or RX because we can receive more signals |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
345 |
// simultaneously (e.g., at the eNB). |
7893 | 346 |
{ |
347 |
// To check if we're synchronized to this signal, we check |
|
348 |
// for the CellId which is reported in the LtePhyTag |
|
349 |
NS_ASSERT (pb->Begin () != pb->End ()); |
|
350 |
LtePhyTag tag; |
|
351 |
Ptr<Packet> firstPacketInBurst = *(pb->Begin ()); |
|
352 |
firstPacketInBurst->RemovePacketTag (tag); |
|
353 |
if (tag.GetCellId () == m_cellId) |
|
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
354 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
355 |
NS_LOG_LOGIC (this << " synchronized with this signal (cellId=" << tag.GetCellId () << ")"); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
356 |
if (m_rxPacketBurstList.empty ()) |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
357 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
358 |
NS_ASSERT (m_state == IDLE); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
359 |
// first transmission, i.e., we're IDLE and we |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
360 |
// start RX |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
361 |
m_firstRxStart = Simulator::Now (); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
362 |
m_firstRxDuration = duration; |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
363 |
NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
364 |
Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
365 |
} |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
366 |
else |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
367 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
368 |
NS_ASSERT (m_state == RX); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
369 |
// sanity check: if there are multiple RX events, they |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
370 |
// should occur at the same time and have the same |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
371 |
// duration, otherwise the interference calculation |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
372 |
// won't be correct |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
373 |
NS_ASSERT ((m_firstRxStart == Simulator::Now ()) |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
374 |
&& (m_firstRxDuration == duration)); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
375 |
} |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
376 |
|
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
377 |
ChangeState (RX); |
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
378 |
m_interference->StartRx (rxPsd); |
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
379 |
|
7893 | 380 |
for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter |
381 |
!= pb->End (); ++iter) |
|
382 |
{ |
|
383 |
Ptr<Packet> packet = (*iter)->Copy (); |
|
384 |
m_phyRxStartTrace (packet); |
|
385 |
} |
|
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
386 |
|
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
387 |
m_rxPacketBurstList.push_back (pb); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
388 |
|
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
389 |
NS_LOG_LOGIC (this << " numSimultaneousRxEvents = " << m_rxPacketBurstList.size ()); |
7893 | 390 |
} |
391 |
else |
|
392 |
{ |
|
393 |
NS_LOG_LOGIC (this << " not in sync with this signal (cellId=" |
|
394 |
<< tag.GetCellId () << ", m_cellId=" << m_cellId << ")"); |
|
395 |
} |
|
396 |
} |
|
397 |
break; |
|
398 |
||
399 |
default: |
|
400 |
NS_FATAL_ERROR ("unknown state"); |
|
401 |
break; |
|
6705 | 402 |
} |
7891
382a429bdc69
added PHY synchronization model
Nicola Baldo <nicola@baldo.biz>
parents:
7886
diff
changeset
|
403 |
|
7893 | 404 |
NS_LOG_LOGIC (this << " state: " << m_state); |
6705 | 405 |
} |
406 |
} |
|
407 |
||
408 |
void |
|
409 |
LteSpectrumPhy::EndRx () |
|
410 |
{ |
|
411 |
NS_LOG_FUNCTION (this); |
|
7893 | 412 |
NS_LOG_LOGIC (this << " state: " << m_state); |
6705 | 413 |
|
414 |
NS_ASSERT (m_state == RX); |
|
415 |
||
7886 | 416 |
// this will trigger CQI calculation and Error Model evaluation |
417 |
// as a side effect, the error model should update the error status of all PDUs |
|
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
418 |
m_interference->EndRx (); |
6705 | 419 |
|
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
420 |
for (std::list<Ptr<PacketBurst> >::const_iterator i = m_rxPacketBurstList.begin (); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
421 |
i != m_rxPacketBurstList.end (); ++i) |
7886 | 422 |
{ |
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
423 |
// iterate over all packets in the PacketBurst |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
424 |
for (std::list<Ptr<Packet> >::const_iterator j = (*i)->Begin (); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
425 |
j != (*i)->End (); ++j) |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
426 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
427 |
// here we should determine whether this particular PDU |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
428 |
// (identified by RNTI and LCID) has been received with errors |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
429 |
// or not |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
430 |
// LteMacTag tag; |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
431 |
// (*iter)->PeekPacketTag (tag); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
432 |
// uint16_t rnti = tag.GetRnti (); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
433 |
// uint8_t lcid = tag.GetLcid (); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
434 |
// bool pduError = IsPduInError (rnti, lcid); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
435 |
bool pduError = false; |
6705 | 436 |
|
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
437 |
if (pduError) |
7886 | 438 |
{ |
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
439 |
m_phyRxEndErrorTrace ((*j)->Copy ()); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
440 |
if (!m_phyMacRxEndErrorCallback.IsNull ()) |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
441 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
442 |
NS_LOG_LOGIC (this << " calling m_phyMacRxEndErrorCallback"); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
443 |
m_phyMacRxEndOkCallback ((*j)->Copy ()); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
444 |
} |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
445 |
else |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
446 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
447 |
NS_LOG_LOGIC (this << " m_phyMacRxEndErrorCallback is NULL"); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
448 |
} |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
449 |
} |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
450 |
else // pdu received successfully |
7886 | 451 |
{ |
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
452 |
m_phyRxEndOkTrace ((*j)->Copy ()); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
453 |
if (!m_phyMacRxEndOkCallback.IsNull ()) |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
454 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
455 |
NS_LOG_LOGIC (this << " calling m_phyMacRxEndOkCallback"); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
456 |
m_phyMacRxEndOkCallback (*j); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
457 |
} |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
458 |
else |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
459 |
{ |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
460 |
NS_LOG_LOGIC (this << " m_phyMacRxEndOkCallback is NULL"); |
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
461 |
} |
7886 | 462 |
} |
6705 | 463 |
} |
464 |
} |
|
465 |
ChangeState (IDLE); |
|
7927
c8d380a263ec
fixed uplink RX and interference calculation
Nicola Baldo <nbaldo@cttc.es>
parents:
7926
diff
changeset
|
466 |
m_rxPacketBurstList.clear (); |
6705 | 467 |
} |
468 |
||
7886 | 469 |
void |
470 |
LteSpectrumPhy::SetCellId (uint16_t cellId) |
|
471 |
{ |
|
472 |
m_cellId = cellId; |
|
473 |
} |
|
474 |
||
475 |
void |
|
476 |
LteSpectrumPhy::AddSinrChunkProcessor (Ptr<LteSinrChunkProcessor> p) |
|
477 |
{ |
|
7924
3a44452d0dad
made LteInterference an Object and fixed more disposals
Nicola Baldo <nbaldo@cttc.es>
parents:
7913
diff
changeset
|
478 |
m_interference->AddSinrChunkProcessor (p); |
7886 | 479 |
} |
480 |
||
6705 | 481 |
|
482 |
} // namespace ns3 |