diff --git a/src/lte/helper/cc-helper.cc b/src/lte/helper/cc-helper.cc index b31ec2236..22a6f630b 100644 --- a/src/lte/helper/cc-helper.cc +++ b/src/lte/helper/cc-helper.cc @@ -27,6 +27,7 @@ #include #include #include +#include #define MIN_CC 1 #define MAX_CC 2 @@ -172,22 +173,46 @@ CcHelper::EquallySpacedCcs () { std::map< uint8_t, ComponentCarrier > ccmap; + uint32_t ulEarfcn = m_ulEarfcn; + uint32_t dlEarfcn = m_dlEarfcn; + uint32_t maxBandwidthRb = std::max (m_ulBandwidth, m_dlBandwidth); + + // Convert bandwidth from RBs to kHz + uint32_t maxBandwidthKhz = LteSpectrumValueHelper::GetChannelBandwidth(maxBandwidthRb) / 1e3; + for (uint8_t i = 0; i < m_numberOfComponentCarriers; i++) { + // Make sure we stay within the same band. + if (LteSpectrumValueHelper::GetUplinkCarrierBand (ulEarfcn) != + LteSpectrumValueHelper::GetUplinkCarrierBand (m_ulEarfcn) + || LteSpectrumValueHelper::GetDownlinkCarrierBand (dlEarfcn) != + LteSpectrumValueHelper::GetDownlinkCarrierBand (m_dlEarfcn)) + { + NS_FATAL_ERROR ("Band is not wide enough to allocate " << +m_numberOfComponentCarriers << " CCs"); + } + bool pc =false; - // One RB is 200 kHz wide, while increment by 1 in corresponds to 100 kHz shift - // Therefore, we need to multiply by 2 here. - uint32_t ul = m_ulEarfcn + i * 2 * m_ulBandwidth; - uint32_t dl = m_dlEarfcn + i * 2 * m_dlBandwidth; if (i == 0) { pc = true; } - ComponentCarrier cc = CreateSingleCc (m_ulBandwidth, m_dlBandwidth, ul, dl, pc); + ComponentCarrier cc = CreateSingleCc (m_ulBandwidth, m_dlBandwidth, ulEarfcn, dlEarfcn, pc); ccmap.insert (std::pair(i, cc)); - NS_LOG_INFO(" ulBandwidth:"<