From 086502b782754e8cbee57061e9e7bf1c410b8a28 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Mon, 26 Oct 2026 16:47:55 +0100 Subject: [PATCH] Scrubbing centers in many POPs, with real backhaul (#117) S.scrubAt/S.scrubTier become S.scrubs, one center per city, each with its own size and monthly fee; old saves carry theirs over in sanitize(). An attack goes to the nearest working center with a backbone path, and spills to the next when it is full. A remote center's flood (plus a share of the victim's own traffic) is reserved along the backbone path after the L2 circuits, like a circuit: it fills those links, the round trip is shown in the NOC, and what the links cannot carry is not scrubbed and lands on the city. Local centers behave as before. DDoS protection customers lose mood while their attack detours 30+ ms, with the reason in their row; a new requirement asks for a center on the customer's continent. The Infra tab names the nearest center and its distance, and How to play explains it. --- CHANGELOG.md | 1 + site/i18n/fr.js | 11 ++++- site/i18n/it.js | 11 ++++- site/i18n/pt.js | 11 ++++- site/index.html | 100 ++++++++++++++++++++++++++++----------------- tests/game.test.js | 61 ++++++++++++++++++++++++--- 6 files changed, 146 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb7df9..5da019b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- You can now run a scrubbing center in every POP, not just one (#117). An attack goes to the nearest working center and spills to the next when it is full. A center in another city means the flood rides your backbone there and back: it fills your links, adds latency, and whatever your links cannot carry is not scrubbed. DDoS protection customers mind when their attacks are hauled across an ocean, some new customers ask for a center on their own continent, and the NOC shows where each attack is being cleaned. - A new Road to Tier 1 card in Goals shows what still stands between you and Tier 1 (#111, #121, #12). It counts the transit ports left to cancel, names the Tier 1s you still need a PNI with and what they want from you first, and shows how much of the internet you would still reach without transit. The Networks tab can list just the networks you reach only through transit, biggest first, each with why it is not peering with you yet and where to meet it: the cities for a PNI and the exchanges it sits on, your POPs first, then the nearest. Who your transit carries, in the NOC, names the nearest city when a network is not in yours and takes you straight to it. - Your own subsea cables now come in three designs, from the budget route to one as fast as the fastest cable on the map, and two upgrades carry faster channels further (#65). Each design shows its latency, price and build time before you order: optimized costs three times as much and low latency seven times, and both take months longer. Premium terminals and optical engineering light longer routes at higher speeds, so a cable as long as New York to Sydney can now carry traffic, and the order screen tells you which upgrade a route needs. Calling off a cable while it is being laid refunds what you actually paid for it. - Only Spätzle-IX can now be won with peering alone (#114). The goal is now 45% reach and 300 Gbps served, and the scenario card shows your reach as well as your traffic. diff --git a/site/i18n/fr.js b/site/i18n/fr.js index 765ebdc..7f6b310 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -930,7 +930,6 @@ "Reaching your network: {g}":"Ce qui atteint ton réseau : {g}", "On-demand scrubbing diverting, live in {n}d":"Scrubbing à la demande en cours de redirection, actif dans {n} j", "{tier} scrubbing in {city} is cleaning it":"Le scrubbing {tier} à {city} le nettoie", -"{tier} scrubbing is over capacity: {g} leaks past":"Le scrubbing {tier} est saturé : {g} passent quand même", "{net} is scrubbing it upstream (clean-pipe)":"{net} le nettoie en amont (clean-pipe)", "Contained on your sacrificial {net} PNI":"Contenu sur ton PNI sacrificiel {net}", "IX blackhole on ✓":"Blackhole IX actif ✓", @@ -1523,7 +1522,6 @@ "Upgrade to {tier} {cost}":"Passer à {tier} {cost}", "Really shut it down?":"Vraiment l’arrêter ?", "Shut down":"Arrêter", -"You already run one in {city}.":"Tu en as déjà un à {city}.", "Cleans DDoS attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts for businesses.":"Nettoie les attaques DDoS pour tout ton réseau, dans la limite de sa capacité de bande passante propre, et débloque les contrats de protection DDoS pour les entreprises.", "Build {tier} {cost} + {mo}/mo":"Construire {tier} {cost} + {mo}/mois", "Interconnection fabrics (NNI)":"Fabrics d’interconnexion (NNI)", @@ -2613,4 +2611,13 @@ "Reach without transit":"Couverture sans transit", "All {n} out of reach":"Les {n} hors couverture", "Where?":"Où ?", +"Attack hauled to scrubbing in {city}":"Attaque acheminée vers le scrubbing de {city}", +"Wants a scrubbing center on its own continent, so attacks are not hauled across an ocean":"Veut un centre de scrubbing sur son continent, pour que les attaques ne traversent pas un océan", +"Your backbone can only haul {g} of it to {city}: the rest is not scrubbed":"Ton backbone ne peut en acheminer que {g} jusqu’à {city} : le reste n’est pas nettoyé", +"{tier} scrubbing in {city} is cleaning it, hauled over your backbone (+{ms} ms)":"Le scrubbing {tier} à {city} le nettoie, acheminé par ton backbone (+{ms} ms)", +"Your scrubbing centers are full: {g} leaks past":"Tes centres de scrubbing sont pleins : {g} passent quand même", +"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.":"Les attaques vont vers ton centre de scrubbing le plus proche. D’ici, c’est {city}, à {km} km : le flot traverse ton backbone aller et retour, ce qui ajoute de la latence, et ce que tes liens ne peuvent pas porter n’est pas nettoyé. Un centre ici nettoie les attaques sur place.", +"attacks on {city} are hauled to {to} for scrubbing: +{ms} ms":"les attaques sur {city} sont acheminées vers {to} pour le scrubbing : +{ms} ms", +"Scrubbing centers":"Centres de scrubbing", +"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.":"Construis-en dans autant de POP que tu veux. Une attaque va vers le centre en service le plus proche, et ce qu’il ne peut pas absorber passe au suivant. Un centre lointain veut dire que le flot traverse ton backbone jusque-là et que le trafic de la victime revient par le chemin long : ça remplit tes liens, ça ajoute de la latence, et ce que les liens ne peuvent pas porter n’est pas nettoyé. Les clients qui achètent une protection DDoS le remarquent quand leurs attaques traversent un océan.", }; diff --git a/site/i18n/it.js b/site/i18n/it.js index 5b2d060..73b220c 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -929,7 +929,6 @@ "Reaching your network: {g}":"Arriva alla tua rete: {g}", "On-demand scrubbing diverting, live in {n}d":"Scrubbing on-demand in deviazione, attivo tra {n}g", "{tier} scrubbing in {city} is cleaning it":"Lo scrubbing {tier} a {city} lo sta pulendo", -"{tier} scrubbing is over capacity: {g} leaks past":"Lo scrubbing {tier} è oltre capacità: {g} passano comunque", "{net} is scrubbing it upstream (clean-pipe)":"{net} lo sta ripulendo a monte (clean-pipe)", "Contained on your sacrificial {net} PNI":"Contenuto sulla tua PNI sacrificale {net}", "IX blackhole on ✓":"Blackhole IX attivo ✓", @@ -1522,7 +1521,6 @@ "Upgrade to {tier} {cost}":"Aggiorna a {tier} {cost}", "Really shut it down?":"Spegnerlo davvero?", "Shut down":"Spegni", -"You already run one in {city}.":"Ne hai già uno a {city}.", "Cleans DDoS attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts for businesses.":"Ripulisce gli attacchi DDoS per tutta la tua rete, fino alla sua capacità di banda pulita, e sblocca i contratti di protezione DDoS per le aziende.", "Build {tier} {cost} + {mo}/mo":"Costruisci {tier} {cost} + {mo}/mese", "Interconnection fabrics (NNI)":"Fabric di interconnessione (NNI)", @@ -2613,4 +2611,13 @@ "Reach without transit":"Copertura senza transit", "All {n} out of reach":"Tutte le {n} fuori copertura", "Where?":"Dove?", +"Attack hauled to scrubbing in {city}":"Attacco portato allo scrubbing di {city}", +"Wants a scrubbing center on its own continent, so attacks are not hauled across an ocean":"Vuole un centro di scrubbing nel suo continente, così gli attacchi non attraversano un oceano", +"Your backbone can only haul {g} of it to {city}: the rest is not scrubbed":"Il tuo backbone riesce a portarne solo {g} a {city}: il resto non viene pulito", +"{tier} scrubbing in {city} is cleaning it, hauled over your backbone (+{ms} ms)":"Lo scrubbing {tier} a {city} lo sta pulendo, portato lì sul tuo backbone (+{ms} ms)", +"Your scrubbing centers are full: {g} leaks past":"I tuoi centri di scrubbing sono pieni: {g} passano lo stesso", +"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.":"Gli attacchi vanno al tuo centro di scrubbing più vicino. Da qui è {city}, a {km} km: il flusso viaggia sul tuo backbone fin lì e ritorno, il che aggiunge latenza, e quello che i tuoi link non riescono a portare non viene pulito. Un centro qui pulisce gli attacchi sul posto.", +"attacks on {city} are hauled to {to} for scrubbing: +{ms} ms":"gli attacchi su {city} vengono portati a {to} per lo scrubbing: +{ms} ms", +"Scrubbing centers":"Centri di scrubbing", +"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.":"Costruiscine uno in tutti i POP che vuoi. Un attacco va al centro funzionante più vicino, e quello che non riesce a gestire passa al successivo. Un centro lontano vuol dire che il flusso viaggia sul tuo backbone fin lì e il traffico della vittima torna per la strada lunga: riempie i tuoi link, aggiunge latenza, e quello che i link non riescono a portare non viene pulito. I clienti che comprano protezione DDoS se ne accorgono quando i loro attacchi attraversano un oceano.", }; diff --git a/site/i18n/pt.js b/site/i18n/pt.js index 69b4cd0..0851f83 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -929,7 +929,6 @@ "Reaching your network: {g}":"Chegando na sua rede: {g}", "On-demand scrubbing diverting, live in {n}d":"Scrubbing on-demand desviando, ativo em {n}d", "{tier} scrubbing in {city} is cleaning it":"O scrubbing {tier} em {city} está limpando", -"{tier} scrubbing is over capacity: {g} leaks past":"Scrubbing {tier} acima da capacidade: {g} vaza", "{net} is scrubbing it upstream (clean-pipe)":"{net} está limpando upstream (clean-pipe)", "Contained on your sacrificial {net} PNI":"Contido no seu PNI sacrificial com {net}", "IX blackhole on ✓":"Blackhole IX ativo ✓", @@ -1521,7 +1520,6 @@ "Upgrade to {tier} {cost}":"Upgrade para {tier} {cost}", "Really shut it down?":"Desligar mesmo?", "Shut down":"Desligar", -"You already run one in {city}.":"Você já tem um em {city}.", "Cleans DDoS attacks for your whole network, up to its clean-bandwidth capacity, and unlocks DDoS protection contracts for businesses.":"Limpa ataques DDoS de toda a sua rede, até a capacidade de banda limpa, e libera contratos de proteção DDoS para empresas.", "Build {tier} {cost} + {mo}/mo":"Construir {tier} {cost} + {mo}/mês", "Interconnection fabrics (NNI)":"Fabrics de interconexão (NNI)", @@ -2613,4 +2611,13 @@ "Reach without transit":"Alcance sem transit", "All {n} out of reach":"Todas as {n} fora de alcance", "Where?":"Onde?", +"Attack hauled to scrubbing in {city}":"Ataque levado ao scrubbing em {city}", +"Wants a scrubbing center on its own continent, so attacks are not hauled across an ocean":"Quer um centro de scrubbing no próprio continente, para que os ataques não atravessem um oceano", +"Your backbone can only haul {g} of it to {city}: the rest is not scrubbed":"Seu backbone só consegue levar {g} até {city}: o resto não é limpo", +"{tier} scrubbing in {city} is cleaning it, hauled over your backbone (+{ms} ms)":"O scrubbing {tier} em {city} está limpando, levado pelo seu backbone (+{ms} ms)", +"Your scrubbing centers are full: {g} leaks past":"Seus centros de scrubbing estão cheios: {g} passam direto", +"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.":"Os ataques vão para o seu centro de scrubbing mais próximo. Daqui é {city}, a {km} km: a enxurrada viaja pelo seu backbone até lá e volta, o que aumenta a latência, e o que seus links não conseguem levar não é limpo. Um centro aqui limpa os ataques na hora.", +"attacks on {city} are hauled to {to} for scrubbing: +{ms} ms":"os ataques em {city} são levados a {to} para scrubbing: +{ms} ms", +"Scrubbing centers":"Centros de scrubbing", +"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.":"Construa um em quantos POPs quiser. Um ataque vai para o centro ativo mais próximo, e o que ele não aguenta transborda para o seguinte. Um centro distante significa que a enxurrada viaja pelo seu backbone até lá e o tráfego da vítima volta pelo caminho longo: enche seus links, aumenta a latência, e o que os links não conseguem levar não é limpo. Clientes que compram proteção DDoS percebem quando os ataques deles atravessam um oceano.", }; diff --git a/site/index.html b/site/index.html index 90803aa..c93abf8 100644 --- a/site/index.html +++ b/site/index.html @@ -606,8 +606,8 @@ const CN_LIC=150000, CN_JV_MO=6000; // but takes a couple of days to engage. A clean-pipe add-on on a transit scrubs upstream, per port. const SCRUB_TIERS=[{n:'100G',g:100,cost:60000,mo:5000,lvl:1},{n:'1T',g:1000,cost:180000,mo:15000,lvl:3},{n:'10T',g:10000,cost:500000,mo:40000,lvl:4},{n:'100T',g:100000,cost:1500000,mo:110000,lvl:10}]; const SCRUB_DELAY=2, SLA_PEN=20000; -const scrubG=()=>SCRUB_TIERS[S.scrubTier||0].g; -const scrubMo=()=>Math.round(SCRUB_TIERS[S.scrubTier||0].mo*(S.scrubMode==='ondemand'?0.6:1)); +const scrubMo1=x=>Math.round(SCRUB_TIERS[x.tier||0].mo*(S.scrubMode==='ondemand'?0.6:1)),scrubMo=()=>S.scrubs.reduce((a,x)=>a+scrubMo1(x),0); +const hasScrub=()=>!!(S&&S.scrubs&&S.scrubs.length),SCRUB_FAR_MS=30; const cleanMo=t=>Math.round(PORT[t.tier].g*(t.n||1)*5); // DDoS has a shape now: a vector, a size and an entry point. A vector's `fs` is whether Flowspec can drop // it at the edge — it catches the known volumetric UDP floods, but an application-layer HTTP flood sails @@ -1407,7 +1407,7 @@ const GOALS=[ {id:'rd',t:tr('Survive a failure'),d:tr('Things break all the time. Build a second path or a second upstream so traffic reroutes when something dies.'),r:12500,ok:()=>S.stats.survived>0}, {id:'ca',t:tr('Host an embedded cache'),d:tr('Big CDNs give you free cache boxes once you send them enough traffic. Free bandwidth, just add power.'),r:12500,ok:()=>S.caches.length>0}, {id:'pn',t:tr('Set up a PNI'),d:tr('A private cross-connect to one network in the same data center, for when traffic outgrows the IX.'),r:15000,ok:()=>S.pni.length>0}, - {id:'scrub',t:tr('Stand up DDoS defences'),d:tr('Build a scrubbing center from a POP\'s Infra tab. It cleans attacks up to its capacity and lets you sell DDoS protection.'),r:20000,ok:()=>!!S.scrubAt}, + {id:'scrub',t:tr('Stand up DDoS defences'),d:tr('Build a scrubbing center from a POP\'s Infra tab. It cleans attacks up to its capacity and lets you sell DDoS protection.'),r:20000,ok:()=>hasScrub()}, {id:'c3',t:tr('Go global'),d:tr('Have POPs on 3 continents. Subsea cables cost a fortune, so plan the route.'),r:50000,ok:()=>regionsCount()>=3}, {id:'t2',t:tr('Become a Tier 2'),d:tr('5+ POPs, ports on 3+ IXs and 15+ peering sessions.'),r:50000,ok:()=>isTier2()}, {id:'tb',t:tr('Serve 1 Tbps'),d:tr('A terabit per second of happy traffic.'),r:75000,ok:()=>R.served>=1000}, @@ -1686,7 +1686,7 @@ function scenarioModal(){const wk=weekly(),h=scnHof();let best=null;try{best=JSO function newGame(name,home){ S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH, ltv:2,t1v:2,seen:NETS.map(n=>n.id),spares:{},pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{}, - done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubAt:null,scrubTier:0,scrubMode:'always',won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0}; + done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubs:[],scrubMode:'always',won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0}; } /* ================= HELPERS ================= */ @@ -1958,7 +1958,7 @@ function compute(){ // Customer demand per city, added up in S.biz order (what filtering S.biz for each city would give). const bizBw={};for(const b of S.biz){const T=BIZ_T[b.type];if(!T.l2&&!T.fiber&&(!T.event||eventLive(b))){const v=bizBw[b.city];bizBw[b.city]=(v===undefined?0:v)+b.bw;}} // Traffic shares by network index, and their sums, for each share table (and with Russia's throttle). - const shArr=new Map(),shSum=new Map(),DEMTO=new Float64Array(NN),loc=scnRule('local'); + const shArr=new Map(),shSum=new Map(),DEMTO=new Float64Array(NN),loc=scnRule('local'),HAUL=[];R2.haul=[]; for(const c of Object.keys(S.pops)){ const p=S.pops[c],ci=CIDX[c],cn=cnCity(c),SH=cn?NSH_CN:ruCity(c)?NSH_RU:CITY[c].kr&&S.krExit?NSH_KRX:NSH;const eye=(p.bb?p.bb.d:0)*viral*(cn&&ev.golden>day?1.4:1);const biz=bizBw[c]??0;const d0=eye+biz; // Goggle video is throttled in Russia (#70): people there get half of it, so they ask for half. It is not @@ -1976,11 +1976,13 @@ function compute(){ let dd=0; if(atk&&!rtbh){let mult=1;const en=atk.entry||{}; if(DDOS_VEC[atk.vec]&&DDOS_VEC[atk.vec].fs){const cap=fsAt(atk.city);if(cap)mult=Math.min(mult,FS_RES[cap]);} - mult=Math.min(mult,scrubMult(atk)); if(en.k==='t'){const t=S.transit.find(x=>x.id===en.id);if(t&&t.clean)mult=Math.min(mult,0.1);} if(atk.ixbh&&hasIxAt(atk.city))mult=Math.min(mult,0.5); if(edge)mult=0; - dd=atk.gbps*mult; + // Scrubbing is used when it beats the edge tools; floods for a center in another city are hauled after the circuits below. + const sp=edge?null:scrubPlan(atk); + if(sp&&scrubIdeal(sp)x.id===en.id);if(p&&p.sacrif)dd=Math.min(dd,liveCap(PORT[p.tier].g,p.city,p.site,p.n)*0.9);}} const bh=rtbh||edge; if(dd>0)for(let j=0;j'+b.city2;R2.div[b.id]=divMemo[k]??(divMemo[k]=disjointI(b.city,b.city2));}} + /* A flood for a scrubbing center elsewhere rides the backbone there, with the victim's own traffic (#117). + What the links cannot carry is not scrubbed and lands on the city after all. */ + for(const H of HAUL){const A=H.c,B=H.to,Ai=CIDX[A],Bi=CIDX[B];let h=0,ms=null; + if(popUp(A)&&popUp(B)&&SPD[A]&&SPD[A][Bi]0?H.a*take/want:0;ms=path.reduce((x,e)=>x+e.lat,0)*2; + const ek='scrub:'+B;R2.egDesc[ek]={lab:labOf(N_('Attack hauled to scrubbing in {city}'),'city',CITY[B].name),city:A,k:'l2'}; + for(const i of ni)if(HAS[i])nodeTake(i,take);for(const l of path){l.res-=take;l.ld+=take;carry(l,ek,NN,Ai,take);}} + R2.haul.push({city:A,to:B,tier:H.tier,a:H.a,h,ms});const left=(H.a-h)*0.85;if(left>1e-6)for(let j=0;j{const key=src*NC+dst,c0=teCache.get(key); if(c0===false)return null;if(c0&&c0.path.every(l=>l.res>1e-3)&&c0.ni.every(i=>!HAS[i]||NRES[i]>1e-3))return c0; @@ -2155,7 +2165,7 @@ function compute(){ C.pni=S.pni.reduce((a,p)=>a+pniMo(p,R2.usePni[p.id]||0),0); C.caches=S.caches.length*CACHE_MO; C.loans=(S.loans||[]).reduce((a,l)=>a+(BANKS[l.bank].equity?0:l.model==='transit'?Math.round((C.transit||0)*(l.cut||0.3)):l.pay)+loanFees(l),0); - C.extras=(S.cnLic&&S.cnLic.state==='ok'?CN_JV_MO:0)+(S.scrubAt?scrubMo():0)+Object.keys(S.pops).filter(ruCity).length*RU_BOX_MO+Object.values(S.pops).filter(p=>p.site2).length*SITE2_MO+(S.te?TE_MO:0); + C.extras=(S.cnLic&&S.cnLic.state==='ok'?CN_JV_MO:0)+scrubMo()+Object.keys(S.pops).filter(ruCity).length*RU_BOX_MO+Object.values(S.pops).filter(p=>p.site2).length*SITE2_MO+(S.te?TE_MO:0); V.eyeballs=0;V.business=0;V.ix=0; for(const c in S.pops){const sf=sfOf(R2,c);V.eyeballs+=R2.cityEye[c]*sf*EYE_RATE*(CITY[c].arpu||1);} for(const b of S.biz){const sf=BIZ_T[b.type].fiber?(fiberOk(b)?1:0):BIZ_T[b.type].l2?clamp((R2.l2[b.id]||0)/b.bw,0,1):sfOf(R2,b.city);V.business+=b.bw*b.rate*Math.min(1,sf/0.95);} @@ -2208,8 +2218,10 @@ function sanitize(s){ s.inc=s.inc.filter(i=>i&&typeof i.type==='string').map(i=>(i.id=sid(i.id),i.until=num(i.until,s.day),i.cost=num(i.cost,0),i.msg=String(i.msg||'').slice(0,400),i.fix=i.fix==null?undefined:String(i.fix).slice(0,60),i)); s.loans=s.loans.filter(l=>l&&own(BANKS,l.bank));for(const l of s.loans){if(l.model!==undefined&&!['balloon','storm','transit','astro'].includes(l.model))delete l.model;for(const k of ['apr0','cut','share'])if(l[k]!==undefined&&!isFinite(+l[k]))delete l[k];if(!Array.isArray(l.covs))l.covs=[];l.covs=l.covs.filter(c=>own(COVS,c));}s.loanOffers=s.loanOffers.filter(l=>l&&own(BANKS,l.bank)); s.usedNames=s.usedNames.filter(x=>typeof x==='string');s.log=s.log.filter(e=>e&&typeof e.t==='string').slice(0,30); - if(s.scrubAt&&!isCity(s.scrubAt))s.scrubAt=null; - s.scrubTier=int(s.scrubTier,0,SCRUB_TIERS.length-1,0);s.scrubMode=s.scrubMode==='ondemand'?'ondemand':'always'; + // One scrubbing center became a list (#117): older saves carry theirs over. + if(!Array.isArray(s.scrubs))s.scrubs=s.scrubAt&&isCity(s.scrubAt)?[{city:s.scrubAt,tier:s.scrubTier}]:[];delete s.scrubAt;delete s.scrubTier; + {const seen=new Set();s.scrubs=s.scrubs.filter(x=>x&&typeof x==='object'&&isCity(x.city)&&s.pops[x.city]&&!seen.has(x.city)&&seen.add(x.city)).map(x=>({city:x.city,tier:int(x.tier,0,SCRUB_TIERS.length-1,0)}));} + s.scrubMode=s.scrubMode==='ondemand'?'ondemand':'always'; if(s.ev&&s.ev.ddos){const a=s.ev.ddos; if(!a||typeof a!=='object'||!isCity(a.city)||!own(DDOS_VEC,a.vec))delete s.ev.ddos; else{a.gbps=num(a.gbps,2);a.until=num(a.until,s.day);a.bh=!!a.bh;a.ixbh=!!a.ixbh;a.start=num(a.start,s.day); @@ -2219,7 +2231,7 @@ function sanitize(s){ function migrate(s){sanitize(s);if(s.scn&&s.scn.id==='stg'&&s.scn.rules&&typeof s.scn.rules==='object')s.scn.rules.local=true;for(const b of [...s.biz,...s.offers])if(Array.isArray(b.reqs))b.reqs=b.reqs.filter(k=>!REQS[k]||!REQS[k].can||(isCity(b.city)&&(!b.city2||isCity(b.city2))&&REQS[k].can(b,s)));if(s.ltv!==2){for(const l of s.links)if(l.kind==='wave'&&l.tier>=3)l.tier=Math.min(LT.length-1,l.tier+1);s.ltv=2;}if(s.dk){s.dk.m=s.dk.m||{};s.dk.add=s.dk.add||{};s.dk.ret=s.dk.ret||{};s.dk.retUsed=s.dk.retUsed||{};}s.hist=s.hist||[];s.loans=s.loans||[];s.loanOffers=s.loanOffers||[];s.loanStrikes=s.loanStrikes||0;for(const l of s.links||[])if(!l.kind)l.kind='wave'; for(const c in s.pops){const p=s.pops[c];if(p.rgen===undefined){let g=0;const need=(i,key)=>{const k=RG.findIndex(r=>r[key]>=i);if(k>g)g=k;}; for(const l of s.links||[])if((l.a===c||l.b===c)&&l.kind==='wave')need(l.tier,'maxLT'); - for(const t of s.transit||[])if(t.city===c)need(t.tier,'maxP');for(const x of s.pni||[])if(x.city===c)need(x.tier,'maxP');if(s.ixp&&s.ixp[c]!==undefined)need(s.ixp[c],'maxP');p.rgen=g;}}for(const b of s.biz||[])if(!b.reqs)b.reqs=BIZ_T[b.type]&&BIZ_T[b.type].div?['diverse']:[];for(const o of s.offers||[])if(!o.reqs)o.reqs=[];if(!s.lvl)s.lvl=1;s.nni=s.nni||[];s.cnLic=s.cnLic||{state:'none'};if(s.scrubAt===undefined)s.scrubAt=null;s.ev=s.ev||{};for(const l of s.links){if(!l.kind)l.kind='wave';if(l.mo===undefined)l.mo=Math.round(waveMo(l.km,l.sub,l.tier)*(l.mult||1));}for(const c in s.pops){if(!s.pops[c].routers)s.pops[c].routers=1;} + for(const t of s.transit||[])if(t.city===c)need(t.tier,'maxP');for(const x of s.pni||[])if(x.city===c)need(x.tier,'maxP');if(s.ixp&&s.ixp[c]!==undefined)need(s.ixp[c],'maxP');p.rgen=g;}}for(const b of s.biz||[])if(!b.reqs)b.reqs=BIZ_T[b.type]&&BIZ_T[b.type].div?['diverse']:[];for(const o of s.offers||[])if(!o.reqs)o.reqs=[];if(!s.lvl)s.lvl=1;s.nni=s.nni||[];s.cnLic=s.cnLic||{state:'none'};s.ev=s.ev||{};for(const l of s.links){if(!l.kind)l.kind='wave';if(l.mo===undefined)l.mo=Math.round(waveMo(l.km,l.sub,l.tier)*(l.mult||1));}for(const c in s.pops){if(!s.pops[c].routers)s.pops[c].routers=1;} {const all=NETS.map(n=>n.id),seen=Array.isArray(s.seen)?s.seen.filter(x=>typeof x==='string'):null,fresh=seen?all.filter(id=>!seen.includes(id)):all; if(fresh.length&&(s.day||0)>0){const g=s.grace&&s.grace.until>s.day?s.grace:{nets:[]};s.grace={until:s.day+GRACE_DAYS,nets:[...new Set(g.nets.concat(fresh))],fresh:seen?fresh.length:0};} s.seen=all;} @@ -2240,7 +2252,8 @@ const REQS={ metro:{l:tr('Two data centers in every metro they touch'),bonus:.2,only:true,ok:b=>[b.city,b.city2].filter(Boolean).every(c=>S.pops[c]&&S.pops[c].site2)}, twoup:{l:tr('Wants two different transit providers (or none at all)'),bonus:.15,ip:true,ok:()=>new Set(S.transit.map(t=>t.net)).size>=2||S.transit.length===0}, china:{l:tr('Needs low-loss reach into China'),bonus:.3,ip:true,ok:()=>S.transit.some(t=>t.premium&&t.city==='hkg')||S.links.some(l=>l.premium)||S.pni.some(p=>NET[p.net].cn)}, - scrubbed:{l:tr('Will only sign with a network that runs a DDoS scrubbing center'),bonus:.15,ok:()=>!!S.scrubAt}, + scrubbed:{l:tr('Will only sign with a network that runs a DDoS scrubbing center'),bonus:.15,ok:()=>hasScrub()}, + scrubnear:{l:tr('Wants a scrubbing center on its own continent, so attacks are not hauled across an ocean'),bonus:.15,ip:true,ok:b=>S.scrubs.some(x=>CITY[x.city].reg===CITY[b.city].reg)}, puns:{l:tr('Their CEO hates puns. Please do not mention the network names.'),bonus:.05,ok:()=>true}, }; function terrestrialPath(a,b){const ls=S.links.filter(l=>!linkDown(l)&&!l.sub);const adj={};for(const l of ls){(adj[l.a]=adj[l.a]||[]).push(l.b);(adj[l.b]=adj[l.b]||[]).push(l.a);}const seen=new Set([a]),q=[a];while(q.length){const u=q.shift();if(u===b)return true;for(const v of adj[u]||[])if(!seen.has(v)){seen.add(v);q.push(v);}}return false;} @@ -2420,8 +2433,15 @@ function ddosEntry(c){const o=[]; const fsAt=c=>{const p=S.pops[c];return p?(RG[p.rgen||0].fs||0):0;}; // Scrubbing residual for an attack: clean up to the center's capacity (to 15%), overflow leaks. On-demand // does nothing for the first couple of days while traffic is being diverted. -function scrubEngaged(atk){return !!S.scrubAt&&(S.scrubMode==='always'||(S.day-(atk.start||S.day))>=SCRUB_DELAY);} -function scrubMult(atk){if(!scrubEngaged(atk))return 1;const cap=scrubG(),g=atk.gbps||0;if(g<=0)return 1;return g<=cap?0.15:(cap*0.15+(g-cap))/g;} +function scrubEngaged(atk){return hasScrub()&&(S.scrubMode==='always'||(S.day-(atk.start||S.day))>=SCRUB_DELAY);} +// Several centers (#117): the flood goes to the nearest working one, and what it cannot take spills to the next. +// A center in another city only helps if the backbone can carry the flood there; routing works that out. +const scrubFar=c=>{const a=S.ev&&S.ev.ddos;return a&&a.until>S.day&&a.city===c&&(R.haul||[]).find(q=>q.city===c&&q.ms!==null&&q.ms>=SCRUB_FAR_MS)||null;}; +function scrubPlan(atk){if(!scrubEngaged(atk))return null;const c=atk.city;let g=atk.gbps||0;const parts=[]; + for(const x of S.scrubs.filter(x=>popUp(x.city)&&(x.city===c||pathExists(c,x.city))).sort((a,b)=>(a.city===c?0:kmBetween(c,a.city))-(b.city===c?0:kmBetween(c,b.city)))){if(g<=0)break;const a=Math.min(g,SCRUB_TIERS[x.tier||0].g);parts.push({city:x.city,tier:x.tier||0,a});g-=a;} + return parts.length?{parts,leak:g}:null;} +// What still lands on the city if every haul gets through: 15% of what is scrubbed, plus whatever no center can take. +const scrubIdeal=p=>p?p.parts.reduce((s,x)=>s+x.a*0.15,0)+p.leak:Infinity; // The NOC's live attack view: what is hitting you, what each tool would do about it right now, and the buttons. function ddosPanel(){ const a=S&&S.ev&&S.ev.ddos;if(!a||a.until<=S.day||!S.pops[a.city])return ''; @@ -2429,21 +2449,24 @@ function ddosPanel(){ const cleanT=en.k==='t'?S.transit.find(x=>x.id===en.id):null, sacP=en.k==='p'?S.pni.find(x=>x.id===en.id):null; let mult=1; if(V.fs&&cap)mult=Math.min(mult,FS_RES[cap]); - mult=Math.min(mult,scrubMult(a)); if(cleanT&&cleanT.clean)mult=Math.min(mult,0.1); if(a.ixbh&&hasIxAt(a.city))mult=Math.min(mult,0.5); - let land=a.bh?0:a.gbps*mult; + const sp=scrubPlan(a),useS=!!sp&&scrubIdeal(sp)(R.haul||[]).find(q=>q.city===a.city&&q.to===x.city); + let land=a.bh?0:useS?sp.parts.reduce((t,x)=>{const q=x.city===a.city?null:hl(x);return t+x.a*0.15+(q?(q.a-q.h)*0.85:0);},sp.leak):a.gbps*mult; if(sacP&&sacP.sacrif)land=Math.min(land,liveCap(PORT[sacP.tier].g,sacP.city,sacP.site,sacP.n)*0.9); land=Math.round(land); const fsLine=!V.fs?'— '+tr('Flowspec cannot catch an {vec} (application layer)',{vec:esc(V.n)}) :cap>=2?'✓ '+tr('Flowspec on your {model} is dropping {vec} at the edge',{model:esc(model),vec:esc(V.n)}) :cap===1?'~ '+tr('Flowspec on your {model} trims {vec}, but its TCAM is small',{model:esc(model),vec:esc(V.n)}) :'— '+tr('Your {model} here has no Flowspec TCAM',{model:esc(model)}); - const T=SCRUB_TIERS[S.scrubTier||0]; - const scrLine=!S.scrubAt?'— '+tr('No scrubbing center') + const scrOne=x=>{const T=SCRUB_TIERS[x.tier],q=x.city===a.city?null:hl(x); + return q&&q.h')+(sp.leak>0.5?'
~ '+tr('Your scrubbing centers are full: {g} leaks past',{g:fmtG(sp.leak)}):''); const entryLine=cleanT&&cleanT.clean?'✓ '+tr('{net} is scrubbing it upstream (clean-pipe)',{net:esc(NET[cleanT.net].name)}) :sacP&&sacP.sacrif?'✓ '+tr('Contained on your sacrificial {net} PNI',{net:esc(NET[sacP.net].name)}):''; let h=`
@@ -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, []); +});