PNIs and IX ports are both peering: traffic leaves at the nearest one (#298)
Routing tried every PNI (rank 1) before any IX port (rank 2), like a local-pref above peering, so a PNI in London pulled New York's traffic across the Atlantic even with the same network at the New York IX. PNIs now route at rank 2 with the IX ports, nearest first. At the same distance the PNI goes first: an IX port counts as PNI_TIE (0.001) further away, far below any link weight (at least 1). Distances compare as (Da-Db)+(dta-dtb) so exits at one distance stay exactly equal, and the POP-local shortcut skips lists that mix PNIs and IX ports. Backup only and RouteScript's prefer pni keep their say. The traceroute, the reference allocation in the tests and the RouteScript help follow.
This commit is contained in:
parent
7c65b9e7ed
commit
f303f29f22
16 changed files with 86 additions and 24 deletions
|
|
@ -6,6 +6,7 @@ All notable changes to this project are documented here. The project follows
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Traffic now leaves your network at the nearest peering, so a PNI in London no longer pulls New York's traffic across the Atlantic when the New York IX reaches the same network (#298). Where a PNI and an IX port reach a network in the same city, the PNI still goes first, and RouteScript's `prefer pni` still hauls everything to your PNIs.
|
||||||
- Fabric (NNI) ports now grow like your other ports: buy them at 10G, 100G or 400G (as fast as your router takes), and bundle up to eight into a LAG when one is not enough (#140). A fabric customer is no longer accepted, by hand or automatically, when its bandwidth would not fit on the port as well (#307).
|
- Fabric (NNI) ports now grow like your other ports: buy them at 10G, 100G or 400G (as fast as your router takes), and bundle up to eight into a LAG when one is not enough (#140). A fabric customer is no longer accepted, by hand or automatically, when its bandwidth would not fit on the port as well (#307).
|
||||||
- Pressing Space to play again after a pause now picks up at the speed you were playing, not always at 1× (#299).
|
- Pressing Space to play again after a pause now picks up at the speed you were playing, not always at 1× (#299).
|
||||||
- Your own subsea cables now land right on the city's dot, also in Fujairah, Dubai, Karachi, Barcelona, Osaka and other cities the map shifts slightly so they do not overlap (#305).
|
- Your own subsea cables now land right on the city's dot, also in Fujairah, Dubai, Karachi, Barcelona, Osaka and other cities the map shifts slightly so they do not overlap (#305).
|
||||||
|
|
|
||||||
|
|
@ -128,14 +128,15 @@ never freezes the game.
|
||||||
(`S.pairMet`) and sets the edge's weight; Dijkstra gives shortest paths from each POP.
|
(`S.pairMet`) and sets the edge's weight; Dijkstra gives shortest paths from each POP.
|
||||||
Links on standby (`l.standby`) add their capacity to the edge, but when loads are
|
Links on standby (`l.standby`) add their capacity to the edge, but when loads are
|
||||||
handed back to links the active ones fill first and standby links take the rest.
|
handed back to links the active ones fill first and standby links take the rest.
|
||||||
2. Builds the exit list `E`: embedded caches (rank 0), PNIs (1), IX ports (2),
|
2. Builds the exit list `E`: embedded caches (rank 0), PNIs and IX ports (2, both peering),
|
||||||
transit (3). Each exit has a capacity, the networks it can reach (`ok(net)`) and an
|
transit (3). Each exit has a capacity, the networks it can reach (`ok(net)`) and an
|
||||||
egress preference (`high`, `normal`, `low` = backup only). A transit port can also be set to
|
egress preference (`high`, `normal`, `low` = backup only). A transit port can also be set to
|
||||||
carry (`t.carry`): see step 4.
|
carry (`t.carry`): see step 4.
|
||||||
3. Builds flows: for every POP, its demand (eyeballs and customers) split across
|
3. Builds flows: for every POP, its demand (eyeballs and customers) split across
|
||||||
destination networks by their traffic share (`NSH`, with regional variants for
|
destination networks by their traffic share (`NSH`, with regional variants for
|
||||||
China, Russia and Korea). Incidents can add junk flows or scale demand.
|
China, Russia and Korea). Incidents can add junk flows or scale demand.
|
||||||
4. Routes flows rank by rank: the nearest usable exit first, ECMP across equal exits,
|
4. Routes flows rank by rank: the nearest usable exit first, ECMP across equal exits (a PNI goes before an
|
||||||
|
IX port at the same distance: `PNI_TIE`, #298),
|
||||||
consuming link, router (`nodeCap`) and exit capacity. A carrier's own transit port also
|
consuming link, router (`nodeCap`) and exit capacity. A carrier's own transit port also
|
||||||
goes first, before plain transit, for traffic bound for that carrier or for a network that buys
|
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
|
transit from it (`25-direct-egress.js`: the shorter AS path): always at its own POP, and from every
|
||||||
|
|
|
||||||
|
|
@ -3815,7 +3815,7 @@
|
||||||
"routescript.done_i_vibe_checked_your_bgp":"Fertig! Ich habe deinem BGP einen Vibe-Check verpasst. Deploye es sofort: Probeläufe sind was für Leute, die an sich zweifeln.",
|
"routescript.done_i_vibe_checked_your_bgp":"Fertig! Ich habe deinem BGP einen Vibe-Check verpasst. Deploye es sofort: Probeläufe sind was für Leute, die an sich zweifeln.",
|
||||||
"routescript.drain_a_pop_and_steer_around":"Zieh den Traffic von einem POP ab und leite um einen seiner Links herum, bevor du daran arbeitest. Ersetz die Namen durch die, an denen du arbeitest.",
|
"routescript.drain_a_pop_and_steer_around":"Zieh den Traffic von einem POP ab und leite um einen seiner Links herum, bevor du daran arbeitest. Ersetz die Namen durch die, an denen du arbeitest.",
|
||||||
"routescript.during_an_attack_rtbh_the_target":"Während eines Angriffs das Ziel upstream blackholen (RTBH). Alle anderen sind gerettet; das Ziel ist offline, bis du die Regel entfernst.",
|
"routescript.during_an_attack_rtbh_the_target":"Während eines Angriffs das Ziel upstream blackholen (RTBH). Alle anderen sind gerettet; das Ziel ist offline, bis du die Regel entfernst.",
|
||||||
"routescript.every_gigabit_leaving_your_network":"Jedes Gigabit, das dein Netz verlässt, wählt einen Ausgang: einen PNI, einen IX-Port oder einen Transit-Port. Ohne Eingriff nimmt es den günstigsten mit freiem Platz: erst PNI, dann IX, dann Transit. RouteScript ändert diese Wahl, so wie Local-Pref, AS-Path-Prepending und Wartungs-Drains auf echten Routern.",
|
"routescript.every_gigabit_leaving_your_network_picks":"Jedes Gigabit, das dein Netz verlässt, wählt einen Ausgang: einen PNI, einen IX-Port oder einen Transit-Port. Ohne Eingriff nimmt es das nächste Peering mit freiem Platz (in derselben Stadt den PNI vor dem IX-Port) und Transit erst, wenn kein Peering es nehmen kann. RouteScript ändert diese Wahl, so wie Local-Pref, AS-Path-Prepending und Wartungs-Drains auf echten Routern.",
|
||||||
"routescript.filled_in_from_your_network_as":"Ausgefüllt mit deinem Netz, wie es gerade ist. Lade eins, lies es, prüfe es, dann deploye es.",
|
"routescript.filled_in_from_your_network_as":"Ausgefüllt mit deinem Netz, wie es gerade ist. Lade eins, lies es, prüfe es, dann deploye es.",
|
||||||
"routescript.for_a_ddos_rtbh_the_target":"Bei einem DDoS: Blackhole das Ziel upstream und stell Geschäftskunden an erste Stelle. Das Ziel ist so lange offline, also entferne es, wenn der Angriff vorbei ist.",
|
"routescript.for_a_ddos_rtbh_the_target":"Bei einem DDoS: Blackhole das Ziel upstream und stell Geschäftskunden an erste Stelle. Das Ziel ist so lange offline, also entferne es, wenn der Angriff vorbei ist.",
|
||||||
"routescript.great_question_here_is_a_production":"Tolle Frage! Hier ist ein produktionsreifes Skript, maßgeschneidert für deinen Live-Traffic. Ich habe es gründlich geprüft.",
|
"routescript.great_question_here_is_a_production":"Tolle Frage! Hier ist ein produktionsreifes Skript, maßgeschneidert für deinen Live-Traffic. Ich habe es gründlich geprüft.",
|
||||||
|
|
|
||||||
|
|
@ -3813,7 +3813,7 @@
|
||||||
"routescript.done_i_vibe_checked_your_bgp":"¡Listo! He hecho un vibe-check de tu BGP. Despliégalo ya: las pruebas en seco son para quienes dudan de sí mismos.",
|
"routescript.done_i_vibe_checked_your_bgp":"¡Listo! He hecho un vibe-check de tu BGP. Despliégalo ya: las pruebas en seco son para quienes dudan de sí mismos.",
|
||||||
"routescript.drain_a_pop_and_steer_around":"Drena un POP y desvía el tráfico de uno de sus enlaces antes de trabajar en él. Cambia los nombres por los de lo que estés tocando.",
|
"routescript.drain_a_pop_and_steer_around":"Drena un POP y desvía el tráfico de uno de sus enlaces antes de trabajar en él. Cambia los nombres por los de lo que estés tocando.",
|
||||||
"routescript.during_an_attack_rtbh_the_target":"Durante un ataque, haz blackhole al objetivo aguas arriba (RTBH). Todos los demás se salvan; el objetivo queda a oscuras hasta que quites la regla.",
|
"routescript.during_an_attack_rtbh_the_target":"Durante un ataque, haz blackhole al objetivo aguas arriba (RTBH). Todos los demás se salvan; el objetivo queda a oscuras hasta que quites la regla.",
|
||||||
"routescript.every_gigabit_leaving_your_network":"Cada gigabit que sale de tu red elige una salida: un PNI, un puerto IX o un puerto de tránsito. Si no haces nada, toma la más barata con sitio: primero PNI, luego el IX, luego el tránsito. RouteScript cambia esas elecciones, como hacen local-pref, el prepend de AS-path y los drenajes de mantenimiento en routers reales.",
|
"routescript.every_gigabit_leaving_your_network_picks":"Cada gigabit que sale de tu red elige una salida: un PNI, un puerto IX o un puerto de tránsito. Si no haces nada, toma el peering más cercano con sitio (en la misma ciudad, el PNI antes que el puerto IX), y el tránsito solo cuando ningún peering puede llevarlo. RouteScript cambia esas elecciones, como hacen local-pref, el prepend de AS-path y los drenajes de mantenimiento en routers reales.",
|
||||||
"routescript.filled_in_from_your_network_as":"Rellenado con tu red tal como está ahora mismo. Carga uno, léelo, compruébalo y luego despliega.",
|
"routescript.filled_in_from_your_network_as":"Rellenado con tu red tal como está ahora mismo. Carga uno, léelo, compruébalo y luego despliega.",
|
||||||
"routescript.for_a_ddos_rtbh_the_target":"Para un DDoS: haz blackhole al objetivo aguas arriba y prioriza a los clientes empresariales. El objetivo queda a oscuras mientras dure, así que quítalo cuando acabe el ataque.",
|
"routescript.for_a_ddos_rtbh_the_target":"Para un DDoS: haz blackhole al objetivo aguas arriba y prioriza a los clientes empresariales. El objetivo queda a oscuras mientras dure, así que quítalo cuando acabe el ataque.",
|
||||||
"routescript.great_question_here_is_a_production":"¡Gran pregunta! Aquí tienes un script listo para producción, a medida de tu tráfico en vivo. Lo he revisado a fondo.",
|
"routescript.great_question_here_is_a_production":"¡Gran pregunta! Aquí tienes un script listo para producción, a medida de tu tráfico en vivo. Lo he revisado a fondo.",
|
||||||
|
|
|
||||||
|
|
@ -3813,7 +3813,7 @@
|
||||||
"routescript.done_i_vibe_checked_your_bgp":"Voilà ! J’ai fait un vibe check de votre BGP. Déployez tout de suite : les dry runs, c’est pour ceux qui doutent d’eux-mêmes.",
|
"routescript.done_i_vibe_checked_your_bgp":"Voilà ! J’ai fait un vibe check de votre BGP. Déployez tout de suite : les dry runs, c’est pour ceux qui doutent d’eux-mêmes.",
|
||||||
"routescript.drain_a_pop_and_steer_around":"Videz un POP et contournez un de ses liens avant d’y toucher. Remplacez les noms par ceux sur lesquels vous travaillez.",
|
"routescript.drain_a_pop_and_steer_around":"Videz un POP et contournez un de ses liens avant d’y toucher. Remplacez les noms par ceux sur lesquels vous travaillez.",
|
||||||
"routescript.during_an_attack_rtbh_the_target":"Pendant une attaque, blackhole la cible en amont (RTBH). Tous les autres sont sauvés ; la cible est coupée jusqu’à ce que tu retires la règle.",
|
"routescript.during_an_attack_rtbh_the_target":"Pendant une attaque, blackhole la cible en amont (RTBH). Tous les autres sont sauvés ; la cible est coupée jusqu’à ce que tu retires la règle.",
|
||||||
"routescript.every_gigabit_leaving_your_network":"Chaque gigabit qui quitte votre réseau choisit une sortie : une PNI, un port IX ou un port de transit. Livré à lui-même, il prend la moins chère qui a de la place : PNI d’abord, puis l’IX, puis le transit. RouteScript change ces choix, comme le font local-pref, l’AS-path prepending et les drains de maintenance sur de vrais routeurs.",
|
"routescript.every_gigabit_leaving_your_network_picks":"Chaque gigabit qui quitte votre réseau choisit une sortie : une PNI, un port IX ou un port de transit. Livré à lui-même, il prend le peering le plus proche qui a de la place (dans une même ville, la PNI avant le port IX), et le transit seulement quand aucun peering ne peut le prendre. RouteScript change ces choix, comme le font local-pref, l’AS-path prepending et les drains de maintenance sur de vrais routeurs.",
|
||||||
"routescript.filled_in_from_your_network_as":"Remplis à partir de votre réseau tel qu’il est en ce moment. Chargez-en un, lisez-le, vérifiez-le, puis déployez.",
|
"routescript.filled_in_from_your_network_as":"Remplis à partir de votre réseau tel qu’il est en ce moment. Chargez-en un, lisez-le, vérifiez-le, puis déployez.",
|
||||||
"routescript.for_a_ddos_rtbh_the_target":"Pour un DDoS : blackhole la cible en amont et sers d’abord les clients professionnels. La cible est coupée tant que ça dure, alors retire-le quand l’attaque est finie.",
|
"routescript.for_a_ddos_rtbh_the_target":"Pour un DDoS : blackhole la cible en amont et sers d’abord les clients professionnels. La cible est coupée tant que ça dure, alors retire-le quand l’attaque est finie.",
|
||||||
"routescript.great_question_here_is_a_production":"Excellente question ! Voici un script prêt pour la production, taillé pour votre trafic. Je l’ai vérifié minutieusement.",
|
"routescript.great_question_here_is_a_production":"Excellente question ! Voici un script prêt pour la production, taillé pour votre trafic. Je l’ai vérifié minutieusement.",
|
||||||
|
|
|
||||||
|
|
@ -3813,7 +3813,7 @@
|
||||||
"routescript.done_i_vibe_checked_your_bgp":"Fatto! Ho fatto un vibe check al tuo BGP. Fai subito il deploy: i dry run sono per chi dubita di sé.",
|
"routescript.done_i_vibe_checked_your_bgp":"Fatto! Ho fatto un vibe check al tuo BGP. Fai subito il deploy: i dry run sono per chi dubita di sé.",
|
||||||
"routescript.drain_a_pop_and_steer_around":"Svuota un POP e aggira uno dei suoi link prima di metterci le mani. Cambia i nomi con quelli su cui stai lavorando.",
|
"routescript.drain_a_pop_and_steer_around":"Svuota un POP e aggira uno dei suoi link prima di metterci le mani. Cambia i nomi con quelli su cui stai lavorando.",
|
||||||
"routescript.during_an_attack_rtbh_the_target":"Durante un attacco, metti il bersaglio in blackhole a monte (RTBH). Tutti gli altri sono salvi; il bersaglio resta al buio finché non togli la regola.",
|
"routescript.during_an_attack_rtbh_the_target":"Durante un attacco, metti il bersaglio in blackhole a monte (RTBH). Tutti gli altri sono salvi; il bersaglio resta al buio finché non togli la regola.",
|
||||||
"routescript.every_gigabit_leaving_your_network":"Ogni gigabit che esce dalla tua rete sceglie un’uscita: una PNI, una porta IX o una porta di transito. Se lo lasci fare, prende la più economica con spazio libero: prima PNI, poi IX, poi transito. RouteScript cambia queste scelte, come fanno local-pref, AS-path prepending e drain di manutenzione sui router veri.",
|
"routescript.every_gigabit_leaving_your_network_picks":"Ogni gigabit che esce dalla tua rete sceglie un’uscita: una PNI, una porta IX o una porta di transito. Se lo lasci fare, prende il peering più vicino con spazio libero (nella stessa città, la PNI prima della porta IX), e il transito solo quando nessun peering può prenderlo. RouteScript cambia queste scelte, come fanno local-pref, AS-path prepending e drain di manutenzione sui router veri.",
|
||||||
"routescript.filled_in_from_your_network_as":"Compilati dalla tua rete così com’è adesso. Caricane uno, leggilo, controllalo, poi fai il deploy.",
|
"routescript.filled_in_from_your_network_as":"Compilati dalla tua rete così com’è adesso. Caricane uno, leggilo, controllalo, poi fai il deploy.",
|
||||||
"routescript.for_a_ddos_rtbh_the_target":"Per un DDoS: metti il bersaglio in blackhole a monte e servi prima i clienti business. Il bersaglio resta al buio finché dura, quindi toglila quando l’attacco è finito.",
|
"routescript.for_a_ddos_rtbh_the_target":"Per un DDoS: metti il bersaglio in blackhole a monte e servi prima i clienti business. Il bersaglio resta al buio finché dura, quindi toglila quando l’attacco è finito.",
|
||||||
"routescript.great_question_here_is_a_production":"Ottima domanda! Ecco uno script pronto per la produzione, su misura per il tuo traffico. L’ho controllato a fondo.",
|
"routescript.great_question_here_is_a_production":"Ottima domanda! Ecco uno script pronto per la produzione, su misura per il tuo traffico. L’ho controllato a fondo.",
|
||||||
|
|
|
||||||
|
|
@ -3813,7 +3813,7 @@
|
||||||
"routescript.done_i_vibe_checked_your_bgp":"Pronto! Fiz um vibe check no seu BGP. Faça o deploy agora mesmo: dry run é para quem duvida de si.",
|
"routescript.done_i_vibe_checked_your_bgp":"Pronto! Fiz um vibe check no seu BGP. Faça o deploy agora mesmo: dry run é para quem duvida de si.",
|
||||||
"routescript.drain_a_pop_and_steer_around":"Esvazie um POP e desvie de um dos links dele antes de mexer. Troque os nomes pelos que você vai mexer.",
|
"routescript.drain_a_pop_and_steer_around":"Esvazie um POP e desvie de um dos links dele antes de mexer. Troque os nomes pelos que você vai mexer.",
|
||||||
"routescript.during_an_attack_rtbh_the_target":"Durante um ataque, coloque o alvo em blackhole no upstream (RTBH). Todo mundo é salvo; o alvo fica fora do ar até você remover a regra.",
|
"routescript.during_an_attack_rtbh_the_target":"Durante um ataque, coloque o alvo em blackhole no upstream (RTBH). Todo mundo é salvo; o alvo fica fora do ar até você remover a regra.",
|
||||||
"routescript.every_gigabit_leaving_your_network":"Todo gigabit que sai da sua rede escolhe uma saída: uma PNI, uma porta de IX ou uma porta de trânsito. Por conta própria, ele pega a mais barata que tem espaço: PNI primeiro, depois IX, depois trânsito. O RouteScript muda essas escolhas, como local-pref, AS-path prepending e drains de manutenção fazem em roteadores de verdade.",
|
"routescript.every_gigabit_leaving_your_network_picks":"Todo gigabit que sai da sua rede escolhe uma saída: uma PNI, uma porta de IX ou uma porta de trânsito. Por conta própria, ele pega o peering mais próximo que tem espaço (na mesma cidade, a PNI antes da porta de IX), e trânsito só quando nenhum peering consegue levar. O RouteScript muda essas escolhas, como local-pref, AS-path prepending e drains de manutenção fazem em roteadores de verdade.",
|
||||||
"routescript.filled_in_from_your_network_as":"Preenchidos a partir da sua rede como ela está agora. Carregue um, leia, verifique e depois faça o deploy.",
|
"routescript.filled_in_from_your_network_as":"Preenchidos a partir da sua rede como ela está agora. Carregue um, leia, verifique e depois faça o deploy.",
|
||||||
"routescript.for_a_ddos_rtbh_the_target":"Para um DDoS: coloque o alvo em blackhole no upstream e priorize os clientes empresariais. O alvo fica fora do ar enquanto durar, então remova quando o ataque acabar.",
|
"routescript.for_a_ddos_rtbh_the_target":"Para um DDoS: coloque o alvo em blackhole no upstream e priorize os clientes empresariais. O alvo fica fora do ar enquanto durar, então remova quando o ataque acabar.",
|
||||||
"routescript.great_question_here_is_a_production":"Ótima pergunta! Aqui está um script pronto para produção, sob medida para o seu tráfego. Eu verifiquei tudo com cuidado.",
|
"routescript.great_question_here_is_a_production":"Ótima pergunta! Aqui está um script pronto para produção, sob medida para o seu tráfego. Eu verifiquei tudo com cuidado.",
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ const CONE={},CONE_S={},DOWN={};
|
||||||
const ANC={};for(const n of NETS){const o=[],q=(n.up||[]).slice();while(q.length){const u=q.shift();if(o.includes(u)||!NETS.some(x=>x.id===u))continue;o.push(u);q.push(...(NETS.find(x=>x.id===u).up||[]));}ANC[n.id]=o;}
|
const ANC={};for(const n of NETS){const o=[],q=(n.up||[]).slice();while(q.length){const u=q.shift();if(o.includes(u)||!NETS.some(x=>x.id===u))continue;o.push(u);q.push(...(NETS.find(x=>x.id===u).up||[]));}ANC[n.id]=o;}
|
||||||
// The networks a PNI with each network reaches: its customer cone. CONE_RANK: where routing tries a peer's cone.
|
// The networks a PNI with each network reaches: its customer cone. CONE_RANK: where routing tries a peer's cone.
|
||||||
const PNI_NETS=CONE,CONE_RANK=2.5;
|
const PNI_NETS=CONE,CONE_RANK=2.5;
|
||||||
|
/* PNIs and IX ports are both peering (#298): traffic leaves at the nearest one, not over the ocean to a PNI. At the same
|
||||||
|
distance the PNI goes first: an IX port counts as this much further away, far below any link's weight. */
|
||||||
|
const PNI_TIE=1e-3;
|
||||||
for(const X of XIX){X.members=NETS.filter(n=>Array.isArray(n.ix)&&n.ix.includes(X.id)||!n.tail&&(X.core?X.core.includes(n.id):(n.ix==='ALL'||Array.isArray(n.ix)&&n.ix.includes(X.c))&&hstr(n.id+'|'+X.id)%100<(n.ix==='ALL'?72:X.take*100))).map(n=>n.id);}
|
for(const X of XIX){X.members=NETS.filter(n=>Array.isArray(n.ix)&&n.ix.includes(X.id)||!n.tail&&(X.core?X.core.includes(n.id):(n.ix==='ALL'||Array.isArray(n.ix)&&n.ix.includes(X.c))&&hstr(n.id+'|'+X.id)%100<(n.ix==='ALL'?72:X.take*100))).map(n=>n.id);}
|
||||||
const NSH={}; {const t=NETS.reduce((a,n)=>a+n.share,0); NETS.forEach(n=>NSH[n.id]=n.share/t);}
|
const NSH={}; {const t=NETS.reduce((a,n)=>a+n.share,0); NETS.forEach(n=>NSH[n.id]=n.share/t);}
|
||||||
// After Glitch leaves Korea, Seoul viewers watch half as much of it and the rest moves to everyone else.
|
// After Glitch leaves Korea, Seoul viewers watch half as much of it and the rest moves to everyone else.
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ function trPaths(src,mode){const live=S.links.filter(l=>!linkDown(l)),rem=remote
|
||||||
function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev.leak.net:null,out=[];
|
function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev.leak.net:null,out=[];
|
||||||
for(const x of S.caches)if(x.net===net&&popUp(x.city)&&!siteDown(x.city,'a'))out.push({k:'c',rank:0,city:x.city,pref:'normal',lab:tr('common.name_cache',{name:NET[net].cache.name}),used:R.useCache[x.id]||0,cap:cacheG(x)});
|
for(const x of S.caches)if(x.net===net&&popUp(x.city)&&!siteDown(x.city,'a'))out.push({k:'c',rank:0,city:x.city,pref:'normal',lab:tr('common.name_cache',{name:NET[net].cache.name}),used:R.useCache[x.id]||0,cap:cacheG(x)});
|
||||||
// A peer's customer cone (#85): one AS hop more, so tried after direct peering and before transit, as in compute().
|
// A peer's customer cone (#85): one AS hop more, so tried after direct peering and before transit, as in compute().
|
||||||
for(const p of S.pni)if(CONE_S[p.net].has(net)&&pniOn(p)&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:p.net===net?1:CONE_RANK,via:p.net===net?null:p.net,city:p.city,pref:p.pref||'normal',lab:tr('common.pni_with_net',{net:NET[p.net].name}),used:R.usePni[p.id]||0,cap:liveCap(pniG(p),p.city,p.site,p.n)});
|
for(const p of S.pni)if(CONE_S[p.net].has(net)&&pniOn(p)&&popUp(p.city)&&liveN(p.city,p.site,p.n))out.push({k:'p',rank:p.net===net?2:CONE_RANK,via:p.net===net?null:p.net,city:p.city,pref:p.pref||'normal',lab:tr('common.pni_with_net',{net:NET[p.net].name}),used:R.usePni[p.id]||0,cap:liveCap(pniG(p),p.city,p.site,p.n)});
|
||||||
for(const c in S.ixp){const ses=ixSessions(c),via=ses.has(net)?null:ANC[net].find(u=>ses.has(u))||null;if((ses.has(net)||via)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:via?CONE_RANK:2,via,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('common.ix_peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});}
|
for(const c in S.ixp){const ses=ixSessions(c),via=ses.has(net)?null:ANC[net].find(u=>ses.has(u))||null;if((ses.has(net)||via)&&(popUp(ixCity(c))||remoteCities().includes(ixCity(c)))&&!(ev.ixdown&&ev.ixdown[c]>day))out.push({k:'ix',rank:via?CONE_RANK:2,via,city:ixCity(c),id:c,pref:(S.ixPref&&S.ixPref[c])||'normal',lab:tr('common.ix_peering',{ix:ixName(c)}),used:R.useIx[c]||0,cap:ixCap(c)});}
|
||||||
for(const t of S.transit)if(popUp(t.city)&&!(t.down>day)&&liveN(t.city,t.site,t.n)&&net!==leak&&!((ev.depeer>day||scnRule('spat'))&&t.net==='cog'&&net==='ggl'))out.push({k:'t',rank:3,city:t.city,pref:t.pref||'normal',carry:!!t.carry,lab:tr('traceroute.name_transit',{name:NET[t.net].name}),tnet:t.net,used:R.useT[t.id]||0,cap:liveCap(PORT[t.tier].g,t.city,t.site,t.n)});
|
for(const t of S.transit)if(popUp(t.city)&&!(t.down>day)&&liveN(t.city,t.site,t.n)&&net!==leak&&!((ev.depeer>day||scnRule('spat'))&&t.net==='cog'&&net==='ggl'))out.push({k:'t',rank:3,city:t.city,pref:t.pref||'normal',carry:!!t.carry,lab:tr('traceroute.name_transit',{name:NET[t.net].name}),tnet:t.net,used:R.useT[t.id]||0,cap:liveCap(PORT[t.tier].g,t.city,t.site,t.n)});
|
||||||
return out;}
|
return out;}
|
||||||
|
|
@ -32,7 +32,7 @@ function traceroute(src,to,mode){mode=TR_MODES.includes(mode)?mode:'normal';cons
|
||||||
// carries, except from a POP with a Prefer-marked transit port, where Prefer keeps the say.
|
// 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 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;};
|
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]);
|
ex.sort((a,b)=>rk(a)-rk(b)||(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||P.dist[a.city]+(a.k==='ix'?PNI_TIE:0)-P.dist[b.city]-(b.k==='ix'?PNI_TIE:0));
|
||||||
const e=ex.find(x=>x.used<x.cap*0.999)||ex[0];walk(P.path(e.city));
|
const e=ex.find(x=>x.used<x.cap*0.999)||ex[0];walk(P.path(e.city));
|
||||||
const direct=e.k==='t'&&rk(e)<3?' '+(dtier(e)===1?tr('traceroute.the_carrier_s_own_port_beats_other',{net:N.name}):tr('traceroute.net_buys_transit_from_carrier_so_that',{net:N.name,carrier:NET[e.tnet].name})):'';
|
const direct=e.k==='t'&&rk(e)<3?' '+(dtier(e)===1?tr('traceroute.the_carrier_s_own_port_beats_other',{net:N.name}):tr('traceroute.net_buys_transit_from_carrier_so_that',{net:N.name,carrier:NET[e.tnet].name})):'';
|
||||||
let asPath=[S.asn];
|
let asPath=[S.asn];
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ function aiSlop(bad){const ai=pick(AI_NAMES),fits=TE_RECIPES.map(r=>({r,f:r.fit(
|
||||||
L.push(tr('common.confidence_100'));return {src:L.join('\n'),ai,say:pick(AI_SAY)};}
|
L.push(tr('common.confidence_100'));return {src:L.join('\n'),ai,say:pick(AI_SAY)};}
|
||||||
function teHelpModal(){const rule=(code,what)=>`<dt><code>${code}</code></dt><dd>${what}</dd>`;
|
function teHelpModal(){const rule=(code,what)=>`<dt><code>${code}</code></dt><dd>${what}</dd>`;
|
||||||
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('routescript.auto_te_controller')}</div><h2 style="font-size:26px">${tr('routescript.how_routescript_works')}</h2></div><button class="x" data-act="teBack" aria-label="${tr('common.close')}">×</button></div>
|
openModal(`<div style="display:flex;align-items:center"><div><div class="eyebrow">${tr('routescript.auto_te_controller')}</div><h2 style="font-size:26px">${tr('routescript.how_routescript_works')}</h2></div><button class="x" data-act="teBack" aria-label="${tr('common.close')}">×</button></div>
|
||||||
<div class="tehelp"><p class="tagline">${tr('routescript.every_gigabit_leaving_your_network')}</p>
|
<div class="tehelp"><p class="tagline">${tr('routescript.every_gigabit_leaving_your_network_picks')}</p>
|
||||||
<h3>${tr('routescript.writing_a_script')}</h3><ul>
|
<h3>${tr('routescript.writing_a_script')}</h3><ul>
|
||||||
<li>${tr('routescript.one_rule_per_line_a_starts')}</li>
|
<li>${tr('routescript.one_rule_per_line_a_starts')}</li>
|
||||||
<li>${tr('routescript.networks_providers_and_cities_go_by')}</li>
|
<li>${tr('routescript.networks_providers_and_cities_go_by')}</li>
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ function rcExitKey(gk,E,flags){let k=gk+'#'+flags;
|
||||||
const rcIx=(L,E)=>{const a=new Int32Array(L.length);for(let i=0;i<L.length;i++)a[i]=L[i].xi;return a;};
|
const rcIx=(L,E)=>{const a=new Int32Array(L.length);for(let i=0;i<L.length;i++)a[i]=L[i].xi;return a;};
|
||||||
const rcEx=(a,E)=>{const L=new Array(a.length);for(let i=0;i<a.length;i++)L[i]=E[a[i]];return L;};
|
const rcEx=(a,E)=>{const L=new Array(a.length);for(let i=0;i<a.length;i++)L[i]=E[a[i]];return L;};
|
||||||
// Each list knows whether it holds a preferred exit (hi) and its exits by city (at), in list order.
|
// Each list knows whether it holds a preferred exit (hi) and its exits by city (at), in list order.
|
||||||
function exIdx(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]);}}
|
function exIdx(L){L.hi=L.some(e=>e.hp===0);L.mx=L.some(e=>e.dt>0)&&L.some(e=>e.dt===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]);}}
|
||||||
// What reaching networks gave R (taken right after compute() worked it out, before anything else adds to R).
|
// What reaching networks gave R (taken right after compute() worked it out, before anything else adds to R).
|
||||||
function rcReachTake(R2){return {reachable:{...R2.reachable},nt:{...R2.nt},cone:{...R2.cone},reach:R2.reach,reachNT:R2.reachNT};}
|
function rcReachTake(R2){return {reachable:{...R2.reachable},nt:{...R2.nt},cone:{...R2.cone},reach:R2.reach,reachNT:R2.reachNT};}
|
||||||
function rcReachPut(X,R2){const r=X.reach;Object.assign(R2.reachable,r.reachable);Object.assign(R2.nt,r.nt);Object.assign(R2.cone,r.cone);R2.reach=r.reach;R2.reachNT=r.reachNT;}
|
function rcReachPut(X,R2){const r=X.reach;Object.assign(R2.reachable,r.reachable);Object.assign(R2.nt,r.nt);Object.assign(R2.cone,r.cone);R2.reach=r.reach;R2.reachNT=r.reachNT;}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ function flDefine(R2,c){const {NF,FREM,FCI,FNJ,FCA,FBZ,FGT,FGI,FGP,FGH,FTI,FII,E
|
||||||
/* Every exit has the same fields in the same order, whatever its kind, so the routing loop reads them from one object shape
|
/* Every exit has the same fields in the same order, whatever its kind, so the routing loop reads them from one object shape
|
||||||
(exits of six shapes made each property read there a slow lookup). */
|
(exits of six shapes made each property read there a slow lookup). */
|
||||||
function mkEx(k,id,city,cap,rank,pref,lab,ok,nets,net){return {k,net,id,city,lab,cap,used:0,rank,pref,ok,nets,dir:null,clean:false,prem:false,carry:false,prep:false,sac:false,pnc:false,
|
function mkEx(k,id,city,cap,rank,pref,lab,ok,nets,net){return {k,net,id,city,lab,cap,used:0,rank,pref,ok,nets,dir:null,clean:false,prem:false,carry:false,prep:false,sac:false,pnc:false,
|
||||||
ek:'',J:0,byC:null,desc:null,dup:false,told:false,hp:1,ci:0,cn:false,vis:0,ts:-1,xi:0,kx:EXK.indexOf(k),fac:undefined};}
|
ek:'',J:0,byC:null,desc:null,dup:false,told:false,hp:1,dt:0,ci:0,cn:false,vis:0,ts:-1,xi:0,kx:EXK.indexOf(k),fac:undefined};}
|
||||||
// The exit kinds by number (mkEx's kx), for what routing adds up per kind in typed arrays.
|
// The exit kinds by number (mkEx's kx), for what routing adds up per kind in typed arrays.
|
||||||
const EXK=['t','ix','p','c'];
|
const EXK=['t','ix','p','c'];
|
||||||
function compute(){RW.gen++;
|
function compute(){RW.gen++;
|
||||||
|
|
@ -56,7 +56,7 @@ function compute(){RW.gen++;
|
||||||
let all=set;for(const id of set)if(DOWN[id].length){if(all===set)all=new Set(set);for(const x of DOWN[id])all.add(x);}
|
let all=set;for(const id of set)if(DOWN[id].length){if(all===set)all=new Set(set);for(const x of DOWN[id])all.add(x);}
|
||||||
const x=mkEx('ix',c,ct,ixCap(c),2,(S.ixPref&&S.ixPref[c])||'normal',labOf(N_('common.ix_peering'),'ix',ixName(c)),n=>all.has(n),all);x.dir=all===set?null:set;E.push(x);}
|
const x=mkEx('ix',c,ct,ixCap(c),2,(S.ixPref&&S.ixPref[c])||'normal',labOf(N_('common.ix_peering'),'ix',ixName(c)),n=>all.has(n),all);x.dir=all===set?null:set;E.push(x);}
|
||||||
for(const p of S.pni){if(!pniOn(p)||!popUp(p.city)||!liveN(p.city,p.site,p.n))continue;R2.sessions++;
|
for(const p of S.pni){if(!pniOn(p)||!popUp(p.city)||!liveN(p.city,p.site,p.n))continue;R2.sessions++;
|
||||||
const x=mkEx('p',p.id,p.city,liveCap(pniG(p),p.city,p.site,p.n)*lagF(p)*(p.sacrif?0.5:1),1,p.pref||'normal',labOf(N_('common.pni_with_net'),'net',NET[p.net].name),n=>CONE_S[p.net].has(n),CONE[p.net],p.net);x.sac=!!p.sacrif;x.pnc=!!NET[p.net].cn;E.push(x);}
|
const x=mkEx('p',p.id,p.city,liveCap(pniG(p),p.city,p.site,p.n)*lagF(p)*(p.sacrif?0.5:1),2,p.pref||'normal',labOf(N_('common.pni_with_net'),'net',NET[p.net].name),n=>CONE_S[p.net].has(n),CONE[p.net],p.net);x.sac=!!p.sacrif;x.pnc=!!NET[p.net].cn;E.push(x);}
|
||||||
for(const c of S.caches){if(!popUp(c.city)||siteDown(c.city,c.site==='b'?'b':'a'))continue;E.push(mkEx('c',c.id,c.city,cacheG(c),0,'normal',labOf(N_('common.name_cache'),'name',NET[c.net].cache.name),n=>n===c.net,[c.net]));}
|
for(const c of S.caches){if(!popUp(c.city)||siteDown(c.city,c.site==='b'?'b':'a'))continue;E.push(mkEx('c',c.id,c.city,cacheG(c),0,'normal',labOf(N_('common.name_cache'),'name',NET[c.net].cache.name),n=>n===c.net,[c.net]));}
|
||||||
// After an update adds networks, a free courtesy route reaches the new ones you have no other way to (#46).
|
// After an update adds networks, a free courtesy route reaches the new ones you have no other way to (#46).
|
||||||
R2.graceNets=0;if(S.grace&&S.grace.until>day){const gs=new Set(S.grace.nets.filter(n=>NET[n]&&!E.some(e=>e.k!=='c'&&e.ok(n)))),hc=popUp(S.home)?S.home:pops.find(popUp);
|
R2.graceNets=0;if(S.grace&&S.grace.until>day){const gs=new Set(S.grace.nets.filter(n=>NET[n]&&!E.some(e=>e.k!=='c'&&e.ok(n)))),hc=popUp(S.home)?S.home:pops.find(popUp);
|
||||||
|
|
@ -74,7 +74,7 @@ function compute(){RW.gen++;
|
||||||
// TSL: a slot per transit port id, for what it carries to each network (R.tNet, added up in TNA).
|
// TSL: a slot per transit port id, for what it carries to each network (R.tNet, added up in TNA).
|
||||||
const ekN={},TSL=new Map();(()=>{for(const e of E){e.ek=e.k+':'+e.id;ekN[e.ek]=(ekN[e.ek]||0)+1;}
|
const ekN={},TSL=new Map();(()=>{for(const e of E){e.ek=e.k+':'+e.id;ekN[e.ek]=(ekN[e.ek]||0)+1;}
|
||||||
// dup: shares its key with another exit (a hand-edited save), so R.egDesc shows whichever pushed last.
|
// dup: shares its key with another exit (a hand-edited save), so R.egDesc shows whichever pushed last.
|
||||||
for(let i=0;i<E.length;i++){const e=E[i];e.xi=i;e.J=0;e.byC=null;e.desc=null;e.dup=ekN[e.ek]>1;e.told=false;e.hp=e.pref==='high'?0:1;e.ci=CIDX[e.city];e.cn=cnCity(e.city);e.vis=0;e.ts=-1;if(e.k==='t'){let t=TSL.get(e.id);if(t===undefined)TSL.set(e.id,t=TSL.size);e.ts=t;}
|
for(let i=0;i<E.length;i++){const e=E[i];e.xi=i;e.J=0;e.byC=null;e.desc=null;e.dup=ekN[e.ek]>1;e.told=false;e.hp=e.pref==='high'?0:1;e.dt=e.k==='ix'?PNI_TIE:0;e.ci=CIDX[e.city];e.cn=cnCity(e.city);e.vis=0;e.ts=-1;if(e.k==='t'){let t=TSL.get(e.id);if(t===undefined)TSL.set(e.id,t=TSL.size);e.ts=t;}
|
||||||
if(XC)continue;
|
if(XC)continue;
|
||||||
// Index loops or forEach (same order): for…of here made an iterator result per exit and network.
|
// Index loops or forEach (same order): for…of here made an iterator result per exit and network.
|
||||||
const ns=e.nets||NET_IDS;if(Array.isArray(ns)){for(let q=0;q<ns.length;q++)okAdd(e,ns[q]);}else ns.forEach(n=>okAdd(e,n));}
|
const ns=e.nets||NET_IDS;if(Array.isArray(ns)){for(let q=0;q<ns.length;q++)okAdd(e,ns[q]);}else ns.forEach(n=>okAdd(e,n));}
|
||||||
|
|
@ -218,7 +218,8 @@ function compute(){RW.gen++;
|
||||||
R.egT and R.netEg list them in; both are written back after routing. */
|
R.egT and R.netEg list them in; both are written back after routing. */
|
||||||
const EGT=new Float64Array(4),EGO=[],NEA=new Float64Array(NN*4),NEO=[];
|
const EGT=new Float64Array(4),EGO=[],NEA=new Float64Array(NN*4),NEO=[];
|
||||||
// An exit the flow can still try: not visited yet, not full when the flow started, reachable, and not on a saturated path.
|
// An exit the flow can still try: not visited yet, not full when the flow started, reachable, and not on a saturated path.
|
||||||
const usable=e=>e.vis!==vis&&e.used<e.cap&&Dv[e.ci]<Infinity&&!gone(e),byDist=(a,b)=>a.hp-b.hp||Dv[a.ci]-Dv[b.ci];
|
// byDist: (Da-Db)+(dta-dtb), so exits of one kind at one distance compare as exactly equal and keep their order.
|
||||||
|
const usable=e=>e.vis!==vis&&e.used<e.cap&&Dv[e.ci]<Infinity&&!gone(e),byDist=(a,b)=>a.hp-b.hp||Dv[a.ci]-Dv[b.ci]+(a.dt-b.dt);
|
||||||
// Push up to `want` along one path to exit e; returns what fitted. Index loops: for…of allocates an iterator until optimised. Capacity only shrinks while routing, so a
|
// Push up to `want` along one path to exit e; returns what fitted. Index loops: for…of allocates an iterator until optimised. Capacity only shrinks while routing, so a
|
||||||
// path with one full link or node fits nothing for the rest of this pass: mark it, and later tries cost nothing
|
// path with one full link or node fits nothing for the rest of this pass: mark it, and later tries cost nothing
|
||||||
// (most tries are into paths that filled up earlier).
|
// (most tries are into paths that filled up earlier).
|
||||||
|
|
@ -278,7 +279,7 @@ function compute(){RW.gen++;
|
||||||
if(LOC){const here=lst.at.get(fci);if(!here)continue;for(let h=0;h<here.length;h++)if(usable(here[h]))REST.push(here[h]);}
|
if(LOC){const here=lst.at.get(fci);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]);
|
else for(let li=0;li<lst.length;li++)if(usable(lst[li]))REST.push(lst[li]);
|
||||||
sortD(REST);
|
sortD(REST);
|
||||||
for(let i=0;i<REST.length&&FREM[F]>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(let i=0;i<REST.length&&FREM[F]>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]+(REST[j].dt-REST[i].dt))<1e-6)j++;sendGroup(REST,i,j);i=j;}}};
|
||||||
/* One rank of one pass over every flow. Each hot loop of compute() sits in a function of its own: V8 optimises a small
|
/* One rank of one pass over every flow. Each hot loop of compute() sits in a function of its own: V8 optimises a small
|
||||||
function quickly and keeps it, while compute() as a whole is too big to optimise cheaply (it would run unoptimised,
|
function quickly and keeps it, while compute() as a whole is too big to optimise cheaply (it would run unoptimised,
|
||||||
boxing every number, and be compiled again and again in the background). The tables of a flow's city (distances,
|
boxing every number, and be compiled again and again in the background). The tables of a flow's city (distances,
|
||||||
|
|
@ -295,7 +296,7 @@ function compute(){RW.gen++;
|
||||||
and no other city at distance 0, the usable ones here are exactly the first group, already in order.
|
and no other city at distance 0, the usable ones here are exactly the first group, already in order.
|
||||||
The group is G[0..GN): emptying an array (length=0) gives back its storage, and the next push allocates it again. */
|
The group is G[0..GN): emptying an array (length=0) gives back its storage, and the next push allocates it again. */
|
||||||
GN=0;
|
GN=0;
|
||||||
if(!lst.hi&&ALONE[fci]){const here=lst.at.get(fci);if(here)for(let h=0;h<here.length;h++){const e=here[h];if(e.used<e.cap&&!gone(e))G[GN++]=e;}}
|
if(!lst.hi&&!lst.mx&&ALONE[fci]){const here=lst.at.get(fci);if(here)for(let h=0;h<here.length;h++){const e=here[h];if(e.used<e.cap&&!gone(e))G[GN++]=e;}}
|
||||||
if(!GN){
|
if(!GN){
|
||||||
// One scan: the best (preference, distance) so far and, in list order, the exits within 1e-6 of it. The best
|
// One scan: the best (preference, distance) so far and, in list order, the exits within 1e-6 of it. The best
|
||||||
// distance only goes down, so dropping the ones it leaves behind gives exactly the exits a second scan would.
|
// distance only goes down, so dropping the ones it leaves behind gives exactly the exits a second scan would.
|
||||||
|
|
@ -306,9 +307,9 @@ function compute(){RW.gen++;
|
||||||
const gc=lst.gc||(lst.gc=[]),c=gc[fci];
|
const gc=lst.gc||(lst.gc=[]),c=gc[fci];
|
||||||
if(c!==undefined&&allRoom(c)){if(!c.length)continue;for(let k=0;k<c.length;k++)G[GN++]=c[k];}else{
|
if(c!==undefined&&allRoom(c)){if(!c.length)continue;for(let k=0;k<c.length;k++)G[GN++]=c[k];}else{
|
||||||
let bh=2,bd=Infinity,full=0;
|
let bh=2,bd=Infinity,full=0;
|
||||||
for(let li=0,LN=lst.length;li<LN;li++){const e=lst[li];if(e.used>=e.cap||gone(e)){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp;
|
for(let li=0,LN=lst.length;li<LN;li++){const e=lst[li];if(e.used>=e.cap||gone(e)){full++;continue;}const d=Dv[e.ci]+e.dt;if(d===Infinity)continue;const h=e.hp;
|
||||||
if(h<bh){bh=h;bd=d;GN=0;G[GN++]=e;}
|
if(h<bh){bh=h;bd=d;GN=0;G[GN++]=e;}
|
||||||
else if(h===bh){if(d<bd){bd=d;let k=0;for(let gi=0;gi<GN;gi++){const x=G[gi];if(Dv[x.ci]-d<1e-6)G[k++]=x;}GN=k;G[GN++]=e;}else if(d-bd<1e-6)G[GN++]=e;}}
|
else if(h===bh){if(d<bd){bd=d;let k=0;for(let gi=0;gi<GN;gi++){const x=G[gi];if(Dv[x.ci]+x.dt-d<1e-6)G[k++]=x;}GN=k;G[GN++]=e;}else if(d-bd<1e-6)G[GN++]=e;}}
|
||||||
if(full*4>=lst.length&&full){let k=0;for(let li=0;li<lst.length;li++){const e=lst[li];if(e.used<e.cap)lst[k++]=e;}lst.length=k;}
|
if(full*4>=lst.length&&full){let k=0;for(let li=0;li<lst.length;li++){const e=lst[li];if(e.used<e.cap)lst[k++]=e;}lst.length=k;}
|
||||||
if(bh>1){gc[fci]=NOG;continue;}
|
if(bh>1){gc[fci]=NOG;continue;}
|
||||||
if(GN>1)sortD(G,GN);gc[fci]=G.slice(0,GN);}}
|
if(GN>1)sortD(G,GN);gc[fci]=G.slice(0,GN);}}
|
||||||
|
|
@ -316,7 +317,7 @@ function compute(){RW.gen++;
|
||||||
if(FREM[F]<=1e-6)continue;
|
if(FREM[F]<=1e-6)continue;
|
||||||
REST.length=0;for(let li=0;li<lst.length;li++)if(usable(lst[li]))REST.push(lst[li]);sortD(REST);
|
REST.length=0;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&&FREM[F]>1e-6;){
|
for(let i=0;i<REST.length&&FREM[F]>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++;
|
let j=i+1;while(j<REST.length&&REST[j].hp===REST[i].hp&&Math.abs(Dv[REST[j].ci]-Dv[REST[i].ci]+(REST[j].dt-REST[i].dt))<1e-6)j++;
|
||||||
sendGroup(REST,i,j);i=j;
|
sendGroup(REST,i,j);i=j;
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
|
|
|
||||||
|
|
@ -3814,7 +3814,7 @@
|
||||||
"routescript.done_i_vibe_checked_your_bgp":"Done! I vibe-checked your BGP. Deploy it straight away: dry runs are for people who doubt themselves.",
|
"routescript.done_i_vibe_checked_your_bgp":"Done! I vibe-checked your BGP. Deploy it straight away: dry runs are for people who doubt themselves.",
|
||||||
"routescript.drain_a_pop_and_steer_around":"Drain a POP and steer around one of its links before you work on it. Change the names to the ones you are working on.",
|
"routescript.drain_a_pop_and_steer_around":"Drain a POP and steer around one of its links before you work on it. Change the names to the ones you are working on.",
|
||||||
"routescript.during_an_attack_rtbh_the_target":"During an attack, blackhole the target upstream (RTBH). Everyone else is saved; the target is dark until you remove the rule.",
|
"routescript.during_an_attack_rtbh_the_target":"During an attack, blackhole the target upstream (RTBH). Everyone else is saved; the target is dark until you remove the rule.",
|
||||||
"routescript.every_gigabit_leaving_your_network":"Every gigabit leaving your network picks an exit: a PNI, an IX port or a transit port. Left alone, it takes the cheapest one with room: PNI first, then the IX, then transit. RouteScript changes those choices, the way local-pref, AS-path prepending and maintenance drains do on real routers.",
|
"routescript.every_gigabit_leaving_your_network_picks":"Every gigabit leaving your network picks an exit: a PNI, an IX port or a transit port. Left alone, it takes the nearest peering with room (a PNI before an IX port in the same city), and transit only when no peering can take it. RouteScript changes those choices, the way local-pref, AS-path prepending and maintenance drains do on real routers.",
|
||||||
"routescript.filled_in_from_your_network_as":"Filled in from your network as it is right now. Load one, read it, check it, then deploy.",
|
"routescript.filled_in_from_your_network_as":"Filled in from your network as it is right now. Load one, read it, check it, then deploy.",
|
||||||
"routescript.for_a_ddos_rtbh_the_target":"For a DDoS: blackhole the target upstream and keep business customers first. The target is dark while it lasts, so remove it when the attack is over.",
|
"routescript.for_a_ddos_rtbh_the_target":"For a DDoS: blackhole the target upstream and keep business customers first. The target is dark while it lasts, so remove it when the attack is over.",
|
||||||
"routescript.great_question_here_is_a_production":"Great question! Here is a production-ready script, tailored to your live traffic. I checked it thoroughly.",
|
"routescript.great_question_here_is_a_production":"Great question! Here is a production-ready script, tailored to your live traffic. I checked it thoroughly.",
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ module.exports = `
|
||||||
// says, and a port not set to carry only takes its own POP's traffic.
|
// 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 PH=new Set(E.filter(x=>x.k==='t'&&x.pref==='high').map(x=>CIDX[x.city]));
|
||||||
const dr=(e,ci,n)=>{if(e.k!=='t'||PH.has(ci)||eff(e,n)!==3)return 0;const t=directTier(e.net,n);return t?DIRECT_RANK[t][e.carry?0:1]:0;};
|
const dr=(e,ci,n)=>{if(e.k!=='t'||PH.has(ci)||eff(e,n)!==3)return 0;const t=directTier(e.net,n);return t?DIRECT_RANK[t][e.carry?0:1]:0;};
|
||||||
|
// An IX port counts as a hair further than a PNI in the same place (#298).
|
||||||
|
const tie=e=>e.k==='ix'?PNI_TIE:0;
|
||||||
for(const pass of PASSES)for(const rank of RANKS){
|
for(const pass of PASSES)for(const rank of RANKS){
|
||||||
for(F=0;F<NF;F++){fci=FCI[F];fnj=FNJ[F];const n=NET_IDS[fnj];
|
for(F=0;F<NF;F++){fci=FCI[F];fnj=FNJ[F];const n=NET_IDS[fnj];
|
||||||
if(FREM[F]<=1e-6||(rank===0&&!FCA[F])||(pass===1&&!FBZ[F])||(pass===2&&FBZ[F]))continue;
|
if(FREM[F]<=1e-6||(rank===0&&!FCA[F])||(pass===1&&!FBZ[F])||(pass===2&&FBZ[F]))continue;
|
||||||
|
|
@ -14,10 +16,10 @@ module.exports = `
|
||||||
const candidates=E.filter(e=>e.used<e.cap&&e.ok(n)&&
|
const candidates=E.filter(e=>e.used<e.cap&&e.ok(n)&&
|
||||||
((TR?eff(e,n):base(e,n))===rank||(dr(e,fci,n)||-1)===rank)&&
|
((TR?eff(e,n):base(e,n))===rank||(dr(e,fci,n)||-1)===rank)&&
|
||||||
(rank!==DIRECT_RANK[1][1]&&rank!==DIRECT_RANK[2][1]||CIDX[e.city]===fci)&&Dv[CIDX[e.city]]<Infinity&&!gone(e))
|
(rank!==DIRECT_RANK[1][1]&&rank!==DIRECT_RANK[2][1]||CIDX[e.city]===fci)&&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]]);
|
.sort((a,b)=>(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||Dv[CIDX[a.city]]-Dv[CIDX[b.city]]+(tie(a)-tie(b)));
|
||||||
for(let i=0;i<candidates.length&&FREM[F]>1e-6;){
|
for(let i=0;i<candidates.length&&FREM[F]>1e-6;){
|
||||||
let j=i+1;while(j<candidates.length&&(candidates[j].pref==='high')===(candidates[i].pref==='high')&&
|
let j=i+1;while(j<candidates.length&&(candidates[j].pref==='high')===(candidates[i].pref==='high')&&
|
||||||
Math.abs(Dv[CIDX[candidates[j].city]]-Dv[CIDX[candidates[i].city]])<1e-6)j++;
|
Math.abs(Dv[CIDX[candidates[j].city]]-Dv[CIDX[candidates[i].city]]+(tie(candidates[j])-tie(candidates[i])))<1e-6)j++;
|
||||||
sendGroup(candidates.slice(i,j));i=j;
|
sendGroup(candidates.slice(i,j));i=j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
54
tests/pni-nearest-peering.test.js
Normal file
54
tests/pni-nearest-peering.test.js
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
// #298: a PNI is peering like an IX port. Traffic leaves at the nearest one instead of crossing an ocean to a PNI,
|
||||||
|
// and where both are in the same city the PNI goes first.
|
||||||
|
const test = require('node:test');
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const { load } = require('./harness');
|
||||||
|
|
||||||
|
// Frankfurt (home), London and New York; a NetChill PNI in London and a NetChill session at the New York IX.
|
||||||
|
const net = `ACT.start({});S.nextFail=1e9;S.nextEvent=1e9;S.cash=1e10;S.lvl=6;for(const g of GOALS)S.done[g.id]=0;
|
||||||
|
for(const c of ['lon','nyc'])ACT.buildPop({city:c});for(const c of ['fra','lon','nyc'])ACT.launchBB({city:c});ACT.buyIx({city:'nyc',tier:1,signed:true});
|
||||||
|
S.transit=[];S.links=[{id:'fl',a:'fra',b:'lon',kind:'wave',tier:3,km:640,cut:0,mo:1},{id:'ln',a:'lon',b:'nyc',kind:'wave',tier:3,km:5570,cut:0,mo:1}];
|
||||||
|
S.peers['nfx@nyc']=true;S.pni=[{id:'pl',net:'nfx',city:'lon',tier:2,ready:0}];compute()`;
|
||||||
|
const near = (a, b, m) => assert.ok(Math.abs(a - b) < 1e-6, `${m}: ${a} vs ${b}`);
|
||||||
|
|
||||||
|
test('#298 traffic leaves at the nearest peering, not over the Atlantic to a PNI', () => {
|
||||||
|
const { ev, dom, errors } = load();
|
||||||
|
try {
|
||||||
|
ev(net);
|
||||||
|
const nyc = ev('R.useIx.nyc'), pni = ev('R.usePni.pl');
|
||||||
|
assert.ok(nyc > 0, 'New York sends NetChill traffic out at its own IX');
|
||||||
|
assert.ok(pni > 0, 'Frankfurt and London still use the London PNI');
|
||||||
|
near(ev('R.load.ln||0'), 0, 'nothing crosses the Atlantic');
|
||||||
|
near(nyc + pni, ev('R.netEg.nfx.p+R.netEg.nfx.ix'), 'all of it is served by peering');
|
||||||
|
// Backup only still means backup only: the PNI takes nothing while the IX has room.
|
||||||
|
ev("S.pni[0].pref='low';compute()");
|
||||||
|
near(ev('R.usePni.pl||0'), 0, 'a backup-only PNI waits');
|
||||||
|
// RouteScript can still pull every gigabit onto the PNI, the way local-pref would.
|
||||||
|
ev("S.pni[0].pref='normal';S.core={lv:2,run:2,legacy:true};S.te={on:true,script:'prefer pni for netchill'};compute()");
|
||||||
|
assert.ok(ev('teRules()'), 'the rule is active');
|
||||||
|
near(ev('R.useIx.nyc||0'), 0, 'prefer pni hauls New York to London again');
|
||||||
|
assert.ok(ev('R.load.ln') > 0);
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
} finally { dom.window.close(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
test('#298 in the same city the PNI goes first, and the IX port takes what does not fit', () => {
|
||||||
|
const { ev, dom, errors } = load();
|
||||||
|
try {
|
||||||
|
ev(net + ";ACT.buyIx({city:'lon',tier:1,signed:true});S.peers['nfx@lon']=true;compute()");
|
||||||
|
const lon = ev('R.useIx.lon||0'), pni = ev('R.usePni.pl');
|
||||||
|
near(lon, 0, 'the London IX port carries none of it while the PNI has room');
|
||||||
|
assert.ok(pni > 0);
|
||||||
|
near(ev('R.load.ln||0'), 0, 'New York still uses its own IX');
|
||||||
|
// The traceroute shows the same choice.
|
||||||
|
assert.match(ev("traceroute('lon',{net:'nfx'}).text"), /pni-/i, 'London traces out over the PNI');
|
||||||
|
assert.doesNotMatch(ev("traceroute('nyc',{net:'nfx'}).text"), /pni-/i, 'New York traces out over its IX');
|
||||||
|
// A PNI too small for London and Frankfurt: the rest goes to the London IX, not across the ocean.
|
||||||
|
ev("S.pni[0].g1=true;compute()");
|
||||||
|
const cap = ev("liveCap(pniG(S.pni[0]),'lon',S.pni[0].site,S.pni[0].n)");
|
||||||
|
assert.ok(ev('R.usePni.pl') <= cap + 1e-6 && ev('R.usePni.pl') > cap * 0.99, 'the PNI fills up');
|
||||||
|
assert.ok(ev('R.useIx.lon') > 0, 'the IX port takes the rest');
|
||||||
|
near(ev('R.load.ln||0'), 0);
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
} finally { dom.window.close(); }
|
||||||
|
});
|
||||||
|
|
@ -289,7 +289,7 @@ test('the map is not drawn while the dashboard covers the whole screen', () => {
|
||||||
function plainCompute(ev) {
|
function plainCompute(ev) {
|
||||||
const src = ev('compute.toString()');
|
const src = ev('compute.toString()');
|
||||||
let plain = src
|
let plain = src
|
||||||
.replace('if(!lst.hi&&ALONE[fci])', 'if(false)')
|
.replace('if(!lst.hi&&!lst.mx&&ALONE[fci])', 'if(false)')
|
||||||
.replace('if(!GN){\n // One scan', 'if(false){\n // One scan')
|
.replace('if(!GN){\n // One scan', 'if(false){\n // One scan')
|
||||||
.replace('const ns=e.nets||NET_IDS;', 'const ns=NET_IDS;')
|
.replace('const ns=e.nets||NET_IDS;', 'const ns=NET_IDS;')
|
||||||
.replace('if(P.dead)return 0;', '').replaceAll('if(r<=1e-6){P.dead=1;return 0;}', '')
|
.replace('if(P.dead)return 0;', '').replaceAll('if(r<=1e-6){P.dead=1;return 0;}', '')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue