bridgedb.Stability

This module provides functionality for tracking bridge stability metrics.

Bridge stability metrics are calculated using the model introduced in `”An Analysis of Tor Bridge Stability”`_ and `implemented in the Tor Metrics library`_.

class BridgeHistory(fingerprint, ip, port, weightedUptime, weightedTime, weightedRunLength, totalRunWeights, lastSeenWithDifferentAddressAndPort, lastSeenWithThisAddressAndPort, lastDiscountedHistoryValues, lastUpdatedWeightedTime)[source]

Bases: object

Record Class that tracks a single Bridge The fields stored are:

fingerprint, ip, port, weightedUptime, weightedTime, weightedRunLength, totalRunWeights, lastSeenWithDifferentAddressAndPort, lastSeenWithThisAddressAndPort, lastDiscountedHistoryValues.

fingerprint The Bridge Fingerprint (unicode) ip The Bridge IP (unicode) port The Bridge orport (integer)

weightedUptime Weighted uptime in seconds (long int) weightedTime Weighted time in seconds (long int) weightedRunLength Weighted run length of previous addresses or ports in

seconds. (long int)
totalRunWeights Total run weights of previously used addresses or
ports. (float)
lastSeenWithDifferentAddressAndPort
Timestamp in milliseconds when this bridge was last seen with a different address or port. (long int)
lastSeenWithThisAddressAndPort
Timestamp in milliseconds when this bridge was last seen with this address and port. (long int)
lastDiscountedHistoryValues:
Timestamp in milliseconds when this bridge was last discounted. (long int)
lastUpdatedWeightedTime:
Timestamp in milliseconds when the weighted time was updated. (long int)
discountWeightedFractionalUptimeAndWeightedTime(discountUntilMillis)[source]

discount weighted times

numDiscountRounds(discountUntilMillis)[source]

return the number of rounds of discounting needed to bring this history element current

weightedFractionalUptime

Weighted Fractional Uptime

tosa

the Time On Same Address (TOSA)

familiar

A bridge is ‘familiar’ if 1/8 of all active bridges have appeared more recently than it, or if it has been around for a Weighted Time of 8 days.

wmtbac

Weighted Mean Time Between Address Change

addOrUpdateBridgeHistory(bridge, timestamp)[source]
discountAndPruneBridgeHistories(discountUntilMillis)[source]
updateWeightedTime(statusPublicationMillis)[source]
updateBridgeHistory(bridges, timestamps)[source]

Process all the timestamps and update the bridge stability statistics in the database.

Parameters:
  • bridges (dict) – All bridges from the descriptors, parsed into :class:`bridgedb.bridges.Bridge`s.
  • timestamps (dict) – A dictionary whose keys are bridge fingerprints, and whose values are lists of integers, each integer being a timestamp (in seconds since Unix Epoch) for when a descriptor for that bridge was published.
Return type:

dict

Returns:

The original timestamps, but which each list of integers (re)sorted.