Esempio n. 1
0
def trivialSimulation(args):
    num = 1000 if not args.total_relays else args.total_relays
    print("Number of nodes in simulated Tor network: %d" % num)

    net = tornet.Network(num)

    # Decorate the network.
    if args.fascist_firewall:
        net = tornet.FascistNetwork(net)
    if args.flaky_network:
        net = tornet.FlakyNetwork(net)
    if args.evil_filtering:
        net = tornet.EvilFilteringNetwork(net)
    if args.sniper_network:
        net = tornet.SniperNetwork(net)

    params = client.ClientParams(
        PROP241=args.prop241,
        PROP259=args.prop259,
        PRIORITIZE_BANDWIDTH=not args.no_prioritize_bandwidth)
    c = client.Client(net, params)

    ok = 0
    bad = 0

    for period in xrange(30):  # one hour each
        for subperiod in xrange(30):  # two minutes each
            if (subperiod % 10) == 0:
                # nodes left and arrived
                net.do_churn()
            # nodes went up and down
            net.updateRunning()

            for attempts in xrange(6):  # 20 sec each

                # actually have the client act.
                if c.buildCircuit():
                    ok += 1
                else:
                    bad += 1

                # time passed
                simtime.advanceTime(20)

        # new consensus
        c.updateGuardLists()

    print("Successful client circuits (total): %d (%d)" % (ok, (ok + bad)))
    print("Percentage of successful circuits:  %f%%" %
          ((ok / float(ok + bad)) * 100.0))
    print("Average guard bandwidth capacity:   %d KB/s" %
          c.averageGuardBandwidth())
Esempio n. 2
0
def trivialSimulation(args):
    num = 1000 if not args.total_relays else args.total_relays
    print("Number of nodes in simulated Tor network: %d" % num)

    net = tornet.Network(num)

    # Decorate the network.
    if args.fascist_firewall:
        net = tornet.FascistNetwork(net)
    if args.flaky_network:
        net = tornet.FlakyNetwork(net)
    if args.evil_filtering:
        net = tornet.EvilFilteringNetwork(net)
    if args.sniper_network:
        net = tornet.SniperNetwork(net)

    params = client.ClientParams(
        PROP241=args.prop241,
        PROP259=args.prop259,
        PRIORITIZE_BANDWIDTH=not args.no_prioritize_bandwidth)
    c = client.Client(net, params)

    ok = 0
    bad = 0

    for period in xrange(30): # one hour each
        for subperiod in xrange(30): # two minutes each
            if (subperiod % 10) == 0:
                # nodes left and arrived
                net.do_churn()
            # nodes went up and down
            net.updateRunning()

            for attempts in xrange(6): # 20 sec each

                # actually have the client act.
                if c.buildCircuit():
                    ok += 1
                else:
                    bad += 1

                # time passed
                simtime.advanceTime(20)

        # new consensus
        c.updateGuardLists()

    print("Successful client circuits (total): %d (%d)" % (ok, (ok + bad)))
    print("Percentage of successful circuits:  %f%%"
          % ((ok / float(ok + bad)) * 100.0))
    print("Average guard bandwidth capacity:   %d KB/s" % c.averageGuardBandwidth())
Esempio n. 3
0
def trivialSimulation():
    net = tornet.Network(100)

    # Decorate the network.
    # Uncomment one or two of these at a time, kthx!
    #net = tornet.FascistNetwork(net)
    #net = tornet.FlakyNetwork(net)
    #net = tornet.EvilFilteringNetwork(net)
    #net = tornet.SniperNetwork(net)

    c = client.Client(net, client.ClientParams())

    ok = 0
    bad = 0

    for period in xrange(30): # one hour each
        for subperiod in xrange(30): # two minutes each
            if (subperiod % 10) == 0:
                # nodes left and arrived
                net.do_churn()
            # nodes went up and down
            net.updateRunning()

            for attempts in xrange(6): # 20 sec each

                # actually have the client act.
                if c.buildCircuit():
                    ok += 1
                else:
                    bad += 1

                # time passed
                simtime.advanceTime(20)

        # new consensus
        c.updateGuardLists()

    print("Successful client circuits (total): %d (%d)" % (ok, (ok + bad)))
    print("Percentage of successful circuilts: %f%%"
          % ((ok / float(ok + bad)) * 100.0))