Esempio n. 1
0
        public void testAss()
        {
            DatagramTransportImpl   mock = new DatagramTransportImpl(null);
            AssociationListenerImpl al   = new AssociationListenerImpl(null);
            MockAssociation         ass  = new MockAssociation(mock, al);

            ass.setMyVerTag(335297160);
            ByteBuffer b = ByteBuffer.wrap(sampleDataOpen);
            Packet     p = new Packet(b);

            ass.deal(p);

            Packet       ack    = new Packet(mock.sent);
            List <Chunk> chunks = ack.getChunkList();

            Assert.AreEqual(1, chunks.Count, "Expecting 1 chunk ");
            DataChunk dat = chunks[0] as DataChunk;

            Assert.AreEqual(dat.getType(), DataChunk.CType.DATA, "Expecting a Data chunk");
            Console.WriteLine("got " + dat.GetType().Name + " chunk" + dat.ToString());
            Assert.AreEqual(dat.getSSeqNo(), 0, "Expecting seqno of zero");
            Assert.AreEqual(dat.getStreamId(), 0, "Expecting stream of zero");
            Assert.AreEqual(dat.getPpid(), 50, "Expecting an DCEP");
            Assert.AreEqual(dat.getData(), null, "Data should be zero");
            Assert.AreEqual(dat.getDCEP() != null, true, "Expected  to parse a DCEP packet");
            Assert.AreEqual(dat.getDCEP().isAck(), true, "Expected an ack DCEP packet ");

            Assert.AreEqual((al.stream == null), false, "expecting a stream");
            al.stream.send("hello");
            // ugh - uses a side effect on the sent buffer, which we capture.
            Packet pack = new Packet(mock.sent);

            chunks = pack.getChunkList();
            Assert.AreEqual(1, chunks.Count, "Expecting 1 chunk ");
            dat = chunks[0] as DataChunk;
            Assert.AreEqual(dat.getType(), Chunk.CType.DATA, "Expecting a Data chunk");
            Console.WriteLine("got " + dat.GetType().Name + " chunk" + dat.ToString());
            Assert.AreEqual(dat.getSSeqNo(), 1, "Expecting seqno of one");             // we've done a DCEP ack by now.
            Assert.AreEqual(dat.getStreamId(), 0, "Expecting stream of zero");
            Assert.AreEqual(dat.getDataAsString(), "hello", "Expecting hello in the data");
        }
Esempio n. 2
0
        public void testInitAck()
        {
            ByteBuffer   b      = ByteBuffer.wrap(sampleInit);
            Packet       p      = new Packet(b);
            List <Chunk> chunks = p.getChunkList();

            Assert.AreEqual(1, chunks.Count, "Expecting 1 chunk ");
            Chunk ic = chunks[0];

            Assert.AreEqual(ic.getType(), Chunk.CType.INIT, "Expecting an init chunk");

            Association ass = new MockAssociation(null, null);

            Chunk[] ca = ass.inboundInit(ic as InitChunk);
            Assert.AreEqual(1, ca.Length, "Expecting a single reply chunk");
            ByteBuffer iacbb = ass.mkPkt(ca);
            Packet     iac   = new Packet(iacbb);

            chunks = iac.getChunkList();
            Assert.AreEqual(1, chunks.Count, "Expecting 1 chunk ");
            ic = chunks[0];
            Assert.AreEqual(ic.getType(), Chunk.CType.INITACK, "Expecting an InitAck chunk");
        }