How does onion routing work?
Onion routing is the heart of Tor. In the most basic sense, Tor programs running on multiple computers across the internet each make a random decision as to where to route the individual packetflow of a given connection. There is typically constant flows of encrypted traffic between Tor programs, so it is an electronic and encrypted version of the old 'which cup is the ball under' trick you might have seen at a circus. Some Tor programs are configured to permit traffic to 'exit' the Tor network and head to standard internet websites. These are called exit nodes. A given particular destination must have at least one exit node willing to permit traffic to flow prior to the connection being made. To make a connection, an application will talk socks5 to a local Tor instance which will then relay the connection through the Tor network to the exit node. This process is known as onion routing. It seems aptly named because one would have to peel many layers to find out exactly where the packetflow has been and is going to ultimately reach an exit node ;-)