aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-06-19 23:23:35 +0000
committerNick Mathewson <nickm@torproject.org>2003-06-19 23:23:35 +0000
commitfba684586f5bc8662d618eb1b782426a22fb980c (patch)
tree3955588d4fd10639b5af23da0980cb253f83e8cd /doc
parent968d31162b685d8f9e53a46124d4d12cba81d8b4 (diff)
downloadtor-fba684586f5bc8662d618eb1b782426a22fb980c.tar
tor-fba684586f5bc8662d618eb1b782426a22fb980c.tar.gz
Add specification for half-open connections, modified from last week's
conversation enough to correspond to real TCP. svn:r338
Diffstat (limited to 'doc')
-rw-r--r--doc/tor-spec.txt44
1 files changed, 30 insertions, 14 deletions
diff --git a/doc/tor-spec.txt b/doc/tor-spec.txt
index e4637b851..6dcdc11ee 100644
--- a/doc/tor-spec.txt
+++ b/doc/tor-spec.txt
@@ -487,24 +487,40 @@ which reveals the downstream node.
cells, echo their contents to the corresponding TCP stream.
[XXX Mention zlib encoding. -NM]
-5.2. Closing connections
+5.2. Closing streams
[Note -- TCP streams can only be half-closed for reading. Our
Bickford's conversation was incorrect. -NM]
-
- When one side of the TCP stream is closed, the corresponding edge
- node sends a RELAY_END cell along the circuit; upon receiving a
- RELAY_END cell, the edge node closes its side of the corresponding
- TCP stream (by sending a FIN packet), but continues to accept and
- package incoming data until both sides of the TCP stream are
- closed. At that point, the edge node sends a second RELAY_END
- cell, and drops its record of the stream.
-
- For creation and handling of RELAY_EXTEND and RELAY_EXTENDED cells,
- see section 4. For creating and handling of RELAY_SENDME cells,
- see section 6.
-
+ Because TCP connections can be half-open, we follow an equivalent
+ to TCP's FIN/FIN-ACK/ACK protocol to close streams.
+
+ A exit conneection can have a TCP stream in one of three states:
+ 'OPEN', 'DONE_PACKAGING', and 'DONE_DELIVERING'. For the purposes
+ of modeling transitions, we treat 'CLOSED' as a fourth state,
+ although connections in this state are not, in fact, tracked by the
+ onion router.
+
+ A stream begins in the 'OPEN' state. Upon receiving a 'FIN' from
+ the corresponding TCP connection, the edge node sends a 'RELAY_END'
+ cell along the circuit and changes its state to 'DONE_PACKAGING'.
+ Upon receiving a 'RELAY_END' cell, an edge node sends a 'FIN' to
+ the corresponding TCP connection (e.g., by calling
+ shutdown(SHUT_WR)) and changing its state to 'DONE_DELIVERING'.
+
+ When a stream in already in 'DONE_DELIVERING' receives a 'FIN', it
+ also sends a 'RELAY_END' along the circuit, and changes its state
+ to 'CLOSED'. When a stream already in 'DONE_PACKAGING' receives a
+ 'RELAY_END' cell, it sends a 'FIN' and changes its state to
+ 'CLOSED'.
+
+ [Note: Please rename 'RELAY_END2'. :) -NM ]
+
+ If an edge node encounters an error on any stram, it sends a
+ 'RELAY_END2' cell along the circuit (if possible) and closes the
+ TCP connection immediately. If an edge node receives a
+ 'RELAY_END2' cell for any stream, it closes the TCP connection
+ completely, and sends nothing along the circuit.
6. Flow control