mtr

package module
v0.0.0-...-407658d Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

README

mtr

mtr、 traceroute、 go、 icmp、 udp

Example

go build cmd/gomtr.go
sudo ./gomtr

Documentation

Index

Constants

View Source
const DEFAULT_MAX_HOPS = 30
View Source
const DEFAULT_PACKET_SIZE = 52
View Source
const DEFAULT_PORT = 33434
View Source
const DEFAULT_PROTO = "icmp"
View Source
const DEFAULT_PROTO_ICMP = "icmp"
View Source
const DEFAULT_PROTO_UDP = "udp"
View Source
const DEFAULT_RETRIES = 5
View Source
const DEFAULT_SNT_SIZE = 10
View Source
const DEFAULT_TIMEOUT_MS = 500

Variables

This section is empty.

Functions

func AddressString

func AddressString(addr [4]byte) string

func DestAddr

func DestAddr(dest string) (destAddr [4]byte, err error)

func DestAddrs

func DestAddrs(dest string) (addrs [][4]byte, err error)

func LocalAddr

func LocalAddr() (addr [4]byte, err error)

func T

func T(host string, isMtr bool, maxHops, packetSize, sntSize, retries int) (result string, err error)

func Time2Float

func Time2Float(t time.Duration) float32

Types

type MtrResult

type MtrResult struct {
	Success  bool
	TTL      int
	Host     string
	SuccSum  int
	LastTime time.Duration
	AllTime  time.Duration
	BestTime time.Duration
	AvgTime  time.Duration
	WrstTime time.Duration
}

type TracerouteHop

type TracerouteHop struct {
	Success  bool
	Address  string
	Host     string
	N        int
	TTL      int
	Snt      int
	LastTime time.Duration
	AvgTime  time.Duration
	BestTime time.Duration
	WrstTime time.Duration
	Loss     float32
}

type TracerouteOptions

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

func (*TracerouteOptions) MaxHops

func (options *TracerouteOptions) MaxHops() int

func (*TracerouteOptions) PacketSize

func (options *TracerouteOptions) PacketSize() int

func (*TracerouteOptions) Port

func (options *TracerouteOptions) Port() int

func (*TracerouteOptions) Retries

func (options *TracerouteOptions) Retries() int

func (*TracerouteOptions) SetMaxHops

func (options *TracerouteOptions) SetMaxHops(maxHops int)

func (*TracerouteOptions) SetPacketSize

func (options *TracerouteOptions) SetPacketSize(packetSize int)

func (*TracerouteOptions) SetPort

func (options *TracerouteOptions) SetPort(port int)

func (*TracerouteOptions) SetRetries

func (options *TracerouteOptions) SetRetries(retries int)

func (*TracerouteOptions) SetSntSize

func (options *TracerouteOptions) SetSntSize(sntSize int)

func (*TracerouteOptions) SetTimeoutMs

func (options *TracerouteOptions) SetTimeoutMs(timeoutMs int)

func (*TracerouteOptions) SntSize

func (options *TracerouteOptions) SntSize() int

func (*TracerouteOptions) TimeoutMs

func (options *TracerouteOptions) TimeoutMs() int

type TracerouteRequest

type TracerouteRequest struct {
	LocalAddr string
	DstAddr   string
	Ttl       int
	Timeout   int
}

type TracerouteResult

type TracerouteResult struct {
	DestAddress [4]byte
	Hops        []TracerouteHop
}

func Mtr

func Mtr(dest [4]byte, options *TracerouteOptions, c ...chan TracerouteHop) (result TracerouteResult, err error)

func Traceroute

func Traceroute(dest [4]byte, options *TracerouteOptions, c ...chan TracerouteHop) (result TracerouteResult, err error)

type TracerouteReturn

type TracerouteReturn struct {
	Success bool
	Addr    string
	Elapsed time.Duration
}

func Icmp

func Icmp(localAddr string, dst net.Addr, ttl, pid int, timeout time.Duration) (hop TracerouteReturn, err error)

func IcmpRpc

func IcmpRpc(localAddr string, dstAddr string, ttl int, timeout int) (hop TracerouteReturn, err error)

func IcmpWrapper

func IcmpWrapper(localAddr, destAddr [4]byte, ttl, port int, tv syscall.Timeval, p []byte) (hop TracerouteReturn, err error)

func Udp

func Udp(socketAddr, destAddr [4]byte, ttl, port int, tv syscall.Timeval, p []byte) (hop TracerouteReturn, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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