由于部分网络截断icmp data故ttl改为在seq读取

This commit is contained in:
tsosunchia
2024-04-17 19:34:01 +08:00
parent d1a72458a6
commit 7ae4eb13c9
2 changed files with 6 additions and 4 deletions

View File

@@ -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)

View File

@@ -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)