I am looking to create my own version of TOR, and to do that I need to understand the way that relay, directory servers and clients communicate. but after reading Tor: The Second-Generation Onion Router I was left with some questions about the cell structure:

  • what is CircID and what is it's purpose?
  • what is StreamID and what is it's purpose?
  • what is Relay? (the one shown in the cell picture below)

visual overview of cell structure plus the details of relay cell structure

1 Answer 1


In simple words:

  • CircID serves the purpose to separate the circuits = onion 3-node chains. As it described in design - I'm citing: The header includes a circuit identifier (circID) that specifies which circuit the cell refers to (many circuits can be multiplexed over the single TLS connection), and a com- mand to describe what to do with the cell’s payload.
  • StreamID serves the purpose for separating streams inside the circuits - it's handy when you're connecting to different exit nodes through one middle node, for example. It's described in the design here, but it's not that straightforward if you haven't seen the code and played with it - I was making my Tor version too - the document says: Relay cells have an additional header (the relay header) at the front of the payload, containing a streamID (stream iden- tifier: many streams can be multiplexed over a circuit);
  • Relay is an operation code, i.e. "what exactly should be done with the data portion annotated" - see the part 4.1 in the design draft and the code itself if you'll have command-specific questions

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .