diff --git a/CHANGELOG.md b/CHANGELOG.md
index f296193..62aedfe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- Opening a link from a list now moves the map to it, zoomed so the whole line fits beside the open panel.
+- 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.
## [2.3.0] — 2026-10-31
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index ee16483..e75d50c 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -118,12 +118,18 @@ never freezes the game.
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),
transit (3). Each exit has a capacity, the networks it can reach (`ok(net)`) and an
- egress preference (`high`, `normal`, `low` = backup only).
+ egress preference (`high`, `normal`, `low` = backup only). A transit port can also be set to
+ carry (`t.carry`): see step 4.
3. Builds flows: for every POP, its demand (eyeballs and customers) split across
destination networks by their traffic share (`NSH`, with regional variants for
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,
- consuming link, router (`nodeCap`) and exit capacity. With Auto-TE, overflow spills
+ 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
+ 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. 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.
diff --git a/site/i18n/de.js b/site/i18n/de.js
index 36c06f4..2d59e64 100644
--- a/site/i18n/de.js
+++ b/site/i18n/de.js
@@ -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 Tier 1!",
"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}",
@@ -2405,12 +2405,14 @@
"link_panels.additional_traffic_lost":"Zusätzlich verlorener Traffic",
"link_panels.an_alternate_path_exists_but_current":"Es gibt einen anderen Weg, aber mit dem jetzigen Routing und der Kapazität kommt weniger Traffic an.",
"link_panels.apply_for_a_license_price_mo_n_days":"Lizenz beantragen {price} + {mo}/Monat · ~{n} Tage",
+"link_panels.at_this_pop_net_s_traffic_always":"In diesem POP nimmt der Verkehr zu {net} immer diesen Port. POPs ohne einen nehmen ihren nächsten Transit-Port.",
"link_panels.back_in_n_days":"Zurück in {n} Tagen.",
"link_panels.behind_the_great_firewall":"Hinter der Großen Firewall",
"link_panels.biggest_fabric_money_can_buy":"Die größte Fabric, die man für Geld kaufen kann.",
"link_panels.biggest_feeder_egress_in_city_set":"Größter Zubringer: {egress} in {city}. Stell ihn auf „Nur Backup“, gib den Kunden einen näheren Ausgang (Peering, einen Cache, lokalen Transit) oder erhöhe die Metrik dieses Links.",
"link_panels.build_a_pop_here_first":"Bau hier zuerst einen POP.",
"link_panels.cancel_the_iru":"IRU kündigen",
+"link_panels.carry_here":"Hierher leiten",
"link_panels.click_to_tear_down":"Klicken zum Abbauen",
"link_panels.collecting_data_check_back_in_a":"Daten werden gesammelt. Schau in ein paar Tagen wieder rein.",
"link_panels.congested_upgrade_it_or_add_a":"Überlastet. Rüste ihn auf oder füg einen parallelen Pfad hinzu.",
@@ -2422,6 +2424,7 @@
"link_panels.de_kicks_personalised_pricing_p_of_3d4f":"Personalisierte DE-KICKS-Preise: {p} % von dem, was ein normaler IX verlangen würde.",
"link_panels.each_channel_is_a_pair_of":"Jeder Kanal ist ein Paar Optiken, eine pro Ende. ZR+-Optiken stecken direkt in deinen Routern. Transponder sitzen in einem Shelf.",
"link_panels.enters_your_network_at":"Kommt in dein Netz bei",
+"link_panels.every_pop_carries_net_s_traffic":"Jeder POP leitet den Verkehr zu {net} durch dein Netz bis zu diesem Port.",
"link_panels.finish_in_1_day_price":"In 1 Tag fertigstellen {price}",
"link_panels.foreign_networks_need_a_local_joint":"Ausländische Netze brauchen ein lokales Joint Venture und eine Betriebslizenz, um hier Infrastruktur zu bauen.",
"link_panels.found_your_own_ix_cost_mo":"Eigenen IX gründen {cost} + {mo}/Monat",
@@ -2455,6 +2458,7 @@
"link_panels.name_is_down_nothing_you_can":"{name} ist down. Da hilft nur Warten, oder ein anderer Pfad.",
"link_panels.name_parallel_link":"Paralleler Link {name}",
"link_panels.name_wave":"{name}-Wave",
+"link_panels.nearest_port":"Nächster Port",
"link_panels.needs_a_pop_in_cities_too":"Braucht auch einen POP in {cities}.",
"link_panels.needs_what":"braucht {what}",
"link_panels.needs_your_own_scrubbing_center":"Braucht ein eigenes Scrubbing-Center (Tab Infra).",
@@ -2519,6 +2523,7 @@
"link_panels.this_is_the_only_link_between":"Das ist der einzige Link zwischen diesen Städten. Füg einen parallelen hinzu oder einen Pfad über eine andere Stadt.",
"link_panels.tier_1_only_a_pni_and":"Tier 1: nur ein PNI, und nur, wenn du groß genug für den Tier-1-Club bist",
"link_panels.totals_for_all_n_links_between":"Summen für alle {n} Links zwischen diesen Städten.",
+"link_panels.traffic_for_net":"Verkehr zu {net}",
"link_panels.unplugged_optics_go_on_the_spares":"Ausgesteckte Optiken kommen ins Ersatzteilregal und werden beim nächsten Mal zuerst verwendet.",
"link_panels.upgrade_fabric_to_name_cost_mo":"Fabric auf {name} upgraden {cost} + {mo}/Monat",
"link_panels.upgrade_to_sys_price":"Upgrade auf {sys} {price}",
@@ -3801,6 +3806,7 @@
"traceroute.ix_peering_beats_transit":"IX-Peering schlägt Transit",
"traceroute.n_network_unreachable":"!N Netz nicht erreichbar",
"traceroute.name_transit":"Transit von {name}",
+"traceroute.net_buys_transit_from_carrier_so_that":"{net} kauft Transit bei {carrier}, daher schlägt dieser Port die anderen Transit-Ports.",
"traceroute.net_carries_it_to_city":"{net} bringt es nach {city}",
"traceroute.net_hands_it_to_its_customer":"{net} übergibt es an seinen Kunden {to}",
"traceroute.net_hands_it_to_to":"{net} übergibt es an {to}",
@@ -3810,6 +3816,7 @@
"traceroute.pnis_beat_ix_peering":"PNIs schlagen IX-Peering",
"traceroute.private_cross_connect":"privater Cross-Connect",
"traceroute.rule_and_closer_exits_win_ties":"{rule}, und bei Gleichstand gewinnt der nähere Ausgang",
+"traceroute.the_carrier_s_own_port_beats_other":"Dieser Port führt direkt zu {net} und schlägt daher die anderen Transit-Ports.",
"traceroute.this_one_is_set_to_mode":"; dieser steht auf {mode}",
"traceroute.transit_is_the_last_resort":"Transit ist der letzte Ausweg",
"tutorial.businesses_pop_up_as_bubbles_on":"Unternehmen tauchen als $-Blasen auf der Karte auf. Öffne Deals und gewinne deinen ersten Kunden.",
diff --git a/site/i18n/es.js b/site/i18n/es.js
index 227fa94..6850479 100644
--- a/site/i18n/es.js
+++ b/site/i18n/es.js
@@ -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 Tier 1!",
"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}",
@@ -2403,12 +2403,14 @@
"link_panels.additional_traffic_lost":"Tráfico perdido adicional",
"link_panels.an_alternate_path_exists_but_current":"Hay un camino alternativo, pero con el routing y la capacidad actuales llega menos tráfico.",
"link_panels.apply_for_a_license_price_mo_n_days":"Solicitar una licencia {price} + {mo}/mes · ~{n} días",
+"link_panels.at_this_pop_net_s_traffic_always":"En este POP, el tráfico de {net} siempre usa este puerto. Los POP que no tienen uno usan su puerto de tránsito más cercano.",
"link_panels.back_in_n_days":"De vuelta en {n} días.",
"link_panels.behind_the_great_firewall":"Tras el Gran Cortafuegos",
"link_panels.biggest_fabric_money_can_buy":"La fabric más grande que el dinero puede comprar.",
"link_panels.biggest_feeder_egress_in_city_set":"Mayor alimentador: {egress} en {city}. Ponlo en «Solo respaldo», dale a los clientes una salida más cercana (peering, una caché, tránsito local) o sube la métrica de este enlace.",
"link_panels.build_a_pop_here_first":"Construye primero un POP aquí.",
"link_panels.cancel_the_iru":"Cancelar la IRU",
+"link_panels.carry_here":"Llevar aquí",
"link_panels.click_to_tear_down":"Haz clic para desmontar",
"link_panels.collecting_data_check_back_in_a":"Recopilando datos. Vuelve en unos días.",
"link_panels.congested_upgrade_it_or_add_a":"Congestionado. Mejóralo o añade una ruta paralela.",
@@ -2420,6 +2422,7 @@
"link_panels.de_kicks_personalised_pricing_p_of_3d4f":"Precio personalizado de DE-KICKS: {p} % de lo que cobraría un IX normal.",
"link_panels.each_channel_is_a_pair_of":"Cada canal es un par de ópticas, una por extremo. Las ópticas ZR+ se enchufan directo a tus routers. Los transpondedores van en un estante.",
"link_panels.enters_your_network_at":"Entra en tu red por",
+"link_panels.every_pop_carries_net_s_traffic":"Cada POP lleva el tráfico de {net} por tu red hasta este puerto.",
"link_panels.finish_in_1_day_price":"Terminar en 1 día {price}",
"link_panels.foreign_networks_need_a_local_joint":"Las redes extranjeras necesitan una empresa conjunta local y una licencia de operación para construir infraestructura aquí.",
"link_panels.found_your_own_ix_cost_mo":"Funda tu propio IX {cost} + {mo}/mes",
@@ -2453,6 +2456,7 @@
"link_panels.name_is_down_nothing_you_can":"{name} está caído. No puedes hacer nada salvo esperar, o tener otra ruta.",
"link_panels.name_parallel_link":"Enlace paralelo {name}",
"link_panels.name_wave":"Onda {name}",
+"link_panels.nearest_port":"Puerto más cercano",
"link_panels.needs_a_pop_in_cities_too":"Necesita también un POP en {cities}.",
"link_panels.needs_what":"necesita {what}",
"link_panels.needs_your_own_scrubbing_center":"Necesita tu propio centro de depuración (pestaña Infra).",
@@ -2517,6 +2521,7 @@
"link_panels.this_is_the_only_link_between":"Este es el único enlace entre estas ciudades. Añade uno paralelo, o una ruta por otra ciudad.",
"link_panels.tier_1_only_a_pni_and":"Tier 1: solo un PNI, y solo cuando seas lo bastante grande para el club de los Tier 1",
"link_panels.totals_for_all_n_links_between":"Totales de los {n} enlaces entre estas ciudades.",
+"link_panels.traffic_for_net":"Tráfico hacia {net}",
"link_panels.unplugged_optics_go_on_the_spares":"Las ópticas desenchufadas van al estante de repuestos y se usan primero la próxima vez.",
"link_panels.upgrade_fabric_to_name_cost_mo":"Mejorar la fabric a {name} {cost} + {mo}/mes",
"link_panels.upgrade_to_sys_price":"Mejorar a {sys} {price}",
@@ -3799,6 +3804,7 @@
"traceroute.ix_peering_beats_transit":"el peering en IX gana al tránsito",
"traceroute.n_network_unreachable":"!N red inalcanzable",
"traceroute.name_transit":"Tránsito de {name}",
+"traceroute.net_buys_transit_from_carrier_so_that":"{net} compra tránsito a {carrier}, así que ese puerto gana a los otros puertos de tránsito.",
"traceroute.net_carries_it_to_city":"{net} lo lleva hasta {city}",
"traceroute.net_hands_it_to_its_customer":"{net} lo entrega a su cliente {to}",
"traceroute.net_hands_it_to_to":"{net} lo entrega a {to}",
@@ -3808,6 +3814,7 @@
"traceroute.pnis_beat_ix_peering":"los PNIs ganan al peering en IX",
"traceroute.private_cross_connect":"interconexión cruzada privada",
"traceroute.rule_and_closer_exits_win_ties":"{rule}, y las salidas más cercanas ganan los empates",
+"traceroute.the_carrier_s_own_port_beats_other":"Este puerto va directo a {net}, así que gana a los otros puertos de tránsito.",
"traceroute.this_one_is_set_to_mode":"; esta está en {mode}",
"traceroute.transit_is_the_last_resort":"el tránsito es el último recurso",
"tutorial.businesses_pop_up_as_bubbles_on":"Las empresas aparecen como burbujas de $ en el mapa. Abre Tratos y firma a tu primer cliente.",
diff --git a/site/i18n/fr.js b/site/i18n/fr.js
index 639b21d..6fdb579 100644
--- a/site/i18n/fr.js
+++ b/site/i18n/fr.js
@@ -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 Tier 1 !",
"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}",
@@ -2403,12 +2403,14 @@
"link_panels.additional_traffic_lost":"Trafic perdu en plus",
"link_panels.an_alternate_path_exists_but_current":"Un autre chemin existe, mais avec le routage et la capacité actuels, moins de trafic arrive.",
"link_panels.apply_for_a_license_price_mo_n_days":"Demander une licence {price} + {mo}/mois · ~{n} jours",
+"link_panels.at_this_pop_net_s_traffic_always":"Dans ce POP, le trafic de {net} passe toujours par ce port. Les POP qui n’en ont pas utilisent leur port de transit le plus proche.",
"link_panels.back_in_n_days":"Retour dans {n} jours.",
"link_panels.behind_the_great_firewall":"Derrière le Grand Pare-feu",
"link_panels.biggest_fabric_money_can_buy":"Le plus gros fabric que l’argent puisse acheter.",
"link_panels.biggest_feeder_egress_in_city_set":"Plus gros contributeur : {egress} à {city}. Passe-le en « Secours seul », donne aux clients une sortie plus proche (peering, cache, transit local) ou augmente la métrique de ce lien.",
"link_panels.build_a_pop_here_first":"Construis d’abord un POP ici.",
"link_panels.cancel_the_iru":"Résilier l’IRU",
+"link_panels.carry_here":"Acheminer ici",
"link_panels.click_to_tear_down":"Clique pour couper la session",
"link_panels.collecting_data_check_back_in_a":"Collecte des données en cours. Repasse dans quelques jours.",
"link_panels.congested_upgrade_it_or_add_a":"Saturé. Augmente sa capacité ou ajoute un chemin parallèle.",
@@ -2420,6 +2422,7 @@
"link_panels.de_kicks_personalised_pricing_p_of_3d4f":"Tarif personnalisé DE-KICKS : {p} % de ce que facturerait un IX normal.",
"link_panels.each_channel_is_a_pair_of":"Chaque canal, c’est une paire d’optiques, une à chaque bout. Les optiques ZR+ se branchent directement dans tes routeurs. Les transpondeurs vivent sur une étagère.",
"link_panels.enters_your_network_at":"Entre dans ton réseau à",
+"link_panels.every_pop_carries_net_s_traffic":"Chaque POP achemine le trafic de {net} à travers ton réseau jusqu’à ce port.",
"link_panels.finish_in_1_day_price":"Terminer en 1 jour {price}",
"link_panels.foreign_networks_need_a_local_joint":"Les réseaux étrangers ont besoin d’une coentreprise locale et d’une licence d’opérateur pour construire ici.",
"link_panels.found_your_own_ix_cost_mo":"Fonder ton propre IX {cost} + {mo}/mois",
@@ -2453,6 +2456,7 @@
"link_panels.name_is_down_nothing_you_can":"{name} est en panne. Rien à faire à part attendre, ou avoir un autre chemin.",
"link_panels.name_parallel_link":"Lien parallèle {name}",
"link_panels.name_wave":"Longueur d’onde {name}",
+"link_panels.nearest_port":"Port le plus proche",
"link_panels.needs_a_pop_in_cities_too":"Il faut aussi un POP à {cities}.",
"link_panels.needs_what":"requiert {what}",
"link_panels.needs_your_own_scrubbing_center":"Il faut ton propre centre de scrubbing (onglet Infra).",
@@ -2517,6 +2521,7 @@
"link_panels.this_is_the_only_link_between":"C’est le seul lien entre ces villes. Ajoutes-en un parallèle, ou un chemin via une autre ville.",
"link_panels.tier_1_only_a_pni_and":"Tier 1 : PNI uniquement, et seulement quand tu seras assez gros pour le club des Tier 1",
"link_panels.totals_for_all_n_links_between":"Totaux des {n} liens entre ces villes.",
+"link_panels.traffic_for_net":"Trafic vers {net}",
"link_panels.unplugged_optics_go_on_the_spares":"Les optiques débranchées vont sur l’étagère de rechange et sont utilisées en premier la fois suivante.",
"link_panels.upgrade_fabric_to_name_cost_mo":"Passer au fabric {name} {cost} + {mo}/mois",
"link_panels.upgrade_to_sys_price":"Passer à {sys} {price}",
@@ -3799,6 +3804,7 @@
"traceroute.ix_peering_beats_transit":"le peering IX bat le transit",
"traceroute.n_network_unreachable":"!N réseau injoignable",
"traceroute.name_transit":"Transit {name}",
+"traceroute.net_buys_transit_from_carrier_so_that":"{net} achète du transit chez {carrier}, donc ce port passe avant les autres ports de transit.",
"traceroute.net_carries_it_to_city":"{net} l’achemine jusqu’à {city}",
"traceroute.net_hands_it_to_its_customer":"{net} le passe à son client {to}",
"traceroute.net_hands_it_to_to":"{net} le passe à {to}",
@@ -3808,6 +3814,7 @@
"traceroute.pnis_beat_ix_peering":"les PNI battent le peering IX",
"traceroute.private_cross_connect":"cross-connect privé",
"traceroute.rule_and_closer_exits_win_ties":"{rule}, et la sortie la plus proche l’emporte en cas d’égalité",
+"traceroute.the_carrier_s_own_port_beats_other":"Ce port mène directement chez {net}, donc il passe avant les autres ports de transit.",
"traceroute.this_one_is_set_to_mode":" ; celle-ci est réglée sur {mode}",
"traceroute.transit_is_the_last_resort":"le transit est le dernier recours",
"tutorial.businesses_pop_up_as_bubbles_on":"Les entreprises apparaissent sous forme de bulles $ sur la carte. Ouvre Offres et signe ton premier client.",
diff --git a/site/i18n/it.js b/site/i18n/it.js
index 783b854..7a6a0cc 100644
--- a/site/i18n/it.js
+++ b/site/i18n/it.js
@@ -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 Tier 1!",
"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}",
@@ -2403,12 +2403,14 @@
"link_panels.additional_traffic_lost":"Ulteriore traffico perso",
"link_panels.an_alternate_path_exists_but_current":"Esiste un percorso alternativo, ma con routing e capacità attuali viene consegnato meno traffico.",
"link_panels.apply_for_a_license_price_mo_n_days":"Richiedi una licenza {price} + {mo}/mese · ~{n} giorni",
+"link_panels.at_this_pop_net_s_traffic_always":"In questo POP il traffico di {net} usa sempre questa porta. I POP che non ne hanno una usano la porta di transit più vicina.",
"link_panels.back_in_n_days":"Torna tra {n} giorni.",
"link_panels.behind_the_great_firewall":"Dietro il Great Firewall",
"link_panels.biggest_fabric_money_can_buy":"Il fabric più grosso che si possa comprare.",
"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":"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.",
@@ -2420,6 +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 instrada il traffico di {net} attraverso la tua rete fino a questa porta.",
"link_panels.finish_in_1_day_price":"Termina in 1 giorno {price}",
"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 {cost} + {mo}/mese",
@@ -2453,6 +2456,7 @@
"link_panels.name_is_down_nothing_you_can":"{name} è giù. Non puoi far altro che aspettare, o avere un altro percorso.",
"link_panels.name_parallel_link":"Link parallelo {name}",
"link_panels.name_wave":"Wave {name}",
+"link_panels.nearest_port":"Porta più vicina",
"link_panels.needs_a_pop_in_cities_too":"Serve un POP anche a {cities}.",
"link_panels.needs_what":"serve {what}",
"link_panels.needs_your_own_scrubbing_center":"Serve il tuo centro di scrubbing (scheda Infra).",
@@ -2517,6 +2521,7 @@
"link_panels.this_is_the_only_link_between":"È l’unico link tra queste città. Aggiungine uno parallelo, o un percorso che passi da un’altra città.",
"link_panels.tier_1_only_a_pni_and":"Tier 1: solo un PNI, e solo quando sarai abbastanza grande per il club dei Tier 1",
"link_panels.totals_for_all_n_links_between":"Totali di tutti i {n} link tra queste città.",
+"link_panels.traffic_for_net":"Traffico per {net}",
"link_panels.unplugged_optics_go_on_the_spares":"Le ottiche scollegate vanno sullo scaffale dei ricambi e la volta dopo si usano per prime.",
"link_panels.upgrade_fabric_to_name_cost_mo":"Passa al fabric {name} {cost} + {mo}/mese",
"link_panels.upgrade_to_sys_price":"Passa a {sys} {price}",
@@ -3799,6 +3804,7 @@
"traceroute.ix_peering_beats_transit":"il peering IX batte il transit",
"traceroute.n_network_unreachable":"!N rete irraggiungibile",
"traceroute.name_transit":"Transit {name}",
+"traceroute.net_buys_transit_from_carrier_so_that":"{net} compra transit da {carrier}, quindi quella porta batte le altre porte di transit.",
"traceroute.net_carries_it_to_city":"{net} lo porta fino a {city}",
"traceroute.net_hands_it_to_its_customer":"{net} lo passa al suo cliente {to}",
"traceroute.net_hands_it_to_to":"{net} lo passa a {to}",
@@ -3808,6 +3814,7 @@
"traceroute.pnis_beat_ix_peering":"i PNI battono il peering IX",
"traceroute.private_cross_connect":"cross-connect privato",
"traceroute.rule_and_closer_exits_win_ties":"{rule}, e a parità vince l’uscita più vicina",
+"traceroute.the_carrier_s_own_port_beats_other":"Questa porta va direttamente a {net}, quindi batte le altre porte di transit.",
"traceroute.this_one_is_set_to_mode":"; questa è impostata su {mode}",
"traceroute.transit_is_the_last_resort":"il transit è l’ultima spiaggia",
"tutorial.businesses_pop_up_as_bubbles_on":"Le aziende spuntano come bolle $ sulla mappa. Apri Offerte e firma il tuo primo cliente.",
diff --git a/site/i18n/pt.js b/site/i18n/pt.js
index db295ed..a4c9e7d 100644
--- a/site/i18n/pt.js
+++ b/site/i18n/pt.js
@@ -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ê é Tier 1!",
"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}",
@@ -2403,12 +2403,14 @@
"link_panels.additional_traffic_lost":"Tráfego perdido a mais",
"link_panels.an_alternate_path_exists_but_current":"Existe um caminho alternativo, mas com o roteamento e a capacidade atuais chega menos tráfego.",
"link_panels.apply_for_a_license_price_mo_n_days":"Pedir licença {price} + {mo}/mês · ~{n} dias",
+"link_panels.at_this_pop_net_s_traffic_always":"Neste POP, o tráfego de {net} sempre usa esta porta. POPs sem uma usam a porta de transit mais próxima.",
"link_panels.back_in_n_days":"Volta em {n} dias.",
"link_panels.behind_the_great_firewall":"Atrás do Great Firewall",
"link_panels.biggest_fabric_money_can_buy":"O maior fabric que o dinheiro pode comprar.",
"link_panels.biggest_feeder_egress_in_city_set":"Maior fonte: {egress} em {city}. Coloque em “Só backup”, dê aos clientes uma saída mais próxima (peering, um cache, transit local) ou aumente a métrica deste link.",
"link_panels.build_a_pop_here_first":"Construa um POP aqui primeiro.",
"link_panels.cancel_the_iru":"Cancelar o IRU",
+"link_panels.carry_here":"Trazer para cá",
"link_panels.click_to_tear_down":"Clique para encerrar",
"link_panels.collecting_data_check_back_in_a":"Coletando dados. Volte em alguns dias.",
"link_panels.congested_upgrade_it_or_add_a":"Congestionado. Faça upgrade ou adicione um caminho paralelo.",
@@ -2420,6 +2422,7 @@
"link_panels.de_kicks_personalised_pricing_p_of_3d4f":"Preço personalizado DE-KICKS: {p}% do que um IX normal cobraria.",
"link_panels.each_channel_is_a_pair_of":"Cada canal é um par de ópticas, uma em cada ponta. Ópticas ZR+ encaixam direto nos seus routers. Transponders ficam numa prateleira.",
"link_panels.enters_your_network_at":"Entra na sua rede em",
+"link_panels.every_pop_carries_net_s_traffic":"Cada POP leva o tráfego de {net} pela sua rede até esta porta.",
"link_panels.finish_in_1_day_price":"Concluir em 1 dia {price}",
"link_panels.foreign_networks_need_a_local_joint":"Redes estrangeiras precisam de uma joint venture local e de uma licença de operação para construir infraestrutura aqui.",
"link_panels.found_your_own_ix_cost_mo":"Fundar seu próprio IX {cost} + {mo}/mês",
@@ -2453,6 +2456,7 @@
"link_panels.name_is_down_nothing_you_can":"{name} caiu. Não há o que fazer além de esperar, ou ter outro caminho.",
"link_panels.name_parallel_link":"Link paralelo {name}",
"link_panels.name_wave":"Wave {name}",
+"link_panels.nearest_port":"Porta mais próxima",
"link_panels.needs_a_pop_in_cities_too":"Requer um POP em {cities} também.",
"link_panels.needs_what":"requer {what}",
"link_panels.needs_your_own_scrubbing_center":"Requer seu próprio centro de scrubbing (aba Infra).",
@@ -2517,6 +2521,7 @@
"link_panels.this_is_the_only_link_between":"É o único link entre essas cidades. Adicione um paralelo, ou um caminho passando por outra cidade.",
"link_panels.tier_1_only_a_pni_and":"Tier 1: só PNI, e só quando você for grande o bastante para o clube dos Tier 1",
"link_panels.totals_for_all_n_links_between":"Totais de todos os {n} links entre essas cidades.",
+"link_panels.traffic_for_net":"Tráfego para {net}",
"link_panels.unplugged_optics_go_on_the_spares":"Ópticos desconectados vão para a prateleira de reservas e são usados primeiro na próxima vez.",
"link_panels.upgrade_fabric_to_name_cost_mo":"Upgrade para fabric {name} {cost} + {mo}/mês",
"link_panels.upgrade_to_sys_price":"Atualizar para {sys} {price}",
@@ -3799,6 +3804,7 @@
"traceroute.ix_peering_beats_transit":"peering no IX vence transit",
"traceroute.n_network_unreachable":"!N rede inalcançável",
"traceroute.name_transit":"Transit {name}",
+"traceroute.net_buys_transit_from_carrier_so_that":"{net} compra transit de {carrier}, então essa porta vence as outras portas de transit.",
"traceroute.net_carries_it_to_city":"{net} leva até {city}",
"traceroute.net_hands_it_to_its_customer":"{net} passa para o seu cliente {to}",
"traceroute.net_hands_it_to_to":"{net} passa para {to}",
@@ -3808,6 +3814,7 @@
"traceroute.pnis_beat_ix_peering":"PNIs vencem peering no IX",
"traceroute.private_cross_connect":"cross-connect privado",
"traceroute.rule_and_closer_exits_win_ties":"{rule}, e no empate vence a saída mais próxima",
+"traceroute.the_carrier_s_own_port_beats_other":"Esta porta vai direto para {net}, então vence as outras portas de transit.",
"traceroute.this_one_is_set_to_mode":"; esta está configurada como {mode}",
"traceroute.transit_is_the_last_resort":"transit é o último recurso",
"tutorial.businesses_pop_up_as_bubbles_on":"Empresas aparecem como bolhas de $ no mapa. Abra Negócios e feche seu primeiro cliente.",
diff --git a/src/game/60-features/50-traceroute.js b/src/game/60-features/50-traceroute.js
index 8f4618a..d9b05eb 100644
--- a/src/game/60-features/50-traceroute.js
+++ b/src/game/60-features/50-traceroute.js
@@ -11,7 +11,7 @@ function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev
// 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 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',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;}
// coneChain(peer,net): [peer, …, net], the shortest walk down customer links (the network's up lists, read backwards).
function coneChain(top,id){const prev={[id]:null},q=[id];while(q.length){const x=q.shift();if(x===top)break;for(const u of NET[x].up||[])if(NET[u]&&!(u in prev)){prev[u]=x;q.push(u);}}
@@ -24,8 +24,13 @@ 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};}
- ex.sort((a,b)=>(a.pref==='low'?4:a.rank)-(b.pref==='low'?4:b.rank)||(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||P.dist[a.city]-P.dist[b.city]);
+ // 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.usedkmBetween(e.city,c)S.day?35:20}):'';
- return {text:lines.join('\n'),why:`${tr('traceroute.exit_exit_in_city',{exit:e.lab,city:CITY[e.city].name})} ${tr('traceroute.rule_and_closer_exits_win_ties',{rule:order[0].toUpperCase()+order.slice(1)})}${e.pref!=='normal'?tr('traceroute.this_one_is_set_to_mode',{mode:e.pref==='high'?tr('common.prefer'):tr('common.backup_only')}):''}.${e.used>=e.cap*0.999?' '+tr('traceroute.it_is_full_so_some_traffic'):''}${cn}`,asPath};}
+ return {text:lines.join('\n'),why:`${tr('traceroute.exit_exit_in_city',{exit:e.lab,city:CITY[e.city].name})} ${tr('traceroute.rule_and_closer_exits_win_ties',{rule:order[0].toUpperCase()+order.slice(1)})}${e.pref!=='normal'?tr('traceroute.this_one_is_set_to_mode',{mode:e.pref==='high'?tr('common.prefer'):tr('common.backup_only')}):''}.${direct}${e.used>=e.cap*0.999?' '+tr('traceroute.it_is_full_so_some_traffic'):''}${cn}`,asPath};}
function traceModal(src,to){const pops=Object.keys(S.pops).sort((a,b)=>CITY[a].name.localeCompare(CITY[b].name));src=src&&S.pops[src]?src:UI.trFrom&&S.pops[UI.trFrom]?UI.trFrom:S.home&&S.pops[S.home]?S.home:pops[0];
const nets=NETS.slice().sort((a,b)=>b.share-a.share),t=to||UI.trTo||'net:ggl';UI.trFrom=src;UI.trTo=t;
const r=t.startsWith('net:')?traceroute(src,{net:t.slice(4)}):traceroute(src,{city:t.slice(5)});
diff --git a/src/game/80-simulation/25-direct-egress.js b/src/game/80-simulation/25-direct-egress.js
new file mode 100644
index 0000000..4ae0eff
--- /dev/null
+++ b/src/game/80-simulation/25-direct-egress.js
@@ -0,0 +1,14 @@
+/* A carrier's own transit port beats other transit ports for traffic bound for that carrier (tier 1) or for a network
+ that buys transit from it (tier 2): the shorter AS path. A port set to carry pulls that traffic from every POP; any
+ other only takes it at the POP it sits in. These ranks come after RouteScript's `prefer transit` (2.9) and before plain
+ transit (3), and each port stays in the plain transit list too, so POPs far from it can still use it.
+ 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};}
diff --git a/src/game/80-simulation/30-compute.js b/src/game/80-simulation/30-compute.js
index efe6b3e..282fcf0 100644
--- a/src/game/80-simulation/30-compute.js
+++ b/src/game/80-simulation/30-compute.js
@@ -25,7 +25,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,clean:!!t.clean,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&&!(snd&&NET[n].kr)};
+ const ex={k:'t',net:t.net,clean:!!t.clean,prem:premOn(t),pref:t.pref||'normal',carry:!!t.carry,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&&!(snd&&NET[n].kr)};
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;
@@ -150,7 +150,12 @@ function compute(){
const base=(e,n)=>e.pref==='low'?4:e.rank>0&&e.rank<3&&coneOf(e,n)?CONE_RANK:e.rank;
// 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;};
- const RANKS=TR?[0,0.5,1,2,CONE_RANK,2.9,3,3.5,4,4.4,4.5,4.6]:[0,1,2,CONE_RANK,3,4];
+ // 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 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;
// Each network's exits by the rank they route at (RouteScript can move an exit per network), in E's order.
@@ -159,7 +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;ie.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.
@@ -209,8 +215,23 @@ 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=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;fi1e-6;){let j=i+1;while(jv&&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.premium=premOnlyAt(NET[t.net],t.city)||!!t.premium&&premCity(NET[t.net],t.city),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.carry===true||delete t.carry,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,...(u.site==='ab'?{site:'ab'}:{})}:undefined;if(!x.up)delete x.up;}}
diff --git a/src/game/90-actions/60-links.js b/src/game/90-actions/60-links.js
index a795f32..5638495 100644
--- a/src/game/90-actions/60-links.js
+++ b/src/game/90-actions/60-links.js
@@ -39,6 +39,7 @@ Object.assign(ACT,{
const w=pairW(key,l.km);S.pairMet[key]={k,v:clampM(k,k==='w'?w:w/(l.km+60))};metBlur();sfx('click');after();},
metricSet:({id})=>{const l=S.links.find(x=>x.id===id),t=$('metIn');if(!l||!t)return;const key=edgeKey(l),c=pairCm(key);if(!c)return;const v=parseFloat(String(t.value).replace(',','.'));if(!Number.isFinite(v)){sfx('err');return;}
t.blur();S.pairMet[key]={k:c.k,v:clampM(c.k,v)};sfx('click');after();},
+ setCarry:({id,on})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;if(on)t.carry=true;else delete t.carry;sfx('click');after();},
setStandby:({id,on})=>{const l=S.links.find(x=>x.id===id);if(!l)return;if(on)l.standby=true;else delete l.standby;sfx('click');after();},
goEgress:({city,k})=>{ACT.focusCity({city});UI.tab=k==='t'?'up':k==='l2'?'cust':k==='nni'?'links':'peer';renderPanel();},
});
diff --git a/src/game/93-ui/50-city-panel.js b/src/game/93-ui/50-city-panel.js
index d2720c2..b9c4d1e 100644
--- a/src/game/93-ui/50-city-panel.js
+++ b/src/game/93-ui/50-city-panel.js
@@ -47,7 +47,7 @@ function cityPanel(c){
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+=`
${btn(tr('common.check_redundancy'),'linkCheck',{id:l.id},'ghost sm',linkDown(l))}`;}
+// At its own POP a carrier's port always takes that carrier's traffic (25-direct-egress.js). From POPs with no port of it, the
+// traffic goes to the nearest transit port, or across your network to this one. Only worth asking when something else could take it.
+function carryCtl(t){if(Object.keys(S.pops).length<2||!S.transit.some(x=>x.net!==t.net))return '';const n=esc(NET[t.net].name);
+ return `
`;}
function trafficSection(l){
const rec=R.ef[edgeKey(l)],n=pairLinks(l.a,l.b).length;
let h=linkCheckControl(l)+`
${tr('link_panels.what_s_on_this_link')}
`;
diff --git a/src/i18n/en.js b/src/i18n/en.js
index 4d0353e..eb71f08 100644
--- a/src/i18n/en.js
+++ b/src/i18n/en.js
@@ -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 Tier 1!",
"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}",
@@ -2404,12 +2404,14 @@
"link_panels.additional_traffic_lost":"Additional traffic lost",
"link_panels.an_alternate_path_exists_but_current":"An alternate path exists, but current routing and capacity deliver less traffic.",
"link_panels.apply_for_a_license_price_mo_n_days":"Apply for a license {price} + {mo}/mo · ~{n} days",
+"link_panels.at_this_pop_net_s_traffic_always":"At this POP, {net}'s traffic always uses this port. POPs without one use their nearest transit port.",
"link_panels.back_in_n_days":"Back in {n} days.",
"link_panels.behind_the_great_firewall":"Behind the Great Firewall",
"link_panels.biggest_fabric_money_can_buy":"Biggest fabric money can buy.",
"link_panels.biggest_feeder_egress_in_city_set":"Biggest feeder: {egress} in {city}. Set it to “Backup only”, give the customers a closer egress (peering, a cache, local transit), or raise this link's metric.",
"link_panels.build_a_pop_here_first":"Build a POP here first.",
"link_panels.cancel_the_iru":"Cancel the IRU",
+"link_panels.carry_here":"Carry here",
"link_panels.click_to_tear_down":"Click to tear down",
"link_panels.collecting_data_check_back_in_a":"Collecting data. Check back in a few days.",
"link_panels.congested_upgrade_it_or_add_a":"Congested. Upgrade it or add a parallel path.",
@@ -2421,6 +2423,7 @@
"link_panels.de_kicks_personalised_pricing_p_of_3d4f":"DE-KICKS personalised pricing: {p}% of what a normal IX would charge.",
"link_panels.each_channel_is_a_pair_of":"Each channel is a pair of optics, one per end. ZR+ optics plug straight into your routers. Transponders sit on a shelf.",
"link_panels.enters_your_network_at":"Enters your network at",
+"link_panels.every_pop_carries_net_s_traffic":"Every POP carries {net}'s traffic across your network to this port.",
"link_panels.finish_in_1_day_price":"Finish in 1 day {price}",
"link_panels.foreign_networks_need_a_local_joint":"Foreign networks need a local joint venture and an operating license to build infrastructure here.",
"link_panels.found_your_own_ix_cost_mo":"Found your own IX {cost} + {mo}/mo",
@@ -2454,6 +2457,7 @@
"link_panels.name_is_down_nothing_you_can":"{name} is down. Nothing you can do but wait, or have another path.",
"link_panels.name_parallel_link":"{name} parallel link",
"link_panels.name_wave":"{name} wave",
+"link_panels.nearest_port":"Nearest port",
"link_panels.needs_a_pop_in_cities_too":"Needs a POP in {cities} too.",
"link_panels.needs_what":"needs {what}",
"link_panels.needs_your_own_scrubbing_center":"Needs your own scrubbing center (Infra tab).",
@@ -2518,6 +2522,7 @@
"link_panels.this_is_the_only_link_between":"This is the only link between these cities. Add a parallel one, or a path through another city.",
"link_panels.tier_1_only_a_pni_and":"Tier 1: only a PNI, and only once you are big enough for the Tier 1 club",
"link_panels.totals_for_all_n_links_between":"Totals for all {n} links between these cities.",
+"link_panels.traffic_for_net":"Traffic for {net}",
"link_panels.unplugged_optics_go_on_the_spares":"Unplugged optics go on the spares shelf and are used first next time.",
"link_panels.upgrade_fabric_to_name_cost_mo":"Upgrade fabric to {name} {cost} + {mo}/mo",
"link_panels.upgrade_to_sys_price":"Upgrade to {sys} {price}",
@@ -3800,6 +3805,7 @@
"traceroute.ix_peering_beats_transit":"IX peering beats transit",
"traceroute.n_network_unreachable":"!N network unreachable",
"traceroute.name_transit":"{name} transit",
+"traceroute.net_buys_transit_from_carrier_so_that":"{net} buys transit from {carrier}, so that port beats the other transit ports.",
"traceroute.net_carries_it_to_city":"{net} carries it to {city}",
"traceroute.net_hands_it_to_its_customer":"{net} hands it to its customer {to}",
"traceroute.net_hands_it_to_to":"{net} hands it to {to}",
@@ -3809,6 +3815,7 @@
"traceroute.pnis_beat_ix_peering":"PNIs beat IX peering",
"traceroute.private_cross_connect":"private cross-connect",
"traceroute.rule_and_closer_exits_win_ties":"{rule}, and closer exits win ties",
+"traceroute.the_carrier_s_own_port_beats_other":"This port goes straight to {net}, so it beats the other transit ports.",
"traceroute.this_one_is_set_to_mode":"; this one is set to {mode}",
"traceroute.transit_is_the_last_resort":"transit is the last resort",
"tutorial.businesses_pop_up_as_bubbles_on":"Businesses pop up as $ bubbles on the map. Open Deals and sign your first customer.",
diff --git a/tests/direct-egress.test.js b/tests/direct-egress.test.js
new file mode 100644
index 0000000..cb448c5
--- /dev/null
+++ b/tests/direct-egress.test.js
@@ -0,0 +1,188 @@
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const { load } = require('./harness');
+
+const port = (ev, carrier, city) => ev(`S.transit.find(t=>t.net==='${carrier}'${city ? `&&t.city==='${city}'` : ''}).id`);
+const via = (ev, id, dest) => ev(`((R.tNet['${id}']||{})['${dest}'])||0`);
+
+// New York with eyeballs, and Level Tree and Tell-Ya ports in the same POP.
+function newYork(lvlTier = 1, demand = 800) {
+ const g = load();
+ g.ev(`ACT.pickStart({city:'nyc'});ACT.start({});S.cash=1e9;ACT.launchBB({city:'nyc'});S.pops.nyc.bb.d=${demand};
+ ACT.buyTransit({city:'nyc',net:'lvl',tier:${lvlTier}});ACT.buyTransit({city:'nyc',net:'tly',tier:1});compute()`);
+ g.lvl = port(g.ev, 'lvl'); g.tly = port(g.ev, 'tly');
+ return g;
+}
+
+// Chicago has the eyeballs; Level Tree is in New York, Tell-Ya in Chicago, and a 100G wave joins them.
+function twoPops() {
+ 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();
+ ACT.launchBB({city:'chi'});S.pops.chi.bb.d=80;
+ ACT.buyTransit({city:'nyc',net:'lvl',tier:1});ACT.buyTransit({city:'chi',net:'tly',tier:1});compute()`);
+ g.lvl = port(g.ev, 'lvl'); g.tly = port(g.ev, 'tly');
+ g.link = g.ev("S.links[0].id");
+ return g;
+}
+
+test('at its own POP a carrier\'s port takes the traffic bound for that carrier, not an even split', () => {
+ const { ev, lvl, tly, errors } = newYork();
+ assert.ok(via(ev, lvl, 'lvl') > 1, 'Level Tree traffic goes out of the Level Tree port');
+ assert.equal(via(ev, tly, 'lvl'), 0, 'and none of it out of Tell-Ya');
+ assert.ok(via(ev, tly, 'tly') > 1 && via(ev, lvl, 'tly') === 0, 'the same for Tell-Ya');
+ assert.ok(via(ev, lvl, 'ntt') > 1 && via(ev, tly, 'ntt') > 1, 'traffic for a carrier you have no port of still shares both ports');
+ assert.deepEqual(errors, []);
+});
+
+test('traffic for a carrier\'s customers prefers that carrier too, and a carrier beats its own customers\' other upstreams', () => {
+ const { ev, lvl, tly, errors } = newYork();
+ // Tee-Hee Mobile buys from Level Tree and Not That Telecom, not from Tell-Ya.
+ assert.deepEqual(JSON.parse(ev("JSON.stringify(NET.tmo.up)")), ['lvl', 'ntt']);
+ assert.ok(via(ev, lvl, 'tmo') > 0 && via(ev, tly, 'tmo') === 0, 'Tee-Hee Mobile goes out of the Level Tree port');
+ // Add Not That Telecom: it is just as good an upstream for Tee-Hee, so the two share it. Its own traffic stays on its own port.
+ ev("ACT.buyTransit({city:'nyc',net:'ntt',tier:1});compute()");
+ const ntt = port(ev, 'ntt');
+ assert.ok(via(ev, lvl, 'tmo') > 0 && via(ev, ntt, 'tmo') > 0 && via(ev, tly, 'tmo') === 0, 'two upstreams of the same network share its traffic');
+ assert.ok(via(ev, ntt, 'ntt') > 0 && via(ev, lvl, 'ntt') === 0 && via(ev, tly, 'ntt') === 0);
+ assert.deepEqual(errors, []);
+});
+
+test('when the carrier\'s own port is full, the rest spills onto the other transit ports', () => {
+ const { ev, lvl, tly, errors } = newYork(0); // a 10G Level Tree port
+ assert.ok(ev(`R.useT['${lvl}']`) > 9.99, 'the small port is full');
+ assert.ok(via(ev, lvl, 'lvl') > 9, 'mostly with Level Tree traffic');
+ assert.ok(via(ev, tly, 'lvl') > 1, 'and the rest of Level Tree\'s traffic goes out of Tell-Ya');
+ assert.deepEqual(errors, []);
+});
+
+test('Prefer, Backup only and RouteScript keep the say they had', () => {
+ // A Prefer-marked port of another carrier takes everything first, as it always did.
+ let g = newYork(1, 150);
+ g.ev(`ACT.setPref({kind:'t',id:'${g.tly}',v:'high'});compute()`);
+ assert.ok(via(g.ev, g.tly, 'lvl') > 1 && via(g.ev, g.lvl, 'lvl') === 0, 'Prefer on Tell-Ya sends Level Tree traffic there too');
+ assert.deepEqual(g.errors, []);
+ // A port set to Backup only is the last resort, even for its own traffic.
+ g = newYork(1, 150);
+ g.ev(`ACT.setPref({kind:'t',id:'${g.lvl}',v:'low'});compute()`);
+ assert.equal(via(g.ev, g.lvl, 'lvl'), 0, 'Level Tree on backup carries none of its own traffic while Tell-Ya has room');
+ assert.ok(via(g.ev, g.tly, 'lvl') > 1);
+ assert.deepEqual(g.errors, []);
+ // RouteScript's avoid transit is policy, and beats the shorter path.
+ g = newYork(1, 150);
+ g.ev("S.te={on:true,script:'avoid transit level tree'};S.core={lv:2,run:2,legacy:true};compute()");
+ assert.ok(g.ev("!!teRules()"), 'the script is active');
+ assert.equal(via(g.ev, g.lvl, 'lvl'), 0, 'avoid transit level tree keeps even its own traffic off it');
+ assert.ok(via(g.ev, g.tly, 'lvl') > 1);
+ 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");
+ assert.ok(via(ev, tly, 'lvl') > 1, 'by default Chicago sends Level Tree traffic out of its own nearest port, Tell-Ya');
+ assert.equal(via(ev, lvl, 'lvl'), 0);
+ assert.equal(ev(`R.load['${link}']||0`), 0, 'nothing crosses the link');
+ ev(`ACT.setCarry({id:'${lvl}',on:1})`);
+ assert.equal(ev(`S.transit.find(t=>t.id==='${lvl}').carry`), true);
+ assert.ok(via(ev, lvl, 'lvl') > 1, 'with Carry here, it crosses to New York and leaves by Level Tree');
+ assert.ok(via(ev, tly, 'lvl') < 0.001, 'and not by Tell-Ya');
+ assert.ok(ev(`R.load['${link}']`) > 1, 'over the circuit');
+ assert.ok(via(ev, tly, 'tly') > 1 && via(ev, lvl, 'tly') === 0, 'Tell-Ya\'s own traffic is not affected');
+ ev(`ACT.setCarry({id:'${lvl}',on:0})`);
+ assert.equal(ev(`S.transit.find(t=>t.id==='${lvl}').carry`), undefined, 'switching it off removes the flag');
+ assert.ok(via(ev, tly, 'lvl') > 1, 'and the nearest port is used again');
+ assert.deepEqual(errors, []);
+});
+
+test('traceroute shows the exit that routing uses, and says why', () => {
+ const { ev, lvl, errors } = twoPops();
+ const why = (to, from = 'chi') => ev(`traceroute('${from}',{net:'${to}'}).why`);
+ const tly = port(ev, 'tly');
+ assert.match(why('lvl'), /Tell-Ya.*Chicago/, 'nearest port from Chicago');
+ assert.doesNotMatch(why('lvl'), /straight to/);
+ assert.ok(via(ev, tly, 'lvl') > 1 && via(ev, lvl, 'lvl') === 0, 'and that is the port routing really uses');
+ ev(`ACT.setCarry({id:'${lvl}',on:1})`);
+ assert.ok(via(ev, lvl, 'lvl') > 1 && via(ev, tly, 'lvl') < 0.001, 'routing now uses the carrying port too');
+ assert.match(why('lvl'), /Level Tree.*New York/, 'the carrying port, in New York');
+ assert.match(why('lvl'), /straight to Level Tree/, 'because it goes straight to the carrier');
+ assert.match(why('tmo'), /Tee-Hee Mobile buys transit from Level Tree/, 'and for its customers');
+ assert.match(why('lvl', 'nyc'), /Level Tree.*New York/, 'at its own POP the carrier\'s port wins without carrying');
+ ev(`ACT.setCarry({id:'${lvl}',on:0})`);
+ assert.match(why('lvl', 'nyc'), /Level Tree.*New York.*straight to Level Tree/, 'also with carry off');
+ assert.deepEqual(errors, []);
+});
+
+test('the carry setting is saved, repaired and optional', () => {
+ const { ev, errors } = twoPops();
+ ev(`ACT.setCarry({id:'${port(ev, 'lvl')}',on:1});save(true)`);
+ const saved = ev('slotRaw(UI.slot)');
+ const again = load({ storage: { 'sot-save-v1': saved } });
+ assert.equal(again.ev("S.transit.find(t=>t.net==='lvl').carry"), true, 'survives a reload');
+ assert.equal(again.ev("S.transit.find(t=>t.net==='tly').carry"), undefined, 'and is off for the others');
+ // Hand-edited or imported garbage is dropped; an old save without the field just loads.
+ const bad = JSON.parse(saved);
+ bad.transit.forEach((t, i) => { t.carry = i ? 'yes' : 1; });
+ const fixed = load({ storage: { 'sot-save-v1': JSON.stringify(bad) } });
+ assert.equal(fixed.ev("S.transit.some(t=>'carry' in t)"), false);
+ const old = JSON.parse(saved);
+ old.transit.forEach((t) => { delete t.carry; });
+ assert.equal(load({ storage: { 'sot-save-v1': JSON.stringify(old) } }).ev("S.transit.length"), 2);
+ assert.deepEqual([...errors, ...again.errors, ...fixed.errors], []);
+});
+
+test('each port offers the choice when it can matter, on a desktop and a phone', () => {
+ for (const w of [1280, 360]) {
+ const { ev, dom, errors } = load();
+ ev(`window.innerWidth=${w};ACT.pickStart({city:'nyc'});ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;ACT.buyTransit({city:'nyc',net:'lvl',tier:1});UI.sel={type:'city',id:'nyc'};UI.tab='up';renderPanel()`);
+ const body = () => dom.window.document.getElementById('panelBody');
+ assert.equal(body().querySelectorAll('[data-act="setCarry"]').length, 0, `${w}px: one POP, one carrier: nothing to choose`);
+ ev("ACT.buildPop({city:'chi'});ACT.buyTransit({city:'chi',net:'tly',tier:1});UI.sel={type:'city',id:'nyc'};UI.tab='up';renderPanel()");
+ assert.equal(body().querySelectorAll('[data-act="setCarry"]').length, 2, `${w}px: Nearest port and Carry here for the Level Tree port`);
+ assert.match(body().textContent, /Traffic for Level Tree/);
+ assert.match(body().textContent, /At this POP, Level Tree's traffic always uses this port/);
+ body().querySelector('[data-act="setCarry"][data-args*="\\"on\\":1"]').click();
+ assert.equal(ev("S.transit.find(t=>t.net==='lvl').carry"), true, `${w}px: the button works`);
+ assert.match(body().textContent, /Every POP carries Level Tree's traffic across your network to this port/);
+ assert.deepEqual(errors, []);
+ }
+});
+
+test('the control reads right in every language', () => {
+ for (const lang of ['it', 'pt', 'fr', 'es', 'de']) {
+ const { ev, dom, errors } = load({ lang });
+ ev("ACT.pickStart({city:'nyc'});ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;ACT.buyTransit({city:'nyc',net:'lvl',tier:1});ACT.buildPop({city:'chi'});ACT.buyTransit({city:'chi',net:'tly',tier:1});UI.sel={type:'city',id:'nyc'};UI.tab='up';renderPanel()");
+ const text = dom.window.document.getElementById('panelBody').textContent;
+ assert.ok(!/\{net\}|link_panels\./.test(text), `${lang}: no raw placeholders or labels`);
+ assert.notEqual(ev("tr('link_panels.carry_here')"), 'Carry here', `${lang}: translated`);
+ assert.deepEqual(errors, []);
+ }
+});
diff --git a/tests/helpers/reference-allocation.js b/tests/helpers/reference-allocation.js
index f9e4e70..d15bc61 100644
--- a/tests/helpers/reference-allocation.js
+++ b/tests/helpers/reference-allocation.js
@@ -3,12 +3,17 @@
// 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++;
const candidates=E.filter(e=>e.used(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||Dv[CIDX[a.city]]-Dv[CIDX[b.city]]);
for(let i=0;i1e-6;){
let j=i+1;while(jt.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'",
+ "S.te.script='avoid transit level tree\\nprefer transit tell-ya\\nspill at 80%'",
"S.te.script='prefer transit Cogentle\\nprepend transit Cogentle 2\\nprotect customers'",
"S.ev.rpki={nets:['ggl','nfx'],until:S.day+3};S.ev.depeer=S.day+3",
"S.ev.ddos={city:'fra',until:S.day+3,gbps:300,vec:'syn',entry:{k:'edge'}}",