From fbe2dab565f8ecfdd6541f99feff8fca51166f4b Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Fri, 23 Oct 2026 09:08:51 +0200 Subject: [PATCH] Add LAGs for transit, IX ports and PNIs Bundle up to 8 identical ports to the same transit provider, IX or PNI. Each member costs a full port and adds capacity; flow hashing is never perfectly even, so a bundle carries about 95% of the sum. Upgrading the port speed upgrades every member. Also fix goals completed on day 0 paying their reward again on every action that day. --- CHANGELOG.md | 1 + README.md | 4 ++-- site/index.html | 47 ++++++++++++++++++++++++++-------------------- tests/game.test.js | 32 +++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22e8e79..91933ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ First public release. (lease or build) with DWDM line systems, amplifiers and ZR+/transponder optics. - Router generations from 100G to 1.6T ports, extra routers and generators for redundancy. +- LAGs: bundle up to 8 identical ports to the same transit provider, IX or PNI. - Traffic engineering: per-link traffic breakdown, link metrics, egress preferences, latency-aware and scenic routing. - Mainland China (licenses, the Great Firewall, premium routes via Hong Kong), diff --git a/README.md b/README.md index 4075878..f29d683 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ You start with one router in one city and grow into a transit-free Tier 1: with route servers, open/selective/restrictive/paid peering, PNIs, embedded CDN caches, and NNI fabrics for virtual circuits and remote peering. - **Infrastructure:** leased waves on around 40 real-ish subsea cable systems, - dark fiber (leased or self-built) lit with DWDM and ZR+ optics, and router - generations that cap your port speeds. + dark fiber (leased or self-built) lit with DWDM and ZR+ optics, router + generations that cap your port speeds, and LAGs to bundle ports when one isn't enough. - **Traffic engineering:** see exactly what fills each link, tune link metrics and egress preferences, and route traders over the fastest path and backups the scenic way. - **Things break, constantly:** backhoes, sharks, fat fingers, route leaks, RPKI diff --git a/site/index.html b/site/index.html index e42aa8c..184ccbc 100644 --- a/site/index.html +++ b/site/index.html @@ -668,7 +668,11 @@ const popUp=c=>S.pops[c]&&!(S.pops[c].down>S.day); const regionsCount=()=>new Set(Object.keys(S.pops).map(c=>CITY[c].reg)).size; function ixName(c){return S.myIx[c]?S.myIx[c].name:CITY[c].ix;} function ixMembers(c){if(S.myIx[c])return S.myIx[c].members.slice();if(!CITY[c].ix)return [];return NETS.filter(n=>n.ix==='ALL'||(Array.isArray(n.ix)&&n.ix.includes(c))).map(n=>n.id);} -function ixCap(c){return S.myIx[c]?400:PORT[S.ixp[c]].g;} +// LAG: several identical ports bundled into one logical link. Flow hashing is never perfectly even, so a bundle carries ~95% of the sum. +const LAG_MAX=8; +function lagCap(g,n){n=n||1;return g*n*(n>1?0.95:1);} +function lagName(tier,n){return (n||1)>1?`${n}×${PORT[tier].n} LAG`:`${PORT[tier].n} port`;} +function ixCap(c){return S.myIx[c]?400:lagCap(PORT[S.ixp[c]].g,(S.ixn||{})[c]);} function ixSessions(c){ const s=new Set(); if(S.ixp[c]===undefined)return s; for(const id of ixMembers(c)){const n=NET[id]; @@ -714,10 +718,10 @@ function compute(){ const E=[], ev=S.ev; const depeer=ev.depeer>day, leak=ev.leak&&ev.leak.until>day?ev.leak.net:null; for(const t of S.transit){if(!popUp(t.city)||t.down>day)continue; - E.push({k:'t',prem:!!t.premium&&t.city==='hkg',pref:t.pref||'normal',lab:NET[t.net].name+' transit',id:t.id,city:t.city,cap:PORT[t.tier].g,used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak});} + E.push({k:'t',prem:!!t.premium&&t.city==='hkg',pref:t.pref||'normal',lab:NET[t.net].name+' transit',id:t.id,city:t.city,cap:lagCap(PORT[t.tier].g,t.n),used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak});} for(const c in S.ixp){if(!(popUp(c)||remote.includes(c))||(S.ev.ixdown&&S.ev.ixdown[c]>day))continue;const set=ixSessions(c);R2.sessions+=set.size; E.push({k:'ix',pref:(S.ixPref&&S.ixPref[c])||'normal',lab:ixName(c)+' peering',id:c,city:c,cap:ixCap(c),used:0,rank:2,ok:n=>set.has(n)});} - for(const p of S.pni){R2.sessions++;if(!popUp(p.city))continue;E.push({k:'p',pnc:!!NET[p.net].cn,pref:p.pref||'normal',lab:'PNI with '+NET[p.net].name,id:p.id,city:p.city,cap:PORT[p.tier].g,used:0,rank:1,ok:n=>n===p.net});} + for(const p of S.pni){R2.sessions++;if(!popUp(p.city))continue;E.push({k:'p',pnc:!!NET[p.net].cn,pref:p.pref||'normal',lab:'PNI with '+NET[p.net].name,id:p.id,city:p.city,cap:lagCap(PORT[p.tier].g,p.n),used:0,rank:1,ok:n=>n===p.net});} for(const c of S.caches){if(!popUp(c.city))continue;E.push({k:'c',pref:'normal',lab:NET[c.net].cache.name+' cache',id:c.id,city:c.city,cap:CACHE_CAP,used:0,rank:0,ok:n=>n===c.net});} {const rp=ev.rpki&&ev.rpki.until>day?new Set(ev.rpki.nets):null;if(rp)for(const e of E){if(e.k==='c')continue;const o=e.ok;e.ok=n=>!rp.has(n)&&o(n);}} for(const n of NETS){R2.reachable[n.id]=E.some(e=>e.rank>0&&e.ok(n.id));if(R2.reachable[n.id])R2.reach+=NSH[n.id];} @@ -778,9 +782,9 @@ function compute(){ C.optical=S.links.filter(l=>l.kind==='df').reduce((a,l)=>a+(l.ready>S.day?0:ampCount(l.km)*AMP_MO)+(l.spares?Math.round(150+(l.ch||[]).length*80):0),0); C.links=S.links.reduce((a,l)=>a+(l.mo||0),0); C.nni=(S.nni||[]).reduce((a,x)=>a+NNI[x.tier].mo,0); - C.transit=S.transit.reduce((a,t)=>{const q=p95(t,R2.useT[t.id]||0);R2.p95[t.id]=q;return a+Math.max(q,PORT[t.tier].g*0.2)*NET[t.net].price*(t.premium&&t.city==='hkg'?NET[t.net].premium:1)*pm*regionMult(t.city)+PORT[t.tier].tmo;},0); - C.ix=Object.keys(S.ixp).reduce((a,c)=>a+(S.myIx[c]?MYIX_MO:PORT[S.ixp[c]].ix),0); - C.pni=S.pni.reduce((a,p)=>a+PORT[p.tier].pni+(NET[p.net].pol==='paid'?NET[p.net].paidFee:0),0); + C.transit=S.transit.reduce((a,t)=>{const q=p95(t,R2.useT[t.id]||0);R2.p95[t.id]=q;const n=t.n||1;return a+Math.max(q,PORT[t.tier].g*n*0.2)*NET[t.net].price*(t.premium&&t.city==='hkg'?NET[t.net].premium:1)*pm*regionMult(t.city)+PORT[t.tier].tmo*n;},0); + C.ix=Object.keys(S.ixp).reduce((a,c)=>a+(S.myIx[c]?MYIX_MO:PORT[S.ixp[c]].ix*((S.ixn||{})[c]||1)),0); + C.pni=S.pni.reduce((a,p)=>a+PORT[p.tier].pni*(p.n||1)+(NET[p.net].pol==='paid'?NET[p.net].paidFee:0),0); C.caches=S.caches.length*CACHE_MO; C.extras=(S.cnLic&&S.cnLic.state==='ok'?CN_JV_MO:0)+(S.scrubAt?SCRUB_MO:0)+Object.keys(S.pops).filter(ruCity).length*RU_BOX_MO; V.eyeballs=0;V.business=0;V.ix=0; @@ -1081,7 +1085,7 @@ function spawnOffer(){ S.offers.push({id:uid(),city,city2,name,type:t,bw,rate:r2,reqs,latMax:T.lat?+(kmBetween(city,city2)/200*1.35).toFixed(1):null,exp:S.day+40}); } function checkGoals(){ - for(const g of GOALS){if(S.done[g.id])continue;let ok=false;try{ok=g.ok();}catch(e){} + for(const g of GOALS){if(S.done[g.id]!==undefined)continue;let ok=false;try{ok=g.ok();}catch(e){} if(ok){S.done[g.id]=S.day;if(g.r){S.cash+=g.r;} toast(`Goal complete: ${esc(g.t)}${g.r?`
Reward: +${fmt$(g.r)}`:''}`,'goal');sfx('coin'); track('goal_'+g.id);if(g.win&&!S.won){S.won=true;track('win_tier1');showWin();}}} @@ -1106,16 +1110,19 @@ const ACT={ buildPop:({city})=>{if(S.pops[city])return;if(cnCity(city)&&!cnOk()){toast('You need a license first.
Foreign networks need a joint venture to build in mainland China.','bad');sfx('err');return;}if(!spend(popCost(city)))return;S.pops[city]={day:S.day,bb:null,boost:0,down:0,routers:1,gen:false};floater(CITY[city].x,CITY[city].y-30,'New POP!','#FF4F9A');UI.tab='cust';after();}, launchBB:({city})=>{const p=S.pops[city];if(!p||p.bb)return;const C=CITY[city];if(!spend(bbCost(city)))return;p.bb={d:Math.max(8,C.P*0.03)};floater(C.x,C.y-30,'Eyeballs online!','#16A866');after();}, ad:({city})=>{const p=S.pops[city];if(!p||!p.bb)return;if(!spend(8000))return;p.boost=S.day+30;floater(CITY[city].x,CITY[city].y-30,'Ad campaign!','#FF8A3D');after();}, - buyTransit:({city,net,tier})=>{tier=+tier;if(!S.pops[city]||!NET[net]||!NET[net].price||!NET[net].pops.includes(city)||!PORT[tier])return;if(!portOk(city,tier)){toast(`Your router can't take a ${PORT[tier].n} port.
Upgrade it in the Infra tab.`,'bad');sfx('err');return;}const ex=S.transit.find(t=>t.city===city&&t.net===net);if(!spend(PORT[tier].setup))return;if(ex)ex.tier=tier;else S.transit.push({id:uid(),city,net,tier,down:0});toast(`${esc(NET[net].name)} transit is live in ${CITY[city].name}.
Full table received: ~1,000,000 routes.`,'good');after();}, + buyTransit:({city,net,tier})=>{tier=+tier;if(!S.pops[city]||!NET[net]||!NET[net].price||!NET[net].pops.includes(city)||!PORT[tier])return;if(!portOk(city,tier)){toast(`Your router can't take a ${PORT[tier].n} port.
Upgrade it in the Infra tab.`,'bad');sfx('err');return;}const ex=S.transit.find(t=>t.city===city&&t.net===net);if(ex&&tier<=ex.tier)return;if(!spend(PORT[tier].setup*(ex&&ex.n||1)))return;if(ex)ex.tier=tier;else S.transit.push({id:uid(),city,net,tier,down:0});toast(`${esc(NET[net].name)} transit is live in ${CITY[city].name}.
Full table received: ~1,000,000 routes.`,'good');after();}, + lagT:({id,d})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;const n=(t.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0){if(!portOk(t.city,t.tier))return;if(!spend(PORT[t.tier].setup))return;}t.n=n;toast(+d>0?`LAG member added.
${esc(NET[t.net].name)} in ${CITY[t.city].name} is now ${lagName(t.tier,n)}.`:`LAG member removed.`,'good');after();}, + lagP:({id,d})=>{const p=S.pni.find(x=>x.id===id);if(!p)return;const n=(p.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0&&!spend(1500+PORT[p.tier].setup/2))return;p.n=n;sfx('build');after();}, + lagIx:({city,d})=>{if(S.ixp[city]===undefined||S.myIx[city]||!S.pops[city])return;S.ixn=S.ixn||{};const n=(S.ixn[city]||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0&&!spend(PORT[S.ixp[city]].ix))return;S.ixn[city]=n;sfx('build');after();}, cancelTransit:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.transit=S.transit.filter(t=>t.id!==id);UI.confirm=null;after();}, - buyIx:({city,tier})=>{tier=+tier;if(!PORT[tier]||!ixName(city)||(!S.pops[city]&&(!remoteCities().includes(city)||tier>1))||(S.ixp[city]!==undefined&&tier<=S.ixp[city]))return;if(S.pops[city]&&!portOk(city,tier)){toast(`Your router can't take a ${PORT[tier].n} port.
Upgrade it in the Infra tab.`,'bad');sfx('err');return;}if(!spend(PORT[tier].ix))return;const had=S.ixp[city]!==undefined;S.ixp[city]=tier;if(!had)toast(`Port up at ${esc(ixName(city))}!
Now request peering, or join the route server.`,'good');after();}, - cancelIx:({city})=>{if(UI.confirm!=='ix'+city){UI.confirm='ix'+city;renderPanel();return;}delete S.ixp[city];delete S.rs[city];for(const k in S.peers)if(k.endsWith('@'+city))delete S.peers[k];UI.confirm=null;after();}, + buyIx:({city,tier})=>{tier=+tier;if(!PORT[tier]||!ixName(city)||(!S.pops[city]&&(!remoteCities().includes(city)||tier>1))||(S.ixp[city]!==undefined&&tier<=S.ixp[city]))return;if(S.pops[city]&&!portOk(city,tier)){toast(`Your router can't take a ${PORT[tier].n} port.
Upgrade it in the Infra tab.`,'bad');sfx('err');return;}const had=S.ixp[city]!==undefined;if(!spend(PORT[tier].ix*(had?((S.ixn||{})[city]||1):1)))return;S.ixp[city]=tier;if(!had)toast(`Port up at ${esc(ixName(city))}!
Now request peering, or join the route server.`,'good');after();}, + cancelIx:({city})=>{if(UI.confirm!=='ix'+city){UI.confirm='ix'+city;renderPanel();return;}delete S.ixp[city];delete S.rs[city];if(S.ixn)delete S.ixn[city];for(const k in S.peers)if(k.endsWith('@'+city))delete S.peers[k];UI.confirm=null;after();}, rs:({city})=>{S.rs[city]=!S.rs[city];if(S.rs[city])toast('Route server session up.
You now peer with every open network on this IX, in one go.','good');sfx('build');after();}, peer:({city,net})=>{const r=peerOk(net,'ix');if(!r.ok){toast(`${esc(NET[net].name)} declined.
${esc(r.why)}`,'bad');sfx('err');return;}S.peers[net+'@'+city]=true; toast(`${esc(NET[net].name)} accepted!
${NET[net].pol==='selective'?'They checked your PearingDB page and liked the traffic numbers.':'BGP session established.'}`,'good');sfx('build');after();}, unpeer:({city,net})=>{delete S.peers[net+'@'+city];after();}, pni:({city,net,tier})=>{tier=+tier;if(!S.pops[city]||!NET[net]||!NET[net].pops.includes(city)||!PORT[tier])return;if(!portOk(city,tier)){toast(`Your router can't take a ${PORT[tier].n} port.
Upgrade it in the Infra tab.`,'bad');sfx('err');return;}const r=peerOk(net,'pni');if(!r.ok){toast(`${esc(NET[net].name)} declined the PNI.
${esc(r.why)}`,'bad');sfx('err');return;} - const ex=S.pni.find(p=>p.city===city&&p.net===net);if(!spend(1500+PORT[tier].setup/2))return;if(ex)ex.tier=tier;else S.pni.push({id:uid(),city,net,tier}); + const ex=S.pni.find(p=>p.city===city&&p.net===net);if(ex&&tier<=ex.tier)return;if(!spend((1500+PORT[tier].setup/2)*(ex&&ex.n||1)))return;if(ex)ex.tier=tier;else S.pni.push({id:uid(),city,net,tier}); toast(`PNI with ${esc(NET[net].name)} is up.
A cross-connect in ${esc(CITY[city].dc)}. Private and fast.`,'good');after();}, cancelPni:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}S.pni=S.pni.filter(p=>p.id!==id);UI.confirm=null;after();}, cache:({city,net})=>{const n=NET[net];if(!n||!n.cache||!S.pops[city]||S.caches.filter(x=>x.city===city&&x.net===net).length>=4)return;if((R.demTo[net]||0)${esc(n.name)} says not yet.
Send them ${n.cache.min}+ Gbps first.`,'bad');sfx('err');return;} @@ -1241,12 +1248,12 @@ function renderHUD(){ function renderLeft(){ const L=$('left');L.classList.toggle('closed',!UI.leftOpen); if(!S){L.hidden=true;return;}L.hidden=false; - const ndone=GOALS.filter(g=>S.done[g.id]).length; + const ndone=GOALS.filter(g=>S.done[g.id]!==undefined).length; const tabs=[['goals',`Goals${ndone}/${GOALS.length}`],['deals',`Deals${S.offers.length?`${S.offers.length}`:''}`],['noc',`NOC${S.inc.length?`${S.inc.length}`:''}`],['nets','Networks']]; $('leftTabs').innerHTML=tabs.map(([k,l])=>``).join('')+(innerWidth<760?``:''); let h=''; if(UI.left==='goals'){ - const cur=GOALS.find(g=>!S.done[g.id]); + const cur=GOALS.find(g=>S.done[g.id]===undefined); h+=GOALS.map(g=>{const d=S.done[g.id]!==undefined,c=g===cur;return `
${d?'✓':''}
${esc(g.t)}
${c||!d?`
${esc(g.d)}
`:''}${!d&&g.r?`
Reward ${fmt$(g.r)}
`:''}
`;}).join(''); }else if(UI.left==='deals'){ {const lv=S.lvl||1,nx=LEVELS[lv];h+=`
Customer level ${lv}: ${LEVELS[lv-1].n}
${nx?`Next: ${nx.req} unlocks ${nx.unlock.toLowerCase()}`:'Every customer type is unlocked. Go get those terabits.'}
`;} @@ -1327,9 +1334,9 @@ function cityPanel(c){ if(!prov.length)h+=`

Nobody sells transit here. Haul your traffic over fiber to a city that has it.

`; for(const n of prov){const t=S.transit.find(x=>x.city===c&&x.net===n.id);const pr=n.price*S.priceMul*(t&&t.premium&&c==='hkg'?n.premium:1)*regionMult(c); h+=`
${logo(n)}
${esc(n.name)} ${TYPE_L[n.type]}
$${pr.toFixed(2)} per Gbps / month · billed on 95th percentile
`; - if(t){const u=R.useT[t.id]||0,cap=PORT[t.tier].g,tdown=t.down>S.day; - h+=`
${PORT[t.tier].n} port${tdown?' · OUTAGE':''}${fmtG(u)}
${prefCtl('t',t.id,t.pref)}${n.premium&&c==='hkg'?`
${btn(t.premium?'CN-Too premium on ✓':`Switch to CN-Too premium ${n.premium}× price · ~3% loss into China`,'togglePrem',{id:t.id},t.premium?'green sm':'sm')}
`:''}
95th pct ${fmtG(R.p95[t.id]||0)} · commit ${fmtG(cap*.2)} · bill ${fmt$(Math.max(R.p95[t.id]||0,cap*.2)*pr+PORT[t.tier].tmo)}/mo
-
${PORT.map((P2,i)=>i>t.tier?btn(`Upgrade ${P2.n} ${fmt$(P2.setup)} + ${fmt$(P2.tmo)}/mo port`,'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash`;} + if(t){const u=R.useT[t.id]||0,cap=lagCap(PORT[t.tier].g,t.n),tdown=t.down>S.day; + h+=`
${lagName(t.tier,t.n)}${tdown?' · OUTAGE':''}${fmtG(u)}
${prefCtl('t',t.id,t.pref)}${n.premium&&c==='hkg'?`
${btn(t.premium?'CN-Too premium on ✓':`Switch to CN-Too premium ${n.premium}× price · ~3% loss into China`,'togglePrem',{id:t.id},t.premium?'green sm':'sm')}
`:''}
95th pct ${fmtG(R.p95[t.id]||0)} · commit ${fmtG(cap*.2)} · bill ${fmt$(Math.max(R.p95[t.id]||0,PORT[t.tier].g*(t.n||1)*.2)*pr+PORT[t.tier].tmo*(t.n||1))}/mo
+
${PORT.map((P2,i)=>i>t.tier?btn(`Upgrade ${(t.n||1)>1?'all to ':''}${P2.n} ${fmt$(P2.setup*(t.n||1))} + ${fmt$(P2.tmo*(t.n||1))}/mo`,'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash${fmt$(PORT[t.tier].setup)} + ${fmt$(PORT[t.tier].tmo)}/mo`,'lagT',{id:t.id,d:1},'sm',S.cash1?btn('− member','lagT',{id:t.id,d:-1},'ghost sm'):''}${btn(UI.confirm===t.id?'Really cancel?':'Cancel','cancelTransit',{id:t.id},'ghost sm')}
`;} else h+=`
${PORT.map((P2,i)=>btn(`${P2.n} ${fmt$(P2.setup)} + ${fmt$(P2.tmo)}/mo`,'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash`; h+=`
`;} h+=``; @@ -1340,7 +1347,7 @@ function cityPanel(c){ const here=NETS.filter(n=>n.pops.includes(c)); for(const n of here){const pn=S.pni.find(x=>x.city===c&&x.net===n.id),chk=peerOk(n.id,'pni'); h+=`
${logo(n)}
${esc(n.name)} ${n.pol}
`; - if(pn){const u=R.usePni[pn.id]||0,cap=PORT[pn.tier].g;h+=`
${PORT[pn.tier].n} PNI${fmtG(u)}
${prefCtl('p',pn.id,pn.pref)}
${PORT.map((P2,i)=>i>pn.tier?btn(`Upgrade ${P2.n}`,'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)):'').join('')}${btn(UI.confirm===pn.id?'Really remove?':'Remove','cancelPni',{id:pn.id},'ghost sm')}
`;} + if(pn){const u=R.usePni[pn.id]||0,cap=lagCap(PORT[pn.tier].g,pn.n);h+=`
${(pn.n||1)>1?`${pn.n}×${PORT[pn.tier].n} LAG`:PORT[pn.tier].n} PNI${fmtG(u)}
${prefCtl('p',pn.id,pn.pref)}
${PORT.map((P2,i)=>i>pn.tier?btn(`Upgrade ${(pn.n||1)>1?'all to ':''}${P2.n}`,'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)):'').join('')}${(pn.n||1)${fmt$(1500+PORT[pn.tier].setup/2)} + ${fmt$(PORT[pn.tier].pni)}/mo`,'lagP',{id:pn.id,d:1},'sm',S.cash<1500+PORT[pn.tier].setup/2):''}${(pn.n||1)>1?btn('− member','lagP',{id:pn.id,d:-1},'ghost sm'):''}${btn(UI.confirm===pn.id?'Really remove?':'Remove','cancelPni',{id:pn.id},'ghost sm')}
`;} else{h+=chk.ok?`
${PORT.map((P2,i)=>btn(`${P2.n} ${fmt$(1500+P2.setup/2)}`,'pni',{city:c,net:n.id,tier:i},'sm',S.cash<1500+P2.setup/2||!portOk(c,i))).join('')}
${chk.fee?`
Paid peering: ${fmt$(chk.fee)}/mo on top
`:''}`:`
${esc(chk.why)}
`;} h+=`
`;} h+=`

Embedded caches

CDNs put free cache servers inside your POP. Most of their traffic is then served right here, with no transit and no IX port.

`; @@ -1382,9 +1389,9 @@ function ixSection(c){const C=CITY[c],ix=ixName(c);let h=''; else if(!ix){h+=`

There's no IX in ${C.name} yet. Found one: networks join over time, pay you for ports, and peer with you for free.

${S.pops[c]?btn(`Found your own IX ${fmt$(MYIX_COST)} + ${fmt$(MYIX_MO)}/mo`,'foundIx',{city:c},'pink',S.cashBuild a POP here first.

'}`;} else if(S.ixp[c]===undefined){h+=`

${esc(ix)} is a shared switch. One port lets you peer with every member for free. Members: ${ixMembers(c).map(id=>esc(NET[id].name)).join(', ')||'nobody yet'}.

${PORT.map((P2,i)=>btn(`${P2.n} port ${fmt$(P2.ix)}/mo`,'buyIx',{city:c,tier:i},'',S.cash1))).join('')}
`;} else{const mine=!!S.myIx[c],u=R.useIx[c]||0,cap=ixCap(c),set=ixSessions(c),xdown=S.ev.ixdown&&S.ev.ixdown[c]>S.day; - h+=`
${mine?'Your own fabric · 400G':PORT[S.ixp[c]].n+' port'}${xdown?' · FABRIC DOWN':''}${fmtG(u)}
${prefCtl('ix',c,S.ixPref&&S.ixPref[c])}`; + h+=`
${mine?'Your own fabric · 400G':lagName(S.ixp[c],(S.ixn||{})[c])}${xdown?' · FABRIC DOWN':''}${fmtG(u)}
${prefCtl('ix',c,S.ixPref&&S.ixPref[c])}`; if(mine)h+=`
Members paying you${S.myIx[c].members.length} · ${fmt$(S.myIx[c].members.length*MYIX_FEE)}/mo
`; - else h+=`
${PORT.map((P2,i)=>i>S.ixp[c]?btn(`Upgrade ${P2.n} ${fmt$(P2.ix)}/mo`,'buyIx',{city:c,tier:i},'sm',(!!S.pops[c]&&!portOk(c,i))||(!S.pops[c]&&i>1)):'').join('')}${btn(S.rs[c]?'Leave route server':'Join route server','rs',{city:c},S.rs[c]?'ghost sm':'pink sm')}${btn(UI.confirm==='ix'+c?'Really leave?':'Leave IX','cancelIx',{city:c},'ghost sm')}
`; + else h+=`
${PORT.map((P2,i)=>i>S.ixp[c]?btn(`Upgrade ${P2.n} ${fmt$(P2.ix*((S.ixn||{})[c]||1))}/mo`,'buyIx',{city:c,tier:i},'sm',(!!S.pops[c]&&!portOk(c,i))||(!S.pops[c]&&i>1)):'').join('')}${S.pops[c]&&((S.ixn||{})[c]||1)${fmt$(PORT[S.ixp[c]].ix)}/mo`,'lagIx',{city:c,d:1},'sm',S.cash1?btn('− member','lagIx',{city:c,d:-1},'ghost sm'):''}${btn(S.rs[c]?'Leave route server':'Join route server','rs',{city:c},S.rs[c]?'ghost sm':'pink sm')}${btn(UI.confirm==='ix'+c?'Really leave?':'Leave IX','cancelIx',{city:c},'ghost sm')}
`; h+=`
`; for(const id of ixMembers(c)){const n=NET[id],on=set.has(id),viaRs=on&&!S.peers[id+'@'+c]&&!mine,chk=peerOk(id,'ix'); h+=`
${logo(n)}
${esc(n.name)}
${TYPE_L[n.type]} ${n.pol} · ${(NSH[id]*100).toFixed(0)}%
${!on&&!chk.ok?`
${esc(chk.why)}
`:''}
@@ -1543,7 +1550,7 @@ function showHelp(){
PNI
Private network interconnect: a cable straight to one network in the same building. For big traffic.
Embedded cache
A CDN's server in your rack. Serves most of that CDN's traffic locally, for the price of power.
Peering policy
Open peers with anyone. Selective wants to see traffic first. Restrictive (Tier 1s) only peers with giants, over PNIs. Paid means exactly that.
-
Waves
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.
95th percentile
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.
Routers
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.
Dark fiber
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.
Subsea cables
Subsea waves can only follow real-ish cable systems, 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.
Latency
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.
NOC dashboard
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.
Asia
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.
Russia
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.
Traffic engineering
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.
China
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.
Weird requirements
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.
Customer levels
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.
L2VPN & DDoS protection
Businesses may want a private circuit between two of your POPs (it rides your backbone), or DDoS protection (needs your own scrubbing center).
NNI fabrics
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.
+
Waves
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.
95th percentile
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.
Routers
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.
Dark fiber
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.
Subsea cables
Subsea waves can only follow real-ish cable systems, 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.
Latency
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.
NOC dashboard
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.
Asia
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.
Russia
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.
LAGs
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.
Traffic engineering
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.
China
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.
Weird requirements
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.
Customer levels
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.
L2VPN & DDoS protection
Businesses may want a private circuit between two of your POPs (it rides your backbone), or DDoS protection (needs your own scrubbing center).
NNI fabrics
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.
Failures
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.
${btn(UI.started?'Back to the map':'Got it','helpClose',{},'big')}
`); } diff --git a/tests/game.test.js b/tests/game.test.js index d31ff99..5dc63b2 100644 --- a/tests/game.test.js +++ b/tests/game.test.js @@ -93,3 +93,35 @@ test('saves never resurrect a bankrupt game', () => { assert.equal(ev('S.lost'), true); assert.equal(ev('loadSave()'), null); }); + +test('LAGs add members, capacity and cost to transit, IX ports and PNIs', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e7;S.lvl=4;S.pops.fra.rgen=2;for(const g of GOALS)S.done[g.id]=0"); + ev("ACT.buyTransit({city:'fra',net:'cog',tier:1});ACT.buyIx({city:'fra',tier:1})"); + ev("const t=S.transit[0];window.__c0=S.cash;ACT.lagT({id:t.id,d:1});ACT.lagT({id:t.id,d:1});ACT.lagIx({city:'fra',d:1});compute()"); + assert.equal(ev('S.transit[0].n'), 3); + assert.equal(ev("S.ixn.fra"), 2); + assert.equal(ev("__c0-S.cash"), 1500 * 2 + 1500, 'two transit members and one IX member were charged'); + assert.equal(ev("ixCap('fra')"), 190); + assert.equal(ev("R.cost.transit>0"), true); + ev("ACT.buyTransit({city:'fra',net:'cog',tier:2})"); + assert.equal(ev('S.transit[0].tier'), 2, 'upgrading a LAG upgrades every member'); + ev("ACT.lagT({id:S.transit[0].id,d:-1})"); + assert.equal(ev('S.transit[0].n'), 2); + ev("for(let i=0;i<10;i++)ACT.lagT({id:S.transit[0].id,d:1})"); + assert.equal(ev('S.transit[0].n'), 8, 'capped at 8 members'); + ev("selectCity('fra');ACT.tab({t:'up'})"); + assert.match(ev("document.getElementById('panelBody').textContent"), /8×400G LAG/); + assert.deepEqual(errors, []); +}); + +test('goal rewards are paid once, even for goals finished on day 0', () => { + const { ev } = load(); + ev("ACT.start({})"); + const c0 = ev('S.cash'); + ev("ACT.launchBB({city:'fra'})"); + const c1 = ev('S.cash'); + for (let i = 0; i < 5; i++) ev('after()'); + assert.equal(ev('S.cash'), c1, 'no repeated reward'); + assert.equal(c1 - c0, ev("GOALS.find(g=>g.id==='bb').r") - ev("bbCost('fra')")); +});