137-bootstrap-phases.txt 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. Filename: 137-bootstrap-phases.txt
  2. Title: Keep controllers informed as Tor bootstraps
  3. Version: $Revision$
  4. Last-Modified: $Date$
  5. Author: Roger Dingledine
  6. Created: 07-Jun-2008
  7. Status: Open
  8. 1. Overview.
  9. Tor has many steps to bootstrapping directory information and
  10. initial circuits, but from the controller's perspective we just have
  11. a coarse-grained "CIRCUIT_ESTABLISHED" status event. Tor users with
  12. slow connections or with connectivity problems can wait a long time
  13. staring at the yellow onion, wondering if it will ever change color.
  14. This proposal describes a new client status event so Tor can give
  15. more details to the controller. Section 2 describes the changes to the
  16. controller protocol; Section 3 describes Tor's internal bootstrapping
  17. phases when everything is going correctly; Section 4 describes when
  18. Tor detects a problem and issues a bootstrap warning; Section 5 covers
  19. suggestions for how controllers should display the results.
  20. 2. Controller event syntax.
  21. The generic status event is:
  22. "650" SP StatusType SP StatusSeverity SP StatusAction
  23. [SP StatusArguments] CRLF
  24. So in this case we send
  25. 650 STATUS_CLIENT NOTICE/WARN BOOTSTRAP \
  26. PROGRESS=num TAG=string SUMMARY=string WARNING=string REASON=string
  27. "Progress" gives a number between 0 and 100 for how far through
  28. the bootstrapping process we are. "Summary" is a string that can be
  29. displayed to the user to describe the *next* task that Tor will tackle,
  30. i.e., the task it is working on after sending the status event. "Tag"
  31. is an optional string that controllers can use to recognize bootstrap
  32. phases from Section 3, if they want to do something smarter than just
  33. blindly displaying the summary string.
  34. The severity describes whether this is a normal bootstrap phase
  35. (severity notice) or an indication of a bootstrapping problem
  36. (severity warn). If severity warn, it should also include a "warning"
  37. argument string with any hints Tor has to offer about why it's having
  38. troubles bootstrapping, and a "reason" string that lists of the reasons
  39. allowed in the ORConn event.
  40. 3. The bootstrap phases.
  41. This section describes the various phases currently reported by
  42. Tor. Controllers should not assume that the percentages and tags listed
  43. here will continue to match up, or even that the tags will stay in
  44. the same order. Some phases might also be skipped (not reported) if the
  45. associated bootstrap step is already complete.
  46. Phase 0:
  47. tag=starting summary="starting"
  48. Tor starts out in this phase.
  49. Phase 5:
  50. tag=conn_dir summary="Connecting to directory mirror"
  51. Tor sends this event as soon as Tor has chosen a directory mirror ---
  52. one of the authorities if bootstrapping for the first time or after
  53. a long downtime, or one of the relays listed in its cached directory
  54. information otherwise.
  55. Tor will stay at this phase until it has successfully established
  56. a TCP connection with some directory mirror. Problems in this phase
  57. generally happen because Tor doesn't have a network connection, or
  58. because the local firewall is dropping SYN packets.
  59. Phase 10
  60. tag=handshake_dir summary="Finishing handshake with directory mirror"
  61. This event occurs when Tor establishes a TCP connection with a relay
  62. (or its https proxy if it's using one). Tor remains in this phase until
  63. the TLS handshake with the relay is finished.
  64. Problems in this phase generally happen because Tor's firewall is
  65. doing more sophisticated MITM attacks on it, or doing packet-level
  66. keyword recognition of Tor's handshake.
  67. Phase 15:
  68. tag=onehop_create summary="Establishing one-hop circuit for dir info"
  69. Once TLS is finished with a relay, Tor will send a CREATE_FAST cell
  70. to establish a one-hop circuit for retrieving directory information.
  71. It will remain in this phase until it receives the CREATED_FAST cell
  72. back, indicating that the circuit is ready.
  73. Phase 20:
  74. tag=requesting_status summary="Asking for networkstatus consensus"
  75. Once we've finished our one-hop circuit, we will start a new stream
  76. for fetching the networkstatus consensus. We'll stay in this phase
  77. until we get the 'connected' relay cell back, indicating that we've
  78. established a directory connection.
  79. Phase 25:
  80. tag=loading_status summary="Loading networkstatus consensus"
  81. Once we've established a directory connection, we will start fetching
  82. the networkstatus consensus document. This could take a while; this
  83. phase is a good opportunity for using the "progress" keyword to indicate
  84. partial progress.
  85. This phase could stall if the directory mirror we picked doesn't
  86. have a copy of the networkstatus consensus so we have to ask another,
  87. or it does give us a copy but we don't find it valid.
  88. Phase 40:
  89. tag=loading_keys summary="Loading authority key certs"
  90. Sometimes when we've finished loading the networkstatus consensus,
  91. we find that we don't have all the authority key certificates for the
  92. keys that signed the consensus. At that point we put the consensus we
  93. fetched on hold and fetch the keys so we can verify the signatures.
  94. Phase 45
  95. tag=requesting_descriptors summary="Asking for relay descriptors"
  96. Once we have a valid networkstatus consensus and we've checked all
  97. its signatures, we start asking for relay descriptors. We stay in this
  98. phase until we have received a 'connected' relay cell in response to
  99. a request for descriptors.
  100. Phase 50:
  101. tag=loading_descriptors summary="Loading relay descriptors"
  102. We will ask for relay descriptors from several different locations,
  103. so this step will probably make up the bulk of the bootstrapping,
  104. especially for users with slow connections. We stay in this phase until
  105. we have descriptors for at least 1/4 of the usable relays listed in
  106. the networkstatus consensus. This phase is also a good opportunity to
  107. use the "progress" keyword to indicate partial steps.
  108. Phase 80:
  109. tag=conn_or summary="Connecting to entry guard"
  110. Once we have a valid consensus and enough relay descriptors, we choose
  111. some entry guards and start trying to build some circuits. This step
  112. is similar to the "conn_dir" phase above; the only difference is
  113. the context.
  114. If a Tor starts with enough recent cached directory information,
  115. its first bootstrap status event will be for the conn_or phase.
  116. Phase 85:
  117. tag=handshake_or summary="Finishing handshake with entry guard"
  118. This phase is similar to the "handshake_dir" phase, but it gets reached
  119. if we finish a TCP connection to a Tor relay and we have already reached
  120. the "conn_or" phase. We'll stay in this phase until we complete a TLS
  121. handshake with a Tor relay.
  122. Phase 90:
  123. tag=circuit_create "Establishing circuits"
  124. Once we've finished our TLS handshake with an entry guard, we will
  125. set about trying to make some 3-hop circuits in case we need them soon.
  126. Phase 100:
  127. tag=done summary="Done"
  128. A full 3-hop circuit has been established. Tor is ready to handle
  129. application connections now.
  130. 4. Bootstrap problem events.
  131. When an OR Conn fails, we send a "bootstrap problem" status event, which
  132. is like the standard bootstrap status event except with severity warn.
  133. We include the same progress, tag, and summary values as we would for
  134. a normal bootstrap event, but we also include 'warning' and 'reason'
  135. strings.
  136. The reason string is the same argument as the reason string for ORCONN
  137. failure events; the controller can recognize the various reasons
  138. and help the user accordingly. The warning string currently tries to
  139. provide the equivalent of strerror() -- this isn't very useful if the
  140. controller can recognize reason tags and be smarter, but for a very
  141. simple controller it should be better than nothing.
  142. Currently Tor ignores the first nine bootstrap problem reports for
  143. a given phase, reports the tenth to the controller, and then ignores
  144. further problems at that phase. Hopefully this is a good balance between
  145. tolerating occasional errors and reporting serious problems quickly. (We
  146. will want to revisit this approach if there are many different 'reason'
  147. values being reported among the first ten problem reports, since in
  148. this case the controller will only hear one of them.)
  149. 5. Suggested controller behavior.
  150. Controllers should start out with a yellow onion or the equivalent
  151. ("starting"), and then watch for either a bootstrap status event
  152. (meaning the Tor they're using is sufficiently new to produce them,
  153. and they should load up the progress bar or whatever they plan to use
  154. to indicate progress) or a circuit_established status event (meaning
  155. bootstrapping is finished).
  156. In addition to a progress bar in the display, controllers should also
  157. have some way to indicate progress even when no controller window is
  158. open. For example, folks using Tor Browser Bundle in hostile Internet
  159. cafes don't want a big splashy screen up. One way to let the user keep
  160. informed of progress in a more subtle way is to change the task tray
  161. icon and/or tooltip string as more bootstrap events come in.
  162. Controllers should also have some mechanism to alert their user when
  163. bootstrapping problems are reported. Perhaps we should gather a set of
  164. help texts and the controller can send the user to the right anchor in a
  165. "bootstrapping problems" help page?
  166. 6. Getting up to speed when the controller connects.
  167. There's a new "GETINFO /status/bootstrap-phase" option, which returns
  168. the most recent bootstrap phase status event sent. Specifically,
  169. it returns a string starting with either "NOTICE BOOTSTRAP ..." or
  170. "WARN BOOTSTRAP ...".
  171. Controllers should use this getinfo when they connect or attach to
  172. Tor to learn its current state.