import struct


def dict_from_packet(bytes):
    """ Returns dict of the ICMP header fields from an ICMP packet """
    names = [ "type", "code", "checksum", "id", "sequence" ]
    struct_format = "!BBHHH"
    data = bytes[20:28]
    unpacked_data = struct.unpack(struct_format, data)
    return dict(zip(names, unpacked_data))