RadioBearerStatsCalculator: handle end epoch via scheduled event
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Jaume Nin <jnin@cttc.es>
|
||||
* Nicola Baldo <nbaldo@cttc.es>
|
||||
*/
|
||||
|
||||
#include "radio-bearer-stats-calculator.h"
|
||||
@@ -59,8 +60,16 @@ RadioBearerStatsCalculator::GetTypeId (void)
|
||||
static TypeId tid =
|
||||
TypeId ("ns3::RadioBearerStatsCalculator")
|
||||
.SetParent<LteStatsCalculator> ().AddConstructor<RadioBearerStatsCalculator> ()
|
||||
.AddAttribute ("StartTime", "Start time of the on going epoch.", TimeValue (Seconds (0.)),MakeTimeAccessor (&RadioBearerStatsCalculator::m_startTime), MakeTimeChecker ())
|
||||
.AddAttribute ("EpochDuration", "Epoch duration.", TimeValue (Seconds (0.25)), MakeTimeAccessor (&RadioBearerStatsCalculator::m_epochDuration), MakeTimeChecker ())
|
||||
.AddAttribute ("StartTime", "Start time of the on going epoch.",
|
||||
TimeValue (Seconds (0.)),
|
||||
MakeTimeAccessor (&RadioBearerStatsCalculator::SetStartTime,
|
||||
&RadioBearerStatsCalculator::GetStartTime),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("EpochDuration", "Epoch duration.",
|
||||
TimeValue (Seconds (0.25)),
|
||||
MakeTimeAccessor (&RadioBearerStatsCalculator::GetEpoch,
|
||||
&RadioBearerStatsCalculator::SetEpoch),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("DlRlcOutputFilename",
|
||||
"Name of the file where the downlink results will be saved.",
|
||||
StringValue ("DlRlcStats.txt"),
|
||||
@@ -95,11 +104,36 @@ RadioBearerStatsCalculator::DoDispose ()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RadioBearerStatsCalculator::SetStartTime (Time t)
|
||||
{
|
||||
m_startTime = t;
|
||||
RescheduleEndEpoch ();
|
||||
}
|
||||
|
||||
Time
|
||||
RadioBearerStatsCalculator::GetStartTime () const
|
||||
{
|
||||
return m_startTime;
|
||||
}
|
||||
|
||||
void
|
||||
RadioBearerStatsCalculator::SetEpoch (Time e)
|
||||
{
|
||||
m_epochDuration = e;
|
||||
RescheduleEndEpoch ();
|
||||
}
|
||||
|
||||
Time
|
||||
RadioBearerStatsCalculator::GetEpoch () const
|
||||
{
|
||||
return m_epochDuration;
|
||||
}
|
||||
|
||||
void
|
||||
RadioBearerStatsCalculator::UlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << "UlTxPDU" << imsi << rnti << (uint32_t) lcid << packetSize);
|
||||
CheckEpoch ();
|
||||
ImsiLcidPair_t p (imsi, lcid);
|
||||
if (Simulator::Now () > m_startTime)
|
||||
{
|
||||
@@ -115,7 +149,6 @@ void
|
||||
RadioBearerStatsCalculator::DlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << "DlTxPDU" << imsi << rnti << (uint32_t) lcid << packetSize);
|
||||
CheckEpoch ();
|
||||
ImsiLcidPair_t p (imsi, lcid);
|
||||
if (Simulator::Now () > m_startTime)
|
||||
{
|
||||
@@ -133,8 +166,6 @@ RadioBearerStatsCalculator::UlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rn
|
||||
{
|
||||
NS_LOG_FUNCTION (this << "UlRxPDU" << imsi << rnti << (uint32_t) lcid << packetSize << delay);
|
||||
ImsiLcidPair_t p (imsi, lcid);
|
||||
CheckEpoch ();
|
||||
|
||||
if (Simulator::Now () > m_startTime)
|
||||
{
|
||||
m_ulCellId[p] = cellId;
|
||||
@@ -158,7 +189,6 @@ void
|
||||
RadioBearerStatsCalculator::DlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << "DlRxPDU" << imsi << rnti << (uint32_t) lcid << packetSize << delay);
|
||||
CheckEpoch ();
|
||||
ImsiLcidPair_t p (imsi, lcid);
|
||||
if (Simulator::Now () > m_startTime)
|
||||
{
|
||||
@@ -349,26 +379,22 @@ RadioBearerStatsCalculator::ResetResults (void)
|
||||
}
|
||||
|
||||
void
|
||||
RadioBearerStatsCalculator::CheckEpoch (void)
|
||||
RadioBearerStatsCalculator::RescheduleEndEpoch (void)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
if (Simulator::Now () > m_startTime + m_epochDuration)
|
||||
{
|
||||
ShowResults ();
|
||||
ResetResults ();
|
||||
StartEpoch ();
|
||||
}
|
||||
m_endEpochEvent.Cancel ();
|
||||
NS_ASSERT (Simulator::Now ().GetMilliSeconds () == 0); // below event time assumes this
|
||||
m_endEpochEvent = Simulator::Schedule (m_startTime + m_epochDuration, &RadioBearerStatsCalculator::EndEpoch, this);
|
||||
}
|
||||
|
||||
void
|
||||
RadioBearerStatsCalculator::StartEpoch (void)
|
||||
RadioBearerStatsCalculator::EndEpoch (void)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
while (Simulator::Now () > m_startTime + m_epochDuration)
|
||||
{
|
||||
m_startTime += m_epochDuration;
|
||||
}
|
||||
ShowResults ();
|
||||
ResetResults ();
|
||||
m_startTime += m_epochDuration;
|
||||
m_endEpochEvent = Simulator::Schedule (m_epochDuration, &RadioBearerStatsCalculator::EndEpoch, this);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Jaume Nin <jnin@cttc.es>
|
||||
* Nicola Baldo <nbaldo@cttc.es>
|
||||
*/
|
||||
|
||||
#ifndef RADIO_BEARER_STATS_CALCULATOR_H_
|
||||
@@ -49,8 +50,6 @@ typedef std::map<ImsiLcidPair_t, LteFlowId_t> FlowIdMap;
|
||||
* - Number of received bytes
|
||||
* - Average, min, max and standard deviation of RLC to RLC delay
|
||||
* - Average, min, max and standard deviation of RLC PDU size
|
||||
* TODO: Actual statistics calculation implies checking the time every time a packet is send or received so it is not very efficient. The epoch
|
||||
* implementation should be replaced by a timer to avoid this overhead.
|
||||
*/
|
||||
class RadioBearerStatsCalculator : public LteStatsCalculator
|
||||
{
|
||||
@@ -111,6 +110,31 @@ public:
|
||||
*/
|
||||
std::string GetDlPdcpOutputFilename (void);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* \param t the value of the StartTime attribute
|
||||
*/
|
||||
void SetStartTime (Time t);
|
||||
|
||||
/**
|
||||
*
|
||||
* \return the value of the StartTime attribute
|
||||
*/
|
||||
Time GetStartTime () const;
|
||||
|
||||
/**
|
||||
*
|
||||
* \param e the epoch duration
|
||||
*/
|
||||
void SetEpoch (Time e);
|
||||
|
||||
/**
|
||||
*
|
||||
* \return the epoch duration
|
||||
*/
|
||||
Time GetEpoch () const;
|
||||
|
||||
/**
|
||||
* Notifies the stats calculator that an uplink transmission has occurred.
|
||||
* @param cellId CellId of the attached Enb
|
||||
@@ -311,10 +335,11 @@ private:
|
||||
void
|
||||
ResetResults (void);
|
||||
|
||||
void
|
||||
StartEpoch (void);
|
||||
void
|
||||
CheckEpoch (void);
|
||||
void RescheduleEndEpoch ();
|
||||
|
||||
void EndEpoch (void);
|
||||
|
||||
EventId m_endEpochEvent;
|
||||
|
||||
FlowIdMap m_flowId;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#include "lte-test-mimo.h"
|
||||
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("LenaTestMimo");
|
||||
NS_LOG_COMPONENT_DEFINE ("LteTestMimo");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -66,14 +66,14 @@ LenaTestMimoSuite::LenaTestMimoSuite ()
|
||||
NS_LOG_INFO ("creating LenaMimoTestCase");
|
||||
|
||||
// RR DOWNLINK- DISTANCE 300
|
||||
// [0, 0.2] sec TxMode 0: MCS 20 -> TB size 1191
|
||||
// [0.2, 0.3] sec TxMode 1: MCS 26 -> TB size 1836
|
||||
// [0.3, 0.4] sec TxMode 2: MCS 18 -> TB size 967 (x2 layers)
|
||||
// interval 1 : [0.1, 0.2) sec TxMode 0: MCS 20 -> TB size 1191 bytes
|
||||
// interval 2 : [0.3, 0.4) sec TxMode 1: MCS 26 -> TB size 1836 bytes
|
||||
// interval 3 : [0.5, 0.6) sec TxMode 2: MCS 18 -> TB size 967 bytes (x2 layers)
|
||||
// -->
|
||||
std::vector<uint32_t> estThrDl;
|
||||
estThrDl.push_back (119100); // TTI 1 estimated throughput for TxMode 1
|
||||
estThrDl.push_back (183600); // TTI 2 estimated throughput for TxMode 2
|
||||
estThrDl.push_back (193400); // TTI 3 estimated throughput for TxMode 3
|
||||
estThrDl.push_back (119100); // interval 1 : estimated throughput for TxMode 1
|
||||
estThrDl.push_back (183600); // interval 2 : estimated throughput for TxMode 2
|
||||
estThrDl.push_back (193400); // interval 3 : estimated throughput for TxMode 3
|
||||
AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler", true));
|
||||
AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::PfFfMacScheduler", true));
|
||||
AddTestCase (new LenaMimoTestCase(300, estThrDl, "ns3::RrFfMacScheduler", false));
|
||||
@@ -187,7 +187,7 @@ LenaMimoTestCase::DoRun (void)
|
||||
// need to allow for RRC connection establishment + SRS before enabling traces
|
||||
lteHelper->EnableRlcTraces ();
|
||||
lteHelper->EnableMacTraces ();
|
||||
double simulationTime = 0.401;
|
||||
double simulationTime = 0.6;
|
||||
double tolerance = 0.1;
|
||||
|
||||
uint8_t rnti = 1;
|
||||
@@ -205,7 +205,7 @@ LenaMimoTestCase::DoRun (void)
|
||||
NS_FATAL_ERROR ("No RR Scheduler available");
|
||||
}
|
||||
Simulator::Schedule (Seconds (0.2), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 1);
|
||||
Simulator::Schedule (Seconds (0.3), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 2);
|
||||
Simulator::Schedule (Seconds (0.4), &RrFfMacScheduler::TransmissionModeConfigurationUpdate, rrsched, rnti, 2);
|
||||
}
|
||||
else if (m_schedulerType.compare ("ns3::PfFfMacScheduler") == 0)
|
||||
{
|
||||
@@ -216,7 +216,7 @@ LenaMimoTestCase::DoRun (void)
|
||||
}
|
||||
|
||||
Simulator::Schedule (Seconds (0.2), &PfFfMacScheduler::TransmissionModeConfigurationUpdate, pfsched, rnti, 1);
|
||||
Simulator::Schedule (Seconds (0.3), &PfFfMacScheduler::TransmissionModeConfigurationUpdate, pfsched, rnti, 2);
|
||||
Simulator::Schedule (Seconds (0.4), &PfFfMacScheduler::TransmissionModeConfigurationUpdate, pfsched, rnti, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -227,11 +227,8 @@ LenaMimoTestCase::DoRun (void)
|
||||
Ptr<RadioBearerStatsCalculator> rlcStats = lteHelper->GetRlcStats ();
|
||||
rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (0.1)));
|
||||
|
||||
/**
|
||||
* Check that the assignation is done in a RR fashion
|
||||
*/
|
||||
NS_LOG_INFO (m_schedulerType << " MIMO test:");
|
||||
double sampleTime = 0.2;
|
||||
double sampleTime = 0.199999; // at 0.2 RlcStats are reset
|
||||
for (uint8_t j = 0; j < m_estThrDl.size (); j ++)
|
||||
{
|
||||
NS_LOG_INFO ("\t test with user at distance " << m_dist << " time " << sampleTime);
|
||||
@@ -240,7 +237,7 @@ LenaMimoTestCase::DoRun (void)
|
||||
uint8_t lcId = 3;
|
||||
Time t = Seconds (sampleTime);
|
||||
Simulator::Schedule(t, &LenaMimoTestCase::GetRlcBufferSample, this, rlcStats, imsi, lcId);
|
||||
sampleTime += 0.1;
|
||||
sampleTime += 0.2;
|
||||
}
|
||||
Simulator::Stop (Seconds (simulationTime));
|
||||
Simulator::Run ();
|
||||
@@ -249,7 +246,7 @@ LenaMimoTestCase::DoRun (void)
|
||||
NS_LOG_INFO ("Check consistency");
|
||||
for (uint8_t i = 0; i < m_estThrDl.size (); i++)
|
||||
{
|
||||
NS_LOG_INFO ("\tTTI " << i + 1 << " bytes rxed " << (double)m_dlDataRxed.at (i) << " ref " << m_estThrDl.at (i));
|
||||
NS_LOG_INFO ("interval " << i + 1 << ": bytes rxed " << (double)m_dlDataRxed.at (i) << " ref " << m_estThrDl.at (i));
|
||||
NS_TEST_ASSERT_MSG_EQ_TOL ((double)m_dlDataRxed.at (i) , m_estThrDl.at (i), m_estThrDl.at (i) * tolerance, " Unfair Throughput!");
|
||||
}
|
||||
|
||||
@@ -260,7 +257,7 @@ void
|
||||
LenaMimoTestCase::GetRlcBufferSample (Ptr<RadioBearerStatsCalculator> rlcStats, uint64_t imsi, uint8_t lcId)
|
||||
{
|
||||
m_dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId));
|
||||
// NS_LOG_INFO ("\t get bytes " << m_dlDataRxed.at (m_dlDataRxed.size () - 1));
|
||||
NS_LOG_INFO (Simulator::Now () << "\t get bytes " << m_dlDataRxed.at (m_dlDataRxed.size () - 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user