I am wondering that how many times a client "talks" to Directory Server (say, it can be a hard-coded Directory Authority Server, or just a normal Directory Server) to fetch the consensus file, knowing that the consensus file is changed, and redistributed among directory servers every one hour?

In other words, how frequent does a client fetch consensus data from Directory Server, or just once at the beginning time when starting Tor Browser? Lets assume that this client continuously uses Tor for more than 1 hour.


As far as I see it the answer is in the source code. ;-)

The file main.c has a function run_scheduled_events. The comment to this function says:

Perform regular maintenance tasks. This function gets run once per second by second_elapsed_callback().

Within the source code there is a list of things which this function does. As far as I see it item 2c deals with downloading the networkstatus:

2c. Every minute (or every second if TestingTorNetwork), check whether we want to download any networkstatus documents.

The code itself is:

#define networkstatus_dl_check_interval(o) ((o)->TestingTorNetwork ? 1 : 60)

if (!should_delay_dir_fetches(options, NULL) &&
    time_to_download_networkstatus < now) {
  time_to_download_networkstatus =
    now + networkstatus_dl_check_interval(options);

So it looks at should_delay_dir_fetches in networkstatus.c. If your network is enabled and you have running bridges/pluggable transports (in case you set it) all is fine. Furthermore it checks if a specific timer is less than the current time. If this is true, the timer is updated (current time plus 60 seconds) and update_networkstatus_downloads is called which itself calls update_consensus_networkstatus_downloads. This function takes care about the actual downloading.

The function is defined at line 733 in networkstatus.c. It has a bit more logic inside. However as far as I see it, it waits until the current consensus is older than the current time. If this happens a new document is fetched.

You can also set logging at info level and will find lines like the following:

Jan 28 18:21:51.000 [info] update_consensus_networkstatus_downloads(): Launching microdesc networkstatus consensus download.
Jan 28 19:36:04.000 [info] update_consensus_networkstatus_downloads(): Launching microdesc networkstatus consensus download.

Summary: Every minute it is checked if the consensus document is too old. If it is older than the current time a new one will be fetched.

  • Dear Jens, thank you so much for your informative Answer. I think it's probably what I am really looking for. However, I will need to figure it out a little bit to get the most precise answer, cos you interpreted from the source code that :"every 60 seconds is an attempt to download new documents", but to the best of my knowledge, the consensus file is only regenerated every one hour, as I asked here: tor.stackexchange.com/questions/4939/… So does "1download/60s" will add more load to the directory servers? – 2523fewqf23f Jan 28 '15 at 9:47
  • @Windy: I missed a point and have corrected my first answer. Sorry for the confusion. – Jens Kubieziel Jan 28 '15 at 17:29
  • 1
    Dear Jens, that was a wonderful answer. Thanks to your dedicated and comprehensive explanation, I am quite clear now about the internal operating mechanism of the source code. Have a nice day! – 2523fewqf23f Jan 29 '15 at 4:46

From what I gathered, I have not found anything that point that a client periodically fetch the consensus file. On the other hand, consensus files do expire, and when that happens the client will request the latest version.

If you set TestingTorNetwork in torrc to 1, one of the properties tested will be the frequency of fetching the consensus file. The following values will be tested for both clients and servers:

TestingServerConsensusDownloadSchedule 0, 0, 5, 10, 15, 20, 30, 60 TestingClientConsensusDownloadSchedule 0, 0, 5, 10, 15, 20, 30, 60

  • 1
    Dear Linostar. Thank you so much for your prompt explanation. So, do you have any idea about how long a consensus will expire, or it will just expire when a new consensus is available to download? Btw, thank you so much for your precious hint, I found some helpful definition here torproject.org/docs/tor-manual.html.en#TestingTorNetwork And here as well, although I still cannot clearly understand some terminologies in this Trac#ticket: trac.torproject.org/projects/tor/ticket/13976 – 2523fewqf23f Jan 28 '15 at 9:32
  • 1
    As per definition of Tor metrics, the consensus is voted on by directory authorities once per hour. I guess that means the expiry duration is also 1 hour. – Linostar Jan 28 '15 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.