2020-05-20 21:00:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/router_id.hpp>
|
|
|
|
#include <llarp/util/status.hpp>
|
|
|
|
#include <llarp/util/time.hpp>
|
2020-05-20 21:00:10 +00:00
|
|
|
|
|
|
|
/// Types stored in our peerstats database are declared here
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
// Struct containing stats we know about a peer
|
|
|
|
struct PeerStats
|
|
|
|
{
|
2020-06-01 16:29:24 +00:00
|
|
|
RouterID routerId;
|
2020-05-20 21:00:10 +00:00
|
|
|
|
|
|
|
int32_t numConnectionAttempts = 0;
|
|
|
|
int32_t numConnectionSuccesses = 0;
|
|
|
|
int32_t numConnectionRejections = 0;
|
|
|
|
int32_t numConnectionTimeouts = 0;
|
|
|
|
|
|
|
|
int32_t numPathBuilds = 0;
|
|
|
|
int64_t numPacketsAttempted = 0;
|
|
|
|
int64_t numPacketsSent = 0;
|
|
|
|
int64_t numPacketsDropped = 0;
|
|
|
|
int64_t numPacketsResent = 0;
|
|
|
|
|
|
|
|
int32_t numDistinctRCsReceived = 0;
|
|
|
|
int32_t numLateRCs = 0;
|
|
|
|
|
|
|
|
double peakBandwidthBytesPerSec = 0;
|
2020-06-01 15:26:31 +00:00
|
|
|
llarp_time_t longestRCReceiveInterval = 0ms;
|
|
|
|
llarp_time_t leastRCRemainingLifetime = 0ms;
|
|
|
|
llarp_time_t lastRCUpdated = 0ms;
|
2020-05-20 21:00:10 +00:00
|
|
|
|
2020-05-28 16:03:07 +00:00
|
|
|
// not serialized
|
|
|
|
bool stale = true;
|
|
|
|
|
2020-05-21 16:35:34 +00:00
|
|
|
PeerStats();
|
2020-05-20 21:00:10 +00:00
|
|
|
PeerStats(const RouterID& routerId);
|
|
|
|
|
|
|
|
PeerStats&
|
|
|
|
operator+=(const PeerStats& other);
|
|
|
|
bool
|
2020-06-25 23:23:37 +00:00
|
|
|
operator==(const PeerStats& other) const;
|
2020-05-27 21:00:09 +00:00
|
|
|
|
|
|
|
util::StatusObject
|
|
|
|
toJson() const;
|
2020-07-09 19:06:31 +00:00
|
|
|
|
|
|
|
void
|
2020-07-20 19:48:57 +00:00
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
static void
|
|
|
|
BEncodeList(const std::vector<PeerStats>& statsList, llarp_buffer_t* buf);
|
2020-05-20 21:00:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llarp
|