Ejemplo n.º 1
0
        /// <summary>
        /// Create a new SCTP association instance where the INIT will be generated
        /// from this end of the connection.
        /// </summary>
        /// <param name="sctpTransport">The transport layer doing the actual sending and receiving of
        /// packets, e.g. UDP, DTLS, raw sockets etc.</param>
        /// <param name="destination">Optional. The remote destination end point for this association.
        /// Some transports, such as DTLS, are already established and do not use this parameter.</param>
        /// <param name="sctpSourcePort">The source port for the SCTP packet header.</param>
        /// <param name="sctpDestinationPort">The destination port for the SCTP packet header.</param>
        /// <param name="defaultMTU">The default Maximum Transmission Unit (MTU) for the underlying
        /// transport. This determines the maximum size of an SCTP packet that will be used with
        /// the transport.</param>
        /// <param name="localTransportPort">Optional. The local transport (e.g. UDP or DTLS) port being
        /// used for the underlying SCTP transport. This be set on the SCTP association's ID to aid in
        /// diagnostics.</param>
        public SctpAssociation(
            SctpTransport sctpTransport,
            IPEndPoint destination,
            ushort sctpSourcePort,
            ushort sctpDestinationPort,
            ushort defaultMTU,
            int localTransportPort,
            ushort numberOutboundStreams = DEFAULT_NUMBER_OUTBOUND_STREAMS,
            ushort numberInboundStreams  = DEFAULT_NUMBER_INBOUND_STREAMS)
        {
            _sctpTransport         = sctpTransport;
            Destination            = destination;
            _sctpSourcePort        = sctpSourcePort;
            _sctpDestinationPort   = sctpDestinationPort;
            _defaultMTU            = defaultMTU;
            _numberOutboundStreams = numberOutboundStreams;
            _numberInboundStreams  = numberInboundStreams;
            VerificationTag        = Crypto.GetRandomUInt(true);

            ID    = $"{sctpSourcePort}:{sctpDestinationPort}:{localTransportPort}";
            ARwnd = DEFAULT_ADVERTISED_RECEIVE_WINDOW;

            _dataReceiver = new SctpDataReceiver(ARwnd, _defaultMTU, 0);
            _dataSender   = new SctpDataSender(ID, this.SendChunk, defaultMTU, Crypto.GetRandomUInt(true), DEFAULT_ADVERTISED_RECEIVE_WINDOW);

            State = SctpAssociationState.Closed;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new SCTP association instance from the cookie that was previously
        /// sent to the remote party in an INIT ACK chunk.
        /// </summary>
        public SctpAssociation(
            SctpTransport sctpTransport,
            SctpTransportCookie cookie,
            int localTransportPort)
        {
            _sctpTransport = sctpTransport;
            ID             = $"{cookie.SourcePort}:{cookie.DestinationPort}:{localTransportPort}";
            State          = SctpAssociationState.Closed;

            GotCookie(cookie);
        }