#!/usr/bin/python
import re, sys

RECEIVED = re.compile('.+ received REQUEST_RESPONSE from (?P<id>\d+)@/(?P<addr>.+)')
SENT = re.compile('.+ sending (?P<verb>.+) version (?P<version>\d) to (?P<id>\d+)@/(?P<addr>.+)')

target = '192.168.136.234'

sent = {}
unknown = []
past = False

for line in open(sys.argv[1]):
    m = SENT.match(line)
    if m:
        d = m.groupdict()
        if not past and d['addr'] == target and d['verb'] != 'REQUEST_RESPONSE' and not d['verb'].startswith('GOSSIP'):
            sent[d['id']] = line
        continue

    m = RECEIVED.match(line)
    if m:
        d = m.groupdict()
        if d['addr'] == target:
            if d['id'] == '3280':
                past = True
            try:
                sent_line = sent[d['id']]
            except KeyError:
                # print "Response on message not sent", m.groupdict()['id']
                unknown.append(d['id'])
                continue

            del sent[d['id']]
            print sent_line, line

print "Not acked:", sent
# print "Minus unknown or out of order:", set(set(sent) - set(unknown))