Comprehensive video about str and bytes
Script to get ICMP packet data:
https://gist.github.com/Paulius11/a49d9c8443d7477bb546f85c4a098d9f
Working with TCP/IP protocol stack:
Ethernet Frame Format
eth_header=struct.unpack('!6s6sH', data)
Internet Protocol Header
|
# s char[] bytes
# H (unsigned short) Integer = 2 (standard octets)
# B Integer = 1 (standard octets)
eth_header=struct.unpack('!6s6sH', data)
icmp_type, code, checksum, packet_id, sequence = struct.unpack('!BBHHH', packet[20:28])
https://www.binarytides.com/python-packet-sniffer-code-linux/ -
https://www.bitforestinfo.com/blog/02/15/how-to-write-simple-packet-sniffer.html