Exemplo n.º 1
0
        public void RoundTripDataPacket()
        {
            byte[] buffer =
            {
                0x00, 0x07, 0x11, 0x5c, 0x2e, 0x0b, 0x82, 0xc7, 0x5d, 0x2c, 0xeb, 0xa7, 0x00, 0x07, 0x00, 0x13,
                0xdf, 0x08, 0xc1, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x69, 0x0a, 0x00
            };

            Assert.True(SctpPacket.IsValid(buffer, 0, buffer.Length, 0x2e0b82c7U));

            var dataPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            var rndTripBuffer = dataPkt.GetBytes();

            logger.LogDebug($"Before: {buffer.HexStr()}");
            logger.LogDebug($"After : {rndTripBuffer.HexStr()}");

            Assert.True(SctpPacket.IsValid(rndTripBuffer, 0, rndTripBuffer.Length, 0x2e0b82c7U));

            var sctpPkt = SctpPacket.Parse(rndTripBuffer, 0, buffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(7, sctpPkt.Header.SourcePort);
            Assert.Equal(4444, sctpPkt.Header.DestinationPort);
            Assert.Equal(0x2e0b82c7U, sctpPkt.Header.VerificationTag);
            Assert.Equal(0x5d2ceba7U, sctpPkt.Header.Checksum);
            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.DATA); });

            var dataChunk = sctpPkt.Chunks.First() as SctpDataChunk;

            Assert.Equal(20, dataChunk.GetChunkLength(true));
            Assert.Equal("68690A", dataChunk.UserData.HexStr());
            Assert.Equal(3741893047, dataChunk.TSN);
        }
Exemplo n.º 2
0
        public void ParseUsrSctpAbortPacket()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            byte[] buffer =
            {
                0x00, 0x07, 0x11, 0x5c, 0x93, 0xc9, 0xd9, 0x8a, 0x19, 0x82, 0x31, 0xc1, 0x06, 0x00, 0x00, 0x3b,
                0x00, 0x0d, 0x00, 0x37, 0x43, 0x75, 0x6d, 0x20, 0x61, 0x63, 0x6b, 0x20, 0x30, 0x30, 0x30, 0x30,
                0x30, 0x30, 0x30, 0x30, 0x20, 0x67, 0x72, 0x65, 0x61, 0x74, 0x65, 0x72, 0x20, 0x6f, 0x72, 0x20,
                0x65, 0x71, 0x75, 0x61, 0x6c, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x20, 0x54, 0x53, 0x4e, 0x20, 0x63,
                0x36, 0x65, 0x33, 0x61, 0x64, 0x33, 0x63, 0x00
            };

            Assert.True(SctpPacket.IsValid(buffer, 0, buffer.Length, 0x93c9d98aU));

            var sctpPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(7, sctpPkt.Header.SourcePort);
            Assert.Equal(4444, sctpPkt.Header.DestinationPort);
            Assert.Equal(0x93c9d98aU, sctpPkt.Header.VerificationTag);
            Assert.Equal(0x198231c1U, sctpPkt.Header.Checksum);

            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.ABORT); });

            var abortChunk = sctpPkt.Chunks.First() as SctpAbortChunk;
            var cause      = (SctpErrorProtocolViolation)(abortChunk.ErrorCauses.First());

            logger.LogDebug($"ABORT reason={cause.AdditionalInformation}.");

            Assert.Single(abortChunk.ErrorCauses);
            Assert.Equal("Cum ack 00000000 greater or equal than TSN c6e3ad3c", cause.AdditionalInformation);
        }
Exemplo n.º 3
0
        public void RoundTripHeartbeatPacket()
        {
            byte[] buffer =
            {
                0x00, 0x07, 0x11, 0x5c, 0x05, 0x4a, 0x3a, 0xf0, 0x02, 0x3b, 0xcc, 0x90, 0x04, 0x00, 0x00, 0x2c,
                0x00, 0x01, 0x00, 0x28, 0x4c, 0x3a, 0x56, 0x60, 0xa8, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };

            Assert.True(SctpPacket.IsValid(buffer, 0, buffer.Length, 0x054a3af0U));

            var heartbeatPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            var rndTripBuffer = heartbeatPkt.GetBytes();

            logger.LogDebug($"Before: {buffer.HexStr()}");
            logger.LogDebug($"After : {rndTripBuffer.HexStr()}");

            Assert.True(SctpPacket.IsValid(rndTripBuffer, 0, rndTripBuffer.Length, 0x054a3af0U));

            var sctpPkt = SctpPacket.Parse(rndTripBuffer, 0, buffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(7, sctpPkt.Header.SourcePort);
            Assert.Equal(4444, sctpPkt.Header.DestinationPort);
            Assert.Equal(0x054a3af0U, sctpPkt.Header.VerificationTag);
            Assert.Equal(0x023bcc90U, sctpPkt.Header.Checksum);
            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.HEARTBEAT); });

            var heartbeatChunk = sctpPkt.Chunks.First();

            Assert.Equal(44, heartbeatChunk.GetChunkLength(true));
        }
Exemplo n.º 4
0
        public async Task SmallBufferSend()
        {
            BlockingCollection <byte[]> inStm  = new BlockingCollection <byte[]>();
            BlockingCollection <byte[]> outStm = new BlockingCollection <byte[]>();
            var             mockTransport      = new MockB2BSctpTransport(outStm, inStm);
            SctpAssociation assoc = new SctpAssociation(mockTransport, null, 5000, 5000, 1400, 0);

            SctpDataSender sender = new SctpDataSender("dummy", assoc.SendChunk, 1400, 0, 1000);

            sender.StartSending();
            sender.SendData(0, 0, new byte[] { 0x00, 0x01, 0x02 });

            await Task.Delay(100);

            Assert.Single(outStm);

            byte[]     sendBuffer = outStm.Single();
            SctpPacket pkt        = SctpPacket.Parse(sendBuffer, 0, sendBuffer.Length);

            Assert.NotNull(pkt);
            Assert.NotNull(pkt.Chunks.Single() as SctpDataChunk);

            var datachunk = pkt.Chunks.Single() as SctpDataChunk;

            Assert.Equal("000102", datachunk.UserData.HexStr());
        }
Exemplo n.º 5
0
        public void ParseUsrSctpCookieEchoPacket()
        {
            byte[] buffer =
            {
                0xdf, 0x90, 0x00, 0x07, 0xcd, 0x6e, 0x61, 0x50, 0xce, 0x44, 0xba, 0xac, 0x0a, 0x00, 0x00, 0x14,
                0x4b, 0x41, 0x4d, 0x45, 0x2d, 0x42, 0x53, 0x44, 0x20, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00
            };

            // Checksum does not match because the original cookie was too long and was truncated for testing purposes.
            Assert.False(SctpPacket.VerifyChecksum(buffer, 0, buffer.Length));
            Assert.Equal(0xcd6e6150U, SctpPacket.GetVerificationTag(buffer, 0, buffer.Length));

            var sctpPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(57232, sctpPkt.Header.SourcePort);
            Assert.Equal(7, sctpPkt.Header.DestinationPort);
            Assert.Equal(0xcd6e6150U, sctpPkt.Header.VerificationTag);
            Assert.Equal(0xce44baacU, sctpPkt.Header.Checksum);
            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.COOKIE_ECHO); });

            var cookieEchoChunk = sctpPkt.Chunks.First();

            Assert.Equal(0x14, cookieEchoChunk.GetChunkLength(true));
            Assert.Equal(0x10, cookieEchoChunk.ChunkValue.Length);
        }
Exemplo n.º 6
0
        public void GetInitAckPacket()
        {
            logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name);
            logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name);

            var sctpTransport = new MockSctpTransport();

            uint remoteTag   = Crypto.GetRandomUInt();
            uint remoteTSN   = Crypto.GetRandomUInt();
            uint remoteARwnd = SctpAssociation.DEFAULT_ADVERTISED_RECEIVE_WINDOW;

            SctpPacket    init      = new SctpPacket(5000, 5000, 0);
            SctpInitChunk initChunk = new SctpInitChunk(SctpChunkType.INIT, remoteTag, remoteTSN, remoteARwnd,
                                                        SctpAssociation.DEFAULT_NUMBER_OUTBOUND_STREAMS, SctpAssociation.DEFAULT_NUMBER_INBOUND_STREAMS);

            init.AddChunk(initChunk);

            var initAck = sctpTransport.GetInitAck(init);

            Assert.NotNull(initAck);

            var initAckChunk = initAck.Chunks.Single() as SctpInitChunk;

            Assert.NotNull(initAckChunk);
            Assert.NotNull(initAckChunk.StateCookie);

            var cookie = JSONParser.FromJson <SctpTransportCookie>(Encoding.UTF8.GetString(initAckChunk.StateCookie));

            logger.LogDebug($"Cookie: {cookie.ToJson()}");

            Assert.NotNull(cookie.CreatedAt);
            Assert.NotNull(cookie.HMAC);
            Assert.Equal(cookie.HMAC, sctpTransport.GetCookieHMAC(initAckChunk.StateCookie));
        }
        public void Listen()
        {
            while (!_exit)
            {
                if (_input.TryTake(out var buffer, 1000))
                {
                    SctpPacket pkt = SctpPacket.Parse(buffer, 0, buffer.Length);

                    // Process packet.
                    if (pkt.Chunks.Any(x => x.KnownType == SctpChunkType.INIT))
                    {
                        var initAckPacket = base.GetInitAck(pkt, null);
                        var initAckBuffer = initAckPacket.GetBytes();
                        Send(null, initAckBuffer, 0, initAckBuffer.Length);
                    }
                    else if (pkt.Chunks.Any(x => x.KnownType == SctpChunkType.COOKIE_ECHO))
                    {
                        var cookieEcho = pkt.Chunks.Single(x => x.KnownType == SctpChunkType.COOKIE_ECHO);
                        var cookie     = base.GetCookie(pkt);
                        if (cookie.IsEmpty())
                        {
                            throw new ApplicationException($"MockB2BSctpTransport gave itself an invalid INIT cookie.");
                        }
                        else
                        {
                            OnCookieEcho?.Invoke(cookie);
                        }
                    }
                    else
                    {
                        OnSctpPacket?.Invoke(pkt);
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void ParseSACKChunk()
        {
            var sackBuffer = BufferUtils.ParseHexStr("13881388E48092946AB2050003000014D19244F60002000000000001A7498379");

            var sackPkt = SctpPacket.Parse(sackBuffer, 0, sackBuffer.Length);

            Assert.NotNull(sackPkt);
            Assert.Single(sackPkt.Chunks);
            Assert.Equal(2806612857U, (sackPkt.Chunks.Single() as SctpSackChunk).DuplicateTSN.Single());
        }
Exemplo n.º 9
0
        public void RoundTripInitPacket()
        {
            byte[] buffer =
            {
                0xdf, 0x90, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x6a, 0xb8, 0x0e, 0x99, 0x01, 0x00, 0x00, 0xa0,
                0xe3, 0x1c, 0x55, 0x36, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x6c, 0xd7, 0x4d, 0xda,
                0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x04, 0x80, 0x08, 0x00, 0x09, 0xc0, 0x0f, 0xc1, 0x80,
                0x82, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x24, 0x5c, 0x91, 0x79, 0x78, 0xeb, 0xcf, 0x87, 0x25,
                0xd4, 0x64, 0xb6, 0xc3, 0x7f, 0xf9, 0x21, 0x19, 0x1d, 0x61, 0xe6, 0x31, 0x3d, 0x9d, 0x56, 0x1f,
                0xdb, 0x66, 0xb4, 0x05, 0x05, 0xd4, 0x47, 0x53, 0x80, 0x04, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00,
                0x80, 0x03, 0x00, 0x06, 0x80, 0xc1, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x05, 0x00, 0x06,
                0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0xa0, 0x01, 0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0x70, 0x01,
                0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x89, 0x01, 0x00, 0x06, 0x00, 0x14, 0x2a, 0x02, 0x80, 0x84,
                0x69, 0x81, 0x78, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x08,
                0xc0, 0xa8, 0x0b, 0x32, 0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x00, 0x32
            };

            Assert.True(SctpPacket.IsValid(buffer, 0, buffer.Length, 0x0U));

            var initPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            var rndTripBuffer = initPkt.GetBytes();

            logger.LogDebug($"Before: {buffer.HexStr()}");
            logger.LogDebug($"After : {rndTripBuffer.HexStr()}");

            Assert.True(SctpPacket.IsValid(rndTripBuffer, 0, rndTripBuffer.Length, 0x0U));

            var sctpPkt = SctpPacket.Parse(rndTripBuffer, 0, rndTripBuffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(57232, sctpPkt.Header.SourcePort);
            Assert.Equal(7, sctpPkt.Header.DestinationPort);
            Assert.Equal(0U, sctpPkt.Header.VerificationTag);
            // Note the checksum can differ if there are any unrecognised parameters.
            Assert.Equal(0xBE4AE6F5U, sctpPkt.Header.Checksum);
            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.INIT); });

            var initChunk = sctpPkt.Chunks.First() as SctpInitChunk;

            Assert.Equal(0xe31c5536U, initChunk.InitiateTag);
            Assert.Equal(131072U, initChunk.ARwnd);
            Assert.Equal(10, initChunk.NumberOutboundStreams);
            Assert.Equal(2048, initChunk.NumberInboundStreams);
            Assert.Equal(1826049498U, initChunk.InitialTSN);
        }
Exemplo n.º 10
0
        public TempPacketSaveData GetPacket(byte[] payload, int sctpStreamId, SctpPayloadProtocol proto)
        {
            PhysicalAddress emptyAddress = PhysicalAddress.Parse("000000000000");

            PacketDotNet.EthernetPacket etherPacket = new EthernetPacket(emptyAddress, emptyAddress, EthernetType.IPv4);

            bool flip = sctpStreamId < 0;

            sctpStreamId = Math.Abs(sctpStreamId);
            Random r = new Random(sctpStreamId);

            IPAddress sourceIp = new IPAddress(r.Next());
            IPAddress destIp   = new IPAddress(r.Next());

            if (flip)
            {
                IPAddress tempAddress = sourceIp;
                sourceIp = destIp;
                destIp   = tempAddress;
            }

            var        IPProtocolType_Sctp = 132;
            IPv4Packet ipPacket            = new IPv4Packet(sourceIp, destIp)
            {
                Protocol = (ProtocolType)IPProtocolType_Sctp
            };
            SctpPacket    sctpPacket = new SctpPacket(1, 1, 0, 0);
            SctpDataChunk dataChunk  = new PacketDotNet.Sctp.Chunks.SctpDataChunk(new ByteArraySegment(
                                                                                      new byte[]
            {
                0x00, 0x03, 0x00, 0x14, 0x79, 0x46, 0x08, 0xb7, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00,
                0x00, 0x00
            }), sctpPacket)
            {
                PayloadData     = payload,
                PayloadProtocol = proto
            };

            dataChunk.Length = (ushort)(16 + payload.Length);
            byte[] ipPayload = sctpPacket.Bytes.Concat(dataChunk.Bytes).ToArray();
            ipPacket.PayloadData      = ipPayload;
            etherPacket.PayloadPacket = ipPacket;
            return(new TempPacketSaveData(etherPacket.Bytes, LinkLayerType.Ethernet));
        }
Exemplo n.º 11
0
        public void ParseUsrSctpInitPacket()
        {
            byte[] buffer =
            {
                0xdf, 0x90, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x6a, 0xb8, 0x0e, 0x99, 0x01, 0x00, 0x00, 0xa0,
                0xe3, 0x1c, 0x55, 0x36, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x6c, 0xd7, 0x4d, 0xda,
                0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x04, 0x80, 0x08, 0x00, 0x09, 0xc0, 0x0f, 0xc1, 0x80,
                0x82, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x24, 0x5c, 0x91, 0x79, 0x78, 0xeb, 0xcf, 0x87, 0x25,
                0xd4, 0x64, 0xb6, 0xc3, 0x7f, 0xf9, 0x21, 0x19, 0x1d, 0x61, 0xe6, 0x31, 0x3d, 0x9d, 0x56, 0x1f,
                0xdb, 0x66, 0xb4, 0x05, 0x05, 0xd4, 0x47, 0x53, 0x80, 0x04, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00,
                0x80, 0x03, 0x00, 0x06, 0x80, 0xc1, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x05, 0x00, 0x06,
                0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0xa0, 0x01, 0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0x70, 0x01,
                0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x89, 0x01, 0x00, 0x06, 0x00, 0x14, 0x2a, 0x02, 0x80, 0x84,
                0x69, 0x81, 0x78, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x08,
                0xc0, 0xa8, 0x0b, 0x32, 0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x00, 0x32
            };

            Assert.True(SctpPacket.IsValid(buffer, 0, buffer.Length, 0U));

            var sctpPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(57232, sctpPkt.Header.SourcePort);
            Assert.Equal(7, sctpPkt.Header.DestinationPort);
            Assert.Equal(0U, sctpPkt.Header.VerificationTag);
            Assert.Equal(0x6ab80e99U, sctpPkt.Header.Checksum);
            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.INIT); });

            var initChunk = sctpPkt.Chunks.First() as SctpInitChunk;

            Assert.Equal(0xe31c5536U, initChunk.InitiateTag);
            Assert.Equal(131072U, initChunk.ARwnd);
            Assert.Equal(10, initChunk.NumberOutboundStreams);
            Assert.Equal(2048, initChunk.NumberInboundStreams);
            Assert.Equal(1826049498U, initChunk.InitialTSN);

            foreach (var unrecognisedParam in initChunk.UnrecognizedPeerParameters)
            {
                logger.LogDebug($"Chunk Unrecognised Parameter {unrecognisedParam.ParameterType}.");
            }
        }
Exemplo n.º 12
0
        public void ParseUsrSctpCookieAckPacket()
        {
            byte[] buffer =
            {
                0x00, 0x07, 0xdf, 0x90, 0xe3, 0x1c, 0x55, 0x36, 0xb2, 0x04, 0xdf, 0x21, 0x0b, 0x00, 0x00, 0x04
            };

            Assert.True(SctpPacket.IsValid(buffer, 0, buffer.Length, 0xe31c5536U));

            var sctpPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(7, sctpPkt.Header.SourcePort);
            Assert.Equal(57232, sctpPkt.Header.DestinationPort);
            Assert.Equal(0xe31c5536U, sctpPkt.Header.VerificationTag);
            Assert.Equal(0xb204df21U, sctpPkt.Header.Checksum);
            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.COOKIE_ACK); });

            var cookieAckChunk = sctpPkt.Chunks.First();

            Assert.Equal(4, cookieAckChunk.GetChunkLength(true));
        }
Exemplo n.º 13
0
        public void ParseUsrSctpInitAckPacket()
        {
            byte[] buffer =
            {
                0x00, 0x07, 0xdf, 0x90, 0xe3, 0x1c, 0x55, 0x36, 0x53, 0x72, 0xb8, 0xb5, 0x02, 0x00, 0x02, 0x50,
                0xcd, 0x6e, 0x61, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x5f, 0xb4, 0x0a, 0xc2,
                0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x04, 0x80, 0x08, 0x00, 0x09, 0xc0, 0x0f, 0xc1, 0x80,
                0x82, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x24, 0xad, 0xb8, 0x33, 0x07, 0xba, 0xb4, 0x2e, 0x59,
                0x93, 0x81, 0x50, 0x20, 0x3c, 0x70, 0xf6, 0xf1, 0x4b, 0x6f, 0x7f, 0x4e, 0x81, 0x49, 0x7c, 0x3e,
                0xef, 0xf2, 0xc8, 0x37, 0xfa, 0xd1, 0x5f, 0x74, 0x80, 0x04, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00,
                0x80, 0x03, 0x00, 0x06, 0x80, 0xc1, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0xa0, 0x01,
                0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0x70, 0x01, 0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x89, 0x01,
                0x00, 0x06, 0x00, 0x14, 0x2a, 0x02, 0x80, 0x84, 0x69, 0x81, 0x78, 0x80, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x0b, 0x32, 0x00, 0x05, 0x00, 0x08,
                0xc0, 0xa8, 0x00, 0x32, 0x00, 0x07, 0x01, 0xb8, 0x4b, 0x41, 0x4d, 0x45, 0x2d, 0x42, 0x53, 0x44,
                0x20, 0x31, 0x2e, 0x31, 0x00, 0x00, 0x00, 0x00, 0x5d, 0x5c, 0x53, 0x60, 0xb9, 0x27, 0x08, 0x00,
                0x60, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x55, 0x1c, 0xe3,
                0xcd, 0x6e, 0x61, 0x50, 0xc0, 0xa8, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0xdf, 0x90, 0x00, 0x07, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0xa0, 0xe3, 0x1c, 0x55, 0x36, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x00,
                0x6c, 0xd7, 0x4d, 0xda, 0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x04, 0x80, 0x08, 0x00, 0x09,
                0xc0, 0x0f, 0xc1, 0x80, 0x82, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x24, 0x5c, 0x91, 0x79, 0x78,
                0xeb, 0xcf, 0x87, 0x25, 0xd4, 0x64, 0xb6, 0xc3, 0x7f, 0xf9, 0x21, 0x19, 0x1d, 0x61, 0xe6, 0x31,
                0x3d, 0x9d, 0x56, 0x1f, 0xdb, 0x66, 0xb4, 0x05, 0x05, 0xd4, 0x47, 0x53, 0x80, 0x04, 0x00, 0x06,
                0x00, 0x01, 0x00, 0x00, 0x80, 0x03, 0x00, 0x06, 0x80, 0xc1, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08,
                0x00, 0x05, 0x00, 0x06, 0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0xa0, 0x01, 0x00, 0x05, 0x00, 0x08,
                0xac, 0x16, 0x70, 0x01, 0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x89, 0x01, 0x00, 0x06, 0x00, 0x14,
                0x2a, 0x02, 0x80, 0x84, 0x69, 0x81, 0x78, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
                0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x0b, 0x32, 0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x00, 0x32,
                0x02, 0x00, 0x02, 0x50, 0xcd, 0x6e, 0x61, 0x50, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x00,
                0x5f, 0xb4, 0x0a, 0xc2, 0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x04, 0x80, 0x08, 0x00, 0x09,
                0xc0, 0x0f, 0xc1, 0x80, 0x82, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x24, 0xad, 0xb8, 0x33, 0x07,
                0xba, 0xb4, 0x2e, 0x59, 0x93, 0x81, 0x50, 0x20, 0x3c, 0x70, 0xf6, 0xf1, 0x4b, 0x6f, 0x7f, 0x4e,
                0x81, 0x49, 0x7c, 0x3e, 0xef, 0xf2, 0xc8, 0x37, 0xfa, 0xd1, 0x5f, 0x74, 0x80, 0x04, 0x00, 0x06,
                0x00, 0x01, 0x00, 0x00, 0x80, 0x03, 0x00, 0x06, 0x80, 0xc1, 0x00, 0x00, 0x00, 0x05, 0x00, 0x08,
                0xac, 0x16, 0xa0, 0x01, 0x00, 0x05, 0x00, 0x08, 0xac, 0x16, 0x70, 0x01, 0x00, 0x05, 0x00, 0x08,
                0xc0, 0xa8, 0x89, 0x01, 0x00, 0x06, 0x00, 0x14, 0x2a, 0x02, 0x80, 0x84, 0x69, 0x81, 0x78, 0x80,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x0b, 0x32,
                0x00, 0x05, 0x00, 0x08, 0xc0, 0xa8, 0x00, 0x32, 0xc5, 0x35, 0x15, 0xc8, 0x35, 0x57, 0x0a, 0xd5,
                0x96, 0x29, 0xc8, 0xbf, 0x38, 0x7b, 0xc2, 0x16, 0xe9, 0x4c, 0x81, 0xbe
            };

            Assert.True(SctpPacket.IsValid(buffer, 0, buffer.Length, 0xe31c5536U));

            var sctpPkt = SctpPacket.Parse(buffer, 0, buffer.Length);

            Assert.NotNull(sctpPkt);
            Assert.Equal(7, sctpPkt.Header.SourcePort);
            Assert.Equal(57232, sctpPkt.Header.DestinationPort);
            Assert.Equal(0xe31c5536U, sctpPkt.Header.VerificationTag);
            Assert.Equal(0x5372b8b5U, sctpPkt.Header.Checksum);
            Assert.Single(sctpPkt.Chunks);
            Assert.Contains(sctpPkt.Chunks, (chunk) => { return(chunk.KnownType == SctpChunkType.INIT_ACK); });

            var initChunk = sctpPkt.Chunks.First() as SctpInitChunk;

            Assert.Equal(0xcd6e6150U, initChunk.InitiateTag);
            Assert.Equal(131072U, initChunk.ARwnd);
            Assert.Equal(10, initChunk.NumberOutboundStreams);
            Assert.Equal(2048, initChunk.NumberInboundStreams);
            Assert.Equal(1605634754U, initChunk.InitialTSN);
        }
Exemplo n.º 14
0
 public SctpPacket GetInitAck(SctpPacket initPacket)
 {
     return(base.GetInitAck(initPacket, null));
 }