JunkWire
Function: Improve the usability of bad networks.
UDP disguises as TCP: reduces QoS after masquerading as TCP
Multiple servers can be configured, automatic disconnection, reconnection and server change, no upper layer awareness: heartbeat detection, sending 5 heartbeat packets per second. If all five heartbeat packets are lost, switch to the next server. It can be completed in 2 seconds.
Optional FEC forward error correction: 20 original packets plus 10 error correction packets can reduce the packet loss rate to one ten thousandth.
Interleaving coding: can evenly spread the packet loss concentrated in a short period of time to prevent both original packets and error correction packets from being lost.
Configuration method
Junkwire uses tun devices for data transmission, so first make sure that the operating environment supports tun devices. After running, a tun device called faketcp will be created. The IP address of this device can be configured through the configuration file. Generally, it can be written as 10.1.1.1, as long as it does not conflict with your local network environment. After running, a network device 10.1.1.2 will be virtualized.
Server configuration
First, configure the server DNAT to forward the packets of the corresponding port to junkwire for processing.
First enable ipv4 forwarding, add net.ipv4.ip_forward=1 to the /etc/sysctl.conf file and then run sysctl -p to make it take effect.
Add iptables rules iptables -t nat -A PREROUTING -i network card name -d network card IP -p tcp --dport 17021 (client connection port) -j DNAT --to-destination 10.1.1.2:17021
Wireguard configuration example, change according to actual situation
[Interface]
Address = 10.200.201.1/24
ListenPort = 21007
#ListenPort = 12273
PrivateKey = xxx
MTU = 1340
[Peer]
PublicKey = xxx
AllowedIPs = 10.200.201.2/32
PersistentKeepalive = 25
Server-side junkwire configuration file example
{
"mode": "server",
"queue":500,
"server": {
"tun": {
"deviceIP": "10.1.1.1",
"port": "17021",
"srcIP": "10.1.1.2"
},
"socket": {
"dstIP": "127.0.0.1",
"dstPort": "21007"
}
},
"fec": {
"enable":false, //是否启用fec
"seg": 20, //几个数据包
"parity": 20, //几个纠错包
"duration":0, //交织编码的时长
"stageTimeout":8, //桶没装满的话最长等多久
"cap":500,
"row":1000
}
}
Start junkwire ./junkwire -c configuration file
Start wireguard wg-quick up wg0
Client configuration
The client needs to allow the data of virtual device 10.1.1.2 to be sent smoothly, and snat is required.
iptables -t nat -A POSTROUTING -s 10.1.1.2 -p tcp -o eth0 -j SNAT --to-source local network card ip
Routing configuration to prevent export IP from being brought into wireguard
ip route add server ip/32 via local gateway dev eth0
wireguard configuration
[Interface]
Address = 10.200.201.2/24
PrivateKey = yJAu/oI+Oo/Mhswqbm3I/3PWYi+WSxX7JpTQ8IoQqWU=
MTU = 1340
[Peer]
PublicKey = 5/SgVv3hc3f5Fa/XoLo4isBzyrwwATs5sfQv7oWhiTM=
Endpoint = 127.0.0.1:21007
AllowedIPs = 0.0.0.0/1,128.0.0.0/1
PersistentKeepalive = 25
junkwire configuration example
{
"mode": "client",
"queue":500,
"client": {
"tun": {
"deviceIP": "10.1.1.1",
"port": "8978",
"srcIP": "10.1.1.2",
"peers": [
{
"ip":"线路1",
"port":"50018"
},
{
"ip":"线路2",
"port":"17021"
},
{
"ip":"线路3",
"port":"17021"
}
]
},
"socket": {
"listenPort": "21007"
}
},
"fec": {
"enable":false,
"seg": 20,
"parity": 10,
"stageTimeout": 8,
"duration": 0,
"cap": 500,
"row": 1000
}
}
Start junkwire ./junkwire -c configuration file
Start wireguard wg-quick up wg0