[tor-talk] How does Tor REALLY work?

casey dunham casey.dunham at gmail.com
Tue Mar 8 13:27:43 UTC 2011


I've got a bunch of notes from perusing the source code trying to understand it.

It sounds like it would be a great project for someone that is just
getting into Tor and already knows C (I hope I didn't just volunteer
myself for the project...)

My question would be, how likely is it that the architecture that you
just described would be changing anytime soon?

I think any documentation written to such an end would have to strike
a balance between being detailed enough to be useful and not too
detailed in that parts of it get outdated rather quickly.

I was thinking about doing this for the JTor implementation as I have
been digging into that a decent amount the last few weeks.

On Mon, Mar 7, 2011 at 6:55 PM, Nick Mathewson <nickm at freehaven.net> wrote:
> On Sat, Mar 5, 2011 at 7:29 AM,  <hikki at safe-mail.net> wrote:
>> I mean _really_ work.
>>
>> (I already know how it protects your anonymity.)
>>
>> What happens from the moment you start the Tor program? What's the first
>> thing it does, the next thing, and so forth? I've never seen a detailed
>> technical illustration of how it works on a technical level.
>
> You mean, which parts of the code call what, and how they all fit
> together?  I'm afraid we haven't written anything like that.  I'd love
> for somebody to start writing one, but for now, learning how the code
> all fits together will require you to read some C.
>
> If you're still interested, here are some good points to start with:
>   - The tor program does most of its work in the main thread.  The
> main thread is written launches operations in response to events,
> which include network IO, timers, and signals.  Tor uses libevent to
> notice these events.  The starting point for handling network IO
> events (in 0.2.2) is conn_read_callback and conn_write_callback.  The
> starting point for handling signals is signal_callback.  The starting
> point for invoking periodic timers is second_elapsed_callback.  These
> are all in src/or/main.c.
>   - There are also subthreads to handle CPU-intensive tasks.  Right
> now, they only handle onionskins.
>   - To see how the program starts up, start with the function
> tor_main() in src/or/main.c.  When Tor is run, it invokes
> do_main_loop(), which sets up more of the global state, and then
> spends most of its time in a loop.  The loop's main job is to call
> event_base_loop(): this is where Tor spends most of its time.
>
> Again, this is just a sketch of interesting points to start reading a
> top-down tour of the program, and isn't a "tor internals guide" by any
> means.  If somebody has time to write one someday, that would rock.
>
>
> cheers,
> --
> Nick
> _______________________________________________
> tor-talk mailing list
> tor-talk at lists.torproject.org
> https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-talk
>


More information about the tor-talk mailing list