From efc7ef826853596a65085d4a4840bf5ee2a5056d Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Tue, 15 Mar 2011 20:01:50 +0100 Subject: [PATCH] PHY synchronization --- src/lte/examples/inter-cell-interference.cc | 69 ++++++++++++++++++ src/lte/model/lte-phy.h | 3 +- src/lte/model/lte-spectrum-phy.cc | 79 +++++++++++---------- src/lte/model/lte-ue-net-device.cc | 3 + src/lte/model/lte-ue-net-device.h | 2 + src/lte/model/lte-ue-phy.cc | 6 +- src/lte/model/lte-ue-phy.h | 8 +-- 7 files changed, 124 insertions(+), 46 deletions(-) create mode 100644 src/lte/examples/inter-cell-interference.cc diff --git a/src/lte/examples/inter-cell-interference.cc b/src/lte/examples/inter-cell-interference.cc new file mode 100644 index 000000000..5d296ede3 --- /dev/null +++ b/src/lte/examples/inter-cell-interference.cc @@ -0,0 +1,69 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Manuel Requena + * Nicola Baldo + */ + + +#include "ns3/core-module.h" +#include "ns3/network-module.h" +#include "ns3/mobility-module.h" +#include "ns3/lte-module.h" + +using namespace ns3; + +int main (int argc, char *argv[]) +{ + LenaHelper lena; + + lena.EnableLogComponents (); + + // Create Nodes: eNodeB and UE + NodeContainer enbNodes; + NodeContainer ueNodes; + enbNodes.Create (1); + ueNodes.Create (1); + + // Install Mobility Model + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (enbNodes); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (ueNodes); + + // Create Devices and install them in the Nodes (eNB and UE) + NetDeviceContainer enbDevs; + NetDeviceContainer ueDevs; + enbDevs = lena.InstallEnbDevice (enbNodes); + ueDevs = lena.InstallUeDevice (ueNodes); + + // Attach a UE to a eNB + lena.Attach (ueDevs, enbDevs.Get (0)); + + // Activate an EPS bearer + enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer bearer (q); + lena.ActivateEpsBearer (ueDevs, bearer); + + + Simulator::Stop (Seconds (0.004)); + + Simulator::Run (); + Simulator::Destroy (); + return 0; +} diff --git a/src/lte/model/lte-phy.h b/src/lte/model/lte-phy.h index 48e91b806..6e24114f1 100644 --- a/src/lte/model/lte-phy.h +++ b/src/lte/model/lte-phy.h @@ -246,7 +246,8 @@ public: -private: +protected: + Ptr m_netDevice; Ptr m_downlinkSpectrumPhy; diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc index 17861d9f1..ed6667968 100644 --- a/src/lte/model/lte-spectrum-phy.cc +++ b/src/lte/model/lte-spectrum-phy.cc @@ -236,7 +236,7 @@ bool LteSpectrumPhy::StartTx (Ptr pb) { NS_LOG_FUNCTION (this << pb); - NS_LOG_LOGIC (this << "state: " << m_state); + NS_LOG_LOGIC (this << " state: " << m_state); for (std::list >::const_iterator iter = pb->Begin (); iter @@ -296,7 +296,7 @@ void LteSpectrumPhy::EndTx () { NS_LOG_FUNCTION (this); - NS_LOG_LOGIC (this << "state: " << m_state); + NS_LOG_LOGIC (this << " state: " << m_state); NS_ASSERT (m_state == TX); @@ -326,7 +326,7 @@ void LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, SpectrumType st, Time duration) { NS_LOG_FUNCTION (this << pb << rxPsd << st << duration); - NS_LOG_LOGIC (this << "state: " << m_state); + NS_LOG_LOGIC (this << " state: " << m_state); m_interference.AddSignal (rxPsd, duration); @@ -337,51 +337,54 @@ LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, S switch (m_state) { case TX: - /* - * NS FATAL ERROR: according to FDD channel acces, - * the physical layer for reception cannot be used for transmission. - */ - NS_FATAL_ERROR ("FDD ERROR: TX State while receiving packet"); - + 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: - - // To check if we're synchronized to this signal, we check - // for the CellId which is reported in the LtePhyTag - NS_ASSERT (pb->Begin () != pb->End ()); - LtePhyTag tag; - Ptr firstPacketInBurst = *(pb->Begin ()); - firstPacketInBurst->RemovePacketTag (tag); - if (tag.GetCellId () == m_cellId) - { - // we're synchronized with this signal - ChangeState (RX); + { + // To check if we're synchronized to this signal, we check + // for the CellId which is reported in the LtePhyTag + NS_ASSERT (pb->Begin () != pb->End ()); + LtePhyTag tag; + 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); - m_interference.StartRx (rxPsd); + m_interference.StartRx (rxPsd); - for (std::list >::const_iterator iter = pb->Begin (); iter - != pb->End (); ++iter) - { - Ptr packet = (*iter)->Copy (); - m_phyRxStartTrace (packet); - } + for (std::list >::const_iterator iter = pb->Begin (); iter + != pb->End (); ++iter) + { + Ptr packet = (*iter)->Copy (); + m_phyRxStartTrace (packet); + } - m_rxPacketBurst = pb; - m_rxPsd = rxPsd; + m_rxPacketBurst = pb; + m_rxPsd = rxPsd; - NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration); - m_endRxEventId = Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this); - - break; - - } + NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration); + m_endRxEventId = Simulator::Schedule (duration, &LteSpectrumPhy::EndRx, this); + } + else + { + NS_LOG_LOGIC (this << " not in sync with this signal (cellId=" + << tag.GetCellId () << ", m_cellId=" << m_cellId << ")"); + } + } + break; + + default: + NS_FATAL_ERROR ("unknown state"); + break; } - NS_LOG_LOGIC (this << "state: " << m_state); + NS_LOG_LOGIC (this << " state: " << m_state); } } @@ -389,7 +392,7 @@ void LteSpectrumPhy::AbortRx () { NS_LOG_FUNCTION (this); - NS_LOG_LOGIC (this << "state: " << m_state); + NS_LOG_LOGIC (this << " state: " << m_state); NS_ASSERT (m_state == RX); @@ -410,7 +413,7 @@ void LteSpectrumPhy::EndRx () { NS_LOG_FUNCTION (this); - NS_LOG_LOGIC (this << "state: " << m_state); + NS_LOG_LOGIC (this << " state: " << m_state); NS_ASSERT (m_state == RX); diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index 5270bc662..c5c9ff531 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -144,6 +144,9 @@ LteUeNetDevice::SetTargetEnb (Ptr enb) { NS_LOG_FUNCTION (this << enb); m_targetEnb = enb; + + // WILD HACK - should go through RRC and then through PHY SAP + m_phy->DoSetCellId (enb->GetCellId ()); } diff --git a/src/lte/model/lte-ue-net-device.h b/src/lte/model/lte-ue-net-device.h index 5f6f98a16..6b0bf46e7 100644 --- a/src/lte/model/lte-ue-net-device.h +++ b/src/lte/model/lte-ue-net-device.h @@ -100,6 +100,8 @@ private: Ptr m_mac; Ptr m_phy; Ptr m_rrc; + + }; } // namespace ns3 diff --git a/src/lte/model/lte-ue-phy.cc b/src/lte/model/lte-ue-phy.cc index 2fd40bc70..b660897f3 100644 --- a/src/lte/model/lte-ue-phy.cc +++ b/src/lte/model/lte-ue-phy.cc @@ -365,9 +365,11 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo) void -LteUePhy::SetTargetEnb (Ptr enbPhy) +LteUePhy::SetEnbCellId (uint16_t cellId) { - m_targetEnbPhy = enbPhy; + m_enbCellId = cellId; + m_downlinkSpectrumPhy->SetCellId (cellId); + m_uplinkSpectrumPhy->SetCellId (cellId); } diff --git a/src/lte/model/lte-ue-phy.h b/src/lte/model/lte-ue-phy.h index d33b6d77b..74a88c81e 100644 --- a/src/lte/model/lte-ue-phy.h +++ b/src/lte/model/lte-ue-phy.h @@ -145,12 +145,11 @@ public: /** - * set the eNB this PHY is synchronized with + * set the cellId of the eNb this PHY is synchronized with * - * \param enbPhy a pointer to the PHY of the eNB, used for exchanging control messages * \param cellId the cell identifier of the eNB */ - void SetTargetEnb (Ptr enbPhy); + void SetEnbCellId (uint16_t cellId); private: @@ -165,8 +164,7 @@ private: uint16_t m_rnti; - Ptr m_targetEnbPhy; - uint16_t m_cellId; + uint16_t m_enbCellId; };