gnirehtet icon indicating copy to clipboard operation
gnirehtet copied to clipboard

increase speed or packet size?

Open captainscf opened this issue 2 years ago • 1 comments

Hi, first of all, thank you for scrcpy, I just realize they're from the same team.

I'm trying to get Moonlight to run smoothly on my tablet via USB-C from my PC. Connecting via Android tethering yielded 210Mbps to PC, 340Mbps from PC While using gnirehtet, I only got 80Mbps to PC, 130Mbps from PC I then try use gigabit ethernet for my tablet and it did reach 900Mbps to and from PC.

The reason I'm asking if the speed can be increased is because I wanted to maximize the USB-C 3.0 5Gbps bandwidth, I know 5Gbps is theoretical, but it should be able to communicate above 1Gbps, faster than gigabit ethernet. Using adb push pull some files, it reached average of 1116Mbps analyzed from Wireshark USBpcap, the packet sizes are 1048603 bytes with adb push/pull, with gnirehtet the packet sizes are only up to ~60000 bytes

Anything I should try to improve the bandwidth/speed? Thank you for the support.

captainscf avatar Nov 25 '23 07:11 captainscf

Key Bottlenecks in Gnirehtet: Uses ADB Reverse TCP — which adds overhead and limits throughput

No ADB multiplexing or bulk transfer — only a simple TCP tunnel

VPN layer adds latency — and runs in user-space Java (non-native)

No USB 3.0 parallelism — ADB doesn't automatically scale with cable capability

Small packet sizes — typical MTU ~1500; you observed 60 KB with gnirehtet vs 1 MB with ADB file transfer

What You Can Try to Boost Speed

  1. Use --tun mode (native support) instead of VPN-over-TCP If you're using a custom build or patched version of gnirehtet: t gnirehtet run --tun This uses a lower-level native TUN interface (not Java VPN API), which is faster — but may require root or different Android versions.

Status: Not in the official version — needs to be compiled manually

  1. Increase buffer size on the relay Ty launching gnirehtet with increased read/write buffer settings.

Edit the relay Java source:

private static final int BUFFER_SIZE = 1024 * 1024; // 1 MB instead of default 64 KB This allows larger chunks of data per read/write, reducing ADB overhead.

Status: Requires recompiling relay-java with this tweak

  1. Use ADB over TCP instead of USB Surprisingly, some users have reported higher throughput via Wi-Fi ADB (especially over 5 GHz):

adb tcpip 5555 adb connect <device_ip> Then run gnirehtet normally.

Speeds may still vary depending on Wi-Fi router quality and congestion.

  1. Switch to native USB tethering for Moonlight For apps like Moonlight, where latency and bandwidth are key, using native USB tethering (RNDIS or Ethernet gadget) is far superior:

Android gets a real IP on PC

Lower latency (no VPN, no ADB)

Higher throughput (~300–400 Mbps reliably)

Go to:

Settings → Hotspot & Tethering → USB Tethering Pair with firewall rules or dnsmasq to route the PC internet correctly.

  1. Use Ethernet-over-USB gadget mode (rooted or custom ROM) Advanced option:

Root your Android tablet

Use it as a USB Ethernet device (e.g., with g_ether, g_cdc)

Allows full duplex, ~800–1000 Mbps speeds

🔧 Custom ROMs or Linux deploy environments can do this.

VaradGupta23 avatar Jul 07 '25 12:07 VaradGupta23