Adds some QOL.
This commit is contained in:
@@ -166,7 +166,25 @@ def activate_hystart():
|
|||||||
|
|
||||||
|
|
||||||
def is_hystart_activated():
|
def is_hystart_activated():
|
||||||
return subprocess.check_output('cat /sys/module/tcp_cubic/parameters/hystart', shell=True) == "1"
|
return (
|
||||||
|
subprocess.check_output(
|
||||||
|
"cat /sys/module/tcp_cubic/parameters/hystart", shell=True
|
||||||
|
)
|
||||||
|
== "1"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def is_tcp_probe_enabled():
|
||||||
|
return (
|
||||||
|
subprocess.check_output(
|
||||||
|
"cat /sys/kernel/debug/tracing/events/tcp/tcp_probe/enable", shell=True
|
||||||
|
)
|
||||||
|
== "1"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def enable_tcp_probe():
|
||||||
|
os.system("echo '1' > /sys/kernel/debug/tracing/events/tcp/tcp_probe/enable")
|
||||||
|
|
||||||
|
|
||||||
def set_default_receive_window():
|
def set_default_receive_window():
|
||||||
@@ -187,7 +205,9 @@ def monitor_serial(ser, output_file):
|
|||||||
run_cmds = [NR_CQI_COMMAND, NR_SERVINGCELL_COMMAND, NR_EN_DC_STATUS_COMMAND]
|
run_cmds = [NR_CQI_COMMAND, NR_SERVINGCELL_COMMAND, NR_EN_DC_STATUS_COMMAND]
|
||||||
try:
|
try:
|
||||||
while ser.is_open:
|
while ser.is_open:
|
||||||
response = subprocess.check_output(CMD_TIME_EPOCH, shell=True).decode("utf-8")
|
response = subprocess.check_output(CMD_TIME_EPOCH, shell=True).decode(
|
||||||
|
"utf-8"
|
||||||
|
)
|
||||||
for cmd in run_cmds:
|
for cmd in run_cmds:
|
||||||
ser.write(cmd)
|
ser.write(cmd)
|
||||||
sleep(0.3)
|
sleep(0.3)
|
||||||
@@ -203,9 +223,12 @@ def monitor_serial(ser, output_file):
|
|||||||
if not ser.is_open:
|
if not ser.is_open:
|
||||||
print_message("Serial port is closed. Exit monitoring thread.")
|
print_message("Serial port is closed. Exit monitoring thread.")
|
||||||
else:
|
else:
|
||||||
print_message("Something went wrong while monitoring serial interface. Exit monitoring thread.")
|
print_message(
|
||||||
|
"Something went wrong while monitoring serial interface. Exit monitoring thread."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class Server:
|
class Server:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = config
|
self.config = config
|
||||||
@@ -235,10 +258,10 @@ class Server:
|
|||||||
print_message("HARQ nothing to do on server side.")
|
print_message("HARQ nothing to do on server side.")
|
||||||
|
|
||||||
def bandwidth(self):
|
def bandwidth(self):
|
||||||
use_reverse_mode = False
|
server_is_sender = False
|
||||||
if "reverse" in self.config["set"]:
|
if "reverse" in self.config["set"]:
|
||||||
use_reverse_mode = self.config["set"]["reverse"]
|
server_is_sender = self.config["set"]["server_is_sender"]
|
||||||
print_message("Use reverse mode: {}".format(use_reverse_mode))
|
print_message("Use reverse mode: {}".format(server_is_sender))
|
||||||
|
|
||||||
tcp_algo = list()
|
tcp_algo = list()
|
||||||
if "algo" in self.config["set"]:
|
if "algo" in self.config["set"]:
|
||||||
@@ -257,12 +280,22 @@ class Server:
|
|||||||
# prevent address already in use
|
# prevent address already in use
|
||||||
sleep(2)
|
sleep(2)
|
||||||
ws_filter = ""
|
ws_filter = ""
|
||||||
if use_reverse_mode:
|
if server_is_sender:
|
||||||
# server sends
|
# server sends
|
||||||
|
if not is_tcp_probe_enabled():
|
||||||
|
print_message("tcp probe is not enabled!")
|
||||||
|
enable_tcp_probe()
|
||||||
|
print_message("tcp probe is now enabled")
|
||||||
|
|
||||||
for n in range(1, self.config["number_of_measurements"] + 1):
|
for n in range(1, self.config["number_of_measurements"] + 1):
|
||||||
print_message(
|
print_message(
|
||||||
"{} of {}".format(n, self.config["number_of_measurements"])
|
"{} of {}".format(n, self.config["number_of_measurements"])
|
||||||
)
|
)
|
||||||
|
print_message(
|
||||||
|
"Using {} for congestion control".format(
|
||||||
|
tcp_algo[congestion_control_index]
|
||||||
|
)
|
||||||
|
)
|
||||||
iperf_command = [
|
iperf_command = [
|
||||||
"iperf3",
|
"iperf3",
|
||||||
"-s",
|
"-s",
|
||||||
@@ -281,6 +314,9 @@ class Server:
|
|||||||
)
|
)
|
||||||
subprocess.call(iperf_command)
|
subprocess.call(iperf_command)
|
||||||
processHandler.kill_all()
|
processHandler.kill_all()
|
||||||
|
congestion_control_index = (congestion_control_index + 1) % len(
|
||||||
|
tcp_algo
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# client sends
|
# client sends
|
||||||
ws_filter = "{} and port {}".format("tcp", self.config["port"])
|
ws_filter = "{} and port {}".format("tcp", self.config["port"])
|
||||||
@@ -319,7 +355,12 @@ class Server:
|
|||||||
else:
|
else:
|
||||||
name_option = ""
|
name_option = ""
|
||||||
filepath = "{}{}{}_bandwidth_{}_{}_{}.pcap".format(
|
filepath = "{}{}{}_bandwidth_{}_{}_{}.pcap".format(
|
||||||
self.config["folder"], self.config["prefix"], name_option, "tcp", tcp_algo[congestion_control_index], n
|
self.config["folder"],
|
||||||
|
self.config["prefix"],
|
||||||
|
name_option,
|
||||||
|
"tcp",
|
||||||
|
tcp_algo[congestion_control_index],
|
||||||
|
n,
|
||||||
)
|
)
|
||||||
tcpdump_flags.append("-s96")
|
tcpdump_flags.append("-s96")
|
||||||
thread = Thread(
|
thread = Thread(
|
||||||
@@ -344,7 +385,9 @@ class Server:
|
|||||||
subprocess.call(iperf_command)
|
subprocess.call(iperf_command)
|
||||||
sleep(2)
|
sleep(2)
|
||||||
processHandler.kill_all()
|
processHandler.kill_all()
|
||||||
congestion_control_index = (congestion_control_index + 1) % len(tcp_algo)
|
congestion_control_index = (congestion_control_index + 1) % len(
|
||||||
|
tcp_algo
|
||||||
|
)
|
||||||
|
|
||||||
def cbr(self):
|
def cbr(self):
|
||||||
use_reverse_mode = False
|
use_reverse_mode = False
|
||||||
@@ -479,7 +522,11 @@ class Client:
|
|||||||
self.config["number_of_measurements"],
|
self.config["number_of_measurements"],
|
||||||
)
|
)
|
||||||
command = [c]
|
command = [c]
|
||||||
print_message("Start sending {} pings with nog gap.".format(self.config["number_of_measurements"]))
|
print_message(
|
||||||
|
"Start sending {} pings with nog gap.".format(
|
||||||
|
self.config["number_of_measurements"]
|
||||||
|
)
|
||||||
|
)
|
||||||
ping_out = subprocess.check_output(command, shell=True).decode("utf-8")
|
ping_out = subprocess.check_output(command, shell=True).decode("utf-8")
|
||||||
filepath = "{}{}_ping_no_gap.txt".format(
|
filepath = "{}{}_ping_no_gap.txt".format(
|
||||||
self.config["folder"], self.config["prefix"]
|
self.config["folder"], self.config["prefix"]
|
||||||
@@ -599,10 +646,10 @@ class Client:
|
|||||||
processHandler.kill_all()
|
processHandler.kill_all()
|
||||||
|
|
||||||
def bandwidth(self):
|
def bandwidth(self):
|
||||||
use_reverse_mode = False
|
server_is_sender = False
|
||||||
if "reverse" in self.config["set"]:
|
if "reverse" in self.config["set"]:
|
||||||
use_reverse_mode = self.config["set"]["reverse"] == "true"
|
server_is_sender = self.config["set"]["reverse"] == "true"
|
||||||
print_message("Use reverse mode: {}".format(use_reverse_mode))
|
print_message("Use reverse mode: {}".format(server_is_sender))
|
||||||
|
|
||||||
tcp_algo = list()
|
tcp_algo = list()
|
||||||
if "algo" in self.config["set"]:
|
if "algo" in self.config["set"]:
|
||||||
@@ -626,7 +673,7 @@ class Client:
|
|||||||
sleep(2)
|
sleep(2)
|
||||||
|
|
||||||
congestion_control_index = 0
|
congestion_control_index = 0
|
||||||
if use_reverse_mode:
|
if server_is_sender:
|
||||||
# server is sending
|
# server is sending
|
||||||
ws_filter = "{} and port {}".format("tcp", self.config["port"])
|
ws_filter = "{} and port {}".format("tcp", self.config["port"])
|
||||||
print_message("Use ws filter: {}".format(ws_filter))
|
print_message("Use ws filter: {}".format(ws_filter))
|
||||||
@@ -635,13 +682,17 @@ class Client:
|
|||||||
"{} of {}".format(n, self.config["number_of_measurements"])
|
"{} of {}".format(n, self.config["number_of_measurements"])
|
||||||
)
|
)
|
||||||
print_message(
|
print_message(
|
||||||
"Measurement {} of {}".format(
|
"Using {} for congestion control".format(
|
||||||
n, self.config["number_of_measurements"]
|
tcp_algo[congestion_control_index]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
tcpdump_flags = []
|
tcpdump_flags = []
|
||||||
filepath = "{}{}_bandwidth_reverse_{}_{}_{}.pcap".format(
|
filepath = "{}{}_bandwidth_reverse_{}_{}_{}.pcap".format(
|
||||||
self.config["folder"], self.config["prefix"], "tcp", tcp_algo[congestion_control_index], n
|
self.config["folder"],
|
||||||
|
self.config["prefix"],
|
||||||
|
"tcp",
|
||||||
|
tcp_algo[congestion_control_index],
|
||||||
|
n,
|
||||||
)
|
)
|
||||||
tcpdump_flags.append("-s96")
|
tcpdump_flags.append("-s96")
|
||||||
thread = Thread(
|
thread = Thread(
|
||||||
@@ -669,11 +720,17 @@ class Client:
|
|||||||
subprocess.call(iperf_command)
|
subprocess.call(iperf_command)
|
||||||
sleep(4)
|
sleep(4)
|
||||||
processHandler.kill_all()
|
processHandler.kill_all()
|
||||||
congestion_control_index = (congestion_control_index + 1) % len(tcp_algo)
|
congestion_control_index = (congestion_control_index + 1) % len(
|
||||||
|
tcp_algo
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# client is sending
|
# client is sending
|
||||||
state_counter = 0
|
state_counter = 0
|
||||||
name_option = ""
|
name_option = ""
|
||||||
|
if not is_tcp_probe_enabled():
|
||||||
|
print_message("tcp probe is not enabled!")
|
||||||
|
enable_tcp_probe()
|
||||||
|
print_message("tcp probe is now enabled")
|
||||||
for n in range(1, self.config["number_of_measurements"] + 1):
|
for n in range(1, self.config["number_of_measurements"] + 1):
|
||||||
print_message(
|
print_message(
|
||||||
"{} of {}".format(n, self.config["number_of_measurements"])
|
"{} of {}".format(n, self.config["number_of_measurements"])
|
||||||
@@ -715,7 +772,9 @@ class Client:
|
|||||||
sleep(2)
|
sleep(2)
|
||||||
subprocess.call(iperf_command)
|
subprocess.call(iperf_command)
|
||||||
processHandler.kill_all()
|
processHandler.kill_all()
|
||||||
congestion_control_index = (congestion_control_index + 1) % len(tcp_algo)
|
congestion_control_index = (congestion_control_index + 1) % len(
|
||||||
|
tcp_algo
|
||||||
|
)
|
||||||
sleep(4)
|
sleep(4)
|
||||||
|
|
||||||
def cbr(self):
|
def cbr(self):
|
||||||
@@ -955,7 +1014,7 @@ if __name__ == "__main__":
|
|||||||
default=False,
|
default=False,
|
||||||
help="Measure greedy tcp throughput with iperf3."
|
help="Measure greedy tcp throughput with iperf3."
|
||||||
"Use the --set flag for: "
|
"Use the --set flag for: "
|
||||||
"reverse=false enable reverse mode. Server is sending."
|
"server_is_sender=false if enable server is sending."
|
||||||
"algo=cubic set tcp algorithm. Can be a comma separated string for multiple congestion control algorithms."
|
"algo=cubic set tcp algorithm. Can be a comma separated string for multiple congestion control algorithms."
|
||||||
"alternate_hystart=false if enabled alternate reproduce every Cubic measurement wicht and without HyStart (Also raises the receive window.). "
|
"alternate_hystart=false if enabled alternate reproduce every Cubic measurement wicht and without HyStart (Also raises the receive window.). "
|
||||||
"time=10 length of transmission in seconds.",
|
"time=10 length of transmission in seconds.",
|
||||||
|
|||||||
Reference in New Issue
Block a user