pathping

package
v0.0.0-...-e2dc121 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllPeers

func GetAllPeers() (map[int][]int, error)

Types

type Client

type Client struct {
	Count    int
	Interval time.Duration
}

func NewClient

func NewClient(count int, interval time.Duration) *Client

func (*Client) Measure

func (c *Client) Measure(path []int) (Result, error)

type Config

type Config struct {
	ID         uint16
	Port       int
	BufferSize int
	Logger     logging.Logger
}

Config contains the configuration for a mesh node

type MeasurementOptions

type MeasurementOptions struct {
	Count    int           // Number of measurements to take
	Interval time.Duration // Interval between measurements
	PathVer  []uint16
}

MeasurementOptions contains options for starting a measurement

type PathPingServer

type PathPingServer struct {
	// contains filtered or unexported fields
}

PathPingServer represents a mesh network node capable of forwarding and measuring latency

func NewServer

func NewServer(global *system.Node) *PathPingServer

NewServer returns a new PathPingServer instance with the given config.

The PathPingServer is a singleton and only one instance is created for the entire program. Subsequent calls to NewServer will return the same instance.

The server is configured with the given site ID, port, and buffer size. A logger is also provided which is used to log any errors or messages.

The server is not started until the Start method is called.

func (*PathPingServer) Measure

func (n *PathPingServer) Measure(path []uint16, opts MeasurementOptions) (Result, error)

Measure sends a packet along the given path and measures the round-trip time.

The measurement is repeated 'count' times with an interval of 'interval' between each measurement. The server will return an error if the measurement exceeds the given timeout.

The path must start with the local node ID and must be between 2 and *pathPingMax (default 16) nodes long.

func (*PathPingServer) Start

func (n *PathPingServer) Start() error

Start the PathPingServer and begin listening for incoming packets.

The server is configured to listen on the configured port and IP address and to connect to all other nodes in the mesh network.

The server will start listening for incoming packets and will begin forwarding packets to the next hop.

The server will return an error if it is already started.

func (*PathPingServer) Stop

func (n *PathPingServer) Stop() error

type Result

type Result struct {
	Status   int
	Protocol string
	Path     []uint16
	Duration time.Duration
	Loss     float64
}

Result contains the results of a completed measurement

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL