icmp

package module
v0.0.0-...-6bc2bad Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

icmp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ping

func Ping(address string, count uint16) ([]int, error)

Ping sends count IPv4 ICMP echo packets to the address. Reply times are returned with -1 for missing packets.

func ValidateEchoReply

func ValidateEchoReply(sent, received Packet) (bool, error)

ValidateEchoReply checks that the received packet is the correct reply to the sent packet.

Types

type Packet

type Packet []byte

Packet holds an IPv4 ICMP packet.

func BuildEchoRequest

func BuildEchoRequest(identifier uint16, sequence uint16, payload []byte) Packet

BuildEchoRequest generates a valid ICMP echo packet with the payload supplied.

type Type

type Type byte

Type are the valid codes in the first byte of an ICMP packet. See RFC 792 for a detailed explanation each type.

const (
	//EchoReply is the response to an Echo packet.
	EchoReply Type = 0
	//DestinationUnreachable if the destination can't be reached.
	DestinationUnreachable Type = 3
	//Redirect indicates an alternative path to a destination.
	Redirect Type = 5
	//Echo is a request to receive an EchoReply.
	Echo Type = 8
	//RouterAdvertisement used by ICMP Internet Router Discovery Protocol (IRDP).
	RouterAdvertisement Type = 9
	//RouterSolicitation used by ICMP Internet Router Discovery Protocol (IRDP).
	RouterSolicitation Type = 10
	//TimeExceeded indicates the destination can't be reached due to TTL.
	TimeExceeded Type = 11
	//ParameterProblem indicates a problem with the header.
	ParameterProblem Type = 12
	//Timestamp requests a TimestampReply to determine round trip and processing time.
	Timestamp Type = 13
	//TimestampReply responds to Timestamp to determine round trip and processing time.
	TimestampReply Type = 14
	//ExtendedEcho is an extended ping request. See RFC 4884.
	ExtendedEcho Type = 42
	//ExtendedEchoReply is the response to an ExtendedEcho request request. See RFC 4884.
	ExtendedEchoReply Type = 43
	//InvalidOrUnknown is used to indicated a Type that is bad.
	InvalidOrUnknown Type = 255
)

func (Type) Byte

func (t Type) Byte() byte

Byte returns the numerical resprentation of the Type, or 255 if it is InvalidOrUnknown.

func (Type) String

func (t Type) String() string

String returns the name of the type, or InvalidOrUnknown.

Jump to

Keyboard shortcuts

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