A 1.6T transponder takes two ports on 800G routers, one per 800G client (#256)

This commit is contained in:
Frederic Jung 2026-11-01 19:02:06 +01:00
parent 935c08839f
commit 25a43e22df
No known key found for this signature in database
11 changed files with 52 additions and 4 deletions

View file

@ -2535,6 +2535,7 @@
"link_panels.stock_a_spare_optic_price":"Eine Reserve-{optic} einlagern <small>{price}</small>",
"link_panels.sys_level_n":"{sys} <small>Level {n}</small>",
"link_panels.take_it_off_standby":"Aus dem Standby holen",
"link_panels.takes_n_router_ports_per_end":{"one":"belegt {n} Router-Port an jedem Ende","other":"belegt {n} Router-Ports an jedem Ende"},
"link_panels.there_s_no_ix_in_city":"In {city} gibt es noch keinen IX. Gründe einen: Netze treten mit der Zeit bei, zahlen dir Ports und peeren kostenlos mit dir.",
"link_panels.they_need_the_full_internet_your":"Sie brauchen das volle Internet. Deine Erreichbarkeit ist {pct}.",
"link_panels.this_backhoe_wins":"Dieser Bagger gewinnt.",

View file

@ -2533,6 +2533,7 @@
"link_panels.stock_a_spare_optic_price":"Tener una {optic} de repuesto <small>{price}</small>",
"link_panels.sys_level_n":"{sys} <small>nivel {n}</small>",
"link_panels.take_it_off_standby":"Sacarlo de la espera",
"link_panels.takes_n_router_ports_per_end":{"one":"ocupa {n} puerto de router en cada extremo","other":"ocupa {n} puertos de router en cada extremo"},
"link_panels.there_s_no_ix_in_city":"Aún no hay IX en {city}. Funda uno: las redes se unen con el tiempo, te pagan por los puertos y hacen peering contigo gratis.",
"link_panels.they_need_the_full_internet_your":"Necesitan todo internet. Tu alcance es del {pct}.",
"link_panels.this_backhoe_wins":"Esta retroexcavadora gana.",

View file

@ -2533,6 +2533,7 @@
"link_panels.stock_a_spare_optic_price":"Stocker un {optic} de rechange <small>{price}</small>",
"link_panels.sys_level_n":"{sys} <small>niveau {n}</small>",
"link_panels.take_it_off_standby":"Le sortir de l’attente",
"link_panels.takes_n_router_ports_per_end":{"one":"occupe {n} port de routeur à chaque bout","other":"occupe {n} ports de routeur à chaque bout"},
"link_panels.there_s_no_ix_in_city":"Pas encore d’IX à {city}. Fondes-en un : les réseaux te rejoignent peu à peu, te paient leurs ports et font du peering gratuit avec toi.",
"link_panels.they_need_the_full_internet_your":"Ils veulent tout Internet. Ta couverture est de {pct}.",
"link_panels.this_backhoe_wins":"Cette pelleteuse gagne.",

View file

@ -2533,6 +2533,7 @@
"link_panels.stock_a_spare_optic_price":"Metti da parte un {optic} di scorta <small>{price}</small>",
"link_panels.sys_level_n":"{sys} <small>livello {n}</small>",
"link_panels.take_it_off_standby":"Toglilo dallo standby",
"link_panels.takes_n_router_ports_per_end":{"one":"occupa {n} porta del router a ogni capo","other":"occupa {n} porte del router a ogni capo"},
"link_panels.there_s_no_ix_in_city":"A {city} non c’è ancora un IX. Fondane uno: le reti si uniscono col tempo, ti pagano le porte e fanno peering con te gratis.",
"link_panels.they_need_the_full_internet_your":"Vogliono internet per intero. La tua copertura è del {pct}.",
"link_panels.this_backhoe_wins":"Questa ruspa vince.",

View file

@ -2533,6 +2533,7 @@
"link_panels.stock_a_spare_optic_price":"Guardar um {optic} sobressalente <small>{price}</small>",
"link_panels.sys_level_n":"{sys} <small>nível {n}</small>",
"link_panels.take_it_off_standby":"Tirar da reserva",
"link_panels.takes_n_router_ports_per_end":{"one":"ocupa {n} porta de roteador em cada ponta","other":"ocupa {n} portas de roteador em cada ponta"},
"link_panels.there_s_no_ix_in_city":"Ainda não há IX em {city}. Funde um: as redes entram com o tempo, pagam pelas portas e fazem peering com você de graça.",
"link_panels.they_need_the_full_internet_your":"Eles querem a internet inteira. Seu alcance é de {pct}.",
"link_panels.this_backhoe_wins":"Esta retroescavadeira vence.",

View file

@ -11,8 +11,11 @@ const cacheBox=c=>{const p=S.pops[c];return p&&portG(p.rgen||0)>=CACHE_BIG?{g:CA
function cachePorts(c,extra=[],g){const n={a:0,b:0};for(const x of S.caches)if(x.city===c)n[x.site==='b'?'b':'a']+=cacheG(x);for(const x of extra)n[x.site==='b'?'b':'a']+=cacheG(x);
const p=S.pops[c],k=p?portG(g===undefined?(p.rgen||0):g):CACHE_CAP;return Math.ceil(n.a/k-1e-9)+Math.ceil(n.b/k-1e-9);}
const cachePortsAdd=(c,adds)=>cachePorts(c,adds)-cachePorts(c);
/* A dark fiber channel takes as many router ports at each end as the optic's speed needs (#256): a pluggable sits
in one port, but a 1.6T transponder shelf hands off to an 800G router as two 800G clients. */
const chPorts=(o,c,g)=>{const p=S.pops[c];return p&&OPT[o]?Math.max(1,Math.ceil(OPT[o].g/portG(g===undefined?(p.rgen||0):g)-1e-9)):1;};
function portsUsed(c,g){let u=0;
for(const l of S.links){if(l.a!==c&&l.b!==c||l.kind==='vxc')continue;u+=l.kind==='df'?(l.ch||[]).length:1;}
for(const l of S.links){if(l.a!==c&&l.b!==c||l.kind==='vxc')continue;if(l.kind!=='df'){u++;continue;}for(const o of l.ch||[])u+=chPorts(o,c,g);}
// A puzzle's content origin (t.pz) hands off on a port of its own: it takes none of yours.
for(const t of S.transit)if(t.city===c&&!t.pz)u+=PORT_SLOT(t.tier)*(t.n||1);
for(const x of S.pni)if(x.city===c)u+=PORT_SLOT(x.tier)*(x.n||1);

View file

@ -25,7 +25,7 @@ Object.assign(ACT,{
regen:({id,d})=>{d=+d;const l=S.links.find(x=>x.id===id);if(!l||l.kind!=='df'||(l.sub&&!l.seat)||(d!==1&&d!==-1))return;const n=(l.regen|0)+d;if(n<0||n>REGEN_MAX)return;
if(d<0&&(l.ch||[]).some(o=>!optMode(o,Object.assign({},l,{regen:n})))){toast(tr('fiber_and_hardware.those_optics_need_the_regen_site'),'bad');sfx('err');return;}
if(d>0&&!spend(REGEN_COST+Math.round((l.ch||[]).reduce((a,c)=>a+optCost(c),0)*REGEN_CH)))return;l.regen=n;toast(d>0?tr('fiber_and_hardware.regen_site_n_is_up_optical',{n,a:CITY[l.a].name,b:CITY[l.b].name,km:spanKm(l).toLocaleString()}):tr('fiber_and_hardware.regen_site_removed'),'good');sfx('build');after();},
addCh:({id,o})=>{const l=S.links.find(x=>x.id===id),O=OPT[o];if(!l||!O||l.kind!=='df')return;const why=chWhy(l,o);if(why){toast(tr('fiber_and_hardware.can_t_add_optic_why',{optic:O.n,why:esc(why)}),'bad');sfx('err');return;}if(!portGate(l.a,1)||!portGate(l.b,1))return;const sp=spareN(o)>0;if(!spend(chCost(l,o)))return;if(sp)S.spares[o]--;(l.ch=l.ch||[]).push(o);floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,`+${O.n}`,'#FF4F9A');after();},
addCh:({id,o})=>{const l=S.links.find(x=>x.id===id),O=OPT[o];if(!l||!O||l.kind!=='df')return;const why=chWhy(l,o);if(why){toast(tr('fiber_and_hardware.can_t_add_optic_why',{optic:O.n,why:esc(why)}),'bad');sfx('err');return;}if(!portGate(l.a,chPorts(o,l.a))||!portGate(l.b,chPorts(o,l.b)))return;const sp=spareN(o)>0;if(!spend(chCost(l,o)))return;if(sp)S.spares[o]--;(l.ch=l.ch||[]).push(o);floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,`+${O.n}`,'#FF4F9A');after();},
rmCh:({id,o})=>{const l=S.links.find(x=>x.id===id);if(!l||!OPT[o])return;const i=(l.ch||[]).lastIndexOf(o);if(i<0)return;l.ch.splice(i,1);S.spares=S.spares||{};S.spares[o]=(S.spares[o]||0)+1;floater((CITY[l.a].x+CITY[l.b].x)/2,(CITY[l.a].y+CITY[l.b].y)/2-20,tr('fiber_and_hardware.optic_to_spares',{optic:OPT[o].n}),'#7B61FF');after();},
hwLock:()=>{if(hwLock())return;const c=hwLockCost();if(!spend(c))return;S.hw=S.hw||{};S.hw.lock={until:S.day+HW_LOCK_DAYS,mul:hwTrend(S.day)};toast(tr('fiber_and_hardware.prices_locked_until_date_your_vendor',{date:dateStr(S.hw.lock.until)}),'good');after();},
buySpare:({o})=>{if(!OPT[o]||!techOk('opt',o,OPT[o].lvl)||spareN(o)>=64)return;if(!spend(optCost(o)))return;S.spares=S.spares||{};S.spares[o]=(S.spares[o]||0)+1;sfx('build');after();},

View file

@ -14,7 +14,7 @@ Object.assign(ACT,{
if(why){toast(tr('fiber_and_hardware.can_t_add_optic_why',{optic:OPT[o].n,why:esc(why)}),'bad');sfx('err');return;}
const free=chMax(l)-(l.ch||[]).length-soldSlots(l);
if(d>free){toast(tr('optic_counts.only_n_channels_free',{n:free}),'bad');sfx('err');return;}
if(!portGate(l.a,d)||!portGate(l.b,d)||!spend(opticCountCost(l,o,n)))return;
if(!portGate(l.a,d*chPorts(o,l.a))||!portGate(l.b,d*chPorts(o,l.b))||!spend(opticCountCost(l,o,n)))return;
const sp=Math.min(d,spareN(o));if(sp)S.spares[o]-=sp;
(l.ch=l.ch||[]).push(...Array(d).fill(o));
}else{

View file

@ -125,7 +125,7 @@ function dfPanel(l){
if(l.own&&l.sub&&!l.seat)h+=subUpgradePanel(l);
for(const k of Object.keys(OPT)){const O=OPT[k],n=(l.ch||[]).filter(x=>x===k).length,why=chWhy(l,k);
const md=optMode(k,l),cc=chCost(l,k),sp=spareN(k);
h+=`<div class="row"><div class="grow"><div class="nm">${O.n} <span class="meta">${optModes(k,l).map(([g,r])=>tr('link_panels.g_to_km_km',{g:fmtG(g),km:r.toLocaleString()})).join(' · ')}</span></div><div class="meta">${esc(O.blurb)}${n?` · <b>${tr('link_panels.n_lit',{n})}</b>`:''}${sp?` · ${trn('link_panels.n_spare_on_the_shelf',sp)}`:''}</div>${md&&!md.full?`<div class="meta">⚠️ ${tr('link_panels.runs_at_g_per_channel_on',{g:fmtG(md.g)})} ${(!l.sub||l.seat)&&regenNeed(k,l)>(l.regen|0)?trn('link_panels.n_regen_site_would_bring_it',regenNeed(k,l),{g:fmtG(O.g)}):''}</div>`:''}${why?`<div class="why">${esc(why)}</div>`:''}${!techOk('opt',k,O.lvl)&&demoCan(O.lvl)?`<div class="btns">${demoBtn('opt',k,O.lvl,'','ghost sm')}</div>`:''}${opticCountControl(l,k,n)}</div>${n?btn('−','rmCh',{id:l.id,o:k},'ghost sm'):''}${btn(sp?`+ <small>${cc?tr('link_panels.spare_price',{price:fmt$(cc)}):tr('common.spare')}</small>`:`+ <small>${fmt$(cc)}</small>`,'addCh',{id:l.id,o:k},'sm',!!why||S.cash<cc)}</div>`;}
h+=`<div class="row"><div class="grow"><div class="nm">${O.n} <span class="meta">${optModes(k,l).map(([g,r])=>tr('link_panels.g_to_km_km',{g:fmtG(g),km:r.toLocaleString()})).join(' · ')}</span></div><div class="meta">${esc(O.blurb)}${n?` · <b>${tr('link_panels.n_lit',{n})}</b>`:''}${sp?` · ${trn('link_panels.n_spare_on_the_shelf',sp)}`:''}${(np=>np>1?` · ${trn('link_panels.takes_n_router_ports_per_end',np)}`:'')(Math.max(chPorts(k,l.a),chPorts(k,l.b)))}</div>${md&&!md.full?`<div class="meta">⚠️ ${tr('link_panels.runs_at_g_per_channel_on',{g:fmtG(md.g)})} ${(!l.sub||l.seat)&&regenNeed(k,l)>(l.regen|0)?trn('link_panels.n_regen_site_would_bring_it',regenNeed(k,l),{g:fmtG(O.g)}):''}</div>`:''}${why?`<div class="why">${esc(why)}</div>`:''}${!techOk('opt',k,O.lvl)&&demoCan(O.lvl)?`<div class="btns">${demoBtn('opt',k,O.lvl,'','ghost sm')}</div>`:''}${opticCountControl(l,k,n)}</div>${n?btn('−','rmCh',{id:l.id,o:k},'ghost sm'):''}${btn(sp?`+ <small>${cc?tr('link_panels.spare_price',{price:fmt$(cc)}):tr('common.spare')}</small>`:`+ <small>${fmt$(cc)}</small>`,'addCh',{id:l.id,o:k},'sm',!!why||S.cash<cc)}</div>`;}
{const st=Object.keys(OPT).filter(k=>spareN(k)>0);h+=`<p class="note">${tr('link_panels.unplugged_optics_go_on_the_spares')}</p>`;
{const used=[...new Set(l.ch||[])].filter(k=>OPT[k]&&OPT[k].lvl<=lvl());if(used.length)h+=`<div class="btns">${used.map(k=>btn(tr('link_panels.stock_a_spare_optic_price',{optic:OPT[k].n,price:fmt$(optCost(k))}),'buySpare',{o:k},'ghost sm',S.cash<optCost(k)||spareN(k)>=64)).join('')}</div><p class="meta">${tr('link_panels.spares_bought_now_are_already_paid')}</p>`;}if(st.length)h+=`<h4 class="sub4">${tr('common.spares_shelf')}</h4>`+st.map(k=>`<div class="row"><div class="grow"><div class="nm">${spareN(k)} × ${OPT[k].n}</div></div>${btn(tr('link_panels.sell_one_price',{price:fmt$(spareValue(k))}),'sellSpare',{o:k},'ghost sm')}</div>`).join('');}
const rg=l.regen|0,rgAdd=REGEN_COST+Math.round((l.ch||[]).reduce((a,c)=>a+optCost(c),0)*REGEN_CH);

View file

@ -2534,6 +2534,7 @@
"link_panels.stock_a_spare_optic_price":"Stock a spare {optic} <small>{price}</small>",
"link_panels.sys_level_n":"{sys} <small>level {n}</small>",
"link_panels.take_it_off_standby":"Take it off standby",
"link_panels.takes_n_router_ports_per_end":{"one":"takes {n} router port at each end","other":"takes {n} router ports at each end"},
"link_panels.there_s_no_ix_in_city":"There's no IX in {city} yet. Found one: networks join over time, pay you for ports, and peer with you for free.",
"link_panels.they_need_the_full_internet_your":"They need the full internet. Your reach is {pct}.",
"link_panels.this_backhoe_wins":"This backhoe wins.",

39
tests/optic-ports.test.js Normal file
View file

@ -0,0 +1,39 @@
const test=require('node:test');
const assert=require('node:assert/strict');
const {load}=require('./harness');
// #256: a 1.6T transponder on 800G routers hands off as two 800G clients, so it takes two ports at each end.
function setup(ev,g){ev(`ACT.start({});S.cash=1e9;S.lvl=13;S.day=100;for(const g of GOALS)S.done[g.id]=0;
S.pops.fra.rgen=${g};S.pops.fra.routers=1;S.pops.ams={...S.pops.fra};
S.links=[{id:'fiber',a:'fra',b:'ams',kind:'df',own:false,sys:'roadm',km:400,ch:[],ready:0,day:0,cut:0,mo:1}];compute();`);}
test('#256 a 1.6T optic takes two 800G router ports at each end, one 1.6T port',()=>{
const {ev,dom,errors}=load();try{
setup(ev,'mainRG(2)');
assert.equal(ev("RG[S.pops.fra.rgen].pn"),'800G');
ev("ACT.addCh({id:'fiber',o:'tp16'})");
assert.equal(ev('portsUsed("fra")'),2,'two 800G clients');assert.equal(ev('portsUsed("ams")'),2);
ev("ACT.addCh({id:'fiber',o:'zr8'})");
assert.equal(ev('portsUsed("fra")'),3,'an 800ZR+ plugs into one port');
ev("ACT.setChCount({id:'fiber',o:'tp16',n:3})");
assert.equal(ev('portsUsed("fra")'),7);
// the panel says so
ev("UI.sel={type:'link',id:'fiber'};renderPanel()");
assert.match(dom.window.document.getElementById('panel').textContent,/takes 2 router ports at each end/);
// a 1.6T router carries the same optic in one port, and the swap is counted at the new speed
assert.equal(ev('portsUsed("fra",mainRG(3))'),4);
ev('S.pops.fra.rgen=S.pops.ams.rgen=mainRG(3)');
assert.equal(ev('portsUsed("fra")'),4);
assert.deepEqual(errors,[]);
}finally{dom.window.close();}
});
test('#256 a full 800G router has no room for a 1.6T optic that needs two ports',()=>{
const {ev,dom}=load();try{
setup(ev,'mainRG(2)');
const free=ev('portsMax("fra")')-1;
ev(`S.links[0].ch=Array(${free}).fill('zr8');compute()`);
assert.equal(ev('portsMax("fra")-portsUsed("fra")'),1);
ev("ACT.addCh({id:'fiber',o:'tp16'})");
assert.equal(ev("S.links[0].ch.filter(o=>o==='tp16').length"),0,'one free port is not enough');
ev("ACT.addCh({id:'fiber',o:'zr8'})");
assert.equal(ev('portsMax("fra")-portsUsed("fra")'),0,'but an 800ZR+ still fits');
}finally{dom.window.close();}
});