/// <summary> /// Sends an SCTP packet to the remote peer. /// </summary> /// <param name="pkt">The packet to send.</param> private void SendPacket(SctpPacket pkt) { if (!_wasAborted) { byte[] buffer = pkt.GetBytes(); _sctpTransport.Send(ID, buffer, 0, buffer.Length); } }
/// <summary> /// Sends a SCTP chunk to the remote party. /// </summary> /// <param name="chunk">The chunk to send.</param> internal void SendChunk(SctpChunk chunk) { if (!_wasAborted) { SctpPacket pkt = new SctpPacket( _sctpSourcePort, _sctpDestinationPort, _remoteVerificationTag); pkt.AddChunk(chunk); byte[] buffer = pkt.GetBytes(); _sctpTransport.Send(ID, buffer, 0, buffer.Length); } }
/// <summary> /// Send an SCTP packet with one of the error type chunks (ABORT or ERROR) to the remote peer. /// </summary> /// <param name=isAbort">Set to true to use an ABORT chunk otherwise an ERROR chunk will be used.</param> /// <param name="desintationPort">The SCTP destination port.</param> /// <param name="sourcePort">The SCTP source port.</param> /// <param name="initiateTag">If available the initial tag for the remote peer.</param> /// <param name="error">The error to send.</param> private void SendError( bool isAbort, ushort destinationPort, ushort sourcePort, uint initiateTag, ISctpErrorCause error) { SctpPacket errorPacket = new SctpPacket( destinationPort, sourcePort, initiateTag); SctpErrorChunk errorChunk = isAbort ? new SctpAbortChunk(true) : new SctpErrorChunk(); errorChunk.AddErrorCause(error); errorPacket.AddChunk(errorChunk); var buffer = errorPacket.GetBytes(); Send(null, buffer, 0, buffer.Length); }
/// <summary> /// Attempts to create an association with a remote party by sending an initialisation /// control chunk. /// </summary> private void SendInit() { if (!_wasAborted) { // A packet containing an INIT chunk MUST have a zero Verification Tag (RFC4960 Pg 15). SctpPacket init = new SctpPacket(_sctpSourcePort, _sctpDestinationPort, 0); SctpInitChunk initChunk = new SctpInitChunk( SctpChunkType.INIT, VerificationTag, TSN, ARwnd, _numberOutboundStreams, _numberInboundStreams); init.AddChunk(initChunk); SetState(SctpAssociationState.CookieWait); byte[] buffer = init.GetBytes(); _sctpTransport.Send(ID, buffer, 0, buffer.Length); _t1Init = new Timer(T1InitTimerExpired, init, T1_INIT_TIMER_MILLISECONDS, T1_INIT_TIMER_MILLISECONDS); } }