Pinned attack flows route at their entry port's own rank, not a cone rank
base() now takes the target network; pinned junk has none, so coneOf() called every PNI a cone route and the flood was routed late (behind real traffic) or not at all. Pinned flows use the port's own rank (low preference still last), those ranks join RSET, and the reference allocation in the routing test does the same.
This commit is contained in:
parent
2873ee3435
commit
6d839102b5
3 changed files with 22 additions and 4 deletions
17
tests/ddos-floods.test.js
Normal file
17
tests/ddos-floods.test.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Where a flood goes and who pays for it: junk enters at its ingress ports and rides your backbone to the victim.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
test('a flood entering over a PNI with NetChill competes on that PNI at its own rank, as real traffic does', () => {
|
||||
for (const net of ['nfx', 'lvl']) {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;S.lvl=6;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=5000;S.pops.fra.rgen=RG.length-1;S.pops.fra.routers=8");
|
||||
ev(`S.transit=[];S.ixp={};S.peers={};S.grace=null;S.pni=[{id:'pa',net:'${net}',city:'fra',tier:1}];compute()`);
|
||||
assert.equal(ev(`R.netEg.${net}.p`), 100, 'the 100G PNI is full of real traffic');
|
||||
ev("S.ev.ddos={id:'x',city:'fra',vec:'http',gbps:100,start:S.day,until:S.day+5,entries:[{k:'p',id:'pa',city:'fra',share:1}]};compute()");
|
||||
assert.equal(ev('R.usePni.pa'), 100);
|
||||
assert.ok(!(ev(`R.netEg.${net}?.p||0`) > 1), `${net}: the junk is not routed behind the real traffic as if it were a cone route`);
|
||||
assert.deepEqual(errors, []);
|
||||
}
|
||||
});
|
||||
|
|
@ -6,7 +6,7 @@ module.exports = `
|
|||
if(f.rem<=1e-6||(rank===0&&!f.cache)||(pass&&!pass(f)))continue;
|
||||
Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++;
|
||||
const candidates=E.filter(e=>e.used<e.cap&&(f.pin?e.ek===f.pin:e.ok(f.n))&&
|
||||
(f.pin?base(e):TR?eff(e,f.n):base(e,f.n))===rank&&Dv[CIDX[e.city]]<Infinity)
|
||||
(f.pin?pr(e):TR?eff(e,f.n):base(e,f.n))===rank&&Dv[CIDX[e.city]]<Infinity)
|
||||
.sort((a,b)=>(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||Dv[CIDX[a.city]]-Dv[CIDX[b.city]]);
|
||||
for(let i=0;i<candidates.length&&f.rem>1e-6;){
|
||||
let j=i+1;while(j<candidates.length&&(candidates[j].pref==='high')===(candidates[i].pref==='high')&&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue