probe

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package probe measures the network: ICMP, TCP and UDP round trips, and Paris traceroutes.

Index

Constants

View Source
const DefaultTracePort = 33434

DefaultTracePort is the classic traceroute destination port.

Variables

This section is empty.

Functions

func ValidateTrace

func ValidateTrace(s TraceSpec) error

ValidateTrace checks a spec before it is scheduled.

Types

type Env

type Env struct {
	Host       string // target name, for the HTTP Host header and TLS
	Privileged bool   // raw ICMP sockets allowed
}

Env is what the edge knows beyond the spec of a check.

type Hop

type Hop struct {
	IP   netip.Addr
	Sent int
	RTTs []time.Duration
}

Hop is one TTL. IP is zero when nothing answered.

type Prober

type Prober interface {
	Probe(ip string, count int, timeout time.Duration) Result
}

Prober runs one cycle against a literal IP address.

func New

func New(s check.Spec, env Env) (Prober, error)

New builds the prober of a check. The spec must be valid (see check.Spec.Validate); options are parsed here.

type Resolution

type Resolution struct {
	IP      netip.Addr
	Latency time.Duration
	Looked  bool // false for a literal address
	Err     error
}

Resolution is the outcome of one lookup.

func Resolve

func Resolve(ctx context.Context, host string, f check.Family, timeout time.Duration) Resolution

Resolve turns a host into the address to probe, once per cycle.

type Result

type Result struct {
	Sent     int
	Received int
	RTTs     []time.Duration // answered samples, in order
	Err      error           // last error, for diagnostics
	Metrics  map[string]float64
}

Result is one cycle of samples.

type Trace

type Trace struct {
	Hops    []Hop
	Reached bool // the destination answered
	Err     error
}

Trace is the result of one traceroute.

func Traceroute

func Traceroute(ctx context.Context, dst netip.Addr, s TraceSpec) Trace

Traceroute walks the path to dst, one probe at a time. All probes share the same ports (Paris traceroute), so per-flow load balancing keeps them on one path.

type TraceSpec

type TraceSpec struct {
	Protocol  check.Protocol // check.TraceUDP or check.TraceICMP
	Port      int            // udp destination, 0 for DefaultTracePort
	LocalPort int            // udp source, 0 for ephemeral
	MaxHops   int
	Count     int           // probes per hop
	Timeout   time.Duration // per probe
	// Called before each probe, for rate limiting. Optional.
	Wait func(ctx context.Context) error
}

TraceSpec describes a traceroute.

Jump to

Keyboard shortcuts

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