|
|
|
@ -399,7 +399,7 @@ namespace tunnel
@@ -399,7 +399,7 @@ namespace tunnel
|
|
|
|
|
std::unique_lock<std::mutex> l(m_TestsMutex); |
|
|
|
|
m_Tests[msgID] = it; |
|
|
|
|
} |
|
|
|
|
auto msg = CreateDeliveryStatusMsg (msgID); |
|
|
|
|
auto msg = CreateTunnelTestMsg (msgID); |
|
|
|
|
auto outbound = it.first; |
|
|
|
|
auto s = shared_from_this (); |
|
|
|
|
msg->onDrop = [msgID, outbound, s]() |
|
|
|
@ -452,16 +452,23 @@ namespace tunnel
@@ -452,16 +452,23 @@ namespace tunnel
|
|
|
|
|
buf += 4; |
|
|
|
|
uint64_t timestamp = bufbe64toh (buf); |
|
|
|
|
|
|
|
|
|
if (!ProcessDeliveryStatus (msgID, timestamp)) |
|
|
|
|
{ |
|
|
|
|
if (m_LocalDestination) |
|
|
|
|
m_LocalDestination->ProcessDeliveryStatusMessage (msg); |
|
|
|
|
else |
|
|
|
|
LogPrint (eLogWarning, "Tunnels: Local destination doesn't exist, dropped"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TunnelPool::ProcessTunnelTest (std::shared_ptr<I2NPMessage> msg) |
|
|
|
|
{ |
|
|
|
|
const uint8_t * buf = msg->GetPayload (); |
|
|
|
|
uint32_t msgID = bufbe32toh (buf); |
|
|
|
|
buf += 4; |
|
|
|
|
uint64_t timestamp = bufbe64toh (buf); |
|
|
|
|
|
|
|
|
|
ProcessTunnelTest (msgID, timestamp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool TunnelPool::ProcessDeliveryStatus (uint32_t msgID, uint64_t timestamp) |
|
|
|
|
bool TunnelPool::ProcessTunnelTest (uint32_t msgID, uint64_t timestamp) |
|
|
|
|
{ |
|
|
|
|
decltype(m_Tests)::mapped_type test; |
|
|
|
|
bool found = false; |
|
|
|
@ -477,9 +484,9 @@ namespace tunnel
@@ -477,9 +484,9 @@ namespace tunnel
|
|
|
|
|
} |
|
|
|
|
if (found) |
|
|
|
|
{ |
|
|
|
|
int dlt = (int)((int64_t)i2p::util::GetMillisecondsSinceEpoch () - (int64_t)timestamp); |
|
|
|
|
LogPrint (eLogDebug, "Tunnels: Test of ", msgID, " successful. ", dlt, " milliseconds"); |
|
|
|
|
if (dlt < 0) |
|
|
|
|
int dlt = (int)((int64_t)i2p::util::GetSteadyMicroseconds () - (int64_t)timestamp); |
|
|
|
|
LogPrint (eLogDebug, "Tunnels: Test of ", msgID, " successful. ", dlt, " microseconds"); |
|
|
|
|
if (dlt < 0) // should not happen
|
|
|
|
|
dlt = 0; |
|
|
|
|
int numHops = 0; |
|
|
|
|
if (test.first) numHops += test.first->GetNumHops (); |
|
|
|
@ -493,7 +500,7 @@ namespace tunnel
@@ -493,7 +500,7 @@ namespace tunnel
|
|
|
|
|
int latency = 0; |
|
|
|
|
if (numHops) latency = dlt*test.first->GetNumHops ()/numHops; |
|
|
|
|
if (!latency) latency = dlt/2; |
|
|
|
|
test.first->AddLatencySample(latency); |
|
|
|
|
test.first->AddLatencySample (latency); |
|
|
|
|
} |
|
|
|
|
if (test.second) |
|
|
|
|
{ |
|
|
|
@ -503,7 +510,7 @@ namespace tunnel
@@ -503,7 +510,7 @@ namespace tunnel
|
|
|
|
|
int latency = 0; |
|
|
|
|
if (numHops) latency = dlt*test.second->GetNumHops ()/numHops; |
|
|
|
|
if (!latency) latency = dlt/2; |
|
|
|
|
test.second->AddLatencySample(latency); |
|
|
|
|
test.second->AddLatencySample (latency); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return found; |
|
|
|
|