|
@@ -13,6 +13,8 @@ import json
|
|
import gzip
|
|
import gzip
|
|
import pickle
|
|
import pickle
|
|
import tempfile
|
|
import tempfile
|
|
|
|
+import collections
|
|
|
|
+import gc
|
|
#
|
|
#
|
|
import stem.control
|
|
import stem.control
|
|
import stem.descriptor.remote
|
|
import stem.descriptor.remote
|
|
@@ -59,14 +61,17 @@ class CustomExperiment(experiment.Experiment):
|
|
#local_ip = '129.97.119.196'
|
|
#local_ip = '129.97.119.196'
|
|
#target_ip = '129.97.119.226'
|
|
#target_ip = '129.97.119.226'
|
|
target_hostname = 'cluck2'
|
|
target_hostname = 'cluck2'
|
|
|
|
+ target_dir = '/tmp/chutney-net'
|
|
elif self.remote_name == 'sengler-rpi':
|
|
elif self.remote_name == 'sengler-rpi':
|
|
local_ip = '129.97.119.196'
|
|
local_ip = '129.97.119.196'
|
|
target_ip = '129.97.169.9'
|
|
target_ip = '129.97.169.9'
|
|
target_hostname = 'sengler-rpi'
|
|
target_hostname = 'sengler-rpi'
|
|
|
|
+ target_dir = '/tmp/chutney-net'
|
|
elif self.remote_name is None:
|
|
elif self.remote_name is None:
|
|
local_ip = None
|
|
local_ip = None
|
|
target_ip = None
|
|
target_ip = None
|
|
target_hostname = None
|
|
target_hostname = None
|
|
|
|
+ target_dir = None
|
|
else:
|
|
else:
|
|
raise Exception('hostname not known')
|
|
raise Exception('hostname not known')
|
|
#
|
|
#
|
|
@@ -85,9 +90,14 @@ class CustomExperiment(experiment.Experiment):
|
|
target_optional_args['ip'] = target_ip
|
|
target_optional_args['ip'] = target_ip
|
|
if target_hostname is not None:
|
|
if target_hostname is not None:
|
|
target_optional_args['remote_hostname'] = target_hostname
|
|
target_optional_args['remote_hostname'] = target_hostname
|
|
|
|
+ if target_dir is not None:
|
|
|
|
+ target_optional_args['remote_net_dir'] = target_dir
|
|
|
|
|
|
- target_optional_args['num_cpus'] = 4 # make sure it can process onion skins fast enough, and keep it consistent between computers
|
|
|
|
|
|
+ target_optional_args['num_cpus'] = 2 # make sure it can process onion skins fast enough, and keep it consistent between computers
|
|
|
|
+ # tor actually uses one more worker thread than what you ask for
|
|
target_optional_args['num_additional_eventloops'] = self.num_additional_eventloops
|
|
target_optional_args['num_additional_eventloops'] = self.num_additional_eventloops
|
|
|
|
+ target_optional_args['dircache'] = False
|
|
|
|
+ # the voting interval is 40 seconds which puts an unrealistic workload on the target, so we disable it
|
|
target_cpu_prof = False #True
|
|
target_cpu_prof = False #True
|
|
target_daemon = False
|
|
target_daemon = False
|
|
target_log_throughput = True
|
|
target_log_throughput = True
|
|
@@ -144,7 +154,11 @@ class CustomExperiment(experiment.Experiment):
|
|
remote_script_path = '/tmp/log_system_usage.py'
|
|
remote_script_path = '/tmp/log_system_usage.py'
|
|
remote_save_path = '/tmp/cpu-usage.pickle.gz'
|
|
remote_save_path = '/tmp/cpu-usage.pickle.gz'
|
|
local_save_path = os.path.join(self.save_data_path, 'remote-cpu-usage.pickle.gz')
|
|
local_save_path = os.path.join(self.save_data_path, 'remote-cpu-usage.pickle.gz')
|
|
- command = 'python3 {} 0.1 {}'.format(remote_script_path, remote_save_path)
|
|
|
|
|
|
+ #
|
|
|
|
+ tor_pids = subprocess.check_output(['ssh', self.remote_name, 'pgrep tor']).decode('utf-8').split()
|
|
|
|
+ tor_pids = [pid for pid in tor_pids]
|
|
|
|
+ logging.info('Logging the following pids on {}: {}'.format(self.remote_name, tor_pids))
|
|
|
|
+ command = 'python3 {} 0.2 {} {}'.format(remote_script_path, remote_save_path, ','.join(tor_pids))
|
|
#
|
|
#
|
|
try:
|
|
try:
|
|
subprocess.check_output(['scp', local_script_path, '{}:{}'.format(self.remote_name, remote_script_path)], stderr=subprocess.STDOUT)
|
|
subprocess.check_output(['scp', local_script_path, '{}:{}'.format(self.remote_name, remote_script_path)], stderr=subprocess.STDOUT)
|
|
@@ -157,6 +171,9 @@ class CustomExperiment(experiment.Experiment):
|
|
#
|
|
#
|
|
if next_action is not None:
|
|
if next_action is not None:
|
|
next_action()
|
|
next_action()
|
|
|
|
+ time.sleep(5)
|
|
|
|
+ # wait a few seconds so that we have extra data
|
|
|
|
+ # this may be useful if we need to do averaging
|
|
#
|
|
#
|
|
if p.poll() != None:
|
|
if p.poll() != None:
|
|
raise Exception('Remote CPU monitoring script exited before it was supposed to')
|
|
raise Exception('Remote CPU monitoring script exited before it was supposed to')
|
|
@@ -196,10 +213,11 @@ class CustomExperiment(experiment.Experiment):
|
|
def build_circuit_generator(consensus, server_address):
|
|
def build_circuit_generator(consensus, server_address):
|
|
fingerprints = [desc.nickname for desc in consensus]
|
|
fingerprints = [desc.nickname for desc in consensus]
|
|
exit_fingerprints = [desc.nickname for desc in consensus if desc.exit_policy.can_exit_to(*server_address)]
|
|
exit_fingerprints = [desc.nickname for desc in consensus if desc.exit_policy.can_exit_to(*server_address)]
|
|
|
|
+ authority_fingerprints = [desc.nickname for desc in consensus if desc.nickname.endswith('a')]
|
|
#
|
|
#
|
|
target_fingerprints = [desc.nickname for desc in consensus if desc.nickname.endswith('target')]
|
|
target_fingerprints = [desc.nickname for desc in consensus if desc.nickname.endswith('target')]
|
|
assert len(target_fingerprints) >= 1, 'No target relay in the consensus'
|
|
assert len(target_fingerprints) >= 1, 'No target relay in the consensus'
|
|
- non_exit_fingerprints = list(set(fingerprints)-set(exit_fingerprints)-set(target_fingerprints))
|
|
|
|
|
|
+ non_exit_fingerprints = list(set(fingerprints)-set(exit_fingerprints)-set(target_fingerprints)-set(authority_fingerprints))
|
|
#
|
|
#
|
|
assert len(exit_fingerprints) >= 1, 'Need at least one exit relay'
|
|
assert len(exit_fingerprints) >= 1, 'Need at least one exit relay'
|
|
assert len(non_exit_fingerprints) >= 1, 'Need at least one non-exit relay'
|
|
assert len(non_exit_fingerprints) >= 1, 'Need at least one non-exit relay'
|
|
@@ -258,12 +276,18 @@ if __name__ == '__main__':
|
|
#
|
|
#
|
|
start_time = time.time()
|
|
start_time = time.time()
|
|
#
|
|
#
|
|
- tors = {'working':'/home/sengler/code/working/tor/src/app/tor', 'working-without':'/home/sengler/code/working/tor-without-tcmalloc/src/app/tor', 'dev-without':'/home/sengler/code/dev/tor-throughput-log-0.4.2.6-without-tcmalloc/src/app/tor', 'dev-with':'/home/sengler/code/dev/tor-throughput-log-0.4.2.6-with-tcmalloc/src/app/tor'}
|
|
|
|
|
|
+ #tors = {'working':'/home/sengler/code/working/tor/src/app/tor', 'working-without':'/home/sengler/code/working/tor-without-tcmalloc/src/app/tor', 'dev-without':'/home/sengler/code/dev/tor-throughput-log-0.4.2.6-without-tcmalloc/src/app/tor', 'dev-with':'/home/sengler/code/dev/tor-throughput-log-0.4.2.6-with-tcmalloc/src/app/tor'}
|
|
|
|
+ tors = collections.OrderedDict()
|
|
|
|
+ tors['working'] = '/home/sengler/code/working/tor/src/app/tor'
|
|
|
|
+ tors['working-without'] = '/home/sengler/code/working/tor-without-tcmalloc/src/app/tor'
|
|
|
|
+ tors['dev-with'] = '/home/sengler/code/dev/tor-throughput-log-0.4.2.6-with-tcmalloc/src/app/tor'
|
|
|
|
+ tors['dev-without'] = '/home/sengler/code/dev/tor-throughput-log-0.4.2.6-without-tcmalloc/src/app/tor'
|
|
hosts = ['sengler-rpi', 'cluck2']
|
|
hosts = ['sengler-rpi', 'cluck2']
|
|
###hosts = ['cluck2']
|
|
###hosts = ['cluck2']
|
|
###hosts = ['sengler-rpi']
|
|
###hosts = ['sengler-rpi']
|
|
num_repetitions = 15
|
|
num_repetitions = 15
|
|
nums_additional_eventloops_options = [0, 1, 2, 3]
|
|
nums_additional_eventloops_options = [0, 1, 2, 3]
|
|
|
|
+ #nums_additional_eventloops_options = [3, 2, 1, 0]
|
|
#
|
|
#
|
|
#tors = {'working':'/home/sengler/code/working/tor/src/app/tor', 'dev-without':'/home/sengler/code/dev/tor-throughput-log-0.4.2.6-without-tcmalloc/src/app/tor'}
|
|
#tors = {'working':'/home/sengler/code/working/tor/src/app/tor', 'dev-without':'/home/sengler/code/dev/tor-throughput-log-0.4.2.6-without-tcmalloc/src/app/tor'}
|
|
#hosts = ['cluck2']
|
|
#hosts = ['cluck2']
|
|
@@ -295,18 +319,18 @@ if __name__ == '__main__':
|
|
# num_bytes = 20*(2**20)
|
|
# num_bytes = 20*(2**20)
|
|
if host == 'cluck2':
|
|
if host == 'cluck2':
|
|
num_clients = 150
|
|
num_clients = 150
|
|
- num_guards = 58 # number of relays (including guards)
|
|
|
|
|
|
+ num_guards = 30 # number of relays (including guards)
|
|
num_authorities = 2 # will also act as a relay or guard
|
|
num_authorities = 2 # will also act as a relay or guard
|
|
- num_exits = 60 # will be used only as an exit
|
|
|
|
|
|
+ num_exits = 30 # will be used only as an exit
|
|
num_streams_per_client = 10
|
|
num_streams_per_client = 10
|
|
num_bytes = 20*(2**20)
|
|
num_bytes = 20*(2**20)
|
|
elif host == 'sengler-rpi':
|
|
elif host == 'sengler-rpi':
|
|
- num_clients = 30
|
|
|
|
- num_guards = 58 # number of relays (including guards)
|
|
|
|
- num_authorities = 2 # will also act as a relay or guard
|
|
|
|
- num_exits = 60 # will be used only as an exit
|
|
|
|
- num_streams_per_client = 8
|
|
|
|
- num_bytes = 10*(2**20)
|
|
|
|
|
|
+ num_clients = 100
|
|
|
|
+ num_guards = 300 # number of relays (including guards)
|
|
|
|
+ num_authorities = 3 # will also act as a relay or guard
|
|
|
|
+ num_exits = 300 # will be used only as an exit
|
|
|
|
+ num_streams_per_client = 6
|
|
|
|
+ num_bytes = 5*(2**20)
|
|
elif host is None:
|
|
elif host is None:
|
|
num_clients = 10
|
|
num_clients = 10
|
|
num_guards = 10 # number of relays (including guards)
|
|
num_guards = 10 # number of relays (including guards)
|
|
@@ -329,11 +353,11 @@ if __name__ == '__main__':
|
|
os.mkdir(save_data_path)
|
|
os.mkdir(save_data_path)
|
|
logging.info('Starting on {} using {}-{} ({}), repeat {}, attempt {}'.format(host, tor_name, num_additional_eventloops, tor_path, repeat, attempt))
|
|
logging.info('Starting on {} using {}-{} ({}), repeat {}, attempt {}'.format(host, tor_name, num_additional_eventloops, tor_path, repeat, attempt))
|
|
#
|
|
#
|
|
- #experiment = CustomExperiment(args.helgrind, args.target_tor, save_data_path, measureme_log_path, args.num_bytes,
|
|
|
|
- experiment = CustomExperiment(args.helgrind, tor_path, num_additional_eventloops, host, save_data_path,
|
|
|
|
- measureme_log_path, num_bytes,
|
|
|
|
- num_streams_per_client, num_clients, num_guards, num_authorities, num_exits,
|
|
|
|
- build_circuit_generator, args.buffer_len, args.wait_range, measureme, test_network=False)
|
|
|
|
|
|
+ #exp = CustomExperiment(args.helgrind, args.target_tor, save_data_path, measureme_log_path, args.num_bytes,
|
|
|
|
+ exp = CustomExperiment(args.helgrind, tor_path, num_additional_eventloops, host, save_data_path,
|
|
|
|
+ measureme_log_path, num_bytes,
|
|
|
|
+ num_streams_per_client, num_clients, num_guards, num_authorities, num_exits,
|
|
|
|
+ build_circuit_generator, args.buffer_len, args.wait_range, measureme, test_network=False)
|
|
#
|
|
#
|
|
def sleep_then_run(duration, func):
|
|
def sleep_then_run(duration, func):
|
|
logging.info('Sleeping for {} seconds before running \'{}\''.format(duration, func.__name__))
|
|
logging.info('Sleeping for {} seconds before running \'{}\''.format(duration, func.__name__))
|
|
@@ -345,9 +369,9 @@ if __name__ == '__main__':
|
|
#p = subprocess.Popen(['ssh', '-t', 'sengler-rpi', 'python3 /tmp/log_system_usage.py /tmp/usage.gz'])
|
|
#p = subprocess.Popen(['ssh', '-t', 'sengler-rpi', 'python3 /tmp/log_system_usage.py /tmp/usage.gz'])
|
|
#
|
|
#
|
|
try:
|
|
try:
|
|
- experiment.start_system_logging(lambda: experiment.start_remote_logging(lambda: experiment.start_chutney(lambda: experiment.start_throughput_server(lambda: sleep_then_run(20, experiment.start_throughput_clients)))))
|
|
|
|
- except (stem.Timeout, stem.CircuitExtensionFailed):
|
|
|
|
- tries = 5
|
|
|
|
|
|
+ exp.start_chutney(lambda: exp.start_throughput_server(lambda: sleep_then_run(120, lambda: exp.start_system_logging(lambda: exp.start_remote_logging(exp.start_throughput_clients)))))
|
|
|
|
+ except (stem.Timeout, stem.CircuitExtensionFailed, experiment.RepeatExperimentError):
|
|
|
|
+ tries = 9
|
|
attempt += 1
|
|
attempt += 1
|
|
if attempt < tries:
|
|
if attempt < tries:
|
|
logging.exception('Experiment run failed, trying again ({} tries remaining)'.format(tries-attempt))
|
|
logging.exception('Experiment run failed, trying again ({} tries remaining)'.format(tries-attempt))
|
|
@@ -356,11 +380,14 @@ if __name__ == '__main__':
|
|
raise
|
|
raise
|
|
#
|
|
#
|
|
#
|
|
#
|
|
- shutil.copytree('/tmp/chutney-net/nodes', os.path.join(save_data_path, 'nodes'))
|
|
|
|
|
|
+ shutil.copytree('/run/user/3271/chutney-net/nodes', os.path.join(save_data_path, 'nodes'))
|
|
os.system("ps u | grep 'tor'")
|
|
os.system("ps u | grep 'tor'")
|
|
- os.system("rm -rf /tmp/chutney-net/*")
|
|
|
|
|
|
+ os.system("rm -rf /run/user/3271/chutney-net/*")
|
|
break
|
|
break
|
|
#
|
|
#
|
|
|
|
+ exp = None
|
|
|
|
+ gc.collect()
|
|
|
|
+ # not sure if this is actually useful, but hopefully it reduces memory usage for when we need to fork
|
|
#
|
|
#
|
|
#
|
|
#
|
|
#
|
|
#
|