Class SctpTransport
Contains the common methods that an SCTP transport layer needs to implement. As well as being able to be carried directly in IP packets, SCTP packets can also be wrapped in higher level protocols.
Inherited Members
Namespace: SIPSorcery.Net
Assembly: SIPSorcery.dll
Syntax
public abstract class SctpTransport
Fields
| Improve this Doc View SourceDEFAULT_COOKIE_LIFETIME_SECONDS
Declaration
public const int DEFAULT_COOKIE_LIFETIME_SECONDS = 60
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
| Improve this Doc View SourceIsPortAgnostic
This property can be used to indicate whether an SCTP transport layer is port agnostic. For example a DTLS transport is likely to only ever create a single SCTP association and the SCTP ports are redundant for matching end points. This allows the checks done on received SCTP packets to be more accepting about the ports used in the SCTP packet header.
Declaration
public virtual bool IsPortAgnostic { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the transport implementation does not rely on the SCTP source and destination port for end point matching. False if it does. |
Methods
| Improve this Doc View SourceAbort(String)
Ungracefully closes an association. Any locally queued user data will be discarded, and an ABORT chunk is sent to the peer.
Declaration
public void Abort(string associationID)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
Associate(IPAddress, Int32)
Initiates an association to a specific peer end point
Declaration
public string Associate(IPAddress destination, int streamCount)
Parameters
Type | Name | Description |
---|---|---|
System.Net.IPAddress | destination | |
System.Int32 | streamCount |
Returns
Type | Description |
---|---|
System.String | An association ID, which is a local handle to the SCTP association. |
ChangeHeartbeat(String, Int32)
Instructs the local endpoint to enable or disable heartbeat on the specified destination transport address.
Declaration
public string ChangeHeartbeat(string associationID, int interval)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
System.Int32 | interval | Indicates the frequency of the heartbeat if this is to enable heartbeat on a destination transport address. This value is added to the RTO of the destination transport address.This value, if present, affects all destinations. |
Returns
Type | Description |
---|---|
System.String |
Destroy(String)
Release the resources for the specified SCTP instance.
Declaration
public void Destroy(string instanceName)
Parameters
Type | Name | Description |
---|---|---|
System.String | instanceName |
GetCookie(SctpPacket)
Attempts to retrieve the cookie that should have been set by this peer from a COOKIE ECHO chunk. This is the step in the handshake that a new SCTP association will be created for a remote party. Providing the state cookie is valid create a new association.
Declaration
protected SctpTransportCookie GetCookie(SctpPacket sctpPacket)
Parameters
Type | Name | Description |
---|---|---|
SctpPacket | sctpPacket | The packet containing the COOKIE ECHO chunk received from the remote party. |
Returns
Type | Description |
---|---|
SctpTransportCookie | If the state cookie in the chunk is valid a new SCTP association will be returned. IF it's not valid an empty cookie will be returned and an error response gets sent to the peer. |
GetCookieHMAC(Byte[])
Checks whether the state cookie that is supplied in a COOKIE ECHO chunk is valid for this SCTP transport.
Declaration
protected string GetCookieHMAC(byte[] buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | The buffer holding the state cookie. |
Returns
Type | Description |
---|---|
System.String | True if the cookie is determined as valid, false if not. |
GetInitAck(SctpPacket, IPEndPoint)
Creates the INIT ACK chunk and packet to send as a response to an SCTP packet containing an INIT chunk.
Declaration
protected SctpPacket GetInitAck(SctpPacket initPacket, IPEndPoint remoteEP)
Parameters
Type | Name | Description |
---|---|---|
SctpPacket | initPacket | The received packet containing the INIT chunk. |
System.Net.IPEndPoint | remoteEP | Optional. The remote IP end point the INIT packet was received on. For transports that don't use an IP transport directly this parameter can be set to null and it will not form part of the COOKIE ECHO checks. |
Returns
Type | Description |
---|---|
SctpPacket | An SCTP packet with a single INIT ACK chunk. |
GetInitAckCookie(UInt16, UInt16, UInt32, UInt32, UInt32, String, Int32)
Gets a cookie to send in an INIT ACK chunk. This method is overloadable so that different transports can tailor how the cookie is created. For example the WebRTC SCTP transport only ever uses a single association so the local Tag and TSN properties must be the same rather than random.
Declaration
protected virtual SctpTransportCookie GetInitAckCookie(ushort sourcePort, ushort destinationPort, uint remoteTag, uint remoteTSN, uint remoteARwnd, string remoteEndPoint, int lifeTimeExtension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | sourcePort | |
System.UInt16 | destinationPort | |
System.UInt32 | remoteTag | |
System.UInt32 | remoteTSN | |
System.UInt32 | remoteARwnd | |
System.String | remoteEndPoint | |
System.Int32 | lifeTimeExtension |
Returns
Type | Description |
---|---|
SctpTransportCookie |
GetSrttReport(String)
Instructs the local SCTP to report the current Smoothed Round Trip Time (SRTT) measurement on the specified destination transport address of the given association.
Declaration
public int GetSrttReport(string associationID)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
Returns
Type | Description |
---|---|
System.Int32 | An integer containing the most recent SRTT in milliseconds. |
GotInit(SctpPacket, IPEndPoint)
Declaration
protected void GotInit(SctpPacket initPacket, IPEndPoint remoteEndPoint)
Parameters
Type | Name | Description |
---|---|---|
SctpPacket | initPacket | |
System.Net.IPEndPoint | remoteEndPoint |
Initialize(UInt16)
This method allows SCTP to initialise its internal data structures and allocate necessary resources for setting up its operation environment.
Declaration
public string Initialize(ushort localPort)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | localPort | SCTP port number, if the application wants it to be specified. |
Returns
Type | Description |
---|---|
System.String | The local SCTP instance name. |
Receive(String, Byte[], Int32, Int32)
This method shall read the first user message in the SCTP in-queue into the buffer specified by the application, if there is one available.The size of the message read, in bytes, will be returned.
Declaration
public int Receive(string associationID, byte[] buffer, int length, int streamID)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
System.Byte[] | buffer | The buffer to place the received data into. |
System.Int32 | length | The maximum size of the data to receive. |
System.Int32 | streamID | Optional. If specified indicates which stream to receive the data on. |
Returns
Type | Description |
---|---|
System.Int32 |
ReceiveUnacknowledged(String, Byte[], Int32, Int32)
??
Declaration
public void ReceiveUnacknowledged(string dataRetrievalID, byte[] buffer, int length, int streamID)
Parameters
Type | Name | Description |
---|---|---|
System.String | dataRetrievalID | The identification passed to the application in the failure notification. |
System.Byte[] | buffer | The buffer to store the received message. |
System.Int32 | length | The maximum size of the data to receive. |
System.Int32 | streamID | This is a return value that is set to indicate which stream the data was sent to. |
ReceiveUnsent(String, Byte[], Int32, Int32)
??
Declaration
public void ReceiveUnsent(string dataRetrievalID, byte[] buffer, int length, int streamID)
Parameters
Type | Name | Description |
---|---|---|
System.String | dataRetrievalID | The identification passed to the application in the failure notification. |
System.Byte[] | buffer | The buffer to store the received message. |
System.Int32 | length | The maximum size of the data to receive. |
System.Int32 | streamID | This is a return value that is set to indicate which stream the data was sent to. |
RequestHeartbeat(String)
Instructs the local endpoint to perform a HeartBeat on the specified destination transport address of the given association.
Declaration
public string RequestHeartbeat(string associationID)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
Returns
Type | Description |
---|---|
System.String | Indicates whether the transmission of the HEARTBEAT chunk to the destination address is successful. |
Send(String, Byte[], Int32, Int32)
Declaration
public abstract void Send(string associationID, byte[] buffer, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | |
System.Byte[] | buffer | |
System.Int32 | offset | |
System.Int32 | length |
Send(String, Byte[], Int32, Int32, Int32, Int32)
This is the main method to send user data via SCTP.
Declaration
public string Send(string associationID, byte[] buffer, int length, int contextID, int streamID, int lifeTime)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
System.Byte[] | buffer | The buffer holding the data to send. |
System.Int32 | length | The number of bytes from the buffer to send. |
System.Int32 | contextID | Optional. A 32-bit integer that will be carried in the sending failure notification to the application if the transportation of this user message fails. |
System.Int32 | streamID | Optional. To indicate which stream to send the data on. If not specified, stream 0 will be used. |
System.Int32 | lifeTime | Optional. specifies the life time of the user data. The user data will not be sent by SCTP after the life time expires.This parameter can be used to avoid efforts to transmit stale user messages. |
Returns
Type | Description |
---|---|
System.String |
SetPrimary(String)
Instructs the local SCTP to use the specified destination transport address as the primary path for sending packets.
Declaration
public string SetPrimary(string associationID)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID |
Returns
Type | Description |
---|---|
System.String |
SetProtocolParameters(String, Object)
This method allows the local SCTP to customise the protocol parameters.
Declaration
public void SetProtocolParameters(string associationID, object protocolParameters)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
System.Object | protocolParameters | The specific names and values of the protocol parameters that the SCTP user wishes to customise. |
Shutdown(String)
Gracefully closes an association. Any locally queued user data will be delivered to the peer.The association will be terminated only after the peer acknowledges all the SCTP packets sent.
Declaration
public void Shutdown(string associationID)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
Status(String)
Returns the current status of the association.
Declaration
public SctpStatus Status(string associationID)
Parameters
Type | Name | Description |
---|---|---|
System.String | associationID | Local handle to the SCTP association. |
Returns
Type | Description |
---|---|
SctpStatus |