From c6b45f4e5ac86badcbf36410d6eabdb2c633e2d1 Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Thu, 31 Mar 2011 11:59:57 +0200 Subject: [PATCH] fixed uplink RX and interference calculation --- src/lte/helper/lena-helper.cc | 3 + src/lte/model/lte-interference.cc | 23 ++++-- src/lte/model/lte-interference.h | 2 +- src/lte/model/lte-spectrum-phy.cc | 121 ++++++++++++++++++------------ src/lte/model/lte-spectrum-phy.h | 7 +- 5 files changed, 96 insertions(+), 60 deletions(-) diff --git a/src/lte/helper/lena-helper.cc b/src/lte/helper/lena-helper.cc index c6e9e154d..2af66692d 100644 --- a/src/lte/helper/lena-helper.cc +++ b/src/lte/helper/lena-helper.cc @@ -146,6 +146,9 @@ LenaHelper::InstallSingleEnbDevice (Ptr n) Ptr noisePsd = LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (); ulPhy->SetNoisePowerSpectralDensity (noisePsd); + Ptr p = Create (phy->GetObject ()); + ulPhy->AddSinrChunkProcessor (p); + dlPhy->SetChannel (m_downlinkChannel); ulPhy->SetChannel (m_uplinkChannel); diff --git a/src/lte/model/lte-interference.cc b/src/lte/model/lte-interference.cc index 5dd2c8a12..91191cb3a 100644 --- a/src/lte/model/lte-interference.cc +++ b/src/lte/model/lte-interference.cc @@ -68,12 +68,25 @@ void LteInterference::StartRx (Ptr rxPsd) { NS_LOG_FUNCTION (this << *rxPsd); - m_rxSignal = rxPsd; - m_lastChangeTime = Now (); - m_receiving = true; - for (std::list >::const_iterator it = m_sinrChunkProcessorList.begin (); it != m_sinrChunkProcessorList.end (); ++it) + if (m_receiving == false) { - (*it)->Start (); + NS_LOG_LOGIC ("first signal"); + m_rxSignal = rxPsd->Copy (); + m_lastChangeTime = Now (); + m_receiving = true; + for (std::list >::const_iterator it = m_sinrChunkProcessorList.begin (); it != m_sinrChunkProcessorList.end (); ++it) + { + (*it)->Start (); + } + } + else + { + NS_LOG_LOGIC ("additional signal"); + // receiving multiple simultaneous signals, make sure they are synchronized + NS_ASSERT (m_lastChangeTime == Now ()); + // make sure they use orthogonal resource blocks + NS_ASSERT (Sum((*rxPsd)*(*m_rxSignal)) == 0.0); + (*m_rxSignal) += (*rxPsd); } } diff --git a/src/lte/model/lte-interference.h b/src/lte/model/lte-interference.h index 7fa024bc7..e376a3ad9 100644 --- a/src/lte/model/lte-interference.h +++ b/src/lte/model/lte-interference.h @@ -105,7 +105,7 @@ private: bool m_receiving; - Ptr m_rxSignal; /**< stores the power spectral density of + Ptr m_rxSignal; /**< stores the power spectral density of * the signal whose RX is being * attempted */ diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 45e6864ee..cae780829 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -54,7 +54,6 @@ LteSpectrumPhy::~LteSpectrumPhy () void LteSpectrumPhy::DoDispose () { NS_LOG_FUNCTION (this); - m_endRxEventId.Cancel (); m_channel = 0; m_mobility = 0; m_device = 0; @@ -339,10 +338,11 @@ LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, S NS_FATAL_ERROR ("cannot RX while TX: according to FDD channel acces, the physical layer for transmission cannot be used for reception"); break; - case RX: - break; - case IDLE: + case RX: + // the behavior is similar when + // we're IDLE or RX because we can receive more signals + // simultaneously (e.g., at the eNB). { // To check if we're synchronized to this signal, we check // for the CellId which is reported in the LtePhyTag @@ -351,10 +351,30 @@ LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, S Ptr firstPacketInBurst = *(pb->Begin ()); firstPacketInBurst->RemovePacketTag (tag); if (tag.GetCellId () == m_cellId) - { - NS_LOG_LOGIC (this << " synchronized with this signal (cellId=" << tag.GetCellId () << ")"); - ChangeState (RX); - + { + NS_LOG_LOGIC (this << " synchronized with this signal (cellId=" << tag.GetCellId () << ")"); + if (m_rxPacketBurstList.empty ()) + { + NS_ASSERT (m_state == IDLE); + // first transmission, i.e., we're IDLE and we + // start RX + m_firstRxStart = Simulator::Now (); + m_firstRxDuration = duration; + NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration); + Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this); + } + else + { + NS_ASSERT (m_state == RX); + // sanity check: if there are multiple RX events, they + // should occur at the same time and have the same + // duration, otherwise the interference calculation + // won't be correct + NS_ASSERT ((m_firstRxStart == Simulator::Now ()) + && (m_firstRxDuration == duration)); + } + + ChangeState (RX); m_interference->StartRx (rxPsd); for (std::list >::const_iterator iter = pb->Begin (); iter @@ -363,12 +383,10 @@ LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, S Ptr packet = (*iter)->Copy (); m_phyRxStartTrace (packet); } - - m_rxPacketBurst = pb; - m_rxPsd = rxPsd; - - NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration); - m_endRxEventId = Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this); + + m_rxPacketBurstList.push_back (pb); + + NS_LOG_LOGIC (this << " numSimultaneousRxEvents = " << m_rxPacketBurstList.size ()); } else { @@ -399,50 +417,53 @@ LteSpectrumPhy::EndRx () // as a side effect, the error model should update the error status of all PDUs m_interference->EndRx (); - for (std::list >::const_iterator iter = m_rxPacketBurst->Begin (); iter - != m_rxPacketBurst->End (); ++iter) + for (std::list >::const_iterator i = m_rxPacketBurstList.begin (); + i != m_rxPacketBurstList.end (); ++i) { - // here we should determine whether this particular PDU - // (identified by RNTI and LCID) has been received with errors - // or not - // LteMacTag tag; - // (*iter)->PeekPacketTag (tag); - // uint16_t rnti = tag.GetRnti (); - // uint8_t lcid = tag.GetLcid (); - // bool pduError = IsPduInError (rnti, lcid); - bool pduError = false; + // iterate over all packets in the PacketBurst + for (std::list >::const_iterator j = (*i)->Begin (); + j != (*i)->End (); ++j) + { + // here we should determine whether this particular PDU + // (identified by RNTI and LCID) has been received with errors + // or not + // LteMacTag tag; + // (*iter)->PeekPacketTag (tag); + // uint16_t rnti = tag.GetRnti (); + // uint8_t lcid = tag.GetLcid (); + // bool pduError = IsPduInError (rnti, lcid); + bool pduError = false; - if (pduError) - { - m_phyRxEndErrorTrace ((*iter)->Copy ()); - if (!m_phyMacRxEndErrorCallback.IsNull ()) + if (pduError) { - NS_LOG_LOGIC (this << " calling m_phyMacRxEndErrorCallback"); - m_phyMacRxEndOkCallback ((*iter)->Copy ()); - } - else + m_phyRxEndErrorTrace ((*j)->Copy ()); + if (!m_phyMacRxEndErrorCallback.IsNull ()) + { + NS_LOG_LOGIC (this << " calling m_phyMacRxEndErrorCallback"); + m_phyMacRxEndOkCallback ((*j)->Copy ()); + } + else + { + NS_LOG_LOGIC (this << " m_phyMacRxEndErrorCallback is NULL"); + } + } + else // pdu received successfully { - NS_LOG_LOGIC (this << " m_phyMacRxEndErrorCallback is NULL"); - } - } - else // pdu received successfully - { - m_phyRxEndOkTrace ((*iter)->Copy ()); - if (!m_phyMacRxEndOkCallback.IsNull ()) - { - NS_LOG_LOGIC (this << " calling m_phyMacRxEndOkCallback"); - m_phyMacRxEndOkCallback (*iter); - } - else - { - NS_LOG_LOGIC (this << " m_phyMacRxEndOkCallback is NULL"); + m_phyRxEndOkTrace ((*j)->Copy ()); + if (!m_phyMacRxEndOkCallback.IsNull ()) + { + NS_LOG_LOGIC (this << " calling m_phyMacRxEndOkCallback"); + m_phyMacRxEndOkCallback (*j); + } + else + { + NS_LOG_LOGIC (this << " m_phyMacRxEndOkCallback is NULL"); + } } } } - ChangeState (IDLE); - m_rxPacketBurst = 0; - m_rxPsd = 0; + m_rxPacketBurstList.clear (); } void diff --git a/src/lte/model/lte-spectrum-phy.h b/src/lte/model/lte-spectrum-phy.h index 132a8a082..0ca137c3d 100644 --- a/src/lte/model/lte-spectrum-phy.h +++ b/src/lte/model/lte-spectrum-phy.h @@ -157,8 +157,6 @@ private: void EndTx (); void EndRx (); - EventId m_endRxEventId; - Ptr m_mobility; Ptr m_device; @@ -166,11 +164,12 @@ private: Ptr m_channel; Ptr m_txPsd; - Ptr m_rxPsd; Ptr m_txPacketBurst; - Ptr m_rxPacketBurst; + std::list > m_rxPacketBurstList; State m_state; + Time m_firstRxStart; + Time m_firstRxDuration; TracedCallback > m_phyTxStartTrace; TracedCallback > m_phyTxEndTrace;