What's mean the 22nd byte in icmp reply message?

Viewed 65

Please see the code below:

What's mean the 22nd byte in icmp reply message, please?

If delete "packet[22] += 8" line will can't receive reply.

// Echo Example
func main() {
    ifce, err := water.New(water.Config{
        DeviceType: water.TUN,
    })
    if err != nil {
        log.Fatal(err)
    }

    log.Printf("Interface Name: %s\n", ifce.Name())

    packet := make([]byte, 2000)
    for {
        // receive Echo request
        n, err := ifce.Read(packet)
        if err != nil {
            log.Fatal(err)
        }

        // prepare Echo reply
        var (
            ip     [4]byte
            packet = packet[:n]
        )

        copy(ip[:], packet[12:16])
        copy(packet[12:16], packet[16:20])
        copy(packet[16:20], ip[:])

        packet[20] = 0
        packet[22] += 8 // Why do this?

        _, err = ifce.Write(packet)
        if err != nil {
            log.Fatal(err)
        }
    }
}

What's mean the 22nd byte in icmp reply message, please?

If delete "packet[22] += 8" line will can't receive reply.


0 Answers
Related