Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m47s
Foundation / checks (network) (push) Successful in 8m11s
Foundation / checks (client) (push) Successful in 12m20s
Foundation / checks (tsan) (push) Successful in 7m44s
Foundation / checks (checks) (push) Successful in 31m12s
Foundation / checks (postgres) (push) Successful in 33m27s
Foundation / image (push) Successful in 2m14s
Foundation / postgres-tools (push) Successful in 6m24s
Foundation / server-image (push) Successful in 18m6s
evo_network_quic wraps msquic in a single-owner Endpoint: newest-wins datagram channel and one length-framed reliable stream, both bounded, with explicit close causes. The client pins exactly one CA and name with an owned Mbed TLS check that is the sole authority (OpenSSL's verdict advisory), callbacks never call msquic under the lock, and MinimumMtu starts at 1280 so 1,200-byte datagrams fit minimum paths. An owned seeded UDP impairment relay drives loss, duplication, reordering, corruption, MTU and outage tests, passing on MSVC, GCC and Clang ASan/UBSan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.9 KiB
C++
44 lines
1.9 KiB
C++
#pragma once
|
|
// M10.2 owned UDP impairment relay (ADR-0090) for tests and measurements; never shipped.
|
|
// Listens on 127.0.0.1:<port> for one client and forwards to 127.0.0.1:<target>, applying
|
|
// seeded loss, duplication, reordering, delay/jitter, a payload-size (MTU) limit and
|
|
// corruption to each packet in each direction. Impairment decisions come from SplitMix64
|
|
// in packet order; wall-clock delivery times are not deterministic. Runs its own thread.
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <memory>
|
|
|
|
namespace evo::network::impair {
|
|
struct Impairment {
|
|
double loss{}; // Probability a packet is dropped.
|
|
double duplicate{}; // Probability a packet is sent twice.
|
|
double reorder{}; // Probability a packet is held back by `reorder_delay`.
|
|
double corrupt{}; // Probability one byte is flipped.
|
|
std::chrono::milliseconds delay{}, jitter{}, reorder_delay{10};
|
|
std::size_t max_payload{65507}; // Larger UDP payloads are dropped (path MTU).
|
|
};
|
|
struct RelayCounters {
|
|
std::uint64_t forwarded{}, dropped{}, duplicated{}, reordered{}, corrupted{}, oversized{};
|
|
};
|
|
class UdpRelay {
|
|
public:
|
|
// Upstream (client -> server) and downstream (server -> client) impairments.
|
|
[[nodiscard]] static std::unique_ptr<UdpRelay> start(std::uint16_t target_port,
|
|
Impairment upstream, Impairment downstream,
|
|
std::uint64_t seed);
|
|
UdpRelay(const UdpRelay&) = delete;
|
|
UdpRelay& operator=(const UdpRelay&) = delete;
|
|
~UdpRelay();
|
|
[[nodiscard]] std::uint16_t port() const noexcept;
|
|
// Changes impairments while running (e.g. a total outage to exercise idle timeout).
|
|
void set(Impairment upstream, Impairment downstream);
|
|
[[nodiscard]] RelayCounters counters() const;
|
|
|
|
struct Impl;
|
|
|
|
private:
|
|
explicit UdpRelay(std::unique_ptr<Impl> impl);
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
} // namespace evo::network::impair
|