|
|
|
|
@ -54,8 +54,6 @@ def serve(address):
|
|
|
|
|
samples.append((time.monotonic() - started) * 1000) |
|
|
|
|
observed = reply["observed"] |
|
|
|
|
break |
|
|
|
|
else: |
|
|
|
|
pass |
|
|
|
|
if len(samples) + lost < _ + 1: |
|
|
|
|
lost += 1 |
|
|
|
|
print(json.dumps({"samples_ms": samples, "observed": observed, "lost": lost}), flush=True) |
|
|
|
|
@ -90,8 +88,14 @@ class Probes:
|
|
|
|
|
return json.loads(line) |
|
|
|
|
|
|
|
|
|
def calibrate(self): |
|
|
|
|
results = {"wan": [], "nat": []} |
|
|
|
|
results = {"lan": [], "wan": [], "nat": []} |
|
|
|
|
public = {n.country: n for n in NODES if not n.nat and n.client_type == 0} |
|
|
|
|
for country, first in public.items(): |
|
|
|
|
second = next(n for n in NODES if n.country == country and not n.nat and n.name != first.name) |
|
|
|
|
result = self.exchange(first.name, second.ip, count=20) |
|
|
|
|
if len(result["samples_ms"]) < 19 or statistics.median(result["samples_ms"]) > 10: |
|
|
|
|
raise RuntimeError(f"LAN {country}: measured connection is not a good local link: {result}") |
|
|
|
|
results["lan"].append(dict(result, country=country, median_ms=statistics.median(result["samples_ms"]))) |
|
|
|
|
for link in WANS: |
|
|
|
|
result = self.exchange(public[link.a].name, public[link.b].ip, count=40) |
|
|
|
|
if len(result["samples_ms"]) < 30: |
|
|
|
|
|