--- a/src/lte/model/eps-bearer.cc Sun Jul 01 21:17:35 2012 -0300
+++ b/src/lte/model/eps-bearer.cc Sun Aug 05 21:33:37 2012 -0300
@@ -38,6 +38,12 @@
{
}
+EpsBearer::EpsBearer (Qci x, struct GbrQosInformation y)
+ : qci (x),gbrQosInfo (y)
+{
+}
+
+
bool
EpsBearer::IsGbr () const
{
--- a/src/lte/model/eps-bearer.h Sun Jul 01 21:17:35 2012 -0300
+++ b/src/lte/model/eps-bearer.h Sun Aug 05 21:33:37 2012 -0300
@@ -88,6 +88,8 @@
*/
EpsBearer (Qci x);
+ EpsBearer (Qci x, GbrQosInformation y);
+
/**
*
* @return true if the EPS Bearer is a Guaranteed Bit Rate bearer, false otherwise
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/fdtbfq-ff-mac-scheduler.cc Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,1430 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#ifdef __FreeBSD__
+#define log2(x) (log(x) / M_LN2)
+#endif /* __FreeBSD__ */
+
+#include <ns3/log.h>
+#include <ns3/pointer.h>
+
+#include <ns3/simulator.h>
+#include <ns3/lte-amc.h>
+#include <ns3/fdtbfq-ff-mac-scheduler.h>
+
+NS_LOG_COMPONENT_DEFINE ("FdTbfqFfMacScheduler");
+
+namespace ns3 {
+
+int FdTbfqType0AllocationRbg[4] = {
+ 10, // RGB size 1
+ 26, // RGB size 2
+ 63, // RGB size 3
+ 110 // RGB size 4
+}; // see table 7.1.6.1-1 of 36.213
+
+
+NS_OBJECT_ENSURE_REGISTERED (FdTbfqFfMacScheduler);
+
+
+
+class FdTbfqSchedulerMemberCschedSapProvider : public FfMacCschedSapProvider
+{
+public:
+ FdTbfqSchedulerMemberCschedSapProvider (FdTbfqFfMacScheduler* scheduler);
+
+ // inherited from FfMacCschedSapProvider
+ virtual void CschedCellConfigReq (const struct CschedCellConfigReqParameters& params);
+ virtual void CschedUeConfigReq (const struct CschedUeConfigReqParameters& params);
+ virtual void CschedLcConfigReq (const struct CschedLcConfigReqParameters& params);
+ virtual void CschedLcReleaseReq (const struct CschedLcReleaseReqParameters& params);
+ virtual void CschedUeReleaseReq (const struct CschedUeReleaseReqParameters& params);
+
+private:
+ FdTbfqSchedulerMemberCschedSapProvider ();
+ FdTbfqFfMacScheduler* m_scheduler;
+};
+
+FdTbfqSchedulerMemberCschedSapProvider::FdTbfqSchedulerMemberCschedSapProvider ()
+{
+}
+
+FdTbfqSchedulerMemberCschedSapProvider::FdTbfqSchedulerMemberCschedSapProvider (FdTbfqFfMacScheduler* scheduler) : m_scheduler (scheduler)
+{
+}
+
+
+void
+FdTbfqSchedulerMemberCschedSapProvider::CschedCellConfigReq (const struct CschedCellConfigReqParameters& params)
+{
+ m_scheduler->DoCschedCellConfigReq (params);
+}
+
+void
+FdTbfqSchedulerMemberCschedSapProvider::CschedUeConfigReq (const struct CschedUeConfigReqParameters& params)
+{
+ m_scheduler->DoCschedUeConfigReq (params);
+}
+
+
+void
+FdTbfqSchedulerMemberCschedSapProvider::CschedLcConfigReq (const struct CschedLcConfigReqParameters& params)
+{
+ m_scheduler->DoCschedLcConfigReq (params);
+}
+
+void
+FdTbfqSchedulerMemberCschedSapProvider::CschedLcReleaseReq (const struct CschedLcReleaseReqParameters& params)
+{
+ m_scheduler->DoCschedLcReleaseReq (params);
+}
+
+void
+FdTbfqSchedulerMemberCschedSapProvider::CschedUeReleaseReq (const struct CschedUeReleaseReqParameters& params)
+{
+ m_scheduler->DoCschedUeReleaseReq (params);
+}
+
+
+
+
+class FdTbfqSchedulerMemberSchedSapProvider : public FfMacSchedSapProvider
+{
+public:
+ FdTbfqSchedulerMemberSchedSapProvider (FdTbfqFfMacScheduler* scheduler);
+
+ // inherited from FfMacSchedSapProvider
+ virtual void SchedDlRlcBufferReq (const struct SchedDlRlcBufferReqParameters& params);
+ virtual void SchedDlPagingBufferReq (const struct SchedDlPagingBufferReqParameters& params);
+ virtual void SchedDlMacBufferReq (const struct SchedDlMacBufferReqParameters& params);
+ virtual void SchedDlTriggerReq (const struct SchedDlTriggerReqParameters& params);
+ virtual void SchedDlRachInfoReq (const struct SchedDlRachInfoReqParameters& params);
+ virtual void SchedDlCqiInfoReq (const struct SchedDlCqiInfoReqParameters& params);
+ virtual void SchedUlTriggerReq (const struct SchedUlTriggerReqParameters& params);
+ virtual void SchedUlNoiseInterferenceReq (const struct SchedUlNoiseInterferenceReqParameters& params);
+ virtual void SchedUlSrInfoReq (const struct SchedUlSrInfoReqParameters& params);
+ virtual void SchedUlMacCtrlInfoReq (const struct SchedUlMacCtrlInfoReqParameters& params);
+ virtual void SchedUlCqiInfoReq (const struct SchedUlCqiInfoReqParameters& params);
+
+
+private:
+ FdTbfqSchedulerMemberSchedSapProvider ();
+ FdTbfqFfMacScheduler* m_scheduler;
+};
+
+
+
+FdTbfqSchedulerMemberSchedSapProvider::FdTbfqSchedulerMemberSchedSapProvider ()
+{
+}
+
+
+FdTbfqSchedulerMemberSchedSapProvider::FdTbfqSchedulerMemberSchedSapProvider (FdTbfqFfMacScheduler* scheduler)
+ : m_scheduler (scheduler)
+{
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedDlRlcBufferReq (const struct SchedDlRlcBufferReqParameters& params)
+{
+ m_scheduler->DoSchedDlRlcBufferReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedDlPagingBufferReq (const struct SchedDlPagingBufferReqParameters& params)
+{
+ m_scheduler->DoSchedDlPagingBufferReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedDlMacBufferReq (const struct SchedDlMacBufferReqParameters& params)
+{
+ m_scheduler->DoSchedDlMacBufferReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedDlTriggerReq (const struct SchedDlTriggerReqParameters& params)
+{
+ m_scheduler->DoSchedDlTriggerReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedDlRachInfoReq (const struct SchedDlRachInfoReqParameters& params)
+{
+ m_scheduler->DoSchedDlRachInfoReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedDlCqiInfoReq (const struct SchedDlCqiInfoReqParameters& params)
+{
+ m_scheduler->DoSchedDlCqiInfoReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedUlTriggerReq (const struct SchedUlTriggerReqParameters& params)
+{
+ m_scheduler->DoSchedUlTriggerReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedUlNoiseInterferenceReq (const struct SchedUlNoiseInterferenceReqParameters& params)
+{
+ m_scheduler->DoSchedUlNoiseInterferenceReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedUlSrInfoReq (const struct SchedUlSrInfoReqParameters& params)
+{
+ m_scheduler->DoSchedUlSrInfoReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedUlMacCtrlInfoReq (const struct SchedUlMacCtrlInfoReqParameters& params)
+{
+ m_scheduler->DoSchedUlMacCtrlInfoReq (params);
+}
+
+void
+FdTbfqSchedulerMemberSchedSapProvider::SchedUlCqiInfoReq (const struct SchedUlCqiInfoReqParameters& params)
+{
+ m_scheduler->DoSchedUlCqiInfoReq (params);
+}
+
+
+
+
+
+FdTbfqFfMacScheduler::FdTbfqFfMacScheduler ()
+ : m_cschedSapUser (0),
+ m_schedSapUser (0),
+ m_nextRntiUl (0),
+ bankSize(0)
+{
+ m_amc = CreateObject <LteAmc> ();
+ m_cschedSapProvider = new FdTbfqSchedulerMemberCschedSapProvider (this);
+ m_schedSapProvider = new FdTbfqSchedulerMemberSchedSapProvider (this);
+}
+
+FdTbfqFfMacScheduler::~FdTbfqFfMacScheduler ()
+{
+ NS_LOG_FUNCTION (this);
+}
+
+void
+FdTbfqFfMacScheduler::DoDispose ()
+{
+ NS_LOG_FUNCTION (this);
+ delete m_cschedSapProvider;
+ delete m_schedSapProvider;
+}
+
+TypeId
+FdTbfqFfMacScheduler::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("ns3::FdTbfqFfMacScheduler")
+ .SetParent<FfMacScheduler> ()
+ .AddConstructor<FdTbfqFfMacScheduler> ()
+ .AddAttribute ("CqiTimerThreshold",
+ "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
+ UintegerValue (1000),
+ MakeUintegerAccessor (&FdTbfqFfMacScheduler::m_cqiTimersThreshold),
+ MakeUintegerChecker<uint32_t> ())
+ ;
+ return tid;
+}
+
+
+
+void
+FdTbfqFfMacScheduler::SetFfMacCschedSapUser (FfMacCschedSapUser* s)
+{
+ m_cschedSapUser = s;
+}
+
+void
+FdTbfqFfMacScheduler::SetFfMacSchedSapUser (FfMacSchedSapUser* s)
+{
+ m_schedSapUser = s;
+}
+
+FfMacCschedSapProvider*
+FdTbfqFfMacScheduler::GetFfMacCschedSapProvider ()
+{
+ return m_cschedSapProvider;
+}
+
+FfMacSchedSapProvider*
+FdTbfqFfMacScheduler::GetFfMacSchedSapProvider ()
+{
+ return m_schedSapProvider;
+}
+
+void
+FdTbfqFfMacScheduler::DoCschedCellConfigReq (const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // Read the subset of parameters used
+ m_cschedCellConfig = params;
+ FfMacCschedSapUser::CschedUeConfigCnfParameters cnf;
+ cnf.m_result = SUCCESS;
+ m_cschedSapUser->CschedUeConfigCnf (cnf);
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoCschedUeConfigReq (const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode);
+ std::map <uint16_t,uint8_t>::iterator it = m_uesTxMode.find (params.m_rnti);
+ if (it==m_uesTxMode.end ())
+ {
+ m_uesTxMode.insert (std::pair <uint16_t, double> (params.m_rnti, params.m_transmissionMode));
+ }
+ else
+ {
+ (*it).second = params.m_transmissionMode;
+ }
+ return;
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoCschedLcConfigReq (const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " New LC, rnti: " << params.m_rnti);
+
+ std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator it;
+ for (uint16_t i = 0; i < params.m_logicalChannelConfigList.size (); i++)
+ {
+ it = m_flowStatsDl.find (params.m_rnti);
+
+ if (it == m_flowStatsDl.end ())
+ {
+ uint64_t mbrDlInBytes = params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateDl / 8; // byte/s
+ uint64_t mbrUlInBytes = params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateUl / 8; // byte/s
+
+ fdtbfqsFlowPerf_t flowStatsDl;
+ flowStatsDl.flowStart = Simulator::Now ();
+ flowStatsDl.packetArrivalRate = 0;
+ flowStatsDl.tokenGenerationRate = mbrDlInBytes;
+ flowStatsDl.tokenPoolSize = 0;
+ flowStatsDl.maxTokenPoolSize = 1;
+ flowStatsDl.counter = 0;
+ flowStatsDl.burstCredit = 625000; // bytes
+ flowStatsDl.debtLimit = -625000; // bytes
+ flowStatsDl.creditableThreshold = 0;
+ m_flowStatsDl.insert (std::pair<uint16_t, fdtbfqsFlowPerf_t> (params.m_rnti, flowStatsDl));
+ fdtbfqsFlowPerf_t flowStatsUl;
+ flowStatsUl.flowStart = Simulator::Now ();
+ flowStatsUl.packetArrivalRate = 0;
+ flowStatsUl.tokenGenerationRate = mbrUlInBytes;
+ flowStatsUl.tokenPoolSize = 0;
+ flowStatsUl.maxTokenPoolSize = 1;
+ flowStatsUl.counter = 0;
+ flowStatsUl.burstCredit = 625000; // bytes
+ flowStatsUl.debtLimit = -625000; // bytes
+ flowStatsUl.creditableThreshold = 0;
+ m_flowStatsUl.insert (std::pair<uint16_t, fdtbfqsFlowPerf_t> (params.m_rnti, flowStatsUl));
+
+ NS_LOG_DEBUG(" UE "<<params.m_rnti<<" MaximulBitrateDl "<<params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateDl << " gbrDlInbytes "<<mbrDlInBytes);
+ }
+ else
+ {
+ NS_LOG_ERROR ("RNTI already exists");
+ }
+ }
+
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoCschedLcReleaseReq (const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoCschedUeReleaseReq (const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+
+void
+FdTbfqFfMacScheduler::DoSchedDlRlcBufferReq (const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity);
+ // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
+
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
+
+ LteFlowId_t flow (params.m_rnti, params.m_logicalChannelIdentity);
+
+ it = m_rlcBufferReq.find (flow);
+
+ if (it == m_rlcBufferReq.end ())
+ {
+ m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
+ }
+ else
+ {
+ (*it).second = params;
+ }
+
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedDlPagingBufferReq (const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedDlMacBufferReq (const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+int
+FdTbfqFfMacScheduler::GetRbgSize (int dlbandwidth)
+{
+ for (int i = 0; i < 4; i++)
+ {
+ if (dlbandwidth < FdTbfqType0AllocationRbg[i])
+ {
+ return (i + 1);
+ }
+ }
+
+ return (-1);
+}
+
+
+int
+FdTbfqFfMacScheduler::LcActivePerFlow (uint16_t rnti)
+{
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
+ int lcActive = 0;
+ for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
+ {
+ if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
+ || ((*it).second.m_rlcRetransmissionQueueSize > 0)
+ || ((*it).second.m_rlcStatusPduSize > 0) ))
+ {
+ lcActive++;
+ }
+ if ((*it).first.m_rnti > rnti)
+ {
+ break;
+ }
+ }
+ return (lcActive);
+
+}
+
+
+void
+FdTbfqFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
+ // API generated by RLC for triggering the scheduling of a DL subframe
+
+
+ // evaluate the relative channel quality indicator for each UE per each RBG
+ // (since we are using allocation type 0 the small unit of allocation is RBG)
+ // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
+ RefreshDlCqiMaps ();
+
+ // update token pool, counter and bank size
+ std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itStats;
+ for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
+ {
+ if ( (*itStats).second.tokenGenerationRate/1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
+ {
+ (*itStats).second.counter += (*itStats).second.tokenGenerationRate/1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
+ (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
+ bankSize += (*itStats).second.tokenGenerationRate/1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
+ }
+ else
+ {
+ (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate/1000;
+ }
+ }
+
+ int rbgSize = GetRbgSize (m_cschedCellConfig.m_dlBandwidth);
+ int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
+ std::map <uint16_t, std::vector <uint16_t> > allocationMap;
+ std::set <uint16_t> allocatedRnti; // store UEs which are already assigned RBGs
+ std::set <uint8_t> allocatedRbg; // store RBGs which are already allocated to UE
+
+ int totalRbg = 0;
+ while (totalRbg < rbgNum)
+ {
+ // select UE with largest metric
+ std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator it;
+ std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itMax = m_flowStatsDl.end ();
+ double metricMax;
+ bool firstRnti = true;
+ for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it++)
+ {
+ if (LcActivePerFlow ((*it).first) == 0)
+ {
+ continue;
+ }
+
+ std::set <uint16_t>::iterator rnti;
+ rnti = allocatedRnti.find((*it).first);
+ if (rnti != allocatedRnti.end()) // already allocated RBGs to this UE
+ {
+ continue;
+ }
+
+ double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
+
+ if (firstRnti == true)
+ {
+ metricMax = metric;
+ itMax = it;
+ firstRnti = false;
+ continue;
+ }
+ if (metric > metricMax)
+ {
+ metricMax = metric;
+ itMax = it;
+ }
+ } // end for m_flowStatsDl
+
+ if (itMax == m_flowStatsDl.end())
+ {
+ // all UEs are allocated RBG
+ break;
+ }
+
+ // mark this UE as "allocated"
+ allocatedRnti.insert((*itMax).first);
+
+ // calculate the maximum number of byte that the scheduler can assigned to this UE
+ uint32_t budget = 0;
+ if ( bankSize > 0 )
+ {
+ budget = (*itMax).second.counter - (*itMax).second.debtLimit;
+ if ( budget > (*itMax).second.burstCredit )
+ budget = (*itMax).second.burstCredit;
+ if ( budget > bankSize )
+ budget = bankSize;
+ }
+ budget = budget + (*itMax).second.tokenPoolSize;
+
+ // calcualte how much bytes this UE acutally need
+ if (budget == 0)
+ {
+ // there are no tokens for this UE
+ continue;
+ }
+ else
+ {
+ // calculate rlc buffer size
+ uint32_t rlcBufSize;
+ uint8_t lcid;
+ std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itRlcBuf;
+ for (itRlcBuf = m_rlcBufferReq.begin (); itRlcBuf != m_rlcBufferReq.end (); itRlcBuf++)
+ {
+ if ( (*itRlcBuf).first.m_rnti == (*itMax).first )
+ lcid = (*itRlcBuf).first.m_lcId;
+ }
+ LteFlowId_t flow ((*itMax).first, lcid);
+ itRlcBuf = m_rlcBufferReq.find (flow);
+ if (itRlcBuf!=m_rlcBufferReq.end ())
+ rlcBufSize = (*itRlcBuf).second.m_rlcTransmissionQueueSize + (*itRlcBuf).second.m_rlcRetransmissionQueueSize + (*itRlcBuf).second.m_rlcStatusPduSize;
+ if ( budget > rlcBufSize )
+ budget = rlcBufSize;
+ }
+
+
+ // assign RBGs to this UE
+ uint32_t bytesTxed = 0;
+ uint32_t bytesTxedTmp = 0;
+ int rbgIndex;
+ while ( bytesTxed <= budget )
+ {
+ totalRbg++;
+
+ std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
+ itCqi = m_a30CqiRxed.find ((*itMax).first);
+ std::map <uint16_t,uint8_t>::iterator itTxMode;
+ itTxMode = m_uesTxMode.find ((*itMax).first);
+ if (itTxMode == m_uesTxMode.end())
+ {
+ NS_FATAL_ERROR ("No Transmission Mode info on user " << (*it).first);
+ }
+ int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
+
+ // find RBG with largest achievableRate
+ double achievableRateMax = 0.0;
+ rbgIndex = rbgNum;
+ for (int k = 0; k < rbgNum; k++)
+ {
+ std::set <uint8_t>::iterator rbg;
+ rbg = allocatedRbg.find(k);
+ if (rbg != allocatedRbg.end()) // RBGs are already allocated to this UE
+ continue;
+
+ std::vector <uint8_t> sbCqi;
+ if (itCqi == m_a30CqiRxed.end ())
+ {
+ for (uint8_t k = 0; k < nLayer; k++)
+ {
+ sbCqi.push_back (1); // start with lowest value
+ }
+ }
+ else
+ {
+ sbCqi = (*itCqi).second.m_higherLayerSelected.at (k).m_sbCqi;
+ }
+ uint8_t cqi1 = sbCqi.at(0);
+ uint8_t cqi2 = 1;
+ if (sbCqi.size () > 1)
+ {
+ cqi2 = sbCqi.at(1);
+ }
+
+ if ((cqi1 > 0)||(cqi2 > 0)) // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
+ {
+ if (LcActivePerFlow ((*itMax).first) > 0)
+ {
+ // this UE has data to transmit
+ double achievableRate = 0.0;
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ uint8_t mcs = 0;
+ if (sbCqi.size () > j)
+ {
+ mcs = m_amc->GetMcsFromCqi (sbCqi.at (j));
+ }
+ else
+ {
+ // no info on this subband -> worst MCS
+ mcs = 0;
+ }
+ achievableRate += ((m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001); // = TB size / TTI
+ }
+
+ if ( achievableRate > achievableRateMax )
+ {
+ achievableRateMax = achievableRate;
+ rbgIndex = k;
+ }
+ } // end of LcActivePerFlow
+ }
+ } // end of for rbgNum
+
+ if ( rbgIndex == rbgNum) // impossible
+ {
+ // all RBGs are already assigned
+ totalRbg = rbgNum;
+ break;
+ }
+ else
+ {
+ // mark this UE as "allocated"
+ allocatedRbg.insert(rbgIndex);
+ }
+
+ // assign this RBG to UE
+ std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
+ itMap = allocationMap.find ((*itMax).first);
+ uint16_t RbgPerRnti;
+ if (itMap == allocationMap.end ())
+ {
+ // insert new element
+ std::vector <uint16_t> tempMap;
+ tempMap.push_back (rbgIndex);
+ allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
+ itMap = allocationMap.find ((*itMax).first); // point itMap to the first RBGs assigned to this UE
+ }
+ else
+ {
+ (*itMap).second.push_back (rbgIndex);
+ }
+
+ RbgPerRnti = (*itMap).second.size();
+
+ // calculate tb size
+ std::vector <uint8_t> worstCqi (2, 15);
+ if (itCqi != m_a30CqiRxed.end ())
+ {
+ for (uint16_t k = 0; k < (*itMap).second.size (); k++)
+ {
+ if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size ()> j)
+ {
+ if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
+ {
+ worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
+ }
+ }
+ else
+ {
+ // no CQI for this layer of this suband -> worst one
+ worstCqi.at (j) = 1;
+ }
+ }
+ }
+ else
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
+ }
+ }
+ }
+ }
+ else
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
+ }
+ }
+
+ bytesTxedTmp = bytesTxed;
+ bytesTxed = 0;
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ int tbSize = (m_amc->GetTbSizeFromMcs (m_amc->GetMcsFromCqi (worstCqi.at (j)), RbgPerRnti * rbgSize) / 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
+ bytesTxed += tbSize;
+ }
+
+ } // end of while()
+
+ // remove and unmark last RBG assigned to UE
+ if ( bytesTxed > budget )
+ {
+ std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
+ itMap = allocationMap.find ((*itMax).first);
+ (*itMap).second.pop_back();
+ allocatedRbg.erase(rbgIndex);
+ bytesTxed = bytesTxedTmp; // recovery bytesTxed
+ totalRbg--;
+ }
+
+ // update UE stats
+ if ( bytesTxed <= (*itMax).second.tokenPoolSize )
+ {
+ (*itMax).second.tokenPoolSize -= bytesTxed;
+ }
+ else
+ {
+ (*itMax).second.counter = (*itMax).second.counter - ( bytesTxed - (*itMax).second.tokenPoolSize );
+ (*itMax).second.tokenPoolSize = 0;
+ if (bankSize <= ( bytesTxed - (*itMax).second.tokenPoolSize ))
+ bankSize = 0;
+ else
+ bankSize = bankSize - ( bytesTxed - (*itMax).second.tokenPoolSize );
+ }
+ } // end of RBGs
+
+ // generate the transmission opportunities by grouping the RBGs of the same RNTI and
+ // creating the correspondent DCIs
+ FfMacSchedSapUser::SchedDlConfigIndParameters ret;
+ std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
+
+ while (itMap != allocationMap.end ())
+ {
+ // create new BuildDataListElement_s for this LC
+ BuildDataListElement_s newEl;
+ newEl.m_rnti = (*itMap).first;
+ // create the DlDciListElement_s
+ DlDciListElement_s newDci;
+ std::vector <struct RlcPduListElement_s> newRlcPduLe;
+ newDci.m_rnti = (*itMap).first;
+
+ uint16_t lcActives = LcActivePerFlow ((*itMap).first);
+// NS_LOG_DEBUG (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+ uint16_t RgbPerRnti = (*itMap).second.size ();
+ std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
+ itCqi = m_a30CqiRxed.find ((*itMap).first);
+ std::map <uint16_t,uint8_t>::iterator itTxMode;
+ itTxMode = m_uesTxMode.find ((*itMap).first);
+ if (itTxMode == m_uesTxMode.end())
+ {
+ NS_FATAL_ERROR ("No Transmission Mode info on user " << (*itMap).first);
+ }
+ int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
+ std::vector <uint8_t> worstCqi (2, 15);
+ if (itCqi != m_a30CqiRxed.end ())
+ {
+ for (uint16_t k = 0; k < (*itMap).second.size (); k++)
+ {
+ if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
+ {
+ //NS_LOG_DEBUG (this << " RBG " << (*itMap).second.at (k) << " CQI " << (uint16_t)((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (0)) );
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size ()> j)
+ {
+ if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
+ {
+ worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
+ }
+ }
+ else
+ {
+ // no CQI for this layer of this suband -> worst one
+ worstCqi.at (j) = 1;
+ }
+ //NS_LOG_DEBUG (this << " RBG " << (*itMap).second.at (k) << " CQI " <<(uint16_t)j <<" "<< (uint16_t)worstCqi.at(j));
+ }
+ }
+ else
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
+ }
+ }
+ }
+ }
+ else
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
+ }
+ }
+// NS_LOG_DEBUG (this << " CQI " << (uint16_t)worstCqi);
+ uint32_t bytesTxed = 0;
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ newDci.m_mcs.push_back (m_amc->GetMcsFromCqi (worstCqi.at (j)));
+ int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (j), RgbPerRnti * rbgSize) / 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
+ // NS_LOG_DEBUG ( Simulator::Now() << " Allocateuser " << newEl.m_rnti << " tbSize "<< tbSize << " RBG " << RgbPerRnti << " mcs " << (uint16_t) newDci.m_mcs.at (j) << " cqi " << (uint16_t)worstCqi.at(j));
+ newDci.m_tbsSize.push_back (tbSize);
+ bytesTxed += tbSize;
+ //NS_LOG_DEBUG (this << " MCS " << m_amc->GetMcsFromCqi (worstCqi.at (j)));
+ }
+
+ newDci.m_resAlloc = 0; // only allocation type 0 at this stage
+ newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
+ uint32_t rbgMask = 0;
+ //for (uint16_t k = 0; k < (*itMap).second.size (); k++)
+ for (uint16_t k = 0; k < RgbPerRnti; k++)
+ {
+ rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
+// NS_LOG_DEBUG (this << " Allocated PRB " << (*itMap).second.at (k));
+ }
+ newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
+
+ // create the rlc PDUs -> equally divide resources among actives LCs
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
+ for (itBufReq = m_rlcBufferReq.begin (); itBufReq != m_rlcBufferReq.end (); itBufReq++)
+ {
+ if (((*itBufReq).first.m_rnti == (*itMap).first) &&
+ (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
+ || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
+ || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ RlcPduListElement_s newRlcEl;
+ newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
+ newRlcEl.m_size = newDci.m_tbsSize.at (j) / lcActives;
+ //NS_LOG_DEBUG ( Simulator::Now() << " LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
+
+ newRlcPduLe.push_back (newRlcEl);
+ UpdateDlRlcBufferInfo (newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size);
+ }
+ }
+ if ((*itBufReq).first.m_rnti > (*itMap).first)
+ {
+ break;
+ }
+ }
+ newDci.m_ndi.push_back (1); // TBD (new data indicator)
+ newDci.m_rv.push_back (0); // TBD (redundancy version)
+
+ newEl.m_dci = newDci;
+ // ...more parameters -> ingored in this version
+
+ newEl.m_rlcPduList.push_back (newRlcPduLe);
+ ret.m_buildDataList.push_back (newEl);
+
+ itMap++;
+ } // end while allocation
+ ret.m_nrOfPdcchOfdmSymbols = 1; // TODO: check correct value according the DCIs txed
+
+ m_schedSapUser->SchedDlConfigInd (ret);
+
+
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedDlRachInfoReq (const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedDlCqiInfoReq (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+
+ for (unsigned int i = 0; i < params.m_cqiList.size (); i++)
+ {
+ if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
+ {
+ // wideband CQI reporting
+ std::map <uint16_t,uint8_t>::iterator it;
+ uint16_t rnti = params.m_cqiList.at (i).m_rnti;
+ it = m_p10CqiRxed.find (rnti);
+ if (it == m_p10CqiRxed.end ())
+ {
+ // create the new entry
+ m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.m_cqiList.at (i).m_wbCqi.at (0)) ); // only codeword 0 at this stage (SISO)
+ // generate correspondent timer
+ m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
+ }
+ else
+ {
+ // update the CQI value and refresh correspondent timer
+ (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
+ // update correspondent timer
+ std::map <uint16_t,uint32_t>::iterator itTimers;
+ itTimers = m_p10CqiTimers.find (rnti);
+ (*itTimers).second = m_cqiTimersThreshold;
+ }
+ }
+ else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
+ {
+ // subband CQI reporting high layer configured
+ std::map <uint16_t,SbMeasResult_s>::iterator it;
+ uint16_t rnti = params.m_cqiList.at (i).m_rnti;
+ it = m_a30CqiRxed.find (rnti);
+ if (it == m_a30CqiRxed.end ())
+ {
+ // create the new entry
+ m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.m_cqiList.at (i).m_sbMeasResult) );
+ m_a30CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
+ }
+ else
+ {
+ // update the CQI value and refresh correspondent timer
+ (*it).second = params.m_cqiList.at (i).m_sbMeasResult;
+ std::map <uint16_t,uint32_t>::iterator itTimers;
+ itTimers = m_a30CqiTimers.find (rnti);
+ (*itTimers).second = m_cqiTimersThreshold;
+ }
+ }
+ else
+ {
+ NS_LOG_ERROR (this << " CQI type unknown");
+ }
+ }
+
+ return;
+}
+
+
+double
+FdTbfqFfMacScheduler::EstimateUlSinr (uint16_t rnti, uint16_t rb)
+{
+ std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find (rnti);
+ if (itCqi == m_ueCqi.end ())
+ {
+ // no cqi info about this UE
+ return (NO_SINR);
+
+ }
+ else
+ {
+ // take the average SINR value among the available
+ double sinrSum = 0;
+ int sinrNum = 0;
+ for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
+ {
+ double sinr = (*itCqi).second.at (i);
+ if (sinr != NO_SINR)
+ {
+ sinrSum += sinr;
+ sinrNum++;
+ }
+ }
+ double estimatedSinr = sinrSum / (double)sinrNum;
+ // store the value
+ (*itCqi).second.at (rb) = estimatedSinr;
+ return (estimatedSinr);
+ }
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
+
+ RefreshUlCqiMaps ();
+
+ std::map <uint16_t,uint32_t>::iterator it;
+ int nflows = 0;
+
+ for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
+ {
+ // remove old entries of this UE-LC
+ if ((*it).second > 0)
+ {
+ nflows++;
+ }
+ }
+
+ if (nflows == 0)
+ {
+ return ; // no flows to be scheduled
+ }
+
+
+ // Divide the resource equally among the active users
+ int rbPerFlow = m_cschedCellConfig.m_ulBandwidth / nflows;
+ if (rbPerFlow == 0)
+ {
+ rbPerFlow = 1; // at least 1 rbg per flow (till available resource)
+ }
+ int rbAllocated = 0;
+
+ FfMacSchedSapUser::SchedUlConfigIndParameters ret;
+ std::vector <uint16_t> rbgAllocationMap;
+ //std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itStats;
+ if (m_nextRntiUl != 0)
+ {
+ for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
+ {
+ if ((*it).first == m_nextRntiUl)
+ {
+ break;
+ }
+ }
+ if (it == m_ceBsrRxed.end ())
+ {
+ NS_LOG_ERROR (this << " no user found");
+ }
+ }
+ else
+ {
+ it = m_ceBsrRxed.begin ();
+ m_nextRntiUl = (*it).first;
+ }
+ do
+ {
+ if (rbAllocated + rbPerFlow > m_cschedCellConfig.m_ulBandwidth)
+ {
+ // limit to physical resources last resource assignment
+ rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
+ }
+
+ UlDciListElement_s uldci;
+ uldci.m_rnti = (*it).first;
+ uldci.m_rbStart = rbAllocated;
+ uldci.m_rbLen = rbPerFlow;
+ std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
+ int cqi = 0;
+ if (itCqi == m_ueCqi.end ())
+ {
+ // no cqi info about this UE
+ uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
+// NS_LOG_DEBUG (this << " UE does not have ULCQI " << (*it).first );
+ }
+ else
+ {
+ // take the lowest CQI value (worst RB)
+ double minSinr = (*itCqi).second.at (uldci.m_rbStart);
+ if (minSinr == NO_SINR)
+ {
+ minSinr = EstimateUlSinr ((*it).first, uldci.m_rbStart);
+ }
+ for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
+ {
+// NS_LOG_DEBUG (this << " UE " << (*it).first << " has SINR " << (*itCqi).second.at(i));
+ double sinr = (*itCqi).second.at (i);
+ if (sinr == NO_SINR)
+ {
+ sinr = EstimateUlSinr ((*it).first, i);
+ }
+ if ((*itCqi).second.at (i) < minSinr)
+ {
+ minSinr = (*itCqi).second.at (i);
+ }
+ }
+
+ // translate SINR -> cqi: WILD ACK: same as DL
+ double s = log2 ( 1 + (
+ pow (10, minSinr / 10 ) /
+ ( (-log (5.0 * 0.00005 )) / 1.5) ));
+ cqi = m_amc->GetCqiFromSpectralEfficiency (s);
+ if (cqi == 0)
+ {
+ it++;
+ if (it == m_ceBsrRxed.end ())
+ {
+ // restart from the first
+ it = m_ceBsrRxed.begin ();
+ }
+ continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
+ }
+ uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
+// NS_LOG_DEBUG (this << " UE " << (*it).first << " minsinr " << minSinr << " -> mcs " << (uint16_t)uldci.m_mcs);
+
+ }
+
+ rbAllocated += rbPerFlow;
+ // store info on allocation for managing ul-cqi interpretation
+ for (int i = 0; i < rbPerFlow; i++)
+ {
+ rbgAllocationMap.push_back ((*it).first);
+ }
+ uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
+ NS_LOG_DEBUG (this <<" "<<Simulator::Now()<< " UE " << (*it).first << " startPRB " << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize " << uldci.m_tbSize << " RbAlloc " << rbAllocated);
+ UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
+ uldci.m_ndi = 1;
+ uldci.m_cceIndex = 0;
+ uldci.m_aggrLevel = 1;
+ uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
+ uldci.m_hopping = false;
+ uldci.m_n2Dmrs = 0;
+ uldci.m_tpc = 0; // no power control
+ uldci.m_cqiRequest = false; // only period CQI at this stage
+ uldci.m_ulIndex = 0; // TDD parameter
+ uldci.m_dai = 1; // TDD parameter
+ uldci.m_freqHopping = 0;
+ uldci.m_pdcchPowerOffset = 0; // not used
+ ret.m_dciList.push_back (uldci);
+
+ it++;
+ if (it == m_ceBsrRxed.end ())
+ {
+ // restart from the first
+ it = m_ceBsrRxed.begin ();
+ }
+ if (rbAllocated == m_cschedCellConfig.m_ulBandwidth)
+ {
+ // Stop allocation: no more PRBs
+ m_nextRntiUl = (*it).first;
+ break;
+ }
+ }
+ while ((*it).first != m_nextRntiUl);
+
+ m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
+ m_schedSapUser->SchedUlConfigInd (ret);
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedUlNoiseInterferenceReq (const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedUlSrInfoReq (const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+
+ std::map <uint16_t,uint32_t>::iterator it;
+
+ for (unsigned int i = 0; i < params.m_macCeList.size (); i++)
+ {
+ if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
+ {
+ // buffer status report
+ uint16_t rnti = params.m_macCeList.at (i).m_rnti;
+ it = m_ceBsrRxed.find (rnti);
+ if (it == m_ceBsrRxed.end ())
+ {
+ // create the new entry
+ uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0);
+ int buffer = BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
+ m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer)); // only 1 buffer status is working now
+ }
+ else
+ {
+ // update the CQI value
+ (*it).second = BufferSizeLevelBsr::BsrId2BufferSize (params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0));
+ }
+ }
+ }
+
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+// NS_LOG_DEBUG (this << " RX SFNID " << params.m_sfnSf);
+ // retrieve the allocation for this subframe
+ std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
+ std::map <uint16_t, std::vector <double> >::iterator itCqi;
+ itMap = m_allocationMaps.find (params.m_sfnSf);
+ if (itMap == m_allocationMaps.end ())
+ {
+ //NS_LOG_DEBUG (this << " Does not find info on allocation, size : " << m_allocationMaps.size ());
+ return;
+ }
+ for (uint32_t i = 0; i < (*itMap).second.size (); i++)
+ {
+ // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
+// NS_LOG_INFO (this << " i " << i << " size " << params.m_ulCqi.m_sinr.size () << " mapSIze " << (*itMap).second.size ());
+ double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
+ //NS_LOG_DEBUG (this << " UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr);
+ itCqi = m_ueCqi.find ((*itMap).second.at (i));
+ if (itCqi == m_ueCqi.end ())
+ {
+ // create a new entry
+ std::vector <double> newCqi;
+ for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+ {
+ if (i == j)
+ {
+ newCqi.push_back (sinr);
+ }
+ else
+ {
+ // initialize with NO_SINR value.
+ newCqi.push_back (NO_SINR);
+ }
+
+ }
+ m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
+ // generate correspondent timer
+ m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
+ }
+ else
+ {
+ // update the value
+ (*itCqi).second.at (i) = sinr;
+ // update correspondent timer
+ std::map <uint16_t, uint32_t>::iterator itTimers;
+ itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
+ (*itTimers).second = m_cqiTimersThreshold;
+
+ }
+
+ }
+ // remove obsolete info on allocation
+ m_allocationMaps.erase (itMap);
+
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::RefreshDlCqiMaps(void)
+{
+ // refresh DL CQI P01 Map
+ std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
+ while (itP10!=m_p10CqiTimers.end ())
+ {
+// NS_LOG_INFO (this << " P10-CQI for user " << (*itP10).first << " is " << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
+ if ((*itP10).second == 0)
+ {
+ // delete correspondent entries
+ std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
+ NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (), " Does not find CQI report for user " << (*itP10).first);
+ NS_LOG_INFO (this << " P10-CQI exired for user " << (*itP10).first);
+ m_p10CqiRxed.erase (itMap);
+ std::map <uint16_t,uint32_t>::iterator temp = itP10;
+ itP10++;
+ m_p10CqiTimers.erase (temp);
+ }
+ else
+ {
+ (*itP10).second--;
+ itP10++;
+ }
+ }
+
+ // refresh DL CQI A30 Map
+ std::map <uint16_t,uint32_t>::iterator itA30 = m_a30CqiTimers.begin ();
+ while (itA30!=m_a30CqiTimers.end ())
+ {
+// NS_LOG_INFO (this << " A30-CQI for user " << (*itA30).first << " is " << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
+ if ((*itA30).second == 0)
+ {
+ // delete correspondent entries
+ std::map <uint16_t,SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find ((*itA30).first);
+ NS_ASSERT_MSG (itMap != m_a30CqiRxed.end (), " Does not find CQI report for user " << (*itA30).first);
+ NS_LOG_INFO (this << " A30-CQI exired for user " << (*itA30).first);
+ m_a30CqiRxed.erase (itMap);
+ std::map <uint16_t,uint32_t>::iterator temp = itA30;
+ itA30++;
+ m_a30CqiTimers.erase (temp);
+ }
+ else
+ {
+ (*itA30).second--;
+ itA30++;
+ }
+ }
+
+ return;
+}
+
+
+void
+FdTbfqFfMacScheduler::RefreshUlCqiMaps(void)
+{
+ // refresh UL CQI Map
+ std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
+ while (itUl!=m_ueCqiTimers.end ())
+ {
+// NS_LOG_INFO (this << " UL-CQI for user " << (*itUl).first << " is " << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
+ if ((*itUl).second == 0)
+ {
+ // delete correspondent entries
+ std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
+ NS_ASSERT_MSG (itMap != m_ueCqi.end (), " Does not find CQI report for user " << (*itUl).first);
+ NS_LOG_INFO (this << " UL-CQI exired for user " << (*itUl).first);
+ (*itMap).second.clear ();
+ m_ueCqi.erase (itMap);
+ std::map <uint16_t,uint32_t>::iterator temp = itUl;
+ itUl++;
+ m_ueCqiTimers.erase (temp);
+ }
+ else
+ {
+ (*itUl).second--;
+ itUl++;
+ }
+ }
+
+ return;
+}
+
+void
+FdTbfqFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
+{
+ std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
+ LteFlowId_t flow (rnti, lcid);
+ it = m_rlcBufferReq.find (flow);
+ if (it!=m_rlcBufferReq.end ())
+ {
+ //NS_LOG_DEBUG (this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " << (*it).second.m_rlcTransmissionQueueSize << " retxqueue " << (*it).second.m_rlcRetransmissionQueueSize << " status " << (*it).second.m_rlcStatusPduSize << " decrease " << size);
+ // Update queues: RLC tx order Status, ReTx, Tx
+ // Update status queue
+ if ((*it).second.m_rlcStatusPduSize <= size)
+ {
+ size -= (*it).second.m_rlcStatusPduSize;
+ (*it).second.m_rlcStatusPduSize = 0;
+ }
+ else
+ {
+ (*it).second.m_rlcStatusPduSize -= size;
+ return;
+ }
+ // update retransmission queue
+ if ((*it).second.m_rlcRetransmissionQueueSize <= size)
+ {
+ size -= (*it).second.m_rlcRetransmissionQueueSize;
+ (*it).second.m_rlcRetransmissionQueueSize = 0;
+ }
+ else
+ {
+ (*it).second.m_rlcRetransmissionQueueSize -= size;
+ return;
+ }
+ // update transmission queue
+ if ((*it).second.m_rlcTransmissionQueueSize <= size)
+ {
+ size -= (*it).second.m_rlcTransmissionQueueSize;
+ (*it).second.m_rlcTransmissionQueueSize = 0;
+ }
+ else
+ {
+ (*it).second.m_rlcTransmissionQueueSize -= size;
+ return;
+ }
+ }
+ else
+ {
+ NS_LOG_ERROR (this << " Does not find DL RLC Buffer Report of UE " << rnti);
+ }
+}
+
+void
+FdTbfqFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
+{
+
+
+ std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
+ if (it!=m_ceBsrRxed.end ())
+ {
+// NS_LOG_DEBUG (this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
+ if ((*it).second >= size)
+ {
+ (*it).second -= size;
+ }
+ else
+ {
+ (*it).second = 0;
+ }
+ }
+ else
+ {
+ NS_LOG_ERROR (this << " Does not find BSR report info of UE " << rnti);
+ }
+
+}
+
+void
+FdTbfqFfMacScheduler::TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode)
+{
+ NS_LOG_FUNCTION (this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
+ FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params;
+ params.m_rnti = rnti;
+ params.m_transmissionMode = txMode;
+ m_cschedSapUser->CschedUeConfigUpdateInd (params);
+}
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/fdtbfq-ff-mac-scheduler.h Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,230 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#ifndef FDTBFQ_FF_MAC_SCHEDULER_H
+#define FDTBFQ_FF_MAC_SCHEDULER_H
+
+#include <ns3/lte-common.h>
+#include <ns3/ff-mac-csched-sap.h>
+#include <ns3/ff-mac-sched-sap.h>
+#include <ns3/ff-mac-scheduler.h>
+#include <vector>
+#include <map>
+#include <set>
+#include <ns3/nstime.h>
+#include <ns3/lte-amc.h>
+
+
+// value for SINR outside the range defined by FF-API, used to indicate that there
+// is no CQI for this element
+#define NO_SINR -5000
+
+namespace ns3 {
+
+
+struct fdtbfqsFlowPerf_t
+{
+ Time flowStart;
+ uint64_t packetArrivalRate; // packet arrival rate( byte/s)
+ uint64_t tokenGenerationRate; // token generation rate ( byte/s )
+ uint32_t tokenPoolSize; // current size of token pool (byte)
+ uint32_t maxTokenPoolSize; // maximum size of token pool (byte)
+ int counter; // the number of token borrow or given to token bank
+ uint32_t burstCredit; // the maximum number of tokens connection i can borrow from the bank each time
+ int debtLimit; // counter threshold that the flow cannot further borrow tokens from bank
+ uint32_t creditableThreshold; // the flow cannot borrow token from bank until the number of token it has deposited to bank reaches this threshold
+};
+
+
+/**
+ * \ingroup ff-api
+ * \defgroup FF-API FdTbfqFfMacScheduler
+ */
+/**
+ * \ingroup FdTbfqFfMacScheduler
+ * \brief Implements the SCHED SAP and CSCHED SAP for a Token Bank Fair Queue scheduler
+ *
+ * This class implements the interface defined by the FfMacScheduler abstract class
+ */
+
+class FdTbfqFfMacScheduler : public FfMacScheduler
+{
+public:
+ /**
+ * \brief Constructor
+ *
+ * Creates the MAC Scheduler interface implementation
+ */
+ FdTbfqFfMacScheduler ();
+
+ /**
+ * Destructor
+ */
+ virtual ~FdTbfqFfMacScheduler ();
+
+ // inherited from Object
+ virtual void DoDispose (void);
+ static TypeId GetTypeId (void);
+
+ // inherited from FfMacScheduler
+ virtual void SetFfMacCschedSapUser (FfMacCschedSapUser* s);
+ virtual void SetFfMacSchedSapUser (FfMacSchedSapUser* s);
+ virtual FfMacCschedSapProvider* GetFfMacCschedSapProvider ();
+ virtual FfMacSchedSapProvider* GetFfMacSchedSapProvider ();
+
+ friend class FdTbfqSchedulerMemberCschedSapProvider;
+ friend class FdTbfqSchedulerMemberSchedSapProvider;
+
+ void TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode);
+
+private:
+ //
+ // Implementation of the CSCHED API primitives
+ // (See 4.1 for description of the primitives)
+ //
+
+ void DoCschedCellConfigReq (const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params);
+
+ void DoCschedUeConfigReq (const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params);
+
+ void DoCschedLcConfigReq (const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params);
+
+ void DoCschedLcReleaseReq (const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params);
+
+ void DoCschedUeReleaseReq (const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params);
+
+ //
+ // Implementation of the SCHED API primitives
+ // (See 4.2 for description of the primitives)
+ //
+
+ void DoSchedDlRlcBufferReq (const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params);
+
+ void DoSchedDlPagingBufferReq (const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params);
+
+ void DoSchedDlMacBufferReq (const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params);
+
+ void DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params);
+
+ void DoSchedDlRachInfoReq (const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params);
+
+ void DoSchedDlCqiInfoReq (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params);
+
+ void DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params);
+
+ void DoSchedUlNoiseInterferenceReq (const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params);
+
+ void DoSchedUlSrInfoReq (const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params);
+
+ void DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params);
+
+ void DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params);
+
+
+ int GetRbgSize (int dlbandwidth);
+
+ int LcActivePerFlow (uint16_t rnti);
+
+ double EstimateUlSinr (uint16_t rnti, uint16_t rb);
+
+ void RefreshDlCqiMaps(void);
+ void RefreshUlCqiMaps(void);
+
+ void UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size);
+ void UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size);
+ Ptr<LteAmc> m_amc;
+
+ /*
+ * Vectors of UE's LC info
+ */
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> m_rlcBufferReq;
+
+
+ /*
+ * Map of UE statistics (per RNTI basis) in downlink
+ */
+ std::map <uint16_t, fdtbfqsFlowPerf_t> m_flowStatsDl;
+
+ /*
+ * Map of UE statistics (per RNTI basis)
+ */
+ std::map <uint16_t, fdtbfqsFlowPerf_t> m_flowStatsUl;
+
+
+ /*
+ * Map of UE's DL CQI P01 received
+ */
+ std::map <uint16_t,uint8_t> m_p10CqiRxed;
+ /*
+ * Map of UE's timers on DL CQI P01 received
+ */
+ std::map <uint16_t,uint32_t> m_p10CqiTimers;
+
+ /*
+ * Map of UE's DL CQI A30 received
+ */
+ std::map <uint16_t,SbMeasResult_s> m_a30CqiRxed;
+ /*
+ * Map of UE's timers on DL CQI A30 received
+ */
+ std::map <uint16_t,uint32_t> m_a30CqiTimers;
+
+ /*
+ * Map of previous allocated UE per RBG
+ * (used to retrieve info from UL-CQI)
+ */
+ std::map <uint16_t, std::vector <uint16_t> > m_allocationMaps;
+
+ /*
+ * Map of UEs' UL-CQI per RBG
+ */
+ std::map <uint16_t, std::vector <double> > m_ueCqi;
+ /*
+ * Map of UEs' timers on UL-CQI per RBG
+ */
+ std::map <uint16_t, uint32_t> m_ueCqiTimers;
+
+ /*
+ * Map of UE's buffer status reports received
+ */
+ std::map <uint16_t,uint32_t> m_ceBsrRxed;
+
+ // MAC SAPs
+ FfMacCschedSapUser* m_cschedSapUser;
+ FfMacSchedSapUser* m_schedSapUser;
+ FfMacCschedSapProvider* m_cschedSapProvider;
+ FfMacSchedSapProvider* m_schedSapProvider;
+
+ // Internal parameters
+ FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig;
+
+ uint16_t m_nextRntiUl; // RNTI of the next user to be served next scheduling in UL
+
+ uint32_t m_cqiTimersThreshold; // # of TTIs for which a CQI canbe considered valid
+
+ std::map <uint16_t,uint8_t> m_uesTxMode; // txMode of the UEs
+
+ uint64_t bankSize; // the number of bytes in token bank
+};
+
+} // namespace ns3
+
+#endif /* FDTBFQ_FF_MAC_SCHEDULER_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/tdtbfq-ff-mac-scheduler.cc Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,1267 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#ifdef __FreeBSD__
+#define log2(x) (log(x) / M_LN2)
+#endif /* __FreeBSD__ */
+
+#include <ns3/log.h>
+#include <ns3/pointer.h>
+
+#include <ns3/simulator.h>
+#include <ns3/lte-amc.h>
+#include <ns3/tdtbfq-ff-mac-scheduler.h>
+
+NS_LOG_COMPONENT_DEFINE ("TdTbfqFfMacScheduler");
+
+namespace ns3 {
+
+int TdTbfqType0AllocationRbg[4] = {
+ 10, // RGB size 1
+ 26, // RGB size 2
+ 63, // RGB size 3
+ 110 // RGB size 4
+}; // see table 7.1.6.1-1 of 36.213
+
+
+NS_OBJECT_ENSURE_REGISTERED (TdTbfqFfMacScheduler);
+
+
+
+class TdTbfqSchedulerMemberCschedSapProvider : public FfMacCschedSapProvider
+{
+public:
+ TdTbfqSchedulerMemberCschedSapProvider (TdTbfqFfMacScheduler* scheduler);
+
+ // inherited from FfMacCschedSapProvider
+ virtual void CschedCellConfigReq (const struct CschedCellConfigReqParameters& params);
+ virtual void CschedUeConfigReq (const struct CschedUeConfigReqParameters& params);
+ virtual void CschedLcConfigReq (const struct CschedLcConfigReqParameters& params);
+ virtual void CschedLcReleaseReq (const struct CschedLcReleaseReqParameters& params);
+ virtual void CschedUeReleaseReq (const struct CschedUeReleaseReqParameters& params);
+
+private:
+ TdTbfqSchedulerMemberCschedSapProvider ();
+ TdTbfqFfMacScheduler* m_scheduler;
+};
+
+TdTbfqSchedulerMemberCschedSapProvider::TdTbfqSchedulerMemberCschedSapProvider ()
+{
+}
+
+TdTbfqSchedulerMemberCschedSapProvider::TdTbfqSchedulerMemberCschedSapProvider (TdTbfqFfMacScheduler* scheduler) : m_scheduler (scheduler)
+{
+}
+
+
+void
+TdTbfqSchedulerMemberCschedSapProvider::CschedCellConfigReq (const struct CschedCellConfigReqParameters& params)
+{
+ m_scheduler->DoCschedCellConfigReq (params);
+}
+
+void
+TdTbfqSchedulerMemberCschedSapProvider::CschedUeConfigReq (const struct CschedUeConfigReqParameters& params)
+{
+ m_scheduler->DoCschedUeConfigReq (params);
+}
+
+
+void
+TdTbfqSchedulerMemberCschedSapProvider::CschedLcConfigReq (const struct CschedLcConfigReqParameters& params)
+{
+ m_scheduler->DoCschedLcConfigReq (params);
+}
+
+void
+TdTbfqSchedulerMemberCschedSapProvider::CschedLcReleaseReq (const struct CschedLcReleaseReqParameters& params)
+{
+ m_scheduler->DoCschedLcReleaseReq (params);
+}
+
+void
+TdTbfqSchedulerMemberCschedSapProvider::CschedUeReleaseReq (const struct CschedUeReleaseReqParameters& params)
+{
+ m_scheduler->DoCschedUeReleaseReq (params);
+}
+
+
+
+
+class TdTbfqSchedulerMemberSchedSapProvider : public FfMacSchedSapProvider
+{
+public:
+ TdTbfqSchedulerMemberSchedSapProvider (TdTbfqFfMacScheduler* scheduler);
+
+ // inherited from FfMacSchedSapProvider
+ virtual void SchedDlRlcBufferReq (const struct SchedDlRlcBufferReqParameters& params);
+ virtual void SchedDlPagingBufferReq (const struct SchedDlPagingBufferReqParameters& params);
+ virtual void SchedDlMacBufferReq (const struct SchedDlMacBufferReqParameters& params);
+ virtual void SchedDlTriggerReq (const struct SchedDlTriggerReqParameters& params);
+ virtual void SchedDlRachInfoReq (const struct SchedDlRachInfoReqParameters& params);
+ virtual void SchedDlCqiInfoReq (const struct SchedDlCqiInfoReqParameters& params);
+ virtual void SchedUlTriggerReq (const struct SchedUlTriggerReqParameters& params);
+ virtual void SchedUlNoiseInterferenceReq (const struct SchedUlNoiseInterferenceReqParameters& params);
+ virtual void SchedUlSrInfoReq (const struct SchedUlSrInfoReqParameters& params);
+ virtual void SchedUlMacCtrlInfoReq (const struct SchedUlMacCtrlInfoReqParameters& params);
+ virtual void SchedUlCqiInfoReq (const struct SchedUlCqiInfoReqParameters& params);
+
+
+private:
+ TdTbfqSchedulerMemberSchedSapProvider ();
+ TdTbfqFfMacScheduler* m_scheduler;
+};
+
+
+
+TdTbfqSchedulerMemberSchedSapProvider::TdTbfqSchedulerMemberSchedSapProvider ()
+{
+}
+
+
+TdTbfqSchedulerMemberSchedSapProvider::TdTbfqSchedulerMemberSchedSapProvider (TdTbfqFfMacScheduler* scheduler)
+ : m_scheduler (scheduler)
+{
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedDlRlcBufferReq (const struct SchedDlRlcBufferReqParameters& params)
+{
+ m_scheduler->DoSchedDlRlcBufferReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedDlPagingBufferReq (const struct SchedDlPagingBufferReqParameters& params)
+{
+ m_scheduler->DoSchedDlPagingBufferReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedDlMacBufferReq (const struct SchedDlMacBufferReqParameters& params)
+{
+ m_scheduler->DoSchedDlMacBufferReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedDlTriggerReq (const struct SchedDlTriggerReqParameters& params)
+{
+ m_scheduler->DoSchedDlTriggerReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedDlRachInfoReq (const struct SchedDlRachInfoReqParameters& params)
+{
+ m_scheduler->DoSchedDlRachInfoReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedDlCqiInfoReq (const struct SchedDlCqiInfoReqParameters& params)
+{
+ m_scheduler->DoSchedDlCqiInfoReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedUlTriggerReq (const struct SchedUlTriggerReqParameters& params)
+{
+ m_scheduler->DoSchedUlTriggerReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedUlNoiseInterferenceReq (const struct SchedUlNoiseInterferenceReqParameters& params)
+{
+ m_scheduler->DoSchedUlNoiseInterferenceReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedUlSrInfoReq (const struct SchedUlSrInfoReqParameters& params)
+{
+ m_scheduler->DoSchedUlSrInfoReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedUlMacCtrlInfoReq (const struct SchedUlMacCtrlInfoReqParameters& params)
+{
+ m_scheduler->DoSchedUlMacCtrlInfoReq (params);
+}
+
+void
+TdTbfqSchedulerMemberSchedSapProvider::SchedUlCqiInfoReq (const struct SchedUlCqiInfoReqParameters& params)
+{
+ m_scheduler->DoSchedUlCqiInfoReq (params);
+}
+
+
+
+
+
+TdTbfqFfMacScheduler::TdTbfqFfMacScheduler ()
+ : m_cschedSapUser (0),
+ m_schedSapUser (0),
+ m_nextRntiUl (0),
+ bankSize(0)
+{
+ m_amc = CreateObject <LteAmc> ();
+ m_cschedSapProvider = new TdTbfqSchedulerMemberCschedSapProvider (this);
+ m_schedSapProvider = new TdTbfqSchedulerMemberSchedSapProvider (this);
+}
+
+TdTbfqFfMacScheduler::~TdTbfqFfMacScheduler ()
+{
+ NS_LOG_FUNCTION (this);
+}
+
+void
+TdTbfqFfMacScheduler::DoDispose ()
+{
+ NS_LOG_FUNCTION (this);
+ delete m_cschedSapProvider;
+ delete m_schedSapProvider;
+}
+
+TypeId
+TdTbfqFfMacScheduler::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("ns3::TdTbfqFfMacScheduler")
+ .SetParent<FfMacScheduler> ()
+ .AddConstructor<TdTbfqFfMacScheduler> ()
+ .AddAttribute ("CqiTimerThreshold",
+ "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
+ UintegerValue (1000),
+ MakeUintegerAccessor (&TdTbfqFfMacScheduler::m_cqiTimersThreshold),
+ MakeUintegerChecker<uint32_t> ())
+ ;
+ return tid;
+}
+
+
+
+void
+TdTbfqFfMacScheduler::SetFfMacCschedSapUser (FfMacCschedSapUser* s)
+{
+ m_cschedSapUser = s;
+}
+
+void
+TdTbfqFfMacScheduler::SetFfMacSchedSapUser (FfMacSchedSapUser* s)
+{
+ m_schedSapUser = s;
+}
+
+FfMacCschedSapProvider*
+TdTbfqFfMacScheduler::GetFfMacCschedSapProvider ()
+{
+ return m_cschedSapProvider;
+}
+
+FfMacSchedSapProvider*
+TdTbfqFfMacScheduler::GetFfMacSchedSapProvider ()
+{
+ return m_schedSapProvider;
+}
+
+void
+TdTbfqFfMacScheduler::DoCschedCellConfigReq (const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // Read the subset of parameters used
+ m_cschedCellConfig = params;
+ FfMacCschedSapUser::CschedUeConfigCnfParameters cnf;
+ cnf.m_result = SUCCESS;
+ m_cschedSapUser->CschedUeConfigCnf (cnf);
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoCschedUeConfigReq (const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " RNTI " << params.m_rnti << " txMode " << (uint16_t)params.m_transmissionMode);
+ std::map <uint16_t,uint8_t>::iterator it = m_uesTxMode.find (params.m_rnti);
+ if (it==m_uesTxMode.end ())
+ {
+ m_uesTxMode.insert (std::pair <uint16_t, double> (params.m_rnti, params.m_transmissionMode));
+ }
+ else
+ {
+ (*it).second = params.m_transmissionMode;
+ }
+ return;
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoCschedLcConfigReq (const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " New LC, rnti: " << params.m_rnti);
+
+ std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
+ for (uint16_t i = 0; i < params.m_logicalChannelConfigList.size (); i++)
+ {
+ it = m_flowStatsDl.find (params.m_rnti);
+
+ if (it == m_flowStatsDl.end ())
+ {
+ // add rlc and pdcp header size in MBR
+ uint64_t mbrDlInBytes = params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateDl / 8; // byte/s
+ uint64_t mbrUlInBytes = params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateUl / 8; // byte/s
+
+ tdtbfqsFlowPerf_t flowStatsDl;
+ flowStatsDl.flowStart = Simulator::Now ();
+ flowStatsDl.packetArrivalRate = 0;
+ flowStatsDl.tokenGenerationRate = mbrDlInBytes;
+ flowStatsDl.tokenPoolSize = 0;
+ flowStatsDl.maxTokenPoolSize = 1;
+ flowStatsDl.counter = 0;
+ flowStatsDl.burstCredit = 625000; // bytes
+ flowStatsDl.debtLimit = -625000; // bytes
+ flowStatsDl.creditableThreshold = 0;
+ m_flowStatsDl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.m_rnti, flowStatsDl));
+ tdtbfqsFlowPerf_t flowStatsUl;
+ flowStatsUl.flowStart = Simulator::Now ();
+ flowStatsUl.packetArrivalRate = 0;
+ flowStatsUl.tokenGenerationRate = mbrUlInBytes;
+ flowStatsUl.tokenPoolSize = 0;
+ flowStatsUl.maxTokenPoolSize = 1;
+ flowStatsUl.counter = 0;
+ flowStatsUl.burstCredit = 625000; // bytes
+ flowStatsUl.debtLimit = -625000; // bytes
+ flowStatsUl.creditableThreshold = 0;
+ m_flowStatsUl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.m_rnti, flowStatsUl));
+
+ NS_LOG_DEBUG(" UE "<<params.m_rnti<<" MaximulBitrateDl "<<params.m_logicalChannelConfigList.at(i).m_eRabMaximulBitrateDl << " gbrDlInbytes "<<mbrDlInBytes);
+ }
+ else
+ {
+ NS_LOG_ERROR ("RNTI already exists");
+ }
+ }
+
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoCschedLcReleaseReq (const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoCschedUeReleaseReq (const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+
+void
+TdTbfqFfMacScheduler::DoSchedDlRlcBufferReq (const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity);
+ // API generated by RLC for updating RLC parameters on a LC (tx and retx queues)
+
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
+
+ LteFlowId_t flow (params.m_rnti, params.m_logicalChannelIdentity);
+
+ it = m_rlcBufferReq.find (flow);
+
+ if (it == m_rlcBufferReq.end ())
+ {
+ m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
+ }
+ else
+ {
+ (*it).second = params;
+ }
+
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedDlPagingBufferReq (const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedDlMacBufferReq (const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+int
+TdTbfqFfMacScheduler::GetRbgSize (int dlbandwidth)
+{
+ for (int i = 0; i < 4; i++)
+ {
+ if (dlbandwidth < TdTbfqType0AllocationRbg[i])
+ {
+ return (i + 1);
+ }
+ }
+
+ return (-1);
+}
+
+
+int
+TdTbfqFfMacScheduler::LcActivePerFlow (uint16_t rnti)
+{
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
+ int lcActive = 0;
+ for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
+ {
+ if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
+ || ((*it).second.m_rlcRetransmissionQueueSize > 0)
+ || ((*it).second.m_rlcStatusPduSize > 0) ))
+ {
+ lcActive++;
+ }
+ if ((*it).first.m_rnti > rnti)
+ {
+ break;
+ }
+ }
+ return (lcActive);
+
+}
+
+
+void
+TdTbfqFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
+ // API generated by RLC for triggering the scheduling of a DL subframe
+
+
+ // evaluate the relative channel quality indicator for each UE per each RBG
+ // (since we are using allocation type 0 the small unit of allocation is RBG)
+ // Resource allocation type 0 (see sec 7.1.6.1 of 36.213)
+ RefreshDlCqiMaps ();
+
+ // update token pool, counter and bank size
+ std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
+ for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
+ {
+ if ( (*itStats).second.tokenGenerationRate/1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
+ {
+ (*itStats).second.counter += (*itStats).second.tokenGenerationRate/1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
+ (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
+ bankSize += (*itStats).second.tokenGenerationRate/1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
+ }
+ else
+ {
+ (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate/1000;
+ }
+ }
+
+ int rbgSize = GetRbgSize (m_cschedCellConfig.m_dlBandwidth);
+ int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
+ std::map <uint16_t, std::vector <uint16_t> > allocationMap;
+
+ // select UE with largest metric
+ std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
+ std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itMax = m_flowStatsDl.end ();
+ double metricMax;
+ bool firstRnti = true;
+ for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it++)
+ {
+ if (LcActivePerFlow ((*it).first) == 0)
+ {
+ continue;
+ }
+
+ double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
+
+ if (firstRnti == true)
+ {
+ metricMax = metric;
+ itMax = it;
+ firstRnti = false;
+ continue;
+ }
+ if (metric > metricMax)
+ {
+ metricMax = metric;
+ itMax = it;
+ }
+ } // end for m_flowStatsDl
+
+ if (itMax == m_flowStatsDl.end())
+ {
+ // no UE available for downlink
+ return;
+ }
+ else
+ {
+ // assign all RBGs to this UE
+ std::vector <uint16_t> tempMap;
+ for (int i = 0; i < rbgNum; i++)
+ {
+ tempMap.push_back (i);
+ }
+ allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
+ }
+
+ // generate the transmission opportunities by grouping the RBGs of the same RNTI and
+ // creating the correspondent DCIs
+ FfMacSchedSapUser::SchedDlConfigIndParameters ret;
+ std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
+
+ while (itMap != allocationMap.end ())
+ {
+ // create new BuildDataListElement_s for this LC
+ BuildDataListElement_s newEl;
+ newEl.m_rnti = (*itMap).first;
+ // create the DlDciListElement_s
+ DlDciListElement_s newDci;
+ std::vector <struct RlcPduListElement_s> newRlcPduLe;
+ newDci.m_rnti = (*itMap).first;
+
+ uint16_t lcActives = LcActivePerFlow ((*itMap).first);
+// NS_LOG_DEBUG (this << "Allocate user " << newEl.m_rnti << " rbg " << lcActives);
+ uint16_t RgbPerRnti = (*itMap).second.size ();
+ std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
+ itCqi = m_a30CqiRxed.find ((*itMap).first);
+ std::map <uint16_t,uint8_t>::iterator itTxMode;
+ itTxMode = m_uesTxMode.find ((*itMap).first);
+ if (itTxMode == m_uesTxMode.end())
+ {
+ NS_FATAL_ERROR ("No Transmission Mode info on user " << (*itMap).first);
+ }
+ int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
+ std::vector <uint8_t> worstCqi (2, 15);
+ if (itCqi != m_a30CqiRxed.end ())
+ {
+ for (uint16_t k = 0; k < (*itMap).second.size (); k++)
+ {
+ if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
+ {
+ //NS_LOG_DEBUG (this << " RBG " << (*itMap).second.at (k) << " CQI " << (uint16_t)((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (0)) );
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size ()> j)
+ {
+ if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
+ {
+ worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
+ }
+ }
+ else
+ {
+ // no CQI for this layer of this suband -> worst one
+ worstCqi.at (j) = 1;
+ }
+ //NS_LOG_DEBUG (this << " RBG " << (*itMap).second.at (k) << " CQI " <<(uint16_t)j <<" "<< (uint16_t)worstCqi.at(j));
+ }
+ }
+ else
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
+ }
+ }
+ }
+ }
+ else
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ worstCqi.at (j) = 1; // try with lowest MCS in RBG with no info on channel
+ }
+ }
+// NS_LOG_DEBUG (this << " CQI " << (uint16_t)worstCqi);
+ uint32_t bytesTxed = 0;
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ newDci.m_mcs.push_back (m_amc->GetMcsFromCqi (worstCqi.at (j)));
+ int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (j), RgbPerRnti * rbgSize) / 8); // (size of TB in bytes according to table 7.1.7.2.1-1 of 36.213)
+ // NS_LOG_DEBUG ( Simulator::Now() << " Allocateuser " << newEl.m_rnti << " tbSize "<< tbSize << " RBG " << RgbPerRnti << " mcs " << (uint16_t) newDci.m_mcs.at (j) << " cqi " << (uint16_t)worstCqi.at(j));
+ newDci.m_tbsSize.push_back (tbSize);
+ bytesTxed += tbSize;
+ //NS_LOG_DEBUG (this << " MCS " << m_amc->GetMcsFromCqi (worstCqi.at (j)));
+ }
+
+ newDci.m_resAlloc = 0; // only allocation type 0 at this stage
+ newDci.m_rbBitmap = 0; // TBD (32 bit bitmap see 7.1.6 of 36.213)
+ uint32_t rbgMask = 0;
+ //for (uint16_t k = 0; k < (*itMap).second.size (); k++)
+ for (uint16_t k = 0; k < RgbPerRnti; k++)
+ {
+ rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
+// NS_LOG_DEBUG (this << " Allocated PRB " << (*itMap).second.at (k));
+ }
+ newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213)
+
+ // create the rlc PDUs -> equally divide resources among actives LCs
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
+ for (itBufReq = m_rlcBufferReq.begin (); itBufReq != m_rlcBufferReq.end (); itBufReq++)
+ {
+ if (((*itBufReq).first.m_rnti == (*itMap).first) &&
+ (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
+ || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
+ || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
+ {
+ for (uint8_t j = 0; j < nLayer; j++)
+ {
+ RlcPduListElement_s newRlcEl;
+ newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
+ newRlcEl.m_size = newDci.m_tbsSize.at (j) / lcActives;
+ //NS_LOG_DEBUG ( Simulator::Now() << " LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity << " size " << newRlcEl.m_size << " layer " << (uint16_t)j);
+
+ newRlcPduLe.push_back (newRlcEl);
+ UpdateDlRlcBufferInfo (newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size);
+ }
+ }
+ if ((*itBufReq).first.m_rnti > (*itMap).first)
+ {
+ break;
+ }
+ }
+ newDci.m_ndi.push_back (1); // TBD (new data indicator)
+ newDci.m_rv.push_back (0); // TBD (redundancy version)
+
+ newEl.m_dci = newDci;
+ // ...more parameters -> ingored in this version
+
+ newEl.m_rlcPduList.push_back (newRlcPduLe);
+ ret.m_buildDataList.push_back (newEl);
+
+ // update UE stats
+ std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
+ it = m_flowStatsDl.find ((*itMap).first);
+ if (it != m_flowStatsDl.end ())
+ {
+ if ( bytesTxed <= (*it).second.tokenPoolSize )
+ {
+ (*it).second.tokenPoolSize -= bytesTxed;
+ }
+ else
+ {
+ (*it).second.counter = (*it).second.counter - ( bytesTxed - (*it).second.tokenPoolSize );
+ (*it).second.tokenPoolSize = 0;
+ if (bankSize <= ( bytesTxed - (*it).second.tokenPoolSize ))
+ bankSize = 0;
+ else
+ bankSize = bankSize - ( bytesTxed - (*it).second.tokenPoolSize );
+ }
+ }
+ else
+ {
+ NS_LOG_DEBUG (this << " No Stats for this allocated UE");
+ }
+
+ //NS_LOG_DEBUG (Simulator::Now() << " After UE " << (*it).first << " counter " << (*it).second.counter << " bank " << bankSize);
+
+ itMap++;
+ } // end while allocation
+ ret.m_nrOfPdcchOfdmSymbols = 1; // TODO: check correct value according the DCIs txed
+
+
+ // update UEs stats
+ /*for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
+ {
+ (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted;
+ // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term Evolution, Ed Wiley)
+ (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 / m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 / m_timeWindow) * (double)((*itStats).second.lastTtiBytesTrasmitted / 0.001));
+// NS_LOG_DEBUG (this << " UE tot bytes " << (*itStats).second.totalBytesTransmitted);
+// NS_LOG_DEBUG (this << " UE avg thr " << (*itStats).second.lastAveragedThroughput);
+ (*itStats).second.lastTtiBytesTrasmitted = 0;
+ }*/
+
+ m_schedSapUser->SchedDlConfigInd (ret);
+
+
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedDlRachInfoReq (const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedDlCqiInfoReq (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+
+ for (unsigned int i = 0; i < params.m_cqiList.size (); i++)
+ {
+ if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
+ {
+ // wideband CQI reporting
+ std::map <uint16_t,uint8_t>::iterator it;
+ uint16_t rnti = params.m_cqiList.at (i).m_rnti;
+ it = m_p10CqiRxed.find (rnti);
+ if (it == m_p10CqiRxed.end ())
+ {
+ // create the new entry
+ m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.m_cqiList.at (i).m_wbCqi.at (0)) ); // only codeword 0 at this stage (SISO)
+ // generate correspondent timer
+ m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
+ }
+ else
+ {
+ // update the CQI value and refresh correspondent timer
+ (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
+ // update correspondent timer
+ std::map <uint16_t,uint32_t>::iterator itTimers;
+ itTimers = m_p10CqiTimers.find (rnti);
+ (*itTimers).second = m_cqiTimersThreshold;
+ }
+ }
+ else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
+ {
+ // subband CQI reporting high layer configured
+ std::map <uint16_t,SbMeasResult_s>::iterator it;
+ uint16_t rnti = params.m_cqiList.at (i).m_rnti;
+ it = m_a30CqiRxed.find (rnti);
+ if (it == m_a30CqiRxed.end ())
+ {
+ // create the new entry
+ m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.m_cqiList.at (i).m_sbMeasResult) );
+ m_a30CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
+ }
+ else
+ {
+ // update the CQI value and refresh correspondent timer
+ (*it).second = params.m_cqiList.at (i).m_sbMeasResult;
+ std::map <uint16_t,uint32_t>::iterator itTimers;
+ itTimers = m_a30CqiTimers.find (rnti);
+ (*itTimers).second = m_cqiTimersThreshold;
+ }
+ }
+ else
+ {
+ NS_LOG_ERROR (this << " CQI type unknown");
+ }
+ }
+
+ return;
+}
+
+
+double
+TdTbfqFfMacScheduler::EstimateUlSinr (uint16_t rnti, uint16_t rb)
+{
+ std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find (rnti);
+ if (itCqi == m_ueCqi.end ())
+ {
+ // no cqi info about this UE
+ return (NO_SINR);
+
+ }
+ else
+ {
+ // take the average SINR value among the available
+ double sinrSum = 0;
+ int sinrNum = 0;
+ for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
+ {
+ double sinr = (*itCqi).second.at (i);
+ if (sinr != NO_SINR)
+ {
+ sinrSum += sinr;
+ sinrNum++;
+ }
+ }
+ double estimatedSinr = sinrSum / (double)sinrNum;
+ // store the value
+ (*itCqi).second.at (rb) = estimatedSinr;
+ return (estimatedSinr);
+ }
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
+{
+ NS_LOG_FUNCTION (this << " UL - Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
+
+ RefreshUlCqiMaps ();
+
+ std::map <uint16_t,uint32_t>::iterator it;
+ int nflows = 0;
+
+ for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
+ {
+ // remove old entries of this UE-LC
+ if ((*it).second > 0)
+ {
+ nflows++;
+ }
+ }
+
+ if (nflows == 0)
+ {
+ return ; // no flows to be scheduled
+ }
+
+
+ // Divide the resource equally among the active users
+ int rbPerFlow = m_cschedCellConfig.m_ulBandwidth / nflows;
+ if (rbPerFlow == 0)
+ {
+ rbPerFlow = 1; // at least 1 rbg per flow (till available resource)
+ }
+ int rbAllocated = 0;
+
+ FfMacSchedSapUser::SchedUlConfigIndParameters ret;
+ std::vector <uint16_t> rbgAllocationMap;
+ //std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
+ if (m_nextRntiUl != 0)
+ {
+ for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
+ {
+ if ((*it).first == m_nextRntiUl)
+ {
+ break;
+ }
+ }
+ if (it == m_ceBsrRxed.end ())
+ {
+ NS_LOG_ERROR (this << " no user found");
+ }
+ }
+ else
+ {
+ it = m_ceBsrRxed.begin ();
+ m_nextRntiUl = (*it).first;
+ }
+ do
+ {
+ if (rbAllocated + rbPerFlow > m_cschedCellConfig.m_ulBandwidth)
+ {
+ // limit to physical resources last resource assignment
+ rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
+ }
+
+ UlDciListElement_s uldci;
+ uldci.m_rnti = (*it).first;
+ uldci.m_rbStart = rbAllocated;
+ uldci.m_rbLen = rbPerFlow;
+ std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
+ int cqi = 0;
+ if (itCqi == m_ueCqi.end ())
+ {
+ // no cqi info about this UE
+ uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD
+// NS_LOG_DEBUG (this << " UE does not have ULCQI " << (*it).first );
+ }
+ else
+ {
+ // take the lowest CQI value (worst RB)
+ double minSinr = (*itCqi).second.at (uldci.m_rbStart);
+ if (minSinr == NO_SINR)
+ {
+ minSinr = EstimateUlSinr ((*it).first, uldci.m_rbStart);
+ }
+ for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
+ {
+// NS_LOG_DEBUG (this << " UE " << (*it).first << " has SINR " << (*itCqi).second.at(i));
+ double sinr = (*itCqi).second.at (i);
+ if (sinr == NO_SINR)
+ {
+ sinr = EstimateUlSinr ((*it).first, i);
+ }
+ if ((*itCqi).second.at (i) < minSinr)
+ {
+ minSinr = (*itCqi).second.at (i);
+ }
+ }
+
+ // translate SINR -> cqi: WILD ACK: same as DL
+ double s = log2 ( 1 + (
+ pow (10, minSinr / 10 ) /
+ ( (-log (5.0 * 0.00005 )) / 1.5) ));
+ cqi = m_amc->GetCqiFromSpectralEfficiency (s);
+ if (cqi == 0)
+ {
+ it++;
+ if (it == m_ceBsrRxed.end ())
+ {
+ // restart from the first
+ it = m_ceBsrRxed.begin ();
+ }
+ continue; // CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
+ }
+ uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
+// NS_LOG_DEBUG (this << " UE " << (*it).first << " minsinr " << minSinr << " -> mcs " << (uint16_t)uldci.m_mcs);
+
+ }
+
+ rbAllocated += rbPerFlow;
+ // store info on allocation for managing ul-cqi interpretation
+ for (int i = 0; i < rbPerFlow; i++)
+ {
+ rbgAllocationMap.push_back ((*it).first);
+ }
+ uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
+ NS_LOG_DEBUG (this <<" "<<Simulator::Now()<< " UE " << (*it).first << " startPRB " << (uint32_t)uldci.m_rbStart << " nPRB " << (uint32_t)uldci.m_rbLen << " CQI " << cqi << " MCS " << (uint32_t)uldci.m_mcs << " TBsize " << uldci.m_tbSize << " RbAlloc " << rbAllocated);
+ UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
+ uldci.m_ndi = 1;
+ uldci.m_cceIndex = 0;
+ uldci.m_aggrLevel = 1;
+ uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF
+ uldci.m_hopping = false;
+ uldci.m_n2Dmrs = 0;
+ uldci.m_tpc = 0; // no power control
+ uldci.m_cqiRequest = false; // only period CQI at this stage
+ uldci.m_ulIndex = 0; // TDD parameter
+ uldci.m_dai = 1; // TDD parameter
+ uldci.m_freqHopping = 0;
+ uldci.m_pdcchPowerOffset = 0; // not used
+ ret.m_dciList.push_back (uldci);
+
+ // update TTI UE stats
+ /*itStats = m_flowStatsUl.find ((*it).first);
+ if (itStats != m_flowStatsUl.end ())
+ {
+ (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize;
+// NS_LOG_DEBUG (this << " UE bytes txed " << (*it).second.lastTtiBytesTrasmitted);
+
+
+ }
+ else
+ {
+ NS_LOG_DEBUG (this << " No Stats for this allocated UE");
+ }*/
+
+
+ it++;
+ if (it == m_ceBsrRxed.end ())
+ {
+ // restart from the first
+ it = m_ceBsrRxed.begin ();
+ }
+ if (rbAllocated == m_cschedCellConfig.m_ulBandwidth)
+ {
+ // Stop allocation: no more PRBs
+ m_nextRntiUl = (*it).first;
+ break;
+ }
+ }
+ while ((*it).first != m_nextRntiUl);
+
+
+ // Update global UE stats
+ // update UEs stats
+ /*for (itStats = m_flowStatsUl.begin (); itStats != m_flowStatsUl.end (); itStats++)
+ {
+ (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted;
+ // update average throughput (see eq. 12.3 of Sec 12.3.1.2 of LTE – The UMTS Long Term Evolution, Ed Wiley)
+ (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 / m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 / m_timeWindow) * (double)((*itStats).second.lastTtiBytesTrasmitted / 0.001));
+ // NS_LOG_DEBUG (this << " UE tot bytes " << (*itStats).second.totalBytesTransmitted);
+ // NS_LOG_DEBUG (this << " UE avg thr " << (*itStats).second.lastAveragedThroughput);
+ (*itStats).second.lastTtiBytesTrasmitted = 0;
+ }*/
+ m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
+ m_schedSapUser->SchedUlConfigInd (ret);
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedUlNoiseInterferenceReq (const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedUlSrInfoReq (const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+ // TODO: Implementation of the API
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+
+ std::map <uint16_t,uint32_t>::iterator it;
+
+ for (unsigned int i = 0; i < params.m_macCeList.size (); i++)
+ {
+ if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
+ {
+ // buffer status report
+ uint16_t rnti = params.m_macCeList.at (i).m_rnti;
+ it = m_ceBsrRxed.find (rnti);
+ if (it == m_ceBsrRxed.end ())
+ {
+ // create the new entry
+ uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0);
+ int buffer = BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
+ m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer)); // only 1 buffer status is working now
+ }
+ else
+ {
+ // update the CQI value
+ (*it).second = BufferSizeLevelBsr::BsrId2BufferSize (params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0));
+ }
+ }
+ }
+
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params)
+{
+ NS_LOG_FUNCTION (this);
+// NS_LOG_DEBUG (this << " RX SFNID " << params.m_sfnSf);
+ // retrieve the allocation for this subframe
+ std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
+ std::map <uint16_t, std::vector <double> >::iterator itCqi;
+ itMap = m_allocationMaps.find (params.m_sfnSf);
+ if (itMap == m_allocationMaps.end ())
+ {
+ //NS_LOG_DEBUG (this << " Does not find info on allocation, size : " << m_allocationMaps.size ());
+ return;
+ }
+ for (uint32_t i = 0; i < (*itMap).second.size (); i++)
+ {
+ // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
+// NS_LOG_INFO (this << " i " << i << " size " << params.m_ulCqi.m_sinr.size () << " mapSIze " << (*itMap).second.size ());
+ double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
+ //NS_LOG_DEBUG (this << " UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr);
+ itCqi = m_ueCqi.find ((*itMap).second.at (i));
+ if (itCqi == m_ueCqi.end ())
+ {
+ // create a new entry
+ std::vector <double> newCqi;
+ for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
+ {
+ if (i == j)
+ {
+ newCqi.push_back (sinr);
+ }
+ else
+ {
+ // initialize with NO_SINR value.
+ newCqi.push_back (NO_SINR);
+ }
+
+ }
+ m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
+ // generate correspondent timer
+ m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
+ }
+ else
+ {
+ // update the value
+ (*itCqi).second.at (i) = sinr;
+ // update correspondent timer
+ std::map <uint16_t, uint32_t>::iterator itTimers;
+ itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
+ (*itTimers).second = m_cqiTimersThreshold;
+
+ }
+
+ }
+ // remove obsolete info on allocation
+ m_allocationMaps.erase (itMap);
+
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::RefreshDlCqiMaps(void)
+{
+ // refresh DL CQI P01 Map
+ std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
+ while (itP10!=m_p10CqiTimers.end ())
+ {
+// NS_LOG_INFO (this << " P10-CQI for user " << (*itP10).first << " is " << (uint32_t)(*itP10).second << " thr " << (uint32_t)m_cqiTimersThreshold);
+ if ((*itP10).second == 0)
+ {
+ // delete correspondent entries
+ std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
+ NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (), " Does not find CQI report for user " << (*itP10).first);
+ NS_LOG_INFO (this << " P10-CQI exired for user " << (*itP10).first);
+ m_p10CqiRxed.erase (itMap);
+ std::map <uint16_t,uint32_t>::iterator temp = itP10;
+ itP10++;
+ m_p10CqiTimers.erase (temp);
+ }
+ else
+ {
+ (*itP10).second--;
+ itP10++;
+ }
+ }
+
+ // refresh DL CQI A30 Map
+ std::map <uint16_t,uint32_t>::iterator itA30 = m_a30CqiTimers.begin ();
+ while (itA30!=m_a30CqiTimers.end ())
+ {
+// NS_LOG_INFO (this << " A30-CQI for user " << (*itA30).first << " is " << (uint32_t)(*itA30).second << " thr " << (uint32_t)m_cqiTimersThreshold);
+ if ((*itA30).second == 0)
+ {
+ // delete correspondent entries
+ std::map <uint16_t,SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find ((*itA30).first);
+ NS_ASSERT_MSG (itMap != m_a30CqiRxed.end (), " Does not find CQI report for user " << (*itA30).first);
+ NS_LOG_INFO (this << " A30-CQI exired for user " << (*itA30).first);
+ m_a30CqiRxed.erase (itMap);
+ std::map <uint16_t,uint32_t>::iterator temp = itA30;
+ itA30++;
+ m_a30CqiTimers.erase (temp);
+ }
+ else
+ {
+ (*itA30).second--;
+ itA30++;
+ }
+ }
+
+ return;
+}
+
+
+void
+TdTbfqFfMacScheduler::RefreshUlCqiMaps(void)
+{
+ // refresh UL CQI Map
+ std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
+ while (itUl!=m_ueCqiTimers.end ())
+ {
+// NS_LOG_INFO (this << " UL-CQI for user " << (*itUl).first << " is " << (uint32_t)(*itUl).second << " thr " << (uint32_t)m_cqiTimersThreshold);
+ if ((*itUl).second == 0)
+ {
+ // delete correspondent entries
+ std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
+ NS_ASSERT_MSG (itMap != m_ueCqi.end (), " Does not find CQI report for user " << (*itUl).first);
+ NS_LOG_INFO (this << " UL-CQI exired for user " << (*itUl).first);
+ (*itMap).second.clear ();
+ m_ueCqi.erase (itMap);
+ std::map <uint16_t,uint32_t>::iterator temp = itUl;
+ itUl++;
+ m_ueCqiTimers.erase (temp);
+ }
+ else
+ {
+ (*itUl).second--;
+ itUl++;
+ }
+ }
+
+ return;
+}
+
+void
+TdTbfqFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
+{
+ std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
+ LteFlowId_t flow (rnti, lcid);
+ it = m_rlcBufferReq.find (flow);
+ if (it!=m_rlcBufferReq.end ())
+ {
+ //NS_LOG_DEBUG (this << " UE " << rnti << " LC " << (uint16_t)lcid << " txqueue " << (*it).second.m_rlcTransmissionQueueSize << " retxqueue " << (*it).second.m_rlcRetransmissionQueueSize << " status " << (*it).second.m_rlcStatusPduSize << " decrease " << size);
+ // Update queues: RLC tx order Status, ReTx, Tx
+ // Update status queue
+ if ((*it).second.m_rlcStatusPduSize <= size)
+ {
+ size -= (*it).second.m_rlcStatusPduSize;
+ (*it).second.m_rlcStatusPduSize = 0;
+ }
+ else
+ {
+ (*it).second.m_rlcStatusPduSize -= size;
+ return;
+ }
+ // update retransmission queue
+ if ((*it).second.m_rlcRetransmissionQueueSize <= size)
+ {
+ size -= (*it).second.m_rlcRetransmissionQueueSize;
+ (*it).second.m_rlcRetransmissionQueueSize = 0;
+ }
+ else
+ {
+ (*it).second.m_rlcRetransmissionQueueSize -= size;
+ return;
+ }
+ // update transmission queue
+ if ((*it).second.m_rlcTransmissionQueueSize <= size)
+ {
+ size -= (*it).second.m_rlcTransmissionQueueSize;
+ (*it).second.m_rlcTransmissionQueueSize = 0;
+ }
+ else
+ {
+ (*it).second.m_rlcTransmissionQueueSize -= size;
+ return;
+ }
+ }
+ else
+ {
+ NS_LOG_ERROR (this << " Does not find DL RLC Buffer Report of UE " << rnti);
+ }
+}
+
+void
+TdTbfqFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
+{
+
+
+ std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
+ if (it!=m_ceBsrRxed.end ())
+ {
+// NS_LOG_DEBUG (this << " UE " << rnti << " size " << size << " BSR " << (*it).second);
+ if ((*it).second >= size)
+ {
+ (*it).second -= size;
+ }
+ else
+ {
+ (*it).second = 0;
+ }
+ }
+ else
+ {
+ NS_LOG_ERROR (this << " Does not find BSR report info of UE " << rnti);
+ }
+
+}
+
+void
+TdTbfqFfMacScheduler::TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode)
+{
+ NS_LOG_FUNCTION (this << " RNTI " << rnti << " txMode " << (uint16_t)txMode);
+ FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params;
+ params.m_rnti = rnti;
+ params.m_transmissionMode = txMode;
+ m_cschedSapUser->CschedUeConfigUpdateInd (params);
+}
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/tdtbfq-ff-mac-scheduler.h Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,231 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#ifndef TDTBFQ_FF_MAC_SCHEDULER_H
+#define TDTBFQ_FF_MAC_SCHEDULER_H
+
+#include <ns3/lte-common.h>
+#include <ns3/ff-mac-csched-sap.h>
+#include <ns3/ff-mac-sched-sap.h>
+#include <ns3/ff-mac-scheduler.h>
+#include <vector>
+#include <map>
+#include <set>
+#include <ns3/nstime.h>
+#include <ns3/lte-amc.h>
+
+
+// value for SINR outside the range defined by FF-API, used to indicate that there
+// is no CQI for this element
+#define NO_SINR -5000
+
+namespace ns3 {
+
+
+struct tdtbfqsFlowPerf_t
+{
+ Time flowStart;
+ uint64_t packetArrivalRate; // packet arrival rate( byte/s)
+ uint64_t tokenGenerationRate; // token generation rate ( byte/s )
+ uint32_t tokenPoolSize; // current size of token pool (byte)
+ uint32_t maxTokenPoolSize; // maximum size of token pool (byte)
+ int counter; // the number of token borrow or given to token bank
+ uint32_t burstCredit; // the maximum number of tokens connection i can borrow from the bank each time
+ int debtLimit; // counter threshold that the flow cannot further borrow tokens from bank
+ uint32_t creditableThreshold; // the flow cannot borrow token from bank until the number of token it has deposited to bank reaches this threshold
+};
+
+
+/**
+ * \ingroup ff-api
+ * \defgroup FF-API TdTbfqFfMacScheduler
+ */
+/**
+ * \ingroup TdTbfqFfMacScheduler
+ * \brief Implements the SCHED SAP and CSCHED SAP for a Token Bank Fair Queue scheduler
+ *
+ * This class implements the interface defined by the FfMacScheduler abstract class
+ */
+
+class TdTbfqFfMacScheduler : public FfMacScheduler
+{
+public:
+ /**
+ * \brief Constructor
+ *
+ * Creates the MAC Scheduler interface implementation
+ */
+ TdTbfqFfMacScheduler ();
+
+ /**
+ * Destructor
+ */
+ virtual ~TdTbfqFfMacScheduler ();
+
+ // inherited from Object
+ virtual void DoDispose (void);
+ static TypeId GetTypeId (void);
+
+ // inherited from FfMacScheduler
+ virtual void SetFfMacCschedSapUser (FfMacCschedSapUser* s);
+ virtual void SetFfMacSchedSapUser (FfMacSchedSapUser* s);
+ virtual FfMacCschedSapProvider* GetFfMacCschedSapProvider ();
+ virtual FfMacSchedSapProvider* GetFfMacSchedSapProvider ();
+
+ friend class TdTbfqSchedulerMemberCschedSapProvider;
+ friend class TdTbfqSchedulerMemberSchedSapProvider;
+
+ void TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode);
+
+private:
+ //
+ // Implementation of the CSCHED API primitives
+ // (See 4.1 for description of the primitives)
+ //
+
+ void DoCschedCellConfigReq (const struct FfMacCschedSapProvider::CschedCellConfigReqParameters& params);
+
+ void DoCschedUeConfigReq (const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params);
+
+ void DoCschedLcConfigReq (const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params);
+
+ void DoCschedLcReleaseReq (const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params);
+
+ void DoCschedUeReleaseReq (const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params);
+
+ //
+ // Implementation of the SCHED API primitives
+ // (See 4.2 for description of the primitives)
+ //
+
+ void DoSchedDlRlcBufferReq (const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params);
+
+ void DoSchedDlPagingBufferReq (const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params);
+
+ void DoSchedDlMacBufferReq (const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params);
+
+ void DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params);
+
+ void DoSchedDlRachInfoReq (const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params);
+
+ void DoSchedDlCqiInfoReq (const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params);
+
+ void DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params);
+
+ void DoSchedUlNoiseInterferenceReq (const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params);
+
+ void DoSchedUlSrInfoReq (const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params);
+
+ void DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params);
+
+ void DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params);
+
+
+ int GetRbgSize (int dlbandwidth);
+
+ int LcActivePerFlow (uint16_t rnti);
+
+ double EstimateUlSinr (uint16_t rnti, uint16_t rb);
+
+ void RefreshDlCqiMaps(void);
+ void RefreshUlCqiMaps(void);
+
+ void UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size);
+ void UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size);
+ Ptr<LteAmc> m_amc;
+
+ /*
+ * Vectors of UE's LC info
+ */
+ std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> m_rlcBufferReq;
+
+
+ /*
+ * Map of UE statistics (per RNTI basis) in downlink
+ */
+ std::map <uint16_t, tdtbfqsFlowPerf_t> m_flowStatsDl;
+
+ /*
+ * Map of UE statistics (per RNTI basis)
+ */
+ std::map <uint16_t, tdtbfqsFlowPerf_t> m_flowStatsUl;
+
+
+ /*
+ * Map of UE's DL CQI P01 received
+ */
+ std::map <uint16_t,uint8_t> m_p10CqiRxed;
+ /*
+ * Map of UE's timers on DL CQI P01 received
+ */
+ std::map <uint16_t,uint32_t> m_p10CqiTimers;
+
+ /*
+ * Map of UE's DL CQI A30 received
+ */
+ std::map <uint16_t,SbMeasResult_s> m_a30CqiRxed;
+ /*
+ * Map of UE's timers on DL CQI A30 received
+ */
+ std::map <uint16_t,uint32_t> m_a30CqiTimers;
+
+ /*
+ * Map of previous allocated UE per RBG
+ * (used to retrieve info from UL-CQI)
+ */
+ std::map <uint16_t, std::vector <uint16_t> > m_allocationMaps;
+
+ /*
+ * Map of UEs' UL-CQI per RBG
+ */
+ std::map <uint16_t, std::vector <double> > m_ueCqi;
+ /*
+ * Map of UEs' timers on UL-CQI per RBG
+ */
+ std::map <uint16_t, uint32_t> m_ueCqiTimers;
+
+ /*
+ * Map of UE's buffer status reports received
+ */
+ std::map <uint16_t,uint32_t> m_ceBsrRxed;
+
+ // MAC SAPs
+ FfMacCschedSapUser* m_cschedSapUser;
+ FfMacSchedSapUser* m_schedSapUser;
+ FfMacCschedSapProvider* m_cschedSapProvider;
+ FfMacSchedSapProvider* m_schedSapProvider;
+
+
+ // Internal parameters
+ FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig;
+
+ uint16_t m_nextRntiUl; // RNTI of the next user to be served next scheduling in UL
+
+ uint32_t m_cqiTimersThreshold; // # of TTIs for which a CQI canbe considered valid
+
+ std::map <uint16_t,uint8_t> m_uesTxMode; // txMode of the UEs
+
+ uint64_t bankSize; // the number of bytes in token bank
+};
+
+} // namespace ns3
+
+#endif /* TDTBFQ_FF_MAC_SCHEDULER_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.cc Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,791 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>,
+ * Nicola Baldo <nbaldo@cttc.es>
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#include <ns3/object.h>
+#include <ns3/spectrum-interference.h>
+#include <ns3/spectrum-error-model.h>
+#include <ns3/log.h>
+#include <ns3/test.h>
+#include <ns3/simulator.h>
+#include <ns3/packet.h>
+#include <ns3/ptr.h>
+#include "ns3/radio-bearer-stats-calculator.h"
+#include <ns3/constant-position-mobility-model.h>
+#include <ns3/eps-bearer.h>
+#include <ns3/node-container.h>
+#include <ns3/mobility-helper.h>
+#include <ns3/net-device-container.h>
+#include <ns3/lte-ue-net-device.h>
+#include <ns3/lte-enb-net-device.h>
+#include <ns3/lte-ue-rrc.h>
+#include <ns3/lte-helper.h>
+#include "ns3/string.h"
+#include "ns3/double.h"
+#include <ns3/lte-enb-phy.h>
+#include <ns3/lte-ue-phy.h>
+#include <ns3/boolean.h>
+#include <ns3/enum.h>
+
+#include "ns3/epc-helper.h"
+#include "ns3/network-module.h"
+#include "ns3/ipv4-global-routing-helper.h"
+#include "ns3/internet-module.h"
+#include "ns3/applications-module.h"
+#include "ns3/point-to-point-helper.h"
+
+#include "lte-test-fdtbfq-ff-mac-scheduler.h"
+
+NS_LOG_COMPONENT_DEFINE ("LenaTestFdTbfqFfMacCheduler");
+
+namespace ns3 {
+
+LenaTestFdTbfqFfMacSchedulerSuite::LenaTestFdTbfqFfMacSchedulerSuite ()
+ : TestSuite ("lte-fdtbfq-ff-mac-scheduler", SYSTEM)
+{
+ NS_LOG_INFO ("creating LenaTestFdTbfqFfMacSchedulerSuite");
+
+ // General config
+ // Traffic: UDP traffic with fixed rate
+ // Token generation rate = traffic rate
+ // RLC header length = 2 bytes, PDCP header = 2 bytes
+ // Simulation time = 1.0 sec
+ // Throughput in this file is calculated in RLC layer
+
+ //Test Case 1: homogeneous flow test in FDTBFQ (same distance)
+
+ // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 26 -> 2196 -> 2196000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 2196000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 < 2196000 -> througphut = 232000 byte/sec
+ // 6 user -> 232000 * 6 = 139200 < 2196000 -> throughput = 232000 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 2196000 -> throughput = 2196000 / 12 = 183000 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 2196000 -> throughput = 2196000 / 15 = 146400 byte/sec
+ // UPLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
+ // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 > 232000 -> throughput = 232000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 > 232000 -> throughput = 232000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 < 232000 -> throughput = 185000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 26 -> 89 -> 89000 bytes/sec
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (1,0,0,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (3,0,0,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (6,0,0,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (12,0,0,183000,185000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (15,0,0,146400,0,200,1));
+
+ // DOWNLINK - DISTANCE 3000 -> MCS 24 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
+ // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 20 -> 1383 -> 1383000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 1383000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 < 1383000 -> througphut = 232000 byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 1383000 -> throughput = 1383000 / 6 = 230500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 1383000 -> throughput = 1383000 / 12 = 115250 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 1383000 -> throughput = 1383000 / 15 = 92200 byte/sec
+ // UPLINK - DISTANCE 3000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 25 PRB at Itbs 18 -> 1239 -> 1239000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 18 -> 389 -> 389000 > 232000 -> throughput = 232000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 18 -> 193 -> 193000 < 232000 -> throughput = 193000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 18 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 18 -> 47 -> 47000 bytes/sec
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (1,0,3000,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (3,0,3000,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (6,0,3000,230500,193000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (12,0,3000,115250,97000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (15,0,3000,92200,0,200,1));
+
+ // DOWNLINK - DISTANCE 6000 -> MCS 16 -> Itbs 15 (from table 7.1.7.2.1-1 of 36.213)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 15 -> 903 -> 903000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 903000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 < 903000 -> througphut = 232000 byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 903000 -> throughput = 903000 / 6 = 150500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 903000 -> throughput = 903000 / 12 = 75250 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 903000 -> throughput = 903000 / 15 = 60200 byte/sec
+ // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 < 232000 -> throughput = 201000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 11 -> 47 -> 47000 < 232000 -> throughput = 47000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 11 -> 22 -> 22000 bytes/sec
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (1,0,6000,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (3,0,6000,232000,201000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (6,0,6000,150500,97000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (12,0,6000,75250,47000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (15,0,6000,60200,0,200,1));
+
+ // DOWNLINK - DISTANCE 9000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 11 -> 597 -> 597000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 597000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 > 597000 -> througphut = 597000 / 3 = 199000byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 597000 -> throughput = 597000 / 6 = 99500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 597000 -> throughput = 597000 / 12 = 49750 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 597000 -> throughput = 597000 / 15 = 39800 byte/sec
+ // UPLINK - DISTANCE 9000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 < 232000 -> throughput = 137000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 < 232000 -> throughput = 67000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 8 -> 32 -> 32000 < 232000 -> throughput = 32000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 8 -> 15 -> 15000 bytes/sec
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (1,0,9000,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (3,0,9000,199000,137000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (6,0,9000,99500,67000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (12,0,9000,49750,32000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (15,0,9000,39800,0,200,1));
+
+ // DONWLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 6 -> 309 -> 309000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 309000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 > 309000 -> througphut = 309000 / 3 = 103000byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 309000 -> throughput = 309000 / 6 = 51500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 309000 -> throughput = 309000 / 12 = 25750 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 309000 -> throughput = 309000 / 15 = 20600 byte/sec
+ // UPLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 25 PRB at Itbs 6 -> 233 -> 233000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 6 -> 69 -> 69000 < 232000 -> throughput = 69000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 6 -> 32 -> 32000 < 232000 -> throughput = 32000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 6 -> 15 -> 15000 < 232000 -> throughput = 15000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 6 -> 7 -> 7000 bytes/sec
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (1,0,15000,232000,232000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (3,0,15000,103000,69000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (6,0,15000,51500,32000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (12,0,15000,25750,15000,200,1));
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase1 (15,0,15000,20600,0,200,1));
+
+ // Test Case 2: homogeneous flow test in FDTBFQ (different distance)
+ // Traffic1 info
+ // UDP traffic: payload size = 100 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 132000 byte/rate
+ // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 + 1/597000 + 1/309000) = 694720 byte/s
+ // 132000 * 5 = 660000 < 694720 -> estimated throughput in downlink = 132000 byte/sec
+ std::vector<uint16_t> dist1;
+ dist1.push_back (0); // User 0 distance --> MCS 28
+ dist1.push_back (3000); // User 1 distance --> MCS 24
+ dist1.push_back (6000); // User 2 distance --> MCS 16
+ dist1.push_back (9000); // User 3 distance --> MCS 12
+ dist1.push_back (15000); // User 4 distance --> MCS 6
+ std::vector<uint16_t> packetSize1;
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ std::vector<uint32_t> estThrFdTbfqDl1;
+ estThrFdTbfqDl1.push_back (132000); // User 0 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl1.push_back (132000); // User 1 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl1.push_back (132000); // User 2 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl1.push_back (132000); // User 3 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl1.push_back (132000); // User 4 estimated TTI throughput from FDTBFQ
+ std::vector<uint32_t> estThrFdTbfqUl1;
+ estThrFdTbfqUl1.push_back (469000); // User 0 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl1.push_back (249000); // User 1 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl1.push_back (125000); // User 2 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl1.push_back (85000); // User 3 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl1.push_back (41000); // User 4 estimated TTI throughput from FDTBFQ
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase2 (dist1,estThrFdTbfqDl1, estThrFdTbfqUl1,packetSize1,1));
+
+ // Traffic2 info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 + 1/597000 + 1/309000) = 694720 byte/s
+ // 232000 * 5 = 1160000 > 694720 -> estimated throughput in downlink = 694720 / 5 = 138944 byte/sec
+ std::vector<uint16_t> dist2;
+ dist2.push_back (0); // User 0 distance --> MCS 28
+ dist2.push_back (3000); // User 1 distance --> MCS 24
+ dist2.push_back (6000); // User 2 distance --> MCS 16
+ dist2.push_back (9000); // User 3 distance --> MCS 12
+ dist2.push_back (15000); // User 4 distance --> MCS 6
+ std::vector<uint16_t> packetSize2;
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ std::vector<uint32_t> estThrFdTbfqDl2;
+ estThrFdTbfqDl2.push_back (138944); // User 0 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl2.push_back (138944); // User 1 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl2.push_back (138944); // User 2 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl2.push_back (138944); // User 3 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl2.push_back (138944); // User 4 estimated TTI throughput from FDTBFQ
+ std::vector<uint32_t> estThrFdTbfqUl2;
+ estThrFdTbfqUl2.push_back (469000); // User 0 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl2.push_back (249000); // User 1 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl2.push_back (125000); // User 2 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl2.push_back (85000); // User 3 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl2.push_back (41000); // User 4 estimated TTI throughput from FDTBFQ
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase2 (dist2,estThrFdTbfqDl2,estThrFdTbfqUl2,packetSize2,1));
+
+ // Test Case 3: heterogeneous flow test in FDTBFQ
+ // UDP traffic: payload size = [100,200,300] bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> [132000, 232000, 332000] byte/rate
+ // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 ) = 1312417 byte/s
+ // 132000 + 232000 + 332000 = 696000 < 1312417 -> estimated throughput in downlink = [132000, 232000, 332000] byte/sec
+ std::vector<uint16_t> dist3;
+ dist3.push_back (0); // User 0 distance --> MCS 28
+ dist3.push_back (3000); // User 1 distance --> MCS 24
+ dist3.push_back (6000); // User 2 distance --> MCS 16
+ std::vector<uint16_t> packetSize3;
+ packetSize3.push_back (100);
+ packetSize3.push_back (200);
+ packetSize3.push_back (300);
+ std::vector<uint32_t> estThrFdTbfqDl3;
+ estThrFdTbfqDl3.push_back (132000); // User 0 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl3.push_back (232000); // User 1 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqDl3.push_back (332000); // User 2 estimated TTI throughput from FDTBFQ
+ std::vector<uint32_t> estThrFdTbfqUl3;
+ estThrFdTbfqUl3.push_back (469000); // User 0 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl3.push_back (249000); // User 1 estimated TTI throughput from FDTBFQ
+ estThrFdTbfqUl3.push_back (125000); // User 2 estimated TTI throughput from FDTBFQ
+ AddTestCase (new LenaFdTbfqFfMacSchedulerTestCase2 (dist3,estThrFdTbfqDl3, estThrFdTbfqUl3,packetSize3,1));
+
+}
+
+static LenaTestFdTbfqFfMacSchedulerSuite lenaTestFdTbfqFfMacSchedulerSuite;
+
+// --------------- T E S T - C A S E # 1 ------------------------------
+
+
+std::string
+LenaFdTbfqFfMacSchedulerTestCase1::BuildNameString (uint16_t nUser, uint16_t dist)
+{
+ std::ostringstream oss;
+ oss << nUser << " UEs, distance " << dist << " m";
+ return oss.str ();
+}
+
+
+LenaFdTbfqFfMacSchedulerTestCase1::LenaFdTbfqFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval)
+ : TestCase (BuildNameString (nUser, dist)),
+ m_nUser (nUser),
+ m_nLc (nLc),
+ m_dist (dist),
+ m_packetSize (packetSize),
+ m_interval (interval),
+ m_thrRefDl (thrRefDl),
+ m_thrRefUl (thrRefUl)
+{
+}
+
+LenaFdTbfqFfMacSchedulerTestCase1::~LenaFdTbfqFfMacSchedulerTestCase1 ()
+{
+}
+
+void
+LenaFdTbfqFfMacSchedulerTestCase1::DoRun (void)
+{
+ Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
+ Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
+ lteHelper->SetEpcHelper (epcHelper);
+
+ Ptr<Node> pgw = epcHelper->GetPgwNode ();
+
+ // Create a single RemoteHost
+ NodeContainer remoteHostContainer;
+ remoteHostContainer.Create (1);
+ Ptr<Node> remoteHost = remoteHostContainer.Get (0);
+ InternetStackHelper internet;
+ internet.Install (remoteHostContainer);
+
+ // Create the Internet
+ PointToPointHelper p2ph;
+ p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
+ p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
+ p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
+ NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
+ Ipv4AddressHelper ipv4h;
+ ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
+ Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
+ // interface 0 is localhost, 1 is the p2p device
+ Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
+
+ Ipv4StaticRoutingHelper ipv4RoutingHelper;
+ Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
+ remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
+
+ Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
+ Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
+ Config::SetDefault ("ns3::LteSpectrumPhy::PemEnabled", BooleanValue (false));
+
+ LogComponentDisableAll (LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
+//
+// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
+
+ // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
+
+// LogComponentEnable ("FdTbfqFfMacScheduler", LOG_LEVEL_AlL);
+ LogComponentEnable ("LenaTestFdTbfqFfMacCheduler", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
+// LogComponentEnable ("RadioBearerStatsCalculator", LOG_LEVEL_ALL);
+
+
+ lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
+
+ // Create Nodes: eNodeB and UE
+ NodeContainer enbNodes;
+ NodeContainer ueNodes;
+ enbNodes.Create (1);
+ ueNodes.Create (m_nUser);
+
+ // 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;
+ lteHelper->SetSchedulerType ("ns3::FdTbfqFfMacScheduler");
+ enbDevs = lteHelper->InstallEnbDevice (enbNodes);
+ ueDevs = lteHelper->InstallUeDevice (ueNodes);
+
+ // Attach a UE to a eNB
+ lteHelper->Attach (ueDevs, enbDevs.Get (0));
+
+ Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
+ Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
+ enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
+ enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
+
+ // Set UEs' position and power
+ for (int i = 0; i < m_nUser; i++)
+ {
+ Ptr<ConstantPositionMobilityModel> mm = ueNodes.Get (i)->GetObject<ConstantPositionMobilityModel> ();
+ mm->SetPosition (Vector (m_dist, 0.0, 0.0));
+ Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
+ Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
+ uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
+ uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
+ }
+
+ // Install the IP stack on the UEs
+ internet.Install (ueNodes);
+ Ipv4InterfaceContainer ueIpIface;
+ ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
+ // Assign IP address to UEs, and install applications
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ Ptr<Node> ueNode = ueNodes.Get (u);
+ // Set the default gateway for the UE
+ Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
+ ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
+ }
+
+// Activate an EPS bearer
+ enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
+ GbrQosInformation qos;
+ qos.gbrDl = (m_packetSize + 32) * (1000/m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size
+ qos.gbrUl = 0;
+ qos.mbrDl = qos.gbrDl;
+ qos.mbrUl = 0;
+
+ EpsBearer bearer (q, qos);
+ lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ());
+
+ lteHelper->EnableMacTraces ();
+ lteHelper->EnableRlcTraces ();
+ lteHelper->EnablePdcpTraces ();
+
+ // Install downlind and uplink applications
+ uint16_t dlPort = 1234;
+ uint16_t ulPort = 2000;
+ PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
+ PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
+ ApplicationContainer clientApps;
+ ApplicationContainer serverApps;
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ ++ulPort;
+ serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get(u))); // receive packets from remotehost
+ serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
+
+ UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
+ dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ dlClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ dlClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize));
+
+ UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
+ ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ ulClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ ulClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize));
+
+ clientApps.Add (dlClient.Install (remoteHost));
+ clientApps.Add (ulClient.Install (ueNodes.Get(u)));
+ }
+
+ serverApps.Start (Seconds (0.001));
+ clientApps.Start (Seconds (0.001));
+
+ double simulationTime = 1.0;
+ double tolerance = 0.1;
+ Simulator::Stop (Seconds (simulationTime));
+
+ Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
+ rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
+
+ Simulator::Run ();
+
+ /**
+ * Check that the downlink assignation is done in a "token bank fair queue" manner
+ */
+
+ NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
+ std::vector <uint64_t> dlDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ uint64_t data = rlcStats->GetDlRxData (imsi, lcId);
+ dlDataRxed.push_back (data);
+ NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / simulationTime << " ref " << m_thrRefDl);
+ }
+
+ for (int i = 0; i < m_nUser; i++)
+ {
+ NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
+ }
+
+ /**
+ * Check that the uplink assignation is done in a "round robin" manner
+ */
+
+ NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
+ std::vector <uint64_t> ulDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
+ NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / simulationTime << " ref " << m_thrRefUl);
+ }
+
+ for (int i = 0; i < m_nUser; i++)
+ {
+ NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / simulationTime, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
+ }
+ Simulator::Destroy ();
+
+}
+
+
+
+// --------------- T E S T - C A S E # 2 ------------------------------
+
+
+std::string
+LenaFdTbfqFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
+{
+ std::ostringstream oss;
+ oss << "distances (m) = [ " ;
+ for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
+ {
+ oss << *it << " ";
+ }
+ oss << "]";
+ return oss.str ();
+}
+
+
+LenaFdTbfqFfMacSchedulerTestCase2::LenaFdTbfqFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrFdTbfqDl, std::vector<uint32_t> estThrFdTbfqUl, std::vector<uint16_t> packetSize, uint16_t interval)
+ : TestCase (BuildNameString (dist.size (), dist)),
+ m_nUser (dist.size ()),
+ m_dist (dist),
+ m_packetSize (packetSize),
+ m_interval (interval),
+ m_estThrFdTbfqDl (estThrFdTbfqDl),
+ m_estThrFdTbfqUl (estThrFdTbfqUl)
+{
+}
+
+LenaFdTbfqFfMacSchedulerTestCase2::~LenaFdTbfqFfMacSchedulerTestCase2 ()
+{
+}
+
+void
+LenaFdTbfqFfMacSchedulerTestCase2::DoRun (void)
+{
+ Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
+ Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
+ lteHelper->SetEpcHelper (epcHelper);
+
+ Ptr<Node> pgw = epcHelper->GetPgwNode ();
+
+ // Create a single RemoteHost
+ NodeContainer remoteHostContainer;
+ remoteHostContainer.Create (1);
+ Ptr<Node> remoteHost = remoteHostContainer.Get (0);
+ InternetStackHelper internet;
+ internet.Install (remoteHostContainer);
+
+ // Create the Internet
+ PointToPointHelper p2ph;
+ p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
+ p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
+ p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
+ NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
+ Ipv4AddressHelper ipv4h;
+ ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
+ Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
+ // interface 0 is localhost, 1 is the p2p device
+ Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
+
+ Ipv4StaticRoutingHelper ipv4RoutingHelper;
+ Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
+ remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
+
+ Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
+ Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
+ Config::SetDefault ("ns3::LteSpectrumPhy::PemEnabled", BooleanValue (false));
+
+ LogComponentDisableAll (LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
+//
+// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
+
+ // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
+
+// LogComponentEnable ("FdTbfqFfMacScheduler", LOG_LEVEL_AlL);
+ LogComponentEnable ("LenaTestFdTbfqFfMacCheduler", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
+// LogComponentEnable ("RadioBearerStatsCalculator", LOG_LEVEL_ALL);
+
+
+ lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
+
+ // Create Nodes: eNodeB and UE
+ NodeContainer enbNodes;
+ NodeContainer ueNodes;
+ enbNodes.Create (1);
+ ueNodes.Create (m_nUser);
+
+ // 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;
+ lteHelper->SetSchedulerType ("ns3::FdTbfqFfMacScheduler");
+ enbDevs = lteHelper->InstallEnbDevice (enbNodes);
+ ueDevs = lteHelper->InstallUeDevice (ueNodes);
+
+ // Attach a UE to a eNB
+ lteHelper->Attach (ueDevs, enbDevs.Get (0));
+
+ Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
+ Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
+ enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
+ enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
+
+ // Set UEs' position and power
+ for (int i = 0; i < m_nUser; i++)
+ {
+ Ptr<ConstantPositionMobilityModel> mm = ueNodes.Get (i)->GetObject<ConstantPositionMobilityModel> ();
+ mm->SetPosition (Vector (m_dist.at(i), 0.0, 0.0));
+ Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
+ Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
+ uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
+ uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
+ }
+
+ // Install the IP stack on the UEs
+ internet.Install (ueNodes);
+ Ipv4InterfaceContainer ueIpIface;
+ ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
+ // Assign IP address to UEs, and install applications
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ Ptr<Node> ueNode = ueNodes.Get (u);
+ // Set the default gateway for the UE
+ Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
+ ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
+ }
+
+// Activate an EPS bearer
+ enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
+ GbrQosInformation qos;
+ uint16_t mbrDl = 0;
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ mbrDl = mbrDl + m_packetSize.at(u);
+ }
+ mbrDl = mbrDl/ueNodes.GetN();
+ qos.gbrDl = (mbrDl + 32) * (1000/m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size
+ qos.gbrUl = 0;
+ qos.mbrDl = qos.gbrDl;
+ qos.mbrUl = 0;
+ EpsBearer bearer (q, qos);
+ lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ());
+
+ lteHelper->EnableMacTraces ();
+ lteHelper->EnableRlcTraces ();
+ lteHelper->EnablePdcpTraces ();
+
+ // Install downlind and uplink applications
+ uint16_t dlPort = 1234;
+ uint16_t ulPort = 2000;
+ PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
+ PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
+ ApplicationContainer clientApps;
+ ApplicationContainer serverApps;
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ ++ulPort;
+ serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get(u))); // receive packets from remotehost
+ serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
+
+ UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
+ dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ dlClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ dlClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize.at(u)));
+
+ UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
+ ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ ulClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ ulClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize.at(u)));
+
+ clientApps.Add (dlClient.Install (remoteHost));
+ clientApps.Add (ulClient.Install (ueNodes.Get(u)));
+ }
+
+ serverApps.Start (Seconds (0.001));
+ clientApps.Start (Seconds (0.001));
+
+ double simulationTime = 1.0;
+ double tolerance = 0.1;
+ Simulator::Stop (Seconds (simulationTime));
+
+ Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
+ rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
+
+ Simulator::Run ();
+
+ /**
+ * Check that the downlink assignation is done in a "token bank fair queue" manner
+ */
+
+ NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
+ std::vector <uint64_t> dlDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
+ NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / simulationTime << " ref " << m_nUser);
+ }
+
+ for (int i = 0; i < m_nUser; i++)
+ {
+ NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, m_estThrFdTbfqDl.at(i), m_estThrFdTbfqDl.at(i) * tolerance, " Unfair Throughput!");
+ }
+
+ /**
+ * Check that the assignation in uplink is done in a round robin manner.
+ */
+
+ NS_LOG_INFO ("UL - Test with " << m_nUser);
+ std::vector <uint64_t> ulDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
+ NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / simulationTime << " ref " << (double)m_estThrFdTbfqUl.at (i));
+ //NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / simulationTime, (double)m_estThrFdTbfqUl.at (i), (double)m_estThrFdTbfqUl.at (i) * tolerance, " Unfair Throughput!");
+ }
+ Simulator::Destroy ();
+
+}
+
+
+} // namespace ns3
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/test/lte-test-fdtbfq-ff-mac-scheduler.h Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,91 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>,
+ * Nicola Baldo <nbaldo@cttc.es>
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#ifndef LENA_TEST_FDTBFQ_FF_MAC_SCHEDULER_H
+#define LENA_TEST_FDTBFQ_FF_MAC_SCHEDULER_H
+
+#include "ns3/simulator.h"
+#include "ns3/test.h"
+
+
+namespace ns3 {
+
+
+/**
+* This system test program creates different test cases with a single eNB and
+* several UEs, all having the same Radio Bearer specification. In each test
+* case, the UEs see the same SINR from the eNB; different test cases are
+* implemented obtained by using different SINR values and different numbers of
+* UEs. The test consists on checking that the obtained throughput performance
+* is equal among users is consistent with the definition of token bank fair
+* queue scheduling
+*/
+class LenaFdTbfqFfMacSchedulerTestCase1 : public TestCase
+{
+public:
+ LenaFdTbfqFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval);
+ virtual ~LenaFdTbfqFfMacSchedulerTestCase1 ();
+
+private:
+ static std::string BuildNameString (uint16_t nUser, uint16_t dist);
+ virtual void DoRun (void);
+ uint16_t m_nUser;
+ uint16_t m_nLc;
+ uint16_t m_dist;
+ uint16_t m_packetSize; // byte
+ uint16_t m_interval; // ms
+ double m_thrRefDl;
+ double m_thrRefUl;
+};
+
+
+class LenaFdTbfqFfMacSchedulerTestCase2 : public TestCase
+{
+public:
+ LenaFdTbfqFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrFdTbfqDl, std::vector<uint32_t> estThrFdTbfqUl, std::vector<uint16_t> packetSize, uint16_t interval);
+ virtual ~LenaFdTbfqFfMacSchedulerTestCase2 ();
+
+private:
+ static std::string BuildNameString (uint16_t nUser, std::vector<uint16_t> dist);
+ virtual void DoRun (void);
+ uint16_t m_nUser;
+ std::vector<uint16_t> m_dist;
+ std::vector<uint16_t> m_packetSize; // byte
+ uint16_t m_interval; // ms
+ std::vector<uint32_t> m_estThrFdTbfqDl;
+ std::vector<uint32_t> m_estThrFdTbfqUl;
+};
+
+
+class LenaTestFdTbfqFfMacSchedulerSuite : public TestSuite
+{
+public:
+ LenaTestFdTbfqFfMacSchedulerSuite ();
+};
+
+
+
+
+} // namespace ns3
+
+
+#endif /* LENA_TEST_FDTBFQ_FF_MAC_SCHEDULER_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.cc Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,787 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>,
+ * Nicola Baldo <nbaldo@cttc.es>\
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#include <ns3/object.h>
+#include <ns3/spectrum-interference.h>
+#include <ns3/spectrum-error-model.h>
+#include <ns3/log.h>
+#include <ns3/test.h>
+#include <ns3/simulator.h>
+#include <ns3/packet.h>
+#include <ns3/ptr.h>
+#include "ns3/radio-bearer-stats-calculator.h"
+#include <ns3/constant-position-mobility-model.h>
+#include <ns3/eps-bearer.h>
+#include <ns3/node-container.h>
+#include <ns3/mobility-helper.h>
+#include <ns3/net-device-container.h>
+#include <ns3/lte-ue-net-device.h>
+#include <ns3/lte-enb-net-device.h>
+#include <ns3/lte-ue-rrc.h>
+#include <ns3/lte-helper.h>
+#include "ns3/string.h"
+#include "ns3/double.h"
+#include <ns3/lte-enb-phy.h>
+#include <ns3/lte-ue-phy.h>
+#include <ns3/boolean.h>
+#include <ns3/enum.h>
+
+#include "ns3/epc-helper.h"
+#include "ns3/network-module.h"
+#include "ns3/ipv4-global-routing-helper.h"
+#include "ns3/internet-module.h"
+#include "ns3/applications-module.h"
+#include "ns3/point-to-point-helper.h"
+
+#include "lte-test-tdtbfq-ff-mac-scheduler.h"
+
+NS_LOG_COMPONENT_DEFINE ("LenaTestTdTbfqFfMacCheduler");
+
+namespace ns3 {
+
+LenaTestTdTbfqFfMacSchedulerSuite::LenaTestTdTbfqFfMacSchedulerSuite ()
+ : TestSuite ("lte-tdtbfq-ff-mac-scheduler", SYSTEM)
+{
+ NS_LOG_INFO ("creating LenaTestTdTbfqFfMacSchedulerSuite");
+
+ // General config
+ // Traffic: UDP traffic with fixed rate
+ // Token generation rate = traffic rate
+ // RLC header length = 2 bytes, PDCP header = 2 bytes
+ // Simulation time = 1.0 sec
+ // Throughput in this file is calculated in RLC layer
+
+ //Test Case 1: homogeneous flow test in TDTBFQ (same distance)
+
+ // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 26 -> 2196 -> 2196000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 2196000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 < 2196000 -> througphut = 232000 byte/sec
+ // 6 user -> 232000 * 6 = 139200 < 2196000 -> throughput = 232000 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 2196000 -> throughput = 2196000 / 12 = 183000 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 2196000 -> throughput = 2196000 / 15 = 146400 byte/sec
+ // UPLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
+ // 1 user -> 25 PRB at Itbs 26 -> 2292 -> 2292000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 26 -> 749 -> 749000 > 232000 -> throughput = 232000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 26 -> 373 -> 373000 > 232000 -> throughput = 232000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 26 -> 185 -> 185000 < 232000 -> throughput = 185000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 26 -> 89 -> 89000 bytes/sec
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,0,0,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,0,0,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,0,0,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,0,0,183000,185000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (15,0,0,146400,0,200,1));
+
+ // DOWNLINK - DISTANCE 3000 -> MCS 24 -> Itbs 20 (from table 7.1.7.2.1-1 of 36.213)
+ // DOWNLINK -> DISTANCE 0 -> MCS 28 -> Itbs 26 (from table 7.1.7.2.1-1 of 36.2 13)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 20 -> 1383 -> 1383000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 1383000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 < 1383000 -> througphut = 232000 byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 1383000 -> throughput = 1383000 / 6 = 230500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 1383000 -> throughput = 1383000 / 12 = 115250 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 1383000 -> throughput = 1383000 / 15 = 92200 byte/sec
+ // UPLINK - DISTANCE 3000 -> MCS 20 -> Itbs 18 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 25 PRB at Itbs 18 -> 1239 -> 1239000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 18 -> 389 -> 389000 > 232000 -> throughput = 232000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 18 -> 193 -> 193000 < 232000 -> throughput = 193000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 18 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 18 -> 47 -> 47000 bytes/sec
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,0,3000,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,0,3000,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,0,3000,230500,193000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,0,3000,115250,97000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (15,0,3000,92200,0,200,1));
+
+ // DOWNLINK - DISTANCE 6000 -> MCS 16 -> Itbs 15 (from table 7.1.7.2.1-1 of 36.213)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 15 -> 903 -> 903000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 903000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 < 903000 -> througphut = 232000 byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 903000 -> throughput = 903000 / 6 = 150500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 903000 -> throughput = 903000 / 12 = 75250 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 903000 -> throughput = 903000 / 15 = 60200 byte/sec
+ // UPLINK - DISTANCE 6000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 25 PRB at Itbs 11 -> 621 -> 621000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 11 -> 201 -> 201000 < 232000 -> throughput = 201000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 11 -> 97 -> 97000 < 232000 -> throughput = 97000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 11 -> 47 -> 47000 < 232000 -> throughput = 47000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 11 -> 22 -> 22000 bytes/sec
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,0,6000,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,0,6000,232000,201000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,0,6000,150500,97000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,0,6000,75250,47000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (15,0,6000,60200,0,200,1));
+
+ // DOWNLINK - DISTANCE 9000 -> MCS 12 -> Itbs 11 (from table 7.1.7.2.1-1 of 36.213)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 11 -> 597 -> 597000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 597000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 > 597000 -> througphut = 597000 / 3 = 199000byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 597000 -> throughput = 597000 / 6 = 99500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 597000 -> throughput = 597000 / 12 = 49750 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 597000 -> throughput = 597000 / 15 = 39800 byte/sec
+ // UPLINK - DISTANCE 9000 -> MCS 8 -> Itbs 8 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 24 PRB at Itbs 8 -> 437 -> 437000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 8 -> 137 -> 137000 < 232000 -> throughput = 137000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 8 -> 67 -> 67000 < 232000 -> throughput = 67000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 8 -> 32 -> 32000 < 232000 -> throughput = 32000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 8 -> 15 -> 15000 bytes/sec
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,0,9000,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,0,9000,199000,137000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,0,9000,99500,67000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,0,9000,49750,32000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (15,0,9000,39800,0,200,1));
+
+ // DONWLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
+ // Traffic info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Totol bandwidth: 24 PRB at Itbs 6 -> 309 -> 309000 byte/sec
+ // 1 user -> 232000 * 1 = 232000 < 309000 -> throughput = 232000 byte/sec
+ // 3 user -> 232000 * 3 = 696000 > 309000 -> througphut = 309000 / 3 = 103000byte/sec
+ // 6 user -> 232000 * 6 = 139200 > 309000 -> throughput = 309000 / 6 = 51500 byte/sec
+ // 12 user -> 232000 * 12 = 2784000 > 309000 -> throughput = 309000 / 12 = 25750 byte/sec
+ // 15 user -> 232000 * 15 = 3480000 > 309000 -> throughput = 309000 / 15 = 20600 byte/sec
+ // UPLINK - DISTANCE 15000 -> MCS 6 -> Itbs 6 (from table 7.1.7.2.1-1 of 36.213)
+ // 1 user -> 25 PRB at Itbs 6 -> 233 -> 233000 > 232000 -> throughput = 232000 bytes/sec
+ // 3 users -> 8 PRB at Itbs 6 -> 69 -> 69000 < 232000 -> throughput = 69000 bytes/sec
+ // 6 users -> 4 PRB at Itbs 6 -> 32 -> 32000 < 232000 -> throughput = 32000 bytes/sec
+ // 12 users -> 2 PRB at Itbs 6 -> 15 -> 15000 < 232000 -> throughput = 15000 bytes/sec
+ // 15 users -> 1 PRB at Itbs 6 -> 7 -> 7000 bytes/sec
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (1,0,15000,232000,232000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (3,0,15000,103000,69000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (6,0,15000,51500,32000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (12,0,15000,25750,15000,200,1));
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase1 (15,0,15000,20600,0,200,1));
+
+ // Test Case 2: homogeneous flow test in TDTBFQ (different distance)
+ // Traffic1 info
+ // UDP traffic: payload size = 100 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 132000 byte/rate
+ // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 + 1/597000 + 1/309000) = 694720 byte/s
+ // 132000 * 5 = 660000 < 694720 -> estimated throughput in downlink = 132000 byte/sec
+ std::vector<uint16_t> dist1;
+ dist1.push_back (0); // User 0 distance --> MCS 28
+ dist1.push_back (3000); // User 1 distance --> MCS 24
+ dist1.push_back (6000); // User 2 distance --> MCS 16
+ dist1.push_back (9000); // User 3 distance --> MCS 12
+ dist1.push_back (15000); // User 4 distance --> MCS 6
+ std::vector<uint16_t> packetSize1;
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ packetSize1.push_back (100);
+ std::vector<uint32_t> estThrTdTbfqDl1;
+ estThrTdTbfqDl1.push_back (132000); // User 0 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl1.push_back (132000); // User 1 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl1.push_back (132000); // User 2 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl1.push_back (132000); // User 3 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl1.push_back (132000); // User 4 estimated TTI throughput from TDTBFQ
+ std::vector<uint32_t> estThrTdTbfqUl1;
+ estThrTdTbfqUl1.push_back (469000); // User 0 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl1.push_back (249000); // User 1 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl1.push_back (125000); // User 2 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl1.push_back (85000); // User 3 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl1.push_back (41000); // User 4 estimated TTI throughput from TDTBFQ
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase2 (dist1,estThrTdTbfqDl1, estThrTdTbfqUl1,packetSize1,1));
+
+ // Traffic2 info
+ // UDP traffic: payload size = 200 bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 232000 byte/rate
+ // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 + 1/597000 + 1/309000) = 694720 byte/s
+ // 232000 * 5 = 1160000 > 694720 -> estimated throughput in downlink = 694720 / 5 = 138944 byte/sec
+ std::vector<uint16_t> dist2;
+ dist2.push_back (0); // User 0 distance --> MCS 28
+ dist2.push_back (3000); // User 1 distance --> MCS 24
+ dist2.push_back (6000); // User 2 distance --> MCS 16
+ dist2.push_back (9000); // User 3 distance --> MCS 12
+ dist2.push_back (15000); // User 4 distance --> MCS 6
+ std::vector<uint16_t> packetSize2;
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ packetSize2.push_back (200);
+ std::vector<uint32_t> estThrTdTbfqDl2;
+ estThrTdTbfqDl2.push_back (138944); // User 0 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl2.push_back (138944); // User 1 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl2.push_back (138944); // User 2 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl2.push_back (138944); // User 3 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl2.push_back (138944); // User 4 estimated TTI throughput from TDTBFQ
+ std::vector<uint32_t> estThrTdTbfqUl2;
+ estThrTdTbfqUl2.push_back (469000); // User 0 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl2.push_back (249000); // User 1 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl2.push_back (125000); // User 2 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl2.push_back (85000); // User 3 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl2.push_back (41000); // User 4 estimated TTI throughput from TDTBFQ
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase2 (dist2,estThrTdTbfqDl2,estThrTdTbfqUl2,packetSize2,1));
+
+ // Test Case 3: heterogeneous flow test in TDTBFQ
+ // UDP traffic: payload size = [100,200,300] bytes, interval = 1 ms
+ // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> [132000, 232000, 332000] byte/rate
+ // Maximum throughput = 5 / ( 1/2196000 + 1/1383000 + 1/903000 ) = 1312417 byte/s
+ // 132000 + 232000 + 332000 = 696000 < 1312417 -> estimated throughput in downlink = [132000, 232000, 332000] byte/sec
+ std::vector<uint16_t> dist3;
+ dist3.push_back (0); // User 0 distance --> MCS 28
+ dist3.push_back (3000); // User 1 distance --> MCS 24
+ dist3.push_back (6000); // User 2 distance --> MCS 16
+ std::vector<uint16_t> packetSize3;
+ packetSize3.push_back (100);
+ packetSize3.push_back (200);
+ packetSize3.push_back (300);
+ std::vector<uint32_t> estThrTdTbfqDl3;
+ estThrTdTbfqDl3.push_back (132000); // User 0 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl3.push_back (232000); // User 1 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqDl3.push_back (332000); // User 2 estimated TTI throughput from TDTBFQ
+ std::vector<uint32_t> estThrTdTbfqUl3;
+ estThrTdTbfqUl3.push_back (469000); // User 0 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl3.push_back (249000); // User 1 estimated TTI throughput from TDTBFQ
+ estThrTdTbfqUl3.push_back (125000); // User 2 estimated TTI throughput from TDTBFQ
+ AddTestCase (new LenaTdTbfqFfMacSchedulerTestCase2 (dist3,estThrTdTbfqDl3, estThrTdTbfqUl3,packetSize3,1));
+
+}
+
+static LenaTestTdTbfqFfMacSchedulerSuite lenaTestTdTbfqFfMacSchedulerSuite;
+
+// --------------- T E S T - C A S E # 1 ------------------------------
+
+
+std::string
+LenaTdTbfqFfMacSchedulerTestCase1::BuildNameString (uint16_t nUser, uint16_t dist)
+{
+ std::ostringstream oss;
+ oss << nUser << " UEs, distance " << dist << " m";
+ return oss.str ();
+}
+
+
+LenaTdTbfqFfMacSchedulerTestCase1::LenaTdTbfqFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval)
+ : TestCase (BuildNameString (nUser, dist)),
+ m_nUser (nUser),
+ m_nLc (nLc),
+ m_dist (dist),
+ m_packetSize (packetSize),
+ m_interval (interval),
+ m_thrRefDl (thrRefDl),
+ m_thrRefUl (thrRefUl)
+{
+}
+
+LenaTdTbfqFfMacSchedulerTestCase1::~LenaTdTbfqFfMacSchedulerTestCase1 ()
+{
+}
+
+void
+LenaTdTbfqFfMacSchedulerTestCase1::DoRun (void)
+{
+ Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
+ Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
+ lteHelper->SetEpcHelper (epcHelper);
+
+ Ptr<Node> pgw = epcHelper->GetPgwNode ();
+
+ // Create a single RemoteHost
+ NodeContainer remoteHostContainer;
+ remoteHostContainer.Create (1);
+ Ptr<Node> remoteHost = remoteHostContainer.Get (0);
+ InternetStackHelper internet;
+ internet.Install (remoteHostContainer);
+
+ // Create the Internet
+ PointToPointHelper p2ph;
+ p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
+ p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
+ p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
+ NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
+ Ipv4AddressHelper ipv4h;
+ ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
+ Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
+ // interface 0 is localhost, 1 is the p2p device
+ Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
+
+ Ipv4StaticRoutingHelper ipv4RoutingHelper;
+ Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
+ remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
+
+ Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
+ Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
+ Config::SetDefault ("ns3::LteSpectrumPhy::PemEnabled", BooleanValue (false));
+
+ LogComponentDisableAll (LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
+//
+// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
+
+ // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
+
+// LogComponentEnable ("TdTbfqFfMacScheduler", LOG_LEVEL_AlL);
+ LogComponentEnable ("LenaTestTdTbfqFfMacCheduler", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
+// LogComponentEnable ("RadioBearerStatsCalculator", LOG_LEVEL_ALL);
+
+
+ lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
+
+ // Create Nodes: eNodeB and UE
+ NodeContainer enbNodes;
+ NodeContainer ueNodes;
+ enbNodes.Create (1);
+ ueNodes.Create (m_nUser);
+
+ // 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;
+ lteHelper->SetSchedulerType ("ns3::TdTbfqFfMacScheduler");
+ enbDevs = lteHelper->InstallEnbDevice (enbNodes);
+ ueDevs = lteHelper->InstallUeDevice (ueNodes);
+
+ // Attach a UE to a eNB
+ lteHelper->Attach (ueDevs, enbDevs.Get (0));
+
+ Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
+ Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
+ enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
+ enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
+
+ // Set UEs' position and power
+ for (int i = 0; i < m_nUser; i++)
+ {
+ Ptr<ConstantPositionMobilityModel> mm = ueNodes.Get (i)->GetObject<ConstantPositionMobilityModel> ();
+ mm->SetPosition (Vector (m_dist, 0.0, 0.0));
+ Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
+ Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
+ uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
+ uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
+ }
+
+ // Install the IP stack on the UEs
+ internet.Install (ueNodes);
+ Ipv4InterfaceContainer ueIpIface;
+ ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
+ // Assign IP address to UEs, and install applications
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ Ptr<Node> ueNode = ueNodes.Get (u);
+ // Set the default gateway for the UE
+ Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
+ ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
+ }
+
+// Activate an EPS bearer
+ enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
+ GbrQosInformation qos;
+ qos.gbrDl = (m_packetSize + 32) * (1000/m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size
+ qos.gbrUl = 0;
+ qos.mbrDl = qos.gbrDl;
+ qos.mbrUl = 0;
+ EpsBearer bearer (q, qos);
+ lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ());
+
+ lteHelper->EnableMacTraces ();
+ lteHelper->EnableRlcTraces ();
+ lteHelper->EnablePdcpTraces ();
+
+ // Install downlind and uplink applications
+ uint16_t dlPort = 1234;
+ uint16_t ulPort = 2000;
+ PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
+ PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
+ ApplicationContainer clientApps;
+ ApplicationContainer serverApps;
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ ++ulPort;
+ serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get(u))); // receive packets from remotehost
+ serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
+
+ UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
+ dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ dlClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ dlClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize));
+
+ UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
+ ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ ulClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ ulClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize));
+
+ clientApps.Add (dlClient.Install (remoteHost));
+ clientApps.Add (ulClient.Install (ueNodes.Get(u)));
+ }
+
+ serverApps.Start (Seconds (0.001));
+ clientApps.Start (Seconds (0.001));
+
+ double simulationTime = 1.0;
+ double tolerance = 0.1;
+ Simulator::Stop (Seconds (simulationTime));
+
+ Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
+ rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
+
+ Simulator::Run ();
+
+ /**
+ * Check that the downlink assignation is done in a "token bank fair queue" manner
+ */
+ NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s) at distance " << m_dist);
+ std::vector <uint64_t> dlDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ uint64_t data = rlcStats->GetDlRxData (imsi, lcId);
+ dlDataRxed.push_back (data);
+ NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / simulationTime << " ref " << m_thrRefDl);
+ }
+
+ for (int i = 0; i < m_nUser; i++)
+ {
+ NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, m_thrRefDl, m_thrRefDl * tolerance, " Unfair Throughput!");
+ }
+
+ /**
+ * Check that the uplink assignation is done in a "round robin" manner
+ */
+ NS_LOG_INFO ("UL - Test with " << m_nUser << " user(s) at distance " << m_dist);
+ std::vector <uint64_t> ulDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
+ NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / simulationTime << " ref " << m_thrRefUl);
+ }
+
+ for (int i = 0; i < m_nUser; i++)
+ {
+ NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / simulationTime, m_thrRefUl, m_thrRefUl * tolerance, " Unfair Throughput!");
+ }
+ Simulator::Destroy ();
+
+}
+
+
+
+// --------------- T E S T - C A S E # 2 ------------------------------
+
+
+std::string
+LenaTdTbfqFfMacSchedulerTestCase2::BuildNameString (uint16_t nUser, std::vector<uint16_t> dist)
+{
+ std::ostringstream oss;
+ oss << "distances (m) = [ " ;
+ for (std::vector<uint16_t>::iterator it = dist.begin (); it != dist.end (); ++it)
+ {
+ oss << *it << " ";
+ }
+ oss << "]";
+ return oss.str ();
+}
+
+
+LenaTdTbfqFfMacSchedulerTestCase2::LenaTdTbfqFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrTdTbfqDl, std::vector<uint32_t> estThrTdTbfqUl, std::vector<uint16_t> packetSize, uint16_t interval)
+ : TestCase (BuildNameString (dist.size (), dist)),
+ m_nUser (dist.size ()),
+ m_dist (dist),
+ m_packetSize (packetSize),
+ m_interval (interval),
+ m_estThrTdTbfqDl (estThrTdTbfqDl),
+ m_estThrTdTbfqUl (estThrTdTbfqUl)
+{
+}
+
+LenaTdTbfqFfMacSchedulerTestCase2::~LenaTdTbfqFfMacSchedulerTestCase2 ()
+{
+}
+
+void
+LenaTdTbfqFfMacSchedulerTestCase2::DoRun (void)
+{
+ Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
+ Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
+ lteHelper->SetEpcHelper (epcHelper);
+
+ Ptr<Node> pgw = epcHelper->GetPgwNode ();
+
+ // Create a single RemoteHost
+ NodeContainer remoteHostContainer;
+ remoteHostContainer.Create (1);
+ Ptr<Node> remoteHost = remoteHostContainer.Get (0);
+ InternetStackHelper internet;
+ internet.Install (remoteHostContainer);
+
+ // Create the Internet
+ PointToPointHelper p2ph;
+ p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
+ p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500));
+ p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001)));
+ NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
+ Ipv4AddressHelper ipv4h;
+ ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
+ Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
+ // interface 0 is localhost, 1 is the p2p device
+ Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
+
+ Ipv4StaticRoutingHelper ipv4RoutingHelper;
+ Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
+ remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
+
+ Config::SetDefault ("ns3::LteAmc::AmcModel", EnumValue (LteAmc::PiroEW2010));
+ Config::SetDefault ("ns3::LteAmc::Ber", DoubleValue (0.00005));
+ Config::SetDefault ("ns3::LteSpectrumPhy::PemEnabled", BooleanValue (false));
+
+ LogComponentDisableAll (LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeRrc", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbMac", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeMac", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteRlc", LOG_LEVEL_ALL);
+//
+// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
+// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
+
+ // LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LtePropagationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("ShadowingLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PenetrationLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("MultipathLossModel", LOG_LEVEL_ALL);
+ // LogComponentEnable ("PathLossModel", LOG_LEVEL_ALL);
+ //
+ // LogComponentEnable ("LteNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteUeNetDevice", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL);
+
+// LogComponentEnable ("TdTbfqFfMacScheduler", LOG_LEVEL_AlL);
+ LogComponentEnable ("LenaTestTdTbfqFfMacCheduler", LOG_LEVEL_ALL);
+ // LogComponentEnable ("LteAmc", LOG_LEVEL_ALL);
+// LogComponentEnable ("RadioBearerStatsCalculator", LOG_LEVEL_ALL);
+
+
+ lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
+
+ // Create Nodes: eNodeB and UE
+ NodeContainer enbNodes;
+ NodeContainer ueNodes;
+ enbNodes.Create (1);
+ ueNodes.Create (m_nUser);
+
+ // 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;
+ lteHelper->SetSchedulerType ("ns3::TdTbfqFfMacScheduler");
+ enbDevs = lteHelper->InstallEnbDevice (enbNodes);
+ ueDevs = lteHelper->InstallUeDevice (ueNodes);
+
+ // Attach a UE to a eNB
+ lteHelper->Attach (ueDevs, enbDevs.Get (0));
+
+ Ptr<LteEnbNetDevice> lteEnbDev = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ();
+ Ptr<LteEnbPhy> enbPhy = lteEnbDev->GetPhy ();
+ enbPhy->SetAttribute ("TxPower", DoubleValue (30.0));
+ enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0));
+
+ // Set UEs' position and power
+ for (int i = 0; i < m_nUser; i++)
+ {
+ Ptr<ConstantPositionMobilityModel> mm = ueNodes.Get (i)->GetObject<ConstantPositionMobilityModel> ();
+ mm->SetPosition (Vector (m_dist.at(i), 0.0, 0.0));
+ Ptr<LteUeNetDevice> lteUeDev = ueDevs.Get (i)->GetObject<LteUeNetDevice> ();
+ Ptr<LteUePhy> uePhy = lteUeDev->GetPhy ();
+ uePhy->SetAttribute ("TxPower", DoubleValue (23.0));
+ uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0));
+ }
+
+ // Install the IP stack on the UEs
+ internet.Install (ueNodes);
+ Ipv4InterfaceContainer ueIpIface;
+ ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs));
+ // Assign IP address to UEs, and install applications
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ Ptr<Node> ueNode = ueNodes.Get (u);
+ // Set the default gateway for the UE
+ Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
+ ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
+ }
+
+// Activate an EPS bearer
+ enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
+ GbrQosInformation qos;
+ uint16_t mbrDl = 0;
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ mbrDl = mbrDl + m_packetSize.at(u);
+ }
+ mbrDl = mbrDl/ueNodes.GetN();
+ qos.gbrDl = (mbrDl + 32) * (1000/m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size
+ qos.gbrUl = 0;
+ qos.mbrDl = qos.gbrDl;
+ qos.mbrUl = 0;
+ EpsBearer bearer (q, qos);
+ lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ());
+
+ lteHelper->EnableMacTraces ();
+ lteHelper->EnableRlcTraces ();
+ lteHelper->EnablePdcpTraces ();
+
+ // Install downlind and uplink applications
+ uint16_t dlPort = 1234;
+ uint16_t ulPort = 2000;
+ PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort));
+ PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort));
+ ApplicationContainer clientApps;
+ ApplicationContainer serverApps;
+ for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
+ {
+ ++ulPort;
+ serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get(u))); // receive packets from remotehost
+ serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs
+
+ UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator
+ dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ dlClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ dlClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize.at(u)));
+
+ UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator
+ ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds(m_interval)));
+ ulClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
+ ulClient.SetAttribute ("PacketSize", UintegerValue(m_packetSize.at(u)));
+
+ clientApps.Add (dlClient.Install (remoteHost));
+ clientApps.Add (ulClient.Install (ueNodes.Get(u)));
+ }
+
+ serverApps.Start (Seconds (0.001));
+ clientApps.Start (Seconds (0.001));
+
+ double simulationTime = 1.0;
+ double tolerance = 0.1;
+ Simulator::Stop (Seconds (simulationTime));
+
+ Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
+ rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (simulationTime)));
+
+ Simulator::Run ();
+
+ /**
+ * Check that the assignation is done in a "token bank fair queue" manner
+ */
+ NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)");
+ std::vector <uint64_t> dlDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
+ NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / simulationTime << " ref " << m_nUser);
+ }
+
+ for (int i = 0; i < m_nUser; i++)
+ {
+ NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataRxed.at (i) / simulationTime, m_estThrTdTbfqDl.at(i), m_estThrTdTbfqDl.at(i) * tolerance, " Unfair Throughput!");
+ }
+
+ /**
+ * Check that the assignation in uplink is done in a round robin manner.
+ */
+
+ NS_LOG_INFO ("UL - Test with " << m_nUser);
+ std::vector <uint64_t> ulDataRxed;
+ for (int i = 0; i < m_nUser; i++)
+ {
+ // get the imsi
+ uint64_t imsi = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetImsi ();
+ // get the lcId
+ uint8_t lcId = ueDevs.Get (i)->GetObject<LteUeNetDevice> ()->GetRrc ()->GetLcIdVector ().at (0);
+ ulDataRxed.push_back (rlcStats->GetUlRxData (imsi, lcId));
+ NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " bytes rxed " << (double)ulDataRxed.at (i) << " thr " << (double)ulDataRxed.at (i) / simulationTime << " ref " << (double)m_estThrTdTbfqUl.at (i));
+ //NS_TEST_ASSERT_MSG_EQ_TOL ((double)ulDataRxed.at (i) / simulationTime, (double)m_estThrTdTbfqUl.at (i), (double)m_estThrTdTbfqUl.at (i) * tolerance, " Unfair Throughput!");
+ }
+ Simulator::Destroy ();
+
+}
+
+
+} // namespace ns3
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/test/lte-test-tdtbfq-ff-mac-scheduler.h Sun Aug 05 21:33:37 2012 -0300
@@ -0,0 +1,91 @@
+/* -*- 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: Marco Miozzo <marco.miozzo@cttc.es>,
+ * Nicola Baldo <nbaldo@cttc.es>
+ * Dizhi Zhou <dizhi.zhou@gmail.com>
+ */
+
+#ifndef LENA_TEST_TDTBFQ_FF_MAC_SCHEDULER_H
+#define LENA_TEST_TDTBFQ_FF_MAC_SCHEDULER_H
+
+#include "ns3/simulator.h"
+#include "ns3/test.h"
+
+
+namespace ns3 {
+
+
+/**
+* This system test program creates different test cases with a single eNB and
+* several UEs, all having the same Radio Bearer specification. In each test
+* case, the UEs see the same SINR from the eNB; different test cases are
+* implemented obtained by using different SINR values and different numbers of
+* UEs. The test consists on checking that the obtained throughput performance
+* is equal among users is consistent with the definition of token bank fair
+* queue scheduling
+*/
+class LenaTdTbfqFfMacSchedulerTestCase1 : public TestCase
+{
+public:
+ LenaTdTbfqFfMacSchedulerTestCase1 (uint16_t nUser, uint16_t nLc, uint16_t dist, double thrRefDl, double thrRefUl, uint16_t packetSize, uint16_t interval);
+ virtual ~LenaTdTbfqFfMacSchedulerTestCase1 ();
+
+private:
+ static std::string BuildNameString (uint16_t nUser, uint16_t dist);
+ virtual void DoRun (void);
+ uint16_t m_nUser;
+ uint16_t m_nLc;
+ uint16_t m_dist;
+ uint16_t m_packetSize; // byte
+ uint16_t m_interval; // ms
+ double m_thrRefDl;
+ double m_thrRefUl;
+};
+
+
+class LenaTdTbfqFfMacSchedulerTestCase2 : public TestCase
+{
+public:
+ LenaTdTbfqFfMacSchedulerTestCase2 (std::vector<uint16_t> dist, std::vector<uint32_t> estThrTdTbfqDl, std::vector<uint32_t> estThrTdTbfqUl, std::vector<uint16_t> packetSize, uint16_t interval);
+ virtual ~LenaTdTbfqFfMacSchedulerTestCase2 ();
+
+private:
+ static std::string BuildNameString (uint16_t nUser, std::vector<uint16_t> dist);
+ virtual void DoRun (void);
+ uint16_t m_nUser;
+ std::vector<uint16_t> m_dist;
+ std::vector<uint16_t> m_packetSize; // byte
+ uint16_t m_interval; // ms
+ std::vector<uint32_t> m_estThrTdTbfqDl;
+ std::vector<uint32_t> m_estThrTdTbfqUl;
+};
+
+
+class LenaTestTdTbfqFfMacSchedulerSuite : public TestSuite
+{
+public:
+ LenaTestTdTbfqFfMacSchedulerSuite ();
+};
+
+
+
+
+} // namespace ns3
+
+
+#endif /* LENA_TEST_TDTBFQ_FF_MAC_SCHEDULER_H */
--- a/src/lte/wscript Sun Jul 01 21:17:35 2012 -0300
+++ b/src/lte/wscript Sun Aug 05 21:33:37 2012 -0300
@@ -62,6 +62,8 @@
'model/tta-ff-mac-scheduler.cc',
'model/tdbet-ff-mac-scheduler.cc',
'model/fdbet-ff-mac-scheduler.cc',
+ 'model/fdtbfq-ff-mac-scheduler.cc',
+ 'model/tdtbfq-ff-mac-scheduler.cc',
'model/epc-gtpu-header.cc',
'model/trace-fading-loss-model.cc',
'model/epc-enb-application.cc',
@@ -86,6 +88,8 @@
'test/lte-test-tta-ff-mac-scheduler.cc',
'test/lte-test-tdbet-ff-mac-scheduler.cc',
'test/lte-test-fdbet-ff-mac-scheduler.cc',
+ 'test/lte-test-fdtbfq-ff-mac-scheduler.cc',
+ 'test/lte-test-tdtbfq-ff-mac-scheduler.cc',
'test/lte-test-earfcn.cc',
'test/lte-test-spectrum-value-helper.cc',
'test/lte-test-pathloss-model.cc',
@@ -168,13 +172,41 @@
'model/tta-ff-mac-scheduler.h',
'model/tdbet-ff-mac-scheduler.h',
'model/fdbet-ff-mac-scheduler.h',
+ 'model/fdtbfq-ff-mac-scheduler.h',
+ 'model/tdtbfq-ff-mac-scheduler.h',
'model/trace-fading-loss-model.h',
'model/epc-gtpu-header.h',
'model/epc-enb-application.h',
'model/epc-sgw-pgw-application.h',
+ 'test/lte-test-downlink-sinr.h',
+ 'test/lte-test-uplink-sinr.h',
+ 'test/lte-test-link-adaptation.h',
+ 'test/lte-test-interference.h',
+ 'test/lte-test-sinr-chunk-processor.h',
+ 'test/lte-test-ue-phy.h',
+ 'test/lte-test-rr-ff-mac-scheduler.h',
+ 'test/lte-test-pf-ff-mac-scheduler.h',
+ 'test/lte-test-fdmt-ff-mac-scheduler.h',
+ 'test/lte-test-tdmt-ff-mac-scheduler.h',
+ 'test/lte-test-tta-ff-mac-scheduler.h',
+ 'test/lte-test-tdbet-ff-mac-scheduler.h',
+ 'test/lte-test-fdbet-ff-mac-scheduler.h',
+ 'test/lte-test-fdtbfq-ff-mac-scheduler.h',
+ 'test/lte-test-tdtbfq-ff-mac-scheduler.h',
+ 'test/lte-test-phy-error-model.h',
+ 'test/lte-test-pathloss-model.h',
+ 'test/epc-test-gtpu.h',
+ 'test/lte-test-entities.h',
+ 'test/lte-simple-net-device.h',
+ 'test/lte-simple-helper.h',
+ 'test/lte-test-rlc-um-transmitter.h',
+ 'test/lte-test-rlc-am-transmitter.h',
+ 'test/lte-test-rlc-um-e2e.h',
+ 'test/lte-test-rlc-am-e2e.h',
'model/epc-tft.h',
'model/epc-tft-classifier.h',
'model/lte-mi-error-model.h',
+ 'test/lte-test-mimo.h'
]
if (bld.env['ENABLE_EXAMPLES']):