Exemple #1
0
        public void TestAddByteArray()
        {
            var queue = new SendQueueWrapper(1024);
            var bytes = new Byte[] { 0x1, 0x2, 0x3 };

            queue.Add(bytes);
            Assert.AreEqual(PcapHeader.MemorySize + bytes.Length, queue.CurrentLength);
        }
Exemple #2
0
        public void TestAddPacket()
        {
            var queue  = new SendQueueWrapper(1024);
            var packet = EthernetPacket.RandomPacket();

            queue.Add(packet);
            Assert.AreEqual(PcapHeader.MemorySize + packet.TotalPacketLength, queue.CurrentLength);
        }
Exemple #3
0
        public void TestTransmitEmpty()
        {
            using var device = GetPcapDevice();
            device.Open();
            var queue = new SendQueueWrapper(1024);

            Assert.AreEqual(0, queue.Transmit(device, SendQueueTransmitModes.Normal));
        }
Exemple #4
0
        public void TestAddRawCapture()
        {
            var queue      = new SendQueueWrapper(1024);
            var bytes      = new Byte[] { 0x1, 0x2, 0x3 };
            var rawCapture = new RawCapture(LinkLayers.Ethernet, new PosixTimeval(10, 20), bytes);

            queue.Add(rawCapture);
            Assert.AreEqual(PcapHeader.MemorySize + rawCapture.PacketLength, queue.CurrentLength);
        }
        /// <summary>
        /// Helper method
        /// </summary>
        /// <returns></returns>
        private static SendQueueWrapper GetSendQueue()
        {
            var queue  = new SendQueueWrapper(1024);
            var packet = EthernetPacket.RandomPacket();

            packet.Type = (EthernetType)0x1234;
            for (var i = 0; i < PacketCount; i++)
            {
                Assert.IsTrue(queue.Add(packet.Bytes, 123456, i * DeltaMs * 1000));
            }
            return(queue);
        }