You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit efbba01
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: anyproxy.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,7 @@ func init() {
100
100
flag.StringVar(&gSendVia, "via", nat.ViaDirect, "-send/-recv: \"direct\" (punch through NAT, fails closed if no path), \"relay\" (through the server B, no punching needed), or the email of a public VPS (needs directRelay enabled) to blindly relay the NAT punch through -- for when the two peers cannot punch to each other directly (e.g. both behind CGNAT) but can each reach that VPS; the QUIC/TLS session still ends end-to-end between the two peers, the VPS only forwards opaque UDP packets. All are end-to-end encrypted. See docs/direct-relay-design.md. -wol: the subscriber's email who should broadcast instead of this machine, default (\"direct\") means broadcast locally")
101
101
102
102
flag.StringVar(&gRecv, "recv", "", "Fetch a file or directory from another subscriber and exit, scp-style EMAIL:PATH (PATH is relative to that peer's websocket.client.receive.dir, and this machine must already be listed in its receive.allow)")
103
-
flag.IntVar(&gParallel, "parallel", 1, "-send/-recv: split each large file into up to N chunks and transfer them over N concurrent connections (default 1, today's single-connection behavior); small files are never split")
103
+
flag.IntVar(&gParallel, "parallel", 1, "-send/-recv: split each large file into up to N chunks and transfer them over N concurrent connections (default 1, today's single-connection behavior); small files are never split. N is capped at 4 regardless of what's passed -- independent connections beyond that stop paying off and start hurting NAT punch reliability. -via direct/VPS: each connection is its own independently NAT-punched QUIC connection with its own congestion window, which is the point -- a single QUIC flow on a lossy path can get stuck with a small window no matter how large the file is, and a few independent flows recover the throughput a lossy path is actually capable of. -via relay: chunks are still concurrent logical sessions but multiplexed over the one already-open connection to the server, so this mainly helps by overlapping round-trips rather than opening more raw connections")
104
104
flag.StringVar(&gConflict, "conflict", "", "-send/-recv: what to do about a same-name file or a leftover .part from an interrupted transfer. MODE is one of: ask (interactive, default on a terminal), rename (save under a new name, no probing; default when stdin is not a terminal), overwrite, skip, or resume (continue a matching .part automatically; skip if the name already holds an identical file, else save under a new name). Only MODE=ask additionally prompts at the terminal: for a same-name file, [r]ename/[o]verwrite(if identical)/[s]kip; for a matching .part, [c]ontinue/[r]estart/[s]kip -- those letters are answers to that prompt, not values for -conflict itself")
105
105
flag.BoolVar(&gDirectPlainUDP, "direct-plain-udp", false, "direct (NAT punch) connections: skip quic-go's batched/ECN fast path for the UDP socket, always falling back to plain per-packet I/O. Try this if a direct transfer shows high loss and a congestion window stuck near its floor even on an otherwise healthy link -- on some machines (seen on Windows, likely a NIC driver/virtual adapter quirk) that fast path itself corrupts or delays packets, which quic-go then mistakes for congestion. Unlike -debug, this does not log every packet, so it's fine to leave on")
Copy file name to clipboardExpand all lines: docs/en/websocket.md
+13-9Lines changed: 13 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -464,23 +464,25 @@ Troubleshooting: with `-debug 2`, quic-go prints `connection doesn't allow setti
464
464
465
465
#### Single large file chunked parallel transfer: `-parallel N`
466
466
467
-
By default each file occupies only one connection (one QUIC stream on `direct`, one relay session on `relay`), which is enough when a single connection's throughput already fills the link, but insufficient when limited by the single-stream congestion window climb or the relay flow-control window — the "single connection" ceiling. `-parallel N` (default 1) splits a **single** large file into at most `N` chunks by byte range, each opening an independent connection for parallel transfer. Both paths (`-via direct`/`-via relay`) and both directions (`-send`/`-recv`) are supported:
467
+
By default each file occupies only one connection (one independently NAT-punched QUIC connection on `direct`/VPS blind-relay, one relay session on `relay`), which is enough when a single connection's throughput already fills the link, but insufficient when limited by the single-stream congestion window climb or the relay flow-control window — the "single connection" ceiling. `-parallel N` (default 1, hard-capped at 4 — anything higher is clamped down to 4) splits a **single** large file into at most `N` chunks for parallel transfer. Both paths (`-via direct`/VPS, `-via relay`) and both directions (`-send`/`-recv`) are supported:
- **Only splits a single file, no multi-file concurrency**. Batch `-send`/`-recv` of multiple files still transfers one after another — the purpose of chunked parallelism is to let a single large file use the bandwidth faster, not to let multiple files compete for the same bandwidth (that would actually lengthen each file's time).
475
-
- **Files too small are not split**: files below 8MiB always take the single-connection path, the `-parallel` value is ignored, since the chunking handshake/header overhead isn't worth it on small files.
476
-
- **Failure semantics identical to no-chunk**: if any chunk fails (network error, verification failure) the whole file errors out and the `.part` file is cleaned up, leaving no half-done file with only some chunks right, and no auto-retry.
475
+
- **Files too small are not split**: files below 8MiB always take the single-connection path, the `-parallel` value is ignored, since the chunking handshake/header overhead isn't worth it on small files. Chunk count doesn't keep growing with file size either — it tops out at 4 (for files 16MiB and up); a multi-gigabyte file still only splits into 4, not more.
476
+
- **Failure semantics identical to no-chunk, but tolerant of partial connection failure**: on `-via direct`/VPS, as long as at least 1 of the `N` independent connections punches through, the transfer proceeds on whichever ones succeeded (a few candidate paths not working is normal and shouldn't fail the whole transfer). Once connections are up, any chunk transfer failure (network error, verification failure) still errors out the whole file and cleans up the `.part` file — no half-done file, no auto-retry.
477
477
- **On `-via relay`, each chunk negotiates its own encryption session** (independent random salt, independently derived AES-256-GCM key); the protocol has long supported "open a new encryption session anytime", so no handshake change is needed for chunking.
478
+
- **The progress line now shows each connection's own instantaneous rate** (`conn1: ... conn2: ...`), so you can tell if one connection is dragging behind the others.
478
479
479
-
##### `-parallel` does not always speed up: understand the bottleneck first
480
+
##### Whether `-parallel` actually opens multiple connections differs by path
480
481
481
-
**Chunking uses the same underlying connection** — on `direct`, the N chunks are N streams on the same QUIC connection; on `relay`, they are N relay sessions on the same websocket (same TCP connection). QUIC/TCP congestion control is computed per **connection**, not per stream/session, meaning these N concurrent paths share the same congestion window and look like **the same five-tuple** (same pair of source/dest IP+port) to network devices. If the bottleneck is operator per-flow rate limiting, or the link itself is congested with packet loss, `-parallel` in this same-connection-multiplexed implementation most likely won't help — the operator still sees "one flow", and won't allocate more bandwidth just because the app opened a few more streams.
482
+
- **`-via direct`/`-via a VPS's email` (blind-relayed punch): genuinely independent QUIC connections.** Each chunk runs its own punch handshake and QUIC handshake, ending up with a fully independent connection that maintains its own congestion window — that's the whole point: on a link with random packet loss, a single QUIC flow's congestion window can get stuck repeatedly pinned low (a real measured case: cwnd stuck around 5~14KB with ~5% loss, throughput ≈ cwnd/RTT), while several independent connections each maintain their own window and the aggregate throughput can recover close to linearly — the same principle multi-threaded download managers rely on. The local UDP socket is still shared (no extra local ports needed), but the QUIC connections themselves, and the bindings on the VPS blind-relay side, are each independent.
483
+
- **`-via relay` (through server B): still the same underlying connection.** The N chunks are N relay sessions on the same websocket (same TCP connection); QUIC/TCP congestion control is computed per **connection**, so these N concurrent paths share the same congestion window and look like the same five-tuple to network devices. If the bottleneck is operator per-flow rate limiting or link congestion, `-parallel` on the `relay` path most likely won't help; it truly helps when a single relay session's own flow-control window fills before the network bandwidth does, or when the bottleneck is actually CPU (hashing, encryption/decryption). To get genuinely independent multiple connections, switch to `-via direct` or `-via a VPS's email`.
482
484
483
-
The scenarios where `-parallel` truly helps are when a single stream/relay session's own flow-control window (not congestion window) fills before the network bandwidth — e.g. a single stream's window is too small on a high-latency long-distance link, or the bottleneck is actually CPU (hashing, encryption/decryption) rather than network. These two cases benefit from multiple concurrent paths; if the bottleneck is poor operator cross-network interconnection quality or per-flow/per-account rate limiting, opening more won't help.
485
+
##### Use `iperf3` to diagnose the bottleneck first, especially for `-via relay`
484
486
485
487
**Use `iperf3` to diagnose before relying on feeling** (assuming A transfers slowly, C is the receiving machine, and the two can reach each other):
486
488
@@ -508,9 +510,11 @@ Reading the results:
508
510
509
511
| Phenomenon | Conclusion |
510
512
|---|---|
511
-
| Single stream slow, multi-stream (`-P 4`) `[SUM]` much higher than single | per-flow rate limiting / single-stream window can't fill, `-parallel` is worth using |
512
-
| Single stream slow, multi-stream `[SUM]` about the same, high packet loss | link itself congested (common with poor operator cross-network interconnection quality), `-parallel` has limited benefit |
513
-
| TCP results ok, UDP noticeably worse | operator may have separately limited UDP; even reshaping into multiple independent QUIC connections may not help, consider switching to `-via relay` (TCP websocket) to bypass |
513
+
| Single stream slow, multi-stream (`-P 4`) `[SUM]` much higher than single | per-flow rate limiting / single-stream window can't fill, `-parallel` is worth using (especially under `-via direct`/VPS, since those connections really are independent) |
514
+
| Single stream slow, multi-stream `[SUM]` about the same, high packet loss | link itself congested (common with poor operator cross-network interconnection quality); independent flows each still eat their own share of the loss so this can't be fully bypassed, `-parallel` has limited benefit but is usually still somewhat better than a single stream (see the QUIC cwnd/loss stats under `-check`) |
515
+
| TCP results ok, UDP noticeably worse | operator may have separately limited UDP; `-via direct`/VPS rides QUIC/UDP, so multiple independent connections may not help either — consider switching to `-via relay` (TCP websocket) to bypass |
516
+
517
+
With `-via direct`/VPS, adding `-debug 2` during transfer shows each connection's own `quic cwnd=... inflight=... sent=...pkt lost=...pkt`, plus a summary line at the end (no `-debug` needed for that one) — this is more direct than iperf3 since it reflects the actual connection this transfer is using, not an inference from a separate speed test.
514
518
515
519
### TCP and UDP: two protocols carried differently on QUIC
0 commit comments