Measuring Tor's performance as users experience it ================================================== The performance (latency and throughput) that Tor users experience depends on numerous factors and is the subject of current research. In order to evaluate progress in improving Tor's performance, we need to continuously measure how fast Tor really is for our users. The primary purpose of these measurements is to compare how performance evolves over time. This howto uses a trivial SOCKS client to download files of various sizes over the Tor network and write down how long substeps take. The following configuration parameters are used: - 50 KB file, downloaded every 5 minutes, timeout of 4:55 minutes, MaxCircuitDirtiness of 1 minute, SOCKS port 9020, no entry guards - 1 MB file, downloaded every 30 minutes, timeout of 29:55 minutes, default MaxCircuitDirtiness of 10 minutes, SOCKS port 9021, no entry guards - 5 MB file, downloaded every 60 minutes, timeout of 59:55 minutes, default MaxCircuitDirtiness of 10 minutes, SOCKS port 9022, no entry guards Create sample files of correct sizes and make them available somewhere via http: $ dd if=/dev/urandom of=.50kbfile count=1 bs=50K $ dd if=/dev/urandom of=.1mbfile count=1 bs=1M $ dd if=/dev/urandom of=.5mbfile count=1 bs=5M These files are available as http://torperf.torproject.org/.50kbfile (and the other two file names). You may use these files, or you can use your own files instead. Check out and build torperf: $ git clone git://git.torproject.org/torperf ~/torperf $ cd ~/torperf $ make Create data directories for the Tor clients (every download uses its own Tor client) and write torrc files: $ mkdir torclient50kb $ mkdir torclient1mb $ mkdir torclient5mb $ cat <> torclient50kb/torrc DataDirectory . SocksPort 9020 MaxCircuitDirtiness 1 minute UseEntryGuards 0 RunAsDaemon 1 Log notice file log EOF $ cat <> torclient1mb/torrc DataDirectory . SocksPort 9021 UseEntryGuards 0 RunAsDaemon 1 Log notice file log EOF $ cat <> torclient5mb/torrc DataDirectory . SocksPort 9022 UseEntryGuards 0 RunAsDaemon 1 Log notice file log EOF Write a start script to start the Tor clients and execute it: $ cat <> start-tors #!/bin/bash cd ~/torperf/torclient50kb && tor -f ~/torperf/torclient50kb/torrc cd ~/torperf/torclient1mb && tor -f ~/torperf/torclient1mb/torrc cd ~/torperf/torclient5mb && tor -f ~/torperf/torclient5mb/torrc EOF $ chmod a+x start-tors $ ./start-tors Install the timeout tool: $ sudo apt-get install timeout Add crontab entries to start the regular requests (line breaks are only for formatting purposes here): $ crontab -e */5 * * * * timeout -2 295 ~/torperf/trivsocks-client torperf.torproject.org 127.0.0.1:9020 /.50kbfile >> ~/torperf/50kb.data 2>/dev/null 2,32 * * * * timeout -2 1795 ~/torperf/trivsocks-client torperf.torproject.org 127.0.0.1:9021 /.1mbfile >> ~/torperf/1mb.data 2>/dev/null 8 * * * * timeout -2 3595 ~/torperf/trivsocks-client torperf.torproject.org 127.0.0.1:9022 /.5mbfile >> ~/torperf/5mb.data 2>/dev/null From now on, the three files 50kb.data, 1mb.data, and 5mb.data should accumulate lines like this (50kb.data shown here; line breaks are only for formatting purposes): 1244638801 612981 1244638801 612991 1244638801 613051 1244638801 613126 1244638801 613134 1244638814 282441 1244638814 282466 1244638817 164531 1244638826 335235 84 51466 The column headers might be: startsec startusec socketsec socketusec connectsec connectusec negotiatesec negotiateusec requestsec requestusec responsesec responseusec datarequestsec datarequestusec dataresponsesec dataresponseusec datacompletesec datacompleteusec writebytes readbytes If everything works, you might want to let your system start these Tor clients on system startup. On Debian, this can be done using a crontab entry, too: $ crontab -e @reboot ~/torperf/start-tors 2>/dev/null