From c96c9ec5909d64fe020d7630f3fd982bc18fd06a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 4 Sep 2023 22:34:29 +1000 Subject: [PATCH] yamux: document stream ACK backlog (#547) Co-authored-by: Marten Seemann --- yamux/README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/yamux/README.md b/yamux/README.md index efab67b57..f6a4b45fa 100644 --- a/yamux/README.md +++ b/yamux/README.md @@ -152,8 +152,19 @@ The Length should be set to one of the following to provide an error code: ## Implementation considerations -### ACK backlog +### ACK backlog & backpressure Yamux allows for a stream to be opened (and used) before it is acknowledged by the remote. +Yamux also does not specify a backpressure mechanism for opening new streams. + +This presents a problem: +A peer must read from the socket and decode the frames to make progress on existing streams. +But any frame could also open yet another stream. + The ACK backlog is defined as the number of streams that a peer has opened which have not yet been acknowledged. -Implementations SHOULD at most allow an ACK backlog of 256 streams. +To support a basic form of backpressure, implementions: + +- SHOULD at most allow an ACK backlog of 256 streams. +- MAY buffer unacknowledged inbound streams instead of resetting them when the application currently cannot handle any more streams. + Such a buffer MUST be bounded in size to mitigate DoS attacks. +- MAY delay acknowledging new streams until the application has received or is about to send the first DATA frame.