137-bootstrap-phases.txt 10 KB

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