From ff0276f32546982e0a55863f9c32604517e1af2f Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Wed, 4 Nov 2026 07:37:10 +0100 Subject: [PATCH] Pie Control: backhaul rows, globe arcs and orbit traceroute for cut-off POPs The Traffic tab gets a Backhaul group (how full, where it lands, the ms it adds, or why it is missing), the empty-sky checklist a backhaul item, dish rows count backhaul; the globe draws backhaul as a sky arc, highlighted on tap; the traceroute to and from a cut-off POP shows its hops through space. Strings in every language; tests in tests/pie-backhaul.test.js. --- CHANGELOG.md | 1 + site/i18n/de.js | 17 +- site/i18n/es.js | 17 +- site/i18n/fr.js | 17 +- site/i18n/it.js | 17 +- site/i18n/pt.js | 17 +- src/game/60-features/50-traceroute.js | 23 +- src/game/60-features/99-pie-in-the-sky.js | 8 +- src/game/93-ui/86-pie-traffic.js | 25 ++- src/game/96-map/89-pie-globe.js | 4 +- src/i18n/en.js | 17 +- tests/pie-backhaul.test.js | 248 ++++++++++++++++++++++ 12 files changed, 387 insertions(+), 24 deletions(-) create mode 100644 tests/pie-backhaul.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index bbf8a98..8da11b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to this project are documented here. The project follows - Space is not quiet for long: three months after your rocket company starts, solar storms, food fights in orbit, rain over tropical pie dishes, backhoes, astronomers and the Founder's 3 a.m. posts come for your satellites. Countries join in too, with landing rights refused for a while, data that has to stay home, two neighbours claiming the same band, a kill switch for exam week, a jammed border, a rival filing for orbits first, a launch pad on offer and traffic that must avoid the neighbour's dishes. Each one asks you to pick one of two answers. A ruleset with no chaos keeps the sky calm. - Your pies now carry traffic and earn money: homes and boats in the remotest places (Pitcairn, the Arctic, the outer islands), airlines, cruise ships and the Mars mission sign up once a baked crust and a pie dish can serve them. With laser links, trading circuits between cities more than 3,000 km apart take the faster path through space, where light runs about half again as fast as in glass; everything else stays on your fiber. A dish whose POP is cut off from your backbone serves only the customers next to it, and a full constellation takes years to pay for itself. - Pie Control now shows what traffic rides your satellites: a new Traffic tab lists who is in orbit (homes, boats, airlines, the Mars mission and trading circuits), how many Gbps each one uses, what it pays, and how much faster orbit is than your fiber. Each crust and pie dish gets a load bar and a plain reason when it sits idle (half-baked, raining, jammed, cut off from your backbone, no landing rights, no lasers, no customers), and an empty sky gets a checklist of what is missing. The globe draws each customer's traffic as a glowing arc you can highlight from the list, dishes on the globe and the map get a load ring, and the traceroute shows a circuit's hops up to orbit, across space and back down. +- A town with no cable can now reach your network through your satellites: a pie dish at a POP your fiber does not reach sends all of that town's traffic up to a baked crust and down at one of your dishes on the backbone, nearby or, with laser links, anywhere. The pipe is small (the dishes' antennas and the crust's room) and adds the orbit's delay, so a big town fills it quickly and laying fiber stays the real fix; it never carries traffic between your other cities. Pie Control's Traffic tab shows each backhaul, how full it is, where it lands and how many ms it adds, or why it is missing, the globe draws it, and the traceroute shows its hops through space. - 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). - Starting a new network no longer leaves the last one's "New POP!" and money pop-ups frozen all over the map until a reload. diff --git a/site/i18n/de.js b/site/i18n/de.js index 030ddc2..3c44f25 100644 --- a/site/i18n/de.js +++ b/site/i18n/de.js @@ -3601,9 +3601,21 @@ "pie_spat.pad_r1":"Du hast abgelehnt. Händeschütteln gab es trotzdem.", "pie_spat.pad_t":"Startrampen-Diplomatie", "pie_spat.pad_won":"Band durchgeschnitten: eine kostenlose Startrampe in {city}.", +"pie_traffic.backhaul":"Backhaul", +"pie_traffic.bh_for":"Backhaul für {city}", +"pie_traffic.bh_full":"Die Leitung ist voll: Verleg Glasfaser nach {city}, um den Rest zu tragen.", +"pie_traffic.bh_full_none":"jede erreichbare Schüssel ist voll", +"pie_traffic.bh_hint":"Ein Ort ohne Glasfaser zu deinem Backbone schickt seinen ganzen Traffic über die eigene Schüssel hoch und bei einer am Backbone wieder runter. Tippe auf eine Zeile, um sie auf dem Globus zu zeigen.", +"pie_traffic.bh_line":"{g} von {cap} · landet in {dish} · +{ms} ms", +"pie_traffic.bh_nocrust":"keine gebackene Kruste darüber", +"pie_traffic.bh_noland":"keine Lande-Schüssel an deinem Backbone unter derselben Kruste", +"pie_traffic.bh_nolas":"keine Schüssel an deinem Backbone im Umkreis von {km} km und keine Laser für eine weiter weg", +"pie_traffic.bh_spat":"ein Streit hält den Traffic von jeder erreichbaren Schüssel fern", "pie_traffic.ck_backbone":"Eine Schüssel an deinem Backbone", -"pie_traffic.ck_backbone_h":"{city} hat keine Glasfaser zum Rest deines Netzes und bedient nur die eigene Nachbarschaft.", +"pie_traffic.ck_backbone_bh":"{city} hat keine Glasfaser zum Rest deines Netzes: Die Schüssel dort kann den eigenen Traffic des Orts per Backhaul hochschicken, aber keinen fremden.", "pie_traffic.ck_backbone_none":"Deine Schüsseln brauchen einen POP, den dein Backbone erreicht.", +"pie_traffic.ck_backhaul":"Backhaul für Orte ohne Glasfaser", +"pie_traffic.ck_backhaul_h":"{city} hat keinen Backhaul: {why}.", "pie_traffic.ck_baked":"Eine Kruste zu mindestens {min} voll", "pie_traffic.ck_baked_none":"Schieß Pies in eine Kruste, bis sie gebacken ist.", "pie_traffic.ck_customers":"Kunden, die den Orbit nutzen", @@ -3617,6 +3629,7 @@ "pie_traffic.crust_half":"{crust} ist zu {p} gebacken; Traffic trägt sie ab {min}.", "pie_traffic.crust_safe":"Der Sicherheitsmodus ist an: Sie trägt nichts, bis du ihn ausschaltest.", "pie_traffic.crusts":"Krusten", +"pie_traffic.d_backhaul":"schickt den eigenen Ort per Backhaul durch den Orbit", "pie_traffic.d_down":"außer Gefecht (ein Bagger)", "pie_traffic.d_idle":"noch nutzt sie kein Kunde", "pie_traffic.d_isl":"vom Backbone abgeschnitten", @@ -3629,6 +3642,7 @@ "pie_traffic.d_ref":"Landerechte vorerst verweigert", "pie_traffic.d_spat":"Rechte wegen eines Streits ausgesetzt bis {d}", "pie_traffic.dish_line":"Terminals {t} · Transit {x} · von {cap}", +"pie_traffic.dish_line_bh":"Terminals {t} · Backhaul {b} · Transit {x} · von {cap}", "pie_traffic.dishes":"Pie-Schüsseln", "pie_traffic.empty_title":"Warum ist mein Himmel leer?", "pie_traffic.headline":{"one":"Gerade im Orbit: {g} von {of} verkaufbar · {amt}/Monat · {n} Kunde","other":"Gerade im Orbit: {g} von {of} verkaufbar · {amt}/Monat · {n} Kunden"}, @@ -4524,6 +4538,7 @@ "traceroute.a_peer_s_customers_come_after":"die Kunden eines Peers kommen nach direkten Peers und vor Transit", "traceroute.across_the_ix_switch":"über den Switch des {ix}", "traceroute.as_path_path":"AS-Pfad: {path}", +"traceroute.bh_why":"{city} hat keine Glasfaser zu deinem Backbone, also geht es durch den Orbit und landet in {dish} (+{ms} ms Round Trip).", "traceroute.caches_beat_pnis":"Caches schlagen PNIs", "traceroute.circuits_through_orbit":"Leitungen durch den Orbit", "traceroute.city_your_router":"{city}, dein Router", diff --git a/site/i18n/es.js b/site/i18n/es.js index bab6881..fa959cc 100644 --- a/site/i18n/es.js +++ b/site/i18n/es.js @@ -3599,9 +3599,21 @@ "pie_spat.pad_r1":"Has rechazado. Igualmente todos se dieron la mano.", "pie_spat.pad_t":"Diplomacia de lanzamiento", "pie_spat.pad_won":"Cinta cortada: una plataforma de lanzamiento gratis en {city}.", +"pie_traffic.backhaul":"Backhaul", +"pie_traffic.bh_for":"Backhaul para {city}", +"pie_traffic.bh_full":"El tubo está lleno: tiende fibra hasta {city} para llevar el resto.", +"pie_traffic.bh_full_none":"todas las antenas a su alcance están llenas", +"pie_traffic.bh_hint":"Un pueblo sin fibra hacia tu backbone sube todo su tráfico por su propia antena y lo baja en una del backbone. Toca una fila para verla en el globo.", +"pie_traffic.bh_line":"{g} de {cap} · aterriza en {dish} · +{ms} ms", +"pie_traffic.bh_nocrust":"ninguna corteza horneada encima", +"pie_traffic.bh_noland":"ninguna antena de aterrizaje en tu backbone bajo la misma corteza", +"pie_traffic.bh_nolas":"ninguna antena de tu backbone a menos de {km} km, y sin láseres para llegar a una más lejana", +"pie_traffic.bh_spat":"una disputa aleja su tráfico de todas las antenas a su alcance", "pie_traffic.ck_backbone":"Una antena en tu backbone", -"pie_traffic.ck_backbone_h":"{city} no tiene fibra hacia el resto de tu red, así que solo atiende a sus vecinos.", +"pie_traffic.ck_backbone_bh":"{city} no tiene fibra hacia el resto de tu red: su antena puede llevar por backhaul el tráfico propio del pueblo, pero no el de nadie más.", "pie_traffic.ck_backbone_none":"Tus antenas necesitan un POP al que llegue tu backbone.", +"pie_traffic.ck_backhaul":"Backhaul para pueblos sin fibra", +"pie_traffic.ck_backhaul_h":"{city} no tiene backhaul: {why}.", "pie_traffic.ck_baked":"Una corteza llena al menos al {min}", "pie_traffic.ck_baked_none":"Lanza tartas a una corteza hasta que esté horneada.", "pie_traffic.ck_customers":"Clientes que usan la órbita", @@ -3615,6 +3627,7 @@ "pie_traffic.crust_half":"{crust} está horneada al {p}; lleva tráfico a partir del {min}.", "pie_traffic.crust_safe":"El modo seguro está activo: no lleva nada hasta que lo apagues.", "pie_traffic.crusts":"Cortezas", +"pie_traffic.d_backhaul":"lleva por backhaul su propio pueblo a través de la órbita", "pie_traffic.d_down":"fuera de combate (una excavadora)", "pie_traffic.d_idle":"aún no la usa ningún cliente", "pie_traffic.d_isl":"aislada de tu backbone", @@ -3627,6 +3640,7 @@ "pie_traffic.d_ref":"derechos de aterrizaje denegados por ahora", "pie_traffic.d_spat":"derechos suspendidos por una disputa hasta {d}", "pie_traffic.dish_line":"Terminales {t} · tránsito {x} · de {cap}", +"pie_traffic.dish_line_bh":"Terminales {t} · backhaul {b} · tránsito {x} · de {cap}", "pie_traffic.dishes":"Antenas-tarta", "pie_traffic.empty_title":"¿Por qué mi cielo está vacío?", "pie_traffic.headline":{"one":"En órbita ahora: {g} de {of} vendibles · {amt}/mes · {n} cliente","other":"En órbita ahora: {g} de {of} vendibles · {amt}/mes · {n} clientes"}, @@ -4522,6 +4536,7 @@ "traceroute.a_peer_s_customers_come_after":"los clientes de un peer van después de los peers directos y antes del tránsito", "traceroute.across_the_ix_switch":"a través del switch de {ix}", "traceroute.as_path_path":"AS path: {path}", +"traceroute.bh_why":"{city} no tiene fibra hacia tu backbone, así que va por la órbita y aterriza en {dish} (+{ms} ms de ida y vuelta).", "traceroute.caches_beat_pnis":"las cachés ganan a los PNIs", "traceroute.circuits_through_orbit":"Circuitos por la órbita", "traceroute.city_your_router":"{city}, tu router", diff --git a/site/i18n/fr.js b/site/i18n/fr.js index e7fee09..7163655 100644 --- a/site/i18n/fr.js +++ b/site/i18n/fr.js @@ -3599,9 +3599,21 @@ "pie_spat.pad_r1":"Tu as refusé. Tout le monde s'est serré la main quand même.", "pie_spat.pad_t":"Diplomatie du lancement", "pie_spat.pad_won":"Ruban coupé : un pas de tir gratuit à {city}.", +"pie_traffic.backhaul":"Backhaul", +"pie_traffic.bh_for":"Backhaul pour {city}", +"pie_traffic.bh_full":"Le tuyau est plein : tire de la fibre jusqu’à {city} pour porter le reste.", +"pie_traffic.bh_full_none":"toutes les antennes à portée sont pleines", +"pie_traffic.bh_hint":"Une ville sans fibre vers ton backbone envoie tout son trafic par sa propre antenne et le redescend sur une antenne du backbone. Touche une ligne pour la voir sur le globe.", +"pie_traffic.bh_line":"{g} sur {cap} · atterrit à {dish} · +{ms} ms", +"pie_traffic.bh_nocrust":"aucune croûte cuite au-dessus", +"pie_traffic.bh_noland":"aucune antenne d’atterrissage sur ton backbone sous la même croûte", +"pie_traffic.bh_nolas":"aucune antenne de ton backbone à moins de {km} km, et pas de lasers pour en atteindre une plus loin", +"pie_traffic.bh_spat":"une brouille tient son trafic loin de toutes les antennes à portée", "pie_traffic.ck_backbone":"Une antenne sur ton backbone", -"pie_traffic.ck_backbone_h":"{city} n’a pas de fibre vers le reste de ton réseau, elle ne sert donc que ses voisins.", +"pie_traffic.ck_backbone_bh":"{city} n’a pas de fibre vers le reste de ton réseau : son antenne peut faire le backhaul du trafic de la ville elle-même, mais de personne d’autre.", "pie_traffic.ck_backbone_none":"Tes antennes ont besoin d’un POP que ton backbone atteint.", +"pie_traffic.ck_backhaul":"Backhaul pour les villes sans fibre", +"pie_traffic.ck_backhaul_h":"{city} n’a pas de backhaul : {why}.", "pie_traffic.ck_baked":"Une croûte remplie à au moins {min}", "pie_traffic.ck_baked_none":"Lance des tartes dans une croûte jusqu’à ce qu’elle soit cuite.", "pie_traffic.ck_customers":"Des clients qui utilisent l’orbite", @@ -3615,6 +3627,7 @@ "pie_traffic.crust_half":"{crust} est cuite à {p} ; elle transporte du trafic à partir de {min}.", "pie_traffic.crust_safe":"Le mode sécurité est activé : elle ne transporte rien tant que tu ne l’éteins pas.", "pie_traffic.crusts":"Croûtes", +"pie_traffic.d_backhaul":"fait le backhaul de sa propre ville par l’orbite", "pie_traffic.d_down":"hors d’usage (une pelleteuse)", "pie_traffic.d_idle":"aucun client ne l’utilise encore", "pie_traffic.d_isl":"coupée de ton backbone", @@ -3627,6 +3640,7 @@ "pie_traffic.d_ref":"droits d’atterrissage refusés pour l’instant", "pie_traffic.d_spat":"droits suspendus par une brouille jusqu’au {d}", "pie_traffic.dish_line":"Terminaux {t} · transit {x} · sur {cap}", +"pie_traffic.dish_line_bh":"Terminaux {t} · backhaul {b} · transit {x} · sur {cap}", "pie_traffic.dishes":"Antennes-tartes", "pie_traffic.empty_title":"Pourquoi mon ciel est-il vide ?", "pie_traffic.headline":{"one":"En orbite en ce moment : {g} sur {of} vendables · {amt}/mois · {n} client","other":"En orbite en ce moment : {g} sur {of} vendables · {amt}/mois · {n} clients"}, @@ -4522,6 +4536,7 @@ "traceroute.a_peer_s_customers_come_after":"les clients d’un peer passent après les peers directs, avant le transit", "traceroute.across_the_ix_switch":"via le switch de {ix}", "traceroute.as_path_path":"AS path : {path}", +"traceroute.bh_why":"{city} n’a pas de fibre vers ton backbone, donc ça passe par l’orbite et atterrit à {dish} (+{ms} ms aller-retour).", "traceroute.caches_beat_pnis":"les caches battent les PNI", "traceroute.circuits_through_orbit":"Circuits par l’orbite", "traceroute.city_your_router":"{city}, ton routeur", diff --git a/site/i18n/it.js b/site/i18n/it.js index 67ad5c7..784b639 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -3599,9 +3599,21 @@ "pie_spat.pad_r1":"Hai rifiutato. Strette di mano per tutti comunque.", "pie_spat.pad_t":"Diplomazia dei lanci", "pie_spat.pad_won":"Nastro tagliato: una rampa di lancio gratis a {city}.", +"pie_traffic.backhaul":"Backhaul", +"pie_traffic.bh_for":"Backhaul per {city}", +"pie_traffic.bh_full":"Il tubo è pieno: posa fibra fino a {city} per portare il resto.", +"pie_traffic.bh_full_none":"ogni parabola a portata è piena", +"pie_traffic.bh_hint":"Un paese senza fibra verso il tuo backbone manda tutto il suo traffico su dalla sua parabola e giù da una sul backbone. Tocca una riga per vederla sul globo.", +"pie_traffic.bh_line":"{g} su {cap} · atterra a {dish} · +{ms} ms", +"pie_traffic.bh_nocrust":"nessuna crosta cotta sopra", +"pie_traffic.bh_noland":"nessuna parabola di atterraggio sul tuo backbone sotto la stessa crosta", +"pie_traffic.bh_nolas":"nessuna parabola del tuo backbone entro {km} km, e niente laser per raggiungerne una più lontana", +"pie_traffic.bh_spat":"una lite tiene il suo traffico lontano da ogni parabola a portata", "pie_traffic.ck_backbone":"Una parabola sul tuo backbone", -"pie_traffic.ck_backbone_h":"{city} non ha fibra verso il resto della tua rete, quindi serve solo i suoi vicini.", +"pie_traffic.ck_backbone_bh":"{city} non ha fibra verso il resto della tua rete: la sua parabola può fare il backhaul del traffico del paese stesso, ma di nessun altro.", "pie_traffic.ck_backbone_none":"Le tue parabole hanno bisogno di un POP raggiunto dal tuo backbone.", +"pie_traffic.ck_backhaul":"Backhaul per i paesi senza fibra", +"pie_traffic.ck_backhaul_h":"{city} non ha backhaul: {why}.", "pie_traffic.ck_baked":"Una crosta piena almeno al {min}", "pie_traffic.ck_baked_none":"Lancia torte in una crosta finché non è cotta.", "pie_traffic.ck_customers":"Clienti che usano l'orbita", @@ -3615,6 +3627,7 @@ "pie_traffic.crust_half":"{crust} è cotta al {p}; porta traffico dal {min}.", "pie_traffic.crust_safe":"La modalità sicura è attiva: non porta niente finché non la spegni.", "pie_traffic.crusts":"Croste", +"pie_traffic.d_backhaul":"fa il backhaul del suo paese attraverso l’orbita", "pie_traffic.d_down":"fuori uso (una ruspa)", "pie_traffic.d_idle":"nessun cliente la usa ancora", "pie_traffic.d_isl":"tagliata fuori dal tuo backbone", @@ -3627,6 +3640,7 @@ "pie_traffic.d_ref":"diritti di atterraggio rifiutati per ora", "pie_traffic.d_spat":"diritti sospesi per una lite fino al {d}", "pie_traffic.dish_line":"Terminali {t} · transit {x} · su {cap}", +"pie_traffic.dish_line_bh":"Terminali {t} · backhaul {b} · transit {x} · su {cap}", "pie_traffic.dishes":"Parabole-torta", "pie_traffic.empty_title":"Perché il mio cielo è vuoto?", "pie_traffic.headline":{"one":"In orbita ora: {g} su {of} vendibili · {amt}/mese · {n} cliente","other":"In orbita ora: {g} su {of} vendibili · {amt}/mese · {n} clienti"}, @@ -4522,6 +4536,7 @@ "traceroute.a_peer_s_customers_come_after":"i clienti di un peer vengono dopo i peer diretti e prima del transit", "traceroute.across_the_ix_switch":"attraverso lo switch di {ix}", "traceroute.as_path_path":"AS path: {path}", +"traceroute.bh_why":"{city} non ha fibra verso il tuo backbone, quindi passa dall’orbita e atterra a {dish} (+{ms} ms andata e ritorno).", "traceroute.caches_beat_pnis":"le cache battono i PNI", "traceroute.circuits_through_orbit":"Circuiti in orbita", "traceroute.city_your_router":"{city}, il tuo router", diff --git a/site/i18n/pt.js b/site/i18n/pt.js index a0cea39..75ebc55 100644 --- a/site/i18n/pt.js +++ b/site/i18n/pt.js @@ -3599,9 +3599,21 @@ "pie_spat.pad_r1":"Você recusou. Teve aperto de mão mesmo assim.", "pie_spat.pad_t":"Diplomacia de lançamento", "pie_spat.pad_won":"Fita cortada: uma plataforma de lançamento grátis em {city}.", +"pie_traffic.backhaul":"Backhaul", +"pie_traffic.bh_for":"Backhaul para {city}", +"pie_traffic.bh_full":"O tubo está cheio: passe fibra até {city} para levar o resto.", +"pie_traffic.bh_full_none":"todas as antenas ao alcance estão cheias", +"pie_traffic.bh_hint":"Uma cidade sem fibra até o seu backbone sobe todo o tráfego pela própria antena e desce numa do backbone. Toque numa linha para vê-la no globo.", +"pie_traffic.bh_line":"{g} de {cap} · desce em {dish} · +{ms} ms", +"pie_traffic.bh_nocrust":"nenhuma crosta assada lá em cima", +"pie_traffic.bh_noland":"nenhuma antena de pouso no seu backbone sob a mesma crosta", +"pie_traffic.bh_nolas":"nenhuma antena do seu backbone a até {km} km, e sem lasers para alcançar uma mais longe", +"pie_traffic.bh_spat":"uma briga mantém o tráfego longe de todas as antenas ao alcance", "pie_traffic.ck_backbone":"Uma antena no seu backbone", -"pie_traffic.ck_backbone_h":"{city} não tem fibra até o resto da sua rede, então só atende os vizinhos.", +"pie_traffic.ck_backbone_bh":"{city} não tem fibra até o resto da sua rede: a antena de lá pode fazer o backhaul do tráfego da própria cidade, mas de mais ninguém.", "pie_traffic.ck_backbone_none":"Suas antenas precisam de um POP que o seu backbone alcance.", +"pie_traffic.ck_backhaul":"Backhaul para cidades sem fibra", +"pie_traffic.ck_backhaul_h":"{city} não tem backhaul: {why}.", "pie_traffic.ck_baked":"Uma crosta pelo menos {min} cheia", "pie_traffic.ck_baked_none":"Lance tortas numa crosta até ela ficar assada.", "pie_traffic.ck_customers":"Clientes que usam a órbita", @@ -3615,6 +3627,7 @@ "pie_traffic.crust_half":"{crust} está {p} assada; leva tráfego a partir de {min}.", "pie_traffic.crust_safe":"O modo seguro está ligado: não leva nada até você desligar.", "pie_traffic.crusts":"Crostas", +"pie_traffic.d_backhaul":"faz o backhaul da própria cidade pela órbita", "pie_traffic.d_down":"fora de ação (uma retroescavadeira)", "pie_traffic.d_idle":"nenhum cliente usa ainda", "pie_traffic.d_isl":"isolada do seu backbone", @@ -3627,6 +3640,7 @@ "pie_traffic.d_ref":"direitos de pouso recusados por enquanto", "pie_traffic.d_spat":"direitos suspensos por uma briga até {d}", "pie_traffic.dish_line":"Terminais {t} · trânsito {x} · de {cap}", +"pie_traffic.dish_line_bh":"Terminais {t} · backhaul {b} · trânsito {x} · de {cap}", "pie_traffic.dishes":"Antenas-torta", "pie_traffic.empty_title":"Por que o meu céu está vazio?", "pie_traffic.headline":{"one":"Em órbita agora: {g} de {of} vendáveis · {amt}/mês · {n} cliente","other":"Em órbita agora: {g} de {of} vendáveis · {amt}/mês · {n} clientes"}, @@ -4522,6 +4536,7 @@ "traceroute.a_peer_s_customers_come_after":"os clientes de um peer vêm depois dos peers diretos e antes do transit", "traceroute.across_the_ix_switch":"pelo switch do {ix}", "traceroute.as_path_path":"AS path: {path}", +"traceroute.bh_why":"{city} não tem fibra até o seu backbone, então vai pela órbita e desce em {dish} (+{ms} ms ida e volta).", "traceroute.caches_beat_pnis":"caches vencem PNIs", "traceroute.circuits_through_orbit":"Circuitos pela órbita", "traceroute.city_your_router":"{city}, seu router", diff --git a/src/game/60-features/50-traceroute.js b/src/game/60-features/50-traceroute.js index 2f6e1e9..dcdcd87 100644 --- a/src/game/60-features/50-traceroute.js +++ b/src/game/60-features/50-traceroute.js @@ -4,10 +4,12 @@ const slug=t=>String(t).toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g,'').r // lowest latency, or the quietest links (one path; a scenic circuit may share the load between two). const TR_MODES=['normal','fast','scenic']; const trUtil=l=>{const c=capOf(l);return c>0?Math.max(0,((R.load&&R.load[l.id])||0)/c):0;}; -function trPaths(src,mode){const live=S.links.filter(l=>!linkDown(l)),rem=remoteCities(),ok=c=>popUp(c)||rem.includes(c),adj={}; +// bh: a cut-off POP whose backhaul through orbit (R.pie.bh, as compute() routed it) the trace may take: only to or from that POP. +function trPaths(src,mode,bh){const live=S.links.filter(l=>!linkDown(l)),rem=remoteCities(),ok=c=>popUp(c)||rem.includes(c),adj={}; // Every link between two cities costs what the pair costs, as in compute(); the trace shows an active link over one on standby. const pw={};for(const l of live){const k=edgeKey(l);pw[k]=Math.min(pw[k]??Infinity,pairW(k,l.km));} for(const l of live){if(!ok(l.a)||!ok(l.b))continue;const k=edgeKey(l),w=(mode==='fast'?linkLat(l)+0.05:mode==='scenic'?pw[k]*(1+10*trUtil(l)):pw[k])+(l.standby?1e-6:0);(adj[l.a]=adj[l.a]||[]).push([l.b,l,w]);(adj[l.b]=adj[l.b]||[]).push([l.a,l,w]);} + const B=trBh(bh);if(B){const l={id:'pie:bh:'+B.city,a:B.city,b:B.land,bh:B};(adj[l.a]=adj[l.a]||[]).push([l.b,l,PIE_BH_W]);(adj[l.b]=adj[l.b]||[]).push([l.a,l,PIE_BH_W]);} const dist={[src]:0},prev={},done=new Set();for(;;){let u=null,ud=Infinity;for(const k in dist)if(!done.has(k)&&dist[k]{if(dist[dst]===undefined)return null;const out=[];let v=dst;while(v!==src){const l=prev[v];out.unshift({l,from:l.a===v?l.b:l.a,to:v});v=l.a===v?l.b:l.a;}return out;};return {dist,path};} function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev.leak.net:null,out=[]; @@ -20,11 +22,18 @@ function trExits(net){const day=S.day,ev=S.ev,leak=ev.leak&&ev.leak.until>day?ev // 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);}} if(!(top in prev))return [top,id];const out=[];for(let x=top;x!==null;x=prev[x])out.push(x);return out;} -function traceroute(src,to,mode){mode=TR_MODES.includes(mode)?mode:'normal';const P=trPaths(src,mode),me=slug(S.name)+'.net',lines=[],ip=(a,b)=>`100.64.${a%250}.${b%250}`;let rtt=0.3,n=1; +// The backhaul of cut-off POP c, if it has one today. +const trBh=c=>c&&R&&R.pie&&R.pie.bh?R.pie.bh.find(b=>b.city===c&&b.cap>0)||null:null; +function traceroute(src,to,mode){mode=TR_MODES.includes(mode)?mode:'normal';const bh=trBh(src)?src:to.city&&trBh(to.city)?to.city:null,P=trPaths(src,mode,bh),me=slug(S.name)+'.net',lines=[],ip=(a,b)=>`100.64.${a%250}.${b%250}`;let rtt=0.3,n=1; const hop=(host,addr,extra,note)=>{rtt+=extra;lines.push(`${String(n++).padStart(2)} ${host} (${addr}) ${rtt.toFixed(1)} ms${note?' ← '+note:''}`);}; hop(`lo0.cr1.${src}.${me}`,ip(hstr(src),1),0,tr('traceroute.city_your_router',{city:CITY[src].name})); - const walk=path=>{for(const h of path){const l=h.l,lat=linkLat(l)*2+0.15;hop(`ae${1+hstr(l.id)%9}.cr1.${h.to}.${me}`,ip(hstr(h.to),2),lat,`${CITY[h.to].name} · ${l.kind==='df'?tr('common.own_dark_fiber'):l.kind==='vxc'?tr('common.fabric_circuit'):l.cable?CAB[l.cable].name:tr('common.terrestrial_wave')} · ${capName(l)}`);}}; - if(to.city){const path=P.path(to.city);lines.unshift(`traceroute to ${to.city}.${me} (${CITY[to.city].name}), 30 hops max`);if(!path){lines.push(' 2 * * * ← '+tr('traceroute.no_working_path_between_these_pops'));return {text:lines.join('\n'),why:tr('traceroute.no_path_every_route_between_these')};}walk(path);return {text:lines.join('\n'),why:S.te&&S.te.on?trn('traceroute.internal_path_over_n_link_chosen',path.length):trn('traceroute.internal_path_over_n_link_chosen_8620',path.length)};} + // Through orbit: up at one dish, across space with lasers, down at the other, each hop's round trip as compute() priced it. + const walk=path=>{for(const h of path){const l=h.l;if(l.bh){const b=l.bh,cr=CRUSTS[b.cr],e={bh:{city:b.city,land:b.land,cr:b.cr,las:b.las,km:b.km}}; + for(const x of pieBhHops(e,h.from===b.city)){const ms=x.ms*2+0.05;if(x.k==='up')hop(`dish.${x.city}.${me}`,ip(hstr(x.city),5),ms,tr('traceroute.sky_up',{city:CITY[x.city].name,crust:tr(cr.n)})); + else if(x.k==='las')hop(`laser.${b.cr}.${me}`,`10.255.${hstr(b.cr)%250}.${(x.km|0)%250}`,ms,tr('traceroute.sky_laser',{km:Math.round(x.km).toLocaleString()})); + else hop(`dish.${x.city}.${me}`,ip(hstr(x.city),6),ms,tr('traceroute.sky_down',{city:CITY[x.city].name}));}continue;} + const lat=linkLat(l)*2+0.15;hop(`ae${1+hstr(l.id)%9}.cr1.${h.to}.${me}`,ip(hstr(h.to),2),lat,`${CITY[h.to].name} · ${l.kind==='df'?tr('common.own_dark_fiber'):l.kind==='vxc'?tr('common.fabric_circuit'):l.cable?CAB[l.cable].name:tr('common.terrestrial_wave')} · ${capName(l)}`);}}; + if(to.city){const path=P.path(to.city);lines.unshift(`traceroute to ${to.city}.${me} (${CITY[to.city].name}), 30 hops max`);if(!path){lines.push(' 2 * * * ← '+tr('traceroute.no_working_path_between_these_pops'));return {text:lines.join('\n'),why:tr('traceroute.no_path_every_route_between_these')};}walk(path);const bw=trBhWhy(bh,path);return {text:lines.join('\n'),why:bw+(S.te&&S.te.on?trn('traceroute.internal_path_over_n_link_chosen',path.length):trn('traceroute.internal_path_over_n_link_chosen_8620',path.length))};} 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};} @@ -33,7 +42,7 @@ function traceroute(src,to,mode){mode=TR_MODES.includes(mode)?mode:'normal';cons 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]+(a.k==='ix'?PNI_TIE:0)-P.dist[b.city]-(b.k==='ix'?PNI_TIE:0)); - const e=ex.find(x=>x.usedx.usedS.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')}):''}.${direct}${e.used>=e.cap*0.999?' '+tr('traceroute.it_is_full_so_some_traffic'):''}${cn}`,asPath};} + return {text:lines.join('\n'),why:`${trBhWhy(bh,ep)}${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};} +// A note when the trace rode a cut-off POP's backhaul: why, and what orbit adds. +function trBhWhy(c,path){const b=trBh(c);return b&&path&&path.some(h=>h.l.bh)?tr('traceroute.bh_why',{city:CITY[c].name,dish:CITY[b.land].name,ms:pieMs(2*b.ms)})+' ':'';} // A circuit riding orbit (R.pie.flows, kind 'c'): its hops as compute() routed them, fiber legs, up, across space and down. const trSkyList=()=>R&&R.pie&&R.pie.flows?R.pie.flows.filter(f=>f.k==='c'&&f.hops&&f.hops.some(h=>h.k==='las')):[]; function trSky(id){const f=trSkyList().find(x=>x.id===id),b=f&&S.biz.find(x=>x.id===id);if(!f||!b)return null;const me=slug(S.name)+'.net',lines=[],ip=(a,c)=>`100.64.${a%250}.${c%250}`;let rtt=0.3,n=1; diff --git a/src/game/60-features/99-pie-in-the-sky.js b/src/game/60-features/99-pie-in-the-sky.js index 746010e..3c8b41b 100644 --- a/src/game/60-features/99-pie-in-the-sky.js +++ b/src/game/60-features/99-pie-in-the-sky.js @@ -13,7 +13,7 @@ dropped when o.until<=d by pieSpatDay(d) - S.pie.crusts[id].down: day a crust is out until (a solar storm); S.pie.dishes[i].down likewise (a backhoe) - pieGlobeData() -> {crusts:[{id,alt,inc,n,las}],dishes:[{city,lat,lon,up,u}],pads:[{city,lat,lon,next}], - launches:[{id,rk,cr,n,day,pad}],flows:[{id,k,g,pts:[city,city],alt?}],hi} + launches:[{id,rk,cr,n,day,pad}],flows:[{id,k:'c'|'t'|'b',g,pts:[city,city],alt?}],hi} - pieFounder(k,{n,c}) -> a Founder post (k from FOUNDER_POSTS); pieCharge(v) bills a cost (book kept) - book.earned: revenue from orbit, for the customers that come with routing. */ function pieBlank(day){const crusts={};for(const id in CRUSTS)crusts[id]={cohorts:[],queued:0}; @@ -36,9 +36,11 @@ const pieLicOk=cc=>{const l=S.pie&&S.pie.lic[cc];return !!l&&l.state==='ok'&&l.u function pieDishes(){const P=S&&S.pie;if(!P)return [];const o=[];for(const x of P.dishes){if(!S.pops[x.city]||x.down>S.day)continue;const cc=CITY[x.city].cc;if(pieLicOk(cc))o.push({id:x.id,city:x.city,cc,ant:x.ant,g:x.ant*PIE_ANT_G*pieDishMul(x)});}return o;} function pieHubs(){return S&&S.pie?Object.keys(CRUSTS).filter(pieUp):[];} function pieGlobeData(){const P=S&&S.pie;if(!P)return {crusts:[],dishes:[],pads:[],launches:[]};const ll=c=>({city:c,lat:CITY[c].lat,lon:CITY[c].lon}),Q=R&&R.pie,ld=Q&&Q.load||{}; - // Traffic from the last compute: sky circuits dish to dish (k 'c'), terminals from their city to their dish (k 't'). + // Traffic from the last compute: sky circuits dish to dish (k 'c'), terminals from their city to their dish (k 't'), and a + // cut-off POP's backhaul up from its dish and down at the landing dish (k 'b'). const flows=[];if(Q&&Q.flows)for(const f of Q.flows){if(!(f.g>0))continue;if(f.k==='c'&&f.via.length>1)flows.push({id:f.id,k:'c',g:f.g,pts:[f.via[0],f.via[f.via.length-1]],alt:f.cr?CRUSTS[f.cr].alt:550}); - else if(f.k==='t'&&f.dish)flows.push({id:f.id,k:'t',g:f.g,pts:[f.city,f.dish]});} + else if(f.k==='t'&&f.dish)flows.push({id:f.id,k:'t',g:f.g,pts:[f.city,f.dish]}); + else if(f.k==='b')flows.push({id:f.id,k:'b',g:f.g,pts:[f.city,f.dish],alt:CRUSTS[f.cr].alt});} return {crusts:Object.keys(CRUSTS).map(id=>({id,alt:CRUSTS[id].alt,inc:CRUSTS[id].inc,n:pieLive(id),las:pieLiveLas(id)})), dishes:P.dishes.map(x=>({...ll(x.city),up:!(x.down>S.day),u:ld[x.city]})),pads:P.pads.map(p=>({...ll(p.city),next:p.next})),launches:P.q.map(L=>({id:L.id,rk:L.rk,cr:L.cr,n:L.n,day:L.day,pad:L.pad})), flows:flows.sort((a,b)=>b.g-a.g),hi:UI.pieHi||null};} diff --git a/src/game/93-ui/86-pie-traffic.js b/src/game/93-ui/86-pie-traffic.js index 88ab332..d896e20 100644 --- a/src/game/93-ui/86-pie-traffic.js +++ b/src/game/93-ui/86-pie-traffic.js @@ -2,23 +2,26 @@ the last compute (R.pie: flows, crust, dish from 35-pie-paths.js); the fiber comparison is worked out only here (pieFiberMs, once per compute). The highlighted row (UI.pieHi) is display only and never saved. */ const PIE_ROWS=40; -const pieIcon=t=>({pizza:'🏡',flywifi:'✈️',boat:'🚢',marsorb:'🔴',mars:'🔴',hft:'📈'})[t]||'🔗'; +const pieIcon=t=>({pizza:'🏡',flywifi:'✈️',boat:'🚢',marsorb:'🔴',mars:'🔴',hft:'📈',bh:'🛰️'})[t]||'🔗'; const pieCn=c=>c&&CITY[c]?esc(CITY[c].name):'?'; const pieMs=v=>v<10?v.toFixed(1):String(Math.round(v)); // Bar colour by use: green, amber from 60%, red from 90% (the globe's rings and the map badge use the same steps). const pieLoadCls=u=>u>=0.9?'bad':u>=0.6?'warn':''; const pieBar=(u,cls)=>`
`; function pieDishWhy(d){const cc=CITY[d.city].cc,l=S.pie.lic[cc];return {nopop:tr('pie_traffic.d_nopop'),down:tr('pie_traffic.d_down'),lic:tr('pie_traffic.d_lic',{country:esc(pieLicCountry(cc))}), - ref:tr('pie_traffic.d_ref'),spat:tr('pie_traffic.d_spat',{d:l?dateStr(l.until):''}),nocrust:tr('pie_traffic.d_nocrust'),isl:tr('pie_traffic.d_isl'),rain:tr('pie_traffic.d_rain'), + ref:tr('pie_traffic.d_ref'),backhaul:tr('pie_traffic.d_backhaul'),spat:tr('pie_traffic.d_spat',{d:l?dateStr(l.until):''}),nocrust:tr('pie_traffic.d_nocrust'),isl:tr('pie_traffic.d_isl'),rain:tr('pie_traffic.d_rain'), jam:tr('pie_traffic.d_jam'),nolas:tr('pie_traffic.d_nolas'),idle:tr('pie_traffic.d_idle')}[d.st]||'';} function pieCrustWhy(c){return c.st==='half'?tr('pie_traffic.crust_half',{crust:tr(CRUSTS[c.id].n),p:pct(c.cov),min:pct(PIE_BAKED)}):c.st==='safe'?tr('pie_traffic.crust_safe'):c.st==='down'?tr('pie_traffic.crust_down'):'';} +// Why a cut-off POP gets no backhaul (R.pie.bh[].why from pieBhLand). +function pieBhWhy(w){return {nocrust:tr('pie_traffic.bh_nocrust'),noland:tr('pie_traffic.bh_noland'),nolas:tr('pie_traffic.bh_nolas',{km:PIE_BENT.toLocaleString()}),spat:tr('pie_traffic.bh_spat'),full:tr('pie_traffic.bh_full_none')}[w]||tr('pie_traffic.bh_noland');} // The empty sky: every condition traffic needs, ticked or not, with a hint for the first thing to fix. -function pieChecks(Q){const P=S.pie,cr=Q.crust,best=cr.slice().sort((a,b)=>b.cov-a.cov)[0],ds=Q.dish,isl=ds.find(d=>d.st==='isl'); +function pieChecks(Q){const P=S.pie,cr=Q.crust,best=cr.slice().sort((a,b)=>b.cov-a.cov)[0],ds=Q.dish,isl=ds.find(d=>d.st==='isl'),bh=Q.bh||[],no=bh.find(b=>!(b.cap>0)); const sold=S.biz.some(b=>BIZ_T[b.type].orbit||(BIZ_T[b.type].lat&&b.route==='fast'&&b.city2&&pieKm(b.city,b.city2)>=PIE_MIN_KM)); return [ {k:'baked',ok:Q.hubs.length>0,l:tr('pie_traffic.ck_baked',{min:pct(PIE_BAKED)}),h:!best?tr('pie_traffic.ck_baked_none'):pieCrustWhy(best)||tr('pie_traffic.ck_baked_none')}, {k:'dish',ok:ds.some(d=>d.cap>0),l:tr('pie_traffic.ck_dish'),h:P.dishes.length?tr('pie_traffic.ck_dish_lic'):tr('pie_traffic.ck_dish_none')}, - {k:'backbone',ok:ds.some(d=>d.cap>0&&!Q.isl.includes(d.city)),l:tr('pie_traffic.ck_backbone'),h:Q.isl.length?tr('pie_traffic.ck_backbone_h',{city:pieCn(isl?isl.city:Q.isl[0])}):tr('pie_traffic.ck_backbone_none')}, + {k:'backbone',ok:ds.some(d=>d.cap>0&&!Q.isl.includes(d.city)),l:tr('pie_traffic.ck_backbone'),h:Q.isl.length?tr('pie_traffic.ck_backbone_bh',{city:pieCn(isl?isl.city:Q.isl[0])}):tr('pie_traffic.ck_backbone_none')}, + ...(Q.isl.length?[{k:'backhaul',ok:bh.some(b=>b.cap>0)&&!no,l:tr('pie_traffic.ck_backhaul'),h:no?tr('pie_traffic.ck_backhaul_h',{city:pieCn(no.city),why:pieBhWhy(no.why)}):''}]:[]), {k:'lasers',ok:cr.some(c=>c.las),l:tr('pie_traffic.ck_lasers'),h:tr('pie_traffic.ck_lasers_h')}, {k:'customers',ok:sold,l:tr('pie_traffic.ck_customers'),h:tr('pie_traffic.ck_customers_h',{km:PIE_MIN_KM.toLocaleString()})}];} function pieFlowRow(f,B){const b=B.get(f.id),hi=UI.pieHi===f.id,nm=b?esc(b.name):'?';let route,ms=''; @@ -28,18 +31,26 @@ function pieFlowRow(f,B){const b=B.get(f.id),hi=UI.pieHi===f.id,nm=b?esc(b.name) return ``;} +// A cut-off POP's backhaul: how full the pipe is, where it lands and what orbit adds, or why it has none. Tap: the globe shows it. +function pieBhRow(b){const id='bh:'+b.city,hi=UI.pieHi===id; + if(!(b.cap>0))return `
🛰️ ${tr('pie_traffic.bh_for',{city:pieCn(b.city)})}–

${pieBhWhy(b.why)}

`; + const u=b.g/b.cap; + return `
${pieBar(u,pieLoadCls(u))}${u>=0.9?`

${tr('pie_traffic.bh_full',{city:pieCn(b.city)})}

`:''}
`;} function pieTrafficHtml(){const Q=R&&R.pie;if(!Q||!Q.flows)return `

${tr('pie_traffic.no_data')}

`; - const fl=Q.flows.filter(f=>f.g>0||f.k==='t').sort((a,b)=>b.g-a.g),g=fl.reduce((a,f)=>a+f.g,0),n=fl.filter(f=>f.g>0).length,B=new Map(S.biz.map(b=>[b.id,b])); + const bh=Q.bh||[],bg=bh.reduce((a,b)=>a+b.g,0),fl=Q.flows.filter(f=>f.k!=='b'&&(f.g>0||f.k==='t')).sort((a,b)=>b.g-a.g),g=fl.reduce((a,f)=>a+f.g,0),n=fl.filter(f=>f.g>0).length,B=new Map(S.biz.map(b=>[b.id,b])); let h=`

${trn('pie_traffic.headline',n,{g:fmtG(g),of:fmtG(pieMarket()),amt:fmt$(Q.rev)})}

`; - if(!(g>0))h+=`
${tr('pie_traffic.empty_title')}
    ${pieChecks(Q).map(c=>`
  • ${c.l}${c.ok?'':`${c.h}`}
  • `).join('')}
`; + if(!(g>0)&&!(bg>0))h+=`
${tr('pie_traffic.empty_title')}
    ${pieChecks(Q).map(c=>`
  • ${c.l}${c.ok?'':`${c.h}`}
  • `).join('')}
`; h+=`

${tr('pie_traffic.crusts')}

`+(Q.crust.length?Q.crust.map(c=>{const why=pieCrustWhy(c); return `
${tr(CRUSTS[c.id].n)} ${pieTag(c.st==='half'?tr('pie.half_baked'):tr('pie.baked'),c.st!=='half')}${c.cap>0?tr('pie_traffic.used_of',{u:fmtG(c.used),cap:fmtG(c.cap)}):pct(c.cov)}
${c.cap>0?pieBar(c.used/c.cap,pieLoadCls(c.used/c.cap)):pieBar(c.cov/PIE_BAKED,'warn')}${why?`

${why}

`:''}
`;}).join(''):`

${tr('pie_traffic.ck_baked_none')}

`); + if(bh.length)h+=`

${tr('pie_traffic.backhaul')}

${tr('pie_traffic.bh_hint')}

`+bh.slice().sort((a,b)=>b.g-a.g).map(pieBhRow).join(''); if(fl.length){h+=`

${tr('pie_traffic.riding')}

${tr('pie_traffic.tap_hint')}

${fl.slice(0,PIE_ROWS).map(f=>pieFlowRow(f,B)).join('')}
`; if(fl.length>PIE_ROWS)h+=`

${trn('pie_traffic.n_more',fl.length-PIE_ROWS)}

`;} if(Q.dish.length)h+=`

${tr('pie_traffic.dishes')}

`+Q.dish.slice().sort((a,b)=>b.used-a.used).map(d=>{const why=d.st==='ok'?'':pieDishWhy(d); return `
📡 ${pieCn(d.city)}${d.cap>0?pct(d.u):'–'}
${pieBar(d.u,pieLoadCls(d.u))} -

${tr('pie_traffic.dish_line',{t:fmtG(d.term),x:fmtG(d.transit),cap:fmtG(d.cap)})}${why?` · ${why}`:''}

`;}).join(''); +

${d.bh>0?tr('pie_traffic.dish_line_bh',{t:fmtG(d.term),b:fmtG(d.bh),x:fmtG(d.transit),cap:fmtG(d.cap)}):tr('pie_traffic.dish_line',{t:fmtG(d.term),x:fmtG(d.transit),cap:fmtG(d.cap)})}${why?` · ${why}`:''}

`;}).join(''); return h;} // Tapping a row: mark it in place and point the globe at it, without rebuilding the panel (the scroll stays where it is). function pieHiSet(id){UI.pieHi=UI.pieHi===id?null:id; diff --git a/src/game/96-map/89-pie-globe.js b/src/game/96-map/89-pie-globe.js index 275b227..2c11088 100644 --- a/src/game/96-map/89-pie-globe.js +++ b/src/game/96-map/89-pie-globe.js @@ -4,7 +4,7 @@ by itself (pieGlobeClose()) once the canvas leaves the page. Positions come from the clock, so nothing is saved. Traffic (data.flows, from the last compute): a sky circuit is a glowing arc from one dish up to its crust, across and down to the other, as wide as its Gbps (log scale, capped), with packets riding it; a terminal customer is a hop from - its city off the sky to its dish. Each dish has a load ring. data.hi (a flow id) is drawn on top, the rest dimmed. */ + its city off the sky to its dish; a cut-off POP's backhaul (k 'b') is drawn like a sky circuit. Each dish has a load ring. data.hi (a flow id) is drawn on top, the rest dimmed. */ const PG_FLOWS=[24,48],PG_ARC=24,PG_D=Math.PI/180,PG_XF=2.6,PG_FPS=30,PG_FULL={short:1584,frozen:520,upper:1200,flaky:2500},PG_CI={short:0,frozen:1,upper:2,flaky:3}; const PG_ST={ day:{sea:'#57C4E5',sea2:'#3AA6CF',land:'#9BDA6C',ink:'#1E2640',grid:'rgba(255,255,255,.35)',sat:['#FFFFFF','#FFD23F','#FF4F9A','#B9A6FF'],laser:'#FF4F9A',beam:['#FF8A3D','#FFD23F'],dish:'#FF4F9A',off:'#8A91A8',flow:'#FFD23F',fglow:'#1E2640',hi:'#FF4F9A',pkt:'#FFFFFF'}, @@ -48,7 +48,7 @@ function pgRefresh(now){PG.dAt=now;let d=null;try{d=PG.get?PG.get():null;}catch( function pgFlows(list,cap,hi){const out=[],L=pgArr(list),seen=new Set();let n=0; const take=f=>{if(!f||typeof f.id!=='string'||seen.has(f.id))return;const g=pgNum(f.g,0),pts=pgPlace(pgArr(f.pts).map(c=>({city:c})),2);if(!(g>0)||pts.length<2)return; const a=pts[0].v,b=pts[1].v,dot=Math.max(-1,Math.min(1,a[0]*b[0]+a[1]*b[1]+a[2]*b[2])),om=Math.acos(dot);if(om<1e-3)return;seen.add(f.id); - const sky=f.k==='c',h=(sky?Math.max(200,Math.min(2000,pgNum(f.alt,550))):550)/6371*PG_XF,raw=new Float32Array((PG_ARC+1)*3),so=Math.sin(om); + const sky=f.k==='c'||f.k==='b',h=(sky?Math.max(200,Math.min(2000,pgNum(f.alt,550))):550)/6371*PG_XF,raw=new Float32Array((PG_ARC+1)*3),so=Math.sin(om); for(let i=0;i<=PG_ARC;i++){const s=i/PG_ARC,p=Math.sin((1-s)*om)/so,q=Math.sin(s*om)/so,r=1+h*(sky?Math.min(1,s/0.15,(1-s)/0.15):Math.sin(Math.PI*s)); raw[i*3]=(p*a[0]+q*b[0])*r;raw[i*3+1]=(p*a[1]+q*b[1])*r;raw[i*3+2]=(p*a[2]+q*b[2])*r;} out.push({id:f.id,sky,w:Math.min(7,1.2+1.5*Math.log10(1+g)),raw,pos:new Float32Array(raw.length),pk:Math.min(4,1+Math.floor(Math.log10(1+g)))});}; diff --git a/src/i18n/en.js b/src/i18n/en.js index bf4b110..f7f0ce2 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -3600,9 +3600,21 @@ "pie_spat.pad_r1":"You declined. Everyone shook hands anyway.", "pie_spat.pad_t":"Launch diplomacy", "pie_spat.pad_won":"Ribbon cut: a free launch pad in {city}.", +"pie_traffic.backhaul":"Backhaul", +"pie_traffic.bh_for":"Backhaul for {city}", +"pie_traffic.bh_full":"The pipe is full: lay fiber to {city} to carry the rest.", +"pie_traffic.bh_full_none":"every dish in reach is full", +"pie_traffic.bh_hint":"A town with no fiber to your backbone sends all its traffic up its own dish and down at one on the backbone. Tap a row to show it on the globe.", +"pie_traffic.bh_line":"{g} of {cap} · lands at {dish} · +{ms} ms", +"pie_traffic.bh_nocrust":"no baked crust overhead", +"pie_traffic.bh_noland":"no landing dish on your backbone under the same crust", +"pie_traffic.bh_nolas":"no dish on your backbone within {km} km, and no lasers to reach one further away", +"pie_traffic.bh_spat":"a spat keeps its traffic off every dish in reach", "pie_traffic.ck_backbone":"A dish on your backbone", -"pie_traffic.ck_backbone_h":"{city} has no fiber to the rest of your network, so it only serves its own neighbours.", +"pie_traffic.ck_backbone_bh":"{city} has no fiber to the rest of your network: its dish can backhaul the town's own traffic, but carries nobody else's.", "pie_traffic.ck_backbone_none":"Your dishes need a POP that your backbone reaches.", +"pie_traffic.ck_backhaul":"Backhaul for towns with no fiber", +"pie_traffic.ck_backhaul_h":"{city} has no backhaul: {why}.", "pie_traffic.ck_baked":"A crust at least {min} full", "pie_traffic.ck_baked_none":"Launch pies into a crust until it is baked.", "pie_traffic.ck_customers":"Customers who use orbit", @@ -3616,6 +3628,7 @@ "pie_traffic.crust_half":"{crust} is {p} baked; it carries traffic from {min}.", "pie_traffic.crust_safe":"Safe mode is on: it carries nothing until you turn it off.", "pie_traffic.crusts":"Crusts", +"pie_traffic.d_backhaul":"backhauls its own town through orbit", "pie_traffic.d_down":"out of action (a backhoe)", "pie_traffic.d_idle":"no customers use it yet", "pie_traffic.d_isl":"cut off from your backbone", @@ -3628,6 +3641,7 @@ "pie_traffic.d_ref":"landing rights refused for now", "pie_traffic.d_spat":"rights suspended by a spat until {d}", "pie_traffic.dish_line":"Terminals {t} · transit {x} · of {cap}", +"pie_traffic.dish_line_bh":"Terminals {t} · backhaul {b} · transit {x} · of {cap}", "pie_traffic.dishes":"Pie dishes", "pie_traffic.empty_title":"Why is my sky empty?", "pie_traffic.headline":{"one":"In orbit now: {g} of {of} sellable · {amt}/mo · {n} customer","other":"In orbit now: {g} of {of} sellable · {amt}/mo · {n} customers"}, @@ -4523,6 +4537,7 @@ "traceroute.a_peer_s_customers_come_after":"a peer’s customers come after direct peers, before transit", "traceroute.across_the_ix_switch":"across the {ix} switch", "traceroute.as_path_path":"AS path: {path}", +"traceroute.bh_why":"{city} has no fiber to your backbone, so it goes through orbit and lands at {dish} (+{ms} ms round trip).", "traceroute.caches_beat_pnis":"caches beat PNIs", "traceroute.circuits_through_orbit":"Circuits through orbit", "traceroute.city_your_router":"{city}, your router", diff --git a/tests/pie-backhaul.test.js b/tests/pie-backhaul.test.js new file mode 100644 index 0000000..934ed2e --- /dev/null +++ b/tests/pie-backhaul.test.js @@ -0,0 +1,248 @@ +// Pie in the Sky: backhaul. A POP with no fiber to the backbone sends all its own traffic up its pie dish and down at a +// landing dish on the backbone (src/game/80-simulation/35-pie-paths.js, rule O3). Seeded; state is set directly. +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const { load } = require('./harness'); + +// A backbone London – New York – Auckland with transit in London and New York, full dishes with landing rights there, a +// full lasered Shortcrust, and Pitcairn (Adamstown): a POP of its own with broadband, no cable, and a dish. +const world = (ev, opt = {}) => { + ev("ACT.modeSet({m:'sandbox'});ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.nextFail=1e9;S.nextEvent=1e9"); + ev("for(const c of ['lon','nyc','akl','pcn'])if(!S.pops[c])ACT.buildPop({city:c});S.links=[];" + + "S.links.push({id:'ln',a:'lon',b:'nyc',kind:'wave',tier:3,km:5818,sub:true,cable:'grace',cut:0,mo:1},{id:'na',a:'nyc',b:'akl',kind:'wave',tier:3,km:14200,sub:true,cut:0,mo:1});for(const c of ['lon','nyc'])ACT.buyTransit({city:c,net:'cog',tier:1});ACT.buyTransit({city:'akl',net:'sgt',tier:1})"); + ev(`ACT.pieFound();for(const c of ${JSON.stringify(opt.dishes || ['lon', 'nyc', 'akl', 'pcn'])}){ACT.pieDish({city:c});S.pie.lic[CITY[c].cc]={state:'ok',until:1e6};}for(const x of S.pie.dishes)x.ant=PIE_ANT_MAX`); + ev(`S.pops.pcn.bb={d:${opt.d || 5}};S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:${opt.las !== false}}];compute()`); +}; +const J = (ev, x) => JSON.parse(ev(`JSON.stringify(${x})`)); +const bh = (ev, c = 'pcn') => J(ev, `R.pie.bh.find(b=>b.city==='${c}')||null`); +const st = (ev, c = 'pcn') => ev(`R.pie.dish.find(d=>d.city==='${c}').st`); +const doc = (dom) => dom.window.document; + +test('Pitcairn with a dish reaches the backbone through orbit: all its traffic lands at Auckland', () => { + const { ev, errors } = load(); + world(ev, { dishes: ['lon', 'nyc', 'akl'] }); + assert.equal(ev("sfOf(R,'pcn')"), 0, 'no dish: Pitcairn is cut off and served by nobody'); + ev("ACT.pieDish({city:'pcn'});S.pie.lic.PN={state:'ok',until:1e6};for(const x of S.pie.dishes)x.ant=PIE_ANT_MAX;compute()"); + assert.deepEqual(J(ev, 'R.pie.isl'), ['pcn'], 'still off the backbone'); + const b = bh(ev); + assert.equal(b.land, 'akl', 'the fastest landing dish'); + assert.equal(b.las, true, 'Auckland is 5,300 km away: lasers'); + const km = ev("pieKm('pcn','akl')"); + assert.ok(Math.abs(b.ms - ev(`pieSkyMs(${km},CRUSTS.short.alt)`)) < 1e-9, `latency is the orbit path: ${b.ms} ms`); + assert.ok(b.ms > 20 && b.ms < 30, `${b.ms} ms one way`); + assert.equal(b.cap, ev("pieDishes().find(d=>d.city==='pcn').g"), 'capacity: the dish (nothing else uses it)'); + assert.ok(ev('R.citySrv.pcn/R.cityDem.pcn') > 0.95, `served ${ev('R.citySrv.pcn/R.cityDem.pcn')}`); + assert.ok(Math.abs(b.g - ev('R.citySrv.pcn')) < 0.5, 'what it carries is what Pitcairn gets'); + // Every Gbps on the backhaul is Pitcairn's. + assert.deepEqual(Object.keys(J(ev, "R.ef['pie:bh:pcn'].dst")), ['pcn']); + assert.equal(st(ev), 'backhaul'); + assert.equal(st(ev, 'akl'), 'ok', 'the landing dish carries it'); + assert.ok(ev("R.pie.dish.find(d=>d.city==='akl').bh") > 4); + assert.ok(ev('R.pie.load.pcn') > 0 && ev('R.pie.load.akl') > 0, 'load rings include backhaul'); + const f = J(ev, "R.pie.flows.find(f=>f.k==='b')"); + assert.deepEqual([f.id, f.city, f.dish], ['bh:pcn', 'pcn', 'akl']); + assert.deepEqual(f.hops.map((h) => h.k), ['up', 'las', 'down']); + assert.ok(Math.abs(f.hops.reduce((a, h) => a + h.ms, 0) - b.ms) < 1e-9); + const cr = J(ev, "R.pie.crust.find(c=>c.id==='short')"); + assert.ok(Math.abs(cr.used - b.g) < 1e-6, `the crust counts what the backhaul carries (${cr.used}), not what it may (${b.cap})`); + // Its users notice the round trip through orbit, like any far exit (#…): 50 ms is where broadband turns bad. + assert.ok(Math.abs(ev('R.latFar.pcn.ms') - 2 * b.ms) < 0.5, 'the exit is one orbit hop away'); + assert.ok(ev('R.latF.pcn') < 1 && ev("sfOf(R,'pcn')") > 0.3); + assert.deepEqual(errors, []); +}); + +test('the pipe is small: a big island POP fills it and the rest is dropped', () => { + const { ev, errors } = load(); + world(ev, { d: 300 }); + ev("S.pie.dishes.find(x=>x.city==='pcn').ant=1;compute()"); + const b = bh(ev); + assert.equal(b.cap, ev('PIE_ANT_G'), 'one antenna'); + assert.ok(b.g >= b.cap - 1e-6 && b.g <= b.cap + 1e-6, `full: ${b.g} of ${b.cap}`); + assert.ok(ev("sfOf(R,'pcn')") < 0.1, 'most of the demand is dropped'); + assert.ok(ev('R.cityDem.pcn') > 10 * b.cap); + // The landing dish's room caps it too: Auckland already full of terminals. + ev("S.pie.dishes.find(x=>x.city==='pcn').ant=PIE_ANT_MAX;S.pie.dishes.find(x=>x.city==='akl').ant=1;compute()"); + assert.ok(bh(ev).cap <= ev('PIE_ANT_G') + 1e-9 || bh(ev).land !== 'akl', 'never more than the landing dish holds'); + for (const d of J(ev, 'R.pie.dish')) assert.ok(d.used <= d.cap + 1e-6, `${d.city}: ${d.used} on ${d.cap}`); + // Laying fiber is the real fix: Pitcairn joins the backbone and the backhaul goes away. + ev("S.links.push({id:'pa',a:'pcn',b:'akl',kind:'wave',tier:3,km:5400,sub:true,cut:0,mo:1});compute()"); + assert.deepEqual(J(ev, 'R.pie.isl'), []); + assert.deepEqual(J(ev, 'R.pie.bh'), []); + assert.equal(ev("Object.keys(R.ef).some(k=>k.startsWith('pie:bh:'))"), false); + assert.deepEqual(errors, []); +}); + +test('POPs on the backbone never route bulk traffic through orbit, and one island never carries another', () => { + const { ev, errors } = load(); + world(ev); + ev("ACT.buildPop({city:'hnl'});ACT.pieDish({city:'hnl'});for(const x of S.pie.dishes)x.ant=PIE_ANT_MAX;S.pops.hnl.bb={d:5};S.pops.lon.bb={d:20};S.pops.nyc.bb={d:20};S.pops.akl.bb={d:5};compute()"); + assert.deepEqual(J(ev, 'R.pie.isl').sort(), ['hnl', 'pcn']); + ev("S.biz.push({id:'h1',type:'hft',city:'lon',city2:'akl',bw:5,rate:1,reqs:[],latMax:null,route:'fast',name:'h1',mood:100,since:0,sites:null},{id:'v1',type:'l2vpn',city:'nyc',city2:'lon',bw:5,rate:1,reqs:[],latMax:null,route:'normal',name:'v1',mood:100,since:0,sites:null});compute()"); + for (const c of ['pcn', 'hnl']) { + const ef = J(ev, `R.ef['pie:bh:${c}']`); + assert.deepEqual(Object.keys(ef.dst), [c], `only ${c}'s traffic on its backhaul`); + assert.ok(!ef.eg['l2:h1'] && !ef.eg['l2:v1'], 'no circuit between other cities'); + } + // Every other orbit edge carries only latency circuits. + assert.ok(ev("Object.keys(R.ef).filter(k=>k.startsWith('pie:')&&!k.startsWith('pie:bh:')).every(k=>Object.keys(R.ef[k].eg).every(e=>e.startsWith('l2:')))")); + assert.ok(ev("sfOf(R,'lon')") > 0.95 && ev("sfOf(R,'akl')") > 0.95); + // A circuit from Pitcairn is Pitcairn's own traffic: carried, in either order. + ev("S.biz.push({id:'p1',type:'l2vpn',city:'lon',city2:'pcn',bw:2,rate:1,reqs:[],latMax:null,route:'normal',name:'p1',mood:100,since:0,sites:null},{id:'p2',type:'hft',city:'pcn',city2:'lon',bw:2,rate:1,reqs:[],latMax:null,route:'fast',name:'p2',mood:100,since:0,sites:null});compute()"); + assert.equal(ev('R.l2.p1'), 2); + assert.equal(ev('R.l2.p2'), 2); + assert.ok(ev("R.ef['pie:bh:pcn'].eg['l2:p1']") > 0 && ev("R.ef['pie:bh:pcn'].eg['l2:p2']") > 0); + assert.ok(ev('R.l2lat.p1') > bh(ev).ms, 'and pays the orbit latency'); + assert.deepEqual(errors, []); +}); + +test('backhaul goes when the sky does: safe mode, a storm, no lasers, no landing rights, a spat, a backhoe', () => { + const { ev, errors } = load(); + world(ev); + const cut = (setup, why, msg) => { + ev(`${setup};compute()`); + const b = bh(ev); + assert.ok(!b || !(b.cap > 0), `${msg}: still backhauling`); + if (why) assert.equal(b.why, why, msg); + assert.ok(ev("sfOf(R,'pcn')") < 0.01, `${msg}: Pitcairn is cut off again`); + assert.equal(ev("Object.keys(R.ef).some(k=>k==='pie:bh:pcn')"), false); + }; + const back = (setup) => { ev(`${setup};compute()`); assert.ok(bh(ev).cap > 0, `back after ${setup}`); }; + cut('S.pie.safe=true', 'nocrust', 'safe mode'); + assert.equal(st(ev), 'nocrust'); + back('S.pie.safe=false'); + cut('S.pie.crusts.short.down=S.day+5', 'nocrust', 'crust down'); + back('delete S.pie.crusts.short.down'); + cut("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:false}]", 'nolas', 'no lasers and no dish within 1,000 km'); + back("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:true}]"); + // Landing rights: without New Zealand's it lands in New York; without any on the backbone it has nowhere to go. + ev("delete S.pie.lic.NZ;compute()"); + assert.equal(bh(ev).land, 'nyc'); + cut("delete S.pie.lic.US;delete S.pie.lic.GB", 'noland', 'no landing dish'); + back("for(const c of ['NZ','US','GB'])S.pie.lic[c]={state:'ok',until:1e6}"); + cut("delete S.pie.lic.PN", null, 'no landing rights on Pitcairn'); + back("S.pie.lic.PN={state:'ok',until:1e6}"); + // Spats: data stays home (Pitcairn has no other dish), not over my airspace (avoid New Zealand's). + cut("S.pie.spat.home={st:'on',cc:'PN',ask:S.day,until:S.day+90,c:0}", 'spat', 'data stays home'); + back('delete S.pie.spat.home'); + ev("S.pie.spat.air={st:'on',cc:'PN',cc2:'NZ',ask:S.day,until:S.day+90,c:0};compute()"); + assert.equal(bh(ev).land, 'nyc', 'not over my airspace: lands in New York instead'); + ev('delete S.pie.spat.air'); + cut("S.pie.dishes.find(x=>x.city==='pcn').down=S.day+3", null, 'a backhoe at the dish'); + assert.equal(st(ev), 'down'); + back("S.pie.dishes.find(x=>x.city==='pcn').down=0"); + assert.deepEqual(errors, []); +}); + +test('bent pipe: a cut-off town within 1,000 km lands without lasers', () => { + const { ev, errors } = load(); + ev("ACT.modeSet({m:'sandbox'});ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.nextFail=1e9;S.nextEvent=1e9;for(const c of ['syd','mel','cbr'])if(!S.pops[c])ACT.buildPop({city:c});S.links=[{id:'sm',a:'syd',b:'mel',kind:'wave',tier:3,km:710,sub:false,cut:0,mo:1}];ACT.buyTransit({city:'syd',net:'cog',tier:1})"); + ev("ACT.pieFound();for(const c of ['syd','cbr']){ACT.pieDish({city:c});}S.pie.lic.AU={state:'ok',until:1e6};S.pops.cbr.bb={d:3};S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:false}];compute()"); + const b = bh(ev, 'cbr'); + assert.equal(b.land, 'syd'); + assert.equal(b.las, false); + assert.ok(b.cap > 0 && b.g > 2.5, `${b.g} of ${b.cap}`); + assert.deepEqual(J(ev, "R.pie.flows.find(f=>f.id==='bh:cbr').hops").map((h) => h.k), ['up', 'down']); + assert.ok(ev('R.citySrv.cbr/R.cityDem.cbr') > 0.9); + assert.deepEqual(errors, []); +}); + +test("a cut-off dish says 'backhaul' or 'isl', even with its own terminals (no more 'ok' by mistake)", () => { + const { ev, errors } = load(); + world(ev, { las: false }); + ev("S.biz.push({id:'pz',type:'pizza',city:'pcn',city2:null,bw:5,rate:BIZ_T.pizza.rate,reqs:[],latMax:null,route:'normal',name:'pz',mood:100,since:0,sites:null});compute()"); + assert.equal(ev('R.pie.gs.pz'), 'pcn', 'the home lands on the island dish'); + assert.ok(ev("R.pie.dish.find(d=>d.city==='pcn').used") > 0, 'which carries its terminal'); + assert.equal(st(ev), 'isl', 'cut off, no lasers: not ok'); + assert.match(ev("pieDishWhy(R.pie.dish.find(d=>d.city==='pcn'))"), /cut off from your backbone/); + ev("S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:true}];compute()"); + assert.equal(st(ev), 'backhaul'); + assert.ok(ev('R.pie.sf.pz') > 0.3, 'and the home now reaches the internet through the backhaul'); + assert.ok(ev("R.pie.dish.find(d=>d.city==='pcn').term") > 0); + assert.deepEqual(errors, []); +}); + +test('the Traffic tab shows backhaul at 360 px, why it is missing, and taps highlight it on the globe', () => { + const { dom, ev, errors } = load(); + ev('window.innerWidth=360'); + world(ev, { d: 300 }); + ev("S.pie.dishes.find(x=>x.city==='pcn').ant=2;compute();UI.pieTab=null;ACT.pieOpen()"); + try { + const d = doc(dom); + const card = () => d.querySelector('#modalCard'); + let txt = card().textContent.replace(/\s+/g, ' '); + assert.match(txt, /Backhaul /); + const row = card().querySelector('.pft-row[data-fid="bh:pcn"]'); + assert.ok(row, 'a backhaul row'); + assert.match(row.textContent.replace(/\s+/g, ' '), /Backhaul for Adamstown.*40\.0 Gbps of 40\.0 Gbps · lands at Auckland · \+2\d ms/); + assert.ok(row.parentNode.querySelector('.bar.bad'), 'a full pipe shows red'); + assert.match(txt, /The pipe is full: lay fiber to Adamstown/); + assert.match(txt, /Terminals .* · backhaul .* · transit .* · of /); + assert.match(txt, /backhauls its own town through orbit/); + assert.equal(/style="[^"]*width:\s*\d{3,}px/.test(card().innerHTML), false, 'no fixed widths'); + row.click(); + assert.equal(ev('UI.pieHi'), 'bh:pcn'); + assert.equal(card().querySelector('.pft-row.on').dataset.fid, 'bh:pcn'); + const g = J(ev, 'pieGlobeData()'); + const f = g.flows.find((x) => x.id === 'bh:pcn'); + assert.deepEqual([f.k, f.pts], ['b', ['pcn', 'akl']]); + assert.equal(g.hi, 'bh:pcn'); + ev("const cv=document.createElement('canvas');document.body.appendChild(cv);pieGlobeOpen(cv,pieGlobeData)"); + assert.equal(ev('pgFrame(1000,true)'), true); + assert.equal(ev('PG.fl[0].id'), 'bh:pcn', 'drawn on top'); + assert.equal(ev('PG.fl[0].sky'), true, 'an arc through the sky'); + ev('pieGlobeClose()'); + // In safe mode the sky is empty and the checklist says why Pitcairn has no backhaul. + ev("UI.pieHi=null;S.pie.safe=true;compute();ACT.pieTab({t:'traffic'})"); + txt = card().textContent.replace(/\s+/g, ' '); + assert.match(txt, /Why is my sky empty\?/); + assert.match(txt, /Backhaul for Adamstown – no baked crust overhead|Backhaul for Adamstown.*no baked crust overhead/); + const ck = Object.fromEntries([...card().querySelectorAll('.pft-ck li')].map((li) => [li.dataset.k, li.className])); + assert.equal(ck.backhaul, 'off'); + assert.match(txt, /Adamstown has no backhaul: no baked crust overhead\./); + } finally { ev('closeModal()'); } + assert.deepEqual(errors, []); +}); + +test('the traceroute to and from a cut-off POP shows the orbit hops', () => { + const { dom, ev, errors } = load(); + world(ev); + ev("traceModal('pcn','net:ggl')"); + const d = doc(dom); + let pre = d.querySelector('#modalCard pre').textContent; + assert.match(pre, /↑ uplink at Adamstown \(Shortcrust \(550 km\)\)/); + assert.match(pre, /laser across space 5,\d{3} km/); + assert.match(pre, /↓ downlink at Auckland/); + assert.doesNotMatch(pre, /\* \* \*/); + assert.match(d.querySelector('#modalCard .note').textContent, /Adamstown has no fiber to your backbone, so it goes through orbit and lands at Auckland \(\+\d+ ms round trip\)/); + ev("traceModal('lon','city:pcn')"); + pre = d.querySelector('#modalCard pre').textContent; + assert.match(pre, /↑ uplink at Auckland/); + assert.match(pre, /↓ downlink at Adamstown/); + // Between two POPs on the backbone the trace never takes the backhaul. + ev("traceModal('lon','city:akl')"); + assert.doesNotMatch(d.querySelector('#modalCard pre').textContent, /uplink|downlink/); + ev('closeModal()'); + assert.deepEqual(errors, []); +}); + +test('saves without pies, and pie saves whose POPs are all connected, route as before', () => { + const { ev, errors } = load(); + const save = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8'); + ev(`S=migrate(JSON.parse(${JSON.stringify(save)}));compute()`); + assert.equal(ev('S.pie'), null); + const out = () => ev("JSON.stringify([R.served,R.demand,R.egT,R.load,R.l2,R.l2lat,R.citySrv])"); + const a = out(); + // A rocket company with a baked, lasered crust and dishes at three connected POPs: nothing to backhaul, nothing moves. + ev("window.__rl=0;const o=pieRelink;pieRelink=function(){__rl++;return o.apply(this,arguments);};S.pieV=1;pieInit();S.pie.co={name:'X'};const ps=Object.keys(S.pops).filter(popUp).slice(0,6);for(const c of ps){S.pie.dishes.push({id:'d'+c,city:c,ant:PIE_ANT_MAX,down:0});S.pie.lic[CITY[c].cc]={state:'ok',until:1e6};}S.pie.crusts.short.cohorts=[{n:CRUSTS.short.full,day:S.day,las:true}];compute()"); + // (the fixture has POPs off its backbone: keep only the dishes on it) + ev("const isl=new Set(R.pie.isl);S.pie.dishes=S.pie.dishes.filter(x=>!isl.has(x.city));__rl=0;compute()"); + assert.ok(ev('S.pie.dishes.length') >= 1); + assert.deepEqual(J(ev, 'R.pie.isl'), []); + assert.deepEqual(J(ev, 'R.pie.bh'), []); + assert.equal(ev('__rl'), 0, 'the backhaul pass never runs'); + const b = JSON.parse(out()), a0 = JSON.parse(a); + assert.deepEqual([b[0], b[1], b[2], b[3], b[6]], [a0[0], a0[1], a0[2], a0[3], a0[6]]); + assert.deepEqual(errors, []); +});