ping

package
v0.0.0-...-113f59a Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package ping allows sending ICMP echo requests to a host in order to determine network latency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListenPacketer

type ListenPacketer interface {
	ListenPacket(ctx context.Context, typ string, addr string) (net.PacketConn, error)
}

PacketListener defines the interface required to listen to packages on an address.

type Pinger

type Pinger struct {
	Logf    logger.Logf
	Verbose bool
	// contains filtered or unexported fields
}

Pinger represents a set of ICMP echo requests to be sent at a single time.

A new instance should be created for each concurrent set of ping requests; this type should not be reused.

func New

func New(ctx context.Context, logf logger.Logf, lp ListenPacketer) *Pinger

New creates a new Pinger. The Context provided will be used to create network listeners, and to set an absolute deadline (if any) on the net.Conn

func (*Pinger) Close

func (p *Pinger) Close() error

func (*Pinger) Send

func (p *Pinger) Send(ctx context.Context, dest net.Addr, data []byte) (time.Duration, error)

Send sends an ICMP Echo Request packet to the destination, waits for a response, and returns the duration between when the request was sent and when the reply was received.

If provided, "data" is sent with the packet and is compared upon receiving a reply.

Jump to

Keyboard shortcuts

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