@decentnetwork/peer 0.1.75 → 0.1.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,7 +105,7 @@ const CWND_MIN_CHUNKS = 8; // ~11 KB floor — keeps a slow/flaky path's buffer
105
105
  // ~0.5s of added latency keeps ping well under a second (fine — the peer stays
106
106
  // usable), and buys far more throughput on a jittery path than a tight 150ms
107
107
  // bound, which collapsed the window to the floor (~17 KB/s observed on lili).
108
- const MAX_QUEUE_MS = 350; // raw-queue ceiling before draining (bulk transfer tolerates ~0.35s added latency)
108
+ const MAX_QUEUE_MS = 350; // raw-queue ceiling before draining (bulk transfer tolerates ~0.35s added latency; a tighter bound collapses the window on a 40%-loss path where recovery makes RTT noisy)
109
109
  const QUEUE_LOW_MS = 150; // grow while the smoothed (jitter-free) queue is under this
110
110
  const VEGAS_GROW = 1.25; // window ×this per RTT when under-filled
111
111
  const VEGAS_SHRINK = 0.8; // window ×this per RTT when the queue is too deep
@@ -674,12 +674,8 @@ export class FileTransferManager {
674
674
  if (st.srttMs < st.minSrttMs)
675
675
  st.minSrttMs = st.srttMs;
676
676
  // Hybrid signal, so per-packet JITTER doesn't masquerade as a queue:
677
- // • GROW on the SMOOTHED queue (srtt − minSrtt): jitter averages out,
678
- // so a flaky path that isn't really queuing keeps growing instead
679
- // of collapsing to the floor (~17 KB/s observed on lili).
680
- // • SHRINK on the RAW queue (rtt − minRtt) against a higher ceiling:
681
- // fast reaction to genuine bufferbloat, but the ceiling sits above
682
- // the jitter band so a lone jittery sample doesn't trigger it.
677
+ // • GROW on the SMOOTHED queue (srtt − minSrtt): jitter averages out.
678
+ // SHRINK on the RAW queue (rtt minRtt) against a higher ceiling.
683
679
  const smoothQueue = st.minSrttMs !== Infinity ? st.srttMs - st.minSrttMs : 0;
684
680
  const rawQueue = st.minRttMs !== Infinity ? rtt - st.minRttMs : 0;
685
681
  if (rawQueue > MAX_QUEUE_MS) {
@@ -695,11 +691,16 @@ export class FileTransferManager {
695
691
  this.emit("file-progress", { friendId, fileId: hex(st.fileId), received: st.acked, total: st.size, sending: true });
696
692
  }
697
693
  }
698
- else if (maxRecv > st.acked + MAX_FILE_DATA_SIZE && nowMs() - st.lastResendMs >= FAST_RT_MIN_MS) {
699
- // Duplicate ack WITH a gap the chunk at `acked` was lost. Rewind the send
700
- // cursor to the ack point so the loop re-sends the hole (rate-limited to
701
- // ~1 RTT so dup-ack bursts for one loss don't storm). No window backoff:
702
- // file-path loss is treated as random, not congestion.
694
+ else if (maxRecv > st.acked + Math.max(4, st.cwnd >> 2) * MAX_FILE_DATA_SIZE && nowMs() - st.lastResendMs >= FAST_RT_MIN_MS) {
695
+ // Duplicate ack WITH a gap bigger than the REORDER window (≈¼ of the flight)
696
+ // the chunk at `acked` is genuinely lost, not just reordered. Requiring a
697
+ // real gap is what unlocked throughput on jittery GFW paths: a 1-chunk
698
+ // trigger fired constantly on per-packet jitter (packets arrive out of
699
+ // order), each firing a go-back-N rewind that re-sent bytes the receiver
700
+ // already had and pinned the window near the floor. Now FEC repairs the
701
+ // occasional true hole locally, so waiting a few chunks before retransmit
702
+ // costs nothing. Rewind the send cursor to the hole (rate-limited to ~1 RTT
703
+ // so a dup-ack burst can't storm). No window backoff: loss ≠ congestion.
703
704
  st.lastResendMs = nowMs();
704
705
  st.lastLossMs = nowMs(); // the path is lossy → turn adaptive FEC on
705
706
  if (st.nextSend > st.acked)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/peer",
3
- "version": "0.1.75",
3
+ "version": "0.1.76",
4
4
  "description": "Pure TypeScript port of Elastos Carrier (toxcore-derived) P2P messaging. DHT, onion routing, TCP relay, FlatBuffers app payloads, Express offline relay. Wire-compatible with iOS Beagle and the Carrier C SDK.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",