Hi, I am not sure if this post belongs here. But I was testing with Raw Socket in python at layer 2. Upon creating an icmp packet, I realized that my packet is being truncated and my icmp header is being shown as a trailer in ethernet layer.
When I open the packet in wireshark, it shows that at ethernet layer, a trailer whose value is Trailer: 0800f4f603090000
This is actually an icmp echo header with type 8 and code 0 . can someone explain what is going on ? Here is the code
----------------------
ICMP_ECHO_REQ = 8 #ping request
remoteHostIP = "8.8.8.8"
sourceip = "0.0.0.0"
socketsender = socket.socket(family=socket.AF_PACKET, type=socket.SOCK_RAW )
socketsender.bind(("eth0",0))
srcmacaddress = "12:38:32:be:4a:66"
dstmacaddress = "12:69:0a:60:d5:2e"
srcmac_packed = struct.pack("!BBBBBB",0x12,0x38,0x32,0xbe,0x4a,0x65)
dstmac_packed = struct.pack("!BBBBBB",0x12,0x69,0x0a,0x60,0xd5,0x2e)
ethertype = struct.pack("!BB",0x8,0x0)
sequencenumber = 0
ipv4_datagram = rawIPV4.IPV4Datagram(sourceip,remoteHostIP,ttl=227, protocol = socket.IPPROTO_ICMP)
ipv4_header = ipv4_datagram.pack()
icmp_datagram = rawICMP.ICMPDatagram (type = ICMP_ECHO_REQ, sequence=sequencenumber)
icmp_header = icmp_datagram.pack()
socketsender.send(dstmac_packed+srcmac_packed+ethertype+ipv4_header+icmp_header)
No comments:
Post a Comment