Far-away transit backhaul is slow, and slow is bad service

Each transit flow's backhaul round trip over your own links (2× the path
latency to the exit) now affects service: free up to 20 ms (~1,500 km),
up to 20% worse at 50 ms, and half the service value past 50 ms. sfOf()
multiplies delivery by it, so revenue, broadband growth and business
customers all feel it. Peering, PNIs and caches are exempt.

City panel chip and Transit-tab warning name the far exit and the round
trip; the NOC lists slow cities. Two tests updated: Moscow on Frankfurt
transit is still fully delivered but now slow, and the Red Sea test pins
Asian demand that would otherwise churn away on Marseille transit.
This commit is contained in:
Frederic Jung 2026-10-26 23:29:49 +01:00
parent 4643adb2ea
commit 68b3d0b839
No known key found for this signature in database
9 changed files with 111 additions and 14 deletions

54
tests/latency.test.js Normal file
View file

@ -0,0 +1,54 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { load } = require('./harness');
function setup(ev) {
ev("ACT.start({});S.cash=1e9;S.lvl=6;S.nextFail=S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0;for(const c of ['nyc','lon','ams'])ACT.buildPop({city:c});for(const c in S.pops)S.pops[c].rgen=3");
ev("UI.via='hibx';openLinkModal('lon','nyc');ACT.buildLink({tier:1});closeModal();UI.via=null;openLinkModal('fra','ams');ACT.buildLink({tier:1});closeModal()");
ev("ACT.launchBB({city:'lon'});S.pops.lon.bb.d=100;ACT.launchBB({city:'ams'});S.pops.ams.bb.d=100");
}
test('broadband backhauled to transit far away is slow, and slow is bad service', () => {
const { ev, errors } = load();
setup(ev);
ev("ACT.buyTransit({city:'nyc',net:'cog',tier:1});ACT.buyTransit({city:'fra',net:'cog',tier:1});compute()");
// London's only way out is transit in New York: everything is delivered, and it is all too slow
assert.ok(ev('R.citySrv.lon/R.cityDem.lon') > 0.95, 'delivered');
assert.ok(ev('R.latFar.lon.ms') > 50, `${ev('R.latFar.lon.ms')} ms round trip`);
assert.equal(ev('R.latFar.lon.to'), 'nyc');
assert.ok(ev("sfOf(R,'lon')") < 0.55, 'over 50 ms counts as bad service');
// Amsterdam goes out in Frankfurt, a few hundred kilometres away: fine
assert.equal(ev('R.latF.ams'), undefined);
assert.ok(ev("sfOf(R,'ams')") > 0.95);
// the panel and the NOC say so
ev("UI.sel={type:'city',id:'lon'};UI.tab='up';renderPanel()");
assert.match(ev("document.getElementById('panelBody').textContent"), /backhauled to transit in New York/);
ev("UI.sel=null;UI.left='noc';UI.leftOpen=true;renderLeft()");
assert.match(ev("document.getElementById('left').textContent"), /Slow cities/);
// bad service costs customers and money: broadband shrinks instead of growing
const d0 = ev('S.pops.lon.bb.d'), a0 = ev('S.pops.ams.bb.d');
for (let i = 0; i < 20; i++) ev('dayTick()');
assert.ok(ev('S.pops.lon.bb.d') < d0, 'London churns');
assert.ok(ev('S.pops.ams.bb.d') >= a0, 'Amsterdam does not');
// local transit fixes it
ev("ACT.buyTransit({city:'lon',net:'cog',tier:1});compute()");
assert.equal(ev('R.latF.lon'), undefined);
assert.ok(ev("sfOf(R,'lon')") > 0.95);
assert.deepEqual(errors, []);
});
test('the penalty is on a curve, and traffic that needs no transit is never penalised', () => {
const { ev, errors } = load();
assert.equal(ev('latLoss(15)'), 0);
assert.equal(ev('latLoss(20)'), 0);
assert.ok(Math.abs(ev('latLoss(35)') - 0.1) < 1e-9);
assert.ok(Math.abs(ev('latLoss(50)') - 0.2) < 1e-9);
assert.equal(ev('latLoss(51)'), 0.5);
setup(ev);
// London reaches an open network over peering in New York: far, but no transit, so no penalty
ev("const x=ixIdsIn('nyc')[0];ACT.buyIx({city:x,tier:1,signed:true});ACT.rs({city:x});compute()");
assert.ok(ev("Object.keys(R.netEg).some(n=>R.netEg[n].ix>0)"), 'traffic over the IX');
assert.equal(ev('R.latF.lon'), undefined);
assert.equal(ev("sfOf(R,'lon')"), ev("clamp(R.citySrv.lon/R.cityDem.lon,0,1)"));
assert.deepEqual(errors, []);
});