Browse Source

Merge pull request #1865 from wekoq/openssl

Add parameter for show TCSR with old algorithm and it's realization
pull/1867/head
orignal 2 years ago committed by GitHub
parent
commit
09a1a78bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      daemon/HTTPServer.cpp
  2. 1
      libi2pd/Config.cpp
  3. 3
      libi2pd/Tunnel.cpp
  4. 15
      libi2pd/Tunnel.h

5
daemon/HTTPServer.cpp

@ -289,6 +289,11 @@ namespace http { @@ -289,6 +289,11 @@ namespace http {
if (family.length () > 0)
s << "<b>"<< tr("Family") << ":</b> " << family << "<br>\r\n";
s << "<b>" << tr("Tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
bool isTotalTCSR;
i2p::config::GetOption("http.showTotalTCSR", isTotalTCSR);
if (isTotalTCSR) {
s << "<b>" << tr("Total tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTotalTunnelCreationSuccessRate() << "%<br/>\r\n";
}
s << "<b>" << tr("Received") << ":</b> ";
ShowTraffic (s, i2p::transport::transports.GetTotalReceivedBytes ());
s << " (" << tr(/* tr: Kibibyte/s */ "%.2f KiB/s", (double) i2p::transport::transports.GetInBandwidth15s () / 1024) << ")<br>\r\n";

1
libi2pd/Config.cpp

@ -95,6 +95,7 @@ namespace config { @@ -95,6 +95,7 @@ namespace config {
("http.hostname", value<std::string>()->default_value("localhost"), "Expected hostname for WebUI")
("http.webroot", value<std::string>()->default_value("/"), "WebUI root path (default: / )")
("http.lang", value<std::string>()->default_value("english"), "WebUI language (default: english )")
("http.showTotalTCSR", value<bool>()->default_value(false), "Show additional value with total TCSR since router's start (default: false)")
;
options_description httpproxy("HTTP Proxy options");

3
libi2pd/Tunnel.cpp

@ -332,7 +332,8 @@ namespace tunnel @@ -332,7 +332,8 @@ namespace tunnel
Tunnels tunnels;
Tunnels::Tunnels (): m_IsRunning (false), m_Thread (nullptr),
m_TunnelCreationSuccessRate (TCSR_START_VALUE), m_TunnelCreationAttemptsNum(0) {
m_TunnelCreationSuccessRate (TCSR_START_VALUE), m_TunnelCreationAttemptsNum(0),
m_TotalNumSuccesiveTunnelCreations (0), m_TotalNumFailedTunnelCreations (0) { // for normal avarage
}
Tunnels::~Tunnels ()

15
libi2pd/Tunnel.h

@ -269,15 +269,21 @@ namespace tunnel @@ -269,15 +269,21 @@ namespace tunnel
i2p::util::Queue<std::shared_ptr<I2NPMessage> > m_Queue;
i2p::util::MemoryPoolMt<I2NPMessageBuffer<I2NP_TUNNEL_ENPOINT_MESSAGE_SIZE> > m_I2NPTunnelEndpointMessagesMemoryPool;
i2p::util::MemoryPoolMt<I2NPMessageBuffer<I2NP_TUNNEL_MESSAGE_SIZE> > m_I2NPTunnelMessagesMemoryPool;
// count of tunnels for total TCSR algorithm
int m_TotalNumSuccesiveTunnelCreations, m_TotalNumFailedTunnelCreations;
// Calculating of tunnel creation success rate
// A modified version of the EWMA algorithm, where alpha is increased at the beginning to accelerate similarity
void SuccesiveTunnelCreation() {
// total TCSR
m_TotalNumSuccesiveTunnelCreations++;
// A modified version of the EWMA algorithm, where alpha is increased at the beginning to accelerate similarity
double alpha = TCSR_SMOOTHING_CONSTANT + (1 - TCSR_SMOOTHING_CONSTANT)/++m_TunnelCreationAttemptsNum;
m_TunnelCreationSuccessRate = alpha * 1 + (1 - alpha) * m_TunnelCreationSuccessRate;
};
void FailedTunnelCreation() {
m_TotalNumFailedTunnelCreations++;
double alpha = TCSR_SMOOTHING_CONSTANT + (1 - TCSR_SMOOTHING_CONSTANT)/++m_TunnelCreationAttemptsNum;
m_TunnelCreationSuccessRate = alpha * 0 + (1 - alpha) * m_TunnelCreationSuccessRate;
};
@ -297,6 +303,11 @@ namespace tunnel @@ -297,6 +303,11 @@ namespace tunnel
int GetQueueSize () { return m_Queue.GetSize (); };
int GetTunnelCreationSuccessRate () const { return std::round(m_TunnelCreationSuccessRate * 100); } // in percents
int GetTotalTunnelCreationSuccessRate () const // in percents
{
int totalNum = m_TotalNumSuccesiveTunnelCreations + m_TotalNumFailedTunnelCreations;
return totalNum ? m_TotalNumSuccesiveTunnelCreations*100/totalNum : 0;
}
};
extern Tunnels tunnels;

Loading…
Cancel
Save