コード例 #1
0
ファイル: Test.cs プロジェクト: yycmmc/Swiddler
        static void WriteSmall()
        {
            using (var stream = new FileStream("test_s", FileMode.Create, FileAccess.ReadWrite, FileShare.Read, Constants.BlockSize /* , FileOptions.DeleteOnClose */))
            {
                var writer = new BlockWriter(stream);

                long seq = 0;

                for (int i = 800; i < 850; i++)
                {
                    for (int c = 0; c < 1; c++)
                    {
                        var packet = new Packet()
                        {
                            Flow           = i % 2 == 0 ? TrafficFlow.Inbound : TrafficFlow.Outbound,
                            Source         = new IPEndPoint(IPAddress.Loopback, 123),
                            Destination    = new IPEndPoint(IPAddress.Loopback, 456),
                            SequenceNumber = seq++,
                            Payload        = new byte[i],
                        };

                        var data = packet.Payload;

                        for (int n = 0; n < data.Length; n++)
                        {
                            data[n] = (byte)((n + 32) % 192);
                        }

                        writer.Write(packet);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Test.cs プロジェクト: yycmmc/Swiddler
        static void Write()
        {
            using (var stream = new FileStream("test_32", FileMode.Create, FileAccess.ReadWrite, FileShare.Read, Constants.BlockSize /* , FileOptions.DeleteOnClose */))
            {
                var writer = new BlockWriter(stream);

                long seq = 0;

                for (int i = 800; i < 1000; i++)
                {
                    for (int n = 0; n < 1000; n++)
                    {
                        var packet = new Packet()
                        {
                            Flow           = TrafficFlow.Inbound,
                            Source         = new IPEndPoint(IPAddress.Loopback, 123),
                            Destination    = new IPEndPoint(IPAddress.Loopback, 456),
                            SequenceNumber = seq++,
                            Payload        = CreatePayload(i * 1),
                        };

                        writer.Write(packet);
                    }
                }
            }
        }