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

View file

@ -1228,7 +1228,10 @@ test('#113 Red Sea Crisis wants traffic into Asia for a month, not broadband and
build(1);
ev("for(const n of NETS.filter(n=>n.price&&n.pops.includes('mrs')).slice(0,2))ACT.buyTransit({city:'mrs',net:n.id,tier:1});for(const c of ['sin','bom'])if(!S.pops[c].bb)ACT.launchBB({city:c});after()");
assert.ok(!ev('S.scn.done'));
let d = 0; while (!ev('S.scn.done') && d < 200) { ev('dayTick()'); d++; }
// Asian users backhauled to Marseille transit get slow service and would churn away; keep them subscribed,
// this is about the 30-day counter.
ev("window.__bb={sin:60,bom:60}");
let d = 0; while (!ev('S.scn.done') && d < 200) { ev('for(const c of ["sin","bom"])S.pops[c].bb.d=Math.max(S.pops[c].bb.d,__bb[c]);dayTick()'); d++; }
assert.ok(ev('S.scn.done'), 'won once 80 Gbps crossed into Asia for 30 days in a row');
assert.ok(d >= 30, `took ${d} days`);
assert.match(ev("scnProg().items.map(x=>x.l+' '+x.txt).join(' | ')"), /Days in a row at 80(\.0)? Gbps or more 30 \/ 30/);

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, []);
});

View file

@ -466,7 +466,9 @@ test('#70 Goggle throttling in Russia no longer counts as traffic you failed to
ev("ACT.start({});S.cash=1e9;S.lvl=4;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});ACT.buildPop({city:'mos'});ACT.launchBB({city:'mos'})");
ev("S.pops.fra.rgen=S.pops.mos.rgen=3;S.pops.fra.routers=S.pops.mos.routers=3;ACT.buyTransit({city:'fra',net:'cog',tier:4});ACT.lagT({id:S.transit[0].id,d:1});UI.via=null;UI.lmode='wave';openLinkModal('fra','mos');ACT.buildLink({tier:4});closeModal();S.pops.mos.bb.d=300;compute()");
assert.equal(ev('S.links.length'), 1);
assert.ok(ev("sfOf(R,'mos')") > 0.99, `Moscow is fully served (${ev("sfOf(R,'mos')")})`);
// (raw delivery: Moscow is backhauled to transit in Frankfurt, which its users feel as latency on top)
assert.ok(ev("R.citySrv.mos/R.cityDem.mos") > 0.99, `Moscow is fully served (${ev("R.citySrv.mos/R.cityDem.mos")})`);
assert.ok(ev("R.latF.mos") < 1, 'and slow, with transit 2,000 km away');
// demand toward Goggle is half of what it would be without the throttle
const g = ev("NSH_RU.ggl"), d0 = ev("R.cityEye.mos");
assert.ok(Math.abs(ev("R.cityDem.mos") - d0 * (1 - g / 2)) < 1e-6);