Developing lightweight computation at the DSG edge

Commit 3d295adf authored by Cameron Sparr's avatar Cameron Sparr
Browse files

README typos

parent 3535a0e9
...@@ -7,36 +7,37 @@ ICMP Ping library for Go, inspired by ...@@ -7,36 +7,37 @@ ICMP Ping library for Go, inspired by
Here is a very simple example that sends & receives 3 packets: Here is a very simple example that sends & receives 3 packets:
```go ```go
pinger, err := ping.NewPinger("www.google.com") pinger, err := ping.NewPinger("www.google.com")
if err != nil { if err != nil {
panic(err) panic(err)
} }
pinger.Count = 3 pinger.Count = 3
pinger.Run() // blocks until finished pinger.Run() // blocks until finished
stats := pinger.Statistics() // get send/receive/rtt stats stats := pinger.Statistics() // get send/receive/rtt stats
``` ```
Here is an example that emulates the unix ping command: Here is an example that emulates the unix ping command:
```go ```go
pinger, err := ping.NewPinger("www.google.com") pinger, err := ping.NewPinger("www.google.com")
if err != nil { if err != nil {
fmt.Printf("ERROR: %s\n", err.Error()) panic(err)
return }
}
pinger.OnRecv = func(pkt *ping.Packet) { pinger.OnRecv = func(pkt *ping.Packet) {
fmt.Printf("%d bytes from %s: icmp_seq=%d time=%v\n", fmt.Printf("%d bytes from %s: icmp_seq=%d time=%v\n",
pkt.Nbytes, pkt.IPAddr, pkt.Seq, pkt.Rtt) pkt.Nbytes, pkt.IPAddr, pkt.Seq, pkt.Rtt)
} }
pinger.OnFinish = func(stats *ping.Statistics) { pinger.OnFinish = func(stats *ping.Statistics) {
fmt.Printf("\n--- %s ping statistics ---\n", stats.Addr) fmt.Printf("\n--- %s ping statistics ---\n", stats.Addr)
fmt.Printf("%d packets transmitted, %d packets received, %v%% packet loss\n", fmt.Printf("%d packets transmitted, %d packets received, %v%% packet loss\n",
stats.PacketsSent, stats.PacketsRecv, stats.PacketLoss) stats.PacketsSent, stats.PacketsRecv, stats.PacketLoss)
fmt.Printf("round-trip min/avg/max/stddev = %v/%v/%v/%v\n", fmt.Printf("round-trip min/avg/max/stddev = %v/%v/%v/%v\n",
stats.MinRtt, stats.AvgRtt, stats.MaxRtt, stats.StdDevRtt) stats.MinRtt, stats.AvgRtt, stats.MaxRtt, stats.StdDevRtt)
} }
fmt.Printf("PING %s (%s):\n", pinger.Addr(), pinger.IPAddr())
pinger.Run() fmt.Printf("PING %s (%s):\n", pinger.Addr(), pinger.IPAddr())
pinger.Run()
``` ```
It sends ICMP packet(s) and waits for a response. If it receives a response, It sends ICMP packet(s) and waits for a response. If it receives a response,
...@@ -44,7 +45,7 @@ it calls the "receive" callback. When it's finished, it calls the "finish" ...@@ -44,7 +45,7 @@ it calls the "receive" callback. When it's finished, it calls the "finish"
callback. callback.
For a full ping example, see For a full ping example, see
[cmd/ping/ping.go"](https://github.com/sparrc/go-ping/blob/master/cmd/ping/ping.go) [cmd/ping/ping.go](https://github.com/sparrc/go-ping/blob/master/cmd/ping/ping.go)
## Installation: ## Installation:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment