HACKING 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 0. Intro.
  2. Onion Routing is still very much in development stages. This document
  3. aims to get you started in the right direction if you want to understand
  4. the code, add features, fix bugs, etc.
  5. Read the README file first, so you can get familiar with the basics.
  6. 1. The pieces.
  7. 1.1 Connections. A connection is a long-standing tcp socket between
  8. nodes. A connection is named based on what it's connected to -- an "OR
  9. connection" has an onion router on the other end, an "OP connection" has
  10. an onion proxy on the other end, an "exit connection" has a website or
  11. other server on the other end, and an "AP connection" has an application
  12. proxy (and thus a user) on the other end.
  13. 1.2. Circuits. A circuit is a single conversation between two
  14. participants over the onion routing network. One end of the circuit has
  15. an AP connection, and the other end has an exit connection. AP and exit
  16. connections have only one circuit associated with them, whereas OP and
  17. OR connections multiplex many circuits at once.
  18. 1.3. Cells. Some connections, specifically OR and OP connections, speak
  19. "cells". This means that data over that connection is bundled into 128
  20. byte packets (8 bytes of header and 120 bytes of payload). Each cell has
  21. a type, or "command", which indicates what it's for.
  22. 2. Other features.
  23. 2.1. Bandwidth throttling. Each cell-speaking connection has a maximum
  24. bandwidth it can use, as specified in the routers.or file. Bandwidth
  25. throttling occurs on both the sender side and the receiving side. The
  26. sending side sends cells at regularly spaced intervals (e.g., a connection
  27. with a bandwidth of 12800B/s would queue a cell every 10ms). The receiving
  28. side protects against misbehaving servers that send cells more frequently,
  29. by using a simple token bucket:
  30. Each connection has a token bucket with a specified capacity. Tokens are
  31. added to the bucket each second (when the bucket is full, new tokens
  32. are discarded.) Each token represents permission to receive one byte
  33. from the network --- to receive a byte, the connection must remove a
  34. token from the bucket. Thus if the bucket is empty, that connection must
  35. wait until more tokens arrive. The number of tokens we add enforces a
  36. longterm average rate of incoming bytes, yet we still permit short-term
  37. bursts above the allowed bandwidth. Currently bucket sizes are set to
  38. ten seconds worth of traffic.
  39. The bandwidth throttling uses TCP to push back when we stop reading.
  40. We extend it with token buckets to allow more flexibility for traffic
  41. bursts.
  42. 2.2. Data congestion control.