Prefer keeps the say at its own POP only, and the direct ranks stop slowing the game day
Review of #205: - Prefer no longer switches the carrier-direct rule off for the whole network. A POP with a Prefer-marked transit port keeps what Prefer says; every other POP keeps the rule. compute(), traceroute and the reference loop in the tests all use the same per-POP rule, and a new test covers it (New York and Chicago, Prefer on one POP's Tell-Ya port). - dayTick() cost. The harness is neutral (the same page on both sides differs by 1%), but the cost was real: the four extra rank passes inside compute()'s main loop made V8 deoptimise compute() 954 times in 30 game days against 46 on main. The direct ranks now run in a small function of their own, in the plain way the reference loop does (their lists are one carrier's ports), so the main loop is the one main has, and the setup moved out of compute(). 61 deopts instead of 954. - Italian: "Porta qui" read as "port here" next to "Porta più vicina"; it is "Instrada qui" now, and "Ogni POP instrada il traffico..." matches. - Help text: says that real BGP carries the traffic from every POP (the shorter AS path beats IGP distance), that Carry here does that here, and that Nearest port is the default. All six languages.
This commit is contained in:
parent
b8845413d3
commit
eb78d7104e
14 changed files with 77 additions and 23 deletions
|
|
@ -17,7 +17,7 @@ All notable changes to this project are documented here. The project follows
|
|||
- Waves between Philippine islands now cost more than waves out of the country: Manila to Cebu costs about twice Manila to Hong Kong.
|
||||
- Manila, Cebu and Davao have more people online, in line with their real populations.
|
||||
- Cable names on the map no longer pile on top of each other when you zoom in. Where short cables crowd together, a name that would cover another is left out, and selecting a city shows the names of all its cables.
|
||||
- Traffic for a carrier now leaves through that carrier's own transit port at the same POP, instead of being shared with every other transit port there. Networks that buy transit from the carrier get the same treatment, and a new switch on each transit port, Carry here, pulls that traffic across your network from POPs that have no port of that carrier. Prefer, Backup only and RouteScript still win.
|
||||
- Traffic for a carrier now leaves through that carrier's own transit port at the same POP, instead of being shared with every other transit port there. Networks that buy transit from the carrier get the same treatment, and a new switch on each transit port, Carry here, pulls that traffic across your network from POPs that have no port of that carrier. Prefer, Backup only and RouteScript still win, and Prefer only does so at the POP where you set it.
|
||||
- Inspecting a congested or busy link now moves the map to it, zoomed so the whole line fits beside the open panel.
|
||||
|
||||
## [2.2.0] — 2026-10-31
|
||||
|
|
|
|||
|
|
@ -128,7 +128,8 @@ never freezes the game.
|
|||
goes first, before plain transit, for traffic bound for that carrier or for a network that buys
|
||||
transit from it (`25-direct-egress.js`: the shorter AS path): always at its own POP, and from every
|
||||
POP when the port is set to carry. Such a port is still an ordinary transit exit for the other
|
||||
POPs. A Prefer-marked port, backup, RouteScript and Auto-TE rules keep their say. With Auto-TE, overflow spills
|
||||
POPs. Backup, RouteScript and Auto-TE rules keep their say, and so does a Prefer-marked port at its own POP (the other
|
||||
POPs keep the rule). With Auto-TE, overflow spills
|
||||
onto alternate paths; RouteScript rules (`teRules()`) can prefer, avoid, cap, drain
|
||||
or blackhole.
|
||||
5. Layer-2 customers (L2VPN, SD-WAN, waves) are carved out of link capacity first.
|
||||
|
|
|
|||
|
|
@ -2158,7 +2158,7 @@
|
|||
"help.want_to_know_how_it_really":"Willst du wissen, wie es wirklich funktioniert?",
|
||||
"help.what_a_wave_costs_depends_on":"Was eine Wave kostet, hängt davon ab, wo sie läuft. Europa ist günstig (viel konkurrierende Glasfaser), Nordamerika Durchschnitt, Asien und Südamerika teurer, und alles nach Afrika kostet ein Mehrfaches. Jede Route hat ihren eigenen Marktpreis, und neue Mieten werden jedes Jahr etwa 8 % günstiger, also kann Warten sich lohnen. Der Link-Planer sagt dir, wie eine Route im Vergleich dasteht.",
|
||||
"help.you_built_a_cartoon_internet_now":"Du hast ein Cartoon-Internet gebaut. Jetzt schau dir an, wie das echte funktioniert:",
|
||||
"help.you_pay_a_bigger_network_per":"Du bezahlst ein größeres Netz pro Gbps, und es liefert deinen Traffic überallhin. Einfach, volle Reichweite, nie kostenlos.",
|
||||
"help.you_pay_a_bigger_network_per":"Du bezahlst ein größeres Netz pro Gbps, und es liefert deinen Traffic überallhin. Einfach, volle Reichweite, nie kostenlos. Der eigene Port eines Carriers nimmt den Traffic, der für diesen Carrier bestimmt ist. Im echten BGP gilt das von jedem POP aus, weil der kürzere AS-Pfad die IGP-Distanz schlägt; hier ist es der Schalter Hierher leiten an einem Port, und Nächster Port ist die Voreinstellung.",
|
||||
"help.you_re_a_tier_1":"Du bist <span style=\"color:var(--me)\">Tier 1</span>!",
|
||||
"help.your_fiber_links_are_leased_waves":"Deine Glasfaser-Links sind gemietete Waves zu einer festen Monatsrate. Länger und größer kostet mehr (10G → 6.4T), und Subsea kostet das 1,8-Fache.",
|
||||
"helpers.y_y_mon_d":"J{y} · {d}. {mon}",
|
||||
|
|
|
|||
|
|
@ -2156,7 +2156,7 @@
|
|||
"help.want_to_know_how_it_really":"¿Quieres saber cómo funciona de verdad?",
|
||||
"help.what_a_wave_costs_depends_on":"Lo que cuesta una onda depende de por dónde pase. Europa es barata (mucha fibra compitiendo), Norteamérica es media, Asia y Sudamérica son más caras, y cualquier cosa hacia África cuesta varias veces más. Cada ruta tiene su precio de mercado, y los alquileres nuevos son un 8 % más baratos cada año, así que esperar puede compensar. El planificador de enlaces te dice cómo se compara una ruta.",
|
||||
"help.you_built_a_cartoon_internet_now":"Construiste un internet de dibujos animados. Ahora mira cómo funciona el de verdad:",
|
||||
"help.you_pay_a_bigger_network_per":"Pagas a una red mayor por Gbps y entrega tu tráfico a cualquier parte. Fácil, alcance total, nunca gratis.",
|
||||
"help.you_pay_a_bigger_network_per":"Pagas a una red mayor por Gbps y entrega tu tráfico a cualquier parte. Fácil, alcance total, nunca gratis. El puerto de un carrier recibe el tráfico destinado a ese carrier. En el BGP real eso vale desde cada POP, porque la ruta AS más corta gana a la distancia IGP; aquí es el interruptor Llevar aquí de un puerto, y Puerto más cercano es lo predeterminado.",
|
||||
"help.you_re_a_tier_1":"¡Eres un <span style=\"color:var(--me)\">Tier 1</span>!",
|
||||
"help.your_fiber_links_are_leased_waves":"Tus enlaces de fibra son ondas alquiladas a tarifa mensual plana. Más largo y más grande cuesta más (10G → 6.4T), y lo submarino cuesta 1,8×.",
|
||||
"helpers.y_y_mon_d":"A{y} · {mon} {d}",
|
||||
|
|
|
|||
|
|
@ -2156,7 +2156,7 @@
|
|||
"help.want_to_know_how_it_really":"Tu veux savoir comment ça marche vraiment ?",
|
||||
"help.what_a_wave_costs_depends_on":"Le prix d’une longueur d’onde dépend de là où elle passe. L’Europe est bon marché (beaucoup de fibre en concurrence), l’Amérique du Nord dans la moyenne, l’Asie et l’Amérique du Sud plus chères, et tout ce qui va vers l’Afrique coûte plusieurs fois plus. Chaque route a son prix du marché, et les nouvelles locations baissent d’environ 8 % par an, donc attendre peut payer. Le planificateur de liens t’indique comment une route se situe.",
|
||||
"help.you_built_a_cartoon_internet_now":"Tu as construit un Internet de dessin animé. Découvre maintenant comment marche le vrai :",
|
||||
"help.you_pay_a_bigger_network_per":"Tu paies un plus gros réseau au Gbps et il livre ton trafic partout. Facile, couverture totale, jamais gratuit.",
|
||||
"help.you_pay_a_bigger_network_per":"Tu paies un plus gros réseau au Gbps et il livre ton trafic partout. Facile, couverture totale, jamais gratuit. Le port d’un carrier prend le trafic qui lui est destiné. Dans le vrai BGP, cela vaut depuis chaque POP, car le chemin AS le plus court l’emporte sur la distance IGP ; ici, c’est l’interrupteur Acheminer ici d’un port, et Port le plus proche est le réglage par défaut.",
|
||||
"help.you_re_a_tier_1":"Tu es un <span style=\"color:var(--me)\">Tier 1</span> !",
|
||||
"help.your_fiber_links_are_leased_waves":"Tes liens en fibre sont des longueurs d’onde louées à tarif mensuel fixe. Plus c’est long et gros, plus c’est cher (10G → 6.4T), et le sous-marin coûte 1,8× plus.",
|
||||
"helpers.y_y_mon_d":"A{y} · {d} {mon}",
|
||||
|
|
|
|||
|
|
@ -2156,7 +2156,7 @@
|
|||
"help.want_to_know_how_it_really":"Vuoi sapere come funziona davvero?",
|
||||
"help.what_a_wave_costs_depends_on":"Quanto costa una wave dipende da dove passa. L’Europa è economica (tanta fibra in concorrenza), il Nord America nella media, Asia e Sud America più care, e qualsiasi cosa verso l’Africa costa diverse volte tanto. Ogni rotta ha il suo prezzo di mercato, e i nuovi contratti costano circa l’8% in meno ogni anno, quindi aspettare può convenire. Il pianificatore di link ti dice come si piazza una rotta.",
|
||||
"help.you_built_a_cartoon_internet_now":"Hai costruito un internet a fumetti. Ora scopri come funziona quello vero:",
|
||||
"help.you_pay_a_bigger_network_per":"Paghi una rete più grande a Gbps e lei consegna il tuo traffico ovunque. Facile, copertura completa, mai gratis.",
|
||||
"help.you_pay_a_bigger_network_per":"Paghi una rete più grande a Gbps e lei consegna il tuo traffico ovunque. Facile, copertura completa, mai gratis. La porta di un carrier prende il traffico diretto a quel carrier. Nel vero BGP vale da ogni POP, perché il percorso AS più corto batte la distanza IGP; qui lo fa l’interruttore Instrada qui di una porta, e Porta più vicina è l’impostazione predefinita.",
|
||||
"help.you_re_a_tier_1":"Sei un <span style=\"color:var(--me)\">Tier 1</span>!",
|
||||
"help.your_fiber_links_are_leased_waves":"I tuoi link in fibra sono wave in affitto a canone mensile fisso. Più lunghe e più grandi costano di più (10G → 6.4T), e il sottomarino costa 1,8× tanto.",
|
||||
"helpers.y_y_mon_d":"A{y} · {d} {mon}",
|
||||
|
|
@ -2410,7 +2410,7 @@
|
|||
"link_panels.biggest_feeder_egress_in_city_set":"Fonte principale: {egress} a {city}. Impostala su “Solo backup”, dai ai clienti un’uscita più vicina (peering, una cache, transit locale) o alza la metrica di questo link.",
|
||||
"link_panels.build_a_pop_here_first":"Prima costruisci un POP qui.",
|
||||
"link_panels.cancel_the_iru":"Disdici l’IRU",
|
||||
"link_panels.carry_here":"Porta qui",
|
||||
"link_panels.carry_here":"Instrada qui",
|
||||
"link_panels.click_to_tear_down":"Clicca per chiudere la sessione",
|
||||
"link_panels.collecting_data_check_back_in_a":"Raccolta dati in corso. Ripassa tra qualche giorno.",
|
||||
"link_panels.congested_upgrade_it_or_add_a":"Congestionato. Potenzialo o aggiungi un percorso parallelo.",
|
||||
|
|
@ -2422,7 +2422,7 @@
|
|||
"link_panels.de_kicks_personalised_pricing_p_of_3d4f":"Prezzi personalizzati DE-KICKS: {p}% di quanto chiederebbe un IX normale.",
|
||||
"link_panels.each_channel_is_a_pair_of":"Ogni canale è una coppia di ottiche, una per estremità. Le ottiche ZR+ si infilano direttamente nei tuoi router. I transponder stanno su uno scaffale.",
|
||||
"link_panels.enters_your_network_at":"Entra nella tua rete a",
|
||||
"link_panels.every_pop_carries_net_s_traffic":"Ogni POP porta il traffico di {net} attraverso la tua rete fino a questa porta.",
|
||||
"link_panels.every_pop_carries_net_s_traffic":"Ogni POP instrada il traffico di {net} attraverso la tua rete fino a questa porta.",
|
||||
"link_panels.finish_in_1_day_price":"Termina in 1 giorno <small>{price}</small>",
|
||||
"link_panels.foreign_networks_need_a_local_joint":"Per costruire infrastrutture qui, le reti straniere hanno bisogno di una joint venture locale e di una licenza operativa.",
|
||||
"link_panels.found_your_own_ix_cost_mo":"Fonda il tuo IX <small>{cost} + {mo}/mese</small>",
|
||||
|
|
|
|||
|
|
@ -2156,7 +2156,7 @@
|
|||
"help.want_to_know_how_it_really":"Quer saber como funciona de verdade?",
|
||||
"help.what_a_wave_costs_depends_on":"Quanto custa uma wave depende de onde ela passa. A Europa é barata (muita fibra concorrendo), a América do Norte é mediana, a Ásia e a América do Sul são mais caras, e qualquer coisa indo para a África custa várias vezes mais. Cada rota tem seu preço de mercado, e novos aluguéis ficam uns 8% mais baratos a cada ano, então esperar pode compensar. O planejador de links diz como uma rota se compara.",
|
||||
"help.you_built_a_cartoon_internet_now":"Você construiu uma internet de desenho animado. Agora veja como a de verdade funciona:",
|
||||
"help.you_pay_a_bigger_network_per":"Você paga uma rede maior por Gbps e ela entrega seu tráfego em qualquer lugar. Fácil, alcance total, nunca de graça.",
|
||||
"help.you_pay_a_bigger_network_per":"Você paga uma rede maior por Gbps e ela entrega seu tráfego em qualquer lugar. Fácil, alcance total, nunca de graça. A porta de um carrier recebe o tráfego destinado a esse carrier. No BGP de verdade isso vale a partir de todo POP, porque o caminho AS mais curto vence a distância IGP; aqui é o botão Trazer para cá de uma porta, e Porta mais próxima é o padrão.",
|
||||
"help.you_re_a_tier_1":"Você é <span style=\"color:var(--me)\">Tier 1</span>!",
|
||||
"help.your_fiber_links_are_leased_waves":"Seus links de fibra são waves alugadas a uma mensalidade fixa. Mais longa e maior custa mais (10G → 6.4T), e subsea custa 1,8×.",
|
||||
"helpers.y_y_mon_d":"A{y} · {d} {mon}",
|
||||
|
|
|
|||
|
|
@ -24,8 +24,9 @@ function traceroute(src,to){const P=trPaths(src),me=slug(S.name)+'.net',lines=[]
|
|||
const N=NET[to.net],ex=trExits(to.net).filter(e=>P.dist[e.city]!==undefined);
|
||||
lines.unshift(`traceroute to www.${slug(N.name)}.example (${N.name}, AS${N.asn}) from ${CITY[src].name}, 30 hops max`);
|
||||
if(!ex.length){lines.push(' 2 * * *\n 3 * * * ← '+tr('traceroute.n_network_unreachable'));return {text:lines.join('\n'),why:tr('traceroute.nothing_on_your_network_reaches_net',{net:N.name,city:CITY[src].name}),asPath:null};}
|
||||
// As in compute(): a carrier's own port (or its customers' carrier) goes before other transit, at this POP or anywhere when it carries.
|
||||
const hiAny=S.transit.some(t=>t.pref==='high'&&popUp(t.city)&&!(t.down>S.day)&&liveN(t.city,t.site,t.n)),dtier=e=>hiAny||e.k!=='t'||e.pref==='low'?0:directTier(e.tnet,N.id);
|
||||
// As in compute(): a carrier's own port (or its customers' carrier) goes before other transit, at this POP or anywhere when it
|
||||
// carries, except from a POP with a Prefer-marked transit port, where Prefer keeps the say.
|
||||
const hiHere=S.transit.some(t=>t.city===src&&t.pref==='high'&&popUp(t.city)&&!(t.down>S.day)&&liveN(t.city,t.site,t.n)),dtier=e=>hiHere||e.k!=='t'||e.pref==='low'?0:directTier(e.tnet,N.id);
|
||||
const rk=e=>{const r=e.pref==='low'?4:e.rank,t=dtier(e);return t&&(e.carry||e.city===src)?Math.min(r,DIRECT_RANK[t][e.carry?0:1]):r;};
|
||||
ex.sort((a,b)=>rk(a)-rk(b)||(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||P.dist[a.city]-P.dist[b.city]);
|
||||
const e=ex.find(x=>x.used<x.cap*0.999)||ex[0];walk(P.path(e.city));
|
||||
|
|
|
|||
|
|
@ -5,3 +5,10 @@
|
|||
DIRECT_RANK[tier] = [carries, this POP only]. compute() and traceroute() share this. */
|
||||
const DIRECT_RANK=[null,[2.92,2.93],[2.94,2.95]];
|
||||
const directTier=(carrier,dest)=>carrier===dest?1:(NET[dest].up&&NET[dest].up.includes(carrier))?2:0;
|
||||
// What compute() needs of the rule, built once per call and kept out of compute(), whose size the JIT is sensitive to.
|
||||
// prefc[ci]: 1 where a Prefer-marked transit port has the say, so the rule is off for flows from that POP.
|
||||
// dirOf(id): the carriers you buy from that are direct for network id (itself: tier 1; one of its upstreams: tier 2), or null.
|
||||
function directSetup(E,NC){const cars=new Set(),prefc=new Uint8Array(NC);
|
||||
for(const e of E)if(e.k==='t'){cars.add(e.net);if(e.pref==='high')prefc[e.ci]=1;}
|
||||
const dirOf=id=>{let m=null;if(cars.has(id))(m=new Map()).set(id,1);const up=NET[id].up;if(up)for(const u of up)if(cars.has(u)&&!(m&&m.has(u)))(m||(m=new Map())).set(u,2);return m;};
|
||||
return {prefc,dirOf};}
|
||||
|
|
|
|||
|
|
@ -151,10 +151,10 @@ function compute(){
|
|||
// LOCAL_PREF on an upstream moves it ahead of or behind the other transits, never ahead of peering (#96).
|
||||
const eff=(e,n)=>{let r=base(e,n);if(TR){if(e.k==='t'&&TR.up[e.net])r=TR.up[e.net]==='prefer'?2.9:3.5;if(e.prep)r=4.4;if(e.k!=='c'&&TR.drain.has(e.city))r=4.6;const o=TR.net[n];if(o){if(o.prefer===e.k)r=0.5;else if(o.avoid===e.k)r=4.5;}}return r;};
|
||||
// A carrier's own port for traffic bound for it or for its customers (25-direct-egress.js): tried before plain transit, but
|
||||
// never over RouteScript, a Prefer-marked port or a port set to backup, which all keep the say they had. Such a port is
|
||||
// also an ordinary transit exit (rank 3), so POPs without one of its own can still use it.
|
||||
const hiAny=E.some(e=>e.k==='t'&&e.pref==='high');
|
||||
const dr=(e,n)=>{if(hiAny||e.k!=='t')return 0;const t=directTier(e.net,n);return t&&eff(e,n)===3?DIRECT_RANK[t][e.carry?0:1]:0;};
|
||||
// never over RouteScript or a port set to backup, which keep the say they had, and not from a POP with a Prefer-marked
|
||||
// transit port (PREFC), where Prefer keeps it. Such a port is also an ordinary transit exit (rank 3), so POPs without one of
|
||||
// its own can still use it. DSEL: for each direct rank, the networks that have an exit there.
|
||||
const DIR=directSetup(E,NC),PREFC=DIR.prefc,dirOf=DIR.dirOf,DSEL=new Map();
|
||||
const RANKS=TR?[0,0.5,1,2,CONE_RANK,2.9,2.92,2.93,2.94,2.95,3,3.5,4,4.4,4.5,4.6]:[0,1,2,CONE_RANK,2.92,2.93,2.94,2.95,3,4];
|
||||
// With `protect customers`, business flows take every rank first; home users get what is left.
|
||||
const PASSES=TR&&TR.protect?[x=>x.bz,x=>!x.bz]:null;
|
||||
|
|
@ -164,8 +164,8 @@ function compute(){
|
|||
const idx=L=>{L.hi=L.some(e=>e.hp===0);L.at=new Map();for(const e of L){const h=L.at.get(e.ci);if(h)h.push(e);else L.at.set(e.ci,[e]);}};
|
||||
// Networks with the same exits at a rank share one list (LIST, by content), so what one flow learns serves them all.
|
||||
const LIST=new Map();for(let i=0;i<E.length;i++)E[i].xi=i;
|
||||
const byRank={},RSET=new Set();for(const id of NET_IDS){const m=byRank[id]={};for(const e of okBy[id]){const r=TR?eff(e,id):base(e,id);RSET.add(r);(m[r]||(m[r]=[])).push(e);
|
||||
const d=dr(e,id);if(d){RSET.add(d);(m[d]||(m[d]=[])).push(e);}}
|
||||
const byRank={},RSET=new Set();for(let j=0;j<NET_IDS.length;j++){const id=NET_IDS[j],m=byRank[id]={},dm=dirOf(id);for(const e of okBy[id]){const r=TR?eff(e,id):base(e,id);RSET.add(r);(m[r]||(m[r]=[])).push(e);
|
||||
if(dm&&r===3&&e.k==='t'){const t=dm.get(e.net);if(t){const d=DIRECT_RANK[t][e.carry?0:1];let ds=DSEL.get(d);if(!ds)DSEL.set(d,ds=new Uint8Array(NET_IDS.length));ds[j]=1;RSET.add(d);(m[d]||(m[d]=[])).push(e);}}}
|
||||
for(const r in m){const L=m[r],key=L.map(e=>e.xi).join(','),o=LIST.get(key);if(o){m[r]=o;continue;}
|
||||
let V=L;if(NCOMP>1){const cs=[];for(const e of L){const k=COMP[e.ci];if(k>=0)(cs[k]||(cs[k]=[])).push(e);}for(const s of cs)if(s)idx(s);V={cs};}else idx(L);LIST.set(key,V);m[r]=V;}}
|
||||
// The flow being routed, and from its POP: distances, arriving edges and the paths walked so far, by city index.
|
||||
|
|
@ -215,16 +215,28 @@ function compute(){
|
|||
// Stable, in place: short lists by insertion (no garbage), long ones by the built-in sort. Both are stable with the
|
||||
// same comparison, so the order is the same either way.
|
||||
const sortD=a=>{const n=a.length;if(n>24){a.sort(byDist);return;}for(let i=1;i<n;i++){const x=a[i];let j=i-1;while(j>=0&&byDist(a[j],x)>0){a[j+1]=a[j];j--;}a[j+1]=x;}};
|
||||
// The direct ranks (25-direct-egress.js) have short lists, one carrier's ports, so they take the plain way: the usable exits
|
||||
// nearest first, tried in groups of equal distance, as the reference loop in the tests does. A direct rank only concerns the
|
||||
// networks that have an exit there, and nothing from a POP where Prefer has the say; a port that is not set to carry only takes
|
||||
// its own POP's traffic. Kept in a function of its own so the loop below stays as it was: the JIT is sensitive to its shape.
|
||||
const directPass=(rank,pass)=>{const DS=DSEL.get(rank),LOC=rank===DIRECT_RANK[1][1]||rank===DIRECT_RANK[2][1];
|
||||
for(let fi=0,FN=flows.length;fi<FN;fi++){f=flows[fi];
|
||||
if(f.rem<=1e-6||DS[f.nj]===0||PREFC[f.ci]===1||(pass&&!pass(f)))continue;
|
||||
Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++;
|
||||
let lst=byRank[f.n][rank];if(!lst)continue;if(lst.cs){lst=lst.cs[COMP[f.ci]];if(!lst)continue;}
|
||||
REST.length=0;
|
||||
if(LOC){const here=lst.at.get(f.ci);if(!here)continue;for(let h=0;h<here.length;h++)if(usable(here[h]))REST.push(here[h]);}
|
||||
else for(let li=0;li<lst.length;li++)if(usable(lst[li]))REST.push(lst[li]);
|
||||
sortD(REST);
|
||||
for(let i=0;i<REST.length&&f.rem>1e-6;){let j=i+1;while(j<REST.length&&REST[j].hp===REST[i].hp&&Math.abs(Dv[REST[j].ci]-Dv[REST[i].ci])<1e-6)j++;sendGroup(REST,i,j);i=j;}}};
|
||||
for(const pass of PASSES||[null])for(const rank of RANKS){
|
||||
if(!RSET.has(rank))continue;
|
||||
// A carrier's own port that is not set to carry only takes the traffic of the POP it sits in.
|
||||
const LOC=rank===DIRECT_RANK[1][1]||rank===DIRECT_RANK[2][1];
|
||||
if(DSEL.has(rank)){directPass(rank,pass);continue;}
|
||||
// Index loops in here: plain for…of allocates an iterator per loop until V8 has optimised compute().
|
||||
for(let fi=0,FN=flows.length;fi<FN;fi++){f=flows[fi];
|
||||
if(f.rem<=1e-6||(rank===0&&!f.cache)||(pass&&!pass(f)))continue;
|
||||
Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++;
|
||||
let lst=byRank[f.n][rank];if(!lst)continue;if(lst.cs){lst=lst.cs[COMP[f.ci]];if(!lst)continue;}
|
||||
if(LOC){G.length=0;const here=lst.at.get(f.ci);if(!here)continue;for(let h=0;h<here.length;h++){const e=here[h];if(e.used<e.cap&&!gone(e))G.push(e);}if(G.length)sendGroup(G,0,G.length);continue;}
|
||||
/* Groups are tried nearest first, preferred exits before the rest, in the order a stable sort of the usable
|
||||
exits gives. Exits only fill up once tried, so the usable ones stay the same until then. Nearly every flow
|
||||
fits in its first group: find that one with a scan (nothing is visited yet), and sort only what is left
|
||||
|
|
|
|||
|
|
@ -2157,7 +2157,7 @@
|
|||
"help.want_to_know_how_it_really":"Want to know how it really works?",
|
||||
"help.what_a_wave_costs_depends_on":"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.",
|
||||
"help.you_built_a_cartoon_internet_now":"You built a cartoon internet. Now see how the real one works:",
|
||||
"help.you_pay_a_bigger_network_per":"You pay a bigger network per Gbps and it delivers your traffic anywhere. Easy, full reach, never free.",
|
||||
"help.you_pay_a_bigger_network_per":"You pay a bigger network per Gbps and it delivers your traffic anywhere. Easy, full reach, never free. A carrier’s own port takes the traffic bound for that carrier. In real BGP that holds from every POP, because the shorter AS path beats IGP distance; here it is a port’s Carry here switch, and Nearest port is the default.",
|
||||
"help.you_re_a_tier_1":"You're a <span style=\"color:var(--me)\">Tier 1</span>!",
|
||||
"help.your_fiber_links_are_leased_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.",
|
||||
"helpers.y_y_mon_d":"Y{y} · {mon} {d}",
|
||||
|
|
|
|||
|
|
@ -77,6 +77,34 @@ test('Prefer, Backup only and RouteScript keep the say they had', () => {
|
|||
assert.deepEqual(g.errors, []);
|
||||
});
|
||||
|
||||
// New York and Chicago, both with eyeballs, a Level Tree and a Tell-Ya port each, and a 100G wave between them.
|
||||
function bothPops() {
|
||||
const g = load();
|
||||
g.ev(`ACT.pickStart({city:'nyc'});ACT.start({});S.cash=1e9;ACT.buildPop({city:'chi'});
|
||||
UI.via=null;UI.route='same';UI.lmode=null;openLinkModal('nyc','chi');ACT.buildLink({tier:1});closeModal();
|
||||
for(const c of ['nyc','chi']){ACT.launchBB({city:c});S.pops[c].bb.d=40;ACT.buyTransit({city:c,net:'lvl',tier:1});ACT.buyTransit({city:c,net:'tly',tier:1});}compute()`);
|
||||
g.p = (carrier, city) => port(g.ev, carrier, city);
|
||||
return g;
|
||||
}
|
||||
|
||||
test('a Prefer-marked port keeps the say at its own POP only; the other POPs still use their own carrier ports', () => {
|
||||
const { ev, p, errors } = bothPops();
|
||||
const lvlNyc = p('lvl', 'nyc'), lvlChi = p('lvl', 'chi'), tlyNyc = p('tly', 'nyc'), tlyChi = p('tly', 'chi');
|
||||
assert.ok(via(ev, lvlNyc, 'lvl') > 1 && via(ev, lvlChi, 'lvl') > 1, 'each POP sends Level Tree traffic out of its own Level Tree port');
|
||||
assert.equal(via(ev, tlyNyc, 'lvl') + via(ev, tlyChi, 'lvl'), 0, 'and none of it out of Tell-Ya');
|
||||
const chicago = via(ev, lvlChi, 'lvl');
|
||||
ev(`ACT.setPref({kind:'t',id:'${tlyNyc}',v:'high'});compute()`);
|
||||
assert.ok(via(ev, tlyNyc, 'lvl') > 1 && via(ev, lvlNyc, 'lvl') === 0, 'New York: Prefer on Tell-Ya takes Level Tree traffic too, as it always did');
|
||||
assert.ok(Math.abs(via(ev, lvlChi, 'lvl') - chicago) < 1e-6 && via(ev, tlyChi, 'lvl') === 0, 'Chicago: still its own Level Tree port, not hauled across to the Prefer port');
|
||||
// Traceroute says the same.
|
||||
assert.match(ev("traceroute('nyc',{net:'lvl'}).why"), /Tell-Ya.*New York/, 'traceroute from New York');
|
||||
assert.match(ev("traceroute('chi',{net:'lvl'}).why"), /Level Tree.*Chicago.*straight to Level Tree/, 'and from Chicago');
|
||||
// Take the Prefer away again: back to each POP on its own carrier's port.
|
||||
ev(`ACT.setPref({kind:'t',id:'${tlyNyc}',v:'normal'});compute()`);
|
||||
assert.ok(via(ev, lvlNyc, 'lvl') > 1 && via(ev, tlyNyc, 'lvl') === 0);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('from a POP without the carrier\'s port, traffic uses the nearest port, or crosses your network when the port carries', () => {
|
||||
const { ev, lvl, tly, link, errors } = twoPops();
|
||||
ev("S.te=null");
|
||||
|
|
|
|||
|
|
@ -3,13 +3,16 @@
|
|||
// Without Auto-TE, an exit whose shortest path from this POP is already full fits nothing, so it counts as
|
||||
// unusable, like a full exit (#210).
|
||||
module.exports = `
|
||||
// A carrier's own port (dr) is also a plain transit exit. A POP with a Prefer-marked transit port keeps what Prefer
|
||||
// says, and a port not set to carry only takes its own POP's traffic.
|
||||
const PH=new Set(E.filter(x=>x.k==='t'&&x.pref==='high').map(x=>CIDX[x.city]));
|
||||
const dr=(e,f)=>{if(e.k!=='t'||PH.has(f.ci)||eff(e,f.n)!==3)return 0;const t=directTier(e.net,f.n);return t?DIRECT_RANK[t][e.carry?0:1]:0;};
|
||||
for(const pass of PASSES||[null])for(const rank of RANKS){
|
||||
for(f of flows){
|
||||
if(f.rem<=1e-6||(rank===0&&!f.cache)||(pass&&!pass(f)))continue;
|
||||
Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++;
|
||||
// A carrier's own port (dr) is also a plain transit exit; one not set to carry only takes its own POP's traffic.
|
||||
const candidates=E.filter(e=>e.used<e.cap&&e.ok(f.n)&&
|
||||
((TR?eff(e,f.n):base(e,f.n))===rank||(dr(e,f.n)||-1)===rank)&&
|
||||
((TR?eff(e,f.n):base(e,f.n))===rank||(dr(e,f)||-1)===rank)&&
|
||||
(rank!==DIRECT_RANK[1][1]&&rank!==DIRECT_RANK[2][1]||CIDX[e.city]===f.ci)&&Dv[CIDX[e.city]]<Infinity&&!gone(e))
|
||||
.sort((a,b)=>(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||Dv[CIDX[a.city]]-Dv[CIDX[b.city]]);
|
||||
for(let i=0;i<candidates.length&&f.rem>1e-6;){
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ test('indexed routing matches the simple allocation loop across network changes'
|
|||
"S.transit.filter(t=>t.net==='lvl').forEach((t,i)=>{if(i%2===0)t.carry=true})",
|
||||
"S.transit.filter(t=>t.net==='tly').forEach(t=>{t.carry=true})",
|
||||
"S.transit.filter(t=>t.net==='lvl').forEach((t,i)=>{t.pref=i%2?'low':'normal'})",
|
||||
// Prefer keeps the say at its own POP: the POPs with a Prefer-marked port skip the carrier-direct rule, the others keep it.
|
||||
"S.transit.forEach((t,i)=>{if(t.net!=='lvl')t.pref=i%3===0?'high':'normal'})",
|
||||
"S.pni.forEach((p,i)=>p.pref=i%3===0?'high':i%3===1?'low':'normal')",
|
||||
"S.te={on:true,script:''};S.core={lv:2,run:2,legacy:true}",
|
||||
"S.te.script='prefer pni for goggle\\nspill at 80%\\navoid transit for netchill'",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue