This commit is contained in:
Pascal Engélibert 2026-01-20 09:54:13 +01:00
commit b3f7476b82
4 changed files with 152 additions and 25 deletions

145
exp.py
View file

@ -4,15 +4,18 @@ import os, sys, subprocess
CONFIGS = {
"debug": {
"experiments": [
"impl-cipher-ver",
"impl-cert-ver",
"impl-kex-ver",
"zrtt",
],
"setups": [
#"none-local",
"none-local",
"client-local",
#"server-local",
"server-local",
],
"records": [
{ "filename": "youtube", "repeat": 1 },
{ "filename": "wikipedia", "repeat": 1 },
],
"repodir": "/home/tuxmain/reps/tlsbench",
"expdir": "/dev/shm/exp",
@ -22,6 +25,7 @@ CONFIGS = {
"p2_repodir": "/home/tuxmain/reps/tlsbench",
"wattmeter": False,
"perf": False,
"rapl": False,
"perf_dir": "/home/tuxmain/.cache/exp",
"p3_suffix": ".localhost",
"p3_port_plain": 8080,
@ -50,6 +54,7 @@ CONFIGS = {
"p2_repodir": "/home/tuxmain/reps/tlsbench",
"wattmeter": False,
"perf": True,
"rapl": False,
"perf_dir": "/home/tuxmain/.cache/exp",
"p3_suffix": ".localhost",
"p3_port_plain": 8080,
@ -69,7 +74,7 @@ CONFIGS = {
"server",
],
"records": [
{ "filename": "youtube", "repeat": 1 },
{ "filename": "wikipedia", "repeat": 500 },
],
"repodir": "/home/tuxmain/reps/tlsbench",
"expdir": "/dev/shm/exp",
@ -81,10 +86,11 @@ CONFIGS = {
"p2_repodir": "/home/exp/exp",
"wattmeter": True,
"perf": False,
"rapl": False,
"p3_suffix": "",
"p3_port_plain": 80,
"p3_port_tls": 443,
"idle": "idle - - - - - - - 600.000081539154 0.0 896 4792 0.5399999999999991 -",
"idle": "idle - - - - - - - 600.000081539154 0.0 896 4792 0.5399999999999991 0 -",
},
"pi3-local": {
"experiments": [
@ -108,6 +114,7 @@ CONFIGS = {
"p2_repodir": "/home/exp/exp",
"wattmeter": False,
"perf": True,
"rapl": False,
"perf_dir": "/home/exp/.cache/exp",
"p3_suffix": ".localhost",
"p3_port_plain": 8080,
@ -139,10 +146,11 @@ CONFIGS = {
"p2_repodir": "/home/exp/exp",
"wattmeter": True,
"perf": False,
"rapl": False,
"p3_suffix": "",
"p3_port_plain": 80,
"p3_port_tls": 443,
"idle": "idle - - - - - - - 600.0001013278961 0.0 735 4942 1.7759999999999962 -",
"idle": "idle - - - - - - - 600.0001013278961 0.0 735 4942 1.7759999999999962 0 -",
},
"core2-local": {
"experiments": [
@ -166,6 +174,66 @@ CONFIGS = {
"p2_repodir": "/home/exp/exp",
"wattmeter": False,
"perf": True,
"rapl": False,
"perf_dir": "/home/exp/.cache/exp",
"p3_suffix": ".localhost",
"p3_port_plain": 8080,
"p3_port_tls": 8443,
},
# i7-4790 -> i5-7300HQ
"i5": {
"experiments": [
"impl-cipher-ver",
"impl-cert-ver",
"impl-kex-ver",
],
"setups": [
"none",
"client",
"server",
],
"records": [
{ "filename": "wikipedia", "repeat": 100 },
],
"repodir": "/home/tuxmain/reps/tlsbench",
"expdir": "/dev/shm/exp",
"log_backup_dir": "/home/tuxmain",
"p2_hostname": "192.168.3.42",
"p2_addr": "192.168.3.42",
"p2_ssh": "exp@192.168.3.42",
"p2_psw": None,
"p2_repodir": "/home/exp/exp",
"wattmeter": True,
"perf": False,
"rapl": True,
"p3_suffix": "",
"p3_port_plain": 80,
"p3_port_tls": 443,
"idle": "idle - - - - - - - 600.0001013278961 0.0 735 4942 1.7759999999999962 0 -",
},
"i5-local": {
"experiments": [
"impl-cipher-ver",
"impl-cert-ver",
"impl-kex-ver",
],
"setups": [
"none-local",
"client-local",
"server-local",
],
"records": [
{ "filename": "wikipedia", "repeat": 10 },
],
"repodir": "/home/exp/exp",
"expdir": "/dev/shm/exp",
"log_backup_dir": "/home/exp",
"p2_hostname": "localhost",
"p2_addr": "127.0.0.1",
"p2_repodir": "/home/exp/exp",
"wattmeter": False,
"perf": True,
"rapl": False,
"perf_dir": "/home/exp/.cache/exp",
"p3_suffix": ".localhost",
"p3_port_plain": 8080,
@ -234,9 +302,10 @@ CERT_SIGN_ALGS = [
IMPLS = [
"aws_lc", # Amazon's Rust crypto widely used in Rust stuff
"boring", # Google's fork of OpenSSL used in Chrome and Android
"graviola", # New crypto in Rust
"openssl", # widely used
"ring", # used in most Rust stuff
#"symcrypt", # Microsoft's crypto
"symcrypt", # Microsoft's crypto
#"wolfcrypt" # used in embedded (won't build with rpxy for now)
]
# Symmetric ciphers
@ -346,7 +415,7 @@ EXPERIMENTS = {
# Some algorithms are not available in all implementations
def alg_filter(kex, cert, cipher, impl):
if "MLKEM" in kex and impl != "openssl" and impl != "aws_lc":
if "MLKEM" in kex and impl != "openssl" and impl != "aws_lc" and impl != "graviola":
return False
if kex == "SECP256R1MLKEM768" and impl == "openssl":
return False
@ -584,14 +653,15 @@ def make_rpxy_config(outdir, domains, cryptodir, config_name, p3_suffix, p3_port
))
f.close()
def make_everything(expdir, domains, make_ca, p3_suffix, p3_port_plain, p3_port_tls):
os.makedirs(expdir, exist_ok=True)
if expdir[-1] != "/":
expdir += "/"
for alg in CERT_SIGN_ALGS:
algdir = expdir+"certs/"+alg
os.makedirs(algdir, exist_ok=True)
make_certs(algdir, domains, alg, make_ca)
def make_everything(expdir, domains, make_ca, config_only, p3_suffix, p3_port_plain, p3_port_tls):
if not config_only:
os.makedirs(expdir, exist_ok=True)
if expdir[-1] != "/":
expdir += "/"
for alg in CERT_SIGN_ALGS:
algdir = expdir+"certs/"+alg
os.makedirs(algdir, exist_ok=True)
make_certs(algdir, domains, alg, make_ca)
# this will be a symbolic link to the chosen certs directory
cryptodir = expdir+"current_certs"
configdir = expdir+"configs/"
@ -671,6 +741,15 @@ def get_net_stat(ssh):
bytes_out = int(items[8])
return (bytes_in, bytes_out)
def get_rapl_energy(ssh, expdir):
res = ssh_run(ssh, expdir+"/powercap", hide=True)
items = res.split("\n")
energy = 0
for item in items:
if item != "" and item != "-1":
energy += int(item)
return energy
def run_exp(config, only_record=None, idle=False):
ssh = None
if "p2_ssh" in config:
@ -702,7 +781,7 @@ def run_exp(config, only_record=None, idle=False):
logfile_name = "log-"+timestr
logfile_path = expdir+"/"+logfile_name
logfile = open(logfile_path, "w")
logfile.write("exp impl alg kex cipher ed setup record time cpu bytes_in bytes_out Wh prof\n")
logfile.write("exp impl alg kex cipher ed setup record time cpu bytes_in bytes_out Wh Wh_rapl prof\n")
logfile.close()
perf_dir = ""
@ -715,27 +794,34 @@ def run_exp(config, only_record=None, idle=False):
rpxy_cpu = get_cpu_stat(ssh)
p2_bytes_in, p2_bytes_out = get_net_stat(ssh)
energy = 0
energy_rapl
if config["wattmeter"]:
energy = wattmeter.get_meter()
if config["rapl"]:
energy_rapl = get_rapl_energy(ssh)
start = time.time()
time.sleep(600)
end = time.time()
new_energy = 0
new_energy_rapl = 0
if config["wattmeter"]:
new_energy = wattmeter.get_meter()
if config["rapl"]:
new_energy_rapl = get_rapl_energy(ssh)
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
new_rpxy_cpu = get_cpu_stat(ssh)
rpxy_cpu_diff = new_rpxy_cpu - rpxy_cpu
p2_bytes_in_diff = new_p2_bytes_in - p2_bytes_in
p2_bytes_out_diff = new_p2_bytes_out - p2_bytes_out
energy_diff = new_energy - energy
energy_rapl_diff = new_energy_rapl - energy_rapl
time_diff = end - start
while True:
try:
with open(logfile_path, "a") as logfile:
logfile.write(f"idle - - - - - - - {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} -\n")
logfile.write(f"idle - - - - - - - {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} {energy_rapl_diff} -\n")
logfile.close()
break
except Exception as e:
@ -790,8 +876,11 @@ def run_exp(config, only_record=None, idle=False):
rpxy_cpu = get_cpu_stat(ssh)
p2_bytes_in, p2_bytes_out = get_net_stat(ssh)
energy = 0
energy_rapl = 0
if config["wattmeter"]:
energy = wattmeter.get_meter()
if config["rapl"]:
energy_rapl = get_rapl_energy(ssh)
start = time.time()
netreplay = run_netreplay(
@ -841,8 +930,11 @@ def run_exp(config, only_record=None, idle=False):
end = time.time()
new_energy = 0
new_energy_rapl = 0
if config["wattmeter"]:
new_energy = wattmeter.get_meter()
if config["rapl"]:
new_energy_rapl = get_rapl_energy(ssh)
new_p2_bytes_in, new_p2_bytes_out = get_net_stat(ssh)
new_rpxy_cpu = get_cpu_stat(ssh)
record_filename = record["filename"]
@ -850,11 +942,12 @@ def run_exp(config, only_record=None, idle=False):
p2_bytes_in_diff = new_p2_bytes_in - p2_bytes_in
p2_bytes_out_diff = new_p2_bytes_out - p2_bytes_out
energy_diff = new_energy - energy
energy_rapl_diff = new_energy_rapl - energy_rapl
time_diff = end - start
while True:
try:
with open(logfile_path, "a") as logfile:
logfile.write(f"{expname} {impl} {alg} {kex} {cipher} {earlydata} {setup} {record_filename} {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} {prof_filename}\n")
logfile.write(f"{expname} {impl} {alg} {kex} {cipher} {earlydata} {setup} {record_filename} {time_diff} {rpxy_cpu_diff} {p2_bytes_in_diff} {p2_bytes_out_diff} {energy_diff} {energy_rapl_diff} {prof_filename}\n")
logfile.close()
break
except Exception as e:
@ -909,14 +1002,15 @@ def connect_ssh(config):
if __name__ == "__main__":
if len(sys.argv) < 2 or sys.argv[1] in ["h", "help", "?", "-h", "-help", "--help", "/?"]:
print("""Options:
make <config> [-c] Create everything
cert <config> <alg> Select cert signature algorithm
send <config> Send configs and certs to p2
update-certs <config> Update system's certs
run <config> Run experiment
make <config> [-c] [-o] Create everything
cert <config> <alg> Select cert signature algorithm
send <config> Send configs and certs to p2
update-certs <config> Update system's certs
run <config> Run experiment
Make options:
-c Make CA cert (otherwise use already existing one)
-o Make only configs (do not make certs)
Cert options:
<alg> One of: {sig_algs}
@ -940,7 +1034,8 @@ Run options:
if opt == "make":
config = CONFIGS[sys.argv[2]]
make_ca = "-c" in sys.argv
make_everything(config["expdir"], DOMAINS, make_ca, config["p3_suffix"], config["p3_port_plain"], config["p3_port_tls"])
config_only = "-o" in sys.argv
make_everything(config["expdir"], DOMAINS, make_ca, config_only, config["p3_suffix"], config["p3_port_plain"], config["p3_port_tls"])
elif opt == "cert":
alg = sys.argv[3]
if not alg in CERT_SIGN_ALGS: