PHY synchronization
This commit is contained in:
69
src/lte/examples/inter-cell-interference.cc
Normal file
69
src/lte/examples/inter-cell-interference.cc
Normal file
@@ -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 <manuel.requena@cttc.es>
|
||||
* Nicola Baldo <nbaldo@cttc.es>
|
||||
*/
|
||||
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -246,7 +246,8 @@ public:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
|
||||
Ptr<LteNetDevice> m_netDevice;
|
||||
|
||||
Ptr<LteSpectrumPhy> m_downlinkSpectrumPhy;
|
||||
|
||||
@@ -236,7 +236,7 @@ bool
|
||||
LteSpectrumPhy::StartTx (Ptr<PacketBurst> pb)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << pb);
|
||||
NS_LOG_LOGIC (this << "state: " << m_state);
|
||||
NS_LOG_LOGIC (this << " state: " << m_state);
|
||||
|
||||
|
||||
for (std::list<Ptr<Packet> >::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<PacketBurst> pb, Ptr <const SpectrumValue> 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<PacketBurst> pb, Ptr <const SpectrumValue> 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<Packet> 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<Packet> 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<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
|
||||
!= pb->End (); ++iter)
|
||||
{
|
||||
Ptr<Packet> packet = (*iter)->Copy ();
|
||||
m_phyRxStartTrace (packet);
|
||||
}
|
||||
for (std::list<Ptr<Packet> >::const_iterator iter = pb->Begin (); iter
|
||||
!= pb->End (); ++iter)
|
||||
{
|
||||
Ptr<Packet> 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);
|
||||
|
||||
|
||||
@@ -144,6 +144,9 @@ LteUeNetDevice::SetTargetEnb (Ptr<LteEnbNetDevice> 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 ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -100,6 +100,8 @@ private:
|
||||
Ptr<LteUeMac> m_mac;
|
||||
Ptr<LteUePhy> m_phy;
|
||||
Ptr<LteUeRrc> m_rrc;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -365,9 +365,11 @@ LteUePhy::SubframeIndication (uint32_t frameNo, uint32_t subframeNo)
|
||||
|
||||
|
||||
void
|
||||
LteUePhy::SetTargetEnb (Ptr<LteEnbPhy> enbPhy)
|
||||
LteUePhy::SetEnbCellId (uint16_t cellId)
|
||||
{
|
||||
m_targetEnbPhy = enbPhy;
|
||||
m_enbCellId = cellId;
|
||||
m_downlinkSpectrumPhy->SetCellId (cellId);
|
||||
m_uplinkSpectrumPhy->SetCellId (cellId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<LteEnbPhy> enbPhy);
|
||||
void SetEnbCellId (uint16_t cellId);
|
||||
|
||||
|
||||
private:
|
||||
@@ -165,8 +164,7 @@ private:
|
||||
|
||||
uint16_t m_rnti;
|
||||
|
||||
Ptr<LteEnbPhy> m_targetEnbPhy;
|
||||
uint16_t m_cellId;
|
||||
uint16_t m_enbCellId;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user