//htonl(0x7F000001); // 127.0.0.1
        public void Append(IPEndPoint source, IPEndPoint destination, ProtocolType protocol, byte[] payload, DateTime?timestamp = null)
        {
            PcapItemHeader packetHeader;
            Ethernet       packetEthernet;
            IPv4           packetIP;

            byte[] sourceBytes, destinationBytes;

            byte[] payloadItemHeader, payloadEthernet, payloadIP, payloadTransport, payloadData;
            int    index;

            switch (protocol)
            {
            case ProtocolType.Udp:
                UDP packetUDP;
                packetUDP        = new UDP((UInt16)source.Port, (UInt16)destination.Port, (UInt16)payload.Length);
                payloadTransport = packetUDP.GetBytes();
                break;

            case ProtocolType.Tcp:
                TCP    packetTCP;
                UInt16 connection1, connection2;

                UInt64 seqAck;
                UInt32 seq, ack;

                connection1 = tcpConnectionId(source, destination);
                connection2 = tcpConnectionId(destination, source);
                if (tcpWindows.ContainsKey(connection1))
                {
                    seqAck = tcpWindows[connection1];
                    seq    = (UInt32)(seqAck >> 32);
                    ack    = (UInt32)seqAck;
                }
                else
                {
                    seq    = 1;
                    ack    = 1;
                    seqAck = ((UInt64)seq << 32) | ack;
                    tcpWindows.Add(connection1, seqAck);
                }

                packetTCP = new TCP((UInt16)source.Port, (UInt16)destination.Port, seq, ack);

                seq   += (UInt32)payload.Length;
                seqAck = ((UInt64)seq << 32) | ack;
                tcpWindows[connection1] = seqAck;

                if (tcpWindows.ContainsKey(connection2))
                {
                    seqAck = tcpWindows[connection2];
                    seq    = (UInt32)(seqAck >> 32);
                    ack    = (UInt32)payload.Length;

                    seqAck = ((UInt64)seq << 32) | ack;
                    tcpWindows[connection2] = seqAck;
                }
                else
                {
                    seq = 1;
                    ack = (UInt32)payload.Length;

                    seqAck = ((UInt64)seq << 32) | ack;
                    tcpWindows.Add(connection2, seqAck);
                }

                payloadTransport = packetTCP.GetBytes();
                break;

            case ProtocolType.IP:
                payloadTransport = new byte[] { };
                break;

            default:
                throw new System.ArgumentException("This protocol is not supported", "protocol");
            }


            /* ipv4 */
            packetIP  = new IPv4(source.Address, destination.Address, protocol, (UInt16)(payloadTransport.Length + payload.Length));
            payloadIP = packetIP.GetBytes();

            /* ethernet */
            sourceBytes      = source.Address.GetAddressBytes();
            destinationBytes = destination.Address.GetAddressBytes();
            packetEthernet   = new Ethernet(new byte[3] {
                sourceBytes[1], sourceBytes[2], sourceBytes[3]
            }, new byte[3] {
                destinationBytes[1], destinationBytes[2], destinationBytes[3]
            });
            payloadEthernet = packetEthernet.GetBytes();

            /* pcap packet header */
            if (timestamp == null)
            {
                timestamp = DateTime.UtcNow;
            }
            packetHeader      = new PcapItemHeader((DateTime)timestamp, (UInt32)(payloadEthernet.Length + payloadIP.Length + payloadTransport.Length + payload.Length));
            payloadItemHeader = packetHeader.GetBytes();

            payloadData = new byte[payloadItemHeader.Length + payloadEthernet.Length + payloadIP.Length + payloadTransport.Length + payload.Length];

            index = 0;
            payloadItemHeader.CopyTo(payloadData, index);
            index += payloadItemHeader.Length;

            payloadEthernet.CopyTo(payloadData, index);
            index += payloadEthernet.Length;

            payloadIP.CopyTo(payloadData, index);
            index += payloadIP.Length;

            payloadTransport.CopyTo(payloadData, index);
            index += payloadTransport.Length;

            payload.CopyTo(payloadData, index);
            index += payload.Length;

            if (payloadData.Length != packetHeader.length + 16)
            {
                throw new Exception("Error of PCap. Possible bug");
            }

            content.Write(payloadData, 0, payloadData.Length);
        }