<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ping(enode, count, destination, interval=None, quiet=False, shell=None):
 """ Perform a ping and parse the result. :param enode: Engine node to communicate with. :type enode: topology.platforms.base.BaseNode :param int count: Number of packets to send. :param str destination: The destination host. :param float interval: The wait interval in seconds between each packet. :param str shell: Shell name to execute commands. If ``None``, use the Engine Node default shell. :rtype: dict :return: The parsed result of the ping command in a dictionary of the form: :: { 'transmitted': 0, 'received': 0, 'errors': 0, 'loss_pc': 0, 'time_ms': 0 } """

    assert count > 0
    assert destination

    addr = ip_address(destination)
    cmd = 'ping'
    if addr.version == 6:
        cmd = 'ping6'

    cmd = [cmd, '-c', str(count), destination]
    if interval is not None:
        assert interval > 0
        cmd.append('-i')
        cmd.append(str(interval))
    if quiet:
        cmd.append('-q')

    ping_raw = enode(' '.join(cmd), shell=shell)
    assert ping_raw

    for line in ping_raw.splitlines():
        m = match(PING_RE, line)
        if m:
            return {
                k: (int(v) if v is not None else 0)
                for k, v in m.groupdict().items()
            }

    raise Exception('Could not parse ping result')