sctp-echo - SCTP-over-UDP echo server/client for creating reliable tunnels over UDP.

git clone https://benconnors.ca/git-repos/sctp-echo

About | Log | Files | Refs

SCTP+UDP Echo Server/Client

This program uses the SCTP protocol tunneled over UDP to turn UDP into a reliable transport. The same program can be run in either server or client mode; in terms of behaviour, this is intended to be identical to

client: socat - UDP4:<remote ip>:<remote port>,sourceport=<local port>
server: socat UDP4-LISTEN:<local ip>:<local port> -

along with some access control on the server side should the client IP/port be known ahead of time. In particular, the server will accept only one (valid) connection and is intended to exit once the connection closes (how reliable this part is is unclear).

The usrsctp library is used rather than the built-in kernel SCTP implementation on FreeBSD/Linux/etc. because the kernel implementations are lazy with UDP encapsulation: the port used to send/recieve SCTP-over-UDP is set for the entire system (i.e. via sysctl) rather than per-connection as in usrsctp. This program is essentially a stripped down and merged version of the discard server included in the usrsctp library as an example.

Limitations

Currently, there is no timeout functionality on the server/client when no connection is made. This is typically not a problem on the server side: to connect to anything expecting a reliable transport typically involves a socat invocation, e.g.:

sctp_echo -s ... | socat -T 60 - TCP-CONNECT:...

would give it a timeout of 60 seconds of no data transferred.

The packets sent are not disguised as anything: they are very clearly SCTP tunneled over UDP; DPI firewalls are likely to block this.

Both of these could be resolved to a degree by implementing a very restricted subset of SCTP or some other protocol for making an unreliable link reliable, rather than relying on SCTP-over-UDP (and specifically usrsctp).

Requirements

  • Some sort of reasonable UNIX (FreeBSD, Linux, etc.)
  • C compiler
  • usrsctp

Building

These should be executed in the directory you found this file.

  1. (Optional) Run autoconf
  2. Run ./configure
  3. Run make

The echo server/client will be src/sctp_echo.

Usage

In server mode:

sctp_echo -s <local IP> <local UDP port> <local SCTP port> <remote IP> <remote SCTP port>

In client mode:

sctp_echo -c <local IP> <local UDP port> <local SCTP port> <remote IP> <remote UDP port> <remote SCTP port>
  • Local IP: the local IP address to connect from/listen on, generally only useful on the server side.
  • Local UDP port: the local UDP port to connect from/listen on.
  • Local SCTP port: the local SCTP port to connect from/listen on. This is never publically seen, since all communication over the network happens via the UDP ports. However, both server and client need to know the other's SCTP port since SCTP-over-UDP is designed to allow the UDP port to be used for multiple SCTP connections.
  • Remote IP: the remote IP to connect to/accept a connection from. Setting it to 0.0.0.0 on the server disables access control.
  • Remote UDP port (client only): the remote UDP port to connect to. On the server, usrsctp handles the remote UDP port transparently.
  • Remote SCTP port: the remote SCTP port to connect to/accept a connection from.