China Telecomet's premium crossing in Moscow, at the Hong Kong price (#195)
This commit is contained in:
parent
7cfadaa6ae
commit
f5e15e427f
16 changed files with 103 additions and 11 deletions
|
|
@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- China Telecomet now sells its CN-Too premium crossing in Moscow too, at the same price as in Hong Kong (#195). Haul your European traffic to Moscow and it reaches China with about 3% loss; nothing else of theirs is on offer there.
|
||||
- Glowball Sakura Lager joins the map: a Tier 2 carrier in the big hubs of the US, Europe and Asia-Pacific that sells transit, takes PNIs and peers openly wherever it is. It is not a Tier 1, so it buys its own transit from three of them, while 13 smaller networks in its regions buy theirs from it, and one PNI with it reaches about 3% of all traffic. Far from home, in Asia and New Zealand, it charges more than the locals, and it sells no transit in Australia.
|
||||
|
||||
## [1.36.0] — 2026-10-28
|
||||
|
|
|
|||
|
|
@ -723,6 +723,7 @@
|
|||
"city_panel.nothing_plugged_in_here_yet":"Aún no hay nada conectado aquí",
|
||||
"city_panel.on_demand_engages_in_n_d":"Bajo demanda (se activa en {n} d)",
|
||||
"city_panel.one_router_is_a_single_point":"Un solo router es un punto único de fallo.",
|
||||
"city_panel.only_the_cn_too_premium_crossing":"Aquí solo venden su cruce premium CN-Too, por tierra hasta China: precios de Hong Kong, alrededor de un 3 % de pérdida hacia China, y nada más.",
|
||||
"city_panel.open_a_pop_here":"Abrir un POP aquí",
|
||||
"city_panel.or_drag_from_one_of_your":"O arrastra desde uno de tus routers hasta esta ciudad para tender la fibra y construir el POP de una vez.",
|
||||
"city_panel.order_circuit_anyway":"Pedir el circuito de todos modos",
|
||||
|
|
|
|||
|
|
@ -723,6 +723,7 @@
|
|||
"city_panel.nothing_plugged_in_here_yet":"Rien n’est encore branché ici",
|
||||
"city_panel.on_demand_engages_in_n_d":"À la demande (s’active en {n} j)",
|
||||
"city_panel.one_router_is_a_single_point":"Un seul routeur, c’est un point de défaillance unique.",
|
||||
"city_panel.only_the_cn_too_premium_crossing":"Ici, ils ne vendent que leur traversée premium CN-Too, par voie terrestre jusqu’en Chine : prix de Hong Kong, environ 3 % de perte vers la Chine, et rien d’autre.",
|
||||
"city_panel.open_a_pop_here":"Ouvrir un POP ici",
|
||||
"city_panel.or_drag_from_one_of_your":"Ou glisse depuis un de tes routeurs jusqu’à cette ville pour tirer la fibre et construire le POP d’un coup.",
|
||||
"city_panel.order_circuit_anyway":"Commander le circuit quand même",
|
||||
|
|
|
|||
|
|
@ -723,6 +723,7 @@
|
|||
"city_panel.nothing_plugged_in_here_yet":"Qui non è ancora collegato niente",
|
||||
"city_panel.on_demand_engages_in_n_d":"On-demand (si attiva tra {n}g)",
|
||||
"city_panel.one_router_is_a_single_point":"Un solo router è un single point of failure.",
|
||||
"city_panel.only_the_cn_too_premium_crossing":"Qui vendono solo il loro attraversamento premium CN-Too, via terra fino in Cina: prezzi di Hong Kong, circa il 3% di perdita verso la Cina, e nient'altro.",
|
||||
"city_panel.open_a_pop_here":"Apri un POP qui",
|
||||
"city_panel.or_drag_from_one_of_your":"Oppure trascina da uno dei tuoi router a questa città per posare la fibra e costruire il POP in un colpo solo.",
|
||||
"city_panel.order_circuit_anyway":"Ordina comunque il circuito",
|
||||
|
|
|
|||
|
|
@ -723,6 +723,7 @@
|
|||
"city_panel.nothing_plugged_in_here_yet":"Nada plugado aqui ainda",
|
||||
"city_panel.on_demand_engages_in_n_d":"On-demand (ativa em {n}d)",
|
||||
"city_panel.one_router_is_a_single_point":"Um router só é um single point of failure.",
|
||||
"city_panel.only_the_cn_too_premium_crossing":"Aqui eles vendem só a travessia premium CN-Too, por terra até a China: preços de Hong Kong, cerca de 3% de perda para a China, e nada mais.",
|
||||
"city_panel.open_a_pop_here":"Abrir um POP aqui",
|
||||
"city_panel.or_drag_from_one_of_your":"Ou arraste de um dos seus routers até esta cidade para lançar fibra e construir o POP de uma vez.",
|
||||
"city_panel.order_circuit_anyway":"Pedir o circuito mesmo assim",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const NETS=[
|
|||
{id:'tng',name:'Tangerine Telecom',asn:5115,type:'t2',pol:'selective',minIx:15,minPni:40,share:.03,price:6,col:'#FF8C42',pops:['tci','bcn','cai','nbo','dxb','par','mrs','mad','lon','ams','lag','jnb','waw','buh','dkr','abj','cas','tun','dla','fih','fdf','run','tnr'],ix:['bcn','par','mrs','mad','lon','ams','lag','jnb','waw','dkr','abj','cas','tun','dla','fih'],blurb:tr('networks.juicy_reach_into_europe_and_africa')},
|
||||
{id:'sgt',name:'SingTell',asn:7474,type:'t2',pol:'selective',minIx:15,minPni:40,share:.03,price:7,col:'#00A6A6',pops:['jkt','mnl','per','akl','icn','sin','hkg','tok','syd','bom','tpe','maa','kul','bkk','sgn','mel','bne'],ix:['sin','hkg','tok','bom','tpe','maa','kul','bkk'],blurb:tr('networks.sings_your_packets_across_asia')},
|
||||
{id:'vdp',name:'Voda-Phony',asn:1373,type:'t2',pol:'paid',freeLv:7,paidFee:8000,share:.03,price:6,col:'#E63946',pops:['man','edi','mil','rom','lis','ath','nbo','cai','ber','dub','dxb','lon','fra','ams','mad','mrs','jnb','bom','lag','cpt','del','maa','ist','prg','bud','buh','doh','acc','dar','fih','mpm','dus'],ix:[],blurb:tr('networks.ended_free_peering_across_europe_and')},
|
||||
{id:'ctc',name:'China Telecomet',asn:4314,type:'t2',pol:'restrictive',share:.02,price:22,premium:2.5,cn:true,col:'#0B5CAD',pops:['pek','sha','hkg','sin','tok','lon','fra','nyc','sjc'],ix:[],blurb:tr('networks.the_biggest_network_in_china_its')},
|
||||
{id:'ctc',name:'China Telecomet',asn:4314,type:'t2',pol:'restrictive',share:.02,price:22,premium:2.5,premAt:['hkg','mos'],premOnly:['mos'],cn:true,col:'#0B5CAD',pops:['pek','sha','hkg','sin','tok','lon','fra','nyc','sjc'],ix:[],blurb:tr('networks.the_biggest_network_in_china_its')},
|
||||
{id:'cun',name:'China Unicorn',asn:4837,type:'t2',pol:'restrictive',share:.015,price:16,cn:true,col:'#D7000F',pops:['pek','sha','hkg','fra','sjc','lon'],ix:[],blurb:tr('networks.number_two_in_china_with_a')},
|
||||
{id:'cmb',name:'China Moble',asn:9880,type:'eye',pol:'paid',freeLv:10,paidFee:12000,share:.01,cn:true,col:'#0085CA',pops:['pek','sha','hkg'],ix:[],blurb:tr('networks.the_largest_mobile_network_on_earth')},
|
||||
{id:'cmc',name:'Comecast',asn:7227,type:'eye',pol:'selective',minIx:10,minPni:30,share:.03,col:'#2C7A7B',pops:['atn','den','bos','hou','phx','slc','ash','nyc','chi','sjc','sea','mia'],ix:['atn','den','bos','ash','nyc','chi','sjc','sea'],blurb:tr('networks.huge_eyeball_network_come_for_the')},
|
||||
|
|
|
|||
|
|
@ -5,7 +5,14 @@
|
|||
Not That Telecom and Level Tree (whose real-world network lists no sites in PeeringDB at all, but sells in Sydney). Others can sit in
|
||||
an Australian city, like the Pacific carriers backhauling to Sydney (or Glowball Sakura Lager), but reach Australian
|
||||
customers only from overseas. */
|
||||
const AU_SELLERS=['tsy','voc','spl','sgt','drz','cog','ntt','lvl'],sellsAt=(n,c)=>!!n.price&&n.pops.includes(c)&&(!CITY[c].au||AU_SELLERS.includes(n.id));
|
||||
const AU_SELLERS=['tsy','voc','spl','sgt','drz','cog','ntt','lvl'],sellsAt=(n,c)=>!!n.price&&(n.pops.includes(c)||!!n.premOnly&&n.premOnly.includes(c))&&(!CITY[c].au||AU_SELLERS.includes(n.id));
|
||||
/* China Telecomet's premium crossing into China (CN-Too) is sold where its border routes start: Hong Kong, and Moscow
|
||||
(#195), where it rides the land route east and nothing else of theirs is on offer (premOnly). It costs the same
|
||||
wherever you buy it: the Hong Kong price. */
|
||||
const premCity=(n,c)=>!!n.premium&&!!n.premAt&&n.premAt.includes(c),premOnlyAt=(n,c)=>!!n.premOnly&&n.premOnly.includes(c);
|
||||
const premOn=t=>!!t.premium&&!!NET[t.net]&&premCity(NET[t.net],t.city);
|
||||
// What a port costs per Gbps and month before the commit: the premium crossing at Hong Kong prices, anything else at the city's.
|
||||
const transitPerG=(n,c,prem)=>prem&&premCity(n,c)?n.price*n.premium*netMult(n,'hkg'):n.price*netMult(n,c);
|
||||
const onIx=(n,c)=>CITY[c].au&&n.auIx?n.auIx.includes(c):n.ix==='ALL'||Array.isArray(n.ix)&&n.ix.includes(c);
|
||||
function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])return S.myIx[c].members.slice();if(!CITY[c].ix)return [];return NETS.filter(n=>onIx(n,c)).map(n=>n.id);}
|
||||
// LAG: several identical ports bundled into one logical link. Flow hashing is never perfectly even, so a bundle carries ~95% of the sum.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function compute(){
|
|||
for(const t of S.transit){if(!popUp(t.city)||t.down>day||!liveN(t.city,t.site,t.n))continue;
|
||||
// AS-path prepending (#96) moves part of the port to a last-resort exit of its own.
|
||||
const cap=Math.min(liveCap(PORT[t.tier].g,t.city,t.site,t.n)*lagF(t),TRX&&TRX.cap[t.net]!==undefined?TRX.cap[t.net]:Infinity),pf=TRX&&TRX.prep[t.net]?PREPEND_F[TRX.prep[t.net]]:0;
|
||||
const ex={k:'t',net:t.net,prem:!!t.premium&&t.city==='hkg',pref:t.pref||'normal',lab:labOf(N_('common.net_transit'),'net',NET[t.net].name),id:t.id,city:t.city,cap:cap*(1-pf),used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak};
|
||||
const ex={k:'t',net:t.net,prem:premOn(t),pref:t.pref||'normal',lab:labOf(N_('common.net_transit'),'net',NET[t.net].name),id:t.id,city:t.city,cap:cap*(1-pf),used:0,rank:3,ok:n=>!(depeer&&t.net==='cog'&&n==='ggl')&&n!==leak};
|
||||
E.push(ex);if(pf)E.push({...ex,cap:cap*pf,prep:true});}
|
||||
// `nets`: every network ok() can say yes to, so it need not be asked about the other hundred.
|
||||
for(const c in S.ixp){const ct=ixCity(c);if(!(popUp(ct)||remote.includes(ct))||(S.ev.ixdown&&S.ev.ixdown[c]>day)||!(S.myIx[c]?myIxLive(c):liveN(ct,(S.ixSite||{})[c],(S.ixn||{})[c])))continue;const set=ixSessions(c);R2.sessions+=set.size;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ function linkDown(l){return l.cut>S.day||(S.ev.runet>S.day&&ruCity(l.a)!==ruCity
|
|||
function remoteCities(){return [...new Set(S.links.filter(l=>l.kind==='vxc').flatMap(l=>[l.a,l.b]))].filter(c=>!S.pops[c]);}
|
||||
function nniUsed(c,prov){return S.links.filter(l=>l.kind==='vxc'&&l.prov===prov&&(l.a===c||l.b===c)).reduce((a,l)=>a+VXC[l.vt].g,0)+S.biz.filter(b=>BIZ_T[b.type].nni&&b.prov===prov&&b.city===c).reduce((a,b)=>a+b.bw,0);}
|
||||
// Monthly price of one connection; compute() sums these, the connections overview lists them.
|
||||
function transitMo(t,q){const n=t.n||1;return Math.max(q,PORT[t.tier].g*n*0.2)*NET[t.net].price*(t.premium&&t.city==='hkg'?NET[t.net].premium:1)*S.priceMul*netMult(NET[t.net],t.city)+PORT[t.tier].tmo*n+(t.clean?cleanMo(t):0);}
|
||||
function transitMo(t,q){const n=t.n||1;return Math.max(q,PORT[t.tier].g*n*0.2)*transitPerG(NET[t.net],t.city,premOn(t))*S.priceMul+PORT[t.tier].tmo*n+(t.clean?cleanMo(t):0);}
|
||||
function pniMo(p,use){if(!pniOn(p))return 0;return (p.g1?Math.round(PORT[0].pni/2):PORT[p.tier].pni)*(p.n||1)+(NET[p.net].pol==='paid'&&!paidFree(NET[p.net])?NET[p.net].paidFee:0)+(NET[p.net].perG?Math.round(NET[p.net].perG*use):0);}
|
||||
function ixMo(c){return S.myIx[c]?Math.round(myFab(c).mo*((S.ixSite||{})[c]==='ab'?1.5:1)):ixPortMo(c,S.ixp[c])*((S.ixn||{})[c]||1)+dkAddonMo(c);}
|
||||
function nniPort(c,prov){return (S.nni||[]).find(x=>x.city===c&&x.prov===prov);}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function sanitize(s){
|
|||
for(const l of s.links){const k=edgeKey(l);if(lo[k]&&l.metric===undefined)lo[k]='normal';delete l.metric;}
|
||||
for(const k in lo)pm[k]=lo[k];const ks=new Set(s.links.map(edgeKey));for(const k of Object.keys(pm))if(!ks.has(k)||!own(MET,pm[k])||pm[k]==='normal')delete pm[k];}
|
||||
const degO=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;
|
||||
s.transit=s.transit.filter(t=>t&&isCity(t.city)&&isNet(t.net)).map(t=>(t.lacp=degO(t.lacp),t.site=['a','b','ab'].includes(t.site)?t.site:'a',t.id=sid(t.id),t.tier=tier(t.tier),t.n=lag(t.n),t.down=num(t.down,0),t.clean=!!t.clean,t));
|
||||
s.transit=s.transit.filter(t=>t&&isCity(t.city)&&isNet(t.net)).map(t=>(t.lacp=degO(t.lacp),t.site=['a','b','ab'].includes(t.site)?t.site:'a',t.id=sid(t.id),t.tier=tier(t.tier),t.n=lag(t.n),t.down=num(t.down,0),t.clean=!!t.clean,t.premium=premOnlyAt(NET[t.net],t.city)||!!t.premium&&premCity(NET[t.net],t.city),t));
|
||||
s.pni=s.pni.filter(x=>x&&isCity(x.city)&&isNet(x.net)).map(x=>(x.lacp=degO(x.lacp),x.site=['a','b','ab'].includes(x.site)?x.site:'a',x.id=sid(x.id),x.tier=tier(x.tier),x.n=lag(x.n),x.sacrif=!!x.sacrif,x));
|
||||
// PNIs on order (#…): delivery day, a pending augment, and 1G for the one network that sells it
|
||||
for(const x of s.pni){if(x.ready!==undefined)x.ready=num(x.ready,0);if(x.g1)x.g1=x.tier===0&&x.net==='dtk'?true:undefined;else delete x.g1;if(x.up){const u=x.up;x.up=u&&typeof u==='object'?{tier:tier(u.tier),n:lag(u.n),ready:num(u.ready,0),g1:!!u.g1&&x.net==='dtk'&&tier(u.tier)===0}:undefined;if(!x.up)delete x.up;}}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const REQS={
|
|||
local:{l:tr('requirements.local_breakout_transit_or_an_ix'),bonus:.2,ip:true,ok:b=>S.transit.some(t=>t.city===b.city)||hasIxAt(b.city)||(isTier1()&&S.pni.some(p=>p.city===b.city))},
|
||||
metro:{l:tr('requirements.two_data_centers_in_every_metro'),bonus:.2,only:true,ok:b=>[b.city,b.city2].filter(Boolean).every(c=>S.pops[c]&&S.pops[c].site2)},
|
||||
twoup:{l:tr('requirements.wants_two_different_transit'),bonus:.15,ip:true,ok:()=>new Set(S.transit.map(t=>t.net)).size>=2||S.transit.length===0},
|
||||
china:{l:tr('requirements.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&&pniOn(p))},
|
||||
china:{l:tr('requirements.needs_low_loss_reach_into_china'),bonus:.3,ip:true,ok:()=>S.transit.some(premOn)||S.links.some(l=>l.premium)||S.pni.some(p=>NET[p.net].cn&&pniOn(p))},
|
||||
scrubbed:{l:tr('requirements.will_only_sign_with_a_network'),bonus:.15,ok:()=>hasScrub()},
|
||||
scrubnear:{l:tr('requirements.wants_a_scrubbing_center_on_its'),bonus:.15,ip:true,ok:b=>S.scrubs.some(x=>CITY[x.city].reg===CITY[b.city].reg)},
|
||||
puns:{l:tr('requirements.their_ceo_hates_puns_please_do'),bonus:.05,ok:()=>true},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ Object.assign(ACT,{
|
|||
buildPop:({city})=>{if(S.pops[city]||!cityOn(city))return;const flipNote=CITY[city]&&CITY[city].au;if(cnCity(city)&&!cnOk()){toast(tr('pops_transit_ix.you_need_a_license_first_foreign'),'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,tr('common.new_pop'),'#FF4F9A');if(flipNote)toast(pick([tr('pops_transit_ix.router_installed_in_city_upside_down',{city:CITY[city].name}),tr('pops_transit_ix.router_installed_in_city_the_vendor',{city:CITY[city].name})]),'good',[],{a:'city',v:city});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:bbStart(city)};floater(C.x,C.y-30,tr('common.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,tr('common.ad_campaign'),'#FF8A3D');after();},
|
||||
buyTransit:({city,net,tier})=>{tier=+tier;if(scnRule('noTransit')){toast(tr('pops_transit_ix.no_transit_in_this_scenario_peering'),'bad');sfx('err');return;}if(!S.pops[city]||!NET[net]||!sellsAt(NET[net],city)||!PORT[tier])return;if(!portOk(city,tier)){toast(tr('actions.your_router_can_t_take_a',{port:PORT[tier].n}),'bad');sfx('err');return;}const ex=S.transit.find(t=>t.city===city&&t.net===net);if(ex&&tier<=ex.tier)return;if(!portGate(city,ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(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(tr('pops_transit_ix.net_transit_is_live_in_city',{net:esc(NET[net].name),city:CITY[city].name}),'good');after();},
|
||||
buyTransit:({city,net,tier})=>{tier=+tier;if(scnRule('noTransit')){toast(tr('pops_transit_ix.no_transit_in_this_scenario_peering'),'bad');sfx('err');return;}if(!S.pops[city]||!NET[net]||!sellsAt(NET[net],city)||!PORT[tier])return;if(!portOk(city,tier)){toast(tr('actions.your_router_can_t_take_a',{port:PORT[tier].n}),'bad');sfx('err');return;}const ex=S.transit.find(t=>t.city===city&&t.net===net);if(ex&&tier<=ex.tier)return;if(!portGate(city,ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(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,...(premOnlyAt(NET[net],city)?{premium:true}:{})});toast(tr('pops_transit_ix.net_transit_is_live_in_city',{net:esc(NET[net].name),city:CITY[city].name}),'good');after();},
|
||||
lagT:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;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)||!portGate(t.city,PORT_SLOT(t.tier)))return;if(!spend(PORT[t.tier].setup))return;}t.n=n;if(n<2&&t.site==='ab')t.site='a';toast(+d>0?tr('pops_transit_ix.lag_member_added_net_in_city',{net:esc(NET[t.net].name),city:CITY[t.city].name,lag:lagName(t.tier,n)}):tr('pops_transit_ix.lag_member_removed'),'good');after();},
|
||||
lagP:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;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&&(!pniOn(p)||p.up||msfNope(p.net,p.city)))return;if(+d>0&&(!portGate(p.city,PORT_SLOT(p.tier))||!spend(1500+PORT[p.tier].setup/2)))return;
|
||||
// A LAG member is an augment: the big networks take months for that too.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Object.assign(ACT,{
|
||||
applyCn:()=>{if(S.cnLic.state!=='none')return;if(!spend(CN_LIC))return;S.cnLic={state:'pending',ready:S.day+45};toast(tr('security_and_china.application_filed_your_local_partner'),'goal');after();},
|
||||
togglePrem:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.premium=!t.premium;sfx('click');after();},
|
||||
togglePrem:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t||!premCity(NET[t.net],t.city)||premOnlyAt(NET[t.net],t.city))return;t.premium=!t.premium;sfx('click');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)<T.lvl){toast(tr('security_and_china.tier_scrubbing_unlocks_at_customer',{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('security_and_china.tier_scrubbing_center_online_in_city',{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)<T.lvl){toast(tr('security_and_china.tier_scrubbing_unlocks_at_customer',{tier:T.n,lv:T.lvl}),'bad');sfx('err');return;}if(!spend(Math.round(T.cost*0.6)))return;x.tier=tier;toast(tr('security_and_china.scrubbing_upgraded_to_tier',{tier:T.n}),'good');after();},
|
||||
scrubMode:()=>{if(!hasScrub())return;S.scrubMode=S.scrubMode==='ondemand'?'always':'ondemand';sfx('click');after();},
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ function cityPanel(c){
|
|||
h+=`<section><h3>${tr('common.ip_transit')}</h3><p class="lead">${tr('city_panel.pay_a_bigger_network_per_gbps')}</p>`;
|
||||
const prov=NETS.filter(n=>sellsAt(n,c)).sort((a,b)=>a.price-b.price);
|
||||
if(!prov.length)h+=`<p class="empty">${tr('city_panel.nobody_sells_transit_here_haul_your')}</p>`;
|
||||
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)*netMult(n,c);
|
||||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="tag ${n.type}">${TYPE_L[n.type]}</span></div><div class="meta">${tr('city_panel.price_per_gbps_month_billed_on',{price:pr.toFixed(2)})}</div>`;
|
||||
for(const n of prov){const t=S.transit.find(x=>x.city===c&&x.net===n.id);const pr=transitPerG(n,c,premOnlyAt(n,c)||!!(t&&premOn(t)))*S.priceMul;
|
||||
h+=`<div class="row">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="tag ${n.type}">${TYPE_L[n.type]}</span></div><div class="meta">${tr('city_panel.price_per_gbps_month_billed_on',{price:pr.toFixed(2)})}</div>${premOnlyAt(n,c)&&!t?`<div class="meta">${tr('city_panel.only_the_cn_too_premium_crossing')}</div>`:''}`;
|
||||
if(t){const u=R.useT[t.id]||0,cap=lagCap(PORT[t.tier].g,t.n),tdown=t.down>S.day;
|
||||
h+=`<div class="kv"><span>${lagName(t.tier,t.n)}${tdown?' · <b style="color:var(--bad)">'+tr('common.outage')+'</b>':''}</span><b>${fmtG(u)}</b></div><div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('t',t.id,t.pref)}${siteCtl('t',t.id,c,t.site)}${n.premium&&c==='hkg'?`<div class="btns">${btn(t.premium?tr('city_panel.cn_too_premium_on'):tr('city_panel.switch_to_cn_too_premium_x',{x:n.premium}),'togglePrem',{id:t.id},t.premium?'green sm':'sm')}</div>`:''}${(()=>{const top=transitTop([t.id],4);return top.length?`<div class="ttop"><div class="meta"><b>${tr('city_panel.top_destinations_on_this_port')}</b></div>${top.map(([id,v])=>`<div class="meta">${esc(NET[id].name)} · ${fmtG(v)} · <i>${esc(offTransitHint(id,c))}</i></div>`).join('')}</div>`:'';})()}<div class="meta">${tr('city_panel.95th_pct_p95_commit_commit_bill',{p95: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))})}</div>
|
||||
h+=`<div class="kv"><span>${lagName(t.tier,t.n)}${tdown?' · <b style="color:var(--bad)">'+tr('common.outage')+'</b>':''}</span><b>${fmtG(u)}</b></div><div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('t',t.id,t.pref)}${siteCtl('t',t.id,c,t.site)}${premOnlyAt(n,c)?`<p class="note">${tr('city_panel.only_the_cn_too_premium_crossing')}</p>`:premCity(n,c)?`<div class="btns">${btn(t.premium?tr('city_panel.cn_too_premium_on'):tr('city_panel.switch_to_cn_too_premium_x',{x:n.premium}),'togglePrem',{id:t.id},t.premium?'green sm':'sm')}</div>`:''}${(()=>{const top=transitTop([t.id],4);return top.length?`<div class="ttop"><div class="meta"><b>${tr('city_panel.top_destinations_on_this_port')}</b></div>${top.map(([id,v])=>`<div class="meta">${esc(NET[id].name)} · ${fmtG(v)} · <i>${esc(offTransitHint(id,c))}</i></div>`).join('')}</div>`:'';})()}<div class="meta">${tr('city_panel.95th_pct_p95_commit_commit_bill',{p95: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))})}</div>
|
||||
<div class="btns">${PORT.map((P2,i)=>i>t.tier&&portShown(i)?btn((t.n||1)>1?tr('common.upgrade_all_to_port_cost_mo',{port:P2.n,cost:fmt$(P2.setup*(t.n||1)),mo:fmt$(P2.tmo*(t.n||1))}):tr('common.upgrade_port_cost_mo_mo',{port:P2.n,cost:fmt$(P2.setup*(t.n||1)),mo:fmt$(P2.tmo*(t.n||1))}),'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash<P2.setup*(t.n||1)||!portOk(c,i)):'').join('')}${(t.n||1)<LAG_MAX?btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(PORT[t.tier].setup),mo:fmt$(PORT[t.tier].tmo)}),'lagT',{id:t.id,d:1},'sm',S.cash<PORT[t.tier].setup||!portOk(c,t.tier)):''}${(t.n||1)>1?btn(tr('common.member'),'lagT',{id:t.id,d:-1},'ghost sm'):''}${btn(t.clean?tr('city_panel.clean_pipe_on'):tr('city_panel.clean_pipe_mo_mo_scrubs_ddos',{mo:fmt$(cleanMo(t))}),'cleanPipe',{id:t.id},t.clean?'green sm':'sm')}${btn(UI.confirm===t.id?tr('common.really_cancel'):tr('common.cancel'),'cancelTransit',{id:t.id},'ghost sm')}</div>`;}
|
||||
else h+=`<div class="btns">${PORT.map((P2,i)=>portShown(i)?btn(tr('city_panel.port_cost_mo_mo',{port:P2.n,cost:fmt$(P2.setup),mo:fmt$(P2.tmo)}),'buyTransit',{city:c,net:n.id,tier:i},'sm',S.cash<P2.setup||!portOk(c,i)):'').join('')}</div>`;
|
||||
h+=`</div></div>`;}
|
||||
|
|
|
|||
|
|
@ -724,6 +724,7 @@
|
|||
"city_panel.nothing_plugged_in_here_yet":"Nothing plugged in here yet",
|
||||
"city_panel.on_demand_engages_in_n_d":"On-demand (engages in {n}d)",
|
||||
"city_panel.one_router_is_a_single_point":"One router is a single point of failure.",
|
||||
"city_panel.only_the_cn_too_premium_crossing":"Here they sell only their CN-Too premium crossing, over land to China: Hong Kong prices, about 3% loss into China, and nothing else.",
|
||||
"city_panel.open_a_pop_here":"Open a POP here",
|
||||
"city_panel.or_drag_from_one_of_your":"Or drag from one of your routers to this city to lay fiber and build the POP in one go.",
|
||||
"city_panel.order_circuit_anyway":"Order circuit anyway",
|
||||
|
|
|
|||
79
tests/moscow-premium.test.js
Normal file
79
tests/moscow-premium.test.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
|
||||
const start = "ACT.start({});S.cash=1e9;S.nextFail=1e9;S.nextEvent=1e9;for(const g of GOALS)S.done[g.id]=0";
|
||||
|
||||
test('#195 China Telecomet sells its premium crossing in Moscow, and nothing else there', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(start);
|
||||
assert.equal(ev("sellsAt(NET.ctc,'mos')"), true, 'on sale in Moscow');
|
||||
assert.equal(ev("NET.ctc.pops.includes('mos')"), false, 'but no PoP there: no PNI, no exchange');
|
||||
assert.equal(ev("peerOk('ctc','pni','mos').ok"), false);
|
||||
ev("ACT.buildPop({city:'mos'});ACT.buyTransit({city:'mos',net:'ctc',tier:1})");
|
||||
const t = "S.transit.find(t=>t.net==='ctc'&&t.city==='mos')";
|
||||
assert.equal(ev(`!!${t}`), true, 'the order went through');
|
||||
assert.equal(ev(`${t}.premium`), true, 'it is the premium crossing from the start');
|
||||
ev(`ACT.togglePrem({id:${t}.id})`);
|
||||
assert.equal(ev(`${t}.premium`), true, 'and it cannot be switched to plain transit');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#195 it costs the same in Moscow as in Hong Kong, and the bill agrees with the panel', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
ev(start);
|
||||
const mos = ev("transitPerG(NET.ctc,'mos',true)"), hkg = ev("transitPerG(NET.ctc,'hkg',true)");
|
||||
assert.equal(mos, hkg, 'same price per Gbps');
|
||||
assert.ok(hkg > ev("transitPerG(NET.ctc,'hkg',false)"), 'dearer than plain transit');
|
||||
ev("ACT.buildPop({city:'mos'});ACT.buyTransit({city:'mos',net:'ctc',tier:1});compute()");
|
||||
const t = "S.transit.find(t=>t.net==='ctc')";
|
||||
assert.equal(ev(`transitMo(${t},100)`), ev(`Math.max(100,PORT[${t}.tier].g*0.2)*${hkg}*S.priceMul+PORT[${t}.tier].tmo`), 'billed at the Hong Kong price');
|
||||
ev("UI.sel={type:'city',id:'mos'};UI.tab='up';renderPanel()");
|
||||
const body = dom.window.document.getElementById('panelBody').textContent;
|
||||
assert.match(body, /China Telecomet/);
|
||||
assert.match(body, /only their CN-Too premium crossing/);
|
||||
assert.match(body, new RegExp(ev(`(${hkg}*S.priceMul).toFixed(2)`).replace('.', '\\.')), 'the panel shows that price');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#195 European traffic hauled to Moscow crosses into China with far less loss on the premium port', () => {
|
||||
// Russians in the game send little to China; the point is Europe: carry Frankfurt's traffic to Moscow and hand it over there.
|
||||
const lost = premium => {
|
||||
const { ev, errors } = load();
|
||||
ev(start + ";ACT.launchBB({city:'fra'});S.pops.fra.bb.d=300;ACT.buildPop({city:'mos'});ACT.buyTransit({city:'mos',net:'ctc',tier:1})");
|
||||
ev("S.links.push({id:'w1',a:'fra',b:'mos',kind:'wave',tier:3,km:2000,sub:false,mo:1,mult:1,trench:'w1',cut:0,day:0})");
|
||||
if (!premium) ev("S.transit.find(t=>t.net==='ctc').premium=false");
|
||||
ev('compute()');
|
||||
assert.deepEqual(errors, []);
|
||||
return { cross: ev('R.gfwCross||0'), lost: ev('R.gfwLost||0') };
|
||||
};
|
||||
const p = lost(true), plain = lost(false);
|
||||
assert.ok(p.cross > 0, 'traffic for China goes out through Moscow');
|
||||
assert.ok(Math.abs(p.lost / p.cross - 0.03) < 0.005, `about 3% lost on the premium crossing (${(p.lost / p.cross * 100).toFixed(1)}%)`);
|
||||
assert.ok(plain.lost / plain.cross > 0.15, 'against about 20% without it');
|
||||
});
|
||||
|
||||
test('#195 Hong Kong still works as before, and premium is not offered where it is not sold', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(start + ";ACT.buildPop({city:'hkg'});ACT.buyTransit({city:'hkg',net:'ctc',tier:1})");
|
||||
const t = "S.transit.find(t=>t.city==='hkg')";
|
||||
assert.equal(ev(`!!${t}.premium`), false, 'plain transit by default in Hong Kong');
|
||||
ev(`ACT.togglePrem({id:${t}.id})`);
|
||||
assert.equal(ev(`${t}.premium`), true, 'switched on');
|
||||
ev(`ACT.togglePrem({id:${t}.id})`);
|
||||
assert.equal(ev(`${t}.premium`), false, 'and off again');
|
||||
ev("ACT.buyTransit({city:'fra',net:'ctc',tier:1})");
|
||||
ev("const f=S.transit.find(t=>t.city==='fra'&&t.net==='ctc');ACT.togglePrem({id:f.id})");
|
||||
assert.equal(ev("!!S.transit.find(t=>t.city==='fra'&&t.net==='ctc').premium"), false, 'no premium in Frankfurt');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#195 saves: a Moscow port stays premium, a bogus premium elsewhere is dropped, and it meets the China requirement', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(start + ";ACT.buildPop({city:'mos'});ACT.buyTransit({city:'mos',net:'ctc',tier:1});ACT.buyTransit({city:'fra',net:'ctc',tier:1})");
|
||||
ev("const s=JSON.parse(JSON.stringify(S));for(const t of s.transit){if(t.city==='mos')t.premium=false;else if(t.net==='ctc')t.premium=true;}window.__t=migrate(s)");
|
||||
assert.equal(ev("__t.transit.find(t=>t.city==='mos').premium"), true);
|
||||
assert.equal(ev("__t.transit.find(t=>t.city==='fra'&&t.net==='ctc').premium"), false);
|
||||
assert.equal(ev("REQS.china.ok()"), true, 'a Moscow premium port counts as low-loss reach into China');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue