A simple demonstration of SCTP (Stream Control Transmission Protocol) multi-streaming capabilities using Python. This application consists of a server and client that exchange ping-pong messages across multiple SCTP streams.
- Multi-stream SCTP communication: Uses 5 concurrent streams (0-4)
- Stream-aware messaging: Server responds on the same stream it receives messages
- Round-robin stream usage: Client cycles through streams 0-4 sequentially
- Real-time stream monitoring: Shows which stream each message is sent/received on
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install libsctp-dev libsctp1 lksctp-toolsRed Hat/CentOS/Fedora:
sudo yum install lksctp-tools-devel lksctp-tools
# or for newer versions:
sudo dnf install lksctp-tools-devel lksctp-toolsmacOS:
# SCTP support on macOS is limited - consider using Docker with Linux
brew install sctpInstall the Python SCTP library:
pip install pysctpOr if using a virtual environment:
python -m venv sctp_env
source sctp_env/bin/activate # On Windows: sctp_env\Scripts\activate
pip install pysctp-
Clone or download the application files:
sctp_server.py- SCTP server implementationsctp_client.py- SCTP client implementation
-
Install dependencies (see Dependencies section above)
-
Make scripts executable (optional):
chmod +x sctp_server.py sctp_client.py
python3 sctp_server.pyExpected output:
[Server] Configured for 5 streams
[Server] Listening on 127.0.0.1:5001
[Server] Connection from ('127.0.0.1', 43881)
[Server] Negotiated streams - Out: 5, In: 5
[Server] Received 'ping-0' on stream 0
[Server] Sent 'pong-0' on stream 0
[Server] Received 'ping-1' on stream 1
[Server] Sent 'pong-1' on stream 1
...
In a separate terminal:
python3 sctp_client.pyExpected output:
[Client] Configured for 5 streams
[Client] Connected to 127.0.0.1:5001
[Client] Sent 'ping-0' on stream 0
[Client] Received 'pong-0' on stream 0
[Client] Sent 'ping-1' on stream 1
[Client] Received 'pong-1' on stream 1
...
You can modify the following parameters in both files:
HOST = '127.0.0.1' # Server IP address
PORT = 5001 # Server port
NUM_STREAMS = 5 # Number of SCTP streams (1-65535)Unlike TCP, SCTP supports multiple independent streams within a single association. This application demonstrates:
- Stream Independence: Messages on different streams can arrive out of order
- Stream Preservation: Responses are sent back on the same stream as the request
- Concurrent Communication: Multiple streams operate simultaneously
- Client connects to server and negotiates 5 streams
- Client sends
ping-Nmessages rotating through streams 0-4 - Server receives messages and responds with
pong-Non the same stream - Process continues indefinitely until interrupted
- Association establishment with multiple streams
- Stream-specific message sending using
sctp_send(data, stream=N) - Stream information extraction from received messages
- Proper SCTP socket configuration for multi-streaming
"No module named 'sctp'"
pip install pysctp