wangyu- / udp2raw

A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket,helps you Bypass UDP FireWalls(or Unstable UDP Environment)
MIT License
7.16k stars 1.16k forks source link

High packet loss after some time of using wireguard+udp2raw setup #538

Open LoveCPro opened 1 month ago

LoveCPro commented 1 month ago

Description:

I am experiencing significant packet loss after some time using the wireguard+udp2raw setup. Initially, there is no packet loss, but after a period (sometimes a few days, sometimes just an hour), packet loss starts to occur, reaching up to 50%. During this time, CPU and memory utilization remain low.When I restart the udp2raw client process, the packet loss stops temporarily, but it starts again after some time.

Previously, when using only WireGuard, I encountered tunnel interruptions specifically when transmitting HTTPS traffic. This issue was resolved by introducing udp2raw.

Expected Behavior:

The tunnel should maintain a stable connection with no packet loss.

Environment:

OS: [openwrt] cmd: client:[/usr/bin/udp2raw -c -l 127.0.0.1:1111 -r ${serverip}:1111 --raw-mode faketcp --cipher-mode xor --log-level 0 -a --wait-lock] server:[/usr/bin/udp2raw -s -l 0.0.0.0:1111 -r 127.0.0.1:1111 --raw-mode faketcp --cipher-mode xor]

Questions:

Are there any known methods to improve this situation? Could this issue be related to firewall settings, and if so, what steps can I take to investigate and resolve it?

wangyu- commented 1 month ago

Well this might be udp2raw bug. But this is (maybe more likely) caused by your ISP is pusnishing long-term connections.

Are there any known methods to improve this situation?

Currently udp2raw doesn't have packet loss monitoring feature.

What you can do is, monintor with your own script, and if the packet loss is considered "high", then you use the udp2raw's --fifo feature to tell udp2raw to re-dial a new connection.

image
wangyu- commented 1 month ago

the advantage of --fifo vs "restart udp2raw" is:

With fifo reconnect, your upper level udp connections will stay valid after reconnect, you traffic will only be interrupted by a few RTTs.

With restarting udp2raw, your wireguard will wait for timeout first, then re-establish a new connection. Traffic will be interrupted much longer.

LoveCPro commented 1 month ago

To minimize packet loss as much as possible, do you have any recommendations? I am not familiar with the --seq-mode parameter. Could you please explain if this parameter can help reduce packet loss? Any additional suggestions for optimizing the setup to avoid packet loss would be greatly appreciated.

wangyu- commented 1 month ago

You can try different --seq-mode and see, it might help or might not help. Cannot provide any guarantee.

If the packet loss is indeed caused by your ISP's qos strategy of punishing long-term connection, there is not many options you can do at your side.