I have this Python function which unpacks ethernet frame:
def ethernet_frame(data):
ipheader = struct.unpack('!6s6sH', data[0:14])
dest_mac = binascii.hexlify(ipheader[0])
src_mac = binascii.hexlify(ipheader[1])
proto = ""
protoType = ipheader[2]
nextProto = hex(protoType)
print(nextProto)
if(nextProto == '0x800'):
proto = 'IPV4'
elif(nextProto == '0x86dd'):
proto = 'IPV6'
print(nextProto)
return dest_mac, src_mac, proto, data[14:]
I was expecting to get 0x800 for IPV4 or 0x86dd for IPV6. But after unpacking the frame I got 0xc0a8. Can someone explain why I'm getting this unexpected data? and how to fix it to get correct data?
from Python - Not Expecting Data by Unpacking Ethernet Frame Getting 0xc0a8 on Type Expecting 0x800
No comments:
Post a Comment