In Tor, I heard that traffic is passed through 3 servers in the network before it reaches the destination, and it's encrypted between those 3 servers, and that those 3 computers are chosen randomly. Considering the fact that true randomness is not possible in programming and computers, how does random picking work on the Tor network?
Originally, it used to be random. But as the popularity increased, it became necessary to attempt to balance Tor’s traffic load over the available router bandwidth. These days it is not just random.
Now a days, Tor utilizes a set of trusted Bandwidth Authorities(bwauths) which actively probs the Tor routers and estimate each router’s capacity. According to this Tor performs load balancing by weighting router selection in proportion to each router’s perceived bandwidth capacity (This is a primary reason why, when you set up a non-exit Tor relay, there is really a 'no use'(the unmeasured phase) period for about 3 days).
There are additional checks as well, including the use of 'entry guards' for the first hop to defend against any attack and exit policies that specify the destination addresses and ports allowed by an exit router’s operator, etc.
Tor starts the circuit build by first selecting exit node. Through the configurations in the
torrc file, users themselves have some control over which nodes (not) to choose. Next, Entry and middle relay is chosen. Here, in general, Tor tries not to choose relays which might belong to the same operator. In general, all paths generated by Tor obey the following constraints:
- Tor do not choose the same router twice for the same path.
- Tor do not choose any router in the same family as another in the same path. (Two routers are in the same family if each one lists the other in the "family" entries of its descriptor.)
- Tor do not choose more than one router in a given /16 subnet.
- Tor don't choose any non-running or non-valid router unless Tor has been configured to do so. By default, Tor is configured to allow non-valid routers in "middle" and "rendezvous" positions.
- The first node must be a Guard node.
There is a lot more information in the Tor path specification document and How does a Tor client pick Tor nodes for circuit creation?