@@ -2505,7 +2528,7 @@ function fireFailure(){
}else if(type==='pmtud'){
const top=NETS.filter(n=>(R.demTo[n.id]||0)>0.5).sort((a,b)=>(R.demTo[b.id]||0)-(R.demTo[a.id]||0)).slice(0,8),n=pick(top.length?top:NETS),dur=2+Math.floor(Math.random()*3);
S.ev.pmtud={net:n.id,until:S.day+dur,f:0.6};
- const msg=S.scrubAt&&Math.random()<0.5?N_('Your scrubbing center returns clean traffic over a GRE tunnel, and nobody clamped the MSS. Big packets to {net} vanish, so pages load halfway and stop.')
+ const msg=hasScrub()&&Math.random()<0.5?N_('Your scrubbing center returns clean traffic over a GRE tunnel, and nobody clamped the MSS. Big packets to {net} vanish, so pages load halfway and stop.')
:pick([N_('Someone filtered all ICMP on your edge “for security”. Path MTU discovery broke, and connections to {net} hang right after the handshake.'),
N_('A PPPoE hop shaved 8 bytes off your MTU and nothing told the servers. Large transfers to {net} stall forever; small ones work fine, which makes it so much worse.')]);
addInc({type,ref:n.id,until:S.ev.pmtud.until,msg:tr(msg,{net:n.name}),cost:500,fix:tr('Clamp the MSS to 1360')},msg);
@@ -2576,7 +2599,7 @@ function ddosAttack(){const type='ddos',fl=scnRule('ddos'),grow=fl?1+S.day/180:1
const gbps=Math.round((monster?800+Math.random()*2600:2+Math.random()*Math.max(18,base*0.9))*grow);
const dur=2+Math.floor(Math.random()*4),entry=ddosEntry(c);
S.ev.ddos={city:c,vec,gbps,until:S.day+dur,entry,bh:false,start:S.day};
- const soaked=(V.fs&&fsAt(c))||S.scrubAt;
+ const soaked=(V.fs&&fsAt(c))||hasScrub();
const how=entry&&entry.lab?tr(', in via {e}',{e:entry.lab}):'';
const msg=tr('A {size} {vec} attack is hitting {city}{how}.',{size:fmtG(gbps),vec:V.n,city:CITY[c].name,how})+' '+(soaked?tr('Your mitigation is eating most of it.'):tr('Junk traffic is eating your capacity. Open the NOC to fight back.'));
if(fl)S.ev.ddos.who=pick(FLOOD_WHO);
@@ -2707,7 +2730,7 @@ function dayTick(){
b.slaFor=a.start;S.cash-=SLA_PEN;b.mood=Math.max(0,b.mood-18);S.stats.sla=(S.stats.sla||0)+1;
toast(tr('
SLA breach: {name}.The attack on {city} got through and your protected customer went down. You owe {pen} in SLA credits.',{name:esc(b.name),city:CITY[a.city].name,pen:fmt$(SLA_PEN)}),'bad');sfx('err');}}
// businesses mood
- for(const b of S.biz.slice()){if(eventTick(b,d))continue;b.pm=b.mood;const sf=bizSf(b),reachOk=BIZ_T[b.type].l2||BIZ_T[b.type].fiber||R.reach>0.99||scnRule('local'),scrubOk=b.type!=='scrub'||!!S.scrubAt,divOk=reqOk(b);
+ for(const b of S.biz.slice()){if(eventTick(b,d))continue;b.pm=b.mood;const sf=bizSf(b),reachOk=BIZ_T[b.type].l2||BIZ_T[b.type].fiber||R.reach>0.99||scnRule('local'),scrubOk=b.type!=='scrub'||(hasScrub()&&!scrubFar(b.city)),divOk=reqOk(b);
if(sf>=0.95&&reachOk&&scrubOk&&divOk)b.mood=Math.min(100,b.mood+2);
else if(S.day-(b.since||0)<15){}
else{b.mood-=(Math.max(0,0.95-sf)*45+(!reachOk?3:0)+(!scrubOk?4:0)+(!divOk?3:0));
@@ -3023,10 +3046,10 @@ const ACT={
connOpen:()=>{if(!S)return;UI.dtab='conn';listReset('conn');const d=$('dash');d.hidden=false;renderDash();d.scrollTop=0;},
applyCn:()=>{if(S.cnLic.state!=='none')return;if(!spend(CN_LIC))return;S.cnLic={state:'pending',ready:S.day+45};toast(tr('
Application filed.Your local partner says about 45 days. Probably.'),'goal');after();},
togglePrem:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.premium=!t.premium;sfx('click');after();},
- buildScrub:({city,tier})=>{if(S.scrubAt)return;const T=SCRUB_TIERS[tier||0];if((lvl()||1)
{tier} scrubbing unlocks at customer level {lv}.',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(T.cost))return;S.scrubAt=city;S.scrubTier=tier||0;S.scrubMode='always';toast(tr('{tier} scrubbing center online in {city}.
Attacks up to {g} are cleaned, and you can sell DDoS protection.',{tier:T.n,city:CITY[city].name,g:fmtG(T.g)}),'good');after();},
- scrubUp:({tier})=>{if(!S.scrubAt||tier<=(S.scrubTier||0))return;const T=SCRUB_TIERS[tier];if((lvl()||1){tier} scrubbing unlocks at customer level {lv}.',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(Math.round(T.cost*0.6)))return;S.scrubTier=tier;toast(tr('Scrubbing upgraded to {tier}.',{tier:T.n}),'good');after();},
- scrubMode:()=>{if(!S.scrubAt)return;S.scrubMode=S.scrubMode==='ondemand'?'always':'ondemand';sfx('click');after();},
- rmScrub:()=>{if(!S.scrubAt)return;if(UI.confirm!=='scrub'){UI.confirm='scrub';renderAll();return;}S.scrubAt=null;S.scrubTier=0;S.scrubMode='always';UI.confirm=null;after();},
+ buildScrub:({city,tier})=>{if(!S.pops[city]||S.scrubs.some(x=>x.city===city))return;const T=SCRUB_TIERS[tier||0];if(!T)return;if((lvl()||1){tier} scrubbing unlocks at customer level {lv}.',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(T.cost))return;if(!hasScrub())S.scrubMode='always';S.scrubs.push({city,tier:tier||0});toast(tr('{tier} scrubbing center online in {city}.
Attacks up to {g} are cleaned, and you can sell DDoS protection.',{tier:T.n,city:CITY[city].name,g:fmtG(T.g)}),'good');after();},
+ scrubUp:({city,tier})=>{const x=S.scrubs.find(q=>q.city===city);tier=+tier;if(!x||!SCRUB_TIERS[tier]||tier<=(x.tier||0))return;const T=SCRUB_TIERS[tier];if((lvl()||1){tier} scrubbing unlocks at customer level {lv}.',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(Math.round(T.cost*0.6)))return;x.tier=tier;toast(tr('Scrubbing upgraded to {tier}.',{tier:T.n}),'good');after();},
+ scrubMode:()=>{if(!hasScrub())return;S.scrubMode=S.scrubMode==='ondemand'?'always':'ondemand';sfx('click');after();},
+ rmScrub:({city})=>{if(!S.scrubs.some(x=>x.city===city))return;if(UI.confirm!=='scrub:'+city){UI.confirm='scrub:'+city;renderAll();return;}S.scrubs=S.scrubs.filter(x=>x.city!==city);if(!hasScrub())S.scrubMode='always';UI.confirm=null;after();},
cleanPipe:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.clean=!t.clean;toast(t.clean?tr('Clean-pipe add-on enabled on {net}.
They scrub a flood before it reaches your port here, for {mo}/mo.',{net:NET[t.net].name,mo:fmt$(cleanMo(t))}):tr('Clean-pipe add-on removed from {net}.',{net:NET[t.net].name}),t.clean?'good':'');after();},
sacrif:({id})=>{const p=S.pni.find(x=>x.id===id);if(!p)return;p.sacrif=!p.sacrif;toast(p.sacrif?tr('{net} PNI is now a sacrificial choke point.
A flood from there dies on the small port instead of inside your network, but legit traffic over it runs at half capacity.',{net:NET[p.net].name}):tr('{net} PNI is back to normal.',{net:NET[p.net].name}),p.sacrif?'good':'');after();},
ixbh:()=>{const a=S.ev.ddos;if(!a){toast(tr('No attack to blackhole right now.'),'');return;}if(!hasIxAt(a.city)){toast(tr('No IX in {city} to announce a blackhole to.',{city:CITY[a.city].name}),'bad');sfx('err');return;}a.ixbh=!a.ixbh;toast(a.ixbh?tr('IX blackhole announced in {city}.
About half the members honour the /32 and drop the junk. The customer stays up.',{city:CITY[a.city].name}):tr('IX blackhole withdrawn.'),a.ixbh?'good':'');sfx('alert');after();},
@@ -3306,7 +3329,7 @@ function renderLeft(){checkLayer();
h+=`${tr('Your Network Operations Center. Every notification also lands here. Things fail all the time on the internet. Redundant links and multiple upstreams let traffic reroute by itself.')}
`;
// Incidents come first, the ones you can fix with one click at the top (#63): no scrolling past hot ports to replace an optic.
for(const i of S.inc.filter(i=>i.type!=='ddos').sort((a,b)=>(b.cost?1:0)-(a.cost?1:0)||(b.impact||0)-(a.impact||0))){h+=`${incTitle(i.type)}
${esc(i.msg)}
${trn('Auto-fix in {n} day','Auto-fix in {n} days',i.until-S.day)}${i.impact?` · ${tr('{g} lost',{g:fmtG(i.impact)})}`:''}
${i.cost?`
${btn(`${esc(i.fix||tr('Rush repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash`:''}
`;}
- h+=`
${tr('DDoS scrubbing')}${S.scrubAt?tr('On · {city}',{city:CITY[S.scrubAt].name}):tr('None (build one from a POP\'s Infra tab)')}
`;
+ h+=`
${tr('DDoS scrubbing')}${hasScrub()?tr('On · {city}',{city:S.scrubs.map(x=>CITY[x.city].name).join(', ')}):tr('None (build one from a POP\'s Infra tab)')}
`;
{const pops=Object.keys(S.pops),nfs=pops.filter(c=>fsAt(c)).length;
h+=`
${tr('Flowspec-capable POPs')}${nfs}/${pops.length}
`;
if(nfs
${tr('Flowspec drop rules live in router TCAM, so only capable routers filter known UDP floods (DNS, NTP, CLDAP, SYN) at the edge. The used Rusty has none, merchant-silicon and whitebox models do a little, the big chassis do it in full. Upgrade a POP’s router from its Infra tab.')}`;}
@@ -3379,7 +3402,7 @@ function cityPanel(c){
h+=`${tr('Business customers')}
`;
const bz=S.biz.filter(b=>bCities(b).includes(c));
if(!bz.length)h+=`${tr('No businesses yet. Offers pop up as $ bubbles on the map.')}
`;
- for(const b of bz)h+=`${esc(b.name)}
${esc(BIZ_T[b.type].l)}${b.city2?` ${CITY[b.city].name} ⇄ ${CITY[b.city2].name}`:''} · ${bTerms(b)}${BIZ_T[b.type].l2?` · ${b.sites?tr('carrying {g} per site',{g:fmtG(R.l2[b.id]||0)}):tr('carrying {g}',{g:fmtG(R.l2[b.id]||0)})}`:''}${BIZ_T[b.type].fiber&&!fiberOk(b)?' · '+tr('fiber is down')+'':''}${BIZ_T[b.type].event&&eventLive(b)?` · ${tr('serving {v}',{v:pct(sfOf(R,b.city))})}`:''}${b.type==='scrub'&&!S.scrubAt?' · '+tr('needs a scrubbing center')+'':''}${S.day-(b.since||0)<15?` · ${tr('provisioning, {n}d grace',{n:15-(S.day-(b.since||0))})}`:''}
${reqList(b)}${BIZ_T[b.type].l2?routeCtl(b):''}
${tr('Happiness {p}%',{p:Math.round(b.mood)})}
${btn(UI.confirm===b.id?tr('Really drop?'):tr('Drop'),'dropBiz',{id:b.id},'ghost sm')}
`;
+ for(const b of bz)h+=`${esc(b.name)}
${esc(BIZ_T[b.type].l)}${b.city2?` ${CITY[b.city].name} ⇄ ${CITY[b.city2].name}`:''} · ${bTerms(b)}${BIZ_T[b.type].l2?` · ${b.sites?tr('carrying {g} per site',{g:fmtG(R.l2[b.id]||0)}):tr('carrying {g}',{g:fmtG(R.l2[b.id]||0)})}`:''}${BIZ_T[b.type].fiber&&!fiberOk(b)?' · '+tr('fiber is down')+'':''}${BIZ_T[b.type].event&&eventLive(b)?` · ${tr('serving {v}',{v:pct(sfOf(R,b.city))})}`:''}${b.type==='scrub'&&!hasScrub()?' · '+tr('needs a scrubbing center')+'':''}${S.day-(b.since||0)<15?` · ${tr('provisioning, {n}d grace',{n:15-(S.day-(b.since||0))})}`:''}
${reqList(b)}${BIZ_T[b.type].l2?routeCtl(b):''}
${tr('Happiness {p}%',{p:Math.round(b.mood)})}
${btn(UI.confirm===b.id?tr('Really drop?'):tr('Drop'),'dropBiz',{id:b.id},'ghost sm')}
`;
h+=``+offersHere(c);
}else if(UI.tab==='up'){
h+=portNote(c);
@@ -3428,13 +3451,13 @@ function cityPanel(c){
:`${tr('Right now {city} is one building. A power cut, an A/C failure or a cleaner with a vacuum takes the whole city dark, and a second router does not help with that. A second data center across town, joined by your own metro ring, keeps half the POP up.',{city:esc(CITY[c].name)})}
${btn(tr('Add a second site
{cost} + {mo}/mo',{cost:fmt$(SITE2_COST),mo:fmt$(SITE2_MO)}),'addSite',{city:c},'pink',S.cash
`}
${tr('Power')}
${tr('Backup generator')}${p.gen?tr('Installed'):tr('None')}
${p.gen?''+tr('Power cuts are covered.')+'
':`${btn(tr('Install generator
{cost} + {mo}/mo',{cost:fmt$(GEN_COST),mo:fmt$(GEN_MO)}),'addGen',{city:c},'',S.cash
`}`;
h+=`${tr('DDoS scrubbing center')}
`;
- if(S.scrubAt===c){const T=SCRUB_TIERS[S.scrubTier||0];
+ {const here=S.scrubs.find(x=>x.city===c),others=S.scrubs.filter(x=>x.city!==c);
+ if(here){const T=SCRUB_TIERS[here.tier||0];
h+=`${tr('Cleans attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts. Clean traffic returns over GRE, which can re-open the MSS black hole.')}
${tr('Capacity')}${T.n} · ${fmtG(T.g)}
- ${tr('Mode')}${S.scrubMode==='ondemand'?tr('On-demand (engages in {n}d)',{n:SCRUB_DELAY}):tr('Always-on')} · ${fmt$(scrubMo())}/mo
- ${btn(S.scrubMode==='ondemand'?tr('Switch to always-on'):tr('Switch to on-demand
cheaper'),'scrubMode',{},'sm')}${SCRUB_TIERS.map((X,i)=>i>(S.scrubTier||0)?btn(tr('Upgrade to {tier}
{cost}',{tier:X.n,cost:fmt$(Math.round(X.cost*0.6))}),'scrubUp',{tier:i},'sm',(lvl()||1)
`;}
- else if(S.scrubAt)h+=`${tr('You already run one in {city}.',{city:CITY[S.scrubAt].name})}
`;
- else{h+=`${tr('Cleans DDoS attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts for businesses.')}
${SCRUB_TIERS.map((X,i)=>btn(tr('Build {tier}
{cost} + {mo}/mo',{tier:X.n,cost:fmt$(X.cost),mo:fmt$(X.mo)}),'buildScrub',{city:c,tier:i},i===0?'':'sm',(lvl()||1)
`;}
+ ${tr('Mode')}${S.scrubMode==='ondemand'?tr('On-demand (engages in {n}d)',{n:SCRUB_DELAY}):tr('Always-on')} · ${fmt$(scrubMo1(here))}/mo
+ ${btn(S.scrubMode==='ondemand'?tr('Switch to always-on'):tr('Switch to on-demand
cheaper'),'scrubMode',{},'sm')}${SCRUB_TIERS.map((X,i)=>i>(here.tier||0)?btn(tr('Upgrade to {tier}
{cost}',{tier:X.n,cost:fmt$(Math.round(X.cost*0.6))}),'scrubUp',{city:c,tier:i},'sm',(lvl()||1)
`;}
+ else{h+=`${others.length?tr('Attacks go to your nearest scrubbing center. From here that is {city}, {km} km away: the flood rides your backbone there and back, which adds latency, and whatever your links cannot carry is not scrubbed. A center here cleans attacks on the spot.',{city:CITY[others.slice().sort((a,b)=>kmBetween(c,a.city)-kmBetween(c,b.city))[0].city].name,km:Math.round(kmBetween(c,others.slice().sort((a,b)=>kmBetween(c,a.city)-kmBetween(c,b.city))[0].city)).toLocaleString()}):tr('Cleans DDoS attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts for businesses.')}
${SCRUB_TIERS.map((X,i)=>btn(tr('Build {tier}
{cost} + {mo}/mo',{tier:X.n,cost:fmt$(X.cost),mo:fmt$(X.mo)}),'buildScrub',{city:c,tier:i},i===0?'':'sm',(lvl()||1)
`;}}
h+=``;
const fabs=FABS.filter(f=>f.cities.includes(c));
if(fabs.length){h+=`${tr('Interconnection fabrics (NNI)')}
${tr('Buy a port on a fabric, then order virtual circuits to your other POPs or to a remote IX. Fast and flexible, but you share their fabric.')}
`;
@@ -3470,7 +3493,7 @@ function decomModal(){const sel=[...(UI.decom||[])],im=decomImpact(sel),all=Obje
function decommission(cities){const set=new Set(cities),im=decomImpact(cities),lids=new Set(im.links.map(l=>l.id)),bids=new Set(im.biz.map(b=>b.id));
S.links=S.links.filter(l=>!lids.has(l.id));S.biz=S.biz.filter(b=>!bids.has(b.id));S.offers=S.offers.filter(o=>!bCities(o).some(c=>set.has(c)));
S.transit=S.transit.filter(t=>!set.has(t.city));S.pni=S.pni.filter(x=>!set.has(x.city));S.caches=S.caches.filter(x=>!set.has(x.city));S.nni=(S.nni||[]).filter(x=>!set.has(x.city));
- for(const c of cities){for(const x of ixIdsIn(c)){delete S.ixp[x];delete S.rs[x];if(S.ixn)delete S.ixn[x];if(S.ixSite)delete S.ixSite[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}delete S.myIx[c];if(S.scrubAt===c)S.scrubAt=null;delete S.pops[c];}
+ for(const c of cities){for(const x of ixIdsIn(c)){delete S.ixp[x];delete S.rs[x];if(S.ixn)delete S.ixn[x];if(S.ixSite)delete S.ixSite[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}delete S.myIx[c];S.scrubs=S.scrubs.filter(x=>x.city!==c);delete S.pops[c];}
const rem=remoteCities();for(const x in S.ixp){const c=ixCity(x);if(!S.pops[c]&&!rem.includes(c)){delete S.ixp[x];delete S.rs[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}}
if(set.has(S.home))S.home=Object.keys(S.pops)[0];
purgeInc();S.cash-=im.fee;S.stats.decom=(S.stats.decom||0)+cities.length;
@@ -3565,7 +3588,7 @@ function dfPanel(l){
}
function offersHere(c){
const os=S.offers.filter(o=>bCities(o).includes(c));if(!os.length)return '';
- return `${tr('Offers here')}
${os.map(o=>`${esc(o.name)}
${esc(BIZ_T[o.type].l)}${o.city2?` ${CITY[o.city].name} ⇄ ${CITY[o.city2].name}`:''} · ${bTerms(o)} · ${tr('{n}d left',{n:o.exp-S.day})}
${R.reach<0.99&&!BIZ_T[o.type].l2?`
${tr('They need the full internet. Your reach is {pct}.',{pct:pct(R.reach)})}
`:''}${o.type==='scrub'&&!S.scrubAt?`
${tr('Needs your own scrubbing center (Infra tab).')}
`:''}${reqList(o)}${bHas(o)?'':`
${tr('Needs a POP in {cities} too.',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}
`}
${bHas(o)?btn(tr('Accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('No'),'decline',{id:o.id},'ghost sm')}
`).join('')}`;
+ return `${tr('Offers here')}
${os.map(o=>`${esc(o.name)}
${esc(BIZ_T[o.type].l)}${o.city2?` ${CITY[o.city].name} ⇄ ${CITY[o.city2].name}`:''} · ${bTerms(o)} · ${tr('{n}d left',{n:o.exp-S.day})}
${R.reach<0.99&&!BIZ_T[o.type].l2?`
${tr('They need the full internet. Your reach is {pct}.',{pct:pct(R.reach)})}
`:''}${o.type==='scrub'&&!hasScrub()?`
${tr('Needs your own scrubbing center (Infra tab).')}
`:''}${reqList(o)}${bHas(o)?'':`
${tr('Needs a POP in {cities} too.',{cities:bCities(o).filter(x=>!S.pops[x]).map(x=>CITY[x].name).join(', ')})}
`}
${bHas(o)?btn(tr('Accept'),'accept',{id:o.id},'green sm'):''}${btn(tr('No'),'decline',{id:o.id},'ghost sm')}
`).join('')}`;
}
function linkPanel(id){
const l=S.links.find(x=>x.id===id);if(!l){UI.sel=null;return '';}
@@ -3672,7 +3695,8 @@ const bizMo=b=>{const T=BIZ_T[b.type];return T.event?0:T.fiber?b.rate:b.bw*b.rat
function bizWhy(b){const T=BIZ_T[b.type],out=[];if(T.event&&!eventLive(b))return out;
const sf=bizSf(b);if(sf<0.95)out.push(T.fiber?tr('their fiber is down'):tr('getting only {p} of the bandwidth they pay for',{p:pct(sf)}));
if(!(T.l2||T.fiber)&&R.reach<=0.99&&!scnRule('local'))out.push(tr('you cannot reach the whole internet ({p})',{p:pct(R.reach)}));
- if(b.type==='scrub'&&!S.scrubAt)out.push(tr('needs a scrubbing center'));
+ if(b.type==='scrub'&&!hasScrub())out.push(tr('needs a scrubbing center'));
+ {const q=b.type==='scrub'&&scrubFar(b.city);if(q)out.push(tr('attacks on {city} are hauled to {to} for scrubbing: +{ms} ms',{city:CITY[b.city].name,to:CITY[q.to].name,ms:Math.round(q.ms)}));}
for(const k of b.reqs||[])if(REQS[k]&&!REQS[k].ok(b))out.push(typeof REQS[k].l==='function'?REQS[k].l(b):REQS[k].l);
return out;}
const moodCls=m=>m<30?'bad':m<60?'warn':'';
@@ -3962,7 +3986,7 @@ function showHelp(){
PNI${tr('Private network interconnect: a cable straight to one network in the same building. For big traffic.')}
${tr('Embedded cache')}${tr('A CDN\'s server in your rack. Serves most of that CDN\'s traffic locally, for the price of power.')}
DE-KICKS${tr('The group behind several big exchanges (Frankfurt, Madrid, Marseille, Dubai, Mumbai, New York) treats price lists as a state secret. Ports are quoted per customer and go up the bigger you look. Haggling can work, backfire or stall for a week. Prices get "harmonised" upwards once a year, add-ons appear on your invoice until you opt out, and trying to leave earns you a retention discount that ends with a fee.')}${tr('Remote peering')}${tr('Reach an IX over a fabric circuit without a POP there. It works, and the route server still gets you every open network, but it is discouraged: the reseller charges 1.5× for the port and oversubscribes it to 80%, latency rides the fabric, one fabric outage drops every session, and many selective networks refuse remote members outright.')}${tr('Peering policy')}${tr('Open peers with anyone. Selective wants to see traffic first. Restrictive (Tier 1s) only peers with giants, over PNIs. Paid means exactly that. Big selective networks also have moods: in some cities they refuse new peers for a few months, or only take PNIs, and now and then they tear down a session you already had. Try another city or a PNI, and ask again later.')}
- ${tr('Waves')}${tr('Your fiber links are leased waves at a flat monthly rate. Longer and bigger costs more (10G → 6.4T), and subsea is 1.8× the price.')}${tr('95th percentile')}${tr('Transit bills sample your usage every day and charge the 95th percentile of the last 30 days, so short spikes are forgiven but long ones are not.')}${tr('Routers')}${tr('Each POP\'s router model caps its fastest port (100G, 400G, 800G, 1.6T) and how much it can forward. Bigger waves and ports need better routers at both ends. Better models unlock with your customer level. With one router, upgrades mean a day of downtime.')}${tr('Dark fiber')}${tr('Lease an IRU or build your own (slow, with delays), then buy a line system with amplifiers and light channels with 400ZR+, 800ZR+ or 1.6T transponders. Much cheaper than waves at scale, but the gear can fail. A spares kit speeds up repairs.')}${tr('Subsea cables')}${tr('Subsea waves can only follow cable systems modelled on real ones, drawn faintly on the map (tap a city to highlight its cables). Teal ones are new and cheap, purple ones pricey, dashed ones old and cut-prone. All your waves on one cable die together when it is cut. Between continents on land, you can often choose overland (2.5×, many borders) or a cable.')}${tr('Latency')}${tr('Every link has latency. High-frequency traders pay a fortune for a circuit within their latency budget; route them “Lowest latency”. Bulk backup customers do not care, so route them “Scenic” over your quiet links to keep busy ones free.')}${tr('NOC dashboard')}${tr('The chart button at the top opens traffic graphs by exit (caches, PNIs, IX, transit), money over time, per-ASN traffic with how it reaches you and what its transit costs, plus your busiest links and routers.')}${tr('Asia')}${tr('A weird, underserved market. Transit costs 2.5× what it does in Europe (Africa 2×, Oceania 1.8×), local incumbents mostly peer only for pay, and IXs are fragmented. But demand is enormous and users sign up 60% faster than anywhere else. Peering and caches pay off most here.')}${tr('Russia')}${tr('Moscow needs a mandatory government box in every POP, Western CDNs are mostly gone, Goggle video is throttled to half speed, and the sovereign internet drills now and then cut Moscow off for a day.')}${tr('Events, chains and wholesale')}${tr('Event networks (a final, a festival, a keynote) need a burst of capacity in one city for a few days and pay once at the end, prorated by how much of the crowd you served; below 70% you pay a penalty. SD-WAN chains connect 3–6 of your POPs hub-and-spoke, so one broken spoke upsets the whole contract. Once you run your own dark fiber, carriers want to rent spare channels as alien waves, and on fiber you built yourself, a spare pair.')}${tr('Bank')}${tr('Tap your cash to open the bank. Lenders make offers now and then, and much more often when you are in the red. Each loan has a monthly payment and some odd conditions; break one and you pay a penalty. Your credit rating decides which banks talk to you. The loan shark is always there. Do not be late.')}${tr('LAGs')}${tr('Out of port speed? Bundle up to 8 identical ports to the same transit provider, IX or PNI into a LAG. Each member costs a full port; flow hashing is never perfectly even, so a bundle carries about 95% of the sum.')}${tr('Traffic engineering')}${tr('Tap a link to see which networks, which entry points and which customer cities fill it. Raise a link\'s metric to steer traffic around it, or set an egress (transit, IX, PNI) to Prefer or Backup only.')}${tr('China')}${tr('Mainland China needs a license and a local joint venture. Many foreign services are blocked there, and traffic crossing the border loses packets unless you pay for premium routes.')}${tr('Weird requirements')}${tr('Some customers come with conditions: no Cogentle anywhere, no subsea cables because of sharks, two routers, a generator, NetChill on-net, low-loss China reach and more. Each pays a bonus. Unmet ones make them grumpy until you fix it or they leave.')}${tr('Customer levels')}${tr('As your peak traffic and footprint grow, bigger customers show up: streaming startups and universities, then AI GPU data centers and cloud on-ramps, then AI training interconnects and hyperscaler DCI deals measured in terabits. Pink $$ bubbles mark the big ones.')}${tr('L2VPN & DDoS protection')}${tr('Businesses may want a private circuit between two of your POPs (it rides your backbone), or DDoS protection (needs your own scrubbing center).')}${tr('NNI fabrics')}${tr('Megapork, PocketFabric and Consolation Connect sell a port plus virtual circuits between cities. Great for small links and remote peering at an IX where you have no POP.')}
+ ${tr('Waves')}${tr('Your fiber links are leased waves at a flat monthly rate. Longer and bigger costs more (10G → 6.4T), and subsea is 1.8× the price.')}${tr('95th percentile')}${tr('Transit bills sample your usage every day and charge the 95th percentile of the last 30 days, so short spikes are forgiven but long ones are not.')}${tr('Routers')}${tr('Each POP\'s router model caps its fastest port (100G, 400G, 800G, 1.6T) and how much it can forward. Bigger waves and ports need better routers at both ends. Better models unlock with your customer level. With one router, upgrades mean a day of downtime.')}${tr('Dark fiber')}${tr('Lease an IRU or build your own (slow, with delays), then buy a line system with amplifiers and light channels with 400ZR+, 800ZR+ or 1.6T transponders. Much cheaper than waves at scale, but the gear can fail. A spares kit speeds up repairs.')}${tr('Subsea cables')}${tr('Subsea waves can only follow cable systems modelled on real ones, drawn faintly on the map (tap a city to highlight its cables). Teal ones are new and cheap, purple ones pricey, dashed ones old and cut-prone. All your waves on one cable die together when it is cut. Between continents on land, you can often choose overland (2.5×, many borders) or a cable.')}${tr('Latency')}${tr('Every link has latency. High-frequency traders pay a fortune for a circuit within their latency budget; route them “Lowest latency”. Bulk backup customers do not care, so route them “Scenic” over your quiet links to keep busy ones free.')}${tr('NOC dashboard')}${tr('The chart button at the top opens traffic graphs by exit (caches, PNIs, IX, transit), money over time, per-ASN traffic with how it reaches you and what its transit costs, plus your busiest links and routers.')}${tr('Asia')}${tr('A weird, underserved market. Transit costs 2.5× what it does in Europe (Africa 2×, Oceania 1.8×), local incumbents mostly peer only for pay, and IXs are fragmented. But demand is enormous and users sign up 60% faster than anywhere else. Peering and caches pay off most here.')}${tr('Russia')}${tr('Moscow needs a mandatory government box in every POP, Western CDNs are mostly gone, Goggle video is throttled to half speed, and the sovereign internet drills now and then cut Moscow off for a day.')}${tr('Events, chains and wholesale')}${tr('Event networks (a final, a festival, a keynote) need a burst of capacity in one city for a few days and pay once at the end, prorated by how much of the crowd you served; below 70% you pay a penalty. SD-WAN chains connect 3–6 of your POPs hub-and-spoke, so one broken spoke upsets the whole contract. Once you run your own dark fiber, carriers want to rent spare channels as alien waves, and on fiber you built yourself, a spare pair.')}${tr('Bank')}${tr('Tap your cash to open the bank. Lenders make offers now and then, and much more often when you are in the red. Each loan has a monthly payment and some odd conditions; break one and you pay a penalty. Your credit rating decides which banks talk to you. The loan shark is always there. Do not be late.')}${tr('LAGs')}${tr('Out of port speed? Bundle up to 8 identical ports to the same transit provider, IX or PNI into a LAG. Each member costs a full port; flow hashing is never perfectly even, so a bundle carries about 95% of the sum.')}${tr('Traffic engineering')}${tr('Tap a link to see which networks, which entry points and which customer cities fill it. Raise a link\'s metric to steer traffic around it, or set an egress (transit, IX, PNI) to Prefer or Backup only.')}${tr('China')}${tr('Mainland China needs a license and a local joint venture. Many foreign services are blocked there, and traffic crossing the border loses packets unless you pay for premium routes.')}${tr('Weird requirements')}${tr('Some customers come with conditions: no Cogentle anywhere, no subsea cables because of sharks, two routers, a generator, NetChill on-net, low-loss China reach and more. Each pays a bonus. Unmet ones make them grumpy until you fix it or they leave.')}${tr('Customer levels')}${tr('As your peak traffic and footprint grow, bigger customers show up: streaming startups and universities, then AI GPU data centers and cloud on-ramps, then AI training interconnects and hyperscaler DCI deals measured in terabits. Pink $$ bubbles mark the big ones.')}${tr('L2VPN & DDoS protection')}${tr('Businesses may want a private circuit between two of your POPs (it rides your backbone), or DDoS protection (needs your own scrubbing center).')}${tr('Scrubbing centers')}${tr('Build one in as many POPs as you like. An attack goes to the nearest working center, and what it cannot take spills to the next. A far center means the flood rides your backbone there and the victim’s traffic comes back the long way: it fills your links, adds latency, and whatever the links cannot carry is not scrubbed. Customers who buy DDoS protection notice when their attacks cross an ocean.')}${tr('NNI fabrics')}${tr('Megapork, PocketFabric and Consolation Connect sell a port plus virtual circuits between cities. Great for small links and remote peering at an IX where you have no POP.')}
${tr('Conferences')}${tr('NANOG, RIPE, DENOG and friends come round every year. Register in the Deals tab for $8k. For 45 days after, selective networks with a presence in that region need only half the usual traffic before they peer with you. Sometimes you also win the raffle.')}${tr('Modes')}${tr('Sandbox gives you a billion dollars, every unlock and no failures, but no badges. Scenarios are hand-built challenges with a goal and a deadline, and the weekly challenge gives everyone the same world for a week. Share your result with the card in the menu.')}${tr('Traceroute')}${tr('Tap 🔍 Traceroute on any of your cities, or open it from the NOC tab, to see the exact path to a network or POP, hop by hop, with latency, the exit and the AS path.')}${tr('Badges')}${tr('Below your goals sits a wall of badges, from common to legendary. Some take luck, some take years, and a couple are secret. Badges you earned in earlier games stay on this device with a dashed outline.')}${tr('The giants')}${tr('At customer level 3 and 4, hyperscalers and AI clouds show up with deals only they would ask for: terabit AI WANs between gigawatt campuses, training runs spread over several sites, week-long dataset ingests, and hundreds of fiber pairs in a trench you dug yourself. They pay like nobody else, and they want diverse paths, two sites per metro and zero excuses. Cities near their campuses list them under “Who’s here”.')}RouteScript${tr('Once Auto-TE is installed, you can program it from the NOC tab. Rules include spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams and blackhole ddos. Check runs a dry run against live traffic; Deploy makes it real, mistakes included.')}Auto-TE${tr('Traffic follows the shortest path by distance and link metric, and reroutes by itself when links fail. When a path is merely full, the overflow is dropped, just like a real IGP. From customer level 3 you can install Auto-TE in the NOC tab: it spills overflow onto up to two alternate paths with free capacity, as long as they are no more than twice as long.')}${tr('Metro diversity')}${tr('A POP is one building until you add a second site in the Infra tab. Then a power cut, cleaner or A/C failure only takes out half the city, and you choose which site each transit, PNI and IX port plugs into, or pick Both to split a LAG across the two buildings. Spread them out, or both halves of your redundancy will sit in the same dark room. Watch out for metro ring cuts, which cut site B off.')}${tr('Wave markets')}${tr('What a wave costs depends on where it runs. Europe is cheap (lots of competing fiber), North America is average, Asia and South America are pricier, and anything into Africa is several times the price. Every route has its own going rate, and new leases get about 8% cheaper each year, so waiting can pay. The link planner tells you how a route compares.')}${tr('Regional quirks')}${tr('In the Gulf, Saudi POPs need a local telecom licence and data on Saudi users stays in the Kingdom; gigaprojects ask for huge demo networks; and now and then the neighbours fall out and every link between Qatar and Saudi Arabia or the UAE goes dark for months, so keep a sea route. South America hangs off Miami: transit is pricier, nothing crosses the Darién Gap by land, and fiber over the Andes costs double and breaks often. IX.brrr in Brazil is run by a nonprofit with cheap public prices, and small Brazilian provedores buy transit in bulk. Inside the UAE only the duopoly may run fiber, so no dark fiber and 3× waves. Korea runs on “sender pays”: transit into Seoul costs about four times the usual price and the three incumbents only peer over paid PNIs, billed per gigabit you send them. Taiwan’s cables meet a lot of anchors, Indian fiber meets road widening and the monsoon, and South Africa has load shedding: bring a generator.')}${tr('Boot times')}${tr('Some routers take forever to boot. The Infra tab shows how long yours takes. Slow booters make crashes last longer and turn a one-router swap into a three-day outage. Bigger chassis, especially anything with a PacketOinker™ inside, are slow more often. Twin routers make it someone else’s problem.')}${tr('Failures')}${tr('Things break all the time: fiber cuts, router crashes, power cuts, IX loops, fabric outages, route leaks, DDoS, fat fingers, cooling failures, and geopolitics: sanctions, tariffs, BGP hijacks, landing permit disputes, exam-day shutdowns and Red Sea cable cuts. Traffic reroutes automatically over other paths and upstreams. Parallel links on diverse routes, a second router and a backup generator all help. Or pay to rush repairs.')}
${tr('Want to know how it really works?')}
${plugHtml(true)}${chatHtml()}${btn(UI.started?tr('Back to the map'):tr('Got it'),'helpClose',{},'big')}${RELEASE_NOTES.length?btn(tr('What’s new in {v}',{v:esc(APP_VERSION)}),'whatsNewShow',{},'ghost'):''}${UI.started&&S&&!S.lost?btn(tr('Start a new network'),'resetAsk',{},'ghost sm'):''}
${UI.started&&S&&!S.lost?btn(tr('Export save'),'exportSave',{},'ghost sm'):''}${btn(tr('Import a save'),'importPick',{},'ghost sm')}${btn(tr('Settings'),'settings',{},'ghost sm')}
`);
}
diff --git a/tests/game.test.js b/tests/game.test.js
index e14cfc6..6bbdadc 100644
--- a/tests/game.test.js
+++ b/tests/game.test.js
@@ -192,7 +192,7 @@ test('Flowspec is a router-model capability, and each tool answers a flood', ()
const http = ev("RG[0].fs=2;S.ev.ddos.vec='http';compute();const s=R.served;RG[0].fs=0;s");
assert.ok(Math.abs(http - none) < 1, 'Flowspec is useless against HTTP');
// Scrubbing cleans any vector, regardless of router. A 1T center swallows this 300 Gbps flood whole.
- ev("S.ev.ddos.vec='dns';S.scrubAt='fra';S.scrubTier=1;S.scrubMode='always';compute()");
+ ev("S.ev.ddos.vec='dns';S.scrubs=[{city:'fra',tier:1}];S.scrubMode='always';compute()");
assert.ok(ev('R.served') > none, 'scrubbing recovers real traffic');
assert.deepEqual(errors, []);
});
@@ -229,8 +229,8 @@ test('scrubbing tiers: capacity caps what a center can clean, and on-demand lags
ev("ACT.start({});S.cash=1e8;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=200;ACT.buyTransit({city:'fra',net:'cog',tier:1});S.ev.ddos={city:'fra',vec:'dns',gbps:300,until:S.day+3,entry:{k:'t',lab:'x'},bh:false,start:S.day};compute()");
const none = ev('R.served');
// A 100G center cannot swallow a 300 Gbps flood; a 10T center can.
- const small = ev("S.scrubAt='fra';S.scrubTier=0;S.scrubMode='always';compute();R.served");
- const big = ev("S.scrubTier=2;compute();R.served");
+ const small = ev("S.scrubs=[{city:'fra',tier:0}];S.scrubMode='always';compute();R.served");
+ const big = ev("S.scrubs[0].tier=2;compute();R.served");
assert.ok(big > small, 'a bigger scrubbing tier cleans more');
assert.ok(big > none, 'the 10T center recovers the flood');
// On-demand does nothing until it engages (SCRUB_DELAY days in).
@@ -266,7 +266,7 @@ test('SLA: a protected customer that still goes down costs an SLA credit, once',
const { ev } = load();
ev("ACT.start({});S.cash=1e8;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=200;ACT.buyTransit({city:'fra',net:'cog',tier:1});S.nextFail=1e9;S.nextEvent=1e9");
// A DDoS protection customer, an overwhelming flood, a 100G center that can't cope.
- ev("S.scrubAt='fra';S.scrubTier=0;S.biz.push({id:'b1',city:'fra',type:'scrub',bw:5,rate:900,mood:80,since:0,reqs:[]});S.ev.ddos={city:'fra',vec:'dns',gbps:6000,until:S.day+5,entry:{k:'t',lab:'x'},bh:false,start:S.day}");
+ ev("S.scrubs=[{city:'fra',tier:0}];S.biz.push({id:'b1',city:'fra',type:'scrub',bw:5,rate:900,mood:80,since:0,reqs:[]});S.ev.ddos={city:'fra',vec:'dns',gbps:6000,until:S.day+5,entry:{k:'t',lab:'x'},bh:false,start:S.day}");
ev("dayTick()");
assert.equal(ev('S.stats.sla'), 1, 'one SLA breach recorded');
assert.ok(ev('S.biz[0].mood') < 70, 'the SLA breach dented their mood');
@@ -281,7 +281,7 @@ test('DDoS goal and badges unlock from the right state', () => {
const okg = id => ev(`GOALS.find(g=>g.id==='${id}').ok()`);
const okb = id => ev(`BADGES.find(b=>b.id==='${id}').ok()`);
assert.equal(okg('scrub'), false, 'the DDoS goal starts incomplete');
- ev("S.scrubAt='fra';S.scrubTier=0");
+ ev("S.scrubs=[{city:'fra',tier:0}]");
assert.equal(okg('scrub'), true, 'a scrubbing center completes the goal');
assert.equal(okb('toaster'), false);
ev("S.stats.ddosHeld=1"); assert.equal(okb('toaster'), true, 'weathering a DDoS earns Toaster Wrangler');
@@ -354,3 +354,54 @@ test('loans: good terms need good credit, big loans want revenue, and the weird
assert.match(t, /numerologist/);
assert.deepEqual(errors, []);
});
+
+test('#117 several scrubbing centers: nearest first, spill to the next, and far ones haul the flood over the backbone', () => {
+ const { ev, errors, dom } = load();
+ // an old save with one center carries it over
+ ev("ACT.start({});S.cash=1e9;S.lvl=6;S.nextFail=1e9;S.nextEvent=1e9");
+ ev("const o=JSON.parse(JSON.stringify(S));o.scrubAt='fra';o.scrubTier=1;delete o.scrubs;migrate(o);window.__o=o");
+ assert.deepEqual(JSON.parse(ev("JSON.stringify(window.__o.scrubs)")), [{ city: 'fra', tier: 1 }]);
+ assert.equal(ev("'scrubAt' in window.__o||'scrubTier' in window.__o"), false);
+ // New York and London over one transatlantic wave
+ ev("for(const c of ['nyc','lon']){ACT.buildPop({city:c});}for(const c of ['fra','nyc','lon'])S.pops[c].rgen=3;ACT.launchBB({city:'nyc'});S.pops.nyc.bb.d=150");
+ ev("ACT.buyTransit({city:'nyc',net:'cog',tier:2});ACT.buyTransit({city:'lon',net:'cog',tier:3});UI.via='grace';UI.route='same';openLinkModal('nyc','lon');ACT.buildLink({tier:3});closeModal()");
+ const tl = "S.links.find(l=>[l.a,l.b].includes('nyc')).id";
+ const atk = g => ev(`S.ev.ddos={city:'nyc',vec:'http',gbps:${g},until:S.day+3,entry:{k:'t',lab:'x'},bh:false,start:S.day-5};compute()`);
+ // build in two cities, one each; the bill adds up
+ ev("ACT.buildScrub({city:'fra',tier:1});ACT.buildScrub({city:'lon',tier:1});ACT.buildScrub({city:'lon',tier:2})");
+ assert.deepEqual(JSON.parse(ev("JSON.stringify(S.scrubs.map(x=>x.city+':'+x.tier))")), ['fra:1', 'lon:1'], 'one center per city');
+ assert.equal(ev('scrubMo()'), 2 * ev('SCRUB_TIERS[1].mo'));
+ // Frankfurt has no backbone path from New York, so the flood goes to London, across the Atlantic
+ atk(0); const quiet = ev(`R.load[${tl}]||0`);
+ atk(600);
+ assert.deepEqual(JSON.parse(ev("JSON.stringify(R.haul.map(q=>q.to))")), ['lon']);
+ assert.ok(ev('R.haul[0].h') > 590, 'all of it fits on the 800G wave');
+ assert.ok(ev('R.haul[0].ms') > 30 && ev('R.haul[0].ms') < 120, `a transatlantic detour (${ev('R.haul[0].ms').toFixed(0)} ms)`);
+ assert.ok(ev(`R.load[${tl}]`) > quiet + 500, 'the flood fills the transatlantic link');
+ assert.match(ev('ddosPanel()'), /hauled over your backbone/);
+ // a protected customer in New York minds the detour
+ ev("S.biz.push({id:'bs',city:'nyc',type:'scrub',bw:5,rate:900,mood:80,since:0,reqs:['scrubnear']})");
+ assert.match(ev("bizWhy(S.biz.find(b=>b.id==='bs')).join(' ')"), /hauled to London/);
+ assert.equal(ev("REQS.scrubnear.ok(S.biz.find(b=>b.id==='bs'))"), false, 'no center in the Americas yet');
+ // a center in New York cleans it on the spot: nothing crosses the ocean
+ ev("ACT.buildScrub({city:'nyc',tier:0})");atk(600);
+ assert.equal(ev("R.haul.filter(q=>q.to==='lon').length"), 1, '100G local, the rest spills to London');
+ assert.equal(ev("R.haul.some(q=>q.to==='nyc')"), false);
+ assert.ok(ev("REQS.scrubnear.ok(S.biz.find(b=>b.id==='bs'))"));
+ ev("S.scrubs.find(x=>x.city==='nyc').tier=1");atk(600);
+ assert.equal(ev('R.haul.length'), 0, 'a 1T center at home takes it all');
+ assert.ok(ev(`R.load[${tl}]||0`) < quiet + 50);
+ // over a thin link only part of it can be hauled; the rest is not scrubbed
+ ev("ACT.rmScrub({city:'nyc'});ACT.rmScrub({city:'nyc'})");
+ assert.equal(ev("S.scrubs.some(x=>x.city==='nyc')"), false, 'shut down after confirming');
+ ev(`S.links.find(l=>l.id===${tl}).tier=1`);atk(600);
+ assert.ok(ev('R.haul[0].h') < 120 && ev('R.haul[0].h') > 0, `the 100G wave caps the haul (${ev('R.haul[0].h').toFixed(0)})`);
+ assert.match(ev('ddosPanel()'), /can only haul/);
+ // the Infra tab says where attacks go from here
+ ev("ACT.selCity&&ACT.selCity({id:'nyc'});UI.sel={type:'city',id:'nyc'};UI.tab='infra';renderPanel()");
+ assert.match(dom.window.document.getElementById('panelBody').textContent, /nearest scrubbing center\. From here that is London/);
+ // closing a POP closes its center
+ ev("ACT.decomOpen({});ACT.decomToggle({city:'lon'});ACT.decomGo()");
+ assert.equal(ev("S.scrubs.some(x=>x.city==='lon')"), false);
+ assert.deepEqual(errors, []);
+});