Documentation
¶
Overview ¶
Package networkcheck implements logic for collecting network statistics
Index ¶
- func RunNetworkChecks(ctx context.Context, rdkLogger logging.Logger, continueRunningTests bool)
- func TestDNS(ctx context.Context, logger logging.Logger, verbose bool)
- func TestPacketLoss(ctx context.Context, logger logging.Logger, verbose bool)
- type DNSResult
- type DNSTestType
- type PacketLossResult
- type STUNResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunNetworkChecks ¶
RunNetworkChecks characterizes the network through a series of DNS, UDP STUN, TCP STUN, and packet loss network checks. Can and should be run asynchronously with server startup to avoid blocking. Specifying continueRunningTests as true will run DNS and packet loss checks every 5 minutes in goroutines non-verbosely after this function completes until context error.
func TestDNS ¶ added in v0.86.2
TestDNS tests connectivity to DNS servers and attempts to resolve hostnames with the system DNS resolver. Should be run at startup, every 5 minutes afterward, and whenever dialing app.viam.com fails. If verbose is true, logs successful and unsuccessful results. Logs only unsuccessful results otherwise.
func TestPacketLoss ¶ added in v0.124.0
TestPacketLoss measures packet loss to the default gateway (router) and to ispProbeTarget as an indicator of ISP/WAN connectivity. If verbose is true, successful results are logged; otherwise only failures are logged.
Types ¶
type DNSResult ¶ added in v0.86.2
type DNSResult struct {
// TestType indicates the type of DNS test.
TestType DNSTestType
// Any error encountered during the test.
ErrorString *string
// DNS server being tested.
DNSServer *string
// Time taken to connect to DNS server.
ConnectTimeMS *int64
// Time taken to send query and receive response.
QueryTimeMS *int64
// Size of DNS response in bytes.
ResponseSize *int64
// Hostname being resolved.
Hostname *string
// Resolved IP addresses (comma-separated).
ResolvedIPs *string
// Time taken to resolve the hostname.
ResolutionTimeMS *int64
}
DNSResult represents the result of a DNS resolution test.
type DNSTestType ¶ added in v0.86.2
type DNSTestType int
DNSTestType is an enumeration of test types.
const ( // ConnectionDNSTestType is a DNS connection test. ConnectionDNSTestType DNSTestType = iota // ResolutionDNSTestType is a DNS resolution test. ResolutionDNSTestType )
func (DNSTestType) String ¶ added in v0.86.2
func (dtt DNSTestType) String() string
String stringifies a DNS test type.
type PacketLossResult ¶ added in v0.124.0
type PacketLossResult struct {
// Target is the IP address being probed.
Target string
// Description describes the role of the target (e.g., "router", "ISP").
Description string
// Sent is the number of ICMP echo probes sent.
Sent int
// Received is the number of ICMP echo replies received.
Received int
// AvgRTTMS is the average round-trip time in milliseconds across received replies.
// Nil if no replies were received.
AvgRTTMS *int64
// ErrorString is set if the test could not be initialized or completed.
ErrorString *string
}
PacketLossResult holds the results of a packet loss probe to a specific host.
func (*PacketLossResult) LossPercent ¶ added in v0.124.0
func (r *PacketLossResult) LossPercent() float64
LossPercent returns the percentage of probes that were lost.
type STUNResponse ¶
type STUNResponse struct {
// STUNServerURL is the URL of the STUN server.
STUNServerURL string
// TCPSourceAddress is the source address for the bind request if this was a TCP test.
// If it was a UDP test, it will be the same UDP source address for all UDP tests, and
// that value will be passed to `logSTUNResults`.
TCPSourceAddress *string
// STUNServerAddr is the resolved address of the STUN server.
STUNServerAddr *string
// BindResponseAddr is our address as reported by the STUN server.
BindResponseAddr *string
// Time taken to send bind request, receive bind response, and extract address. A vague
// measurement of RTT to the STUN server.
TimeToBindResponseMS *int64
// Any error received during STUN interactions.
ErrorString *string
}
STUNResponse represents a response from a STUN server.