Esempio n. 1
0
        public List <byte[]> CreatePackets <T>(T data)
        {
            ipHeader  = new IP4Head();
            tcpHeader = new TCPHead();
            PacketBody <T> body = new PacketBody <T>(data);

            byte[] allPayload = body.OutputBinary();
            Console.WriteLine(string.Format("allPayload Length: {0}", allPayload.Length));
            byte[][] splitPayload = SplitPayload(allPayload);

            List <byte[]> allPackets = new List <byte[]>();

            foreach (byte[] partPayload in splitPayload)
            {
                List <byte[]> singlePacket = new List <byte[]>();
                singlePacket.Add(ipHeader.OutputBinary());
                singlePacket.Add(tcpHeader.OutputBinary());
                tcpHeader.SequenceNumber++;
                singlePacket.Add(partPayload);
                byte[] completePacket = CombineAll(singlePacket);
                ipHeader.TotalLength = (ushort)completePacket.Length;
                singlePacket[0]      = ipHeader.OutputBinary();
                completePacket       = CombineAll(singlePacket);
                allPackets.Add(completePacket);
            }
            return(allPackets);
        }
Esempio n. 2
0
 public PacketTCP()
 {
     IP4Head             ipHeader  = new IP4Head();
     TCPHead             tcpHeader = new TCPHead();
     PacketBody <string> body      = new PacketBody <string>("Hello World");
 }