Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultTimeout is the default timeout to be used to a ping request. DefaultTimeout = time.Second // DefaultPacketSize is the default packet size for ping requests. DefaultPacketSize = uint(56) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct { // Timeout sets the timeout for each ping request. // The default timeout is 1 second. Timeout time.Duration // Count sets the number of packets to be sent/received. // The default count is 0, which means ping requests will be sent // indefinitely. Count uint // PacketSize sets the size of packets to be sent/received. // The default packet size is 56 bytes. PacketSize uint }
Options defines the options for a Pinger.
type Ping ¶
type Ping struct { // Seq is the sequence number. Seq int // Size is the number of bytes in the response. Size int // RTT is the duration for the round trip. RTT time.Duration // Timeout is whether or not the request timed out. Timeout bool }
Ping represents a ping request/response.
type Pinger ¶
type Pinger interface { // Ping accepts a net.Addr representing a host and sends ICMP ping packets // to that host. Ping is a blocking operation. Ping(addr net.Addr) // Stop signals the Pinger to stop sending ping requests to the host. // After a call to Stop(), Ping() is expected to return. Stop() // Report returns the pair of channels where results will be reported to: // 1) a channel of type Ping for successful requests (including temporary errors, e.g. timeouts) // 2) a channel of type error for unrecoverable errors Report() (<-chan Ping, <-chan error) // Stats returns the packet statistics accumulated for the host being // pinged. Stats() Stats }
Pinger defines the operations of a pinger.
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats stores the packet statistics.
func (*Stats) PacketLoss ¶
PacketLoss calculates and returns the percentage of packets that have been lost (i.e. a packet was sent, but a reply was not received due to a timeout).
func (*Stats) RTTStats ¶
RTTStats calculates and returns, respectively, the min, average, max and standard deviation for round-trip latencies.
func (*Stats) Transmitted ¶
Transmitted returns the total number of packets transmitted.
Click to show internal directories.
Click to hide internal directories.