def parse_file(filename):
    """ Parses message information from ccnd log files

        filename: path to ccndlog file

    """
    faces = dict()
    sep = ' '
    with open(filename, 'r') as f:
        data = []
        for line in f:
            cols = line.strip().split(sep)
            if line.find('accepted datagram client') > -1:
                face_id = cols[5].replace('id=', '')
                ip = cols[7]
                port = cols[9]
                faces[face_id] = ip, port
                continue
            if line.find('releasing face id') > -1:
                face_id = cols[5]
                if face_id in faces:
                    del faces[face_id]
                continue
            if len(cols) < 6:
                continue
            timestamp = cols[0]
            message_type = cols[3]
            if message_type not in ['interest_from', 'interest_to',
                'content_from', 'content_to', 'interest_dupnonce',
                'interest_expiry']:
                continue
            face_id = cols[4]
            content_name = cols[5]
            nonce = ''
            if message_type in ['interest_from', 'interest_to',
                'interest_dupnonce']:
                last = cols[-1]
                if len(last.split('-')) == 5:
                    nonce = last
            try:
                size = int(cols[6].replace('(', ''))
            except:
                print('interest_expiry without face id!', line)
                continue
            peer = 'localhost'
            if face_id in faces:
                peer, port = faces[face_id]
            data.append((content_name, timestamp, message_type, peer,
                face_id, size, nonce, line))
    return data
