Traceroute/Traceroute.py
def send_one_trace(icmp_socket, dest_addr, port_id, sequence):
    """Build, pack and send the ICMP packet using socket.

    Args:
        :param icmp_socket: the socket which is created from do_three_trace function.
        :param dest_addr: the IP address of the current node.
        :param port_id: current process id.
        :param sequence: the nth times of the current node latency measurement.

    Returns:
        :return: the time when packet is sent.
    """
    # 1. Build ICMP header, start with a 0 checksum.
    icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, 0, port_id, sequence)
    payload_data = struct.pack("!f", time.time())
    # 2. Checksum ICMP packet using given function.
    packet_checksum = checksum(icmp_header + payload_data)
    # 3. Insert checksum into packet.
    icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, packet_checksum, port_id, sequence)
    packet = icmp_header + payload_data
    # 4. Send packet using socket.
    icmp_socket.sendto(packet, (dest_addr, 1))
    # 5. Record time of sending.
    send_time = time.time()
    return send_time
Build, pack and send the ICMP packet using socket.

    Args:
        :param icmp_socket: the socket which is created from do_three_trace function.
        :param dest_addr: the IP address of the current node.
        :param port_id: current process id.
        :param sequence: the nth times of the current node latency measurement.

    Returns:
        :return: the time when packet is sent.
    
Build, pack and send the ICMP packet using socket.
Build pack and send the ICMP packet using socket .
def send_one_trace(icmp_socket, dest_addr, port_id, sequence):
    icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, 0, port_id, sequence)
    payload_data = struct.pack("!f", time.time())
    packet_checksum = checksum(icmp_header + payload_data)
    icmp_header = struct.pack("!bbHHh", ICMP_ECHO_REQUEST, 0, packet_checksum, port_id, sequence)
    packet = icmp_header + payload_data
    icmp_socket.sendto(packet, (dest_addr, 1))
    send_time = time.time()
    return send_time
def send_one_trace ( icmp_socket , dest_addr , port_id , sequence ) : icmp_header = struct . pack ( "!bbHHh" , ICMP_ECHO_REQUEST , 0 , 0 , port_id , sequence ) payload_data = struct . pack ( "!f" , time . time ( ) ) packet_checksum = checksum ( icmp_header + payload_data ) icmp_header = struct . pack ( "!bbHHh" , ICMP_ECHO_REQUEST , 0 , packet_checksum , port_id , sequence ) packet = icmp_header + payload_data icmp_socket . sendto ( packet , ( dest_addr , 1 ) ) send_time = time . time ( ) return send_time
Build, pack and send the ICMP packet using socket.
Build pack and send the ICMP packet using socket .
"""Build, pack and send the ICMP packet using socket.

    Args:
        :param icmp_socket: the socket which is created from do_three_trace function.
        :param dest_addr: the IP address of the current node.
        :param port_id: current process id.
        :param sequence: the nth times of the current node latency measurement.

    Returns:
        :return: the time when packet is sent.
    """ # 1. Build ICMP header, start with a 0 checksum. # 2. Checksum ICMP packet using given function. # 3. Insert checksum into packet. # 4. Send packet using socket. # 5. Record time of sending.
:return: the time when packet is sent.
: return : the time when packet is sent .
icmp_socket
dest_addr
port_id
sequence
param sequence: the nth times of the current node latency measurement.
param sequence : the nth times of the current node latency measurement .