151-path-selection-improvements.txt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. Filename: 151-path-selection-improvements.txt
  2. Title: Improving Tor Path Selection
  3. Version:
  4. Last-Modified:
  5. Author: Fallon Chen, Mike Perry
  6. Created: 5-Jul-2008
  7. Status: Draft
  8. Overview
  9. The performance of paths selected can be improved by adjusting the
  10. CircuitBuildTimeout and avoiding failing guard nodes. This proposal
  11. describes a method of tracking buildtime statistics at the client, and
  12. using those statistics to adjust the CircuitBuildTimeout.
  13. Motivation
  14. Tor's performance can be improved by excluding those circuits that
  15. have long buildtimes (and by extension, high latency). For those Tor
  16. users who require better performance and have lower requirements for
  17. anonymity, this would be a very useful option to have.
  18. Implementation
  19. Storing Build Times
  20. Circuit build times will be stored in the circular array
  21. 'circuit_build_times' consisting of uint16_t elements as milliseconds.
  22. The total size of this array will be based on the number of circuits
  23. it takes to converge on a good fit of the long term distribution of
  24. the circuit builds for a fixed link. We do not want this value to be
  25. too large, because it will make it difficult for clients to adapt to
  26. moving between different links.
  27. From our initial observations, this value appears to be on the order
  28. of 1000, but will be configurable in a #define NCIRCUITS_TO_OBSERVE.
  29. The exact value for this #define will be determined by performing
  30. goodness of fit tests using measurments obtained from the shufflebt.py
  31. script from TorFlow.
  32. Long Term Storage
  33. The long-term storage representation will be implemented by storing a
  34. histogram with BUILDTIME_BIN_WIDTH millisecond buckets (default 50) when
  35. writing out the statistics to disk. The format of this histogram on disk
  36. is yet to be finalized, but it will likely be of the format
  37. 'CircuitBuildTime <bin> <count>', with the total specified as
  38. 'TotalBuildTimes <total>'
  39. Example:
  40. TotalBuildTimes 100
  41. CircuitBuildTimeBin 1 50
  42. CircuitBuildTimeBin 2 25
  43. CircuitBuildTimeBin 3 13
  44. ...
  45. Reading the histogram in will entail multiplying each bin by the
  46. BUILDTIME_BIN_WIDTH and then inserting <count> values into the
  47. circuit_build_times array each with the value of
  48. <bin>*BUILDTIME_BIN_WIDTH. In order to evenly distribute the
  49. values in the circular array, a form of index skipping must
  50. be employed. Values from bin #N with bin count C and total T
  51. will occupy indexes specified by N+((T/C)*k)-1, where k is the
  52. set of integers ranging from 0 to C-1.
  53. For example, this would mean that the values from bin 1 would
  54. occupy indexes 1+(100/50)*k-1, or 0, 2, 4, 6, 8, 10 and so on.
  55. The values for bin 2 would occupy positions 1, 5, 9, 13. Collisions
  56. will be inserted at the first empty position in the array greater
  57. than the selected index (which may requiring looping around the
  58. array back to index 0).
  59. Learning the CircuitBuildTimeout
  60. Based on studies of build times, we found that the distribution of
  61. circuit buildtimes appears to be a Pareto distribution.
  62. We will calculate the parameters for a Pareto distribution
  63. fitting the data using the estimators at
  64. http://en.wikipedia.org/wiki/Pareto_distribution#Parameter_estimation.
  65. The timeout itself will be calculated by solving the CDF for the
  66. a percentile cutoff BUILDTIME_PERCENT_CUTOFF. This value
  67. represents the percentage of paths the Tor client will accept out of
  68. the total number of paths. We have not yet determined a good
  69. cutoff for this mathematically, but 85% seems a good choice for now.
  70. From http://en.wikipedia.org/wiki/Pareto_distribution#Definition,
  71. the calculation we need is pow(BUILDTIME_PERCENT_CUTOFF/100.0, k)/Xm.
  72. Testing
  73. After circuit build times, storage, and learning are implemented,
  74. the resulting histogram should be checked for consistency by
  75. verifying it persists across successive Tor invocations where
  76. no circuits are built. In addition, we can also use the existing
  77. buildtime scripts to record build times, and verify that the histogram
  78. the python produces matches that which is output to the state file in Tor,
  79. and verify that the Pareto parameters and cutoff points also match.
  80. Soft timeout vs Hard Timeout
  81. At some point, it may be desirable to change the cutoff from a
  82. single hard cutoff that destroys the circuit to a soft cutoff and
  83. a hard cutoff, where the soft cutoff merely triggers the building
  84. of a new circuit, and the hard cutoff triggers destruction of the
  85. circuit.
  86. Good values for hard and soft cutoffs seem to be 85% and 65%
  87. respectively, but we should eventually justify this with observation.
  88. When to Begin Calculation
  89. The number of circuits to observe (NCIRCUITS_TO_CUTOFF) before
  90. changing the CircuitBuildTimeout will be tunable via a #define. From
  91. our measurements, a good value for NCIRCUITS_TO_CUTOFF appears to be
  92. on the order of 100.
  93. Dealing with Timeouts
  94. Timeouts should be counted as the expectation of the region of
  95. of the Pareto distribution beyond the cutoff. The proposal will
  96. be updated with this value soon.
  97. Also, in the event of network failure, the observation mechanism
  98. should stop collecting timeout data.
  99. Client Hints
  100. Some research still needs to be done to provide initial values
  101. for CircuitBuildTimeout based on values learned from modem
  102. users, DSL users, Cable Modem users, and dedicated links. A
  103. radiobutton in Vidalia should eventually be provided that
  104. sets CircuitBuildTimeout to one of these values and also
  105. provide the option of purging all learned data, should any exist.
  106. These values can either be published in the directory, or
  107. shipped hardcoded for a particular Tor version.
  108. Issues
  109. Impact on anonymity
  110. Since this follows a Pareto distribution, large reductions on the
  111. timeout can be achieved without cutting off a great number of the
  112. total paths. This will eliminate a great deal of the performance
  113. variation of Tor usage.