0

Could you tell me please, get more detailed information about the ICMP packet? Right now I'm using some code construction:

import dpkt

with open('icmp_yes.pcap', 'rb') as file:
    pcap_reader = dpkt.pcap.Reader(file)
    for timestamp, packet_data in pcap_reader:
        eth = dpkt.ethernet.Ethernet(packet_data)
        if isinstance(eth.data, dpkt.ip.IP):
            ip = eth.data
            if isinstance(ip.data, dpkt.icmp.ICMP):
                icmp = ip.data
                if icmp.type == 8 and icmp.code == 0:
                    print(f'Type: {icmp.type}, Code: {icmp.code}, Data: {icmp.data}')

I found in the documentation that one can use the parameter unpack.

and I get the following information:

<bound method ICMP.unpack of ICMP(sum=49444, data=Echo(id=6, seq=1, data=b'\x98K\xefd\x00\x00\x00\x00\xebP\x05\x00\x00\x00\x00\x00\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./01234567'))>

I see that there is data about seq

But how would I get information only about seq, I can not understand.

Alex Rebell
  • 465
  • 3
  • 15

0 Answers0