ping

package
v1.38.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: BSD-3-Clause Imports: 13 Imported by: 5

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 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) (*Pinger, error)

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