'outstream is the stream to write the PCAP trace to.
Ethernet addresses have to be faked, and it can be convenient to
fake IP and TCP addresses as well.  Thus, you can specify local_addrs
or remote_addrs.  These are tuples of (EthAddr, IPAddr, TCPPort).
Any item that is None gets a default value.'

def __init__(self, outstream, socket=None, flush=False, local_addrs=(None, None, None), remote_addrs=(None, None, None)):

    self._out = outstream
    self._flush = flush
    if (socket is not None):
        remote = socket.getpeername()
        local = socket.getsockname()
    else:
        remote = ('1.1.1.1', 1)
        local = ('0.0.0.0', 0)
    def create_packet(e1, e2, i1, i2, t1, t2):
        e = pkt.ethernet(src=e1, dst=e2, type=pkt.ethernet.IP_TYPE)
        i = pkt.ipv4(srcip=i1, dstip=i2, protocol=pkt.ipv4.TCP_PROTOCOL)
        t = pkt.tcp(srcport=t1, dstport=t2, off=5, win=1)
        t.ACK = True
        i.payload = t
        e.payload = i
        return e
    self._c_to_s = create_packet((local_addrs[0] or EthAddr(('\x02' + ('\x00' * 5)))), (remote_addrs[0] or EthAddr(('\x02' + ('\x11' * 5)))), (local_addrs[1] or IPAddr(local[0])), (remote_addrs[1] or IPAddr(remote[0])), (local_addrs[2] or local[1]), (remote_addrs[2] or remote[1]))
    self._s_to_c = create_packet((remote_addrs[0] or EthAddr(('\x02' + ('\x11' * 5)))), (local_addrs[0] or EthAddr(('\x02' + ('\x00' * 5)))), (remote_addrs[1] or IPAddr(remote[0])), (local_addrs[1] or IPAddr(local[0])), (remote_addrs[2] or remote[1]), (local_addrs[2] or local[1]))
    outstream.write(pack('IHHiIII', 2712847316, 2, 4, time.timezone, 0, 2147483647, 1))
