137-bootstrap-phases.txt 10 KB

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