fix latency tests.

* do FEC for latency tests so if we fail one test it doesn't kill the entire path
* ignore FEC'd responses on latency tests
* track latency history and report the mean latency instead of just the last sample
pull/1658/head
Jeff Becker 3 years ago
parent 691390edff
commit 174e1b247b
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -418,6 +418,9 @@ namespace llarp
m_LastLatencyTestTime = now;
SendRoutingMessage(latency, r);
FlushUpstream(r);
// reset ID so we don't mark ourself as dead if we drop a latency sample
r->loop()->call_later(
1s, [self = shared_from_this()]() { self->m_LastLatencyTestID = 0; });
return;
}
dlt = now - m_LastRecvMessage;
@ -682,6 +685,20 @@ namespace llarp
return m_DataHandler && m_DataHandler(shared_from_this(), frame);
}
template <typename Samples_t>
static llarp_time_t
computeLatency(const Samples_t& samps)
{
llarp_time_t mean = 0s;
if (samps.empty())
return mean;
for (const auto& samp : samps)
mean += samp;
return mean / samps.size();
}
constexpr auto MaxLatencySamples = 8;
bool
Path::HandlePathLatencyMessage(const routing::PathLatencyMessage& msg, AbstractRouter* r)
{
@ -689,17 +706,19 @@ namespace llarp
MarkActive(now);
if (msg.L == m_LastLatencyTestID)
{
intro.latency = now - m_LastLatencyTestTime;
m_LatencySamples.emplace_back(now - m_LastLatencyTestTime);
while (m_LatencySamples.size() > MaxLatencySamples)
m_LatencySamples.pop_front();
intro.latency = computeLatency(m_LatencySamples);
m_LastLatencyTestID = 0;
EnterState(ePathEstablished, now);
if (m_BuiltHook)
m_BuiltHook(shared_from_this());
m_BuiltHook = nullptr;
return true;
}
LogWarn("unwarranted path latency message via ", Upstream());
return false;
return true;
}
/// this is the Client's side of handling a DHT message. it's handled

@ -424,7 +424,7 @@ namespace llarp
uint64_t m_RXRate = 0;
uint64_t m_LastTXRate = 0;
uint64_t m_TXRate = 0;
std::deque<llarp_time_t> m_LatencySamples;
const std::string m_shortName;
};
} // namespace path

Loading…
Cancel
Save