def parse_header(line):
    """Parse output of tcpdump of pcap file, extract:
        time
        date
        ethernet_type
        protocol
        source ip
        source port (if it exists)
        destination ip
        destination port (if it exists)
        length of the data
        """
    ret_dict = {}
    h = line.split()
    date = h[0]
    time = h[1]
    ret_dict['raw_header'] = line
    ret_dict['date'] = date
    ret_dict['time'] = time
    src_a = h[3].split(".", 3)
    if "." in src_a[-1]:
        port_a = src_a[-1].split('.')
        ret_dict['src_port'] = port_a[-1]
        ret_dict['src_ip'] = ".".join(h[3].split('.')[:-1])
    else:
        ret_dict['src_ip'] = h[3]
    dest_a = h[5].split(".", 3)
    if "." in dest_a[-1]:
        port_a = dest_a[-1].split('.')
        ret_dict['dest_port'] = port_a[-1].split(":")[0]
        ret_dict['dest_ip'] = ".".join(h[5].split('.')[:-1])
    else:
        ret_dict['dest_ip'] = h[5].split(":")[0]
    ret_dict['protocol'] = h[6]
    ret_dict['ethernet_type'] = h[2]
    try:
        ret_dict['length'] = int(h[-1])
    except Exception as e:
        print("failed to get length because: {0}, setting it to 0".format(str(e)))
        ret_dict['length'] = 0
    if h[2] == 'IP':
        #do something meaningful
        pass
    else:
        pass
        #do something else
    ret_dict['tool'] = "tcpdump_hex_parser"
    return ret_dict