From 48356c01793e4f23b10eaebbcf056a21188b4425 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sat, 31 Oct 2026 13:29:23 +0100 Subject: [PATCH] The intern's PNI order counts the traffic the PNI list shows (#244) The threshold compared the city's whole eyeball demand times the network's traffic share, so a network whose cache boxes in that POP serve most of it (NetChill) looked far bigger than the PNI list said. It now uses pniVal(net,city).want: what your users there send over transit, an exchange or a PNI elsewhere, from live routing. --- CHANGELOG.md | 1 + src/game/60-features/95-standing-orders.js | 5 ++++- tests/standing-orders.test.js | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c2e494..5bfdebd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- The intern's PNI order now counts the traffic the PNI list shows at each POP, so it no longer orders a PNI where a network's own cache boxes already serve most of its traffic (#244). - Cities on the map now show how big they are: zoomed out, bigger cities are bigger dots and megacities glow; zoomed in, a city's skyline grows from a hut to a megacity's towers. When cities crowd together, the smaller ones step back to a dot until you zoom in, so the map stays readable, and exchanges you haven't joined are quieter tags. - DDoS attacks are realistic now: most are small, the big ones are rare, and their size no longer grows with your network, so a big network is no longer hit by floods larger than the internet's record. Attacks go after one customer (gamers and hosting attract the most) or one city's subscribers, last one to three days, and On-call sees about one a month (#242). - A flood now arrives on every port the internet reaches you on, so more POPs and more exits spread it thinner, and a port it fills slows every customer on it. Flowspec and scrubbing behind a full port can no longer empty it (#242). diff --git a/src/game/60-features/95-standing-orders.js b/src/game/60-features/95-standing-orders.js index 51e953a..919f08c 100644 --- a/src/game/60-features/95-standing-orders.js +++ b/src/game/60-features/95-standing-orders.js @@ -168,7 +168,10 @@ const OPS_RUN={ for(const row of utilityPeers())for(const id of row.requests){S.peers[id+'@'+row.ix]=true;X.did('peer',row.ix);}}, // Weekly too: every willing network above the threshold, at its own minimum size and lead time (#181). pni(X){if(S.day%7!==3)return;const b=pniBatch(null,opsP('pni','tier'));if(!b)return;const g=opsP('pni','g'),paid=opsP('pni','paid'); - const loc=q=>(R.cityDem[q.city]||0)*(NSH[q.net]||0); + // The traffic a PNI there would take over: what your users at that POP send to the network today over transit, an + // exchange or a PNI elsewhere, the same figure the PNI list shows. Not the city's whole demand: a network's own + // cache boxes in that POP already serve most of it (#244). + const loc=q=>pniVal(q.net,q.city).want; for(const q of b.orders.filter(q=>opsHere('pni',q.city)&&loc(q)>=g&&(paid||NET[q.net].pol!=='paid'||paidFree(NET[q.net]))).sort((a,b)=>loc(b)-loc(a))){ if(!X.can('pni',q.cost))break;if(X.pay('pni',()=>{if(!spend(q.cost))return false;pniPlace(q);return true;}))X.did('pni',q.city+' '+q.net);}}, // Hand back smaller waves once a bigger link between the same cities carries the pair with a quarter to spare (#102). diff --git a/tests/standing-orders.test.js b/tests/standing-orders.test.js index 09742b3..231f9d6 100644 --- a/tests/standing-orders.test.js +++ b/tests/standing-orders.test.js @@ -127,7 +127,7 @@ test('PNI: weekly, big enough networks only, paid peering left out by default, a const { ev, errors } = game(t, "ACT.buildPop({city:'ams'});S.pops.ams.rgen=1;compute()"); hire(ev); on(ev, 'pni', { g: 5, tier: 1 }, 0); ev('S.day=17;S.pops.fra.bb.d=3000;S.pops.ams.bb={d:3000};compute()'); - const plan = JSON.parse(ev("JSON.stringify(pniBatch(null,1).orders.filter(q=>(R.cityDem[q.city]||0)*NSH[q.net]>=5&&(NET[q.net].pol!=='paid'||paidFree(NET[q.net]))).map(q=>({k:q.city+q.net,cost:q.cost,tier:q.tier,big:pniBig(q.net)})))")); + const plan = JSON.parse(ev("JSON.stringify(pniBatch(null,1).orders.filter(q=>pniVal(q.net,q.city).want>=5&&(NET[q.net].pol!=='paid'||paidFree(NET[q.net]))).map(q=>({k:q.city+q.net,cost:q.cost,tier:q.tier,big:pniBig(q.net)})))")); assert.ok(plan.length > 0); const c0 = cash(ev); shift(ev); @@ -595,3 +595,19 @@ test('#228 the intern names the exchanges it peered at, even one that shares its assert.match(ev("opsLine({i:'kevin',r:[['routers',1,['lon +1']]],up:0,mo:0})"), /London \+1/); assert.deepEqual(errors, []); }); + +test('#244 the PNI order counts the traffic the PNI list shows at that POP, not what cache boxes there already serve', t => { + const { ev, errors } = game(t, "ACT.buildPop({city:'ham'});for(const c of ['fra','ham']){S.pops[c].rgen=mainRG(4);S.pops[c].routers=6;if(!S.pops[c].bb)ACT.launchBB({city:c});S.pops[c].bb.d=CITY[c].P*0.9;}UI.pending={a:'fra',b:'ham'};ACT.buildLink({tier:3});closeModal();ACT.buyTransit({city:'fra',net:'cog',tier:3});ACT.buyTransit({city:'ham',net:'cog',tier:3});for(let i=0;i<6;i++)S.caches.push({id:'nfx'+i,city:'ham',net:'nfx'});compute()"); + // Hamburg's users want a lot from NetChill, but its cache boxes there serve most of it: little is left for a PNI + const whole = ev("(R.cityDem.ham||0)*NSH.nfx"), here = ev("pniVal('nfx','ham').want"); + assert.ok(whole >= 10 && here < 10, `whole demand ${whole}, left for a PNI ${here}`); + hire(ev); on(ev, 'pni', { g: 10, tier: 0 }, 0); + ev('S.day=Math.ceil((S.day+1)/7)*7+3'); shift(ev); + assert.equal(ev("S.pni.some(p=>p.city==='ham'&&p.net==='nfx')"), false, 'no NetChill PNI in Hamburg for 2-odd Gbps'); + // without the cache boxes all of it goes over transit, and the same order does buy the PNI + ev("S.caches=S.caches.filter(x=>x.city!=='ham');compute()"); + assert.ok(ev("pniVal('nfx','ham').want") >= 10); + ev('S.day+=7'); shift(ev); + assert.equal(ev("S.pni.some(p=>p.city==='ham'&&p.net==='nfx')"), true, 'ordered once the traffic is really there'); + assert.deepEqual(errors, []); +});