Custom routing metric for links

A link's routing metric could only be one of four presets (Prefer,
Normal, Avoid, Backup only). Links now also get a Custom option, closer
to how real networks tune IGP metrics:

- Multiplier mode scales the distance cost, (km + 60) × 0.1 to 100.
- Cost mode sets an exact cost, 1 to 65535 like an OSPF metric.

The preset buttons stay plain. Picking Custom explains how a link's cost
is worked out and lists what each preset comes to on that link. Choosing
Custom starts from the current preset and switching modes keeps the
effective cost, so nothing moves until the player changes the value.
Like the presets, it applies to every link between the two cities.

The cost formula lives in one helper, linkW(), used by compute() and the
traceroute paths. Custom links store mk/mv, which sanitize() repairs and
clamps; old saves load unchanged. The link panel skips its daily
re-render while the number field has focus, and Enter applies the value.

Tests cover routing equivalence with the presets, rerouting by cost,
mode switching, input clamping, saves, and the panel at desktop and
phone width. French, Italian and Portuguese for the new strings.
Perf on the big network: no change beyond noise, routing identical to
main.
This commit is contained in:
Marvin 2026-10-26 20:55:12 +01:00
parent 729d4d303d
commit 8a25ebdb95
6 changed files with 161 additions and 10 deletions

View file

@ -1604,7 +1604,6 @@
"Going to customers in":"Vers les clients de",
"Biggest feeder: {egress} in {city}. Set it to “Backup only”, give the customers a closer egress (peering, a cache, local transit), or raise this link's metric.":"Plus gros contributeur : {egress} à {city}. Passe-le en « Secours seul », donne aux clients une sortie plus proche (peering, cache, transit local) ou augmente la métrique de ce lien.",
"Routing metric":"Métrique de routage",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Applies to every link between these two cities.":"Tes routeurs choisissent le chemin le moins coûteux. Augmente la métrique pour pousser le trafic vers d’autres chemins. « Secours seul » le laisse au repos tant que le reste fonctionne. S’applique à tous les liens entre ces deux villes.",
"Behind the Great Firewall":"Derrière le Grand Pare-feu",
"Mainland China plays by its own rules. {list} and other foreign services are blocked here, so users mostly reach Chinese networks. Traffic crossing the border loses about {pct} to filtering and congestion, unless it rides a premium route: CN-Too transit or a premium cross-border circuit (both sold only in Hong Kong), or a PNI with a Chinese network. Revenue per user is lower here.":"La Chine continentale joue selon ses propres règles. {list} et d’autres services étrangers y sont bloqués, donc les utilisateurs atteignent surtout des réseaux chinois. Le trafic qui passe la frontière perd environ {pct} en filtrage et congestion, sauf s’il emprunte une route premium : du transit CN-Too ou un circuit transfrontalier premium (tous deux vendus uniquement à Hong Kong), ou un PNI avec un réseau chinois. Le revenu par utilisateur est plus faible ici.",
"Foreign networks need a local joint venture and an operating license to build infrastructure here.":"Les réseaux étrangers ont besoin d’une coentreprise locale et d’une licence d’opérateur pour construire ici.",
@ -2631,4 +2630,14 @@
"via a capacity broker":"via un courtier en capacité",
"List it with a capacity broker <small>they keep 10%</small>":"La confier à un courtier en capacité <small>il garde 10 %</small>",
"Nothing spare to sell on this fiber right now.":"Rien à vendre sur cette fibre pour l’instant.",
"Custom":"Perso",
"Multiplier":"Multiplicateur",
"Cost":"Coût",
"Set":"Appliquer",
"Cost on this link: {w}. Allowed: {lo} to {hi}.":"Coût sur ce lien : {w}. Autorisé : de {lo} à {hi}.",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Pick Custom to set your own multiplier or cost. Applies to every link between these two cities.":"Tes routeurs choisissent le chemin le moins coûteux. Augmente la métrique pour pousser le trafic vers d’autres chemins. « Secours seul » le laisse au repos tant que le reste fonctionne. Choisis Perso pour fixer ton propre multiplicateur ou coût. S’applique à tous les liens entre ces deux villes.",
"A link’s cost is its length in km plus 60, times a multiplier. Traffic takes the path with the lowest total cost.":"Le coût d’un lien, c’est sa longueur en km plus 60, fois un multiplicateur. Le trafic prend le chemin au coût total le plus bas.",
"Presets on this link: {list}.":"Préréglages sur ce lien : {list}.",
"Cost: the exact number, whatever the distance.":"Coût : le nombre exact, quelle que soit la distance.",
"Multiplier: scales the distance cost, so a longer link still costs more.":"Multiplicateur : il multiplie le coût de la distance, donc un lien plus long coûte toujours plus.",
};

View file

@ -1603,7 +1603,6 @@
"Going to customers in":"Diretto ai clienti a",
"Biggest feeder: {egress} in {city}. Set it to “Backup only”, give the customers a closer egress (peering, a cache, local transit), or raise this link's metric.":"Fonte principale: {egress} a {city}. Impostala su “Solo backup”, dai ai clienti un’uscita più vicina (peering, una cache, transit locale) o alza la metrica di questo link.",
"Routing metric":"Metrica di routing",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Applies to every link between these two cities.":"I tuoi router scelgono il percorso a costo minore. Alza la metrica per spingere il traffico su altri percorsi. “Solo backup” lo lascia a riposo finché il resto funziona. Vale per tutti i link tra queste due città.",
"Behind the Great Firewall":"Dietro il Great Firewall",
"Mainland China plays by its own rules. {list} and other foreign services are blocked here, so users mostly reach Chinese networks. Traffic crossing the border loses about {pct} to filtering and congestion, unless it rides a premium route: CN-Too transit or a premium cross-border circuit (both sold only in Hong Kong), or a PNI with a Chinese network. Revenue per user is lower here.":"La Cina continentale gioca con regole tutte sue. {list} e altri servizi stranieri qui sono bloccati, quindi gli utenti raggiungono soprattutto reti cinesi. Il traffico che attraversa il confine perde circa il {pct} tra filtri e congestione, a meno che non viaggi su una rotta premium: transit CN-Too o un circuito transfrontaliero premium (entrambi venduti solo a Hong Kong), oppure un PNI con una rete cinese. Qui i ricavi per utente sono più bassi.",
"Foreign networks need a local joint venture and an operating license to build infrastructure here.":"Per costruire infrastrutture qui, le reti straniere hanno bisogno di una joint venture locale e di una licenza operativa.",
@ -2631,4 +2630,14 @@
"via a capacity broker":"tramite un broker di capacità",
"List it with a capacity broker <small>they keep 10%</small>":"Mettila in vendita con un broker di capacità <small>trattiene il 10%</small>",
"Nothing spare to sell on this fiber right now.":"Per ora non c’è niente da vendere su questa fibra.",
"Custom":"Personalizzata",
"Multiplier":"Moltiplicatore",
"Cost":"Costo",
"Set":"Imposta",
"Cost on this link: {w}. Allowed: {lo} to {hi}.":"Costo su questo link: {w}. Ammessi: da {lo} a {hi}.",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Pick Custom to set your own multiplier or cost. Applies to every link between these two cities.":"I tuoi router scelgono il percorso a costo minore. Alza la metrica per spingere il traffico su altri percorsi. “Solo backup” lo lascia a riposo finché il resto funziona. Scegli Personalizzata per impostare il tuo moltiplicatore o costo. Vale per tutti i link tra queste due città.",
"A link’s cost is its length in km plus 60, times a multiplier. Traffic takes the path with the lowest total cost.":"Il costo di un link è la sua lunghezza in km più 60, per un moltiplicatore. Il traffico prende il percorso col costo totale più basso.",
"Presets on this link: {list}.":"Preset su questo link: {list}.",
"Cost: the exact number, whatever the distance.":"Costo: il numero esatto, a prescindere dalla distanza.",
"Multiplier: scales the distance cost, so a longer link still costs more.":"Moltiplicatore: scala il costo della distanza, così un link più lungo costa comunque di più.",
};

View file

@ -1602,7 +1602,6 @@
"Going to customers in":"Indo para clientes em",
"Biggest feeder: {egress} in {city}. Set it to “Backup only”, give the customers a closer egress (peering, a cache, local transit), or raise this link's metric.":"Maior fonte: {egress} em {city}. Coloque em “Só backup”, dê aos clientes uma saída mais próxima (peering, um cache, transit local) ou aumente a métrica deste link.",
"Routing metric":"Métrica de roteamento",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Applies to every link between these two cities.":"Seus routers escolhem o caminho de menor custo. Aumente a métrica para empurrar o tráfego para outros caminhos. “Só backup” deixa o link ocioso a menos que nada mais funcione. Vale para todos os links entre essas duas cidades.",
"Behind the Great Firewall":"Atrás do Great Firewall",
"Mainland China plays by its own rules. {list} and other foreign services are blocked here, so users mostly reach Chinese networks. Traffic crossing the border loses about {pct} to filtering and congestion, unless it rides a premium route: CN-Too transit or a premium cross-border circuit (both sold only in Hong Kong), or a PNI with a Chinese network. Revenue per user is lower here.":"A China continental joga com regras próprias. {list} e outros serviços estrangeiros são bloqueados aqui, então os usuários acessam principalmente redes chinesas. O tráfego que cruza a fronteira perde cerca de {pct} com filtragem e congestionamento, a menos que vá por uma rota premium: transit CN-Too ou um circuito transfronteiriço premium (ambos vendidos só em Hong Kong), ou um PNI com uma rede chinesa. A receita por usuário aqui é menor.",
"Foreign networks need a local joint venture and an operating license to build infrastructure here.":"Redes estrangeiras precisam de uma joint venture local e de uma licença de operação para construir infraestrutura aqui.",
@ -2631,4 +2630,14 @@
"via a capacity broker":"por um corretor de capacidade",
"List it with a capacity broker <small>they keep 10%</small>":"Anunciar com um corretor de capacidade <small>ele fica com 10%</small>",
"Nothing spare to sell on this fiber right now.":"Nada sobrando para vender nesta fibra por enquanto.",
"Custom":"Personalizada",
"Multiplier":"Multiplicador",
"Cost":"Custo",
"Set":"Aplicar",
"Cost on this link: {w}. Allowed: {lo} to {hi}.":"Custo neste link: {w}. Permitido: de {lo} a {hi}.",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Pick Custom to set your own multiplier or cost. Applies to every link between these two cities.":"Seus routers escolhem o caminho de menor custo. Aumente a métrica para empurrar o tráfego para outros caminhos. “Só backup” deixa o link ocioso a menos que nada mais funcione. Escolha Personalizada para definir seu próprio multiplicador ou custo. Vale para todos os links entre essas duas cidades.",
"A link’s cost is its length in km plus 60, times a multiplier. Traffic takes the path with the lowest total cost.":"O custo de um link é seu comprimento em km mais 60, vezes um multiplicador. O tráfego segue o caminho de menor custo total.",
"Presets on this link: {list}.":"Predefinições neste link: {list}.",
"Cost: the exact number, whatever the distance.":"Custo: o número exato, seja qual for a distância.",
"Multiplier: scales the distance cost, so a longer link still costs more.":"Multiplicador: multiplica o custo da distância, então um link mais longo continua custando mais.",
};