Kcptun - A UDP Tunnel Based on KCP Protocol - Converting TCP Streams to KCP+UDP to Stream IPTV
Suited for applications with low latency and high speed requirements, it is reputed to double the transmission efficiency X2+.
Target
Accelerating end-to-end remote transmission (point-to-point p2p transmission, encapsulating TCP data as UDP KCP data) through UDP tunneling.
Kcptun is a simple and fast UDP tunnel based on the KCP protocol, capable of converting TCP streams to KCP+UDP streams.
Application
Simple deployment and configuration.
Here’s an example:
- A certain application on a remote/distant client needs to access a specific TCP service within the server’s network segment (such as a game or IPTV).
- By launching the kcptun client on the remote client’s router#1 (listening on a local port and then specifying the server’s IP and port, along with encryption information), this kcptun client’s listening port becomes the port the local application will use to connect.
- Connect to the specific kcp server (listening on the server’s port and then specifying the destination TCP service [IP address and port]) through the server (forwarded from router#2’s port).
- This encrypted and encapsulated entire chain is established over UDP, purportedly doubling transmission efficiency X2+.
Below are two examples of using docker for kcptun applications.
Practical Example 1:
https://hub.docker.com/r/lowid/kcptun
If the service to be encapsulated is a SOCKS proxy on the server:
Server side (kcp+socks) compose file
1 | kcp-server: |
Server side sockd.conf
1 | debug: 0 |
Client side compose file
1 | client: |
Practical Example 2:
1 | $ docker pull chenhw2/kcptun |
Related Content
Implementation Approach
Abandoning the docker approach.
KCP Server:
1 | ./server_linux_amd64 -t "192.168.6.243:8012" -l ":29900" -mode fast3 -nocomp -dscp 46 --key op.carlzeng.com --crypt salsa20 |
Explanatory note: Because this service on port 29900 is configured on a specific server (not on the main router’s public IP), it requires port mapping on the main router’s public IP (i.e., to forward external 29900 UDP data to the same port on this specific server).
1 | Configuration in Padavan interface on K2P |
A comprehensive diagram of the entire process

A peculiar testing method was used to play through frp to another location;
Testing experience: High definition is very smooth, 4K still experiences some lag;
TODO: Waiting for the next step to test local area network playback on the client side after KCP transmission.
After such KCP transmission, as per reports, the transmission latency is halved, and the speed is doubled X2+; awaiting further practical testing to verify.
Source of Inspiration
[Tutorial, project address: https://github.com/xtaci/kcptun/](