Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opsnull/kping
Large Scale, High Performance flood ping.
https://github.com/opsnull/kping
afpacket icmp pfring ping rawsocket sendmmsg
Last synced: 3 months ago
JSON representation
Large Scale, High Performance flood ping.
- Host: GitHub
- URL: https://github.com/opsnull/kping
- Owner: opsnull
- License: apache-2.0
- Created: 2017-07-12T16:22:48.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-11T01:58:53.000Z (over 6 years ago)
- Last Synced: 2024-06-20T05:21:21.897Z (7 months ago)
- Topics: afpacket, icmp, pfring, ping, rawsocket, sendmmsg
- Language: Go
- Size: 30.3 KB
- Stars: 18
- Watchers: 5
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kping
Package kping implements large scale & high performance ICMP flood ping.
It can send up to 1024 ICMP packets in one system call (sendmmsg), and provides two methods for receiving packets quickly: batch, afpacket.
See API document on [godoc](https://godoc.org/github.com/opsnull/kping)
Warning: **WORKING IN PROGRESS**
# Example (using af_packet recv mode)
The simplest example:
``` go
// Create a new Pinger
pinger, err := NewPinger("10.0.0.1", 100, 10, 1*time.Minute, 100*time.Millisecond)
if err != nil {
logger.Fatalln(err)
}// Add IP addresses to Pinger
if err := pinger.AddIPs([]string{"114.114.114.114", "8.8.8.8"}); err != nil {
logger.Fatalln(err)
}// Run !
statistics, err : = pinger.Run()
if err != nil {
logger.Fatalln(err)
}// Print result
for ip, statistic := range statistics {
fmt.Printf("%s: %v\n", ip, statistic)
}
```You can customize and optimize the send & receive options based on your system:
``` go
// Create a new Pinger
pinger, err := NewPinger("10.0.0.1", 100, 10, 1*time.Minute, 100*time.Millisecond)
if err != nil {
logger.Fatalln(err)
}// Set send options
if sendOpts, err := SendOptions(1024, 10*1024*1024, 30, 100*time.Second, 20*time.Millsecond); err != nil{
logger.Fatalln(err)
} else if err := pinger.SetOptions(sendOpts); err != nil {
logger.Fatalln(err)
}// Set Recv mode: afpacket | batch
if err := pinger.SetRecvMode("afpacket"); err != nil{
logger.Fatalln(err)
}// Set afpacket recv mode options
if recvOpts, err := AfPacketRecvOptions(2, 128, "eth1", 100*time.Millsecond); err != nil{
logger.Fatalln(err)
} else if err := pinger.SetOptions(recvOpts); err != nil {
logger.Fatalln(err)
}// Add IP addresses to Pinger
if err := pinger.AddIPs([]string{"114.114.114.114", "8.8.8.8"}); err != nil {
logger.Fatalln(err)
}// Run !
statistics, err : = pinger.Run()
if err != nil {
logger.Fatalln(err)
}// Print result
for ip, statistic := range statistics {
fmt.Printf("%s: %v\n", ip, statistic)
}
```## License
Copyright 2017 zhangjun ([email protected])
Apache License 2.0,[LICENSE](LICENSE).