Commit ca55bb49 authored by Adphi's avatar Adphi

updated docs

parent b222af32
# Ping
Ping is based on [github.com/digineo/go-ping](https://github.com/digineo/go-ping),
more precisely on [github.com/digineo/go-ping/cmd/multiping](https://github.com/digineo/go-ping/tree/master/cmd/multiping)
more precisely on [github.com/digineo/go-ping/cmd/multiping](https://github.com/digineo/go-ping/tree/master/cmd/multiping).
It allow to ping multiple destinations.
Example :
```go
package main
......@@ -53,3 +57,76 @@ func main() {
}
}
```
The pinger :
```go
type Pinger interface {
// deprecated: removed udp support
Privileged() bool
// Addresses returns the list of the destinations host
Addresses() []string
// IPAddresses returns the list of the destinations addresses
IPAddresses() []net.IPAddr
// AddAddress add a destination to the pinger
AddAddress(a string) error
// Remove Address remove a destination from the pinger
RemoveAddress(a string) error
// Run start the pinger. It fails silently if the pinger is already running
Run()
// Stop stops the pinger. It fails silently if the pinger is already stopped
Stop()
// IsRunning returns the state of the pinger
IsRunning() bool
// Statistics returns the a map address ping Statistics
Statistics() map[string]Statistics
// Close closes the connection. It should be call deferred right after the creation of the pinger
Close()
}
```
The Statistics :
```go
type Statistics struct {
// PacketsRecv is the number of packets received.
PacketsRecv int
// PacketsSent is the number of packets sent.
PacketsSent int
// PacketLoss is the percentage of packets lost.
PacketLoss float64
// IPAddr is the address of the host being pinged.
IPAddr net.IPAddr
// Addr is the string address of the host being pinged.
Addr string
// Rtts is the last 10 round-trip times sent via this pinger.
// 0 means nothing was received
Rtts []time.Duration
// MinRtt is the minimum round-trip time sent via this pinger.
MinRtt time.Duration
// MaxRtt is the maximum round-trip time sent via this pinger.
MaxRtt time.Duration
// AvgRtt is the average round-trip time sent via this pinger.
AvgRtt time.Duration
// StdDevRtt is the standard deviation of the round-trip times sent via
// this pinger.
StdDevRtt time.Duration
}
```
......@@ -12,22 +12,33 @@ import (
"github.com/sirupsen/logrus"
)
//Pinger
type Pinger interface {
// deprecated: removed udp support
Privileged() bool
// Addresses returns the list of the destinations host
Addresses() []string
// IPAddresses returns the list of the destinations addresses
IPAddresses() []net.IPAddr
// AddAddress add a destination to the pinger
AddAddress(a string) error
// Remove Address remove a destination from the pinger
RemoveAddress(a string) error
// Run start the pinger. It fails silently if the pinger is already running
Run()
// Stop stops the pinger. It fails silently if the pinger is already stopped
Stop()
// IsRunning returns the state of the pinger
IsRunning() bool
// Statistics returns the a map address ping Statistics
Statistics() map[string]Statistics
// Close closes the connection. It should be call deferred right after the creation of the pinger
Close()
}
......@@ -50,6 +61,7 @@ type _pinger struct {
done chan bool
}
//NewPinger create a new Pinger with given addresses
func NewPinger(ctx context.Context, addrs ...string) (Pinger, error) {
p, err := newPinger(ctx)
if err != nil {
......@@ -82,6 +94,7 @@ func newPinger(ctx context.Context) (*_pinger, error) {
return p, nil
}
// deprecated
func (*_pinger) Privileged() bool {
return true
}
......
......@@ -24,7 +24,7 @@ type Statistics struct {
Addr string
// Rtts is the last 10 round-trip times sent via this pinger.
// 0 means nothing was received
// 0 means timeout
Rtts []time.Duration
// MinRtt is the minimum round-trip time sent via this pinger.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment