goping

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoPinger

type GoPinger struct{} //

func (GoPinger) Ping

func (p GoPinger) Ping(request *PingRequest, response *PingResponse, seq int)

Start listening for icmp packets. Should be root user. One socket will be opened for each ping worker. This way we can parallelizing the work. But every socket will receive every replies We have to search for the right packet (Id:request.Number seq: seq) before returning that to a channel And we have to start a go routine to quickly read the overhead packets and find the right one

type LinuxPinger

type LinuxPinger struct{}

Pinger implementations goes here Defines the linux pinger. this should implement a ping using the SO ping command It should implement the Pinger interface to be called by the main goping

func (LinuxPinger) Ping

func (p LinuxPinger) Ping(request *PingRequest, response *PingResponse, seq int)

type PingRequest

type PingRequest struct {
	//Attributes controlled  outside this package, unless it is created inside by the Ping function
	To        string            //FQDN or IP of the host to be pinged
	Timeout   float64           //Timeout in seconds
	Payload   float64           //Timeout in seconds
	Tos       uint              //Timeout in seconds
	MaxPings  int               //Max Number of pings that this request should do
	MinWait   float64           //The minimum in seconds time a ping should wait before do another ping
	UserMap   map[string]string //Store user defined metrics
	Percentil int               //Percentil to be used in the Summary
	// contains filtered or unexported fields
}

Struct used to hold the options of a ping. It is sent to the PingWithPingRequest... methods

type PingResponse

type PingResponse struct {
	Rtt   float64   //Saves the round trip time from the ping in ms. should be 0 in case of error
	Error error     //nil if the ping succeeded, An error string otherwise
	When  time.Time //Time when the ping was received
	// contains filtered or unexported fields
}

Struct that holds each ping response status

type PingSummary

type PingSummary struct {
	PingsSent     int     //Ammount of ping commands sent to destination
	PingsReceived int     //Amount of successful pings returned
	PacketLoss    float64 //Percentage of Failed Pings related to sent Pings
	PacketSuccess float64 //Percentage of sucess Pings related to sent Pings
	RttAvg        float64 //Return the average RTT of all PingsReceived
	RttMax        float64 //Return the maximum RTT of all PingsReceived
	RttMin        float64 //Return the minimum RTT of all PingsReceived
	RttPerc       float64 //Return the xth percentil RTT. tha xth is received in the PingRequest object
	RttAvgPerc    float64 //Return the average RTT of all PingsReceived cutting values outside the xth percentil
	RttMaxPerc    float64 //Return the maximum RTT of all PingsReceived cutting values outside the xth percentil
	RttMinPerc    float64 //Return the minimum RTT of all PingsReceived cutting values outside the xth percentil
}

Struct that holds the summary of the PingResponse objects

type Pinger

type Pinger interface {
	Ping(*PingRequest, *PingResponse, int)
}

Defines the interface for a pinger PingResponse should contain the Rtt, the error object if any, otherwise nil, the time.Now() value in the When attribute

type Pong

type Pong struct {
	Request   *PingRequest    //The user request received for internal use only
	Responses []*PingResponse //All the responses received
	Summary   *PingSummary    //The summary of all responses
	Error     error           //nil if success, error message if failed
	//Channel to receive the result as a Pong object. Take care with the circular reference on Pong->PingRequest
	Done chan bool //Channel where the Pong (Response) will be passed for the user
}

Struct that control the lifecycle of a Request, it holds the Request itself and all of it PingResponses. This struct is mainly used for communication between channels and as the output for a user. Finally it holds the PingSummary that summarizes the PingResponses object

func Ping

func Ping(request *PingRequest) *Pong

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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