diff --git a/measurement_main.py b/measurement_main.py index 890a6c6..fad1730 100755 --- a/measurement_main.py +++ b/measurement_main.py @@ -328,6 +328,10 @@ class Server: if self.config["set"]["alternate_hystart"] == "true": alternate_hystart = True + time = "10" + if "time" in self.config["set"]: + time = self.config["set"]["time"] + # prevent address already in use sleep(2) ws_filter = "" @@ -364,7 +368,10 @@ class Server: self.config["server"], self.config["port"], ) - subprocess.call(iperf_command) + try: + subprocess.call(iperf_command, timeout=time + 1) + except: + print_message("iPerf timed out. Going ahead with next measurement...") processHandler.kill_all() congestion_control_index = (congestion_control_index + 1) % len( tcp_algo @@ -433,7 +440,10 @@ class Server: str(self.config["port"]), "--one-off", ] - subprocess.call(iperf_command) + try: + subprocess.call(iperf_command, timeout=time + 1) + except: + print_message("iPerf timed out. Going ahead with next measurement...") sleep(2) processHandler.kill_all() congestion_control_index = (congestion_control_index + 1) % len( @@ -546,7 +556,10 @@ class Client: ) ser_thread.start() + gps_ser = None + if self.config["gps"] is not None: + print_message("Opening GPS serial port for {}".format(self.config["gps"])) gps_ser = serial.Serial( self.config["gps"], baudrate=self.config["gps_baudrate"], @@ -581,6 +594,12 @@ class Client: ser.close() sleep(2) print_message("done...") + if gps_ser is not None: + print_message("Closing GPS serial port...") + gps_ser.close() + sleep(2) + print_message("done...") + def ping(self): c = "ping {} -I {} -i {} -c {}".format( @@ -787,7 +806,10 @@ class Client: "-C", tcp_algo[congestion_control_index], ] - subprocess.call(iperf_command) + try: + subprocess.call(iperf_command, timeout=time + 2) + except: + print_message("iPerf timed out. Going ahead with next measurement...") sleep(4) processHandler.kill_all() congestion_control_index = (congestion_control_index + 1) % len( @@ -842,7 +864,10 @@ class Client: self.config["port"], ) sleep(2) - subprocess.call(iperf_command) + try: + subprocess.call(iperf_command, timeout=time+2) + except: + print_message("iPerf timed out. Going ahead with next measurement...") processHandler.kill_all() congestion_control_index = (congestion_control_index + 1) % len( tcp_algo