Skip to content

Commit

Permalink
ipv6 trace 正序输出
Browse files Browse the repository at this point in the history
  • Loading branch information
tsosunchia committed Nov 2, 2023
1 parent 9eda2d2 commit f82af5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions trace/icmp_ipv4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions trace/icmp_ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f82af5f

Please sign in to comment.