ping

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProtocolIPv4ICMP is IANA ICMP IPv4
	ProtocolIPv4ICMP = 1
	// ProtocolIPv6ICMP is IANA ICMP IPv6
	ProtocolIPv6ICMP = 58
)

Variables

View Source
var MacDeviceMap map[string]string

Functions

func TryArping added in v0.0.9

func TryArping(target string) (mac, device string, err error)

Types

type Ping

type Ping struct {
	// contains filtered or unexported fields
}

Ping represents ping

func New

func New(host string) (*Ping, error)

New constructs ping object

func (*Ping) Run

func (p *Ping) Run() (chan Response, error)

Run sends the ICMP message to destination / target

func (*Ping) RunWithContext

func (p *Ping) RunWithContext(ctx context.Context) (chan Response, error)

RunWithContext sends the ICMP message to destination / target with context

func (*Ping) SetCount

func (p *Ping) SetCount(c int)

SetCount sets the count packets

func (*Ping) SetForceV4

func (p *Ping) SetForceV4()

SetForceV4 sets force v4

func (*Ping) SetForceV6

func (p *Ping) SetForceV6()

SetForceV6 sets force v6

func (*Ping) SetInterval

func (p *Ping) SetInterval(i string) error

SetInterval sets wait interval between sending each packet

func (*Ping) SetPacketSize

func (p *Ping) SetPacketSize(s int)

SetPacketSize sets the ICMP packet size

func (*Ping) SetPrivilegedICMP

func (p *Ping) SetPrivilegedICMP(i bool)

SetPrivilegedICMP sets privileged raw ICMP or non-privileged datagram-oriented ICMP

func (*Ping) SetSrcIPAddr

func (p *Ping) SetSrcIPAddr(addr string)

SetSrcIPAddr sets the source ip address

func (*Ping) SetTOS

func (p *Ping) SetTOS(t int) error

SetTOS sets type of service for each echo request packet

func (*Ping) SetTTL

func (p *Ping) SetTTL(t int)

SetTTL sets the IPv4 packet TTL or IPv6 hop-limit for ICMP request packets

func (*Ping) SetTimeout

func (p *Ping) SetTimeout(i string) error

SetTimeout sets wait time for a reply for each packet sent

type Response

type Response struct {
	RTT  float64
	Size int
	TTL  int
	Seq  int
	Addr string
	If   string
	Err  error
}

Response represent ping response

Jump to

Keyboard shortcuts

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