From ad9aabb2657631520356589cf13c8d49074b8e2f Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 4 Nov 2026 08:03:10 +0000 Subject: [PATCH] Follow-ups to #271 - IX ports are measured at their nominal capacity: a LACP fault or one building down no longer buys a bigger port for a day or two. - The order stops before working anything out when its budget is spent (31 ms a day to 0.05 ms on the big network at 3x), and a port that takes a LAG no longer prices every upgrade first. - The log names the exchange, not its city. - Tests for the LACP case and a remote IX port; a test comment's numbers; a shorter CHANGELOG bullet that no longer promises a per-POP switch for remote ports. --- CHANGELOG.md | 2 +- src/game/60-features/95-standing-orders.js | 13 +++++----- tests/intern-ports.test.js | 29 +++++++++++++++++++++- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da8ae76..60338a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] -- The NOC intern has a new order, Keep peering headroom, that adds capacity to your PNI and IX ports before they fill up (#234). A single port at a POP with several routers gets a second port in a LAG, so no router is its only way out; any other port moves up to the smallest port size that fits. It has the same Headroom and Budget dials as the transit order, can be switched off per POP, waits out a DDoS flood instead of buying ports for it, and a PNI with an augment already on order waits for it to land. The monthly figure in the intern's log now counts IX ports too. +- The NOC intern has a new order, Keep peering headroom, that adds capacity to your PNI and IX ports before they fill up (#234). A single port at a POP with several routers gets a second port in a LAG; any other port moves up to the smallest size that fits. It has the same Headroom and Budget dials as the transit order, and it waits out DDoS floods, link faults and PNI augments already on order. The monthly figure in the intern's log now counts IX ports too. - Latency customers only ask for a ceiling something you can build meets. Before, a Mars ground station could ask for 4.3 ms between Pevek and Anadyr, where the only sea route takes 7.7 ms at best. (#273) - Money now shows billions (`$1.20B`) and bandwidth shows petabits (`1.00 Pbps`) instead of running on in millions and terabits, including on the NOC graph and the fiber labels on the map. - DE-Kicks ports stop getting dearer once they cost four times the list price. Before, the yearly price harmonisation kept compounding, so a long game ended up paying $100k a month for one port at Frankfurt or Mumbai. diff --git a/src/game/60-features/95-standing-orders.js b/src/game/60-features/95-standing-orders.js index 2bf7dbf..b11611e 100644 --- a/src/game/60-features/95-standing-orders.js +++ b/src/game/60-features/95-standing-orders.js @@ -159,25 +159,26 @@ const OPS_RUN={ // PNIs and IX ports keep Headroom times today's traffic, hottest first. One port at a POP with several routers gets a // second in a LAG, so it is not the only way out; anything else moves up to the smallest port size that fits. A PNI // augment lands weeks later, so that port waits for it. A flood fills ports for a day or two: not worth buying for. - ports(X){if(ddosAll().length)return;const N=opsP('ports','x'),L=[], + ports(X){if(ddosAll().length||!X.can('ports',1,0,true))return;const N=opsP('ports','x'),L=[], // Router ports that pending PNI augments will take when they land are spoken for. resv=c=>S.pni.reduce((a,p)=>p.up&&p.city===c?a+Math.max(0,PORT_SLOT(p.up.tier)*(p.up.n||1)-PORT_SLOT(p.tier)*(p.n||1)):a,0),room=c=>portsMax(c)-portsUsed(c)+1e-9-resv(c); // Each port: cap() now, use today, lag() and ups() the jobs it could have as {cost, cap after, w for the log, go}, sig() to see a job took. for(const p of S.pni){const c=p.city,use=R.usePni[p.id]||0,cap=()=>lagCap(pniG(p),p.n),n=()=>p.n||1;if(!pniOn(p)||p.up||!(use>0)||cap()>=N*use||!opsHere('ports',c))continue; - L.push({city:c,use,u:use/cap(),cap,n,rt:(S.pops[c]||{}).routers||1,busy:()=>!!p.up,sig:()=>[p.tier,n(),!!p.g1,!!p.up].join(), + L.push({city:c,at:c,use,u:use/cap(),cap,n,rt:(S.pops[c]||{}).routers||1,busy:()=>!!p.up,sig:()=>[p.tier,n(),!!p.g1,!!p.up].join(), lag:()=>n()ACT.lagP({id:p.id,d:1})}:null, ups:()=>{const out=[];for(let t=p.g1?0:p.tier+1;tACT.pni({city:c,net:p.net,tier:t})});}return out;}});} - for(const x in S.ixp){const c=ixCity(x),use=R.useIx[x]||0,cap=()=>ixCap(x),n=()=>(S.ixn||{})[x]||1,pop=S.pops[c];if(S.myIx[x]||!(use>0)||!(cap()>0)||cap()>=N*use||!opsHere('ports',c))continue; + // Nominal capacity, not ixCap(): a LACP fault or one building down halves a LAG for a day or two, not worth a bigger port. + for(const x in S.ixp){const c=ixCity(x),use=R.useIx[x]||0,n=()=>(S.ixn||{})[x]||1,cap=()=>lagCap(PORT[S.ixp[x]].g,n())*(isRemote(x)?REMOTE_CAP:1),pop=S.pops[c];if(S.myIx[x]||!(use>0)||!(cap()>0)||cap()>=N*use||!opsHere('ports',c))continue; const g=()=>PORT[S.ixp[x]].g; - L.push({city:c,use,u:use/cap(),cap,n,rt:pop?pop.routers||1:1,busy:()=>false,sig:()=>S.ixp[x]+','+n(), + L.push({city:c,at:x,use,u:use/cap(),cap,n,rt:pop?pop.routers||1:1,busy:()=>false,sig:()=>S.ixp[x]+','+n(), lag:()=>pop&&n()ACT.lagIx({city:x,d:1})}:null, // A remote port (no POP there) stops at 100G; at a POP the router has to take the bigger port. ups:()=>{const out=[],t0=S.ixp[x];for(let t=t0+1;troom(c):t>1)continue; out.push({cost:ixPortMo(x,t)*n(),cap:cap()*lagCap(PORT[t].g,n())/lagCap(g(),n()),w:PORT[t0].n+'→'+PORT[t].n,go:()=>ACT.buyIx({city:x,tier:t})});}return out;}});} for(const o of L.sort((a,b)=>b.u-a.u))for(let step=0;step<3&&!o.busy()&&o.cap()u.cap>=N*o.use)||ups.at(-1),job=o.n()<2&&o.rt>1?lag||fit:fit||lag,was=o.sig(); + const lag=o.lag(),wantLag=o.n()<2&&o.rt>1,ups=wantLag&&lag?null:o.ups(),fit=ups&&(ups.find(u=>u.cap>=N*o.use)||ups.at(-1)),job=wantLag?lag||fit:fit||lag,was=o.sig(); if(!job||!X.can('ports',job.cost)||!X.pay('ports',()=>{job.go();return o.sig()!==was;}))break; - X.did('ports',o.city+' '+job.w);}}, + X.did('ports',o.at+' '+job.w);}}, optics(X){const at=opsP('optics','at')/100,big=opsP('optics','pick')==='big',gpd=(o,l)=>optG(o,l)/optCost(o); for(const l of S.links){if(l.kind!=='df'||l.ready>S.day||l.eqDown>S.day||l.standby||l.cut>S.day)continue; let cap=dfCap(l);const load=(R.load&&R.load[l.id])||0; diff --git a/tests/intern-ports.test.js b/tests/intern-ports.test.js index d0129eb..435845d 100644 --- a/tests/intern-ports.test.js +++ b/tests/intern-ports.test.js @@ -72,7 +72,7 @@ test('the same two rules for an IX port', t => { }); test('it picks the smallest port that gives the headroom, and the biggest the router takes when none does', t => { - // 120G of traffic at 1.5× needs 180G: 100G is too small, 400G fits. + // 99G of traffic at 1.5× needs about 149G: 100G is too small, 400G fits. const A = twins(t, pni(1, 99) + ";R.usePni.p1=99", "ACT.pni({city:'fra',net:'drz',tier:2})", PNIS); assert.equal(A.ev('S.pni[0].tier'), 2); // A router that tops out at 100G cannot take a bigger port: another member of the LAG instead. @@ -179,3 +179,30 @@ test('an old save has the order off, and a new save keeps its dials', t => { assert.equal(ev('S.ops.spent.ports'), 0); assert.deepEqual(errors, []); }); + +test('a LACP fault or a building down does not buy a bigger IX port: the order counts what the port is', t => { + const { ev, errors } = hired(t, ix(1, 70) + ";S.ixn={fra:2};S.pops.fra.routers=2;S.ev.ixlacp={fra:{until:S.day+2,f:0.5}};compute();R.useIx.fra=70"); + assert.ok(ev("ixCap('fra')") < 1.5 * 70, 'the fault leaves less than the headroom for a day or two'); + on(ev); + const c0 = cash(ev); + shift(ev); + assert.equal(ev(IXP), '[1,2]', 'the 2×100G LAG stays as it is'); + assert.equal(cash(ev), c0); + assert.deepEqual(errors, []); +}); + +test('a remote IX port moves up to 100G at most, and the log names the exchange', t => { + const { ev, errors } = hired(t, "S.rules.pnis='instant';S.links.push({id:'remote',a:'fra',b:'ams',kind:'vxc',prov:FABS.find(f=>f.cities.includes('fra')&&f.cities.includes('ams')).id,vt:1,km:kmBetween('fra','ams'),sub:false,mo:0,cut:0,day:0});" + + "ACT.buyIx({city:'ams',tier:0,signed:true});compute();R.useIx.ams=9"); + assert.equal(ev("isRemote('ams')"), true, 'no POP in Amsterdam: a remote port'); + on(ev); + shift(ev); + assert.equal(ev('S.ixp.ams'), 1, '10G → 100G'); + assert.match(ev('opsEntry(S.ops.log[0])'), new RegExp(ev("ixName('ams')") + '|Amsterdam')); + ev('compute();R.useIx.ams=70'); + const c0 = cash(ev); + shift(ev); + assert.equal(ev('S.ixp.ams'), 1, 'a remote port stops at 100G, and there is no LAG without a POP'); + assert.equal(cash(ev), c0); + assert.deepEqual(errors, []); +});