Skip to content

client: support multi-tunnel latency probing and best IP selection#2739

Open
packethog wants to merge 2 commits intomainfrom
ss/multitunnel_latency
Open

client: support multi-tunnel latency probing and best IP selection#2739
packethog wants to merge 2 commits intomainfrom
ss/multitunnel_latency

Conversation

@packethog
Copy link
Contributor

@packethog packethog commented Jan 28, 2026

Summary of Changes

  • Add multi-tunnel latency probing in doublezerod - now probes device interfaces with UserTunnelEndpoint=true in addition to the device's PublicIp
  • This is gated by a --latency-probe-tunnel-endpoints feature flag
  • Update best_latency() in doublezero CLI to select the IP with the lowest latency when a device has multiple tunnel
    endpoints, rather than just finding the first match
  • This enables latency-based selection across all available tunnel endpoints when devices have multiple IPs configured

Testing Verification

  • All 41 Rust CLI tests pass including 5 new tests for multi-IP scenarios:
    • test_best_latency_multi_ip_selects_best_ip_for_device
    • test_best_latency_multi_ip_current_device_uses_best_ip
    • test_best_latency_multi_ip_switches_when_better_device_exists
    • test_best_latency_multi_ip_multiple_devices
    • test_best_latency_for_device_helper
  • Go latency manager tests pass including new tests for GetProbeTargets() with interface endpoints

@packethog packethog self-assigned this Jan 28, 2026
- doublezerod: probe interfaces with UserTunnelEndpoint=true in addition to device PublicIp
- doublezero: select best latency IP when device has multiple tunnel endpoints
…tunnel probing

- add CLI flag to control whether UserTunnelEndpoint interfaces are probed
- when disabled (default): only probe device PublicIp (original behavior)
- when enabled: probe PublicIp AND UserTunnelEndpoint interfaces
- update tests to cover flag enabled/disabled behavior
@packethog packethog force-pushed the ss/multitunnel_latency branch from 7a94ee5 to 433d5b4 Compare January 28, 2026 17:15
@packethog packethog marked this pull request as ready for review January 28, 2026 17:17
//
// Configuration: 200 devices, each with 1 tunnel endpoint interface = 400 probe targets
// (200 PublicIp + 200 interface IPs). This simulates a realistic production deployment.
func BenchmarkLatencyManagerMemoryStability(b *testing.B) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool test :)

// 1. Memory efficiency: [4]uint8 is 4 bytes inline vs net.IP which is a slice (24 byte header + heap allocation)
// 2. Direct assignment: allows zero-copy from serviceability.Device.PublicIp without conversion
// Convert to net.IP when needed via: net.IP(PublicIp[:])
PublicIp [4]uint8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PublicIp [4]uint8
PublicIP [4]uint8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client: add latency probing for interfaces marked as tunnel endpoints

3 participants