ping

package
v0.0.0-...-d9fbfd9 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolICMP     = 1
	ProtocolIPv6ICMP = 58 // ICMP for IPv6
)

see https://godoc.org/golang.org/x/net/ping/internal/iana#pkg-constants

View Source
const (
	// TimeSliceLength is the length of the icmp payload holding the timestamp
	TimeSliceLength = 8
)

Variables

View Source
var ErrTooShort = errors.New("too short")

ErrTooShort is returned if an echo body holding the timeslice is too short

Functions

func BytesToTime

func BytesToTime(b []byte) (time.Time, error)

BytesToTime converst a []byte into a time.Time

func TimeToBytes

func TimeToBytes(t time.Time) []byte

TimeToBytes converts a time.Time into a []byte for inclusion in the ICMP payload

Types

type ID

type ID uint16

ID is an ICMP ID

type Ping

type Ping struct {
	// Host is the hostname that was pinged
	Host string
	// Src is the source IP. This is probably 0.0.0.0 for sent packets, but a
	// specific IP on the sending host for recieved packets
	Src *net.IPAddr
	// Dst is the destination IP.
	// This will be nil for recieved packets on windows. The reason is that
	// the recieve function does not provide the source address
	// on windows ICMP messages are mathed only by the 16 bit ICMP id.
	Dst *net.IPAddr
	// Count is the ICMP count
	Count int
	// ID is the ICMP ID
	ID ID
	// Seq is the ICMP Sequence
	Seq Seq
	// Sent is the time the echo was sent
	Sent time.Time
	// Recieved is the time the echo was recieved.
	Recieved time.Time
	// TimeOut is timeout duration
	TimeOut time.Duration
	// TTL is the ttl on the recieved packet.
	// This is not supported on windows and will always be zero
	TTL int
	// Len is the length of the recieved packet
	Len int
}

Ping is an ICMP packet that has been received

func (*Ping) RTT

func (p *Ping) RTT() time.Duration

RTT returns the RTT of the ping

func (*Ping) TimeOutTime

func (p *Ping) TimeOutTime() time.Time

TimeOutTime returns the time this ping times out

func (*Ping) ToICMPMsg

func (p *Ping) ToICMPMsg() ([]byte, error)

ToICMPMsg returns a byte array ready to send on the wire

func (*Ping) UpdateFrom

func (p *Ping) UpdateFrom(rp *Ping)

UpdateFrom is for updating a sent ping with attributes from a recieved ping

type Seq

type Seq uint16

Seq is an ICMP Sequence

Jump to

Keyboard shortcuts

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