Documentation
¶
Overview ¶
Package common contains common functionality for both TCP and UDP traceroute implementations
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrReceiveProbeNoPkt = errors.New("ReceiveProbe() doesn't have new packets")
ErrReceiveProbeNoPkt is returned when ReceiveProbe() didn't find anything new. This is normal if the RTT is long
Functions ¶
func LocalAddrForHost ¶
LocalAddrForHost takes in a destionation IP and port and returns the local address that should be used to connect to the destination. The returned connection should be closed by the caller when the the local UDP port is no longer needed
Types ¶
type CanceledError ¶
type CanceledError string
CanceledError is sent when a listener is canceled
func (CanceledError) Error ¶
func (c CanceledError) Error() string
Error implements the error interface for CanceledError
type Hop ¶
type Hop struct { IP net.IP Port uint16 ICMPType uint8 ICMPCode uint8 RTT time.Duration IsDest bool }
Hop encapsulates information about a single hop in a traceroute
type MatcherFunc ¶
MatcherFunc defines functions for matching a packet from the wire to a traceroute based on the source/destination addresses and an identifier
type MismatchError ¶
type MismatchError string
MismatchError is an error type that indicates a MatcherFunc failed due to one or more fields from the packet not matching the expected information
func (MismatchError) Error ¶
func (m MismatchError) Error() string
Error implements the error interface for MismatchError
type ProbeResponse ¶
type ProbeResponse struct { // TTL is the Time To Live of the probe that was originally sent TTL uint8 // IP is the IP address of the responding host IP netip.Addr // RTT is the round-trip time of the probe RTT time.Duration // IsDest is true if the responding host is the destination IsDest bool }
ProbeResponse is the response of a single probe in a traceroute
func TracerouteParallel ¶
func TracerouteParallel(ctx context.Context, t TracerouteDriver, p TracerouteParallelParams) ([]*ProbeResponse, error)
TracerouteParallel runs a traceroute in parallel
type TracerouteDriver ¶
type TracerouteDriver interface { // SendProbe sends a traceroute packet with a specific TTL SendProbe(ttl uint8) error // ReceiveProbe polls to get a traceroute response with a timeout ReceiveProbe(timeout time.Duration) (*ProbeResponse, error) }
TracerouteDriver is an implementation of traceroute send+receive of packets
type TracerouteParallelParams ¶
type TracerouteParallelParams struct { // MinTTL is the TTL to start the traceroute at MinTTL uint8 // MaxTTL is the TTL to end the traceroute at MaxTTL uint8 // TracerouteTimeout is the maximum time to wait for a response TracerouteTimeout time.Duration // PollFrequency is how often to poll for a response PollFrequency time.Duration // SendDelay is the delay between sending probes (typically small) SendDelay time.Duration }
TracerouteParallelParams are the parameters for TracerouteParallel