Is there any encapsulation software for constructing network protocol header?
You see my code, I can use struct.pack()
to construct a ICMP packet.
import socket
import struct
rawsocket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname('icmp'))
packet = struct.pack('!BBHHH13s', 8, 0, 0, 1, 0, b'qasdssdehello')
chksum = checksum(packet)
but, I think it is complicated and difficult to use, is there any open source code of encapsulation struct
? so I can construct a protocol packet easily.