packet

package
v0.0.0-...-3733eb8 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 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/internal/iana#pkg-constants

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

Variables

This section is empty.

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 Packet

type Packet struct {
	// 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.IP
	// Dst is the destination IP
	Dst net.IP
	// ID is the ICMP ID
	ID int
	// Seq is the ICMP Sequence
	Seq int
	// Sent is the time the echo was sent
	Sent time.Time
	// Recieved is the time the echo was recieved.
	Recieved time.Time
	// TimedOut is the time the echo timed out
	TimedOut time.Time
	// TTL is the ttl on the recieved packet.
	TTL int
	// Len is the length of the recieved packet
	Len int
	// RTT is the round trip time of the packet
	RTT time.Duration
}

Packet is an ICMP packet that has been received

func (*Packet) ToICMPMsg

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

ToICMPMsg returns a byte array ready to send on the wire

Jump to

Keyboard shortcuts

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