diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 6e9a44ad..c5bc170c 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -39,6 +39,7 @@ func (t *ICMPTracer) PrintFunc() { if t.AsyncPrinter != nil { t.AsyncPrinter(&t.res) } + // 接收的时候检查一下是不是 3 跳都齐了 if len(t.res.Hops)-1 > ttl { if len(t.res.Hops[ttl]) == t.NumMeasurements { if t.RealtimePrinter != nil { diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index b0a5ea42..3dc26ba0 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -30,7 +30,7 @@ type ICMPTracerv6 struct { } func (t *ICMPTracerv6) PrintFunc() { - // defer t.wg.Done() + defer t.wg.Done() var ttl = t.Config.BeginHop - 1 for { if t.AsyncPrinter != nil { @@ -44,12 +44,12 @@ func (t *ICMPTracerv6) PrintFunc() { t.RealtimePrinter(&t.res, ttl) } ttl++ - if ttl == t.final { + + if ttl == t.final-1 || ttl >= t.MaxHops-1 { return } } } - <-time.After(200 * time.Millisecond) } } @@ -78,6 +78,7 @@ func (t *ICMPTracerv6) Execute() (*Result, error) { t.final = -1 go t.listenICMP() + t.wg.Add(1) go t.PrintFunc() for ttl := t.BeginHop; ttl <= t.MaxHops; ttl++ { t.inflightRequestRWLock.Lock()