Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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).