Ping library for Golang with multi-host support

Overview

pingo Go Reference Go

Fast and lightweight ping library for Golang with multi-host support.

Features

  • ICMP sockets:
    • UDP port 0 means "let the kernel pick a free number"
    • ICMP Echo Message ID is UDP port, so multiple instances of Pinger do not collide
  • Support for custom setsockopt(2) and sendmsg(2) options
  • Support for Linux kernel RX and TX timestamps with SO_TIMESTAMPING
  • IPv4 and IPv6 support
  • ICMP sequence numbers manager (no random): O(1) time, 256kB of memory
  • Context awareness

Requirements

  • go >= 1.16
  • Linux kernel >= 3.11

You may need to adjust ping_group_range sysfs to allow the creation of ICMP sockets:

$ echo 0 2147483647 > /proc/sys/net/ipv4/ping_group_range

Example

Here is a simple traceroute(8) implementation:

dst := net.IPv4(8, 8, 8, 8)

p, err := New(nil)
if err != nil {
	fmt.Println(err)
	return
}
defer p.Close()

ctx, cancel := context.WithCancel(context.Background())
var g errgroup.Group
g.Go(func() error {
	return p.Listen(ctx)
})
defer func() {
	cancel()
	if err := g.Wait(); !errors.Is(err, context.Canceled) {
		fmt.Println(err)
	}
}()

for ttl := uint8(1); ttl < math.MaxUint8-1; ttl++ {
	fmt.Printf("%3d: ", ttl)
	r, err := p.PingContextTimeout(ctx, dst, 1*time.Second, TTL(ttl))
	if errors.Is(err, context.DeadlineExceeded) {
		// no answer from current hop
		fmt.Println("...")
		continue
	}
	from := dst
	switch err := err.(type) {
	case nil:
	case TimeExceededError:
		from = err.From()
	default:
		fmt.Println(err)
		return
	}
	fmt.Printf("%-15s %s\n", from, r.RTT)
	if err == nil {
		return
	}
}
fmt.Println("TTL maxed out")
Issues
  • Add support for custom payload

    Add support for custom payload

    Consider adding support for sending custom payload in ICMP Echo Request packets. It can be used to increase the number of hosts which can be pinged simultaneously.

    opened by mitinarseny 1
Releases(v1.1.2)
Owner
Arseny Mitin
Software Engineer | HSE Computer Security
Arseny Mitin
[FORK] ICMP Ping library for Go

forked from go-ping/ping go get -u github.com/gandaldf/ping go-ping A simple but powerful ICMP echo (ping) library for Go, inspired by go-fastping. He

Diego Parisi 0 Oct 21, 2021
Minecraft Server List Ping library written in Go

minequery Minecraft Server List Ping library written in Go. Features Modern Mine

Altea 9 Jul 31, 2022
A little ping pong service that implements rate limiting with golang

Fred the Guardian Introduction Writing a little ping pong service that implements rate limiting with the programming language golang. Requirements Web

null 0 Jan 2, 2022
ping 和 http get 请求探测 适配 nightingale

n9e-probe 功能 ping 和 http get 请求探测 适配 nightingale 指标 ping metric 说明 ping.latency ping 请求的延迟,单位是毫秒。-1 表示 ping 不通 tag 说明 ip 探测的目标 ip region 如果配置了,则插入 reg

Shanghai Edu 23 May 31, 2022
🚥 Yet another pinger: A high-performance ICMP ping implementation build on top of BPF technology.

yap Yet-Another-Pinger: A high-performance ICMP ping implementation build on top of BPF technology. yap uses the gopacket library to receive and handl

dongdong 39 Jun 21, 2022
DNS Ping: to check packet loss and latency issues with DNS servers

DNSping DNS Ping checks packet loss and latency issues with DNS servers Installation If you have golang, easiest install is go get -u fortio.org/dnspi

Fortio (Φορτίο) 60 Aug 5, 2022
Prometheus exporter for ping metrics such as RTT, packet loss, and jitter to any number of hosts.

ping_exporter Command ping_exporter provides a Prometheus exporter for ping metrics such as RTT, packet loss, and jitter to any number of hosts. Usage

Beard Slayer 6 Jun 29, 2022
Implementation of Minecraft protocols : ping, query and icon.

mcutils - Implementation of Minecraft protocols in Go Informations General All protocols are implemented in Go, without any external dependency. All p

null 8 Aug 8, 2022
PinGo is a standalone and feature-rich tool for common IP-based reachability checking tasks. Ping or Trace and Observe in real-time the statistics.

pingo As a network champion from designing and implementing to troubleshooting large scale networks - I know that is usually not easy for administrato

Jerome Amon 2 Jul 19, 2022
HCio is a straightforward way to ping Healthchecks.io checks directly from a Go application

HCio HCio is a straightforward way to ping Healthchecks.io checks directly from a Go application. Getting Started Create a simple Check: check := hcio

Daniel Sage 1 Dec 20, 2021
Vmessping - A ping prober for vmess:// links in common seen formats

VMessPing A ping prober for vmess:// links in common seen formats. vmessping sup

null 1 Jan 9, 2022
QUIC-PING: A UDP client for sending QUIC PINGs.

QUIC-PING A UDP client for sending "QUIC PING"s. What is a QUIC PING? A QUIC Initial packet with random payload and the version 0xbabababa to force Ve

null 3 Jul 5, 2022
EasyAgent is an infrastructure component, applied to manage the life-cycle of services on the remote host.

Easyagent English | 中文 介绍 easyagent是在袋鼠云内部广泛使用的基础架构组件,最佳应用场景包括ELK体系beats等数据采集器的管控和配置管理、数栈体系自动化部署等 基本原理 easyagent主要有sidecar和server两个组件,sidecar部署在主机端,si

袋鼠云 22 Aug 17, 2022
LazySSH is an SSH server that acts as a jump host only, and dynamically starts temporary virtual machines.

LazySSH is an SSH server that acts as a jump host only, and dynamically starts temporary virtual machines. If you find yourself briefly starti

Stéphan Kochen 473 Jun 12, 2022
Receive phone calls from anybody on the Web. Or host a telephony server yourself.

WebCall WebRTC Telephony Server Browser based telephony over E2E-encrypted P2P-links with very high audio quality. WebCall is lightweight and easy to

Timur Mehrvarz 101 Aug 3, 2022
⚡ 🖥️ 👾 Host your own Lightning Address on LND

⚡ ??️ ?? Host your own Lightning Address on LND Lighting Wallets like BlueWallet, Blixt and many more allow us to send sats to Lighting Addresses like

Heebs 8 Jun 12, 2022
Proxy your Go Module`s Import Path from your own domain to a public host (e.g. github.com).

Go Modules Remote Import Path Proxy Proxy your Go Module`s Import Path from your own domain to a public host (e.g. github.com). For example Uber (buil

Stefan Kürzeder 2 Nov 2, 2021
The rest api that can manage the iptables rules of the remote host

fiewall-api firewall api是基于firewalld来远程管理iptables规则的rest-api,无需部署agent Features 指定一个主机ip,让这个主机上的iptables增加一个规则 处理单个IP或CIDR范围(xx.xx.xx.xx/mask,mac,inte

seal 0 Mar 24, 2022
apache dubbo gateway,L7 proxy,virtual host,k8s ingress controller.

apache dubbo gateway,L7 proxy,virtual host,k8s ingress controller.

null 0 Jul 22, 2022