137-bootstrap-phases.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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: Finished
  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=Keyword SUMMARY=String \
  27. [WARNING=String REASON=Keyword COUNT=num RECOMMENDATION=Keyword]
  28. The arguments MAY appear in any order. Controllers MUST accept unrecognized
  29. arguments.
  30. "Progress" gives a number between 0 and 100 for how far through
  31. the bootstrapping process we are. "Summary" is a string that can be
  32. displayed to the user to describe the *next* task that Tor will tackle,
  33. i.e., the task it is working on after sending the status event. "Tag"
  34. is an optional string that controllers can use to recognize bootstrap
  35. phases from Section 3, if they want to do something smarter than just
  36. blindly displaying the summary string.
  37. The severity describes whether this is a normal bootstrap phase
  38. (severity notice) or an indication of a bootstrapping problem
  39. (severity warn). If severity warn, it should also include a "warning"
  40. argument string with any hints Tor has to offer about why it's having
  41. troubles bootstrapping, a "reason" string that lists one of the reasons
  42. allowed in the ORConn event, a "count" number that tells how many
  43. bootstrap problems there have been so far at this phase, and a
  44. "recommendation" keyword to indicate how the controller ought to react.
  45. 3. The bootstrap phases.
  46. This section describes the various phases currently reported by
  47. Tor. Controllers should not assume that the percentages and tags listed
  48. here will continue to match up, or even that the tags will stay in
  49. the same order. Some phases might also be skipped (not reported) if the
  50. associated bootstrap step is already complete, or if the phase no longer
  51. is necessary. Only "starting" and "done" are guaranteed to exist in all
  52. future versions.
  53. Current Tor versions enter these phases in order, monotonically;
  54. future Tors MAY revisit earlier stages.
  55. Phase 0:
  56. tag=starting summary="starting"
  57. Tor starts out in this phase.
  58. Phase 5:
  59. tag=conn_dir summary="Connecting to directory mirror"
  60. Tor sends this event as soon as Tor has chosen a directory mirror ---
  61. one of the authorities if bootstrapping for the first time or after
  62. a long downtime, or one of the relays listed in its cached directory
  63. information otherwise.
  64. Tor will stay at this phase until it has successfully established
  65. a TCP connection with some directory mirror. Problems in this phase
  66. generally happen because Tor doesn't have a network connection, or
  67. because the local firewall is dropping SYN packets.
  68. Phase 10
  69. tag=handshake_dir summary="Finishing handshake with directory mirror"
  70. This event occurs when Tor establishes a TCP connection with a relay used
  71. as a directory mirror (or its https proxy if it's using one). Tor remains
  72. in this phase until the TLS handshake with the relay is finished.
  73. Problems in this phase generally happen because Tor's firewall is
  74. doing more sophisticated MITM attacks on it, or doing packet-level
  75. keyword recognition of Tor's handshake.
  76. Phase 15:
  77. tag=onehop_create summary="Establishing one-hop circuit for dir info"
  78. Once TLS is finished with a relay, Tor will send a CREATE_FAST cell
  79. to establish a one-hop circuit for retrieving directory information.
  80. It will remain in this phase until it receives the CREATED_FAST cell
  81. back, indicating that the circuit is ready.
  82. Phase 20:
  83. tag=requesting_status summary="Asking for networkstatus consensus"
  84. Once we've finished our one-hop circuit, we will start a new stream
  85. for fetching the networkstatus consensus. We'll stay in this phase
  86. until we get the 'connected' relay cell back, indicating that we've
  87. established a directory connection.
  88. Phase 25:
  89. tag=loading_status summary="Loading networkstatus consensus"
  90. Once we've established a directory connection, we will start fetching
  91. the networkstatus consensus document. This could take a while; this
  92. phase is a good opportunity for using the "progress" keyword to indicate
  93. partial progress.
  94. This phase could stall if the directory mirror we picked doesn't
  95. have a copy of the networkstatus consensus so we have to ask another,
  96. or it does give us a copy but we don't find it valid.
  97. Phase 40:
  98. tag=loading_keys summary="Loading authority key certs"
  99. Sometimes when we've finished loading the networkstatus consensus,
  100. we find that we don't have all the authority key certificates for the
  101. keys that signed the consensus. At that point we put the consensus we
  102. fetched on hold and fetch the keys so we can verify the signatures.
  103. Phase 45
  104. tag=requesting_descriptors summary="Asking for relay descriptors"
  105. Once we have a valid networkstatus consensus and we've checked all
  106. its signatures, we start asking for relay descriptors. We stay in this
  107. phase until we have received a 'connected' relay cell in response to
  108. a request for descriptors.
  109. Phase 50:
  110. tag=loading_descriptors summary="Loading relay descriptors"
  111. We will ask for relay descriptors from several different locations,
  112. so this step will probably make up the bulk of the bootstrapping,
  113. especially for users with slow connections. We stay in this phase until
  114. we have descriptors for at least 1/4 of the usable relays listed in
  115. the networkstatus consensus. This phase is also a good opportunity to
  116. use the "progress" keyword to indicate partial steps.
  117. Phase 80:
  118. tag=conn_or summary="Connecting to entry guard"
  119. Once we have a valid consensus and enough relay descriptors, we choose
  120. some entry guards and start trying to build some circuits. This step
  121. is similar to the "conn_dir" phase above; the only difference is
  122. the context.
  123. If a Tor starts with enough recent cached directory information,
  124. its first bootstrap status event will be for the conn_or phase.
  125. Phase 85:
  126. tag=handshake_or summary="Finishing handshake with entry guard"
  127. This phase is similar to the "handshake_dir" phase, but it gets reached
  128. if we finish a TCP connection to a Tor relay and we have already reached
  129. the "conn_or" phase. We'll stay in this phase until we complete a TLS
  130. handshake with a Tor relay.
  131. Phase 90:
  132. tag=circuit_create "Establishing circuits"
  133. Once we've finished our TLS handshake with an entry guard, we will
  134. set about trying to make some 3-hop circuits in case we need them soon.
  135. Phase 100:
  136. tag=done summary="Done"
  137. A full 3-hop circuit has been established. Tor is ready to handle
  138. application connections now.
  139. 4. Bootstrap problem events.
  140. When an OR Conn fails, we send a "bootstrap problem" status event, which
  141. is like the standard bootstrap status event except with severity warn.
  142. We include the same progress, tag, and summary values as we would for
  143. a normal bootstrap event, but we also include "warning", "reason",
  144. "count", and "recommendation" key/value combos.
  145. The "reason" values are long-term-stable controller-facing tags to
  146. identify particular issues in a bootstrapping step. The warning
  147. strings, on the other hand, are human-readable. Controllers SHOULD
  148. NOT rely on the format of any warning string. Currently the possible
  149. values for "recommendation" are either "ignore" or "warn" -- if ignore,
  150. the controller can accumulate the string in a pile of problems to show
  151. the user if the user asks; if warn, the controller should alert the
  152. user that Tor is pretty sure there's a bootstrapping problem.
  153. Currently Tor uses recommendation=ignore for the first nine bootstrap
  154. problem reports for a given phase, and then uses recommendation=warn
  155. for subsequent problems at that phase. Hopefully this is a good
  156. balance between tolerating occasional errors and reporting serious
  157. problems quickly.
  158. 5. Suggested controller behavior.
  159. Controllers should start out with a yellow onion or the equivalent
  160. ("starting"), and then watch for either a bootstrap status event
  161. (meaning the Tor they're using is sufficiently new to produce them,
  162. and they should load up the progress bar or whatever they plan to use
  163. to indicate progress) or a circuit_established status event (meaning
  164. bootstrapping is finished).
  165. In addition to a progress bar in the display, controllers should also
  166. have some way to indicate progress even when no controller window is
  167. open. For example, folks using Tor Browser Bundle in hostile Internet
  168. cafes don't want a big splashy screen up. One way to let the user keep
  169. informed of progress in a more subtle way is to change the task tray
  170. icon and/or tooltip string as more bootstrap events come in.
  171. Controllers should also have some mechanism to alert their user when
  172. bootstrapping problems are reported. Perhaps we should gather a set of
  173. help texts and the controller can send the user to the right anchor in a
  174. "bootstrapping problems" page in the controller's help subsystem?
  175. 6. Getting up to speed when the controller connects.
  176. There's a new "GETINFO /status/bootstrap-phase" option, which returns
  177. the most recent bootstrap phase status event sent. Specifically,
  178. it returns a string starting with either "NOTICE BOOTSTRAP ..." or
  179. "WARN BOOTSTRAP ...".
  180. Controllers should use this getinfo when they connect or attach to
  181. Tor to learn its current state.