141-jit-sd-downloads.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. Filename: 141-jit-sd-downloads.txt
  2. Title: Download server descriptors on demand
  3. Author: Peter Palfrader
  4. Created: 15-Jun-2008
  5. Status: Draft
  6. 1. Overview
  7. Downloading all server descriptors is the most expensive part
  8. of bootstrapping a Tor client. These server descriptors currently
  9. amount to about 1.5 Megabytes of data, and this size will grow
  10. linearly with network size.
  11. Fetching all these server descriptors takes a long while for people
  12. behind slow network connections. It is also a considerable load on
  13. our network of directory mirrors.
  14. This document describes proposed changes to the Tor network and
  15. directory protocol so that clients will no longer need to download
  16. all server descriptors.
  17. These changes consist of moving load balancing information into
  18. network status documents, implementing a means to download server
  19. descriptors on demand in an anonymity-preserving way, and dealing
  20. with exit node selection.
  21. 2. What is in a server descriptor
  22. When a Tor client starts the first thing it will try to get is a
  23. current network status document: a consensus signed by a majority
  24. of directory authorities. This document is currently about 100
  25. Kilobytes in size, tho it will grow linearly with network size.
  26. This document lists all servers currently running on the network.
  27. The Tor client will then try to get a server descriptor for each
  28. of the running servers. All server descriptors currently amount
  29. to about 1.5 Megabytes of downloads.
  30. A Tor client learns several things about a server from its descriptor.
  31. Some of these it already learned from the network status document
  32. published by the authorities, but the server descriptor contains it
  33. again in a single statement signed by the server itself, not just by
  34. the directory authorities.
  35. Tor clients use the information from server descriptors for
  36. different purposes, which are considered in the following sections.
  37. #three ways: One, to determine if a server will be able to handle
  38. #this client's request; two, to actually communicate or use the server;
  39. #three, for load balancing decisions.
  40. #
  41. #These three points are considered in the following subsections.
  42. 2.1 Load balancing
  43. The Tor load balancing mechanism is quite complex in its details, but
  44. it has a simple goal: The more traffic a server can handle the more
  45. traffic it should get. That means the more traffic a server can
  46. handle the more likely a client will use it.
  47. For this purpose each server descriptor has bandwidth information
  48. which tries to convey a server's capacity to clients.
  49. Currently we weigh servers differently for different purposes. There
  50. is a weight for when we use a server as a guard node (our entry to the
  51. Tor network), there is one weight we assign servers for exit duties,
  52. and a third for when we need intermediate (middle) nodes.
  53. 2.2 Exit information
  54. When a Tor wants to exit to some resource on the internet it will
  55. build a circuit to an exit node that allows access to that resource's
  56. IP address and TCP Port.
  57. When building that circuit the client can make sure that the circuit
  58. ends at a server that will be able to fulfill the request because the
  59. client already learned of all the servers' exit policies from their
  60. descriptors.
  61. 2.3 Capability information
  62. Server descriptors contain information about the specific version of
  63. the Tor protocol they understand [proposal 105].
  64. Furthermore the server descriptor also contains the exact version of
  65. the Tor software that the server is running and some decisions are
  66. made based on the server version number (for instance a Tor client
  67. will only make conditional consensus requests [proposal 139] when
  68. talking to Tor servers version 0.2.1.1-alpha or later).
  69. 2.4 Contact/key information
  70. A server descriptor lists a server's IP address and TCP ports on which
  71. it accepts onion and directory connections. Furthermore it contains
  72. the onion key (a short lived RSA key to which clients encrypt CREATE
  73. cells).
  74. 2.5 Identity information
  75. A Tor client learns the digest of a server's key from the network
  76. status document. Once it has a server descriptor this descriptor
  77. contains the full RSA identity key of the server. Clients verify
  78. that 1) the digest of the identity key matches the expected digest
  79. it got from the consensus, and 2) that the signature on the descriptor
  80. from that key is valid.
  81. 3. No longer require clients to have copies of all SDs
  82. 3.1 Load balancing info in consensus documents
  83. One of the reasons why clients download all server descriptors is for
  84. doing load proper load balancing as described in 2.1. In order for
  85. clients to not require all server descriptors this information will
  86. have to move into the network status document.
  87. Consensus documents will have a new line per router similar
  88. to the "r", "s", and "v" lines that already exist. This line
  89. will convey weight information to clients.
  90. "w Bandwidth=193"
  91. The bandwidth number is the lesser of observed bandwidth and bandwidth
  92. rate limit from the server descriptor that the "r" line referenced by
  93. digest (1st and 3rd field of the bandwidth line in the descriptor).
  94. It is given in kilobytes per second so the byte value in the
  95. descriptor has to be divided by 1024 (and is then truncated, i.e.
  96. rounded down).
  97. Authorities will cap the bandwidth number at some arbitrary value,
  98. currently 10MB/sec. If a router claims a larger bandwidth an
  99. authority's vote will still only show Bandwidth=10240.
  100. The consensus value for bandwidth is the median of all bandwidth
  101. numbers given in votes. In case of an even number of votes we use
  102. the lower median. (Using this procedure allows us to change the
  103. cap value more easily.)
  104. Clients should believe the bandwidth as presented in the consensus,
  105. not capping it again.
  106. 3.2 Fetching descriptors on demand
  107. As described in 2.4 a descriptor lists IP address, OR- and Dir-Port,
  108. and the onion key for a server.
  109. A client already knows the IP address and the ports from the consensus
  110. documents, but without the onion key it will not be able to send
  111. CREATE/EXTEND cells for that server. Since the client needs the onion
  112. key it needs the descriptor.
  113. If a client only downloaded a few descriptors in an observable manner
  114. then that would leak which nodes it was going to use.
  115. This proposal suggests the following:
  116. 1) when connecting to a guard node for which the client does not
  117. yet have a cached descriptor it requests the descriptor it
  118. expects by hash. (The consensus document that the client holds
  119. has a hash for the descriptor of this server. We want exactly
  120. that descriptor, not a different one.)
  121. It does that by sending a RELAY_REQUEST_SD cell.
  122. A client MAY cache the descriptor of the guard node so that it does
  123. not need to request it every single time it contacts the guard.
  124. 2) when a client wants to extend a circuit that currently ends in
  125. server B to a new next server C, the client will send a
  126. RELAY_REQUEST_SD cell to server B. This cell contains in its
  127. payload the hash of a server descriptor the client would like
  128. to obtain (C's server descriptor). The server sends back the
  129. descriptor and the client can now form a valid EXTEND/CREATE cell
  130. encrypted to C's onion key.
  131. Clients MUST NOT cache such descriptors. If they did they might
  132. leak that they already extended to that server at least once
  133. before.
  134. Replies to RELAY_REQUEST_SD requests need to be padded to some
  135. constant upper limit in order to conceal a client's destination
  136. from anybody who might be counting cells/bytes.
  137. RELAY_REQUEST_SD cells contain the following information:
  138. - hash of the server descriptor requested
  139. - hash of the identity digest of the server for which we want the SD
  140. - IP address and OR-port or the server for which we want the SD
  141. - padding factor - the number of cells we want the answer
  142. padded to.
  143. [XXX this just occured to me and it might be smart. or it might
  144. be stupid. clients would learn the padding factor they want
  145. to use from the consensus document. This allows us to grow
  146. the replies later on should SDs become larger.]
  147. [XXX: figure out a decent padding size]
  148. 3.3 Protocol versions
  149. Server descriptors contain optional information of supported
  150. link-level and circuit-level protocols in the form of
  151. "opt protocols Link 1 2 Circuit 1". These are not currently needed
  152. and will probably eventually move into the "v" (version) line in
  153. the consensus. This proposal does not deal with them.
  154. Similarly a server descriptor contains the version number of
  155. a Tor node. This information is already present in the consensus
  156. and is thus available to all clients immediately.
  157. 3.4 Exit selection
  158. Currently finding an appropriate exit node for a user's request is
  159. easy for a client because it has complete knowledge of all the exit
  160. policies of all servers on the network.
  161. The consensus document will once again be extended to contain the
  162. information required by clients. This information will be a summary
  163. of each node's exit policy. The exit policy summary will only contain
  164. the list of ports to which a node exits to most destination IP
  165. addresses.
  166. A summary should claim a router exits to a specific TCP port if,
  167. ignoring private IP addresses, the exit policy indicates that the
  168. router would exit to this port to most IP address. either two /8
  169. netblocks, or one /8 and a couple of /12s or any other combination).
  170. The exact algorith used is this: Going through all exit policy items
  171. - ignore any accept that is not for all IP addresses ("*"),
  172. - ignore rejects for these netblocks (exactly, no subnetting):
  173. 0.0.0.0/8, 169.254.0.0/16, 127.0.0.0/8, 192.168.0.0/16, 10.0.0.0/8,
  174. and 172.16.0.0/12m
  175. - for each reject count the number of IP addresses rejected against
  176. the affected ports,
  177. - once we hit an accept for all IP addresses ("*") add the ports in
  178. that policy item to the list of accepted ports, if they don't have
  179. more than 2^25 IP addresses (that's two /8 networks) counted
  180. against them (i.e. if the router exits to a port to everywhere but
  181. at most two /8 networks).
  182. An exit policy summary will be included in votes and consensus as a
  183. new line attached to each exit node. The line will have the format
  184. "p" <space> "accept"|"reject" <portlist>
  185. where portlist is a comma seperated list of single port numbers or
  186. portranges (e.g. "22,80-88,1024-6000,6667").
  187. Whether the summary shows the list of accepted ports or the list of
  188. rejected ports depends on which list is shorter (has a shorter string
  189. representation). In case of ties we choose the list of accepted
  190. ports. As an exception to this rule an allow-all policy is
  191. represented as "accept 1-65535" instead of "reject " and a reject-all
  192. policy is similarly given as "reject 1-65535".
  193. Summary items are compressed, that is instead of "80-88,89-100" there
  194. only is a single item of "80-100", similarly instead of "20,21" a
  195. summary will say "20-21".
  196. Port lists are sorted in ascending order.
  197. The maximum allowed length of a policy summary (including the "accept "
  198. or "reject ") is 1000 characters. If a summary exceeds that length we
  199. use an accept-style summary and list as much of the port list as is
  200. possible within these 1000 bytes.
  201. 3.4.1 Consensus selection
  202. When building a consensus, authorities have to agree on a digest of
  203. the server descriptor to list in the router line for each router.
  204. This is documented in dir-spec section 3.4.
  205. All authorities that listed that agreed upon descriptor digest in
  206. their vote should also list the same exit policy summary - or list
  207. none at all if the authority has not been upgraded to list that
  208. information in their vote.
  209. If we have votes with matching server descriptor digest of which at
  210. least one of them has an exit policy then we differ between two cases:
  211. a) all authorities agree (or abstained) on the policy summary, and we
  212. use the exit policy summary that they all listed in their vote,
  213. b) something went wrong (or some authority is playing foul) and we
  214. have different policy summaries. In that case we pick the one
  215. that is most commonly listed in votes with the matching
  216. descriptor. We break ties in favour of the lexigraphically larger
  217. vote.
  218. If none one of the votes with a matching server descriptor digest has
  219. an exit policy summary we use the most commonly listed one in all
  220. votes, breaking ties like in case b above.
  221. 3.4.2 Client behaviour
  222. When choosing an exit node for a specific request a Tor client will
  223. choose from the list of nodes that exit to the requested port as given
  224. by the consensus document. If a client has additional knowledge (like
  225. cached full descriptors) that indicates the so chosen exit node will
  226. reject the request then it MAY use that knowledge (or not include such
  227. nodes in the selection to begin with). However, clients MUST NOT use
  228. nodes that do not list the port as accepted in the summary (but for
  229. which they know that the node would exit to that address from other
  230. sources, like a cached descriptor).
  231. An exception to this is exit enclave behaviour: A client MAY use the
  232. node at a specific IP address to exit to any port on the same address
  233. even if that node is not listed as exiting to the port in the summary.
  234. 4. Migration
  235. 4.1 Consensus document changes.
  236. The consensus will need to include
  237. - bandwidth information (see 3.1)
  238. - exit policy summaries (3.4)
  239. A new consensus method (number TBD) will be chosen for this.
  240. 5. Future possibilities
  241. This proposal still requires that all servers have the descriptors of
  242. every other node in the network in order to answer RELAY_REQUEST_SD
  243. cells. These cells are sent when a circuit is extended from ending at
  244. node B to a new node C. In that case B would have to answer a
  245. RELAY_REQUEST_SD cell that asks for C's server descriptor (by SD digest).
  246. In order to answer that request B obviously needs a copy of C's server
  247. descriptor. The RELAY_REQUEST_SD cell already has all the info that
  248. B needs to contact C so it can ask about the descriptor before passing it
  249. back to the client.