--- a/src/lte/model/rr-ff-mac-scheduler.cc Fri Jun 17 17:15:35 2011 +0200
+++ b/src/lte/model/rr-ff-mac-scheduler.cc Fri Jun 17 17:32:20 2011 +0200
@@ -208,7 +208,8 @@
RrFfMacScheduler::RrFfMacScheduler ()
: m_cschedSapUser (0),
m_schedSapUser (0),
- m_schedTtiDelay (2), // WILD ACK: based on a m_macChTtiDelay = 1
+ m_schedTtiDelay (2),
+ // WILD ACK: based on a m_macChTtiDelay = 1
m_nextRntiDl (0),
m_nextRntiUl (0)
{
@@ -371,7 +372,7 @@
void
RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params)
{
- NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf>>4) << " subframe no. " << (0xF & params.m_sfnSf));
+ 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
// Get the actual active flows (queue!=0)
@@ -394,7 +395,7 @@
// CQI == 0 means "out of range" (see table 7.2.3-1 of 36.213)
nflows++;
itLcRnti = lcActivesPerRnti.find ((*it).m_rnti);
- if (itLcRnti!=lcActivesPerRnti.end ())
+ if (itLcRnti != lcActivesPerRnti.end ())
{
(*itLcRnti).second++;
}
@@ -406,7 +407,7 @@
}
}
}
-
+
if (nflows == 0)
{
return;
@@ -426,17 +427,17 @@
// round robin assignment to all UE-LC registered starting from the subsequent of the one
// served last scheduling trigger
//NS_LOG_DEBUG (this << " next to be served " << m_nextRntiDl << " nflows " << nflows);
- if (m_nextRntiDl!=0)
+ if (m_nextRntiDl != 0)
{
for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
{
- if ((*it).m_rnti == m_nextRntiDl)
- {
- break;
- }
+ if ((*it).m_rnti == m_nextRntiDl)
+ {
+ break;
+ }
}
-
- if (it == m_rlcBufferReq.end ())
+
+ if (it == m_rlcBufferReq.end ())
{
NS_LOG_ERROR (this << " no user found");
}
@@ -449,17 +450,17 @@
do
{
itLcRnti = lcActivesPerRnti.find ((*it).m_rnti);
- if (itLcRnti==lcActivesPerRnti.end ())
- {
- // skip this entry
- it++;
- if (it==m_rlcBufferReq.end ())
- {
- // restart from the first
- it = m_rlcBufferReq.begin ();
- }
- continue;
- }
+ if (itLcRnti == lcActivesPerRnti.end ())
+ {
+ // skip this entry
+ it++;
+ if (it == m_rlcBufferReq.end ())
+ {
+ // restart from the first
+ it = m_rlcBufferReq.begin ();
+ }
+ continue;
+ }
int lcNum = (*itLcRnti).second;
// create new BuildDataListElement_s for this RNTI
BuildDataListElement_s newEl;
@@ -492,7 +493,7 @@
newRlcEl.m_size = rlcPduSize;
newRlcPduLe.push_back (newRlcEl);
it++;
- if (it==m_rlcBufferReq.end ())
+ if (it == m_rlcBufferReq.end ())
{
// restart from the first
it = m_rlcBufferReq.begin ();
@@ -527,7 +528,8 @@
m_nextRntiDl = (*it).m_rnti; // store last RNTI served
break; // no more RGB to be allocated
}
- } while ((*it).m_rnti != m_nextRntiDl);
+ }
+ while ((*it).m_rnti != m_nextRntiDl);
ret.m_nrOfPdcchOfdmSymbols = 1; // TODO: check correct value according the DCIs txed
@@ -585,56 +587,56 @@
void
RrFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
{
- NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf>>4) << " subframe no. " << (0xF & params.m_sfnSf));
+ NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf >> 4) << " subframe no. " << (0xF & params.m_sfnSf));
-
+
std::map <uint16_t,uint8_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++;
- }
+ {
+ nflows++;
+ }
}
-
- if (nflows==0)
- {
- return ; // no flows to be scheduled
- }
-
-
+
+ if (nflows == 0)
+ {
+ return ; // no flows to be scheduled
+ }
+
+
// Divide the resource equally among the active users starting from the subsequent one served last scheduling trigger
int rbPerFlow = m_cschedCellConfig.m_ulBandwidth / nflows;
if (rbPerFlow == 0)
- {
- rbPerFlow = 1; // at least 1 rbg per flow (till available resource)
- }
+ {
+ rbPerFlow = 1; // at least 1 rbg per flow (till available resource)
+ }
int rbAllocated = 0;
-
+
FfMacSchedSapUser::SchedUlConfigIndParameters ret;
std::vector <uint16_t> rbgAllocationMap;
- if (m_nextRntiUl!=0)
+ if (m_nextRntiUl != 0)
{
for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
{
- if ((*it).first == m_nextRntiUl)
+ if ((*it).first == m_nextRntiUl)
{
break;
}
}
- if (it == m_ceBsrRxed.end ())
- {
- NS_LOG_ERROR (this << " no user found");
- }
+ if (it == m_ceBsrRxed.end ())
+ {
+ NS_LOG_ERROR (this << " no user found");
+ }
}
else
- {
- it = m_ceBsrRxed.begin ();
- m_nextRntiUl = (*it).first;
- }
+ {
+ it = m_ceBsrRxed.begin ();
+ m_nextRntiUl = (*it).first;
+ }
do
{
if (rbAllocated + rbPerFlow > m_cschedCellConfig.m_ulBandwidth)
@@ -642,10 +644,10 @@
// limit to physical resources last resource assignment
rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
}
- // store info on allocation for managing ul-cqi interpretation
+ // store info on allocation for managing ul-cqi interpretation
for (int i = 0; i < rbPerFlow; i++)
{
- rbgAllocationMap.push_back ((*it).first);
+ rbgAllocationMap.push_back ((*it).first);
}
UlDciListElement_s uldci;
uldci.m_rnti = (*it).first;
@@ -656,33 +658,33 @@
int cqi = 0;
if (itCqi == m_ueCqi.end ())
{
- // no cqi info about this UE
+ // 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);
- for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
- {
- //NS_LOG_DEBUG (this << " UE " << (*it).first << " has CQI " << (*itCqi).second.at(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) ));
-
-
+ // take the lowest CQI value (worst RB)
+ double minSinr = (*itCqi).second.at (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 CQI " << (*itCqi).second.at(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 = LteAmc::GetCqiFromSpectralEfficiency (s);
if (cqi == 0)
{
it++;
- if (it==m_ceBsrRxed.end ())
+ if (it == m_ceBsrRxed.end ())
{
// restart from the first
it = m_ceBsrRxed.begin ();
@@ -691,7 +693,7 @@
}
uldci.m_mcs = LteAmc::GetMcsFromCqi (cqi);
//NS_LOG_DEBUG (this << " UE " << (*it).first << " minsinr " << minSinr << " -> mcs " << (uint16_t)uldci.m_mcs);
-
+
}
uldci.m_tbSize = (LteAmc::GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8); // MCS 0 -> UL-AMC TBD
// NS_LOG_DEBUG (this << " 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);
@@ -709,7 +711,7 @@
uldci.m_pdcchPowerOffset = 0; // not used
ret.m_dciList.push_back (uldci);
it++;
- if (it==m_ceBsrRxed.end ())
+ if (it == m_ceBsrRxed.end ())
{
// restart from the first
it = m_ceBsrRxed.begin ();
@@ -720,7 +722,8 @@
m_nextRntiUl = (*it).first;
break;
}
- } while ((*it).first != m_nextRntiUl);
+ }
+ 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;
@@ -746,30 +749,30 @@
RrFfMacScheduler::DoSchedUlMacCtrlInfoReq (const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params)
{
NS_LOG_FUNCTION (this);
-
+
std::map <uint16_t,uint8_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 bsr = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0);
- m_ceBsrRxed.insert( std::pair<uint16_t, uint8_t > (rnti, bsr)); // only 1 buffer status is working now
- }
- else
- {
- // update the CQI value
- (*it).second = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0);
- }
+ 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 bsr = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0);
+ m_ceBsrRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, bsr)); // only 1 buffer status is working now
+ }
+ else
+ {
+ // update the CQI value
+ (*it).second = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (0);
+ }
+ }
}
- }
-
+
return;
}
@@ -783,9 +786,9 @@
uint32_t subframeNo = (0xF & params.m_sfnSf);
//NS_LOG_DEBUG (this << " sfn " << frameNo << " sbfn " << subframeNo);
if (subframeNo - m_schedTtiDelay < 0)
- {
- frameNo--;
- }
+ {
+ frameNo--;
+ }
subframeNo = (subframeNo - m_schedTtiDelay) % 10;
//NS_LOG_DEBUG (this << " Actual sfn " << frameNo << " sbfn " << subframeNo);
uint16_t sfnSf = ((0xFF & frameNo) << 4) | (0xF & subframeNo);
@@ -793,43 +796,43 @@
std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
std::map <uint16_t, std::vector <double> >::iterator itCqi;
itMap = m_allocationMaps.find (sfnSf);
- if (itMap == m_allocationMaps.end())
- {
- NS_LOG_DEBUG (this << " Does not find info on allocation");
- return;
- }
+ if (itMap == m_allocationMaps.end ())
+ {
+ NS_LOG_DEBUG (this << " Does not find info on allocation");
+ return;
+ }
for (uint32_t i = 0; i < (*itMap).second.size (); i++)
{
- // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
- 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 maximum value according to the fixed point notation
- newCqi.push_back (30.0);
- }
-
- }
- m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
- }
- else
- {
- // update the value
- (*itCqi).second.at (i) = sinr;
- }
-
- }
+ // convert from fixed point notation Sxxxxxxxxxxx.xxx to double
+ 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 maximum value according to the fixed point notation
+ newCqi.push_back (30.0);
+ }
+
+ }
+ m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
+ }
+ else
+ {
+ // update the value
+ (*itCqi).second.at (i) = sinr;
+ }
+
+ }
// remove obsolete info on allocation
m_allocationMaps.erase (m_allocationMaps.begin (), ++itMap);