ICMP Ping/ICMPPing.py
def checksum(string):
    """Fetch string and calculate the checksum.

    This function is copied from sample code file.

    Args:
        :param string: A string of the time in seconds since the epoch.

    Returns:
        :return: The value of checksum (integer type).
    """
    csum = 0
    count_to = (len(string) // 2) * 2
    count = 0
    while count < count_to:
        this_val = string[count + 1] * 256 + string[count]
        csum = csum + this_val
        csum = csum & 0xffffffff
        count = count + 2
    if count_to < len(string):
        csum = csum + string[len(string) - 1]
        csum = csum & 0xffffffff
    csum = (csum >> 16) + (csum & 0xffff)
    csum = csum + (csum >> 16)
    answer = ~csum
    answer = answer & 0xffff
    answer = answer >> 8 | (answer << 8 & 0xff00)
    return answer
Fetch string and calculate the checksum.

    This function is copied from sample code file.

    Args:
        :param string: A string of the time in seconds since the epoch.

    Returns:
        :return: The value of checksum (integer type).
    
Fetch string and calculate the checksum.
This function is copied from sample code file.
Fetch string and calculate the checksum . This function is copied from sample code file .
def checksum(string):
    csum = 0
    count_to = (len(string) // 2) * 2
    count = 0
    while count < count_to:
        this_val = string[count + 1] * 256 + string[count]
        csum = csum + this_val
        csum = csum & 0xffffffff
        count = count + 2
    if count_to < len(string):
        csum = csum + string[len(string) - 1]
        csum = csum & 0xffffffff
    csum = (csum >> 16) + (csum & 0xffff)
    csum = csum + (csum >> 16)
    answer = ~csum
    answer = answer & 0xffff
    answer = answer >> 8 | (answer << 8 & 0xff00)
    return answer
def checksum ( string ) : csum = 0 count_to = ( len ( string ) // 2 ) * 2 count = 0 while count < count_to : this_val = string [ count + 1 ] * 256 + string [ count ] csum = csum + this_val csum = csum & 0xffffffff count = count + 2 if count_to < len ( string ) : csum = csum + string [ len ( string ) - 1 ] csum = csum & 0xffffffff csum = ( csum >> 16 ) + ( csum & 0xffff ) csum = csum + ( csum >> 16 ) answer = ~ csum answer = answer & 0xffff answer = answer >> 8 | ( answer << 8 & 0xff00 ) return answer
Fetch string and calculate the checksum.
Fetch string and calculate the checksum .
"""Fetch string and calculate the checksum.

    This function is copied from sample code file.

    Args:
        :param string: A string of the time in seconds since the epoch.

    Returns:
        :return: The value of checksum (integer type).
    """
:return: The value of checksum (integer type).
: return : The value of checksum ( integer type ) .
string
param string: A string of the time in seconds since the epoch.
param string : A string of the time in seconds since the epoch .