Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCTP over DTLS over UDP for client-server communication #6

Open
cnudroid opened this issue Oct 21, 2020 · 6 comments
Open

SCTP over DTLS over UDP for client-server communication #6

cnudroid opened this issue Oct 21, 2020 · 6 comments

Comments

@cnudroid
Copy link

I have a use case where I want to establish a java client-server communication via SCTP over DTLS over UDP similar to webrtc data channel.
This library looks promising.
I want to use it with java 11 and netty eventually.
Can you please provide some pointers?

@steely-glint
Copy link
Member

steely-glint commented Oct 22, 2020

Ok, for the full webRTC datachannel you'll need 4 things:

  1. ICE (I use https://github.com/steely-glint/slice but Jitsi's ICE4J works too)
  2. DTLS (I use Bouncy castle - Java11 has DTLS built in, but I've never investigated it)
  3. SCTP (I use this lib)
  4. SDP layer that manages offer-answer and orchestrates the first 3 - ours is proprietary

I haven't looked at netty for a while, but this SCTP library needs to be able to create threads - so you may have to do some work to fit that into netty's view of the world.

If you are rolling your own SCTP over DTLS protocol then you may not need 1 and 4 which would make things a lot simpler.

@cnudroid
Copy link
Author

Thanks for your inputs @steely-glint.
I need to establish a client-server channel to transfer data and wanted to use SCTP over UDP instead of TCP.
I am thinking we can use DTLS from bountycastle and for SCTP will use this library.
Do we really need ICE and SDP layer?

@steely-glint
Copy link
Member

No, you only need SDP if you want to interop with webRTC.

You only need ICE if you have NAT or other problems with network topology.

This stack calls it self a SCTP stack, but the API does assume webRTC datachannel -
so instead of plain SCTP streams, you get labeled streams with names as in webRTC.

@cnudroid
Copy link
Author

Here is an update:

  • I created a standalone client-server DTLS communication

  • I then passed the DTLSTransport to this library by using ThreadAssocationTest class as a reference.

  • I could transfer the message between the client and the server.

As far so good till I tried to send data of larger lengths. With large data, I am getting the following error

DTLS server raised alert: fatal(2), internal_error(80)

@steely-glint my understanding is that when we send data which is larger than MTU, the sctp protocol will break them into multiple data chunks and transfer. Please correct me if I got this wrong.

@steely-glint
Copy link
Member

If you look at ThreadAssocationTest you can see that it tests sending and receiving large messages, which the stack breaks up into datachunks that are smaller than the DTLS MTU.
It definitely sounds like the MTU isn't getting passed up to sctp correctly.

If you add
Log.setLevel(Log.VERB);
to your program and attach the output I can probably figure out what is happening.

@cnudroid
Copy link
Author

cnudroid commented Oct 28, 2020

Thanks @steely-glint
The issue is that the getCapacity of DataChunk is hardcoded to 1024 and my DTLSTransport MTU is coming as 383.
Things started working after changing the value of getCapacity to 256.

The system mtu shows 1500. Not sure why the Dtlstransport is returning it as 383. Currently checking it. Will keep you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants