import socket
import struct


def init_icmp_socket(port):
    """
    Initializes ICMP socket
    """

    icmp_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)

    timeout = struct.pack("ll", 5, 0)
    icmp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, timeout)

    icmp_socket.bind(("0.0.0.0", port))

    return icmp_socket