ping

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PacketEvent

type PacketEvent struct {
	IsTimeout bool          `json:"is_timeout"`
	From      string        `json:"from"`
	Seq       int           `json:"seq"`
	Size      int           `json:"size"`
	TTL       int           `json:"ttl"`
	Latency   time.Duration `json:"latency"`
	Message   *icmp.Message `json:"-"`
}

type PacketStatistic

type PacketStatistic struct {
	SendCount     int           `json:"send_count"`
	ReceivedCount int           `json:"received_count"`
	LossedCount   int           `json:"lossed_count"`
	TimeTotal     time.Duration `json:"time_total"`
	TimeMax       time.Duration `json:"time_max"`
	TimeMin       time.Duration `json:"time_min"`
	TimeAvg       time.Duration `json:"time_avg"`
	TimeMdev      time.Duration `json:"time_mdev"`
}

type Pinger

type Pinger struct {
	Host     *net.IPAddr
	Interval time.Duration
	Timeout  time.Duration
	Count    int
	Size     int

	OnEvent func(*PacketEvent, error)
	// contains filtered or unexported fields
}

func New

func New(target string) (*Pinger, error)

func (*Pinger) GetStatistic

func (p *Pinger) GetStatistic() PacketStatistic

func (*Pinger) Start

func (p *Pinger) Start(ctx context.Context)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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