BGP at 3 a.m. brings twice On-call's DDoS, as it says, not twenty times
Spicy chaos moved attacks onto the gamers' daily schedule without scaling it, so the preset had about 20x the attacks of On-call. Without gaming customers, attacks stay on the failure schedule (which spicy already runs 1.8x as often, with a slightly heavier DDoS weight to make it 2x); gaming customers still bring their busier one.
This commit is contained in:
parent
e80fd0e453
commit
b5cba3e591
2 changed files with 23 additions and 4 deletions
|
|
@ -7,9 +7,10 @@ function fireFailure(){
|
|||
if(S.transit.some(t=>!(t.down>S.day)))opts.push(['transit',3]);
|
||||
if(Object.keys(S.ixp).length)opts.push(['ixloop',2]);
|
||||
if(S.transit.length&&S.day>60)opts.push(['leak',2]);
|
||||
// Flood Season brings its own; Change Freeze (calm) has none. Spicy chaos or gaming customers put DDoS on its own,
|
||||
// busier schedule (ddosTick) instead of this one, so it is never counted twice.
|
||||
if(S.day>40&&!scnRule('ddos')&&!ddosOff()&&!ddosSpicy())opts.push(['ddos',2]);
|
||||
// Flood Season brings its own; Change Freeze (calm) has none. Gaming customers put DDoS on its own, busier schedule
|
||||
// (ddosTick) instead of this one, so it is never counted twice. Spicy failures already come 1.8x as often; a slightly
|
||||
// heavier weight makes that twice On-call's DDoS, as BGP at 3 a.m. promises.
|
||||
if(S.day>40&&!scnRule('ddos')&&!ddosOff()&&!gamingCount())opts.push(['ddos',rule('chaos')==='spicy'?2.25:2]);
|
||||
if(fabsUsed.length)opts.push(['fabric',1.5]);
|
||||
const lit=S.links.filter(l=>l.kind==='df'&&dfCap(l)>0&&!linkDown(l));if(lit.length)opts.push(['amp',1.5+lit.length*0.3],['optic',1.5+lit.length*0.3]);
|
||||
opts.push(['funny',4]);
|
||||
|
|
@ -134,12 +135,13 @@ function ddosSize(vec){const fl=scnRule('ddos'),r=Math.random(),roll=fl?1/3+r*2/
|
|||
// Calm (Change Freeze) and no chaos at all mean no attacks, gamers or not.
|
||||
const ddosOff=()=>{const c=rule('chaos');return c==='calm'||c==='none';};
|
||||
// More frequent attacks are opt-in: the spicy chaos setting, or hosting gamers (who attract them in real life).
|
||||
// Outside Flood Season, only gamers move attacks onto ddosTick's daily schedule; spicy alone doubles the usual one.
|
||||
const ddosSpicy=()=>!ddosOff()&&(rule('chaos')==='spicy'||gamingCount()>0);
|
||||
function ddosTick(){if(ddosOff()&&!scnRule('ddos'))return;if(scnRule('ddos')){let next=+S.scn.nextDdos||3,n=0;
|
||||
// Unless spicy, floods take turns as they always did: the next one waits until the last is over.
|
||||
if(!ddosSpicy()&&ddosAll().length)return;
|
||||
while(S.day>=next&&n++<2){ddosAttack(false);next+=floodGap();}S.scn.nextDdos=next<S.day?S.day+floodGap():next;}
|
||||
else if(ddosSpicy()&&(S.day>40||gamingCount()))for(let i=0;i<2;i++)if(Math.random()<ddosRate()/14)ddosAttack(false);}
|
||||
else if(!ddosOff()&&gamingCount())for(let i=0;i<2;i++)if(Math.random()<ddosRate()/14)ddosAttack(false);}
|
||||
// Size, duration and starts are randomized independently; overlapping floods never replace each other.
|
||||
function ddosAttack(recompute=true){const type='ddos',fl=scnRule('ddos');ddosExpire();
|
||||
S.ddosStarts=(S.ddosStarts||[]).filter(d=>d>S.day-7&&d<=S.day);if(S.ddosStarts.length>=14||!Object.keys(S.pops).length)return;S.ddosStarts.push(S.day);
|
||||
|
|
|
|||
|
|
@ -106,3 +106,20 @@ test('spicy chaos stretches exactly the attack (or outage) an incident is about,
|
|||
assert.equal(ev("S.links.find(l=>l.id==='M').cut-S.day"), 4);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('BGP at 3 a.m. brings about twice On-call\'s DDoS; gaming customers bring their own, busier schedule', () => {
|
||||
const picks = {};
|
||||
for (const preset of ['oncall', 'bgp']) {
|
||||
const { ev, errors } = load({ seed: 7 });
|
||||
ev(`beginGame('R','fra',{mode:'normal',preset:'${preset}'});if(UI.pendGame)ACT.pitchSkip();S.cash=1e12;ACT.launchBB({city:'fra'});ACT.buyTransit({city:'fra',net:'cog',tier:1});S.day=100;compute()`);
|
||||
// No daily attacks without gamers, spicy or not.
|
||||
ev("window.__n=0;const real=ddosAttack;ddosAttack=()=>{window.__n++;};for(let i=0;i<300;i++)ddosTick();window.__tick=window.__n;window.__n=0;for(let i=0;i<4000;i++)fireFailure();ddosAttack=real");
|
||||
assert.equal(ev('window.__tick'), 0, `${preset}: no daily DDoS schedule without gaming customers`);
|
||||
picks[preset] = ev('window.__n') * ev('chaosMul()');
|
||||
ev("S.biz.push({id:'g',type:'game',name:'G',city:'fra',bw:1,rate:1,mood:80,since:0});window.__n=0;const real=ddosAttack;ddosAttack=()=>{window.__n++;};for(let i=0;i<300;i++)ddosTick();ddosAttack=real");
|
||||
assert.ok(ev('window.__n') > 5, `${preset}: gamers attract attacks on their own schedule`);
|
||||
assert.deepEqual(errors, []);
|
||||
}
|
||||
const ratio = picks.bgp / picks.oncall;
|
||||
assert.ok(ratio > 1.7 && ratio < 2.3, `about twice the DDoS (${ratio.toFixed(2)}x)`);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue