mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
Add parameter for show TCSR with old algorithm and it's realization
This commit is contained in:
parent
89695a7040
commit
22b1066b0a
|
@ -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 isOldTCSR;
|
||||
i2p::config::GetOption("http.old_tcsr", isOldTCSR);
|
||||
if (isOldTCSR) {
|
||||
s << "<b>" << tr("Tunnel creation success rate (old algorithm)") << ":</b> " << i2p::tunnel::tunnels.OldGetTunnelCreationSuccessRate() << "%<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";
|
||||
|
|
|
@ -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.old_tcsr", value<bool>()->default_value(false), "Show TCSR with old algorithm (default: false)")
|
||||
;
|
||||
|
||||
options_description httpproxy("HTTP Proxy options");
|
||||
|
|
|
@ -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_OldNumSuccesiveTunnelCreations (0), m_OldNumFailedTunnelCreations (0) {
|
||||
}
|
||||
|
||||
Tunnels::~Tunnels ()
|
||||
|
@ -634,6 +635,7 @@ namespace tunnel
|
|||
// delete
|
||||
it = pendingTunnels.erase (it);
|
||||
FailedTunnelCreation();
|
||||
m_OldNumFailedTunnelCreations++;
|
||||
}
|
||||
else
|
||||
++it;
|
||||
|
@ -642,6 +644,7 @@ namespace tunnel
|
|||
LogPrint (eLogDebug, "Tunnel: Pending build request ", it->first, " failed, deleted");
|
||||
it = pendingTunnels.erase (it);
|
||||
FailedTunnelCreation();
|
||||
m_OldNumFailedTunnelCreations++;
|
||||
break;
|
||||
case eTunnelStateBuildReplyReceived:
|
||||
// intermediate state, will be either established of build failed
|
||||
|
@ -651,6 +654,7 @@ namespace tunnel
|
|||
// success
|
||||
it = pendingTunnels.erase (it);
|
||||
SuccesiveTunnelCreation();
|
||||
m_OldNumSuccesiveTunnelCreations++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,9 @@ 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;
|
||||
|
||||
// some old stats
|
||||
int m_OldNumSuccesiveTunnelCreations, m_OldNumFailedTunnelCreations;
|
||||
|
||||
// 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() {
|
||||
|
@ -297,6 +299,11 @@ namespace tunnel
|
|||
|
||||
int GetQueueSize () { return m_Queue.GetSize (); };
|
||||
int GetTunnelCreationSuccessRate () const { return std::round(m_TunnelCreationSuccessRate * 100); } // in percents
|
||||
int OldGetTunnelCreationSuccessRate () const // in percents
|
||||
{
|
||||
int totalNum = m_OldNumSuccesiveTunnelCreations + m_OldNumFailedTunnelCreations;
|
||||
return totalNum ? m_OldNumSuccesiveTunnelCreations*100/totalNum : 0;
|
||||
}
|
||||
};
|
||||
|
||||
extern Tunnels tunnels;
|
||||
|
|
Loading…
Reference in a new issue