Merge pull request #335 from fjaeckel/claude/endgame-scale
Late game grows sideways: eyeball traffic where the eyeballs are, AI campuses in 34 metros, PNIs by router, spill tiers
This commit is contained in:
commit
b892dcd923
32 changed files with 355 additions and 44 deletions
|
|
@ -39,6 +39,7 @@ These are what the game promises, held up by `tests/gameplay-rules.test.js` (one
|
|||
| N5 | Traffic shares are positive and below 20%; `NSH` and the regional tables sum to 1; content carries at least 30%. | Shares drive every flow; eyeballs mostly ask for traffic. |
|
||||
| N6 | Every network has a type, a peering policy (selective ones state `minIx`/`minPni`), a colour and a translated blurb; carriers have a price. | Panels and the peering rules read them. |
|
||||
| N7 | PoPs are real, distinct cities; exchange ports only where the city has an exchange and the network has a PoP. | Presence follows PeeringDB-style reality. |
|
||||
| N8 | A POP's traffic to the networks that sell to homes (`cc`) goes mostly to those whose users live near it: at home above the world share, on other continents below (`locSh()`, `45-home-markets.js`). Only that split moves: a city's total and every network without home markets keep their shares. | People mostly talk to people near them, and peering with an eyeball where its users are must beat hauling its traffic to two cities (#48). |
|
||||
|
||||
## Modes and rules
|
||||
|
||||
|
|
@ -73,6 +74,7 @@ These are what the game promises, held up by `tests/gameplay-rules.test.js` (one
|
|||
| F7 | Extra crews cut a build on land to half its planned time at most. | Permits, rights of way and trenching set the pace; a 1,000-day build finishing tomorrow made lead times meaningless (#203). |
|
||||
| F8 | In the capacity market (Lambda Bazaar), a managed wave comes out of capacity you lit yourself (your own traffic gets that much less, and the customer suffers when your optics cannot carry it), rides one channel (an 800G or 1.6T wave needs an optic that big), and is priced against its fiber: a 400G wave 2.7 times a 100G one on land and 3.8 times on subsea, each bigger size cheaper per bit. Spectrum lists at 30% of the fiber's monthly cost, and heat moves any price by at most −30% to +35%. | Selling lit capacity must cost capacity, or every fiber sells twice; the ratios are 2025 market prices (TeleGeography), so bigger waves win on volume, not on price per bit. |
|
||||
| F9 | A strict latency contract (`BIZ_T.lowlat`, #137) comes only from customer level 7, is 1.6T or 3.2T and never grows past 3.2T, has a latency limit something you can build meets (`latMaxOf`, as trading links), pays more per Gbps than any other big circuit on the same route even with all their extras, and once its 15-day grace is over credits a day's fee and loses patience faster for every day over its limit. | Real low-latency routes sell at a premium for guaranteed milliseconds and pay service credits when they miss; the cap keeps one contract from carrying a level. |
|
||||
| F10 | Growth goes sideways, plus one paid way up: a PNI bundles eight members per router at its POP, up to 32 (`pniLagMax()`); transit, exchange and fabric LAGs stay at eight (`LAG_MAX`). Giant AI circuits land at campuses (`MEGA`) in at least 30 metros, no metro more than two, picked less often where giant circuits already crowd the city. | Raising caps only moves the wall; a fatter PNI costs a router (its price and its port slots), and the late game's demand spreads over many metros as real AI and cloud campuses do (#61, #323). |
|
||||
|
||||
## DDoS
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- A PNI can now grow past eight ports: each router at the POP takes eight members of a PNI, up to 32, so a busier interconnect costs another router and its ports. Saves keep every LAG they have, and a router a PNI still needs stays until the PNI shrinks (#323).
|
||||
- Your traffic to home internet providers now starts where their customers live: a New York POP talks a lot to Comecast and little to Doitsche Telekomm, Frankfurt the other way round. Peering with a big eyeball network in the cities its users are in now takes that traffic off your backbone, while peering in only two cities means hauling it there from everywhere else (#48).
|
||||
- Giant AI circuits now come from campuses in more than 30 metros, from Oregon and Wyoming to Atlanta, Querétaro and Québec, and less often from cities already crowded with them. Ashburn stays a little busier than the rest, but no longer has to carry the whole late game with four other cities (#61).
|
||||
- RouteScript can spill early onto detours within a latency budget: `spill at 80% within 10 ms` keeps a hot link at 80% and moves the rest onto the fastest detour that adds at most 10 ms and is itself under 80%. Stack them (`spill at 90% within 20 ms`) to spill further as links get hotter (#136).
|
||||
- From customer level 7, low-latency wholesale routes call: 1.6 or 3.2 Tbps between two of your cities with a strict latency limit, paying about three times what a hyperscaler pays per Gbps on the same route. Every day over the limit (after the first 15) you pay back a day's fee as an SLA credit and they lose patience twice as fast as a trading link over its limit, so keep a fast path and a fast backup. They never grow past 3.2 Tbps, so one contract cannot carry a whole level (#137).
|
||||
- From customer level 2, you can save up to three POP standards (micro POP, medium POP, regional hub), each a router model and a number of routers, and mark which POP is which. One button in a POP's Infra tab brings it up to its standard, and Utilities brings every POP of a kind up at once with the price shown first. A POP is never stepped down to a smaller model, and a busy POP with one router gets its second router before the swap, so the upgrade rolls instead of taking the POP down (#315).
|
||||
- Utilities can now install the redundancy kit at every POP still missing part of it in one go, at one price shown on the button, from customer level 2. With a NOC intern you can also put the kit in the intern's new-POP template from there (#317).
|
||||
|
|
|
|||
|
|
@ -159,7 +159,8 @@ The day:
|
|||
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.
|
||||
China, Russia and Korea), localised per city: the networks that sell to homes split their part by where their users
|
||||
live (`locSh()`, `30-networks/45-home-markets.js`, #48). Incidents can add junk flows or scale demand.
|
||||
4. Routes flows rank by rank: the nearest usable exit first, ECMP across equal exits (a PNI goes before an
|
||||
IX port at the same distance: `PNI_TIE`, #298),
|
||||
consuming link, router (`nodeCap`) and exit capacity. A carrier's own transit port also
|
||||
|
|
@ -168,7 +169,8 @@ The day:
|
|||
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
|
||||
onto alternate paths (spill tiers, `spill at 80% within 10 ms`, first try the fastest detour under the line within
|
||||
that budget: `tiers()` in `29-route-core.js`); 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.
|
||||
6. Totals costs (`R.cost`) and revenue (`R.rev`) per month.
|
||||
|
|
|
|||
|
|
@ -3904,6 +3904,7 @@
|
|||
"pni_list.f_pni":"Schon PNI",
|
||||
"pni_list.f_transit":"Über Transit",
|
||||
"pni_list.f_worth":"Lohnt sich",
|
||||
"pni_list.lag_full_add_a_router":"LAG voll mit {n} Mitgliedern: Jeder Router hier fasst {more}, bis {max}. Stell einen Router dazu, um ihn zu vergrößern.",
|
||||
"pni_list.list_more":"{list} +{n}",
|
||||
"pni_list.little_to_gain_here":"Hier gibt's wenig zu holen: {g}",
|
||||
"pni_list.n_here":"{g} hier",
|
||||
|
|
@ -3987,6 +3988,7 @@
|
|||
"pops_transit_ix.router_installed_in_city_upside_down":"<b>Router in {city} installiert.</b><br>Kopfüber, wie es hier unten üblich ist. Den Paketen scheint es egal zu sein.",
|
||||
"pops_transit_ix.signed_with_de_kicks_welcome_to":"<b>Bei DE-KICKS unterschrieben.</b><br>Willkommen in der Familie. Bitte erzähl niemandem, was du zahlst.",
|
||||
"pops_transit_ix.stay_take_the_discount":"Bleiben, Rabatt nehmen",
|
||||
"pops_transit_ix.this_pni_already_bundles_n_ports":"<b>Dieser PNI bündelt schon {n} Ports</b>, mehr fassen deine Router hier nicht. Jeder Router nimmt {more} Mitglieder eines PNI auf, bis {max}: Stell einen Router dazu für mehr.",
|
||||
"pops_transit_ix.wait_before_you_go":"Warte! Bevor du gehst …",
|
||||
"pops_transit_ix.we_value_our_partnership_too_much":"Uns ist unsere Partnerschaft zu wichtig, als dass eine Kleinigkeit wie der Preis im Weg stehen sollte.",
|
||||
"pops_transit_ix.you_need_a_license_first_foreign":"<b>Du brauchst zuerst eine Lizenz.</b><br>Ausländische Netze brauchen ein Joint Venture, um in Festlandchina zu bauen.",
|
||||
|
|
@ -4365,6 +4367,7 @@
|
|||
"routescript.every_gigabit_leaving_your_network_picks":"Jedes Gigabit, das dein Netz verlässt, wählt einen Ausgang: einen PNI, einen IX-Port oder einen Transit-Port. Ohne Eingriff nimmt es das nächste Peering mit freiem Platz (in derselben Stadt den PNI vor dem IX-Port) und Transit erst, wenn kein Peering es nehmen kann. RouteScript ändert diese Wahl, so wie Local-Pref, AS-Path-Prepending und Wartungs-Drains auf echten Routern.",
|
||||
"routescript.filled_in_from_your_network_as":"Ausgefüllt mit deinem Netz, wie es gerade ist. Lade eins, lies es, prüfe es, dann deploye es.",
|
||||
"routescript.for_a_ddos_rtbh_the_target":"Bei einem DDoS: Blackhole das Ziel upstream und stell Geschäftskunden an erste Stelle. Das Ziel ist so lange offline, also entferne es, wenn der Angriff vorbei ist.",
|
||||
"routescript.from_this_load_on_spill_onto":"Eine Spill-Stufe: Sobald der kürzeste Pfad so voll ist, nimmt der Überlauf den besten Umweg, wenn er höchstens so viele Millisekunden dazulegt und selbst unter derselben Linie bleibt. Staple sie (80 % within 10 ms, 90 % within 20 ms), damit heißere Links früher und weiter ausweichen.",
|
||||
"routescript.great_question_here_is_a_production":"Tolle Frage! Hier ist ein produktionsreifes Skript, maßgeschneidert für deinen Live-Traffic. Ich habe es gründlich geprüft.",
|
||||
"routescript.help_and_ready_made_scripts":"Hilfe und fertige Skripte",
|
||||
"routescript.here_you_go_i_was_trained":"Bitte schön! Ich wurde mit jeder Router-Config trainiert, die je in einem Forum gepostet wurde, auch denen mit dem Titel „warum geht das nicht“.",
|
||||
|
|
@ -4376,6 +4379,7 @@
|
|||
"routescript.line_n_i_don_t_understand":"Zeile {n}: Ich verstehe „{text}“ nicht. Versuch: spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams, blackhole ddos",
|
||||
"routescript.line_n_prepend_1_to_3":"Zeile {n}: prepend 1- bis 3-mal",
|
||||
"routescript.line_n_spill_must_be_between":"Zeile {n}: spill muss zwischen 20 % und 100 % liegen",
|
||||
"routescript.line_n_within_1_to_100_ms":"Zeile {n}: within muss zwischen 1 und 100 ms liegen",
|
||||
"routescript.live_state_rules":"Live: {state} · {rules}",
|
||||
"routescript.maintenance_window_change_the_names":"# Wartungsfenster: Ändere die Namen, deploye, erledige die Arbeit und entferne es dann wieder.",
|
||||
"routescript.missing_what":"{what} fehlt",
|
||||
|
|
@ -4412,6 +4416,7 @@
|
|||
"routing.routing_and_ddos":"Routing & DDoS",
|
||||
"routing.trace_note":"Folge einem Paket Hop für Hop und sieh, warum es genau dort rausgeht.",
|
||||
"routing.trace_run":"Tracen",
|
||||
"routing_and_routers.a_pni_here_bundles_n_ports":"<b>Verkleinere zuerst einen PNI.</b><br>Dein PNI mit {net} bündelt {n} Ports, und mit einem Router weniger passen nur {m}.",
|
||||
"routing_and_routers.maintenance_window_in_city":"Wartungsfenster in {city}",
|
||||
"routing_and_routers.model_unlocks_at_customer_level_lv":"<b>{model} wird ab Kundenlevel {lv} freigeschaltet.</b>",
|
||||
"routing_and_routers.new_router_in_city_swapped_before":"<b>Neuer Router in {city}</b><br>Getauscht, bevor irgendwas eingesteckt war: null Ausfallzeit, null wütende Kunden.",
|
||||
|
|
|
|||
|
|
@ -3902,6 +3902,7 @@
|
|||
"pni_list.f_pni":"Ya con PNI",
|
||||
"pni_list.f_transit":"Por tránsito",
|
||||
"pni_list.f_worth":"Merece la pena",
|
||||
"pni_list.lag_full_add_a_router":"LAG lleno con {n} miembros: cada router aquí admite {more}, hasta {max}. Añade un router para ampliarlo.",
|
||||
"pni_list.list_more":"{list} +{n}",
|
||||
"pni_list.little_to_gain_here":"Poco que ganar aquí: {g}",
|
||||
"pni_list.n_here":"{g} aquí",
|
||||
|
|
@ -3985,6 +3986,7 @@
|
|||
"pops_transit_ix.router_installed_in_city_upside_down":"<b>Router instalado en {city}.</b><br>Boca abajo, como es costumbre por aquí. A los paquetes no parece importarles.",
|
||||
"pops_transit_ix.signed_with_de_kicks_welcome_to":"<b>Firmado con DE-KICKS.</b><br>Bienvenido a la familia. Por favor, no le digas a nadie lo que pagas.",
|
||||
"pops_transit_ix.stay_take_the_discount":"Quedarme y aceptar el descuento",
|
||||
"pops_transit_ix.this_pni_already_bundles_n_ports":"<b>Este PNI ya agrupa {n} puertos</b>, todo lo que caben en tus routers aquí. Cada router admite {more} miembros de un PNI, hasta {max}: añade un router para más.",
|
||||
"pops_transit_ix.wait_before_you_go":"¡Espera! Antes de irte…",
|
||||
"pops_transit_ix.we_value_our_partnership_too_much":"Valoramos demasiado nuestra relación como para dejar que algo tan pequeño como el precio se interponga.",
|
||||
"pops_transit_ix.you_need_a_license_first_foreign":"<b>Primero necesitas una licencia.</b><br>Las redes extranjeras necesitan una empresa conjunta para construir en China continental.",
|
||||
|
|
@ -4363,6 +4365,7 @@
|
|||
"routescript.every_gigabit_leaving_your_network_picks":"Cada gigabit que sale de tu red elige una salida: un PNI, un puerto IX o un puerto de tránsito. Si no haces nada, toma el peering más cercano con sitio (en la misma ciudad, el PNI antes que el puerto IX), y el tránsito solo cuando ningún peering puede llevarlo. RouteScript cambia esas elecciones, como hacen local-pref, el prepend de AS-path y los drenajes de mantenimiento en routers reales.",
|
||||
"routescript.filled_in_from_your_network_as":"Rellenado con tu red tal como está ahora mismo. Carga uno, léelo, compruébalo y luego despliega.",
|
||||
"routescript.for_a_ddos_rtbh_the_target":"Para un DDoS: haz blackhole al objetivo aguas arriba y prioriza a los clientes empresariales. El objetivo queda a oscuras mientras dure, así que quítalo cuando acabe el ataque.",
|
||||
"routescript.from_this_load_on_spill_onto":"Un escalón de spill: cuando el camino más corto está así de lleno, el exceso toma el mejor desvío si no añade más de esos milisegundos y se queda bajo la misma línea. Apílalos (80% within 10 ms, 90% within 20 ms) para desviar antes y más lejos cuanto más calientes estén los enlaces.",
|
||||
"routescript.great_question_here_is_a_production":"¡Gran pregunta! Aquí tienes un script listo para producción, a medida de tu tráfico en vivo. Lo he revisado a fondo.",
|
||||
"routescript.help_and_ready_made_scripts":"Ayuda y scripts ya hechos",
|
||||
"routescript.here_you_go_i_was_trained":"¡Aquí tienes! Me entrenaron con todas las configuraciones de router que se hayan publicado en un foro, incluidas las tituladas «por qué esto no funciona».",
|
||||
|
|
@ -4374,6 +4377,7 @@
|
|||
"routescript.line_n_i_don_t_understand":"línea {n}: no entiendo «{text}». Prueba: spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams, blackhole ddos",
|
||||
"routescript.line_n_prepend_1_to_3":"línea {n}: prepend de 1 a 3 veces",
|
||||
"routescript.line_n_spill_must_be_between":"línea {n}: spill debe estar entre 20 % y 100 %",
|
||||
"routescript.line_n_within_1_to_100_ms":"línea {n}: within debe estar entre 1 y 100 ms",
|
||||
"routescript.live_state_rules":"En vivo: {state} · {rules}",
|
||||
"routescript.maintenance_window_change_the_names":"# Ventana de mantenimiento: cambia los nombres, despliega, haz el trabajo y quítalo.",
|
||||
"routescript.missing_what":"falta {what}",
|
||||
|
|
@ -4410,6 +4414,7 @@
|
|||
"routing.routing_and_ddos":"Routing y DDoS",
|
||||
"routing.trace_note":"Sigue un paquete salto a salto y mira por qué sale por donde sale.",
|
||||
"routing.trace_run":"Trazar",
|
||||
"routing_and_routers.a_pni_here_bundles_n_ports":"<b>Reduce primero un PNI.</b><br>Tu PNI con {net} agrupa {n} puertos, y con un router menos solo caben {m}.",
|
||||
"routing_and_routers.maintenance_window_in_city":"Ventana de mantenimiento en {city}",
|
||||
"routing_and_routers.model_unlocks_at_customer_level_lv":"<b>{model} se desbloquea en el nivel de cliente {lv}.</b>",
|
||||
"routing_and_routers.new_router_in_city_swapped_before":"<b>Router nuevo en {city}</b><br>Cambiado antes de conectar nada: cero inactividad, cero clientes enfadados.",
|
||||
|
|
|
|||
|
|
@ -3902,6 +3902,7 @@
|
|||
"pni_list.f_pni":"Déjà en PNI",
|
||||
"pni_list.f_transit":"Via le transit",
|
||||
"pni_list.f_worth":"Rentable",
|
||||
"pni_list.lag_full_add_a_router":"LAG plein à {n} membres : chaque routeur ici en tient {more}, jusqu’à {max}. Ajoute un routeur pour l’agrandir.",
|
||||
"pni_list.list_more":"{list} +{n}",
|
||||
"pni_list.little_to_gain_here":"Peu à gagner ici : {g}",
|
||||
"pni_list.n_here":"{g} ici",
|
||||
|
|
@ -3985,6 +3986,7 @@
|
|||
"pops_transit_ix.router_installed_in_city_upside_down":"<b>Routeur installé à {city}.</b><br>À l’envers, comme le veut la coutume ici. Les paquets n’ont pas l’air de s’en soucier.",
|
||||
"pops_transit_ix.signed_with_de_kicks_welcome_to":"<b>Signé avec DE-KICKS.</b><br>Bienvenue dans la famille. Merci de ne dire à personne combien tu paies.",
|
||||
"pops_transit_ix.stay_take_the_discount":"Rester et prendre la remise",
|
||||
"pops_transit_ix.this_pni_already_bundles_n_ports":"<b>Ce PNI regroupe déjà {n} ports</b>, tout ce que tes routeurs ici peuvent tenir. Chaque routeur prend {more} membres d’un PNI, jusqu’à {max} : ajoute un routeur pour aller plus loin.",
|
||||
"pops_transit_ix.wait_before_you_go":"Attends ! Avant de partir…",
|
||||
"pops_transit_ix.we_value_our_partnership_too_much":"Nous tenons trop à notre partenariat pour laisser un détail comme le prix se mettre en travers.",
|
||||
"pops_transit_ix.you_need_a_license_first_foreign":"<b>Il te faut d’abord une licence.</b><br>Les réseaux étrangers ont besoin d’une joint-venture pour construire en Chine continentale.",
|
||||
|
|
@ -4363,6 +4365,7 @@
|
|||
"routescript.every_gigabit_leaving_your_network_picks":"Chaque gigabit qui quitte votre réseau choisit une sortie : une PNI, un port IX ou un port de transit. Livré à lui-même, il prend le peering le plus proche qui a de la place (dans une même ville, la PNI avant le port IX), et le transit seulement quand aucun peering ne peut le prendre. RouteScript change ces choix, comme le font local-pref, l’AS-path prepending et les drains de maintenance sur de vrais routeurs.",
|
||||
"routescript.filled_in_from_your_network_as":"Remplis à partir de votre réseau tel qu’il est en ce moment. Chargez-en un, lisez-le, vérifiez-le, puis déployez.",
|
||||
"routescript.for_a_ddos_rtbh_the_target":"Pour un DDoS : blackhole la cible en amont et sers d’abord les clients professionnels. La cible est coupée tant que ça dure, alors retire-le quand l’attaque est finie.",
|
||||
"routescript.from_this_load_on_spill_onto":"Un palier de spill : dès que le plus court chemin est aussi plein, le trop-plein prend le meilleur détour s’il n’ajoute pas plus de ces millisecondes et reste lui-même sous la même ligne. Empile-les (80% within 10 ms, 90% within 20 ms) pour déborder plus tôt et plus loin quand les liens chauffent.",
|
||||
"routescript.great_question_here_is_a_production":"Excellente question ! Voici un script prêt pour la production, taillé pour votre trafic. Je l’ai vérifié minutieusement.",
|
||||
"routescript.help_and_ready_made_scripts":"Aide et scripts tout prêts",
|
||||
"routescript.here_you_go_i_was_trained":"Et voilà ! J’ai été entraîné sur toutes les configs de routeur jamais postées sur un forum, y compris celles intitulées « pourquoi ça marche pas ».",
|
||||
|
|
@ -4374,6 +4377,7 @@
|
|||
"routescript.line_n_i_don_t_understand":"ligne {n} : je ne comprends pas « {text} ». Essaie : spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams, blackhole ddos",
|
||||
"routescript.line_n_prepend_1_to_3":"ligne {n} : prepend de 1 à 3 fois",
|
||||
"routescript.line_n_spill_must_be_between":"ligne {n} : spill doit être entre 20 % et 100 %",
|
||||
"routescript.line_n_within_1_to_100_ms":"ligne {n} : within doit être entre 1 et 100 ms",
|
||||
"routescript.live_state_rules":"État : {state} · {rules}",
|
||||
"routescript.maintenance_window_change_the_names":"# Fenêtre de maintenance : changez les noms, déployez, faites le travail, puis retirez-le.",
|
||||
"routescript.missing_what":"élément manquant : {what}",
|
||||
|
|
@ -4410,6 +4414,7 @@
|
|||
"routing.routing_and_ddos":"Routage et DDoS",
|
||||
"routing.trace_note":"Suis un paquet saut par saut et vois pourquoi il sort là où il sort.",
|
||||
"routing.trace_run":"Tracer",
|
||||
"routing_and_routers.a_pni_here_bundles_n_ports":"<b>Réduis d’abord un PNI.</b><br>Ton PNI avec {net} regroupe {n} ports, et avec un routeur de moins il n’en tient que {m}.",
|
||||
"routing_and_routers.maintenance_window_in_city":"Fenêtre de maintenance à {city}",
|
||||
"routing_and_routers.model_unlocks_at_customer_level_lv":"<b>Le {model} se débloque au niveau client {lv}.</b>",
|
||||
"routing_and_routers.new_router_in_city_swapped_before":"<b>Nouveau routeur à {city}</b><br>Remplacé avant que quoi que ce soit ne soit branché : zéro interruption, zéro client fâché.",
|
||||
|
|
|
|||
|
|
@ -3902,6 +3902,7 @@
|
|||
"pni_list.f_pni":"Già in PNI",
|
||||
"pni_list.f_transit":"Tramite transit",
|
||||
"pni_list.f_worth":"Conviene",
|
||||
"pni_list.lag_full_add_a_router":"LAG pieno a {n} membri: ogni router qui ne regge {more}, fino a {max}. Aggiungi un router per allargarlo.",
|
||||
"pni_list.list_more":"{list} +{n}",
|
||||
"pni_list.little_to_gain_here":"Poco da guadagnare qui: {g}",
|
||||
"pni_list.n_here":"{g} qui",
|
||||
|
|
@ -3985,6 +3986,7 @@
|
|||
"pops_transit_ix.router_installed_in_city_upside_down":"<b>Router installato a {city}.</b><br>A testa in giù, come si usa da queste parti. Ai pacchetti non sembra importare.",
|
||||
"pops_transit_ix.signed_with_de_kicks_welcome_to":"<b>Firmato con DE-KICKS.</b><br>Benvenuto in famiglia. Per favore, non dire a nessuno quanto paghi.",
|
||||
"pops_transit_ix.stay_take_the_discount":"Resta, prendi lo sconto",
|
||||
"pops_transit_ix.this_pni_already_bundles_n_ports":"<b>Questo PNI raggruppa già {n} porte</b>, tutte quelle che i tuoi router qui possono reggere. Ogni router regge {more} membri di un PNI, fino a {max}: aggiungi un router per averne di più.",
|
||||
"pops_transit_ix.wait_before_you_go":"Aspetta! Prima che tu vada…",
|
||||
"pops_transit_ix.we_value_our_partnership_too_much":"Teniamo troppo alla nostra partnership per lasciare che una sciocchezza come il prezzo si metta in mezzo.",
|
||||
"pops_transit_ix.you_need_a_license_first_foreign":"<b>Prima ti serve una licenza.</b><br>Per costruire nella Cina continentale le reti straniere hanno bisogno di una joint venture.",
|
||||
|
|
@ -4363,6 +4365,7 @@
|
|||
"routescript.every_gigabit_leaving_your_network_picks":"Ogni gigabit che esce dalla tua rete sceglie un’uscita: una PNI, una porta IX o una porta di transito. Se lo lasci fare, prende il peering più vicino con spazio libero (nella stessa città, la PNI prima della porta IX), e il transito solo quando nessun peering può prenderlo. RouteScript cambia queste scelte, come fanno local-pref, AS-path prepending e drain di manutenzione sui router veri.",
|
||||
"routescript.filled_in_from_your_network_as":"Compilati dalla tua rete così com’è adesso. Caricane uno, leggilo, controllalo, poi fai il deploy.",
|
||||
"routescript.for_a_ddos_rtbh_the_target":"Per un DDoS: metti il bersaglio in blackhole a monte e servi prima i clienti business. Il bersaglio resta al buio finché dura, quindi toglila quando l’attacco è finito.",
|
||||
"routescript.from_this_load_on_spill_onto":"Un gradino di spill: quando il percorso più corto è pieno a questo punto, il traffico in eccesso prende la deviazione migliore se aggiunge al massimo questi millisecondi e resta sotto la stessa soglia. Impilali (80% within 10 ms, 90% within 20 ms) per deviare prima e più lontano man mano che i link si scaldano.",
|
||||
"routescript.great_question_here_is_a_production":"Ottima domanda! Ecco uno script pronto per la produzione, su misura per il tuo traffico. L’ho controllato a fondo.",
|
||||
"routescript.help_and_ready_made_scripts":"Aiuto e script pronti",
|
||||
"routescript.here_you_go_i_was_trained":"Ecco qua! Sono stato addestrato su ogni configurazione di router mai pubblicata in un forum, comprese quelle intitolate “perché non funziona”.",
|
||||
|
|
@ -4374,6 +4377,7 @@
|
|||
"routescript.line_n_i_don_t_understand":"riga {n}: non capisco “{text}”. Prova: spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams, blackhole ddos",
|
||||
"routescript.line_n_prepend_1_to_3":"riga {n}: prepend da 1 a 3 volte",
|
||||
"routescript.line_n_spill_must_be_between":"riga {n}: spill deve essere tra 20% e 100%",
|
||||
"routescript.line_n_within_1_to_100_ms":"riga {n}: within deve essere tra 1 e 100 ms",
|
||||
"routescript.live_state_rules":"Stato: {state} · {rules}",
|
||||
"routescript.maintenance_window_change_the_names":"# Finestra di manutenzione: cambia i nomi, fai il deploy, fai il lavoro, poi toglilo.",
|
||||
"routescript.missing_what":"{what} mancante",
|
||||
|
|
@ -4410,6 +4414,7 @@
|
|||
"routing.routing_and_ddos":"Routing e DDoS",
|
||||
"routing.trace_note":"Segui un pacchetto hop dopo hop e scopri perché esce proprio lì.",
|
||||
"routing.trace_run":"Traccia",
|
||||
"routing_and_routers.a_pni_here_bundles_n_ports":"<b>Prima riduci un PNI.</b><br>Il tuo PNI con {net} raggruppa {n} porte, e con un router in meno ne reggi solo {m}.",
|
||||
"routing_and_routers.maintenance_window_in_city":"Finestra di manutenzione a {city}",
|
||||
"routing_and_routers.model_unlocks_at_customer_level_lv":"<b>{model} si sblocca al livello clienti {lv}.</b>",
|
||||
"routing_and_routers.new_router_in_city_swapped_before":"<b>Nuovo router a {city}</b><br>Sostituito prima che ci fosse collegato qualcosa: zero downtime, zero clienti arrabbiati.",
|
||||
|
|
|
|||
|
|
@ -3902,6 +3902,7 @@
|
|||
"pni_list.f_pni":"Já com PNI",
|
||||
"pni_list.f_transit":"Por trânsito",
|
||||
"pni_list.f_worth":"Compensa",
|
||||
"pni_list.lag_full_add_a_router":"LAG cheio com {n} membros: cada router aqui aguenta {more}, até {max}. Adiciona um router para o aumentar.",
|
||||
"pni_list.list_more":"{list} +{n}",
|
||||
"pni_list.little_to_gain_here":"Pouco a ganhar aqui: {g}",
|
||||
"pni_list.n_here":"{g} aqui",
|
||||
|
|
@ -3985,6 +3986,7 @@
|
|||
"pops_transit_ix.router_installed_in_city_upside_down":"<b>Roteador instalado em {city}.</b><br>De cabeça para baixo, como é costume por aqui. Os pacotes não parecem se importar.",
|
||||
"pops_transit_ix.signed_with_de_kicks_welcome_to":"<b>Contrato assinado com a DE-KICKS.</b><br>Bem-vindo à família. Por favor, não conte a ninguém quanto você paga.",
|
||||
"pops_transit_ix.stay_take_the_discount":"Ficar com o desconto",
|
||||
"pops_transit_ix.this_pni_already_bundles_n_ports":"<b>Este PNI já agrupa {n} portas</b>, tudo o que os teus routers aqui aguentam. Cada router aguenta {more} membros de um PNI, até {max}: adiciona um router para mais.",
|
||||
"pops_transit_ix.wait_before_you_go":"Espere! Antes de ir…",
|
||||
"pops_transit_ix.we_value_our_partnership_too_much":"Valorizamos demais nossa parceria para deixar uma bobagem como o preço atrapalhar.",
|
||||
"pops_transit_ix.you_need_a_license_first_foreign":"<b>Primeiro você precisa de uma licença.</b><br>Redes estrangeiras precisam de uma joint venture para construir na China continental.",
|
||||
|
|
@ -4363,6 +4365,7 @@
|
|||
"routescript.every_gigabit_leaving_your_network_picks":"Todo gigabit que sai da sua rede escolhe uma saída: uma PNI, uma porta de IX ou uma porta de trânsito. Por conta própria, ele pega o peering mais próximo que tem espaço (na mesma cidade, a PNI antes da porta de IX), e trânsito só quando nenhum peering consegue levar. O RouteScript muda essas escolhas, como local-pref, AS-path prepending e drains de manutenção fazem em roteadores de verdade.",
|
||||
"routescript.filled_in_from_your_network_as":"Preenchidos a partir da sua rede como ela está agora. Carregue um, leia, verifique e depois faça o deploy.",
|
||||
"routescript.for_a_ddos_rtbh_the_target":"Para um DDoS: coloque o alvo em blackhole no upstream e priorize os clientes empresariais. O alvo fica fora do ar enquanto durar, então remova quando o ataque acabar.",
|
||||
"routescript.from_this_load_on_spill_onto":"Um degrau de spill: quando o caminho mais curto está assim cheio, o excesso segue o melhor desvio se não acrescentar mais do que esses milissegundos e ficar abaixo da mesma linha. Empilha-os (80% within 10 ms, 90% within 20 ms) para desviar mais cedo e mais longe à medida que os links aquecem.",
|
||||
"routescript.great_question_here_is_a_production":"Ótima pergunta! Aqui está um script pronto para produção, sob medida para o seu tráfego. Eu verifiquei tudo com cuidado.",
|
||||
"routescript.help_and_ready_made_scripts":"Ajuda e scripts prontos",
|
||||
"routescript.here_you_go_i_was_trained":"Aqui está! Fui treinado em todas as configurações de roteador já postadas num fórum, inclusive as com o título “por que isso não funciona”.",
|
||||
|
|
@ -4374,6 +4377,7 @@
|
|||
"routescript.line_n_i_don_t_understand":"linha {n}: não entendi “{text}”. Tente: spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams, blackhole ddos",
|
||||
"routescript.line_n_prepend_1_to_3":"linha {n}: prepend de 1 a 3 vezes",
|
||||
"routescript.line_n_spill_must_be_between":"linha {n}: spill deve estar entre 20% e 100%",
|
||||
"routescript.line_n_within_1_to_100_ms":"linha {n}: within tem de estar entre 1 e 100 ms",
|
||||
"routescript.live_state_rules":"Ao vivo: {state} · {rules}",
|
||||
"routescript.maintenance_window_change_the_names":"# Janela de manutenção: troque os nomes, faça o deploy, faça o trabalho e depois remova.",
|
||||
"routescript.missing_what":"falta {what}",
|
||||
|
|
@ -4410,6 +4414,7 @@
|
|||
"routing.routing_and_ddos":"Roteamento e DDoS",
|
||||
"routing.trace_note":"Siga um pacote salto a salto e veja por que ele sai por onde sai.",
|
||||
"routing.trace_run":"Traçar",
|
||||
"routing_and_routers.a_pni_here_bundles_n_ports":"<b>Reduz primeiro um PNI.</b><br>O teu PNI com {net} agrupa {n} portas, e com um router a menos só cabem {m}.",
|
||||
"routing_and_routers.maintenance_window_in_city":"Janela de manutenção em {city}",
|
||||
"routing_and_routers.model_unlocks_at_customer_level_lv":"<b>{model} desbloqueia no nível de cliente {lv}.</b>",
|
||||
"routing_and_routers.new_router_in_city_swapped_before":"<b>Roteador novo em {city}</b><br>Trocado antes de qualquer coisa estar conectada: zero downtime, zero clientes bravos.",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"v":1,"key":"2026-W44","rev":3,"theme":"flood","city":"sto","cash":2050000,"days":250,"lvl":4,"rules":{"ddos":true},"mods":[],"goal":{"t":"floods","p":{"n":28,"big":5}},"name":{"l":"wkscn.name_packet_monsoon","p":{}},"desc":{"l":"wkscn.desc_city_hosts_the_internets_favourite","p":{"city":"sto"}},"seed":1559294845,"par":198,"ref":{"home":"sto","bb":true,"ix":true,"steps":[{"k":"hop","v":["sto","tll",1,null]},{"k":"hop","v":["tll","hel",1,null]}],"avoid":[],"tr2":false,"scrub":2}}
|
||||
{"v":1,"key":"2026-W44","rev":3,"theme":"flood","city":"sto","cash":2050000,"days":250,"lvl":4,"rules":{"ddos":true},"mods":[],"goal":{"t":"floods","p":{"n":28,"big":5}},"name":{"l":"wkscn.name_packet_monsoon","p":{}},"desc":{"l":"wkscn.desc_city_hosts_the_internets_favourite","p":{"city":"sto"}},"seed":1559294845,"par":185,"ref":{"home":"sto","bb":true,"ix":true,"steps":[{"k":"hop","v":["sto","tll",1,null]},{"k":"hop","v":["tll","hel",1,null]}],"avoid":[],"tr2":false,"scrub":2}}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ const API_CMD={
|
|||
cancelPni:{args:[['id','entityId']],confirm:'arg',pass:a=>({id:a.id,ok:1}),
|
||||
doc:'Cancel a PNI or its pending augment.'},
|
||||
lagP:{args:[['id','entityId'],['d','step']],watch:['pni.#id'],
|
||||
doc:'Add or remove a LAG member on a PNI. Adding is an augment with a lead time.'},
|
||||
doc:'Add or remove a LAG member on a PNI, up to 8 per router at the POP (pniLagMax, at most PNI_LAG_MAX). Adding is an augment with a lead time.'},
|
||||
sacrif:{args:[['id','entityId']],watch:['pni.#id'],
|
||||
doc:'Mark a PNI sacrificial, so attack traffic is steered into it.'},
|
||||
peerPol:{args:[['p','peerPolicy']],watch:['ppol'],
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ function apiJson(v){
|
|||
carries the keys confGo/confSponsor need, which exist in no field of S; TE_RECIPES renders
|
||||
each recipe's script, because the source is a function and some read the live network. The
|
||||
recipes' relevance score is not exposed: judging which one fits is the agent's job. */
|
||||
const API_TABLES={ROCKETS,CRUSTS,PIE_RD,PIE_SPAT_DEF,SALES,CITIES,NETS,CABLES,XIX,PORT,LT,NNI,VXC,RG,OPT,DF_SYS,FAB,SCRUB_TIERS,BIZ_T,LEVELS,GOALS,BROKER_GOALS,SCN,BANKS,REQS,NSH,MET,PREF,RT,PPOL,CONFS,LAG_MAX,RMAX,REGEN_MAX,START_CASH,CONF_COST,CONF_SP,CAP_COST,CAP_LV,CONF_DAYS,SUB_UPGRADES,SEA_DESIGNS,TE_COST,TE_MO,MYIX_COST,CN_LIC,SITE2_COST,MYIX_FAB,INTERNS,OPSK,CHARTERS,SEAT_N,CORE_LV,CORE_COST,CORE_REQ,CORE_LAB,INTERN_MO,PZ_TIERS,AR_TIERS,PZ_RG};
|
||||
const API_TABLES={ROCKETS,CRUSTS,PIE_RD,PIE_SPAT_DEF,SALES,CITIES,NETS,CABLES,XIX,PORT,LT,NNI,VXC,RG,OPT,DF_SYS,FAB,SCRUB_TIERS,BIZ_T,LEVELS,GOALS,BROKER_GOALS,SCN,BANKS,REQS,NSH,MET,PREF,RT,PPOL,CONFS,LAG_MAX,PNI_LAG_MAX,PNI_LAG_RT,RMAX,REGEN_MAX,START_CASH,CONF_COST,CONF_SP,CAP_COST,CAP_LV,CONF_DAYS,SUB_UPGRADES,SEA_DESIGNS,TE_COST,TE_MO,MYIX_COST,CN_LIC,SITE2_COST,MYIX_FAB,INTERNS,OPSK,CHARTERS,SEAT_N,CORE_LV,CORE_COST,CORE_REQ,CORE_LAB,INTERN_MO,PZ_TIERS,AR_TIERS,PZ_RG};
|
||||
const API_MADE={
|
||||
BADGES:()=>!S?[]:BADGES.map(b=>{const on=S.ach&&S.ach[b.id]!==undefined,ever=!!hof()[b.id];
|
||||
return b.secret&&!on&&!ever?{id:b.id,i:'❔',t:'???',d:tr('badges.a_secret_badge'),r:b.r,secret:true}:{...b,ever};}),
|
||||
|
|
|
|||
30
src/game/30-networks/45-home-markets.js
Normal file
30
src/game/30-networks/45-home-markets.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* Where each network's users live (#48). A network that sells to homes lists its home markets (cc, see W2), and that is
|
||||
where its eyeballs are. People mostly talk to people near them, so a POP's traffic to the networks that sell to homes
|
||||
goes mostly to the ones at home: a New York POP sends a lot to Comecast and little to Doitsche Telekomm, Frankfurt
|
||||
the other way round. Together those networks keep the share the city's table gives them; only how it splits between
|
||||
them follows geography. Content and carriers without home markets are everywhere and keep their shares.
|
||||
Routing is unchanged: traffic leaves at the nearest exit (hot potato), so an eyeball peered with in the cities its
|
||||
users are in takes that traffic off your backbone where it starts, and one peered with in two cities has it hauled
|
||||
there from everywhere else. */
|
||||
const LOC_HOME=1,LOC_REG=0.3,LOC_FAR=0.08;
|
||||
const LOC_NIX=new Map(NETS.map((n,j)=>[n.id,j]));
|
||||
// Per network index: its home countries and the regions they are in, or null (no home market: everywhere).
|
||||
let LOC_NET=null;
|
||||
function locNets(){if(LOC_NET)return LOC_NET;const ccReg=new Map();
|
||||
for(const c of CITIES){let s=ccReg.get(c.cc);if(!s)ccReg.set(c.cc,s=new Set());s.add(c.reg);}
|
||||
LOC_NET=NETS.map(n=>{if(!n.cc)return null;const cc=new Set(Array.isArray(n.cc)?n.cc:[n.cc]),reg=new Set();for(const k of cc)for(const r of ccReg.get(k)||[])reg.add(r);return {cc,reg};});
|
||||
return LOC_NET;}
|
||||
// How near a city is to a network's users: at home, on the same continent, or far away.
|
||||
const locW=(h,C)=>h.cc.has(C.cc)?LOC_HOME:h.reg.has(C.reg)?LOC_REG:LOC_FAR;
|
||||
/* A city's shares in table T (by network index), localised. The tables and the map never change after load, so each
|
||||
city's array is made once per table and kept. */
|
||||
const LOC_SH=new Map();
|
||||
function locSh(T,c){let m=LOC_SH.get(T);if(!m)LOC_SH.set(T,m=new Map());let a=m.get(c);if(a)return a;
|
||||
const L=locNets(),C=CITY[c],NN=NETS.length;a=new Float64Array(NN);let g=0,gw=0;
|
||||
for(let j=0;j<NN;j++){const s=T[NETS[j].id]||0;if(!s)continue;const h=L[j];if(!h){a[j]=s;continue;}const v=s*locW(h,C);g+=s;gw+=v;a[j]=v;}
|
||||
if(gw>0){const f=g/gw;for(let j=0;j<NN;j++)if(L[j]&&a[j])a[j]*=f;}
|
||||
m.set(c,a);return a;}
|
||||
/* Puzzles, Architect runs and scenarios (the weekly one too) are built and scored on the plain world shares: their
|
||||
reference builds and committed pars were made with them. There a city's split stays the table's. */
|
||||
const LOC_PLAIN=new Map(),locOn=()=>!(S&&(S.mode==='puzzle'||S.pz||S.ar||S.scn));
|
||||
function cityShares(T,c){if(locOn())return locSh(T,c);let a=LOC_PLAIN.get(T);if(!a)LOC_PLAIN.set(T,a=Float64Array.from(NETS,n=>T[n.id]||0));return a;}
|
||||
|
|
@ -197,7 +197,7 @@ const OPS_RUN={
|
|||
// Each port: cap() now, use today, lag() and ups() the jobs it could have as {cost, cap after, w for the log, go}, sig() to see a job took.
|
||||
for(const p of S.pni){const c=p.city,use=(R.usePni[p.id]||0)*opsAhead(),cap=()=>lagCap(pniG(p),p.n),n=()=>p.n||1;if(!pniOn(p)||p.up||!(use>0)||cap()>=N*use||!opsHere('ports',c))continue;
|
||||
L.push({city:c,at:c,use,u:use/cap(),cap,n,rt:(S.pops[c]||{}).routers||1,busy:()=>!!p.up,sig:()=>[p.tier,n(),!!p.g1,!!p.up].join(),
|
||||
lag:()=>n()<LAG_MAX&&!msfNope(p.net,c)&&PORT_SLOT(p.tier)<=room(c)?{cost:1500+PORT[p.tier].setup/2,cap:lagCap(pniG(p),n()+1),w:'+1×'+pniPN(p),go:()=>ACT.lagP({id:p.id,d:1})}:null,
|
||||
lag:()=>n()<pniLagMax(c)&&!msfNope(p.net,c)&&PORT_SLOT(p.tier)<=room(c)?{cost:1500+PORT[p.tier].setup/2,cap:lagCap(pniG(p),n()+1),w:'+1×'+pniPN(p),go:()=>ACT.lagP({id:p.id,d:1})}:null,
|
||||
ups:()=>{const out=[];for(let t=p.g1?0:p.tier+1;t<PORT.length&&portShown(t);t++){const q=pniQuote(c,p.net,t,resv(c));if(q&&!q.why)out.push({cost:q.cost,cap:lagCap(PORT[t].g,n()),w:pniPN(p)+'→'+PORT[t].n,go:()=>ACT.pni({city:c,net:p.net,tier:t})});}return out;}});}
|
||||
// Nominal capacity, not ixCap(): a LACP fault or one building down halves a LAG for a day or two, not worth a bigger port.
|
||||
for(const x in S.ixp){const c=ixCity(x),use=(R.useIx[x]||0)*opsAhead(),n=()=>(S.ixn||{})[x]||1,cap=()=>lagCap(PORT[S.ixp[x]].g,n())*(isRemote(x)?REMOTE_CAP:1),pop=S.pops[c];if(S.myIx[x]||!(use>0)||!(cap()>0)||cap()>=N*use||!opsHere('ports',c))continue;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])ret
|
|||
const IX_MEM={};
|
||||
// LAG: several identical ports bundled into one logical link. Flow hashing is never perfectly even, so a bundle carries ~95% of the sum.
|
||||
const LAG_MAX=8;
|
||||
/* A PNI bundle grows with the routers it lands on (#323): eight members per router at the POP, so a PNI fatter than eight
|
||||
ports costs another router (its price and its port slots), up to 32 members, the most the big LAG implementations
|
||||
bundle. Only PNIs: transit, exchange and fabric ports stay at LAG_MAX. */
|
||||
const PNI_LAG_RT=8,PNI_LAG_MAX=32;
|
||||
function pniLagMax(c){const p=S.pops[c];return Math.min(PNI_LAG_MAX,PNI_LAG_RT*((p&&p.routers)||1));}
|
||||
function lagCap(g,n){n=n||1;return g*n*(n>1?0.95:1);}
|
||||
function lagName(tier,n){return (n||1)>1?`${n}×${PORT[tier].n} LAG`:tr('common.port_port',{port:PORT[tier].n});}
|
||||
function ixCap(c){return ixLagF(c)*(S.myIx[c]?myFab(c).g*(myIxLive(c)?1:0):liveCap(PORT[S.ixp[c]].g,ixCity(c),(S.ixSite||{})[c],(S.ixn||{})[c])*(isRemote(c)?REMOTE_CAP:1));}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ function utilityCacheMoves(city){if(!S||!S.pops[city])return [];const groups=new
|
|||
// list of networks, and Goggle is throttled to half in Russia. The world shares (NSH) would size boxes for networks the
|
||||
// city cannot even reach, and too few for the ones it uses most.
|
||||
const cityShTab=c=>cnCity(c)?NSH_CN:ruCity(c)?NSH_RU:CITY[c].kr&&S.krExit?NSH_KRX:NSH;
|
||||
const cityNetSh=(c,id)=>(cityShTab(c)[id]||0)*(id==='ggl'&&ruCity(c)?0.5:1);
|
||||
// A city's total share only depends on its table and on the Russian throttle, and the tables never change after load:
|
||||
// summed once per kind of city, not once per network asked about (that was cities × networks² every shift).
|
||||
const CSH_SUM=new Map();
|
||||
function cityShSum(c){const T=cityShTab(c),k=ruCity(c)?1:0;let m=CSH_SUM.get(T);if(!m)CSH_SUM.set(T,m=[null,null]);
|
||||
if(m[k]===null){let t=0;for(const id in T)t+=cityNetSh(c,id);m[k]=t;}return m[k];}
|
||||
const cityNetSh=(c,id)=>{const j=LOC_NIX.get(id);return (j===undefined?0:cityShares(cityShTab(c),c)[j])*(id==='ggl'&&ruCity(c)?0.5:1);};
|
||||
// A city's total share only depends on its split (its table, localised for the city, #48) and on the Russian throttle,
|
||||
// and those never change after load: summed once per split, not once per network asked about (that was cities ×
|
||||
// networks² every shift).
|
||||
const CSH_SUM=new WeakMap();
|
||||
function cityShSum(c){const a=cityShares(cityShTab(c),c),k=ruCity(c)?1:0;let m=CSH_SUM.get(a);if(!m)CSH_SUM.set(a,m=[null,null]);
|
||||
if(m[k]===null){const T=cityShTab(c);let t=0;for(const id in T)t+=cityNetSh(c,id);m[k]=t;}return m[k];}
|
||||
function cacheDem(c,id){const t=cityShSum(c);return t>0?((R.cityDem&&R.cityDem[c])||0)*cityNetSh(c,id)/t:0;}
|
||||
// One box per site first, if the city sends the network anything at all; then more boxes while that demand outgrows them
|
||||
// (100G each, #248).
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ cap transit cogentle at 20 gbps
|
|||
avoid transit for goggle
|
||||
# Move traffic before links are completely full
|
||||
spill at 85%
|
||||
# Hot links spill early onto detours that cost little latency
|
||||
# spill at 80% within 10 ms
|
||||
# spill at 90% within 20 ms
|
||||
# Local-pref: use the cheap upstream first, the pricey one last
|
||||
# prefer transit cogentle
|
||||
# avoid transit level tree
|
||||
|
|
@ -27,9 +30,11 @@ function teFind(word,list,label){const w=slug(word);if(!w)return {err:tr('routes
|
|||
const pre=list.filter(x=>w.length>=3&&slug(x.name).startsWith(w));if(pre.length===1)return {v:pre[0].id};
|
||||
const best=list.map(x=>({x,d:Math.min(lev(w,slug(x.name)),lev(w,x.id))})).sort((a,b)=>a.d-b.d)[0];
|
||||
return {err:tr('routescript.unknown_what_word',{what:label,word})+(best&&best.d<=3?tr('routescript.did_you_mean_name',{name:best.x.name}):'')};}
|
||||
function teParse(src){const out={spill:null,cap:{},net:{},up:{},prep:{},protect:false,drain:new Set(),avoid:new Set(),blackhole:false,errors:[],n:0};
|
||||
function teParse(src){const out={spill:null,tiers:[],cap:{},net:{},up:{},prep:{},protect:false,drain:new Set(),avoid:new Set(),blackhole:false,errors:[],n:0};
|
||||
const lines=String(src||'').split('\n').slice(0,60);
|
||||
lines.forEach((raw,i)=>{const line=raw.replace(/#.*/,'').trim().toLowerCase();if(!line)return;const L=i+1;let m;
|
||||
// A spill tier (#136): from this load on, detours that add at most this many milliseconds.
|
||||
if(m=line.match(/^spill\s+at\s+(\d{1,3})\s*%\s+within\s+(\d{1,3})\s*ms$/)){const v=+m[1],ms=+m[2];if(v<20||v>100)out.errors.push(tr('routescript.line_n_spill_must_be_between',{n:L}));else if(ms<1||ms>100)out.errors.push(tr('routescript.line_n_within_1_to_100_ms',{n:L}));else{out.tiers.push({at:v/100,ms});out.tiers.sort((a,b)=>a.at-b.at||a.ms-b.ms);out.n++;}return;}
|
||||
if(m=line.match(/^spill\s+at\s+(\d{1,3})\s*%$/)){const v=+m[1];if(v<20||v>100)out.errors.push(tr('routescript.line_n_spill_must_be_between',{n:L}));else{out.spill=v/100;out.n++;}return;}
|
||||
if(m=line.match(/^(prefer|avoid)\s+(pni|ix|transit)\s+for\s+(.+)$/)){const r=teFind(m[3],NETS,tr('common.network'));if(r.err){out.errors.push(tr('routescript.line_n_err',{n:L,err:r.err}));return;}const o=out.net[r.v]=out.net[r.v]||{};o[m[1]]=TE_KINDS[m[2]];out.n++;return;}
|
||||
if(m=line.match(/^cap\s+transit\s+(.+?)\s+at\s+(\d+(?:\.\d+)?)\s*(gbps|tbps|g|t)$/)){const r=teFind(m[1],NETS.filter(n=>n.price),tr('common.transit_provider'));if(r.err){out.errors.push(tr('routescript.line_n_err',{n:L,err:r.err}));return;}out.cap[r.v]=+m[2]*(m[3][0]==='t'?1000:1);out.n++;return;}
|
||||
|
|
@ -103,6 +108,7 @@ function teHelpModal(){const rule=(code,what)=>`<dt><code>${code}</code></dt><dd
|
|||
<li>${tr('routescript.deploy_makes_it_live_for_the')}</li></ul>
|
||||
<h3>${tr('common.rules')}</h3><dl>
|
||||
${rule('spill at 85%',tr('routescript.move_traffic_to_the_next_exit'))}
|
||||
${rule('spill at 80% within 10 ms',tr('routescript.from_this_load_on_spill_onto'))}
|
||||
${rule('prefer pni for goggle',tr('routescript.send_one_network_s_traffic_over'))}
|
||||
${rule('avoid transit for netchill',tr('routescript.use_that_kind_of_exit_for'))}
|
||||
${rule('cap transit cogentle at 20 gbps',tr('routescript.a_ceiling_on_one_provider_so'))}
|
||||
|
|
@ -122,7 +128,7 @@ function teModal(msg){const src=UI.teDraft!==undefined?UI.teDraft:(S.te.script||
|
|||
<p class="tagline">${tr('routescript.write_rules_check_them_against_live')}</p>
|
||||
<textarea id="teSrc" class="tecode" spellcheck="false" autocapitalize="off" autocomplete="off" rows="12">${esc(src)}</textarea>
|
||||
${msg||''}<div class="btns" style="margin-top:8px">${btn(tr('routescript.check_dry_run'),'teCheck',{},'')}${btn(tr('common.deploy'),'teDeploy',{},'pink')}${S.te.script?btn(tr('common.remove_script'),'teClear',{},'ghost sm'):''}${btn(tr('common.optimize'),'teOpt',{},'ghost sm')}${btn(tr('routescript.reset_to_example'),'teExample',{},'ghost sm')}</div><div class="btns" style="margin-top:6px">${btn('✨ '+tr('routescript.slop_it_with_ai'),'teSlop',{},'aibtn')}${btn(tr('routescript.help_and_ready_made_scripts'),'teHelp',{},'ghost sm')}</div>
|
||||
<p class="meta" style="margin-top:8px"><b>${tr('common.rules_7b18')}</b> <code>spill at 80%</code> · <code>prefer pni|ix|transit for NETWORK</code> · <code>avoid pni|ix|transit for NETWORK</code> · <code>cap transit PROVIDER at 20 gbps</code> · <code>prefer|avoid transit PROVIDER</code> · <code>prepend transit PROVIDER 1-3</code> · <code>protect customers</code> · <code>drain CITY</code> · <code>avoid link CITY-CITY</code> · <code>blackhole ddos</code></p>
|
||||
<p class="meta" style="margin-top:8px"><b>${tr('common.rules_7b18')}</b> <code>spill at 80%</code> · <code>spill at 80% within 10 ms</code> · <code>prefer pni|ix|transit for NETWORK</code> · <code>avoid pni|ix|transit for NETWORK</code> · <code>cap transit PROVIDER at 20 gbps</code> · <code>prefer|avoid transit PROVIDER</code> · <code>prepend transit PROVIDER 1-3</code> · <code>protect customers</code> · <code>drain CITY</code> · <code>avoid link CITY-CITY</code> · <code>blackhole ddos</code></p>
|
||||
${S.te.script?`<p class="meta">${tr('routescript.live_state_rules',{state:S.te.on?tr('common.deployed'):tr('routescript.controller_is_off'),rules:teRules()?tr('routescript.n_rules_active',{n:teRules().n}):tr('common.not_active')})}</p>`:''}`);}
|
||||
function teTrial(src){const keep=S.te.script,on=S.te.on,before={served:R.served,tc:R.cost.transit||0,moved:R.teMoved||0};
|
||||
S.te.script=src;S.te.on=true;compute();const after={served:R.served,tc:R.cost.transit||0,moved:R.teMoved||0,bh:R.teBlack||0};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ function routeCore(){
|
|||
// The day's state, set by nodes() and run(). (TR, base and eff, the ranks, are for the reference loop of the tests.)
|
||||
let NRES,NSEEN,NORD,NLOAD,EL,NKN,SEN,ACN,NC,SED,ACD,
|
||||
E,HAS,PASS,R2,FREM,FNJ,FCI,FCA,FBZ,NF,CNB,NCN,ev,day,SRV,TNS,NN,TNK,TORD,TNA,snd,LATP,FARL,EGT,EGO,NEG,NEO,NEA,FGT,FTI,FGI,FII,FGH,FGP,
|
||||
TE,SPILL,teCache,adj,CORE,OUT,REACH,DSEL,PREFC,BRJ,COMP,SDi,SPi,ALONE,TR,base,eff,
|
||||
TE,SPILL,TT,teCache,adj,CORE,OUT,REACH,DSEL,PREFC,BRJ,COMP,SDi,SPi,ALONE,TR,base,eff,
|
||||
NX=0,USED=null,CAPX=null,CIX=null,HPX=null,DTX=null,VISX=null,TEF=null,EP=0;
|
||||
// The flow being routed, and from its POP: distances, arriving edges and the paths walked so far, by city index.
|
||||
// F: its index; fci, fnj: its city and network index. BRX: BRJ with each list as a list object of one shape (lx()).
|
||||
|
|
@ -98,9 +98,35 @@ function routeCore(){
|
|||
// with free capacity, as long as they are no more than twice as long.
|
||||
const send=(x,want)=>{
|
||||
let room=Math.min(want,FREM[F],CAPX[x]-USED[x]);if(room<=1e-6)return;const ci=CIX[x];
|
||||
const P=PP[ci]||(PP[ci]=walkP(Pv,fci,ci));if(!P.dead)room-=push(x,P,room,TE&&SPILL<1?1-SPILL:0);
|
||||
const P=PP[ci]||(PP[ci]=walkP(Pv,fci,ci));if(TT&&ci!==fci){room=tiers(x,P,room,ci);if(room<=1e-6)return;}
|
||||
if(!P.dead)room-=push(x,P,room,TE&&SPILL<1?1-SPILL:0);
|
||||
if(TE&&room>1e-6&&FREM[F]>1e-6&&USED[x]<CAPX[x]&&ci!==fci)for(let k=0;k<2&&room>1e-6;k++){const P=altPath(fci,ci,Dv[ci]);if(!P)break;const m=push(x,P,Math.min(room,CAPX[x]-USED[x]));if(m<=1e-6)break;room-=m;R2.teMoved+=m;}
|
||||
};
|
||||
/* Spill tiers (#136, `spill at 80% within 10 ms`): the shortest path fills up to a tier's line, then what does not fit
|
||||
takes the fastest detour whose links are all still under that line, if it adds no more than the tier's milliseconds;
|
||||
the next tier lets links run hotter and detours longer. After the last tier the usual rules above take over. A detour
|
||||
is searched by latency over the links under the line (tierSearch), and kept per pair and tier while it still is:
|
||||
links only fill up while routing, so a pair with no detour under a line never gets one. */
|
||||
const pathMs=P=>{let ms=P.ms;if(ms<0){ms=0;const p=P.path;for(let k=0;k<p.length;k++)ms+=p[k].lat;P.ms=ms;}return ms;};
|
||||
let TC=null,TSD=null,TSP=null,TSS=null,TSG=0,TH=[],THU=[];
|
||||
const tierSearch=(src,dst,keep,lim)=>{const n=TEO.length-1,core=CORE;if(!TSD||TSD.length!==n){TSD=new Float64Array(n);TSP=new Array(n);TSS=new Int32Array(n);TSG=0;}
|
||||
const g=++TSG,D=TSD,P=TSP,ST=TSS;let m=0;D[src]=0;ST[src]=g;TH[0]=0;THU[0]=src;m=1;
|
||||
while(m){let best=0;for(let i=1;i<m;i++)if(TH[i]<TH[best])best=i;const d=TH[best],u=THU[best];m--;TH[best]=TH[m];THU[best]=THU[m];
|
||||
if(d>D[u])continue;if(u===dst)break;
|
||||
for(let k=TEO[u],K=TEO[u+1];k<K;k++){const v=TEN[k],e=TEE[k];if(!(e.res>e.cap*keep+1e-3)||(HAS[v]&&NRES[v]<=1e-3)||(core&&OUT[v]&&v!==dst))continue;
|
||||
const nd=d+e.lat;if(nd>lim||!(nd<(ST[v]===g?D[v]:Infinity)))continue;D[v]=nd;ST[v]=g;P[v]=e;TH[m]=nd;THU[m]=v;m++;}}
|
||||
return ST[dst]===g?walkP(P,src,dst):null;};
|
||||
const tierPath=(t,keep,src,dst,lim)=>{const key=(src*NC+dst)*TT.length+t,c=TC.get(key);if(c===false)return null;
|
||||
if(c){let ok=true;const p=c.path,ni=c.ni;for(let k=0;k<p.length;k++)if(!(p[k].res>p[k].cap*keep+1e-3)){ok=false;break;}
|
||||
if(ok)for(let k=0;k<ni.length;k++){const i=ni[k];if(HAS[i]&&!(NRES[i]>1e-3)){ok=false;break;}}
|
||||
if(ok)return pathMs(c)<=lim?c:null;}
|
||||
const Q=tierSearch(src,dst,keep,Infinity);TC.set(key,Q||false);return Q&&pathMs(Q)<=lim?Q:null;};
|
||||
const tiers=(x,P,room,ci)=>{for(let t=0;t<TT.length&&room>1e-6;t++){const T=TT[t],keep=1-T.at;
|
||||
room-=push(x,P,room,keep);
|
||||
if(room<=1e-6||FREM[F]<=1e-6||!(USED[x]<CAPX[x]))break;
|
||||
const Q=tierPath(t,keep,fci,ci,pathMs(P)+T.ms);if(!Q||Q.path===P.path)continue;
|
||||
const m=push(x,Q,Math.min(room,CAPX[x]-USED[x]),keep);if(m>1e-6){room-=m;R2.teMoved+=m;}}
|
||||
return room;};
|
||||
// Exits with the same preference and the same IGP distance form an ECMP group: spread the flow over
|
||||
// them by free capacity (like several transits in one city), then top up in order if one fills.
|
||||
// The group is g[i0..i1): plain loops and one scratch array, since this runs for most flows (same sums, same order).
|
||||
|
|
@ -204,10 +230,11 @@ function routeCore(){
|
|||
return {nodeTake,carry,
|
||||
nodes(o){({NRES,NSEEN,NORD,NLOAD,EL,NKN,SEN,ACN,NC,SED,ACD}=o);},
|
||||
run(o,PASSES,RANKS,RSET){({E,HAS,PASS,R2,FREM,FNJ,FCI,FCA,FBZ,NF,CNB,NCN,ev,day,SRV,TNS,NN,TNK,TORD,TNA,snd,LATP,FARL,EGT,EGO,NEG,NEO,NEA,FGT,FTI,FGI,FII,FGH,FGP,
|
||||
TE,SPILL,teCache,adj,CORE,OUT,REACH,DSEL,PREFC,BRJ,COMP,SDi,SPi,ALONE,TR,base,eff}=o);
|
||||
TE,SPILL,TT,teCache,adj,CORE,OUT,REACH,DSEL,PREFC,BRJ,COMP,SDi,SPi,ALONE,TR,base,eff}=o);
|
||||
NX=E.length;USED=new Float64Array(NX);CAPX=new Float64Array(NX);CIX=new Int32Array(NX);HPX=new Uint8Array(NX);DTX=new Float64Array(NX);VISX=new Int32Array(NX);
|
||||
for(let x=0;x<NX;x++){const e=E[x];USED[x]=e.used;CAPX[x]=e.cap;CIX[x]=e.ci;HPX[x]=e.hp;DTX[x]=e.dt;}
|
||||
F=0;fci=0;fnj=0;Dv=null;Pv=null;PP=null;vis=0;GN=0;walked=[];EP=0;LRs=-1;LRD=null;
|
||||
TC=TT?new Map():null;
|
||||
if(TE){const n=adj.length;TEO=new Int32Array(n+1);let k=0;for(let u=0;u<n;u++){TEO[u]=k;const a=adj[u];if(a)k+=a.length;}TEO[n]=k;
|
||||
TEN=new Int32Array(k);TEE=new Array(k);k=0;for(let u=0;u<n;u++){const a=adj[u];if(a)for(let j=0;j<a.length;j++){TEN[k]=a[j][0];TEE[k]=a[j][1];k++;}}}TEF=TE?new Uint8Array(NC*NC):null;
|
||||
const W=new Map();BRX=new Array(BRJ.length);for(let j=0;j<BRJ.length;j++){const m=BRJ[j],b={};for(const r in m)b[r]=lx(m[r],W);BRX[j]=b;}
|
||||
|
|
@ -218,7 +245,7 @@ function routeCore(){
|
|||
}
|
||||
for(let x=0;x<NX;x++)E[x].used=USED[x];
|
||||
// Nothing of this day is kept: the next run() sets its own.
|
||||
E=R2=BRJ=BRX=SDi=SPi=teCache=TEF=TEE=null;walked=[];}};
|
||||
E=R2=BRJ=BRX=SDi=SPi=teCache=TEF=TEE=TC=null;TSD=TSP=null;walked=[];}};
|
||||
}
|
||||
// The core in use (a test can put the plain one in its place: tests/speed.test.js).
|
||||
let ROUTE=routeCore();
|
||||
|
|
|
|||
|
|
@ -102,13 +102,15 @@ function compute(){RW.gen++;
|
|||
// Goggle video is throttled in Russia (#70): people there get half of it, so they ask for half. It is not
|
||||
// traffic you failed to deliver, and it does not cross your links only to be thrown away.
|
||||
const ru=ruCity(c),thr=n=>n==='ggl'&&ru?0.5:1;let sa=shArr.get(SH),sm=shSum.get(SH);if(!sa){shArr.set(SH,sa=NETS.map(n=>SH[n.id]||0));shSum.set(SH,sm=[]);}
|
||||
const tt=sm[+ru]||(sm[+ru]=[NETS.reduce((t,n,j)=>t+sa[j]*thr(n.id),0),NETS.reduce((t,n,j)=>t+sa[j],0)]),lf=loc?NETS.reduce((t,n,j)=>t+(R2.reachable[n.id]?sa[j]*thr(n.id):0),0)/(tt[0]||1):1,d=d0*tt[0]/(tt[1]||1)*lf;
|
||||
// This city's own split: its traffic to networks that sell to homes goes mostly to the ones whose users are near (#48).
|
||||
const ls=cityShares(SH,c);
|
||||
const tt=sm[+ru]||(sm[+ru]=[NETS.reduce((t,n,j)=>t+sa[j]*thr(n.id),0),NETS.reduce((t,n,j)=>t+sa[j],0)]),lf=loc?NETS.reduce((t,n,j)=>t+(R2.reachable[n.id]?ls[j]*thr(n.id):0),0)/(tt[0]||1):1,d=d0*tt[0]/(tt[1]||1)*lf;
|
||||
R2.cityEye[c]=eye;R2.cityDem[c]=d;R2.citySrv[c]=0;R2.demand+=d;
|
||||
for(let j=0;j<NN;j++)DEMTO[j]=(DEMTO[j]||0)+d0*sa[j]*thr(NETS[j].id);
|
||||
for(let j=0;j<NN;j++)DEMTO[j]=(DEMTO[j]||0)+d0*ls[j]*thr(NETS[j].id);
|
||||
if(!popUp(c))continue;CNB[ci]=cn;
|
||||
R2.cityBlocked=R2.cityBlocked||{};
|
||||
const mtuH=ev.pmtud&&ev.pmtud.until>day?ev.pmtud:null,kr=CITY[c].kr;
|
||||
for(let j=0;j<NN;j++){const n=NETS[j],a=(loc&&!R2.reachable[n.id]?0:d0)*sa[j]*thr(n.id)*(mtuH&&mtuH.net===n.id?mtuH.f:1)*(kr&&ev.krroute>day&&n.id==='fbk'?0.8:1);if(a<=0)continue;
|
||||
for(let j=0;j<NN;j++){const n=NETS[j],a=(loc&&!R2.reachable[n.id]?0:d0)*ls[j]*thr(n.id)*(mtuH&&mtuH.net===n.id?mtuH.f:1)*(kr&&ev.krroute>day&&n.id==='fbk'?0.8:1);if(a<=0)continue;
|
||||
// With `protect customers`, the business part first, then the rest (no arrays: this runs per city and network).
|
||||
const bf=d0>0?biz/d0:0,sp=!!(TRX&&TRX.protect&&bf>0),cn2=cacheNets.has(n.id);
|
||||
for(let q=0;q<(sp?2:1);q++){const x=sp?(q?a*(1-bf):a*bf):a,bz=sp&&!q;if(x<=0)continue;if(cn2){flow(ci,j,x*0.85,true,bz);flow(ci,j,x*0.15,false,bz);}
|
||||
|
|
@ -186,7 +188,7 @@ function compute(){RW.gen++;
|
|||
if(!R2.egDesc[ek])R2.egDesc[ek]={lab:clean?labOf(N_('compute.scrubbed_traffic_from_city'),'city',CITY[A].name):labOf(N_('compute.attack_entering_in_city'),'city',CITY[from].name),city:B,k:'l2'};
|
||||
for(const i of ni)if(HAS[i])nodeTake(i,amt);for(const l of path){l.res-=amt;l.ld+=amt;if(!clean){l.jk=(l.jk||0)+amt;JK=1;}carry(l,ek,clean?NN+2:NN,Bi,amt);}return amt;};
|
||||
const DD=ddosLoad({E,okBy,R2,autoBh:!!(TRX&&TRX.blackhole),haul,ms:msOf});
|
||||
const TE=!!(S.te&&S.te.on)&&coreTE(),TR=TE?teRules():null,REACH=coreTeReach();R2.teMoved=0;const teCache=new Map(),SPILL=TR&&TR.spill?TR.spill:1;
|
||||
const TE=!!(S.te&&S.te.on)&&coreTE(),TR=TE?teRules():null,REACH=coreTeReach();R2.teMoved=0;const teCache=new Map(),SPILL=TR&&TR.spill?TR.spill:1,TT=TR&&TR.tiers.length?TR.tiers:null;
|
||||
/* A network in a peer's customer cone, reached through that peer (#85): after every network you peer with directly
|
||||
(its AS path is one hop longer) and before transit. */
|
||||
const base=(e,n)=>e.pref==='low'?4:e.rank>0&&e.rank<3&&coneOf(e,n)?CONE_RANK:e.rank;
|
||||
|
|
@ -216,7 +218,7 @@ function compute(){RW.gen++;
|
|||
R.egT and R.netEg list them in; both are written back after routing. NEG: each network's R.netEg record. */
|
||||
const EGT=new Float64Array(4),EGO=[],NEA=new Float64Array(NN*4),NEO=[],NEG=[];
|
||||
ROUTE.run({E,HAS,PASS,R2,FREM,FNJ,FCI,FCA,FBZ,NF,CNB,NCN,ev,day,SRV,TNS,NN,TNK,TORD,TNA,snd,LATP,FARL,EGT,EGO,NEG,NEO,NEA,FGT,FTI,FGI,FII,FGH,FGP,
|
||||
TE,SPILL,teCache,adj,CORE,OUT,REACH,DSEL,PREFC,BRJ,COMP,SDi,SPi,ALONE,TR,base,eff},PASSES,RANKS,RSET);
|
||||
TE,SPILL,TT,teCache,adj,CORE,OUT,REACH,DSEL,PREFC,BRJ,COMP,SDi,SPi,ALONE,TR,base,eff},PASSES,RANKS,RSET);
|
||||
for(const i of NORD)R2.nodeLoad[CITIES[i].id]=NLOAD[i];
|
||||
for(const k of EGO)R2.egT[EXK[k]]=EGT[k];for(const j of NEO){const ne=NEG[j];for(let k=0;k<4;k++)ne[EXK[k]]=NEA[j*4+k];}
|
||||
(()=>{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ function sanitize(s){
|
|||
for(const c of Object.keys(s.pops)){const p=s.pops[c];if(!isCity(c)||!p||typeof p!=='object'){delete s.pops[c];continue;}p.routers=int(p.routers,1,RMAX,1);if(p.rupDay!==undefined)p.rupDay=num(p.rupDay,-1);if(p.rgen!==undefined)p.rgen=int(p.rgen,0,RG.length-1,0);p.down=num(p.down,0);if(p.bb&&typeof p.bb==='object')p.bb.d=num(p.bb.d,0);else p.bb=null;}
|
||||
if(!isCity(s.home))s.home=Object.keys(s.pops)[0]||'fra';
|
||||
opsSanitize(s);
|
||||
const tier=v=>int(v,0,PORT.length-1,0),lag=v=>int(v,1,LAG_MAX,1),sid=v=>String(v==null?uid():v).slice(0,40);
|
||||
const tier=v=>int(v,0,PORT.length-1,0),lag=v=>int(v,1,LAG_MAX,1),plag=v=>int(v,1,PNI_LAG_MAX,1),sid=v=>String(v==null?uid():v).slice(0,40);
|
||||
s.links=s.links.filter(l=>l&&isCity(l.a)&&isCity(l.b)&&l.a!==l.b).map(l=>{l.id=sid(l.id);if(l.list!==undefined){const L=l.kind==='df'?cmClean(l.list):null;if(L)l.list=L;else delete l.list;}l.km=num(l.km,kmBetween(l.a,l.b));l.mo=num(l.mo,0);l.cut=num(l.cut,0);if(l.cname!=null)l.cname=String(l.cname).slice(0,60);if(l.pairs!==undefined)l.pairs=Math.min(l.sub?SUB_PAIRS_MAX:s.lvl>=PAIRS_LV?PAIRS_BIG:PAIRS_MAX,Math.max(1,Math.floor(+l.pairs)||1));if(l.kind!=='df'&&l.kind!=='vxc')l.kind='wave';if(l.kind==='wave')l.tier=int(l.tier,0,LT.length-1,0);if(l.cable&&(!own(CAB,l.cable)||!cablePair(l.cable,l.a,l.b)))l.cable=null;if(l.kind==='vxc'&&!own(VXC,l.vt))l.vt=0;if(l.kind==='df'){if(!own(DF_SYS,l.sys))l.sys='lite';l.ch=Array.isArray(l.ch)?l.ch.filter(o=>own(OPT,o)):[];l.ready=num(l.ready,0);if(l.day!==undefined)l.day=Math.min(s.day,Math.max(0,num(l.day,s.day)));for(const k of Object.keys(SUB_UPGRADES)){const f='sub'+k;if(l[f]!==undefined){if(l.own&&l.sub&&Number.isFinite(l[f])&&l[f]>=0)l[f]=Math.round(l[f]);else delete l[f];}}if(l.seaPath!==undefined){if(l.own&&l.sub&&Array.isArray(l.seaPath)&&l.seaPath.length>=2&&l.seaPath.length<=2048&&l.seaPath.every(p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90))l.seaPath=l.seaPath.map(p=>p.slice());else delete l.seaPath;}if(l.paid!==undefined){if(l.own&&l.sub&&Number.isFinite(l.paid)&&l.paid>=0)l.paid=Math.round(l.paid);else delete l.paid;}if(l.own&&l.sub&&!own(SEA_DESIGNS,l.seaDesign))l.seaDesign='standard';l.regen=int(l.regen,0,REGEN_MAX,0);}const deg=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;if(l.loss)l.loss=deg(l.loss);return l;});
|
||||
for(const l of s.links)repairSubUpgradeDates(l,s.day);
|
||||
/* Metrics moved from each link to its city pair (#122). Older saves routed a pair at the lowest metric of its
|
||||
|
|
@ -32,9 +32,9 @@ function sanitize(s){
|
|||
if(!ks.has(k)||typeof v!=='string'||!own(MET,v)||v==='normal')delete pm[k];}}
|
||||
const degO=v=>v&&typeof v==='object'?{until:num(v.until,0),f:Math.min(1,Math.max(0,num(v.f,1)))}:null;
|
||||
s.transit=s.transit.filter(t=>t&&isCity(t.city)&&isNet(t.net)).map(t=>(t.lacp=degO(t.lacp),t.site=['a','b','ab'].includes(t.site)?t.site:'a',t.id=sid(t.id),t.tier=tier(t.tier),t.n=lag(t.n),t.down=num(t.down,0),t.clean=!!t.clean,t.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));
|
||||
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=plag(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;}}
|
||||
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:plag(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;}}
|
||||
// Supply chain: a shortage and a price lock, both optional.
|
||||
{const H=s.hw&&typeof s.hw==='object'&&!Array.isArray(s.hw)?s.hw:{},o={};const sh=H.shock,lk=H.lock;
|
||||
if(sh&&typeof sh==='object'&&own(HW_SHOCK,sh.k))o.shock={k:sh.k,until:num(sh.until,0),mul:clamp(num(sh.mul,1),1,2)};
|
||||
|
|
|
|||
|
|
@ -16,16 +16,60 @@ function eventTick(b,d){if(!BIZ_T[b.type].event)return false;if(d<b.start)return
|
|||
if(d<b.start+b.dur){b.srv=(b.srv||0)+sfOf(R,b.city);b.srvDays=(b.srvDays||0)+1;if(d===b.start)toast(tr('customers_and_events.name_starts_today_bw_of_extra',{name:esc(b.name),bw:fmtG(b.bw),city:CITY[b.city].name,d:b.dur}),'goal',[{l:tr('common.show_me'),act:'focusCity',args:{city:b.city}}]);return true;}
|
||||
const avg=b.srvDays?b.srv/b.srvDays:0;if(avg>=0.95)S.stats.evFull=(S.stats.evFull||0)+1;const pay=avg>=0.95?b.fee:avg>=0.7?Math.round(b.fee*avg):-Math.round(b.fee*0.2);S.cash+=pay;S.biz=S.biz.filter(x=>x!==b);
|
||||
toast(pay>=0?tr('customers_and_events.name_is_over_pay_you_delivered',{name:esc(b.name),pay:fmt$(pay),pct:pct(avg)})+(avg>=0.95?' '+tr('common.flawless'):''):tr('customers_and_events.name_was_a_disaster_only_pct',{name:esc(b.name),pct:pct(avg),pay:fmt$(-pay)}),pay>=0?'good':'bad');sfx(pay>=0?'coin':'err');return true;}
|
||||
/* Where the giants actually build: gigawatt AI campuses and cloud regions, mapped to the nearest city on the map. */
|
||||
const MEGA=[{c:'ash',n:'Data Center Alley'},{c:'ash',n:'Prome-the-mess Ohio'},{c:'dal',n:'Star-Gait Abilene'},{c:'dal',n:'Hyperbole Louisiana'},{c:'dal',n:'Colossus of Blues Memphis'},{c:'chi',n:'Fairweather Wisconsin'},{c:'chi',n:'Project Rainy-er Indiana'},{c:'chi',n:'Cornfield Cluster Iowa'},{c:'nyc',n:'Neocloud New Jersey'},{c:'sto',n:'Star-Gait Fjord-way'},{c:'mad',n:'Aragón Mega-shed'},{c:'dub',n:'Bring-Your-Own-Power Dublin'},{c:'auh',n:'Star-Gait UAE'},{c:'ruh',n:'Desert Kingdom AI Campus'},{c:'doh',n:'Lusail Data Oasis'},{c:'kul',n:'Johor Overflow'},{c:'hyd',n:'Vizag AI Hub'},{c:'icn',n:'Ulsan AI Campus'},{c:'tok',n:'Hokkaido Snow DC'},{c:'syd',n:'Star-Gait Down Under'},{c:'syd',n:'AirDrunk Western Sydney'},{c:'mel',n:'AirDrunk Melbourne West'},{c:'mex',n:'Querétaro Cluster'},{c:'for',n:'Short-Video Ceará Campus'},{c:'scl',n:'Quilicura Region'}];
|
||||
/* Where the giants actually build: gigawatt AI campuses and cloud regions, mapped to the nearest city on the map (#61:
|
||||
not just five metros; real campuses sit all over, from Oregon to Wyoming to Querétaro). w: a hub that draws more. */
|
||||
const MEGA=[
|
||||
{c:'ash',n:'Data Center Alley',w:2},
|
||||
{c:'atn',n:'Peach-flops Georgia'},
|
||||
{c:'auh',n:'Star-Gait UAE'},
|
||||
{c:'aus',n:'Taylor-Made Texas Campus'},
|
||||
{c:'chi',n:'Fairweather Wisconsin'},
|
||||
{c:'chi',n:'Project Rainy-er Indiana'},
|
||||
{c:'cmh',n:'Prome-the-mess Ohio'},
|
||||
{c:'csn',n:'Biggest Little Cluster Reno'},
|
||||
{c:'cys',n:'Wind Chill Wyoming Campus'},
|
||||
{c:'dal',n:'Star-Gait Abilene'},
|
||||
{c:'doh',n:'Lusail Data Oasis'},
|
||||
{c:'dsm',n:'Cornfield Cluster Iowa'},
|
||||
{c:'dub',n:'Bring-Your-Own-Power Dublin'},
|
||||
{c:'for',n:'Short-Video Ceará Campus'},
|
||||
{c:'hyd',n:'Vizag AI Hub'},
|
||||
{c:'icn',n:'Ulsan AI Campus'},
|
||||
{c:'jan',n:'Hyperbole Louisiana'},
|
||||
{c:'kcy',n:'Burnt Ends Bit Barn'},
|
||||
{c:'kul',n:'Johor Overflow'},
|
||||
{c:'lit',n:'Colossus of Blues Memphis'},
|
||||
{c:'mad',n:'Aragón Mega-shed'},
|
||||
{c:'mel',n:'AirDrunk Melbourne West'},
|
||||
{c:'mty',n:'Norteño Nodes Nuevo León'},
|
||||
{c:'nyc',n:'Neocloud New Jersey'},
|
||||
{c:'phx',n:'Mesa-ive Compute Arizona'},
|
||||
{c:'qro',n:'Querétaro Cluster'},
|
||||
{c:'ric',n:'Henrico Hyperscale Hustle'},
|
||||
{c:'ruh',n:'Desert Kingdom AI Campus'},
|
||||
{c:'scl',n:'Quilicura Region'},
|
||||
{c:'sea',n:'Quincy-dence Washington'},
|
||||
{c:'sle',n:'Dilly-Dalles Oregon'},
|
||||
{c:'sto',n:'Star-Gait Fjord-way'},
|
||||
{c:'syd',n:'AirDrunk Western Sydney'},
|
||||
{c:'syd',n:'Star-Gait Down Under'},
|
||||
{c:'tok',n:'Hokkaido Snow DC'},
|
||||
{c:'yqb',n:'Hydro-Chill Québec'},
|
||||
];
|
||||
/* A campus is picked by its weight, less where giant circuits already crowd the city (#61): a metro that carries as much
|
||||
as the average busy one draws half as often, three times as much a quarter. Hubs stay a bit busier, never the only ones. */
|
||||
function megaLoad(){const m=new Map(),add=(c,v)=>{if(c)m.set(c,(m.get(c)||0)+v);};
|
||||
for(const o of S.biz.concat(S.offers||[])){const T=BIZ_T[o.type];if(!T||!T.mega||!T.l2)continue;for(const c of bCities(o))add(c,o.bw||0);}return m;}
|
||||
function megaPick(list,ld){let tot=0,k=0;for(const v of ld.values()){tot+=v;k++;}const avg=k?tot/k:0,w=list.map(m=>(m.w||1)/(1+(avg>0?(ld.get(m.c)||0)/avg:0)));
|
||||
let r=Math.random()*w.reduce((a,b)=>a+b,0);for(let i=0;i<list.length;i++){r-=w[i];if(r<0)return list[i];}return list[list.length-1];}
|
||||
function spawnMega(t,T,nm,mine){
|
||||
const megaMine=MEGA.filter(m=>mine.includes(m.c));if(!megaMine.length)return;
|
||||
if(t==='ingest'){const m=pick(megaMine),bw=pick(T.opts),dur=3+Math.floor(Math.random()*4),start=S.day+10+Math.floor(Math.random()*12);
|
||||
const megaMine=MEGA.filter(m=>mine.includes(m.c));if(!megaMine.length)return;const ld=megaLoad();
|
||||
if(t==='ingest'){const m=megaPick(megaMine,ld),bw=pick(T.opts),dur=3+Math.floor(Math.random()*4),start=S.day+10+Math.floor(Math.random()*12);
|
||||
S.offers.push({id:uid(),city:m.c,city2:null,name:tr('customers_and_events.name_at_site',{name:nm(),site:m.n}),type:t,bw,rate:0,reqs:[],start,dur,fee:Math.round(bw*dur*55),exp:start-2,mega:true});return;}
|
||||
if(t==='aiwan'||t==='agi'){const a=pick(megaMine),others=MEGA.filter(m=>m.c!==a.c&&(Math.random()<0.7?mine.includes(m.c):true));if(!others.length)return;const b=pick(others);if(!reqCan('diverse',{city:a.c,city2:b.c}))return;const km=kmBetween(a.c,b.c),bw=pick(T.opts);
|
||||
if(t==='aiwan'||t==='agi'){const a=megaPick(megaMine,ld),others=MEGA.filter(m=>m.c!==a.c&&(Math.random()<0.7?mine.includes(m.c):true));if(!others.length)return;const b=megaPick(others,ld);if(!reqCan('diverse',{city:a.c,city2:b.c}))return;const km=kmBetween(a.c,b.c),bw=pick(T.opts);
|
||||
const reqs=['diverse'];if(Math.random()<0.4)reqs.push('metro');
|
||||
S.offers.push({id:uid(),city:a.c,city2:b.c,name:`${nm()}: ${a.n} ⇄ ${b.n}`,type:t,bw,rate:Math.round((150+km*0.08)*T.km),reqs,exp:S.day+45,mega:true});return;}
|
||||
if(t==='mtrain'){const hub=pick(megaMine),reg=CITY[hub.c].reg,pool=[...new Set(MEGA.filter(m=>m.c!==hub.c&&CITY[m.c].reg===reg).map(m=>m.c))];if(pool.length<2)return;
|
||||
if(t==='mtrain'){const hub=megaPick(megaMine,ld),reg=CITY[hub.c].reg,pool=[...new Set(MEGA.filter(m=>m.c!==hub.c&&CITY[m.c].reg===reg).map(m=>m.c))];if(pool.length<2)return;
|
||||
const sites=[hub.c];while(sites.length<Math.min(4,pool.length+1)&&pool.length)sites.push(pool.splice(Math.floor(Math.random()*pool.length),1)[0]);
|
||||
const avg=sites.slice(1).reduce((x,c)=>x+kmBetween(hub.c,c),0)/(sites.length-1),bw=pick(T.opts);
|
||||
S.offers.push({id:uid(),city:hub.c,city2:null,sites,name:tr('customers_and_events.name_hub_site',{name:nm(),site:hub.n}),type:t,bw,rate:Math.round((150+avg*0.08)*0.6),reqs:[],exp:S.day+45,mega:true});return;}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Object.assign(ACT,{
|
|||
ad:({city})=>{const p=S.pops[city];if(!p||!p.bb)return;if(!spend(8000))return;p.boost=S.day+30;floater(CITY[city].x,CITY[city].y-30,tr('common.ad_campaign'),'#FF8A3D');after();},
|
||||
buyTransit:({city,net,tier})=>{tier=+tier;if(scnRule('noTransit')){toast(tr('pops_transit_ix.no_transit_in_this_scenario_peering'),'bad');sfx('err');return;}if(!S.pops[city]||!NET[net]||!sellsAt(NET[net],city)||!PORT[tier])return;if(!portOk(city,tier)){toast(tr('actions.your_router_can_t_take_a',{port:PORT[tier].n}),'bad');sfx('err');return;}const ex=S.transit.find(t=>t.city===city&&t.net===net);if(ex&&tier<=ex.tier)return;if(!portGate(city,ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(tier)))return;if(!spend(PORT[tier].setup*(ex&&ex.n||1)))return;if(ex)ex.tier=tier;else S.transit.push({id:uid(),city,net,tier,down:0,...(premOnlyAt(NET[net],city)?{premium:true}:{})});toast(tr('pops_transit_ix.net_transit_is_live_in_city',{net:esc(NET[net].name),city:CITY[city].name}),'good');after();},
|
||||
lagT:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;const t=S.transit.find(x=>x.id===id);if(!t)return;const n=(t.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0){if(!portOk(t.city,t.tier)||!portGate(t.city,PORT_SLOT(t.tier)))return;if(!spend(PORT[t.tier].setup))return;}t.n=n;if(n<2&&t.site==='ab')t.site='a';toast(+d>0?tr('pops_transit_ix.lag_member_added_net_in_city',{net:esc(NET[t.net].name),city:CITY[t.city].name,lag:lagName(t.tier,n)}):tr('pops_transit_ix.lag_member_removed'),'good');after();},
|
||||
lagP:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;const p=S.pni.find(x=>x.id===id);if(!p)return;const n=(p.n||1)+(+d);if(n<1||n>LAG_MAX)return;if(d>0&&(!pniOn(p)||p.up||msfNope(p.net,p.city)))return;if(+d>0&&(!portGate(p.city,PORT_SLOT(p.tier))||!spend(1500+PORT[p.tier].setup/2)))return;
|
||||
lagP:({id,d})=>{d=+d;if(d!==1&&d!==-1)return;const p=S.pni.find(x=>x.id===id);if(!p)return;const n=(p.n||1)+(+d);if(n<1||n>PNI_LAG_MAX)return;if(d>0&&n>pniLagMax(p.city)){toast(tr('pops_transit_ix.this_pni_already_bundles_n_ports',{n:n-1,more:PNI_LAG_RT,max:PNI_LAG_MAX}),'bad');sfx('err');return;}if(d>0&&(!pniOn(p)||p.up||msfNope(p.net,p.city)))return;if(+d>0&&(!portGate(p.city,PORT_SLOT(p.tier))||!spend(1500+PORT[p.tier].setup/2)))return;
|
||||
// A LAG member is an augment: the big networks take months for that too.
|
||||
if(d>0){const lead=pniLead(p.net);p.up={tier:p.tier,n,ready:S.day+lead,g1:!!p.g1};if(!lead)pniUpDone(p);toast(lead?tr('pops_transit_ix.augment_ordered_with_net_eta',{net:esc(NET[p.net].name),eta:pniWhen(lead)}):tr('pops_transit_ix.augment_with_net_is_up',{net:esc(NET[p.net].name),port:p.n+'×'+pniPN(p)}),'good');after();return;}p.n=n;if(n<2&&p.site==='ab')p.site='a';sfx('build');after();},
|
||||
lagIx:({city,d})=>{d=+d;if(d!==1&&d!==-1)return;if(!isIx(city)||S.ixp[city]===undefined||S.myIx[city]||!S.pops[ixCity(city)])return;S.ixn=S.ixn||{};const n=(S.ixn[city]||1)+(+d);if(n<1||n>LAG_MAX)return;if(+d>0&&(!portGate(ixCity(city),PORT_SLOT(S.ixp[city]))||!spend(ixPortMo(city,S.ixp[city]))))return;S.ixn[city]=n;if(n<2&&S.ixSite&&S.ixSite[city]==='ab')S.ixSite[city]='a';sfx('build');after();},
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Object.assign(ACT,{
|
|||
popStdClear:()=>{S.popStd=null;sfx('click');after();},
|
||||
addRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)>=RMAX)return;if(!spend(routerCost(p.rgen||0,p.routers||1)))return;p.routers=(p.routers||1)+1;floater(CITY[city].x,CITY[city].y-30,tr('common.router_added'),'#FF4F9A');after();},
|
||||
models:()=>{UI.models=!UI.models;renderPanel();},
|
||||
rmRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)<=1)return;if(portsUsed(city)>portsMax(city,undefined,p.routers-1)){toast(tr('routing_and_routers.unplug_something_first_used_ports',{used:fmtPorts(portsUsed(city)),max:portsMax(city,undefined,p.routers-1)}),'bad');sfx('err');return;}p.routers--;{const back=tradeIn(p.rgen||0,1);if(back>0){S.cash+=back;toast(tr('routing_and_routers.sold_a_model_on_ebuy_price',{model:esc(RG[p.rgen||0].n),price:fmt$(back)}),'good');}}after();},
|
||||
rmRouter:({city})=>{const p=S.pops[city];if(!p||(p.routers||1)<=1)return;{const m=Math.min(PNI_LAG_MAX,PNI_LAG_RT*(p.routers-1)),big=S.pni.find(x=>x.city===city&&Math.max(x.n||1,(x.up&&x.up.n)||1)>m);if(big){toast(tr('routing_and_routers.a_pni_here_bundles_n_ports',{net:esc(NET[big.net].name),n:Math.max(big.n||1,(big.up&&big.up.n)||1),m}),'bad');sfx('err');return;}}if(portsUsed(city)>portsMax(city,undefined,p.routers-1)){toast(tr('routing_and_routers.unplug_something_first_used_ports',{used:fmtPorts(portsUsed(city)),max:portsMax(city,undefined,p.routers-1)}),'bad');sfx('err');return;}p.routers--;{const back=tradeIn(p.rgen||0,1);if(back>0){S.cash+=back;toast(tr('routing_and_routers.sold_a_model_on_ebuy_price',{model:esc(RG[p.rgen||0].n),price:fmt$(back)}),'good');}}after();},
|
||||
upRouter:({city,g})=>{const p=S.pops[city];if(!p)return;g=g===undefined?mainRG(RG[p.rgen||0].cls+1):+g;if(!RG[g]||g===(p.rgen||0))return;{const why=modelFits(city,g);if(why){toast(tr('routing_and_routers.the_model_won_t_fit_why',{model:esc(RG[g].n),why:esc(why)}),'bad');sfx('err');return;}}if(!techOk('rg',g,RG[g].lvl)){toast(tr('routing_and_routers.model_unlocks_at_customer_level_lv',{model:esc(RG[g].n),lv:RG[g].lvl}),'bad');sfx('err');return;}
|
||||
const rt=p.routers||1,old=p.rgen||0;if(p.rupDay===S.day){toast(tr('routing_and_routers.the_new_routers_in_city_are',{city:CITY[city].name}),'bad');sfx('err');return;}const back=tradeIn(old,rt);if(!spend(swapCost(city,g)))return;p.rgen=g;p.rupDay=S.day;if(back>0)toast(tr('routing_and_routers.sold_the_old_model_on_ebuy',{model:esc(RG[old].n),price:fmt$(back)}),'good');
|
||||
if(rt===1&&popIdle(city))toast(tr('routing_and_routers.new_router_in_city_swapped_before',{city:CITY[city].name}),'good');
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function pniValLine(n,c,v){
|
|||
return `<div class="meta pval" title="${esc(tr('pni_list.saves_minus_cost',{saved:fmt$(Math.round(v.saved)),cost:fmt$(Math.round(v.cost))}))}">${tr('pni_list.n_here',{g:fmtG(v.want)})}: ${via} → ${tr('pni_list.with_port',{port:PORT[v.tier].n,val})}</div>`;}
|
||||
function pniRow(c,n,pn,v,chk){let h=`<div class="row prow">${logo(n)}<div class="grow"><div class="nm">${esc(n.name)} <span class="tag ${n.pol}">${n.pol}</span>${v&&v.worth?` <span class="tag worth">⭐ ${tr('pni_list.worth_it')}</span>`:''}</div><div class="pchips">${pniChip(n.id,c)}</div>${v?pniValLine(n,c,v):''}`;
|
||||
if(pn&&!pniOn(pn))h+=pniWait(pn,c);
|
||||
else if(pn){const u=R.usePni[pn.id]||0,cap=lagCap(pniG(pn),pn.n);h+=`<div class="kv"><span>${(pn.n||1)>1?`${pn.n}×${pniPN(pn)} LAG`:pniPN(pn)} PNI</span><b>${fmtG(u)}</b></div>${pn.up?`<div class="meta">${tr('city_panel.augment_on_order_port_about_n',{port:(pn.up.n>1?pn.up.n+'×':'')+(pn.up.g1?'1G':PORT[pn.up.tier].n),n:Math.max(0,pn.up.ready-S.day)})} ${btn(tr('common.chase_it'),'pniChase',{id:pn.id},'ghost sm')}</div>`:''}<div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('p',pn.id,pn.pref)}${siteCtl('p',pn.id,c,pn.up&&pn.up.site==='ab'?'ab':pn.site)}<div class="btns">${PORT.map((P2,i)=>!pn.up&&!msfNope(n.id,c)&&(i>pn.tier||(pn.g1&&i===0))?btn((a=>(pn.n||1)>1?tr('common.upgrade_all_to_port_cost_mo',a):tr('common.upgrade_port_cost_mo_mo',a))({port:P2.n,cost:fmt$((1500+P2.setup/2)*(pn.n||1)),mo:fmt$(P2.pni*(pn.n||1))}),'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)||S.cash<(1500+P2.setup/2)*(pn.n||1)):'').join('')}${!pn.up&&!pn.g1&&pn.tier>pniMin(n.id)&&!msfNope(n.id,c)?btn(tr('link_panels.downgrade_port_price',{port:PORT[pn.tier-1].n,price:portMo(PORT[pn.tier-1].pni*(pn.n||1))}),'downP',{id:pn.id},'ghost sm'):''}${(pn.n||1)<LAG_MAX&&!pn.up&&!msfNope(n.id,c)?btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(1500+PORT[pn.tier].setup/2),mo:fmt$(PORT[pn.tier].pni)}),'lagP',{id:pn.id,d:1},'sm',S.cash<1500+PORT[pn.tier].setup/2):''}${(pn.n||1)>1?btn(tr('common.member'),'lagP',{id:pn.id,d:-1},'ghost sm'):''}${NET[n.id].cn?btn(pn.sacrif?tr('common.sacrificial_choke'):tr('city_panel.make_sacrificial_contains_floods_1_2'),'sacrif',{id:pn.id},pn.sacrif?'green sm':'sm'):''}${btn(UI.confirm===pn.id?tr('common.really_remove'):tr('common.remove'),'cancelPni',{id:pn.id},'ghost sm')}</div>`;}
|
||||
else if(pn){const u=R.usePni[pn.id]||0,cap=lagCap(pniG(pn),pn.n);h+=`<div class="kv"><span>${(pn.n||1)>1?`${pn.n}×${pniPN(pn)} LAG`:pniPN(pn)} PNI</span><b>${fmtG(u)}</b></div>${pn.up?`<div class="meta">${tr('city_panel.augment_on_order_port_about_n',{port:(pn.up.n>1?pn.up.n+'×':'')+(pn.up.g1?'1G':PORT[pn.up.tier].n),n:Math.max(0,pn.up.ready-S.day)})} ${btn(tr('common.chase_it'),'pniChase',{id:pn.id},'ghost sm')}</div>`:''}<div class="bar ${barCls(u/cap)}"><i style="width:${u/cap*100}%"></i></div>${prefCtl('p',pn.id,pn.pref)}${siteCtl('p',pn.id,c,pn.up&&pn.up.site==='ab'?'ab':pn.site)}${(pn.n||1)>=pniLagMax(c)&&(pn.n||1)<PNI_LAG_MAX&&!pn.up?`<div class="meta">${tr('pni_list.lag_full_add_a_router',{n:pn.n||1,more:PNI_LAG_RT,max:PNI_LAG_MAX})}</div>`:''}<div class="btns">${PORT.map((P2,i)=>!pn.up&&!msfNope(n.id,c)&&(i>pn.tier||(pn.g1&&i===0))?btn((a=>(pn.n||1)>1?tr('common.upgrade_all_to_port_cost_mo',a):tr('common.upgrade_port_cost_mo_mo',a))({port:P2.n,cost:fmt$((1500+P2.setup/2)*(pn.n||1)),mo:fmt$(P2.pni*(pn.n||1))}),'pni',{city:c,net:n.id,tier:i},'sm',!portOk(c,i)||S.cash<(1500+P2.setup/2)*(pn.n||1)):'').join('')}${!pn.up&&!pn.g1&&pn.tier>pniMin(n.id)&&!msfNope(n.id,c)?btn(tr('link_panels.downgrade_port_price',{port:PORT[pn.tier-1].n,price:portMo(PORT[pn.tier-1].pni*(pn.n||1))}),'downP',{id:pn.id},'ghost sm'):''}${(pn.n||1)<pniLagMax(c)&&!pn.up&&!msfNope(n.id,c)?btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(1500+PORT[pn.tier].setup/2),mo:fmt$(PORT[pn.tier].pni)}),'lagP',{id:pn.id,d:1},'sm',S.cash<1500+PORT[pn.tier].setup/2):''}${(pn.n||1)>1?btn(tr('common.member'),'lagP',{id:pn.id,d:-1},'ghost sm'):''}${NET[n.id].cn?btn(pn.sacrif?tr('common.sacrificial_choke'):tr('city_panel.make_sacrificial_contains_floods_1_2'),'sacrif',{id:pn.id},pn.sacrif?'green sm':'sm'):''}${btn(UI.confirm===pn.id?tr('common.really_remove'):tr('common.remove'),'cancelPni',{id:pn.id},'ghost sm')}</div>`;}
|
||||
else{h+=chk.ok?`<div class="btns">${pniG1(n.id)?btn(tr('city_panel.port_cost_mo_mo',{port:'1G',cost:fmt$(PNI_G1_COST),mo:fmt$(Math.round(PORT[0].pni/2))}),'pni',{city:c,net:n.id,tier:-1},'sm',S.cash<PNI_G1_COST||!portOk(c,0)):''}${PORT.map((P2,i)=>portShown(i)&&i>=pniMin(n.id)?btn(tr('city_panel.port_cost_mo_mo',{port:P2.n,cost:fmt$(1500+P2.setup/2),mo:fmt$(P2.pni)}),'pni',{city:c,net:n.id,tier:i},'sm',S.cash<1500+P2.setup/2||!portOk(c,i)):'').join('')}</div><div class="meta">${pniEta(n.id)}${pniMin(n.id)?' · '+tr('city_panel.no_10g_net_starts_at_100g',{net:esc(n.name)}):pniG1(n.id)?' · '+tr('city_panel.sells_pnis_down_to_1g'):''}</div>${chk.fee?`<div class="meta">${tr('city_panel.paid_peering_price_mo_on_top',{price:fmt$(chk.fee)})}</div>`:''}`:`<div class="why">${esc(chk.why)}</div>`;}
|
||||
return h+`</div></div>`;}
|
||||
function pniListHtml(c){const f=UI.pniF||'all',az=UI.pniSort==='az',open=UI.pniOpen||{};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ function connUp(r){if(r.mine)return '';const nx=t=>PORT[t+1]&&portShown(t+1)?t+1
|
|||
if(n<LAG_MAX)h+=btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(PORT[t.tier].setup),mo:fmt$(PORT[t.tier].tmo)}),'lagT',{id:t.id,d:1},'sm',S.cash<PORT[t.tier].setup||!portOk(t.city,t.tier));}
|
||||
else if(r.k==='p'){const p=S.pni.find(x=>x.id===r.id);if(!p)return '';if(!pniOn(p)||p.up||msfNope(p.net,p.city))return `<span class="meta">${!pniOn(p)||p.up?tr('common.on_order'):''}</span>`;const n=p.n||1,i=p.g1?0:nx(p.tier),c=i>=0?(1500+PORT[i].setup/2)*n:0;
|
||||
if(i>=0){const a={port:PORT[i].n,cost:fmt$(c),mo:fmt$(PORT[i].pni*n)};h+=btn(n>1?tr('common.upgrade_all_to_port_cost_mo',a):tr('common.upgrade_port_cost_mo_mo',a),'pni',{city:p.city,net:p.net,tier:i},'sm',!portOk(p.city,i)||S.cash<c);}
|
||||
if(n<LAG_MAX)h+=btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(1500+PORT[p.tier].setup/2),mo:fmt$(PORT[p.tier].pni)}),'lagP',{id:p.id,d:1},'sm',S.cash<1500+PORT[p.tier].setup/2);}
|
||||
if(n<pniLagMax(p.city))h+=btn(tr('common.lag_member_cost_mo_mo',{cost:fmt$(1500+PORT[p.tier].setup/2),mo:fmt$(PORT[p.tier].pni)}),'lagP',{id:p.id,d:1},'sm',S.cash<1500+PORT[p.tier].setup/2);}
|
||||
else if(r.k==='ix'){const c=r.id,city=ixCity(c),n=(S.ixn||{})[c]||1,i=nx(S.ixp[c]);
|
||||
if(i>=0)h+=btn(tr('common.upgrade_port_price',{port:PORT[i].n,price:portMo(ixPortMo(c,i)*n)}),'buyIx',{city:c,tier:i},'sm',(!!S.pops[city]&&!portOk(city,i))||(!S.pops[city]&&i>1));
|
||||
if(S.pops[city]&&!S.myIx[c]&&n<LAG_MAX)h+=btn(tr('common.lag_member_price',{price:portMo(ixPortMo(c,S.ixp[c]))}),'lagIx',{city:c,d:1},'sm',S.cash<ixPortMo(c,S.ixp[c]));}
|
||||
|
|
|
|||
|
|
@ -3903,6 +3903,7 @@
|
|||
"pni_list.f_pni":"Already PNI",
|
||||
"pni_list.f_transit":"Via transit",
|
||||
"pni_list.f_worth":"Worth it",
|
||||
"pni_list.lag_full_add_a_router":"LAG full at {n} members: each router here holds {more}, up to {max}. Add a router to grow it.",
|
||||
"pni_list.list_more":"{list} +{n}",
|
||||
"pni_list.little_to_gain_here":"Little to gain here: {g}",
|
||||
"pni_list.n_here":"{g} here",
|
||||
|
|
@ -3986,6 +3987,7 @@
|
|||
"pops_transit_ix.router_installed_in_city_upside_down":"<b>Router installed in {city}.</b><br>Upside down, as is customary down here. The packets don’t seem to mind.",
|
||||
"pops_transit_ix.signed_with_de_kicks_welcome_to":"<b>Signed with DE-KICKS.</b><br>Welcome to the family. Please don't tell anyone what you pay.",
|
||||
"pops_transit_ix.stay_take_the_discount":"Stay, take the discount",
|
||||
"pops_transit_ix.this_pni_already_bundles_n_ports":"<b>This PNI already bundles {n} ports</b>, all your routers here can hold. Each router takes {more} members of a PNI, up to {max}: add a router for more.",
|
||||
"pops_transit_ix.wait_before_you_go":"Wait! Before you go…",
|
||||
"pops_transit_ix.we_value_our_partnership_too_much":"We value our partnership too much to let a little thing like price get in the way.",
|
||||
"pops_transit_ix.you_need_a_license_first_foreign":"<b>You need a license first.</b><br>Foreign networks need a joint venture to build in mainland China.",
|
||||
|
|
@ -4364,6 +4366,7 @@
|
|||
"routescript.every_gigabit_leaving_your_network_picks":"Every gigabit leaving your network picks an exit: a PNI, an IX port or a transit port. Left alone, it takes the nearest peering with room (a PNI before an IX port in the same city), and transit only when no peering can take it. RouteScript changes those choices, the way local-pref, AS-path prepending and maintenance drains do on real routers.",
|
||||
"routescript.filled_in_from_your_network_as":"Filled in from your network as it is right now. Load one, read it, check it, then deploy.",
|
||||
"routescript.for_a_ddos_rtbh_the_target":"For a DDoS: blackhole the target upstream and keep business customers first. The target is dark while it lasts, so remove it when the attack is over.",
|
||||
"routescript.from_this_load_on_spill_onto":"A spill tier: once the shortest path is this full, the overflow takes the best detour if it adds no more than these milliseconds and stays under the same line. Stack them (80% within 10 ms, 90% within 20 ms) to spill earlier and further as links get hotter.",
|
||||
"routescript.great_question_here_is_a_production":"Great question! Here is a production-ready script, tailored to your live traffic. I checked it thoroughly.",
|
||||
"routescript.help_and_ready_made_scripts":"Help and ready-made scripts",
|
||||
"routescript.here_you_go_i_was_trained":"Here you go! I was trained on every router config ever posted to a forum, including the ones titled “why is this broken”.",
|
||||
|
|
@ -4375,6 +4378,7 @@
|
|||
"routescript.line_n_i_don_t_understand":"line {n}: I don't understand “{text}”. Try: spill at 80%, prefer pni for goggle, avoid transit for netchill, cap transit cogentle at 20 gbps, drain paris, avoid link fra-ams, blackhole ddos",
|
||||
"routescript.line_n_prepend_1_to_3":"line {n}: prepend 1 to 3 times",
|
||||
"routescript.line_n_spill_must_be_between":"line {n}: spill must be between 20% and 100%",
|
||||
"routescript.line_n_within_1_to_100_ms":"line {n}: within must be between 1 and 100 ms",
|
||||
"routescript.live_state_rules":"Live: {state} · {rules}",
|
||||
"routescript.maintenance_window_change_the_names":"# Maintenance Window: change the names, deploy, do the work, then remove it.",
|
||||
"routescript.missing_what":"missing {what}",
|
||||
|
|
@ -4411,6 +4415,7 @@
|
|||
"routing.routing_and_ddos":"Routing & DDoS",
|
||||
"routing.trace_note":"Follow one packet hop by hop and see why it leaves where it does.",
|
||||
"routing.trace_run":"Trace",
|
||||
"routing_and_routers.a_pni_here_bundles_n_ports":"<b>Shrink a PNI first.</b><br>Your PNI with {net} bundles {n} ports, and one router fewer holds only {m}.",
|
||||
"routing_and_routers.maintenance_window_in_city":"Maintenance window in {city}",
|
||||
"routing_and_routers.model_unlocks_at_customer_level_lv":"<b>{model} unlocks at customer level {lv}.</b>",
|
||||
"routing_and_routers.new_router_in_city_swapped_before":"<b>New router in {city}</b><br>Swapped before anything was plugged in: zero downtime, zero angry customers.",
|
||||
|
|
|
|||
|
|
@ -189,7 +189,8 @@ test('a customer dropped while a sales trial routes: the trial runs again on the
|
|||
p.ev(TICK_ERR);
|
||||
p.ev("window.__ot=0;const ot=offerTrial;offerTrial=(...a)=>{__ot++;return ot(...a);};");
|
||||
let found = false;
|
||||
// Which day such a trial comes depends on the offers the seeded game draws (day 46 since latency contracts joined them).
|
||||
// Played until such a trial comes: on the big save that depends on the offers the seeded game draws and on where
|
||||
// each city's traffic goes (#48, #137).
|
||||
for (let d = 0; d < 60 && !found; d++) {
|
||||
p.ev('rwDay()');
|
||||
for (let k = 0; k < 400 && p.ev('!!RW.job'); k++) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ function twoPops() {
|
|||
}
|
||||
|
||||
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();
|
||||
// Both ports with room: New York's traffic to the US eyeballs in Level Tree's cone alone would fill its port (#48).
|
||||
const { ev, lvl, tly, errors } = newYork(1, 150);
|
||||
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');
|
||||
|
|
|
|||
134
tests/endgame-scale.test.js
Normal file
134
tests/endgame-scale.test.js
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
// The late game grows sideways, plus one expensive way up: eyeball traffic starts where the eyeballs are (#48), giant AI
|
||||
// circuits spread over many metros (#61), a PNI grows by eight members per router (#323), and Auto-TE spills early onto
|
||||
// detours within a latency budget (#136).
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
const { lit } = require('../scripts/lib/js-literal');
|
||||
|
||||
const US = ['nyc', 'ash', 'chi', 'atn', 'den', 'sea', 'sjc', 'mia'];
|
||||
|
||||
// POPs in the given cities with the same home demand, a thin backbone between neighbours and transit at every POP.
|
||||
function usNetwork(ev, cities, wave) {
|
||||
ev(`ACT.start({});S.cash=1e10;S.lvl=6;S.day=500;S.biz=[];S.offers=[];S.links=[];S.pops={};S.pni=[];S.caches=[];S.transit=[];S.ixp={};S.peers={};S.rs={};
|
||||
S.nextFail=1e9;S.nextEvent=1e9;const cs=${lit(cities)};
|
||||
for(const c of cs){S.pops[c]={routers:2,rgen:3,gen:true,bb:{d:400},down:0};S.transit.push({id:'t'+c,net:'cog',city:c,tier:3,n:4,down:0});}
|
||||
for(let i=0;i+1<cs.length;i++)S.links.push({id:'w'+i,a:cs[i],b:cs[i+1],kind:'wave',tier:${wave},km:kmBetween(cs[i],cs[i+1]),cut:0,mo:100});
|
||||
compute();`);
|
||||
}
|
||||
|
||||
test('#48: traffic to a network that sells to homes starts where its users live', () => {
|
||||
const { ev, errors } = load();
|
||||
usNetwork(ev, ['nyc'], 3);
|
||||
const us = ev('R.demTo.cmc/R.demand');
|
||||
usNetwork(ev, ['fra'], 3);
|
||||
const de = ev('R.demTo.cmc/R.demand'), deDtk = ev('R.demTo.dtk/R.demand');
|
||||
usNetwork(ev, ['nyc'], 3);
|
||||
const usDtk = ev('R.demTo.dtk/R.demand');
|
||||
assert.ok(us > ev('NSH.cmc') * 3, `a New York POP sends Comecast far more than its world share (${us})`);
|
||||
assert.ok(us > de * 8, `and much more than a Frankfurt POP does (${us} vs ${de})`);
|
||||
assert.ok(deDtk > usDtk * 8, `Doitsche Telekomm the other way round (${deDtk} vs ${usDtk})`);
|
||||
// Only the split between home networks moves: content keeps its share, and a city's total demand stays the same.
|
||||
assert.ok(Math.abs(ev("[...locSh(NSH,'nyc')].reduce((a,b)=>a+b,0)") - 1) < 1e-9, 'the shares still add up to one');
|
||||
assert.equal(ev("locSh(NSH,'nyc')[LOC_NIX.get('ggl')]"), ev('NSH.ggl'), 'content is everywhere');
|
||||
assert.ok(Math.abs(ev("cityNetSh('nyc','cmc')") - ev("locSh(NSH,'nyc')[LOC_NIX.get('cmc')]")) < 1e-12, 'box sizing reads the same split');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#48: peering with an eyeball in more of the cities its users live in carries more of its traffic', () => {
|
||||
const { ev, errors } = load();
|
||||
// A 10G backbone: hauling Comecast's traffic to two PNIs fills it, and the rest leaves over transit.
|
||||
usNetwork(ev, US, 0);
|
||||
const share = pnis => {
|
||||
ev(`S.pni=${lit(pnis)}.map(c=>({id:'cmc@'+c,city:c,net:'cmc',tier:3,n:4}));compute()`);
|
||||
return ev('(R.netEg.cmc.p||0)/R.demTo.cmc');
|
||||
};
|
||||
const two = share(['nyc', 'ash']), all = share(US);
|
||||
assert.ok(all > 0.95, `a PNI in every city takes nearly all of it (${all})`);
|
||||
assert.ok(two < 0.6, `two PNIs only take what the backbone can haul to them (${two})`);
|
||||
assert.ok(all - two > 0.35, `more PNI locations carry more (${two} → ${all})`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#61: giant AI circuits spread over many metros, busy ones a bit busier', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(`ACT.start({});S.cash=1e12;S.lvl=11;S.biz=[];S.offers=[];for(const m of MEGA)if(!S.pops[m.c])S.pops[m.c]={routers:1,rgen:3,gen:true,bb:null,down:0};
|
||||
for(const c of ['ash','nyc','chi','dal','mex','lax','hou','bos','was'])if(!S.pops[c])S.pops[c]={routers:1,rgen:3,gen:true,bb:null,down:0};`);
|
||||
ev('__reseed(61)');
|
||||
// Three hundred offers, each signed as it comes, the way a long game fills up.
|
||||
const out = JSON.parse(ev(`(()=>{const cnt={};let n=0;for(let i=0;i<300;i++){const before=S.offers.length;spawnSpecial(['aiwan','mtrain','agi'][i%3]);
|
||||
if(S.offers.length===before)continue;const o=S.offers.pop();S.biz.push(o);n++;for(const c of bCities(o))cnt[c]=(cnt[c]||0)+1;}return JSON.stringify({cnt,n});})()`));
|
||||
const tot = Object.values(out.cnt).reduce((a, b) => a + b, 0);
|
||||
const five = ['mex', 'chi', 'dal', 'ash', 'nyc'].reduce((a, c) => a + (out.cnt[c] || 0), 0);
|
||||
assert.ok(out.n > 200, `offers came (${out.n})`);
|
||||
assert.ok(Object.keys(out.cnt).length >= 25, `ends in many metros (${Object.keys(out.cnt).length})`);
|
||||
assert.ok(five / tot < 0.35, `the old five metros no longer get most of it (${(five / tot).toFixed(2)})`);
|
||||
const avg = tot / Object.keys(out.cnt).length;
|
||||
assert.ok(out.cnt.ash > avg, `Ashburn stays a bit busier than the average metro (${out.cnt.ash} vs ${avg.toFixed(1)})`);
|
||||
assert.ok(out.cnt.ash < tot * 0.15, `but never the only place (${out.cnt.ash} of ${tot})`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#323: a PNI grows by eight members per router at the POP, up to 32', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
ev("ACT.start({});S.cash=1e12;S.lvl=13;for(const g of GOALS)S.done[g.id]=0;ACT.launchBB({city:'fra'});S.pops.fra.rgen=RG_TOP;S.pops.fra.routers=1;S.rules={...(S.rules||{}),pnis:'instant'};");
|
||||
ev("S.pni.push({id:'p1',city:'fra',net:'nfx',tier:3,n:8});compute()");
|
||||
const n = () => ev("S.pni.find(p=>p.id==='p1').n");
|
||||
assert.equal(ev("pniLagMax('fra')"), 8, 'one router: eight members, as before');
|
||||
ev("ACT.lagP({id:'p1',d:1})");
|
||||
assert.equal(n(), 8, 'a ninth member needs a second router');
|
||||
assert.match(dom.window.document.getElementById('toasts').textContent, /already bundles 8 ports/);
|
||||
ev("ACT.addRouter({city:'fra'})");
|
||||
assert.equal(ev("pniLagMax('fra')"), 16);
|
||||
ev("ACT.lagP({id:'p1',d:1})");
|
||||
assert.equal(n(), 9, 'the second router takes eight more');
|
||||
assert.ok(Math.abs(ev("R.nodeCap.fra") - ev("nodeCap('fra')")) < 1e-9);
|
||||
// Taking that router away again would leave the bundle with nowhere to land.
|
||||
ev("ACT.rmRouter({city:'fra'})");
|
||||
assert.equal(ev('S.pops.fra.routers'), 2, 'the router stays while the PNI needs it');
|
||||
assert.match(dom.window.document.getElementById('toasts').textContent, /Shrink a PNI first/);
|
||||
ev("S.pops.fra.routers=6;");
|
||||
assert.equal(ev("pniLagMax('fra')"), 32, 'never more than 32 members, however many routers');
|
||||
for (let i = 0; i < 30; i++) ev("ACT.lagP({id:'p1',d:1})");
|
||||
assert.equal(n(), 32);
|
||||
// The panel offers a member while there is room and says why when there is none.
|
||||
ev("S.pops.fra.routers=4;UI.sel={type:'city',id:'fra'};S.pni.find(p=>p.id==='p1').n=31;");
|
||||
ev('window.innerWidth=390;renderAll()');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#323: saves keep their LAGs, big ones included, and garbage is clamped', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("ACT.start({});ACT.launchBB({city:'fra'});S.pops.fra.routers=3;");
|
||||
ev("S.pni.push({id:'old',city:'fra',net:'nfx',tier:2,n:8},{id:'big',city:'fra',net:'ggl',tier:2,n:24,up:{tier:3,n:24,ready:S.day+30}},{id:'bad',city:'fra',net:'akm',tier:1,n:999})");
|
||||
ev('const o=JSON.parse(JSON.stringify(S));sanitize(o);window.__o=o');
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='old').n"), 8, 'an old save with an 8-port LAG loads as it was');
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='big').n"), 24);
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='big').up.n"), 24);
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='bad').n"), 32, 'never past the biggest bundle');
|
||||
assert.equal(ev("migrate(JSON.parse(JSON.stringify(S)))&&1"), 1);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('#136: spill tiers keep a hot link at its line while a detour within the latency budget has room', () => {
|
||||
const { ev, errors } = load();
|
||||
// New York reaches its upstream in Los Angeles over a direct 10G wave, or about 10 ms longer through Miami on 800G.
|
||||
ev(`ACT.start({});S.cash=1e12;S.lvl=13;for(const g of GOALS)S.done[g.id]=0;for(const c of ['nyc','lax','mia'])if(!S.pops[c])ACT.buildPop({city:c});
|
||||
for(const c of ['nyc','lax','mia']){S.pops[c].rgen=RG_TOP;S.pops[c].routers=RMAX;}if(!S.pops.nyc.bb)ACT.launchBB({city:'nyc'});S.pops.nyc.bb.d=400;
|
||||
const L=(a,b,t)=>{UI.via=null;UI.lmode='wave';UI.route='main';openLinkModal(a,b);ACT.buildLink({tier:t});closeModal();};
|
||||
L('nyc','lax',0);L('nyc','mia',3);L('mia','lax',3);S.links.forEach(l=>l.ready=0);
|
||||
S.transit=[];const t=NETS.find(n=>n.price&&n.pops.includes('lax')&&n.type==='t1');ACT.buyTransit({city:'lax',net:t.id,tier:3});
|
||||
S.ixp={};S.pni=[];S.caches=[];S.te={on:true,day:0};S.core={lv:2,run:2,legacy:true};S.nextFail=1e9;S.nextEvent=1e9;`);
|
||||
const direct = "R.load[S.links.find(l=>l.a==='nyc'&&l.b==='lax').id]";
|
||||
const run = s => { ev(`S.te.script=${lit(s)};compute()`); return { load: ev(direct), served: ev('R.served'), moved: ev('R.teMoved') }; };
|
||||
const none = run(''), short = run('spill at 80% within 5 ms'), long = run('spill at 80% within 15 ms'), two = run('spill at 80% within 15 ms\nspill at 90% within 30 ms');
|
||||
assert.ok(none.load > 9.99, 'without tiers the direct link fills up');
|
||||
assert.ok(short.load > 9.99, 'a detour 10 ms longer is outside a 5 ms budget: the link fills up as before');
|
||||
assert.ok(Math.abs(long.load - 8) < 1e-6, `within 15 ms the link stays at 80% (${long.load})`);
|
||||
assert.ok(Math.abs(two.load - 8) < 1e-6, 'the 90% tier only opens once the 80% detours are full');
|
||||
assert.ok(Math.abs(long.served - none.served) < 1e-6, 'and nothing is lost: the detour carries it');
|
||||
assert.ok(long.moved > none.moved, 'Auto-TE moved it');
|
||||
assert.equal(ev("teParse('spill at 80% within 500 ms').errors.length"), 1, 'a budget past 100 ms is refused');
|
||||
assert.equal(ev("JSON.stringify(teParse('spill at 90% within 20 ms\\nspill at 80% within 10 ms').tiers)"), '[{"at":0.8,"ms":10},{"at":0.9,"ms":20}]');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
@ -222,6 +222,16 @@ test('N7: presence is real: PoPs are cities, exchange ports only where the netwo
|
|||
fail('N7', bad, 'an exchange port needs an exchange in that city and a PoP there');
|
||||
});
|
||||
|
||||
test('N8: a POP\'s traffic to the networks that sell to homes goes mostly to those whose users live near it (#48)', () => {
|
||||
// Every city keeps its total and content keeps its share: only the split between home networks follows geography.
|
||||
const bad = J(`CITIES.filter(c=>{const a=locSh(NSH,c.id);let t=0;for(let j=0;j<NETS.length;j++){t+=a[j];if(!NETS[j].cc&&Math.abs(a[j]-(NSH[NETS[j].id]||0))>1e-12)return true;}return Math.abs(t-1)>1e-9;}).map(c=>c.id)`);
|
||||
fail('N8', bad, 'locSh() must keep a city\'s total and every share of a network without home markets');
|
||||
// At home a network's share is above its world share, far away below it.
|
||||
const far = J(`NETS.filter(n=>n.cc&&NSH[n.id]>0).flatMap(n=>{const cc=[].concat(n.cc),home=CITIES.find(c=>cc.includes(c.cc)),away=CITIES.find(c=>!locNets()[LOC_NIX.get(n.id)].reg.has(c.reg));
|
||||
const j=LOC_NIX.get(n.id),out=[];if(home&&!(locSh(NSH,home.id)[j]>NSH[n.id]))out.push(n.id+'@home');if(away&&!(locSh(NSH,away.id)[j]<NSH[n.id]))out.push(n.id+'@away');return out;})`);
|
||||
fail('N8', far, 'LOC_HOME > LOC_REG > LOC_FAR, and home markets (cc) are where the users are');
|
||||
});
|
||||
|
||||
// ---------- Modes and rules ----------
|
||||
|
||||
test('M1: On-call is the classic game: the default rules, and what old saves load as', () => {
|
||||
|
|
@ -512,6 +522,18 @@ test('F9: a latency contract is late, capped, achievable, paid for its latency a
|
|||
// D1–D4: DDoS as networks see it (#242). tests/ddos-model.test.js plays each one in detail.
|
||||
const ddFra = (ev) => ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.cash=1e9;S.lvl=4;S.nextFail=1e9;S.nextEvent=1e9;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=40;ACT.buyTransit({city:'fra',net:'cog',tier:1});S.pops.fra.rgen=RG.findIndex(r=>r.fsN===8);S.biz.push({id:'g',type:'game',name:'G',city:'fra',bw:10,rate:1,mood:80,since:0,reqs:[]},{id:'d',type:'dia',name:'D',city:'fra',bw:5,rate:1,mood:80,since:0,reqs:[]});compute()");
|
||||
const ddHit = (ev, g) => ev(`S.ev.ddos={id:'x',city:'fra',tgt:'g',vec:'dns',gbps:${g},start:S.day,until:S.day+2,bh:false};compute()`);
|
||||
test('F10: growth goes sideways, plus one paid way up (#61, #323)', () => {
|
||||
// A PNI bundles eight members per router at its POP, up to 32; every other LAG stays at eight.
|
||||
assert.equal(ev('LAG_MAX'), 8, 'F10: transit, exchange and fabric LAGs hold eight members');
|
||||
const lim = J("[1,2,3,4,5,16].map(r=>{const o=S.pops.fra;S.pops.fra={routers:r};const m=pniLagMax('fra');if(o)S.pops.fra=o;else delete S.pops.fra;return m;})");
|
||||
assert.deepEqual(lim, [8, 16, 24, 32, 32, 32], 'F10: a PNI grows by eight members per router, up to 32');
|
||||
// Giant AI circuits land at campuses spread over many metros, no city more than two.
|
||||
const per = J("MEGA.reduce((m,x)=>(m[x.c]=(m[x.c]||0)+1,m),{})");
|
||||
assert.ok(Object.keys(per).length >= 30, `F10: campuses in at least 30 metros (${Object.keys(per).length})`);
|
||||
fail('F10', Object.entries(per).filter(([, n]) => n > 2).map(([c]) => c), 'no metro holds more than two campuses');
|
||||
fail('F10', J("MEGA.filter(m=>!CITY[m.c]).map(m=>m.c)"), 'campuses sit in real cities');
|
||||
});
|
||||
|
||||
test('D1: attack sizes come from the world, never from your network', () => {
|
||||
const g = load();
|
||||
ddFra(g.ev);
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ test('saves: PNIs on order survive, and garbage is repaired', () => {
|
|||
setup(ev);
|
||||
ev("S.pni.push({id:'x',city:'fra',net:'dtk',tier:0,g1:true,ready:S.day+30,up:{tier:'9',n:99,ready:'x'}},{id:'y',city:'fra',net:'nfx',tier:1,g1:true})");
|
||||
ev('const o=JSON.parse(JSON.stringify(S));sanitize(o);window.__o=o');
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='x').up.n"), ev('LAG_MAX'));
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='x').up.n"), ev('PNI_LAG_MAX'));
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='x').g1"), true);
|
||||
assert.equal(ev("__o.pni.find(p=>p.id==='y').g1"), undefined, 'only Doitsche Telekomm does 1G');
|
||||
assert.deepEqual(errors, []);
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ function pages() {
|
|||
let base = head;
|
||||
try { const b = path.join(os.tmpdir(), `tubes-fuzz-test-${process.pid}-base.html`); fs.writeFileSync(b, page.assembleRef('origin/main')); base = b; } catch (e) {}
|
||||
let P = { base: openPage(base, 'base'), head: openPage(head, 'head') };
|
||||
// A change to the world itself (cities, networks, cables, the kinds of customers that call) or to what links cost
|
||||
// cannot route like main: there is no same game to compare. Then the base is this checkout too, and the cache on/off
|
||||
// check still runs; equivalence with main resumes once it lands.
|
||||
const world = (p) => p.ev("JSON.stringify([CITIES.map(c=>[c.id,c.land,c.P]),NETS.map(n=>[n.id,n.pops,n.ix,n.share,n.price,n.up]),CABLES.map(c=>[c.id,c.pairs.map(q=>[q[0],q[1]])]),[1,300,3000].map(k=>[dfLeaseMo(k),waveMo(k,false,2),dfBuildCost(k)]),Object.keys(BIZ_T).map(t=>[t,BIZ_T[t].lv||1,BIZ_T[t].opts])])");
|
||||
// A change to the world itself (cities, networks, cables, AI campuses, the kinds of customers that call), to what links cost or to where each city's
|
||||
// traffic goes (locSh(), #48) cannot route like main: there is no same game to compare. Then the base is this checkout
|
||||
// too, and the cache on/off check still runs; equivalence with main resumes once it lands.
|
||||
const world = (p) => p.ev("JSON.stringify([CITIES.map(c=>[c.id,c.land,c.P]),NETS.map(n=>[n.id,n.pops,n.ix,n.share,n.price,n.up]),CABLES.map(c=>[c.id,c.pairs.map(q=>[q[0],q[1]])]),[1,300,3000].map(k=>[dfLeaseMo(k),waveMo(k,false,2),dfBuildCost(k)]),Object.keys(BIZ_T).map(t=>[t,BIZ_T[t].lv||1,BIZ_T[t].opts]),MEGA.map(m=>m.c),['nyc','fra','sin'].map(c=>typeof locSh==='function'?Array.from(locSh(NSH,c)):null)])");
|
||||
if (base !== head && world(P.base) !== world(P.head)) { console.log('# route fuzz: the world or its prices differ from main, so both pages are this checkout'); P = { base: openPage(head, 'base'), head: P.head }; }
|
||||
return P;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ test('Auto-TE routes around a full link exactly like the plain path', () => {
|
|||
S.transit=[];const t=NETS.find(n=>n.price&&n.pops.includes('ams')&&n.type==='t1');ACT.buyTransit({city:'ams',net:t.id,tier:3});
|
||||
S.ixp={};S.pni=[];S.caches=[];S.te={on:true,day:0};S.core={lv:2,run:2,legacy:true};S.nextFail=1e9;S.nextEvent=1e9;`);
|
||||
const sig = () => ev('JSON.stringify({served:R.served,teMoved:R.teMoved,egT:R.egT,load:S.links.map(l=>R.load[l.id]||0),node:R.nodeLoad,t:R.useT})');
|
||||
for (const script of ['', 'spill at 70%']) {
|
||||
for (const script of ['', 'spill at 70%', 'spill at 80% within 5 ms\nspill at 90% within 20 ms']) {
|
||||
ev(`S.te.script=${lit(script)}`);
|
||||
ev('compute()'); const fast = sig();
|
||||
ev('__plain()'); const ref = sig();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue