RTTP Stub SDK
To avoid modifying existing application clients, client integration can be simplified by integrating the RTTP Stub SDK.
RTTP Stub SDK is a lightweight client integration library that establishes a local TCP proxy on the client. The application client simply points its connection to the local proxy port, and the SDK automatically forwards data via the RTTP protocol to the remote RTTP server or RTTP Proxy.
How It Works
RTTP Stub SDK acts as a local bridge between the application client and the RTTP network:
- The SDK listens on a specified TCP port locally (e.g.,
127.0.0.1:10080). - The application client (e.g., game client, app) connects to this local port instead of directly connecting to the remote server.
- Upon receiving a TCP connection, the SDK immediately initiates an RTTP connection to the remote RTTP node.
- The SDK performs bidirectional transparent transmission between the local TCP connection and the remote RTTP connection.
[Application Client] <---- TCP (127.0.0.1) ----> [RTTP Stub SDK] <---- RTTP (UDP) ----> [RTTP-integrated Application Server]
[Application Client] <---- TCP (127.0.0.1) ----> [RTTP Stub SDK] <---- RTTP (UDP) ----> [RTTP Proxy] <---- TCP ----> [Application Server]
Key Features
- Zero-Code Modification: Application clients only need to update the connection IP and port, without changing core network communication logic.
- Cross-Platform Support: Provides a cross-platform SDK.
- Multi-Link Mapping: Supports simultaneous configuration of multiple port mappings for complex application requirements.
- Status Monitoring: Built-in status statistics capability, allowing export of connection status and detailed logs in JSON format.
- Network Resilience: Significantly improves transmission stability in environments with packet loss and latency jitter through the underlying RTTP protocol.
API Description
RTTP Stub provides a concise C language interface:
Core Interfaces
| Function | Description |
|---|---|
rt_stub_init() | Initializes the SDK and starts the underlying RTTP engine. |
rt_stub_add_map(local_port, remote_host, remote_port) | Adds a port mapping. Maps a local TCP port to a remote RTTP target. |
rt_stub_start() | Starts the service thread and begins processing network events. |
rt_stub_stop() | Stops the service and closes all connections. |
rt_stub_uninit() | Releases SDK resources. |
Auxiliary Interfaces
| Function | Description |
|---|---|
rt_stub_get_state(buffer, size) | Retrieves the statistical status of all current connections (JSON format). |
rt_stub_read_log(buffer, size) | Reads the latest running logs from the circular buffer. |
Usage Example (C++)
#include "rttp_stub.h"
int main() {
// 1. Initialization
rt_stub_init();
// 2. Configure mapping: Map local port 10080 to remote server port 9000
rt_stub_add_map(10080, "47.100.x.x", 9000);
// 3. Start service
rt_stub_start();
// At this point, the application client can connect to 127.0.0.1:10080 for communication
// ... Running ...
// 4. Stop and release
rt_stub_stop();
rt_stub_uninit();
return 0;
}
Integration
- Local Integration: The RTTP Stub SDK should be integrated directly into the application client process or run as a local sidecar process.