Coder Social home page Coder Social logo

sctp's Introduction

Note

On 29 June 2023, Mobius Software LTD signed an agreement with Mavenir to assume development and support of the RestcommOne on prem products. For more details regarding open source / commercial differentiation, roadmap, licensing and other details please visit the Mobius Website.

Restcomm SCTP

FOSSA Status

RestComm SCTP implementation

License

FOSSA Status

sctp's People

Contributors

abhayani avatar deruelle avatar fossabot avatar ivelin avatar kostyantynnosach-mobius avatar lasithwaruna avatar vetss avatar yulianoifa-mobius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sctp's Issues

SctpChannel.send() return value ignored

In AssociationImpl.java the return value of send is ignored:

protected void write(SelectionKey key) {

	try {			
		// TODO Do we need to synchronize ConcurrentLinkedQueue?
		// synchronized (this.txQueue) {
		if (!txQueue.isEmpty()) {
			while (!txQueue.isEmpty()) {
				// Lets read all the messages in txQueue and send

				PayloadData payloadData = txQueue.poll();

				if (logger.isDebugEnabled()) {
					logger.debug(String.format("Tx : Ass=%s %s", this.name, payloadData));
				}

				if (this.ipChannelType == IpChannelType.SCTP) {
					int seqControl = payloadData.getStreamNumber();

					if (seqControl < 0 || seqControl >= this.associationHandler.getMaxOutboundStreams()) {
						try {
							// TODO : calling in same Thread. Is this ok? or
							// dangerous?
							this.associationListener.inValidStreamId(payloadData);
						} catch (Exception e) {

						}
						
						continue;
					}

					msgInfo = MessageInfo.createOutgoing(this.peerSocketAddress, seqControl);
					msgInfo.payloadProtocolID(payloadData.getPayloadProtocolId());
					msgInfo.complete(payloadData.isComplete());
					msgInfo.unordered(payloadData.isUnordered());
				}

				try
				{
					this.doSend(payloadData.getByteBuf());
				}
				finally {
					payloadData.releaseBuffer();
				}					

			}// end of while
		}

		if (txQueue.isEmpty()) {
			// We wrote away all data, so we're no longer interested
			// in writing on this socket. Switch back to waiting for
			// data.
			key.interestOps(SelectionKey.OP_READ);
		}

	} catch (IOException e) {
		this.ioErrors++;
		logger.error(String.format(
				"IOException while trying to write to underlying socket for Association=%s IOError count=%d",
				this.name, this.ioErrors), e);

		if (this.ioErrors > this.management.getMaxIOErrors()) {
			// Close this socket
			this.close();

			// retry to connect after delay
			this.scheduleConnect();
		}
	}// try-catch
}

private int doSend(ByteBuf buffer) throws IOException {
	if (this.ipChannelType == IpChannelType.SCTP)
		return this.doSendSctp(buffer);
	else
		return this.doSendTcp(buffer);
}

private int doSendSctp(ByteBuf buffer) throws IOException {
	return this.socketChannelSctp.send(buffer.nioBuffer(), msgInfo);
}

private int doSendTcp(ByteBuf buffer) throws IOException {
	return this.socketChannelTcp.write(buffer.nioBuffer());
}

You can see that the write method calls doSend() but ignores the return value. From what I could see the socket is configured in non blocking mode. In this case where the underlying output buffer is full the SctpChannel.send() method would return 0 indicating no bytes of the message were written. However the write() method doesn't check the return value and just assumes that the message was sent successfully (i.e. message not sent and therefore lost).

Replace NIO with Netty

SCTP uses NIO code based on threading module. Its best to switch to Netty instead of managing this low level code.

How to specify secondaryServerAddress for symmetric multipath

When using the client association, how is the secondaryPath peer address configured?

Is it configured on the server and relayed through the SCTP handshake?

Is the implication of that, the primary peer address must be available for the association to get up?

Persistance parameter issues

We need to split a general parameters set into 2 subsets:

  1. parameters that can not be updated when Stack is started
  2. parameters that can be updated when Stack is started

For SCTP stack parameters are:

  1. singleThread, workerThreads
  2. connectDelay

For parameters 1) we need:

  • do not store parameters into xml file
  • remove from CLI / GUI updating for this parameters
  • update manual that we need to setup these paramters in jboss-beans.xml or by invoke of setters before stack start
  • throw Exception if a setter has been invoked when Stack is running

For parameters 2) we need:

  • update manual that we need to setup these paramters either by CLI / GUI or by invoke of setters after stack start
  • throw Exception if a setter has been invoked when Stack is NOT running

Setting singleThread boolean to false yields excessive System.out junk log output.

What steps will reproduce the problem?
1. Call setSingleThread (true) on ManagementImpl
2. Start a normal traffic


What is the expected output? What do you see instead?

While using single thread, no junk logs are observed but when the worker 
threads activated, below log is written;
......
2012.09.04 14:21:43:796 payload.getStreamNumber()=11 
this.workerThreadTable[payload.getStreamNumber()]3
2012.09.04 14:21:43:796 payload.getStreamNumber()=16 
this.workerThreadTable[payload.getStreamNumber()]0
2012.09.04 14:21:43:800 payload.getStreamNumber()=12 
this.workerThreadTable[payload.getStreamNumber()]4
2012.09.04 14:21:43:808 payload.getStreamNumber()=13 
this.workerThreadTable[payload.getStreamNumber()]5
2012.09.04 14:21:43:808 payload.getStreamNumber()=14 
this.workerThreadTable[payload.getStreamNumber()]6
2012.09.04 14:21:43:810 payload.getStreamNumber()=9 
this.workerThreadTable[payload.getStreamNumber()]1
2012.09.04 14:21:43:814 payload.getStreamNumber()=15 
this.workerThreadTable[payload.getStreamNumber()]7
......


What version of the product are you using? On what operating system?

Using latest version of sctp on RHEL 5 OS


Please provide any additional information below.

Issue is; Instead of using logger functionality, this below code is used which 
should be changed in AssociationImpl class;

System.out.println("payload.getStreamNumber()=" + payload.getStreamNumber() + " 
this.workerThreadTable[payload.getStreamNumber()]"

Original issue reported on code.google.com by [email protected] on 4 Sep 2012 at 11:38

Adding congestion control into SCTP stack for outgouing messages

We need to add public int getCongestionLevel(); method into "Association" interface.
For this we need to check the outgoing buffer size and the time between of an outgoing message buffering and the time a message has sent.

CongestionLevel has 3 levels: 0 (no cong) and 1-3 (congestion, more value means more cong level == more message delivering time).

SCTP socket lingers in CLOSE state for RHEL/CentOS

When the SCTP socket was closed via management "m3ua asp stop XXX" and then 
started again "m3ua asp start XXX" the SCTP socket was not created and "netstat 
-pan | grep sctp" will show something like

sctp 3368 602439 X.X.X.X:2905 X.X.X.X:2905 CLOSE

Little more investigation and it turns out to be OS issue :( 
https://access.redhat.com/knowledge/solutions/56433.

There was issue with RHEL OS kernel version before kernel-2.6.32-220.el6.

The other option is set SO_LINGER in Sctp Socket 
http://docs.oracle.com/javase/7/docs/jre/api/nio/sctp/spec/com/sun/nio/sctp/Sctp
StandardSocketOptions.html#SO_LINGER

But from that link, it says its for socket configured for blocking mode only, 
while ours is non-blocking mode. 

Original issue reported on code.google.com by [email protected] on 13 Mar 2013 at 7:12

Support for anonymous connections

Currently the SCTP library does not support dynamic anonymous connections.  To 
incorporate this functionality into the Mobicents Diameter stack this 
functionality is required.

After having a good look at this we think that the best way to extend the SCTP 
library to allow for anonymous client connections is as follows:

    Create a ServerListener framework where the SCTP library can inform an application if an anonymous remote incoming connection has been received - it is not compulsory to add this listener when using an SCTP server.  If it is not added then all anonymous connections will be ignored.
    Allow serverAssociation of 0.0.0.0:0 to be added as wildcard (edit ManagementImpl.java to allow port of 0)
    In SelectorThread.java - doAccept - If there is an association with 0.0.0.0:0 and an attached serverListener then we trigger a newRemoteConnection event on the ServerListener  and pass all the necessary information to the calling application.  The application can then decide whether to ignore and close the socket or create and add a new serverAssociation and Listener for this and attach to the socket. 
    Note that several params had to be made public to allow the calling application to create a new association and attach to the socket - including the Selector parameter in SelectorThread.java and setSocketChannel method in AssocationImpl.java,

This may sound a little clumsy - but because the AssociationListener class can 
only be instantiated and added from the calling application we think this is 
the cleanest option - and so far it seems to work!

Original mail thread is at:
https://groups.google.com/group/mobicents-public/browse_thread/thread/ddb1d3c31d
b62c0a?pli=1

Original issue is with Diameter project at:
http://code.google.com/p/mobicents/issues/detail?id=3056

Patch is attached.

Original issue reported on code.google.com by [email protected] on 11 Jun 2012 at 3:41

Attachments:

mobicents-public › org.mobicents.protocols.sctp.AssociationImpl : peerSocketAddress always null

Hello group,

Recently i pached JVM source code in order to add support for SCTP to Mac OSX operating systems and this effort succeed.
All thinks worked find but i have to patch org.mobicents.protocols.sctp.AssociationImpl (sctp protocol package) file as follows:

public AssociationImpl(String hostAddress, int hostPort, String peerAddress, int peerPort, String assocName,
IpChannelType ipChannelType, String[] extraHostAddresses) throws IOException {

this();
this.hostAddress = hostAddress;
this.hostPort = hostPort;
this.peerAddress = peerAddress;
this.peerPort = peerPort;
this.name = assocName;
this.ipChannelType = ipChannelType;
this.extraHostAddresses = extraHostAddresses;

// This never initialised, why ?
this.peerSocketAddress = new InetSocketAddress(peerAddress, peerPort);

this.type = AssociationType.CLIENT;

}

Is there any special reason why this.peerSocketAddress isnt initialised anywhere? Having this value as null caused problematic MessageInfo, as a result the native stack returned "Invalid Value" exceptions. With this simple patch, SCTP is working fine even in OSX.

Im asking just to verify if i misunderstood something or not regarding this.peerSocketAddress param.

Greetings

Add support for anonymous connection

As of now when server Association is added, it needs to provision the ip:port 
from where to accept connection.

Diameter project wants to have SCTP Server accept connection from any ip:port.

Original issue reported on code.google.com by [email protected] on 11 Jun 2012 at 3:41

  • Merged into: #2

Support for SCTP connection parameters (SocketChannelConfig)

We need to add configuring of SCTP connection parameters.
The list of options:
https://docs.oracle.com/javase/7/docs/jre/api/nio/sctp/spec/com/sun/nio/sctp/SctpStandardSocketOptions.html
http://netty.io/4.0/api/io/netty/channel/socket/SocketChannelConfig.html
The priority option is SO_SNDBUF.

I suggest to make these options stack level. (Althow we can do them Asociation level (for CLIENT Associations) and Server level.)

There is also a method SctpChannel.supportedOptions() for cheking of Channel supported options. It is needed when Association / Server start - to log (INFO level) supported and configured options for a channel to observe.

I think this issues will cover a workaround for the issue #6

Adding of configuring for TxSending buffer for non-netty version

We need to add into "ManagementImpl" setters txBufferSize and rxBufferSize (default values are as now 8192 bytes).
These values will then be used by non-netty versions of AssociationImpl
private ByteBuffer rxBuffer = ByteBuffer.allocateDirect(8192);
private ByteBuffer txBuffer = ByteBuffer.allocateDirect(8192);

Expose SCTP statistics

Expose following statistics from stack

Total bytes sent
Total bytes received 

Total bytes sent per association
Total bytes received per association

Number of times association went down since starting the server. If management 
brings down association this is not counted as down status. This counter is 
only for error condition.

Original issue reported on code.google.com by [email protected] on 25 Sep 2012 at 3:25

netty not connecting

I have a problem that when I use the ManagementImpl, the association goes up, but when using netty, nothing happen. Can anyone help me?
I have traces for the two scenarios between a client and a server. They are attached.

non-netty.zip
netty.zip

Modifying of server / association parameters

We need to have a possibility to modify SCTP server / association instanses by implementing of new methods:

Management.modifyServer(String serverName, String hostAddress, int port, IpChannelType ipChannelType, boolean acceptAnonymousConnections, int maxConcurrentConnectionsCount, String[] extraHostAddresses) throws Exception;

Management.modifyServerAssociation(String assocName, String peerAddress, int peerPort, String serverName, IpChannelType ipChannelType) throws Exception;

Management.modifyAssociation(String assocName, String hostAddress, int hostPort, String peerAddress, int peerPort, IpChannelType ipChannelType, String[] extraHostAddresses) throws Exception;

For a server we need to check if server is stopped (we can change server paramters only if a server is stopped)

For an Association we may update association parameters even if Association is started (and connected) - this is a demand of SS7 stack implemention. If an Association is connected we drop the connection firstly. Then the Association will reconnect itself, for this in client association case we need to check if a reconnection is scheduled.

SCTP invalid stream identifier on response

Environment
SCTP 2.0.18

Scenario
The stack is used to serve a diameter "server" stack (jDiameter). The remote node is requesting following stream setup during INIT:
Number of outbound streams: 17 Number of inbound streams: 17
Our response in the INIT_ACK:
Number of outbound streams: 10 Number of inbound streams: 17
Diameter CER/CEA is exchanged successfully and association/peer is considered open.

Expected result
Association should be remain available.

Actual result
After 10 (remote originated) messages the remote stack drops the association (SCTP ABORT). The reason is that our application stops responding to diameter the keep-alive request (Device-Watchdog-Request) because the SCTP stack refuses to send out a packet using stream ID 10.

It seems that the remote node considers SID 10 to be valid but our SCTP doesn't? The check in question is found in org.mobicents.protocols.sctp.AssociationImpl.java:625.

Docs: update for configuring of parameters SCTP stack

After the update: #8
we need to update the chapter "4.1.2. Configuration"

  1. "setConnectDelay": add at the end: "This parameter can be updated only at the SCTP stack running time, including GUI"
  2. in both "setWorkerThreads" and "setSingleThread" add into the end "This parameter can be updated only when the SCTP stack has not yet run".

Enable/Disable configuration persistance

I think it is reasonable to add into each SCTP stack an extra setter via which we can force not to store / load parameters. For backword compatibility this option must have a default value "perfom of storing/loading config data".

Like this:
void setAvoidConfigUsage(boolean val);
boolean getAvoidConfigUsage();

SCTP Association keeps Payload in buffer and doesn't clean when closing socket

SCTP Association keeps adding PayloadData in TxQueue even though the underlying 
socket is not established.

Also when Socket is closed, it keeps data in buffer and tries to send next time 
when socket is established.



2013-03-11 18:58:08,865 DEBUG [org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM] 
(pool-19-thread-1) FSM.name=ASPSTP2_LOCAL old state=UP_SENT, current 
state=UP_SENT Transition to=timeout
2013-03-11 18:58:08,865 DEBUG [org.mobicents.protocols.sctp.AssociationImpl] 
(Thread-17) Tx : Ass=SCTPAssoSTP2 PayloadData [dataLength=16, complete=true, 
unordered=true, payloadProtocolId=3, streamNumber=0, data=
Start: 0 (0x00)  End: 15 (0x0F)  Length: 16 (0x10)
00: 01 00 03 01 00 00 00 10  00 11 00 08 00 00 00 03 | ........ ........ 
]
2013-03-11 18:58:10,413 DEBUG [org.mobicents.protocols.sctp.AssociationImpl] 
(Thread-17) Rx : Ass=SCTPAssoSTP2 PayloadData [dataLength=8, complete=true, 
unordered=false, payloadProtocolId=3, streamNumber=0, data=
Start: 0 (0x00)  End: 7 (0x07)  Length: 8 (0x08)
00: 01 00 03 01 00 00 00 08  -- -- -- -- -- -- -- -- | ........          
]
2013-03-11 18:58:10,414 DEBUG [org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM] 
(Thread-17) FSM.name=ASPSTP2_PEER old state=INACTIVE, current state=INACTIVE 
Transition to=aspup
2013-03-11 18:58:10,414 DEBUG [org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM] 
(Thread-17) FSM.name=AS2_LOCAL old state=INACTIVE, current state=INACTIVE 
Transition to=aspup
2013-03-11 18:58:10,414 DEBUG [org.mobicents.protocols.sctp.AssociationImpl] 
(Thread-17) Tx : Ass=SCTPAssoSTP2 PayloadData [dataLength=8, complete=true, 
unordered=true, payloadProtocolId=3, streamNumber=0, data=
Start: 0 (0x00)  End: 7 (0x07)  Length: 8 (0x08)
00: 01 00 03 04 00 00 00 08  -- -- -- -- -- -- -- -- | ........          
]
2013-03-11 18:58:10,414 DEBUG [org.mobicents.protocols.sctp.AssociationImpl] 
(Thread-17) Tx : Ass=SCTPAssoSTP2 PayloadData [dataLength=16, complete=true, 
unordered=true, payloadProtocolId=3, streamNumber=0, data=
Start: 0 (0x00)  End: 15 (0x0F)  Length: 16 (0x10)
00: 01 00 00 01 00 00 00 10  00 0D 00 08 00 01 00 02 | ........ ........ 
]
2013-03-11 18:58:11,365 DEBUG [org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM] 
(pool-19-thread-1) FSM.name=ASPSTP2_LOCAL old state=UP_SENT, current 
state=UP_SENT Transition to=timeout
2013-03-11 18:58:13,865 DEBUG [org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM] 
(pool-19-thread-1) FSM.name=ASPSTP2_LOCAL old state=UP_SENT, current 
state=UP_SENT Transition to=timeout
2013-03-11 18:58:16,365 DEBUG [org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM] 
(pool-19-thread-1) FSM.name=ASPSTP2_LOCAL old state=UP_SENT, current 
state=UP_SENT Transition to=timeout
2013-03-11 18:58:18,865 DEBUG [org.mobicents.protocols.ss7.m3ua.impl.fsm.FSM] 
(pool-19-thread-1) FSM.name=ASPSTP2_LOCAL old state=UP_SENT, current 
state=UP_SENT Transition to=timeout

Original issue reported on code.google.com by [email protected] on 12 Mar 2013 at 12:35

Support for one-to-many type SCTP sockets

Most client SCTP associations share the same local port number so the Mobicents SCTP implementation has to be extended to be able to use one-to-many type SCTP sockets.

The New implementation package

We decided to create a separate implementation package because for the following reasons:

· The semantics of the one-to-one and the one-to-many type SCTP sockets are quite different.

· We decided not to implement the whole functionality of the SCTP API:

o Our target infrastructure does not use server type SCTP association by design so it is decided that the new implementation won’t support server type associations (note: it was more like an “economical decision” and is quite possible that we will also implement server functionality in the future).

o supporting TCP connections is out of scope of our interest

The new SCTP API implementation package is named to org.mobicents.protocol.sctp.multiclient.

Init process of one-to-many SCTP connections

The init procedure of the one-to-one and one-to-many like SCTP sockets (channels) are different. The main difference is that there is no connect operation for SctpMultiChannel. Associations of an SctpMultiChannel is initialized by sending the first DATA message. The lack of connect operation poses the following problems:

· Some features of the API depends on connect operation. For example when a link is going down a reconnect sequence is started in order to bring back the association automatically as soon as possible.

· In the our target environment where JSs7 stack is used on the top of the SCTP layer higher level layers do not send any payload through an association until the association notifies its listeners that it is connected.

· In our development it is a very important directive no to change the existing SCTP API which could not be avoided if the initiation processes of the two type of SCTP channel are different

As a solution for this particular problem a special connect method is implemented for the One-to-many like associations. In this method the association send a „dummy” DATA message to the remote peer which implies the correct association initialization on SCTP level. By default the dummy message is an empty DATA chunk, but it can be set using the setInitPayloadData(…) method of MultiManagementImpl class.

SCTP configuration persistence

The Mobicents SCTP and JSs7 libraries have their own solutions for persisting their configurations. This feature of the libraries is undesirable in our target environment, because our system has its own solution for configuration management which makes this feature redundant. Therefore a new Boolean type system property switch: “ss7.disableDefaultConfigPersistance” is introduced. Setting this property value to “true” the configuration persistence feature of the SCTP library can be switched off.

Association branching

SCTP multiclient package provides two type of association. These are the branched (or one-to-one) and the not-branched (or one-to-many) type associations. Branching means that the association is peeled off the multichannel socket to a separate socketChannel which is backed by a separate fd on kernel level. The new channel and the multichannel will share the same selector and selector thread. The advantage off this branched mode that the one-to-one association can be managed separately from the other association. It can be stopped and started on SCTP level (sending SHUTDOWN and INIT messages). While on SCTP level one-to-many association can shutdown only altogether by closing the multiSocketChannel (which handles all one-to-many associations of a same local ip- port address).

The branching feature is controlled at stack level not per association basis, so it is more like an operational mode of the stack. In branching mode all one-to-many like associations are peeled off to a separate one-to-one like association after the association is initialized, while in non-branching mode no association is ever branched.

By default multiclient SCTP stack is in branching mode, but it can be modified by a new Boolean type system property: “sctp.enableBranching”.

These are the main features and limitations of our line of work on this library.

I’d like to ask you to consider if our work described above (in any form) is worth to be “pulled” in the original Mobicents SCTP project. If you need more details please contact me.

Thank you for your time.

Best Regards,

Gábor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.