Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

SCTP Ping-Pong Application

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.

Features

  • 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

Dependencies

System Requirements

Ubuntu/Debian:

sudo apt-get update
sudo apt-get install libsctp-dev libsctp1 lksctp-tools

Red Hat/CentOS/Fedora:

sudo yum install lksctp-tools-devel lksctp-tools
# or for newer versions:
sudo dnf install lksctp-tools-devel lksctp-tools

macOS:

# SCTP support on macOS is limited - consider using Docker with Linux
brew install sctp

Python Dependencies

Install the Python SCTP library:

pip install pysctp

Or if using a virtual environment:

python -m venv sctp_env
source sctp_env/bin/activate  # On Windows: sctp_env\Scripts\activate
pip install pysctp

Installation

  1. Clone or download the application files:

    • sctp_server.py - SCTP server implementation
    • sctp_client.py - SCTP client implementation
  2. Install dependencies (see Dependencies section above)

  3. Make scripts executable (optional):

    chmod +x sctp_server.py sctp_client.py

Usage

Starting the Server

python3 sctp_server.py

Expected 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
...

Starting the Client

In a separate terminal:

python3 sctp_client.py

Expected 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
...

Configuration

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)

How It Works

SCTP Multi-Streaming

Unlike TCP, SCTP supports multiple independent streams within a single association. This application demonstrates:

  1. Stream Independence: Messages on different streams can arrive out of order
  2. Stream Preservation: Responses are sent back on the same stream as the request
  3. Concurrent Communication: Multiple streams operate simultaneously

Message Flow

  1. Client connects to server and negotiates 5 streams
  2. Client sends ping-N messages rotating through streams 0-4
  3. Server receives messages and responds with pong-N on the same stream
  4. Process continues indefinitely until interrupted

Key SCTP Features Demonstrated

  • 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

Troubleshooting

Common Issues

"No module named 'sctp'"

pip install pysctp

About

A simple python client - server SCTP ping pong example using 5 streams / channels

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages