Skip to content

Commit

Permalink
由于部分网络截断icmp data故ttl改为在seq读取
Browse files Browse the repository at this point in the history
  • Loading branch information
tsosunchia committed Apr 17, 2024
1 parent d1a7245 commit 7ae4eb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions trace/icmp_ipv4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions trace/icmp_ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 7ae4eb1

Please sign in to comment.