https://github.com/wisdomatom/go-mtr
golang implementation of mtr
https://github.com/wisdomatom/go-mtr
Last synced: 5 months ago
JSON representation
golang implementation of mtr
- Host: GitHub
- URL: https://github.com/wisdomatom/go-mtr
- Owner: wisdomatom
- License: apache-2.0
- Created: 2023-03-14T03:07:50.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-25T03:55:23.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T02:11:08.363Z (almost 2 years ago)
- Language: Go
- Size: 93.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Mtr
Go implementation of mtr.
mtr combines the functionality of the 'traceroute' and 'ping' programs in a single network diagnostic tool.
As mtr starts, it investigates the network connection between the host mtr runs on and a user-specified destination host. After it determines the address of each network hop between the machines, it sends a sequence of ICMP ECHO requests to each one to determine the quality of the link to each machine. As it does this, it prints running statistics about each machine.
## Getting started
- command use case
```
cd ./cmd
go run root.go --help
```
- code use case
```
package main
import (
"fmt"
"github.com/wisdomatom/go-mtr"
"time"
)
func main() {
tracer, err := go_mtr.NewTrace(go_mtr.Config{
ICMP: true,
UDP: false,
MaxUnReply: 8,
NextHopWait: time.Millisecond * 200,
})
if err != nil {
panic(err)
}
t, err := go_mtr.GetTrace(&go_mtr.Trace{
SrcAddr: go_mtr.GetOutbondIP(),
DstAddr: "8.8.8.8",
SrcPort: 65533,
DstPort: 65535,
MaxTTL: 30,
Retry: 2,
})
if err != nil {
panic(err)
}
res := tracer.BatchTrace([]go_mtr.Trace{*t}, 1)
for _, r := range res {
fmt.Println(r.Marshal())
fmt.Println(r.MarshalAggregate())
}
}
```