ping

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package ping implements pinging based on SCMP echo messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Size

func Size(local, remote *snet.UDPAddr, pldSize int) (int, error)

Size computes the full SCION packet size for an address pair with a given payload size.

Types

type Config

type Config struct {
	Dispatcher reliable.Dispatcher
	Local      *snet.UDPAddr
	Remote     *snet.UDPAddr

	// Attempts is the number of pings to send.
	Attempts uint16
	// Interval is the time between sending pings.
	Interval time.Duration
	// Timeout is the time until a ping is considered to have timed out.
	Timeout time.Duration
	// PayloadSize is the size of the SCMP echo payload.
	PayloadSize int

	// ErrHandler is invoked for every error that does not cause pinging to
	// abort. Execution time must be small, as it is run synchronously.
	ErrHandler func(err error)
	// Update handler is invoked for every ping reply. Execution time must be
	// small, as it is run synchronously.
	UpdateHandler func(Update)
}

Config configures the ping run.

type State

type State int

State indicates the state of the echo reply

const (
	Success State = iota
	AfterTimeout
	OutOfOrder
	Duplicate
)

Possible states.

func (State) String added in v0.9.0

func (s State) String() string

type Stats

type Stats struct {
	Sent     int `json:"sent" yaml:"sent"`
	Received int `json:"received" yaml:"received"`
}

Stats contains the statistics of a ping run.

func Run

func Run(ctx context.Context, cfg Config) (Stats, error)

Run ping with the configuration. This blocks until the configured number attempts is sent, or the context is canceled.

type Update

type Update struct {
	Size     int
	Source   snet.SCIONAddress
	Sequence int
	RTT      time.Duration
	State    State
}

Update contains intermediary information about a received echo reply

Jump to

Keyboard shortcuts

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