ZaStoGram_desktop/Telegram/SourceFiles/mtproto/web_proxy/web_proxy_selftest.h
loop-uh 84e2237558
All checks were successful
Desktop source guards / guards (push) Successful in 6s
Rework the WEB proxy data path around measured limits
A stand (test relay with a sink/echo backend, WAN emulator, env-gated
self-test in the client) showed the dev-17 limits, not the relay, capping
throughput: a fixed 1 MiB upload window and 2 MiB download credit, plus
2 file sessions per DC, while every bridge write waited for its own
round trip through the WebView.

- Bridge: frames written in one carrier turn go to the page as one
  batch, up to 4 page calls are in flight, and the injected script
  joins the frames the page posts in one task into one message.
- Windows: the upload window and the shared download credit follow the
  bandwidth-delay product of the credit loop plus 100 ms of queue
  (AdaptiveWindow), with a periodic drain to keep the base honest, a
  per-direction share when both are busy, and a hold while new streams'
  initial credit floods the relay's downlink.
- Upload and download session counts are upstream's again; upload
  frames shrink with a small window.
- Media sessions over MTProxy and WEB drop a regular temporary key
  borrowed from their DC and use the media cluster key: the regular key
  sent to a -N DC was answered with -404 and destroyed in a loop.
- web_carrier summaries report windows, rates, delays and bridge stats.
2026-09-24 03:18:20 +03:00

39 lines
1.4 KiB
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "mtproto/proxy/data.h"
#include <optional>
// A throughput and latency self-test of the WEB proxy data path, for a
// test relay whose backend is a sink / source / echo server instead of an
// MTProxy (see the stand next to the relay sources). It is enabled only by
//
// TDESKTOP_WEB_PROXY_SELFTEST=host:secret[:up=MB][:down=MB][:ul=N][:dl=N]
// [:ctl=PATH:net=A|B|...]
//
// With ctl and net the whole run is repeated once per network condition:
// before each round the condition string is written to the ctl file, for
// the stand's WAN emulator to pick up (e.g. "100 400000 4000000" for a
// 100 ms round trip, 400 KB/s up and 4 MB/s down).
//
// and then selects that proxy for this run, waits for the carrier and drives
// synthetic streams through the real Transport, WebView bridge and relay:
// idle pings, upload, download, both at once, pinging an interactive echo
// stream every 100 ms the whole time. Results go to the main log with the
// "Web Proxy SelfTest" prefix.
namespace MTP::WebProxy {
[[nodiscard]] std::optional<ProxyData> SelfTestProxy();
// Main thread, after the proxy is active.
void StartSelfTest();
} // namespace MTP::WebProxy