151-path-selection-improvements.txt 6.0 KB

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