icmp

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: MIT Imports: 21 Imported by: 28

Documentation

Overview

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

Index

Constants

View Source
const (
	// DefaultTXTimeout is socket send timeout
	DefaultTXTimeout int64 = 2000
	// ProtocolIPv4ICMP is IANA ICMP IPv4
	ProtocolIPv4ICMP = 1
	// ProtocolIPv6ICMP is IANA ICMP IPv6
	ProtocolIPv6ICMP = 58

	// IPv4ICMPTypeEchoReply is ICMPv4 Echo Reply
	IPv4ICMPTypeEchoReply = 0
	// IPv4ICMPTypeDestinationUnreachable is ICMPv4 Destination Unreachable
	IPv4ICMPTypeDestinationUnreachable = 3
	// IPv4ICMPTypeTimeExceeded is ICMPv4 Time Exceeded
	IPv4ICMPTypeTimeExceeded = 11

	// IPv6ICMPTypeEchoReply is ICMPv6 Echo Reply
	IPv6ICMPTypeEchoReply = 129
	// IPv6ICMPTypeDestinationUnreachable is ICMPv6 Destination Unreachable
	IPv6ICMPTypeDestinationUnreachable = 1
	//IPv6ICMPTypeTimeExceeded is ICMPv6 Time Exceeded
	IPv6ICMPTypeTimeExceeded = 3
)

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 Geo added in v0.2.5

type Geo struct {
	// CountrySrc Geo country source
	CountrySrc string
	// CountryDst Geo country destination
	CountryDst string
	// CitySrc Geo country source
	CitySrc string
	// CityDst Geo country source
	CityDst string
	// Latitude Geo source
	LatSrc float64
	// Latitude Geo destination
	LatDst float64
	// Longitude Geo source
	LonSrc float64
	// Longitude Geo destination
	LonDst float64
	// Distance holds src to dst distance
	Distance float64
}

Geo represents IP Geo params

type HopResp added in v0.2.2

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

HopResp represents hop's response

func (*HopResp) Marshal added in v0.2.6

func (h *HopResp) Marshal() string

Marshal encodes hop response

type ICMPResp added in v0.2.4

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

ICMPResp represents ICMP response msg

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 Stats added in v0.2.4

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

Stats represents statistic's fields

type TCPOption added in v0.2.6

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

TCPOption represents TCP option

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, cfg cli.Config) (*Trace, error)

NewTrace creates new trace object

func (*Trace) Bind

func (i *Trace) Bind() error

Bind starts to listen for ICMP reply

func (*Trace) MRun added in v0.2.4

func (i *Trace) MRun() (chan HopResp, error)

MRun provides trace all hops in loop

func (*Trace) NextHop added in v0.2.2

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

NextHop pings the specific hop by set TTL

func (*Trace) Print added in v0.2.4

func (i *Trace) Print()

Print prints out trace result in normal or terminal mode

func (*Trace) PrintPretty added in v0.2.2

func (i *Trace) PrintPretty()

PrintPretty prints out trace result

func (*Trace) Recv

func (i *Trace) Recv(id, seq int) (ICMPResp, error)

Recv gets the replied icmp packet

func (*Trace) Run

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

Run provides trace based on the other methods

func (*Trace) Send

func (i *Trace) Send(port int) (int, int, error)

Send tries to send ICMP/UDP IPv4/IPv6 packet

func (*Trace) Sendv4 added in v0.2.6

func (i *Trace) Sendv4(id, seq, rport int) error

Send tries to send ICMP/UDP IPv4 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

func (*Trace) TermUI added in v0.2.4

func (i *Trace) TermUI() (string, error)

TermUI prints out trace loop by termui

type Whois added in v0.2.2

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

Whois represents prefix info from RIPE

type Widgets added in v0.2.5

type Widgets struct {
	Hops *ui.List
	ASN  *ui.List
	RTT  *ui.List
	Snt  *ui.List
	Pkl  *ui.List

	Menu   *ui.Par
	Header *ui.Par

	LCRTT *ui.LineChart
	BCPKL *ui.BarChart
}

Widgets represents termui widgets

Jump to

Keyboard shortcuts

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