traceroute

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAXDATALEN     = 65000
	DEFAULTDATALEN = 40

	DEFFIRSTHOP  = 1
	MAXHOPS      = 255
	DEFSIMPROBES = 16
	DEFNUMPROBES = 3

	DEFPORT    = 0
	DEFTCPPORT = 80

	DEFWAITSEC    = 5
	DEFHEREFACTOR = 3
	DEFNEARFACTOR = 10
	DEFSENDSECS   = 0

	DEFMODULE = "default"

	IPV4HdrMinLen = 20
	IPV6HdrLen    = 40

	TCPDEFPORT   = 443
	UDPDEFPORT   = 33434
	DEFNUMHOPS   = 20
	DEFNUMTRACES = 3
)
View Source
const (
	TCP_FIN = 1 << 0
	TCP_SYN = 1 << 1
	TCP_RST = 1 << 2
	TCP_PSH = 1 << 3
	TCP_ACK = 1 << 4
	TCP_URG = 1 << 5
)
View Source
const (
	DNSIPv6 = "[2001:4860:4860::8844]"
	DNSIPv4 = "8.8.8.8"
)

Variables

This section is empty.

Functions

func DestAddr

func DestAddr(dest, proto string) (net.IP, error)

Given a host name convert it to a IP address according to provided ip protocol.

func DestTTL

func DestTTL(printMap map[int]*Probe) int

func RunTraceroute

func RunTraceroute(f *Flags) error

func SrcAddr

func SrcAddr(proto string) (*net.IP, error)

Types

type Args

type Args struct {
	Host string
}

type Coms

type Coms struct {
	SendChan chan *Probe
	RecvChan chan *Probe
}

type Flags

type Flags struct {
	Host         string
	Proto        string
	ICMP         bool
	TCP          bool
	MaxHops      int
	DestPortSeq  uint
	TOS          int
	ProbesPerHop int
	Source       string
	Module       string
	UDP          bool
}

type ICMPHeader

type ICMPHeader struct {
	IType    uint8
	ICode    uint8
	Checksum uint16
	ID       uint16
	Seq      uint16
}

type Probe

type Probe struct {
	ID       uint32
	Sendtime time.Time
	RecvTime time.Time
	Dest     net.IP
	Port     uint16
	TTL      int
	Saddr    net.IP
	Done     bool
}

func GetProbesByTLL

func GetProbesByTLL(printMap map[int]*Probe, ttl int) []*Probe

type TCPHeader

type TCPHeader struct {
	Src        uint16
	Dst        uint16
	SeqNum     uint32
	AckNum     uint32
	DataOffset uint8 // only use high 4 bits
	Flags      uint8 // only use low 6 bits
	Window     uint16
	Checksum   uint16
	Urgent     uint16
}

func ParseTCP

func ParseTCP(data []byte) (*TCPHeader, error)

type Trace

type Trace struct {
	DestIP net.IP

	// See --port in traceroute(8):
	// For UDP tracing, specifies the destination port base traceroute will use (the destination port number
	// will be incremented by each probe).
	// For ICMP tracing, specifies the initial ICMP sequence value (incremented by each probe too).
	// For TCP and others specifies just the (constant) destination port to connect.
	DestPort uint16

	SrcIP        net.IP
	PortOffset   int32
	MaxHops      int
	SendChan     chan<- *Probe
	ReceiveChan  chan<- *Probe
	TracesPerHop int
	PacketRate   int
	ICMPSeqStart uint16
}

func NewTrace

func NewTrace(proto string, dAddr net.IP, sAddr net.IP, cc Coms, f *Flags) *Trace

func (*Trace) BuildICMP4Pkt

func (t *Trace) BuildICMP4Pkt(ttl uint8, id, seq uint16, tos int) (*ipv4.Header, []byte)

func (*Trace) BuildICMP6Pkt

func (t *Trace) BuildICMP6Pkt(ttl int, id uint16, seq uint16, tc int) (*ipv6.ControlMessage, []byte)

func (*Trace) BuildTCP4SYNPkt

func (t *Trace) BuildTCP4SYNPkt(srcPort uint16, dstPort uint16, ttl uint8, seq uint32, tos int) (*ipv4.Header, []byte)

func (*Trace) BuildTCP6SYNPkt

func (t *Trace) BuildTCP6SYNPkt(sport, dport, ttl uint16, seq uint32, tc int) (*ipv6.ControlMessage, []byte)

func (*Trace) BuildUDP4Pkt

func (t *Trace) BuildUDP4Pkt(srcPort uint16, dstPort uint16, ttl uint8, id uint16, tos int) (*ipv4.Header, []byte)

func (*Trace) BuildUDP6Pkt

func (t *Trace) BuildUDP6Pkt(sport, dport uint16, ttl uint8, id uint16, tos int) (*ipv6.ControlMessage, []byte)

func (*Trace) IPv4TCPPing

func (t *Trace) IPv4TCPPing(seq uint32, dport uint16)

func (*Trace) IPv4TCPProbe

func (t *Trace) IPv4TCPProbe(dport uint16)

func (*Trace) IPv6TCPPing

func (t *Trace) IPv6TCPPing(seq uint32, dport uint16)

func (*Trace) IPv6TCPProbe

func (t *Trace) IPv6TCPProbe(dport uint16)

func (*Trace) ReceiveTraceICMP6

func (t *Trace) ReceiveTraceICMP6()

func (*Trace) ReceiveTracesICMP4

func (t *Trace) ReceiveTracesICMP4()

func (*Trace) ReceiveTracesTCP4

func (t *Trace) ReceiveTracesTCP4()

func (*Trace) ReceiveTracesTCP4ICMP

func (t *Trace) ReceiveTracesTCP4ICMP()

func (*Trace) ReceiveTracesTCP6

func (t *Trace) ReceiveTracesTCP6()

func (*Trace) ReceiveTracesTCP6ICMP

func (t *Trace) ReceiveTracesTCP6ICMP()

func (*Trace) ReceiveTracesUDP4

func (t *Trace) ReceiveTracesUDP4()

func (*Trace) ReceiveTracesUDP6

func (t *Trace) ReceiveTracesUDP6()

func (*Trace) SendTracesICMP4

func (t *Trace) SendTracesICMP4()

func (*Trace) SendTracesICMP6

func (t *Trace) SendTracesICMP6()

func (*Trace) SendTracesTCP4

func (t *Trace) SendTracesTCP4()

func (*Trace) SendTracesTCP6

func (t *Trace) SendTracesTCP6()

func (*Trace) SendTracesUDP4

func (t *Trace) SendTracesUDP4()

SendTrace in a routine

func (*Trace) SendTracesUDP6

func (t *Trace) SendTracesUDP6()

type UDPHeader

type UDPHeader struct {
	Src    uint16
	Dst    uint16
	Length uint16
	Chksum uint16
}

Jump to

Keyboard shortcuts

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