I have that function that sends icmp echo requests, my problem is when I add timestamp to the packet and then I check with wireshark I see it cannot parse it correctly normally u will see timestamp shown in the packet info maybe I am not doing the timestamp correctly ?
func Request(sockfd int, ip string) (*Icmp, error) {
seqN++
targetIpB := net.ParseIP(ip).To4()
targetIP := &syscall.SockaddrInet4{
Addr: [4]byte{
targetIpB[0], targetIpB[1],
targetIpB[2], targetIpB[3],
},
}
icmp := &Icmp{
id: uint16(rand.Intn(65536)),
typ: EchoRequest,
sqn: uint16(seqN),
}
icmp.data = make([]byte, 8)
binary.BigEndian.PutUint64(icmp.data, uint64(time.Now().UnixNano()))
icmp.checksum = checksum(icmp.Bytes())
if err := syscall.Sendto(sockfd, icmp.Bytes(), 0, targetIP); err != nil {
return nil, err
}
buf := make([]byte, 1024)
n, _, err := syscall.Recvfrom(sockfd, buf, 0)
if err != nil {
return nil, err
}
return FromBytes(buf[20:n]), nil
}