icmp

package
v0.0.0-...-550a133 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 21 Imported by: 0

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

func Avg(x, y float64) float64

Avg handles average delay

func CIDRRespPrint

func CIDRRespPrint(resp Response)

CIDRRespPrint prints out CIDR host response status

func IsIPv4

func IsIPv4(ip net.IP) bool

IsIPv4 returns true if ip version is v4

func IsIPv6

func IsIPv6(ip net.IP) bool

IsIPv6 returns true if ip version is v6

func Max

func Max(x, y float64) float64

Max handles maximum delay

func Min

func Min(x, y float64) float64

Min handles minimum delay

func NormalizeDuration

func NormalizeDuration(d string) string

NormalizeDuration adds default unit (seconds) as needed

Types

type Geo

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

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

HopResp represents hop's response

func (*HopResp) Marshal

func (h *HopResp) Marshal() string

Marshal encodes hop response

type ICMPResp

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

ICMPResp represents ICMP response msg

type MHopResp

type MHopResp []HopResp

MHopResp represents multi hop's responses

func (MHopResp) Len

func (h MHopResp) Len() int

func (MHopResp) Less

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

func (MHopResp) Swap

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) CIDRHeader

func (p *Ping) CIDRHeader()

CIDRHeader prints ping CIDR header

func (*Ping) IsCIDR

func (p *Ping) IsCIDR() bool

IsCIDR returns true if target is CIDR

func (*Ping) MRun

func (p *Ping) MRun() chan Response

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

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

PrintPretty prints out the result pretty format

func (*Ping) Run

func (p *Ping) Run() chan Response

Run loops the ping and print it out

func (*Ping) SetIP

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

SetIP set ip address

type Response

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

Response represent ping response

type Stats

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

Stats represents statistic's fields

type TCPOption

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

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

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

MRun provides trace all hops in loop

func (*Trace) NextHop

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

NextHop pings the specific hop by set TTL

func (*Trace) Print

func (i *Trace) Print()

Print prints out trace result in normal or terminal mode

func (*Trace) PrintPretty

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

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

Send tries to send ICMP/UDP IPv4 packet

func (*Trace) SetDeadLine

func (i *Trace) SetDeadLine() error

SetDeadLine sets tx/rx timeout

func (*Trace) SetReadDeadLine

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

func (i *Trace) SetWriteDeadLine() error

SetWriteDeadLine sets tx timeout

func (*Trace) TermUI

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

TermUI prints out trace loop by termui

type Whois

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

Whois represents prefix info from RIPE

type Widgets

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