[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-relays] write-history for exit relays only?



On Tue, Sep 06, 2016 at 12:10:06PM -0400, Aaron Johnson wrote:
> > I suspect that one could approximate this number by accounting for the
> > probability of all exits being selected as guard, middle, and exit, but
> > I would prefer a simpler and more reliable approach.
> 
> This doesn’t seem like a bad approximation to me, given that for as
> long as I have been aware, exits have had zero probability of being
> chosen in any position other than the exit position.

Thanks, Aaron.  You are right.  Section 3.8.3 in dir-spec has the answer:
<https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2611>

I just proved this to myself with the small attached Python script.
Currently, exit bandwidth is the network's scarce resource, which is not
surprising since running an exit is riskier than running a guard or a
middle.  Since exits are scarce, the bandwidth weights in case 3,
subcase A are currently in place:
<https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2726>

In that case, the specification hard-codes the probability of an exit
taking on a non-exit role (Wgd, Wmd, and Wme) to 0.
#!/usr/bin/env python3

import sys

import stem
import stem.descriptor.remote


def calc_weights():

    G = M = E = D = T = 0

    for status in stem.descriptor.remote.get_consensus():

        if stem.Flag.GUARD in status.flags:
            G += status.bandwidth

        if stem.Flag.EXIT in status.flags:
            E += status.bandwidth

        if ((stem.Flag.EXIT in status.flags) and
            (stem.Flag.GUARD in status.flags)):
            D += status.bandwidth

        if ((stem.Flag.EXIT not in status.flags) and
            (stem.Flag.GUARD not in status.flags)):
            M += status.bandwidth

    T = G + M + E + D
    print("T=%d\nG=%d\nM=%d\nE=%d\nD=%d" % (T, G, M, E, D))

    if (E >= (float(T) / 3)) and (G >= (float(T) / 3)):
        print("Neither exits nor guards are scarce.")

    if (E < (float(T) / 3)) and (G < (float(T) / 3)):
        print("Both exits and guards are scarce.")

    if (E < (float(T) / 3)) or (G < (float(T) / 3)):
        S = min(E, G)
        if S == E:
            print("Exits are scarce.")
        if S == G:
            print("Guards are scarce.")

        if (S + D) < (float(T) / 3):
            print("Subcase a")
        if (S + D) >= (float(T) / 3):
            print("Subcase b")

    return 0


if __name__ == "__main__":
    sys.exit(calc_weights())
_______________________________________________
tor-relays mailing list
tor-relays@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays