Exemplo n.º 1
0
        public void testFillLongstring()
        {
            Console.WriteLine("--> fill long");
            StringBuilder sb = new StringBuilder("This is a");

            for (int i = 0; i < 1030; i++)
            {
                sb.Append(" long");
            }
            sb.Append(" test.");
            string                  teststring = sb.ToString();
            SCTPMessage             instance   = new SCTPMessage(teststring, _fakeStream);
            SortedArray <DataChunk> chunks     = new SortedArray <DataChunk>();
            long tsn = 111;

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                dc.setTsn((uint)tsn++);
                instance.fill(dc);
                chunks.Add(dc);
            }
            double pktsz    = chunks.First.getDataSize();
            int    estimate = (int)Math.Ceiling(teststring.Length / pktsz);

            Assert.AreEqual(chunks.Count, estimate);
        }
Exemplo n.º 2
0
        internal override void sendAndBlock(SCTPMessage m)
        {
            Chunk[] dar = new Chunk[1];

            DataChunk dc = new DataChunk();

            m.fill(dc);
            dc.setTsn(_nearTSN++);
            // check rollover - will break at maxint.
            dar[0] = dc;
            send(dar);
        }
Exemplo n.º 3
0
        public void testFillShortstring()
        {
            Console.WriteLine("--> fill short string ");
            string                  teststring = "This is a short test";
            SCTPMessage             instance   = new SCTPMessage(teststring, _fakeStream);
            SortedArray <DataChunk> chunks     = new SortedArray <DataChunk>();

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                instance.fill(dc);
                chunks.Add(dc);
            }
            Assert.AreEqual(chunks.Count, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCstring);
        }
Exemplo n.º 4
0
        public void testFillShortBlob()
        {
            Console.WriteLine("--> fill short blob ");
            byte[] testBlob = new byte[21];
            _rand.NextBytes(testBlob);
            SCTPMessage             instance = new SCTPMessage(testBlob, _fakeStream);
            SortedArray <DataChunk> chunks   = new SortedArray <DataChunk>();

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                instance.fill(dc);
                chunks.Add(dc);
            }
            Assert.AreEqual(chunks.Count, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCBINARY);
        }
Exemplo n.º 5
0
        public void testEmptyBlob()
        {
            Console.WriteLine("--> fill empty blob");
            byte[]                  testBlob = new byte[0];
            SCTPMessage             instance = new SCTPMessage(testBlob, _fakeStream);
            SortedArray <DataChunk> chunks   = new SortedArray <DataChunk>();
            long tsn = 111;

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                dc.setTsn((uint)tsn++);
                instance.fill(dc);
                chunks.Add(dc);
            }
            Assert.AreEqual(chunks.Count, 1);
            int pktsz = chunks.First.getDataSize();

            Assert.AreEqual(pktsz, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCBINARYEMPTY);
        }
Exemplo n.º 6
0
        public void testEmptystring()
        {
            Console.WriteLine("--> fill empty string");
            StringBuilder           sb         = new StringBuilder("");
            string                  teststring = sb.ToString();
            SCTPMessage             instance   = new SCTPMessage(teststring, _fakeStream);
            SortedArray <DataChunk> chunks     = new SortedArray <DataChunk>();
            long tsn = 111;

            while (instance.hasMoreData())
            {
                DataChunk dc = new DataChunk();
                dc.setTsn((uint)tsn++);
                instance.fill(dc);
                chunks.Add(dc);
            }
            int pktsz = chunks.First.getDataSize();

            Assert.AreEqual(chunks.Count, 1);
            Assert.AreEqual(pktsz, 1);
            int ppid = ((DataChunk)chunks.First).getPpid();

            Assert.AreEqual(ppid, DataChunk.WEBRTCstringEMPTY);
        }