lokinet/llarp/constants/path.hpp
Jason Rhinelander 823c17206f Add min intro set paths, slightly increase spread speed
This should ensure that we have enough shortly after startup for initial
path builds.

The spread speed here gets slightly increased to lifetime/5 (=4min)
instead of lifetime/4 (=5min) so that our "normal" number of paths is 5
with occassional momentary drops to 4, but should always keep us >= the
new minimum of 4.

Because the path spread happens over time, this shouldn't result in a
rebuild of several paths: we'll build 4 quickly, then another at +4m,
another at +8m, etc.  When the initial 4 expire, we'll be dropping from
9 to 5 established but that's still above the minimum (4) so we won't
need to reconnect to several at once, and the spread builds should keep
us at 5 all the time.
2020-03-01 12:37:43 -04:00

43 lines
1.4 KiB
C++

#ifndef LLARP_CONSTANTS_PATH_HPP
#define LLARP_CONSTANTS_PATH_HPP
#include <chrono>
#include <cstddef>
#include <util/types.hpp>
#include <util/time.hpp>
namespace llarp
{
namespace path
{
/// maximum path length
constexpr std::size_t max_len = 8;
/// default path length
constexpr std::size_t default_len = 4;
/// pad messages to the nearest this many bytes
constexpr std::size_t pad_size = 128;
/// default path lifetime in ms
static constexpr std::chrono::milliseconds default_lifetime = 20min;
/// minimum into lifetime we will advertise
static constexpr std::chrono::milliseconds min_intro_lifetime =
default_lifetime / 2;
/// spacing frequency at which we try to build paths for introductions
static constexpr std::chrono::milliseconds intro_path_spread =
default_lifetime / 5;
/// Minimum paths to keep around for intros; mainly used at startup (the
/// spread, above, should be able to maintain more than this number of paths
/// normally once things are going).
constexpr std::size_t min_intro_paths = 4;
/// after this many ms a path build times out
static constexpr auto build_timeout = 30s;
/// measure latency every this interval ms
static constexpr auto latency_interval = 5s;
/// if a path is inactive for this amount of time it's dead
static constexpr auto alive_timeout = 30s;
} // namespace path
} // namespace llarp
#endif