Add size flag to demo pinger

Adds a command line flag to the demo pinger which lets the user set the
the size of the ICMP payload. This is useful for testing. The default is
set at 16 which is the default for an unconfigured pinger.

Signed-off-by: Charlie Jonas <charlie@charliejonas.co.uk>
This commit is contained in:
Charlie Jonas
2021-02-09 18:54:19 +00:00
parent df22d52de1
commit 54fa5d1e4a

View File

@@ -31,12 +31,16 @@ Examples:
# Send a privileged raw ICMP ping
sudo ping --privileged www.google.com
# Send ICMP messages with a 100-byte payload
ping -s 100 1.1.1.1
`
func main() {
timeout := flag.Duration("t", time.Second*100000, "")
interval := flag.Duration("i", time.Second, "")
count := flag.Int("c", -1, "")
size := flag.Int("s", 16, "")
privileged := flag.Bool("privileged", false, "")
flag.Usage = func() {
fmt.Print(usage)
@@ -81,6 +85,7 @@ func main() {
}
pinger.Count = *count
pinger.Size = *size
pinger.Interval = *interval
pinger.Timeout = *timeout
pinger.SetPrivileged(*privileged)