def clk_chksum(icmp_packet):
    """Calculate ICMP packet checksum"""

    packet_len = len(icmp_packet)
    summ = 0
    for i in range(0, packet_len, 2):
        if i + 1 < packet_len:
            # Fold 2 neighbour bytes into a number and add it to the summ
            summ += icmp_packet[i] + (icmp_packet[i + 1] << 8)
        else:
            # If there is an odd number of bytes, fake the second byte
            summ += icmp_packet[i] + 0
    # Add carry bit to the sum
    summ = (summ >> 16) + (summ & 0xffff)
    # Truncate to 16 bits and return the checksum
    return ~summ & 0xffff