[GH-ISSUE #1902] Latency base routing does not work #3676

Open
opened 2026-08-05 00:53:44 -04:00 by saavagebueno · 0 comments
Owner

Originally created by @hurricanehrndz on GitHub (Apr 29, 2024).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/1902

Originally assigned to: @pascal-fischer on GitHub.

Describe the problem

latency base routing was suppose to be added with the following patch:
https://github.com/netbirdio/netbird/pull/1732

Unfortunately I believe the following if statement is wrong, but I am hesitant to open a PR to fix it since it will make the underlying wireguard connection unstable:

https://github.com/netbirdio/netbird/pull/1732/files#diff-67387c2b097eeb87387ab2575884677a2f9ee1c53b9e8674dcfa4936463c23f9R155

There also seems to be a few race conditions that could impact the route analyzes poorly.

In my testing sometimes the slower connection is picked because it was the first to connect. Other times the slower connection is picked because latency for one of the later connected peers is missing.

I will try and add logs, as I collect them.

To Reproduce

Steps to reproduce the behavior:
Fix if statement, set a more reasonable latency forgiveness number such as 0.015 (15 ms) rather than 100ms and watch what happens. You will eventually end up disconnected from all peers

Expected behavior

I expected the best route to be picked, unless it is a route that is only 100ms different as per the the latency base routing patch intended

Are you using NetBird Cloud?

Nope

NetBird version

modified version of 0.27.3

NetBird status -d output:

Peers detail:
 lon1.peers.n.com:
  NetBird IP: 100.113.20.218
  Public key: DdiC7cXVeE409wdJO1bQjFQ8JYP52X+/HO46FtkTQSI=
  Status: Connecting
  -- detail --
  Connection type:
  Direct: false
  ICE candidate (Local/Remote): -/-
  ICE candidate endpoints (Local/Remote): -/-
  Last connection update: 2024-04-29 10:29:36
  Last WireGuard handshake: -
  Transfer status (received/sent) 0 B/0 B
  Quantum resistance: false
  Routes: -
  Latency: 135.14475ms

 sfo2.peers.n.com:
  NetBird IP: 100.113.35.69
  Public key: S3TburlUFqMPX3PLDlKhQnD/NLxq9B9YCzJ7mAZozh8=
  Status: Connecting
  -- detail --
  Connection type:
  Direct: false
  ICE candidate (Local/Remote): -/-
  ICE candidate endpoints (Local/Remote): -/-
  Last connection update: 2024-04-29 10:29:38
  Last WireGuard handshake: -
  Transfer status (received/sent) 0 B/0 B
  Quantum resistance: false
  Routes: -
  Latency: 59.2695ms

 iad1.peers.n.com:
  NetBird IP: 100.113.74.116
  Public key: MGJ+hGFni8uJSgVsF5AZI9GJCSEaOfJOUJ9joDxbhBI=
  Status: Connecting
  -- detail --
  Connection type:
  Direct: false
  ICE candidate (Local/Remote): -/-
  ICE candidate endpoints (Local/Remote): -/-
  Last connection update: 2024-04-29 10:29:39
  Last WireGuard handshake: -
  Transfer status (received/sent) 0 B/0 B
  Quantum resistance: false
  Routes: -
  Latency: 69.943916ms

Daemon version: 0.27.3.1009
CLI version: 0.27.3.1009
Management: Connected to https://netbird.n.com:443
Signal: Connected to https://netbird.n.com:443
Relays:
  [stun:stunvpn-ec2.n.com:3478] is Available
  [turn:stunvpn-ec2.n.com:3478?transport=udp] is Unavailable, reason: allocate: all retransmissions failed for fGXwf/+OxEZN791L
Nameservers:
  [10.29.2.45:53, 10.29.2.46:53, 10.29.2.47:53] for [n.com, corp.n.com, dev.n.com] is Available
  [10.29.2.45:53, 10.29.2.46:53, 10.29.2.47:53] for [.] is Available
FQDN: hx7yg952h5-89.peers.n.com
NetBird IP: 100.113.101.234/16
Interface type: Userspace
Quantum resistance: false
Routes: -
Peers count: 0/3 Connected

Additional context

I have explicitly disable turn on my coturn instance to force direct connections

Originally created by @hurricanehrndz on GitHub (Apr 29, 2024). Original GitHub issue: https://github.com/netbirdio/netbird/issues/1902 Originally assigned to: @pascal-fischer on GitHub. **Describe the problem** latency base routing was suppose to be added with the following patch: https://github.com/netbirdio/netbird/pull/1732 Unfortunately I believe the following if statement is wrong, but I am hesitant to open a PR to fix it since it will make the underlying wireguard connection unstable: https://github.com/netbirdio/netbird/pull/1732/files#diff-67387c2b097eeb87387ab2575884677a2f9ee1c53b9e8674dcfa4936463c23f9R155 There also seems to be a few race conditions that could impact the route analyzes poorly. In my testing sometimes the slower connection is picked because it was the first to connect. Other times the slower connection is picked because latency for one of the later connected peers is missing. I will try and add logs, as I collect them. **To Reproduce** Steps to reproduce the behavior: Fix if statement, set a more reasonable latency forgiveness number such as 0.015 (15 ms) rather than 100ms and watch what happens. You will eventually end up disconnected from all peers **Expected behavior** I expected the best route to be picked, unless it is a route that is only 100ms different as per the the latency base routing patch intended **Are you using NetBird Cloud?** Nope **NetBird version** modified version of 0.27.3 **NetBird status -d output:** ``` Peers detail: lon1.peers.n.com: NetBird IP: 100.113.20.218 Public key: DdiC7cXVeE409wdJO1bQjFQ8JYP52X+/HO46FtkTQSI= Status: Connecting -- detail -- Connection type: Direct: false ICE candidate (Local/Remote): -/- ICE candidate endpoints (Local/Remote): -/- Last connection update: 2024-04-29 10:29:36 Last WireGuard handshake: - Transfer status (received/sent) 0 B/0 B Quantum resistance: false Routes: - Latency: 135.14475ms sfo2.peers.n.com: NetBird IP: 100.113.35.69 Public key: S3TburlUFqMPX3PLDlKhQnD/NLxq9B9YCzJ7mAZozh8= Status: Connecting -- detail -- Connection type: Direct: false ICE candidate (Local/Remote): -/- ICE candidate endpoints (Local/Remote): -/- Last connection update: 2024-04-29 10:29:38 Last WireGuard handshake: - Transfer status (received/sent) 0 B/0 B Quantum resistance: false Routes: - Latency: 59.2695ms iad1.peers.n.com: NetBird IP: 100.113.74.116 Public key: MGJ+hGFni8uJSgVsF5AZI9GJCSEaOfJOUJ9joDxbhBI= Status: Connecting -- detail -- Connection type: Direct: false ICE candidate (Local/Remote): -/- ICE candidate endpoints (Local/Remote): -/- Last connection update: 2024-04-29 10:29:39 Last WireGuard handshake: - Transfer status (received/sent) 0 B/0 B Quantum resistance: false Routes: - Latency: 69.943916ms Daemon version: 0.27.3.1009 CLI version: 0.27.3.1009 Management: Connected to https://netbird.n.com:443 Signal: Connected to https://netbird.n.com:443 Relays: [stun:stunvpn-ec2.n.com:3478] is Available [turn:stunvpn-ec2.n.com:3478?transport=udp] is Unavailable, reason: allocate: all retransmissions failed for fGXwf/+OxEZN791L Nameservers: [10.29.2.45:53, 10.29.2.46:53, 10.29.2.47:53] for [n.com, corp.n.com, dev.n.com] is Available [10.29.2.45:53, 10.29.2.46:53, 10.29.2.47:53] for [.] is Available FQDN: hx7yg952h5-89.peers.n.com NetBird IP: 100.113.101.234/16 Interface type: Userspace Quantum resistance: false Routes: - Peers count: 0/3 Connected ``` **Additional context** I have explicitly disable turn on my coturn instance to force direct connections
saavagebueno added the bugroutestroubleshooting labels 2026-08-05 00:53:44 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#3676