DEV Community

Ai2th
Ai2th

Posted on

Linxr | Part 8 — Fixing Network Latency & SLIRP Terminal Slowness

In earlier parts of our series, we covered SSH terminals, Docker integration, and storage passthrough. Today in Part 8, we share the deep network engineering required to fix terminal latency and optimize SLIRP user-mode networking in QEMU on Android.


The Symptom: Terminal Typing Lag

During initial testing, typing commands in the SSH terminal tab felt slightly delayed. Keystrokes would buffer for 100–300ms before rendering on screen.

When investigating with tcpdump and socket trace tools, we discovered the root cause:

  1. QEMU SLIRP User-Mode Stack: SLIRP runs entirely in user-space inside the Android process sandbox (no TAP/TUN devices without root).
  2. Nagle’s Algorithm & Socket Buffering: Small SSH keystroke packets (1 byte) were being delayed by socket buffering mechanisms looking to coalesce small TCP frames.

The Fix: TCP_NODELAY & Virtio-Net Tuning

To eliminate typing latency:

  • Disabling Nagle's Algorithm: Forced TCP_NODELAY on local SSH port forwards (port 2222) and local proxy bridges.
  • Virtio-Net MTU Configuration: Tuned guest network interface MTU to 1500 with checksum offloading disabled to reduce guest-to-host packet fragmentation.

The result? Keystroke response times dropped from 250ms to under 15ms, delivering a desktop-grade shell experience on phone screens.


Download & Links

Top comments (0)