Stem Docs

Votes by Bandwidth Authorities

Votes by Bandwidth AuthoritiesΒΆ


Tor takes into account a relay's throughput when picking a route through the Tor network for its circuits. That is to say large, fast relays receive more traffic than small ones since they can better service the load.

To determine a relay's throughput special authorities, called bandwidth authorities, take periodic measurements using them. The lifecycle of new Tor relays is a bit more complicated than that, but that's the general idea.

Bandwidth authorities include their measurements in their votes. The following gets their current votes then prints how many relays it had a measurement for.

from stem.descriptor import remote

# request votes from all the bandwidth authorities

queries = {}
downloader = remote.DescriptorDownloader()

for authority in remote.get_authorities().values():
  if authority.is_bandwidth_authority:
    queries[authority.nickname] = downloader.query(
      endpoints = [(authority.address, authority.dir_port)],

for authority_name, query in queries.items():
    print("Getting %s's vote from %s:" % (authority_name, query.download_url))

    measured, unmeasured = 0, 0

    for desc in
      if desc.measured:
        measured += 1
        unmeasured += 1

    print('  %i measured entries and %i unmeasured' % (measured, unmeasured))
  except Exception as exc:
    print("  failed to get the vote (%s)" % exc)
% python
Getting gabelmoo's vote from
  5935 measured entries and 1332 unmeasured
Getting tor26's vote from
  5735 measured entries and 1690 unmeasured
Getting moria1's vote from
  6647 measured entries and 625 unmeasured
Getting maatuska's vote from
  6313 measured entries and 1112 unmeasured