public void testMessFillSingle() { // assume capacity > 52 SCTPMessage m = new SCTPMessage(data, stream); List <DataChunk> chunks = new List <DataChunk>(); while (m.hasMoreData()) { DataChunk dc = new DataChunk(); m.fill(dc); chunks.Add(dc); } Console.WriteLine("chunks " + chunks.Count); Assert.AreEqual(chunks.Count, 1, "Wrong number of chunks"); Assert.AreEqual(chunks[0].getFlags(), DataChunk.SINGLEFLAG, "First (and only) chunk should have single flag set"); }
public void testMessFill1() { SCTPMessage m = new SCTPMessage(data, stream); List <DataChunk> chunks = new List <DataChunk>(); while (m.hasMoreData()) { DataChunk dc = new DataChunkImpl(); m.fill(dc); chunks.Add(dc); } Console.WriteLine("chunks " + chunks.Count); Assert.AreEqual(chunks.Count, data.Length, "Wrong number of chunks"); Assert.AreEqual(chunks[0].getFlags(), DataChunk.BEGINFLAG, "Start chunk should have start flag set"); Assert.AreEqual(chunks[data.Length - 1].getFlags(), DataChunk.ENDFLAG, "End chunk should have end flag set"); for (int i = 1; i < data.Length - 1; i++) { Assert.AreEqual(chunks[i].getFlags(), 0, "middle chunk should have no flag set"); Assert.AreEqual(chunks[i].getDataAsString(), data[i].ToString(), "middle data should match input"); } }
internal override void sendAndBlock(SCTPMessage m) { while (m.hasMoreData()) { DataChunk dc; lock (_freeBlocks) { dc = _freeBlocks.Count > 0 ? _freeBlocks.Dequeue() : new DataChunk(); } m.fill(dc); Logger.Trace("thinking about waiting for congestion " + dc.getTsn()); lock (_congestion) { Logger.Trace("In congestion sync block "); while (!this.maySend(dc.getDataSize())) { Logger.Trace("about to wait for congestion for " + this.getT3()); Monitor.Wait(_congestion, (int)this.getT3()); // wholly wrong } } // todo check rollover - will break at maxint. enqueue(dc); } }