Skip to content

feat(cel-shed): add RTT measurement feature for bootstrappers #4148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aWN4Y25pa2EK
Copy link

@aWN4Y25pa2EK aWN4Y25pa2EK commented Mar 6, 2025

RTT Measurement Feature for Bootstrapper Connections

Overview

This PR enhances the cel-shed p2p connect-bootstrappers command with Round-Trip Time (RTT) measurement capabilities. The new functionality allows users to assess network latency to bootstrapper nodes, helping identify optimal nodes for connection and diagnose potential network issues.

Features Added

  • Comprehensive RTT Statistics: Measures and reports min, max, average, median, and standard deviation of network latency
  • Configurable Measurement Parameters:
    • --ping-count: Number of ping attempts per bootstrapper (default: 5)
    • --ping-interval: Interval between ping attempts (default: 500ms)
  • Address Display: Shows human-readable node addresses (domain names) alongside peer IDs
  • Output Formats:
    • Standard human-readable output with clear statistics
    • --json flag for JSON-formatted output to facilitate programmatic consumption
  • Detailed Results Option:
    • --detailed flag displays individual ping attempt results
  • Improved Shutdown Handling: Uses a dedicated shutdown context with extended timeout

Implementation Details

  • Leverages the existing p2p.Module.Ping() method to measure RTT
  • Uses goroutines for concurrent ping operations to multiple bootstrappers
  • Implements proper error handling and timeout management
  • Calculates statistical values from multiple ping samples
  • Preserves compatibility with existing command flags

Example Usage

# Basic usage with default settings (5 pings)
cel-shed p2p connect-bootstrappers mainnet

# Use 10 pings with a 1 second interval
cel-shed p2p connect-bootstrappers mainnet --ping-count=10 --ping-interval=1s

# Output in JSON format for parsing
cel-shed p2p connect-bootstrappers mainnet --json

# Show detailed results for each ping attempt
cel-shed p2p connect-bootstrappers mainnet --detailed

JSON Output

[
  {
    "peer_id": "12D3KooWE3fmRtHgfk9DCuQFfY3H3JYEnTU3xZozv1Xmo8KWrWbK",
    "address": "da-full-2.celestia-bootstrap.net",
    "count": 5,
    "success": 5,
    "failed": 0,
    "min": "28.412834ms",
    "max": "38.056417ms",
    "average": "31.12545ms",
    "median": "29.939958ms",
    "std_dev": "3.538119ms"
  },
  {
    "peer_id": "12D3KooWSqZaLcn5Guypo2mrHr297YPJnV8KMEMXNjs3qAS8msw8",
    "address": "da-bridge-1.celestia-bootstrap.net",
    "count": 5,
    "success": 5,
    "failed": 0,
    "min": "29.239291ms",
    "max": "50.791625ms",
    "average": "37.568741ms",
    "median": "30.707834ms",
    "std_dev": "9.626791ms"
  },
  {
    "peer_id": "12D3KooWBBzzGy5hAHUQVh2vBvL25CKwJ7wbmooPcz4amQhzJHJq",
    "address": "boot.celestia.pops.one",
    "count": 5,
    "success": 5,
    "failed": 0,
    "min": "103.188459ms",
    "max": "105.453333ms",
    "average": "104.175441ms",
    "median": "103.888208ms",
    "std_dev": "940.113µs"
  },
  {
    "peer_id": "12D3KooWAzucnC7yawvLbmVxv53ihhjbHFSVZCsPuuSzTg6A7wgx",
    "address": "celestia.qubelabs.io",
    "count": 5,
    "success": 5,
    "failed": 0,
    "min": "18.597333ms",
    "max": "22.830333ms",
    "average": "20.110383ms",
    "median": "19.714042ms",
    "std_dev": "1.440167ms"
  },
  {
    "peer_id": "12D3KooWKZCMcwGCYbL18iuw3YVpAZoyb1VBGbx9Kapsjw3soZgr",
    "address": "da-full-1.celestia-bootstrap.net",
    "count": 5,
    "success": 5,
    "failed": 0,
    "min": "27.265291ms",
    "max": "28.821958ms",
    "average": "28.426941ms",
    "median": "28.76025ms",
    "std_dev": "591.358µs"
  },
  {
    "peer_id": "12D3KooWQpuTFELgsUypqp9N4a1rKBccmrmQVY8Em9yhqppTJcXf",
    "address": "da-bridge-2.celestia-bootstrap.net",
    "count": 5,
    "success": 5,
    "failed": 0,
    "min": "27.443291ms",
    "max": "31.27ms",
    "average": "29.419524ms",
    "median": "29.70975ms",
    "std_dev": "1.313413ms"
  }
]

Standard Output

RTT Measurement Results:
========================

Bootstrapper: 12D3KooWQpuTFELgsUypqp9N4a1rKBccmrmQVY8Em9yhqppTJcXf
Address: da-bridge-2.celestia-bootstrap.net
  Ping Count: 5 (Success: 5, Failed: 0)
  Min RTT: 28.568416ms
  Max RTT: 32.427375ms
  Avg RTT: 30.201183ms
  Median RTT: 29.921541ms
  StdDev RTT: 1.33982ms

Bootstrapper: 12D3KooWE3fmRtHgfk9DCuQFfY3H3JYEnTU3xZozv1Xmo8KWrWbK
Address: da-full-2.celestia-bootstrap.net
  Ping Count: 5 (Success: 5, Failed: 0)
  Min RTT: 29.173125ms
  Max RTT: 32.002333ms
  Avg RTT: 31.047375ms
  Median RTT: 31.378417ms
  StdDev RTT: 1.001409ms

Bootstrapper: 12D3KooWSqZaLcn5Guypo2mrHr297YPJnV8KMEMXNjs3qAS8msw8
Address: da-bridge-1.celestia-bootstrap.net
  Ping Count: 5 (Success: 5, Failed: 0)
  Min RTT: 27.576584ms
  Max RTT: 65.276041ms
  Avg RTT: 38.037624ms
  Median RTT: 30.042958ms
  StdDev RTT: 14.01253ms

Bootstrapper: 12D3KooWBBzzGy5hAHUQVh2vBvL25CKwJ7wbmooPcz4amQhzJHJq
Address: boot.celestia.pops.one
  Ping Count: 5 (Success: 5, Failed: 0)
  Min RTT: 104.773291ms
  Max RTT: 107.502333ms
  Avg RTT: 106.11805ms
  Median RTT: 106.103334ms
  StdDev RTT: 927.308µs

Bootstrapper: 12D3KooWAzucnC7yawvLbmVxv53ihhjbHFSVZCsPuuSzTg6A7wgx
Address: celestia.qubelabs.io
  Ping Count: 5 (Success: 5, Failed: 0)
  Min RTT: 18.962791ms
  Max RTT: 21.418375ms
  Avg RTT: 20.357899ms
  Median RTT: 20.457167ms
  StdDev RTT: 803.953µs

Bootstrapper: 12D3KooWKZCMcwGCYbL18iuw3YVpAZoyb1VBGbx9Kapsjw3soZgr
Address: da-full-1.celestia-bootstrap.net
  Ping Count: 5 (Success: 5, Failed: 0)
  Min RTT: 27.371291ms
  Max RTT: 29.962916ms
  Avg RTT: 28.633541ms
  Median RTT: 28.481166ms
  StdDev RTT: 1.133113ms

…s to enhance diagnostics and monitoring capabilities

refactor(p2p.go): restructure connection handling and logging to support JSON output and improved RTT statistics processing
@github-actions github-actions bot added the external Issues created by non node team members label Mar 6, 2025
@aWN4Y25pa2EK aWN4Y25pa2EK added the kind:feat Attached to feature PRs label Mar 6, 2025
…ariable types instead of %s for consistency and better readability
…e string versions of duration fields for better readability in output

refactor(p2p.go): change RTTStats struct to exclude original duration fields from JSON output while adding new string fields for JSON serialization
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

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

That's useful. Thank you!

Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

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

utack but this is great thanks :)

@renaynay renaynay enabled auto-merge (squash) March 19, 2025 13:38
@renaynay
Copy link
Member

@aWN4Y25pa2EK could you just lint pls 🙏🏻

@cristaloleg
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Issues created by non node team members kind:feat Attached to feature PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants