diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 5b9065ec..d93aa25c 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -150,7 +150,7 @@ func (t *ICMPTracer) listenICMP() { } continue } - ttl := int(msg.Msg[36]) + ttl := int64(binary.BigEndian.Uint16(msg.Msg[34:36])) packet_id := strconv.FormatInt(int64(binary.BigEndian.Uint16(msg.Msg[32:34])), 2) if process_id, _, err := reverseID(packet_id); err == nil { if process_id == int64(os.Getpid()&0x7f) { @@ -271,7 +271,8 @@ func (t *ICMPTracer) send(ttl int) error { id := gernerateID(0) // log.Println("发送的", id) - data := []byte{byte(ttl)} + //data := []byte{byte(ttl)} + data := []byte{byte(0)} data = append(data, bytes.Repeat([]byte{1}, t.Config.PktSize-5)...) data = append(data, 0x00, 0x00, 0x4f, 0xff) diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index ecb4a705..f46be27e 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -171,7 +171,7 @@ func (t *ICMPTracerv6) listenICMP() { } } - ttl := int(msg.Msg[56]) + ttl := int64(binary.BigEndian.Uint16(msg.Msg[54:56])) packet_id := strconv.FormatInt(int64(binary.BigEndian.Uint16(msg.Msg[52:54])), 2) if process_id, _, err := reverseID(packet_id); err == nil { if process_id == int64(os.Getpid()&0x7f) { @@ -264,7 +264,8 @@ func (t *ICMPTracerv6) send(ttl int) error { //id := gernerateID(ttl) id := gernerateID(0) - data := []byte{byte(ttl)} + //data := []byte{byte(ttl)} + data := []byte{byte(0)} data = append(data, bytes.Repeat([]byte{1}, t.Config.PktSize-5)...) data = append(data, 0x00, 0x00, 0x4f, 0xff)