#include <nNetwork.h>
Public Member Functions | |
nPingAverager () | |
constructor | |
~nPingAverager () | |
destructor | |
operator REAL () const | |
conversion to number == GetPing() | |
REAL | GetPing () const |
returns the current best estimate for the ping | |
REAL | GetPingSnail () const |
returns the extremely longterm average ping | |
REAL | GetPingSlow () const |
returns the longterm average ping | |
REAL | GetPingFast () const |
returns the shortterm average ping | |
bool | IsSpiking () const |
returns whether a lag spike is currently in process | |
void | Timestep (REAL decay) |
lets all values decay, so they can be replaced by new ones | |
void | Add (REAL value, REAL weight) |
adds a value to the average | |
void | Add (REAL value) |
adds a value to the average | |
void | Reset () |
resets average to zero | |
nAverager const & | GetSnailAverager (void) const |
Gets extremely slow averager. | |
nPingAverager const & | GetSnailAverager (nAverager &snail) const |
Gets extremely slow averager. | |
nAverager const & | GetSlowAverager (void) const |
Gets slow, reliable averager. | |
nPingAverager const & | GetSlowAverager (nAverager &slow) const |
Gets slow, reliable averager. | |
nAverager const & | GetFastAverager (void) const |
Gets fast averager for detecting ping spikes. | |
nPingAverager const & | GetFastAverager (nAverager &fast) const |
Gets fast averager for detecting ping spikes. | |
Static Public Member Functions | |
static void | SetWeight (REAL const &weight) |
Sets the default statistical weight. | |
static REAL | GetWeight (void) |
Gets the default statistical weight. | |
static void | GetWeight (REAL &weight) |
Gets the default statistical weight. | |
Protected Member Functions | |
nPingAverager & | SetSnailAverager (nAverager const &snail) |
Sets very slow averager. | |
nPingAverager & | SetSlowAverager (nAverager const &slow) |
Sets slow, reliable averager. | |
nPingAverager & | SetFastAverager (nAverager const &fast) |
Sets fast averager for detecting ping spikes. | |
Private Attributes | |
nAverager | snail_ |
extremely slow averager | |
nAverager | slow_ |
slow, reliable averager | |
nAverager | fast_ |
fast averager for detecting ping spikes | |
Static Private Attributes | |
static REAL | weight_ = 1 |
current default weight |
Definition at line 269 of file nNetwork.h.
nPingAverager::nPingAverager | ( | void | ) |
nPingAverager::~nPingAverager | ( | void | ) |
nPingAverager::operator REAL | ( | void | ) | const |
conversion to number == GetPing()
Definition at line 3911 of file nNetwork.cpp.
REAL nPingAverager::GetPing | ( | void | ) | const |
returns the current best estimate for the ping
Definition at line 3856 of file nNetwork.cpp.
Referenced by GameLoop(), nServerLag::Ping(), eTimer::ReadSync(), and sn_GetTimeout().
03860 { 03861 // collect data 03862 // determine the lowest guessed value for variance. 03863 // lag spikes should not contribute here too much. 03864 REAL variance = 1; 03865 { 03866 REAL snailVariance = this->snail_.GetDataVariance(); 03867 REAL slowVariance = this->slow_.GetDataVariance(); 03868 REAL fastVariance = this->fast_.GetDataVariance(); 03869 variance = variance < snailVariance ? variance : snailVariance; 03870 variance = variance < slowVariance ? variance : slowVariance; 03871 variance = variance < fastVariance ? variance : fastVariance; 03872 } 03873 03874 REAL pingSnail = this->GetPingSnail(); 03875 REAL pingSlow = this->GetPingSlow(); 03876 REAL pingFast = this->GetPingFast(); 03877 03878 // the proposed return value: defaults to the snail ping, it flucuates the least 03879 REAL pingReturn = pingSnail; 03880 03881 // return slow average if that differs from the snail one by at least one standard deviation 03882 if ( ( pingSlow - pingReturn ) * ( pingSlow - pingReturn ) > variance ) 03883 { 03884 // but clamp it to sane values 03885 if ( pingSlow > pingReturn * 2 ) 03886 pingSlow = pingReturn * 2; 03887 03888 pingReturn = pingSlow; 03889 } 03890 03891 // same for fast ping 03892 if ( ( pingFast - pingReturn ) * ( pingFast - pingReturn ) > variance ) 03893 { 03894 if ( pingFast > pingReturn * 2 ) 03895 pingFast = pingReturn * 2; 03896 03897 pingReturn = pingFast; 03898 } 03899
REAL nPingAverager::GetPingSnail | ( | void | ) | const |
returns the extremely longterm average ping
Definition at line 3926 of file nNetwork.cpp.
REAL nPingAverager::GetPingSlow | ( | void | ) | const |
returns the longterm average ping
Definition at line 3941 of file nNetwork.cpp.
REAL nPingAverager::GetPingFast | ( | void | ) | const |
returns the shortterm average ping
Definition at line 3956 of file nNetwork.cpp.
bool nPingAverager::IsSpiking | ( | void | ) | const |
returns whether a lag spike is currently in process
Definition at line 3971 of file nNetwork.cpp.
void nPingAverager::Timestep | ( | REAL | decay | ) |
lets all values decay, so they can be replaced by new ones
decay | time since last timestep |
Definition at line 3987 of file nNetwork.cpp.
Referenced by ready_handler().
adds a value to the average
value | the value to add | |
weight | the value's statistical weight |
Definition at line 4005 of file nNetwork.cpp.
void nPingAverager::Add | ( | REAL | value | ) |
adds a value to the average
value | the value to add with default weight |
Definition at line 4023 of file nNetwork.cpp.
void nPingAverager::Reset | ( | void | ) |
void nPingAverager::SetWeight | ( | REAL const & | weight | ) | [inline, static] |
Sets the default statistical weight.
weight | the default statistical weight to set |
Definition at line 893 of file nNetwork.h.
References weight_.
Referenced by gGame::GameLoop(), and gGame::StateUpdate().
REAL nPingAverager::GetWeight | ( | void | ) | [inline, static] |
Gets the default statistical weight.
Definition at line 863 of file nNetwork.h.
References weight_.
00864 { 00865 return weight_; 00866 }
void nPingAverager::GetWeight | ( | REAL & | weight | ) | [inline, static] |
Gets the default statistical weight.
weight | the default statistical weight to fill |
Definition at line 878 of file nNetwork.h.
References weight_.
nAverager const & nPingAverager::GetSnailAverager | ( | void | ) | const [inline] |
Gets extremely slow averager.
Definition at line 908 of file nNetwork.h.
References snail_.
Referenced by sn_GetTimeout(), and gCycleMovement::TimestepCore().
00909 { 00910 return this->snail_; 00911 }
nPingAverager const & nPingAverager::GetSnailAverager | ( | nAverager & | snail | ) | const [inline] |
Gets extremely slow averager.
snail | very slow averager to fill |
Definition at line 924 of file nNetwork.h.
References snail_.
00925 { 00926 snail = this->snail_; 00927 return *this; 00928 }
nAverager const & nPingAverager::GetSlowAverager | ( | void | ) | const [inline] |
Gets slow, reliable averager.
Definition at line 956 of file nNetwork.h.
References slow_.
Referenced by GameLoop().
00957 { 00958 return this->slow_; 00959 }
nPingAverager const & nPingAverager::GetSlowAverager | ( | nAverager & | slow | ) | const [inline] |
Gets slow, reliable averager.
slow | slow, reliable averager to fill |
Definition at line 972 of file nNetwork.h.
References slow_.
00973 { 00974 slow = this->slow_; 00975 return *this; 00976 }
nAverager const & nPingAverager::GetFastAverager | ( | void | ) | const [inline] |
Gets fast averager for detecting ping spikes.
Definition at line 1005 of file nNetwork.h.
References fast_.
Referenced by eTimer::ReadSync().
01006 { 01007 return this->fast_; 01008 }
nPingAverager const & nPingAverager::GetFastAverager | ( | nAverager & | fast | ) | const [inline] |
Gets fast averager for detecting ping spikes.
fast | fast averager for detecting ping spikes to fill |
Definition at line 1021 of file nNetwork.h.
References fast_.
01022 { 01023 fast = this->fast_; 01024 return *this; 01025 }
nPingAverager & nPingAverager::SetSnailAverager | ( | nAverager const & | snail | ) | [inline, protected] |
Sets very slow averager.
snail | very slow averager to set |
Definition at line 941 of file nNetwork.h.
References snail_.
00942 { 00943 this->snail_ = snail; 00944 return *this; 00945 }
nPingAverager & nPingAverager::SetSlowAverager | ( | nAverager const & | slow | ) | [inline, protected] |
Sets slow, reliable averager.
slow | slow, reliable averager to set |
Definition at line 989 of file nNetwork.h.
References slow_.
00990 { 00991 this->slow_ = slow; 00992 return *this; 00993 }
nPingAverager & nPingAverager::SetFastAverager | ( | nAverager const & | fast | ) | [inline, protected] |
Sets fast averager for detecting ping spikes.
fast | fast averager for detecting ping spikes to set |
Definition at line 1038 of file nNetwork.h.
References fast_.
01039 { 01040 this->fast_ = fast; 01041 return *this; 01042 }
nAverager nPingAverager::snail_ [private] |
extremely slow averager
Definition at line 287 of file nNetwork.h.
Referenced by GetSnailAverager(), and SetSnailAverager().
nAverager nPingAverager::slow_ [private] |
slow, reliable averager
Definition at line 288 of file nNetwork.h.
Referenced by GetSlowAverager(), and SetSlowAverager().
nAverager nPingAverager::fast_ [private] |
fast averager for detecting ping spikes
Definition at line 289 of file nNetwork.h.
Referenced by GetFastAverager(), and SetFastAverager().
REAL nPingAverager::weight_ = 1 [static, private] |
current default weight
Definition at line 290 of file nNetwork.h.
Referenced by GetWeight(), and SetWeight().