icmp

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2016 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package icmp provides icmp enhanced methods based on the golang icmp package

Index

Constants

View Source
const (
	ProtocolIPv4ICMP = 1  // IANA ICMP for IPv4
	ProtocolIPv6ICMP = 58 // IANA ICMP for IPv6
)

IANA ICMP

View Source
const (
	// Default TX timeout
	DefaultTXTimeout int64 = 1000
	// Default RX timeout
	DefaultRXTimeout int64 = 2000
)

Variables

This section is empty.

Functions

func Avg added in v0.2.2

func Avg(x, y float64) float64

Avg handles average delay

func IsIPv4 added in v0.1.9

func IsIPv4(ip net.IP) bool

IsIPv4 returns true if ip version is v4

func IsIPv6 added in v0.1.9

func IsIPv6(ip net.IP) bool

IsIPv6 returns true if ip version is v6

func Max added in v0.2.2

func Max(x, y float64) float64

Max handles maximum delay

func Min added in v0.2.2

func Min(x, y float64) float64

Min handles minimum delay

func NormalizeDuration added in v0.2.2

func NormalizeDuration(d string) string

NormalizeDuration adds default unit (seconds) as needed

Types

type HopResp added in v0.2.2

type HopResp struct {
	// contains filtered or unexported fields
}

HopResp represents hop's response

type MHopResp added in v0.2.2

type MHopResp []HopResp

MHopResp represents multi hop's responses

func (MHopResp) Len added in v0.2.2

func (h MHopResp) Len() int

func (MHopResp) Less added in v0.2.2

func (h MHopResp) Less(i, j int) bool

func (MHopResp) Swap added in v0.2.2

func (h MHopResp) Swap(i, j int)

type Ping

type Ping struct {
	MaxRTT time.Duration
	// contains filtered or unexported fields
}

Ping represents ping request

func NewPing

func NewPing(args string, cfg cli.Config) (*Ping, error)

NewPing creates a new ping object

func (*Ping) DelIP

func (p *Ping) DelIP(ipAddr string)

DelIP removes ip adrress

func (*Ping) IsCIDR added in v0.2.3

func (p *Ping) IsCIDR() bool

IsCIDR returns true if target is CIDR

func (*Ping) PacketSize

func (p *Ping) PacketSize(s int)

PacketSize set packet size

func (*Ping) Ping

func (p *Ping) Ping(out chan Response)

Ping tries to send and receive a packet

func (*Ping) PrintPretty added in v0.2.2

func (p *Ping) PrintPretty(resp chan Response)

PrintPretty prints out the result pretty format

func (*Ping) Run added in v0.1.9

func (p *Ping) Run() chan Response

Run loops the ping and print it out

func (*Ping) SetIP added in v0.1.9

func (p *Ping) SetIP(ips []net.IP) error

SetIP set ip address

type Response added in v0.1.9

type Response struct {
	RTT      float64
	Size     int
	Sequence int
	Addr     string
	Timeout  bool
	Error    error
}

Response represent ping response

type Trace

type Trace struct {
	// contains filtered or unexported fields
}

Trace represents trace properties

func NewTrace added in v0.2.2

func NewTrace(args string) (*Trace, error)

NewTrace creates new trace object

func (*Trace) Bind

func (i *Trace) Bind()

Bind starts to listen for ICMP reply

func (*Trace) Done

func (i *Trace) Done()

Done close the socket

func (*Trace) NextHop added in v0.2.2

func (i *Trace) NextHop(fd, hop int) HopResp

NextHop pings the specific hop by set TTL

func (*Trace) PrintPretty added in v0.2.2

func (i *Trace) PrintPretty()

PrintPretty prints out trace result

func (*Trace) Recv

func (i *Trace) Recv(fd int) (int, int, string)

Recv gets the replied icmp packet

func (*Trace) Run

func (i *Trace) Run(retry int) chan []HopResp

Run provides trace based on the other methods

func (*Trace) Send

func (i *Trace) Send() error

Send tries to send an UDP packet

func (*Trace) SetDeadLine added in v0.2.2

func (i *Trace) SetDeadLine() error

SetDeadLine sets tx/rx timeout

func (*Trace) SetReadDeadLine added in v0.2.2

func (i *Trace) SetReadDeadLine() error

SetReadDeadLine sets rx timeout

func (*Trace) SetTTL

func (i *Trace) SetTTL(ttl int)

SetTTL set the IP packat time to live

func (*Trace) SetWriteDeadLine added in v0.2.2

func (i *Trace) SetWriteDeadLine() error

SetWriteDeadLine sets tx timeout

type Whois added in v0.2.2

type Whois struct {
	// contains filtered or unexported fields
}

Whois represents prefix info from RIPE

Jump to

Keyboard shortcuts

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