4

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.

Roya
  • 3,240
  • 3
  • 19
  • 40
2523fewqf23f
  • 545
  • 1
  • 3
  • 12

2 Answers2

3

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);
  update_networkstatus_downloads(now);
}

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.

Jens Kubieziel
  • 8,630
  • 5
  • 35
  • 116
2

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

Linostar
  • 1,133
  • 1
  • 9
  • 24