def get_ip_to_packet_count(stream):
    """
    Returns a dictionary relating IP addresses to the
    number of times they are used as a source or
    destination address in the provided stream.
    """
    ip_counts = {}
    for packet in stream:
        src = packet.src_addr
        dst = packet.dst_addr
        ip_counts[src] = ip_counts[src] + 1 if src in ip_counts else 1
        ip_counts[dst] = ip_counts[dst] + 1 if dst in ip_counts else 1
    return ip_counts