From 0cc8c203fa49ef43d02e5f8f864a4b8d0c2d43fe Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 18 Jun 2011 12:01:36 +0000 Subject: [PATCH] added test code for better dealing with error rate statistic initialization phase --- src/buffer.cpp | 45 +++++++++++++++++++++++++++++++-------------- src/buffer.h | 3 +++ src/util.h | 4 +++- 3 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/buffer.cpp b/src/buffer.cpp index 994abcab..032e0c41 100755 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -116,16 +116,16 @@ CNetBufWithStats::CNetBufWithStats() : { // define the sizes of the simulation buffers, // must be NUM_STAT_SIMULATION_BUFFERS elements! - viBufSizesForSim[0] = 2; - viBufSizesForSim[1] = 3; - viBufSizesForSim[2] = 4; - viBufSizesForSim[3] = 5; - viBufSizesForSim[4] = 6; - viBufSizesForSim[5] = 7; - viBufSizesForSim[6] = 8; - viBufSizesForSim[7] = 9; - viBufSizesForSim[8] = 10; - viBufSizesForSim[9] = 11; + viBufSizesForSim[0] = 2; + viBufSizesForSim[1] = 3; + viBufSizesForSim[2] = 4; + viBufSizesForSim[3] = 5; + viBufSizesForSim[4] = 6; + viBufSizesForSim[5] = 7; + viBufSizesForSim[6] = 8; + viBufSizesForSim[7] = 9; + viBufSizesForSim[8] = 10; + viBufSizesForSim[9] = 11; viBufSizesForSim[10] = 12; viBufSizesForSim[11] = 14; viBufSizesForSim[12] = 16; @@ -199,6 +199,26 @@ bool CNetBufWithStats::Get ( CVector& vecbyData ) // update auto setting UpdateAutoSetting(); + +// TEST +// sometimes in the very first period after a connection we get a bad error +// rate result -> delete this from the initialization phase +const double dInitState = + ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].InitializationState(); + +if ( dInitState < 0.2 ) +{ + if ( ( dInitState > 0.1 ) && + ( ErrorRateStatistic[NUM_STAT_SIMULATION_BUFFERS - 1].GetAverage() > ERROR_RATE_BOUND ) ) + { + for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS; i++ ) + { + ErrorRateStatistic[i].Reset(); + } + } +} + + return bGetOK; } @@ -207,9 +227,6 @@ void CNetBufWithStats::UpdateAutoSetting() int iCurDecision = 0; // dummy initialization bool bDecisionFound = false; - // definition of the error bound - const double dErrorBound = 0.0025; - // Get error rate decision ------------------------------------------------- // Use a specified error bound to identify the best buffer size for the @@ -218,7 +235,7 @@ void CNetBufWithStats::UpdateAutoSetting() for ( int i = 0; i < NUM_STAT_SIMULATION_BUFFERS - 1; i++ ) { if ( ( !bDecisionFound ) && - ( ErrorRateStatistic[i].GetAverage() <= dErrorBound ) ) + ( ErrorRateStatistic[i].GetAverage() <= ERROR_RATE_BOUND ) ) { iCurDecision = viBufSizesForSim[i]; bDecisionFound = true; diff --git a/src/buffer.h b/src/buffer.h index 1a21cc06..fb7f1711 100755 --- a/src/buffer.h +++ b/src/buffer.h @@ -34,6 +34,9 @@ // blocks we have 15 s / 2.66 ms * 2 = approx. 11000 #define MAX_STATISTIC_COUNT 11000 +// definition of the error bound +#define ERROR_RATE_BOUND 0.002 + // number of simulation network jitter buffers for evaluating the statistic #define NUM_STAT_SIMULATION_BUFFERS 13 diff --git a/src/util.h b/src/util.h index 192f7351..95590a90 100755 --- a/src/util.h +++ b/src/util.h @@ -281,7 +281,8 @@ public: } } - bool IsInitialized() { return ( this->iNorm == this->iVectorSize ); } + double InitializationState() const + { return static_cast ( this->iNorm ) / this->iVectorSize; } protected: int iCurIdx; @@ -803,6 +804,7 @@ public: } double GetAverage() { return ErrorsMovAvBuf.GetAverage(); } + double InitializationState() { return ErrorsMovAvBuf.InitializationState(); } protected: CMovingAv ErrorsMovAvBuf;