First commit
This commit is contained in:
2
disable_eth.sh
Normal file
2
disable_eth.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
nmcli c down 4b0d7d27-8946-3f20-b79e-452e993df245
|
||||
2
enable_eth.sh
Normal file
2
enable_eth.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
nmcli c up 4b0d7d27-8946-3f20-b79e-452e993df245
|
||||
41
plotting.py
Normal file
41
plotting.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import csv
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import sys
|
||||
from datetime import datetime
|
||||
import math
|
||||
|
||||
time_data = []
|
||||
ping_data = []
|
||||
jitter_data = []
|
||||
up_data = []
|
||||
down_data = []
|
||||
|
||||
for i in range(1, len(sys.argv)):
|
||||
with open(sys.argv[i], 'r', newline='\n') as csvfile:
|
||||
reader = csv.reader(csvfile)
|
||||
line_count = 0
|
||||
for row in reader:
|
||||
if line_count != 0:
|
||||
time_data.append(datetime.fromtimestamp(float(row[0])))
|
||||
ping_data.append(float(row[1]))
|
||||
jitter_data.append(float(row[2]))
|
||||
down_data.append(int(row[10]) / 1000000)
|
||||
up_data.append(int(row[11]) / 1000000)
|
||||
line_count += 1
|
||||
|
||||
fig_length = -11.36 + 5.46 * math.log(len(time_data))
|
||||
fig_length = max(6, fig_length)
|
||||
print(fig_length)
|
||||
plt.figure(figsize=[int(fig_length),6])
|
||||
plt.plot(time_data, down_data)
|
||||
plt.plot(time_data, up_data)
|
||||
plt.legend(['down', 'up'])
|
||||
plt.gcf().autofmt_xdate()
|
||||
plt.savefig("bandwidth.svg")
|
||||
plt.figure(figsize=[6,6])
|
||||
plt.plot(time_data, ping_data)
|
||||
plt.plot(time_data, jitter_data)
|
||||
plt.legend(['ping', 'jitter'])
|
||||
plt.savefig("ping_jitter.svg")
|
||||
|
||||
49
speedtesting.py
Normal file
49
speedtesting.py
Normal file
@@ -0,0 +1,49 @@
|
||||
from cfspeedtest import CloudflareSpeedtest
|
||||
import os
|
||||
import csv
|
||||
import datetime
|
||||
|
||||
def run_test():
|
||||
suite = CloudflareSpeedtest()
|
||||
results = suite.run_all()
|
||||
tests = results['tests']
|
||||
time = tests['isp'].time
|
||||
latency = tests['latency'].value
|
||||
jitter = tests['jitter'].value
|
||||
h_down = tests['100kB_down_bps'].value
|
||||
o_down = tests['1MB_down_bps'].value
|
||||
t_down = tests['10MB_down_bps'].value
|
||||
q_down = tests['25MB_down_bps'].value
|
||||
np_down = tests['90th_percentile_down_bps'].value
|
||||
h_up = tests['100kB_up_bps'].value
|
||||
o_up = tests['1MB_up_bps'].value
|
||||
t_up = tests['10MB_up_bps'].value
|
||||
np_up = tests['90th_percentile_up_bps'].value
|
||||
return [time, latency, jitter, h_down, o_down, t_down, q_down, h_up, o_up, t_up, np_down, np_up]
|
||||
|
||||
def write_data(filename, data):
|
||||
with open(filename, 'a', newline='\n') as csvfile:
|
||||
writer = csv.writer(csvfile)
|
||||
if os.path.getsize(filename) == 0:
|
||||
writer.writerow(['time','latency','jitter','100kB_down','1MB_down','10MB_down','25MB_down','100kB_up','1MB_up','10MB_up','90th_percentile_down','90th_percentile_up'])
|
||||
writer.writerow(data)
|
||||
|
||||
now = datetime.datetime.now()
|
||||
date = now.strftime("%d-%m-%Y")
|
||||
filename_lan = 'results_' + date + '_lan.csv'
|
||||
filename_wlan = 'results_' + date + '_wlan.csv'
|
||||
|
||||
lan_data = run_test()
|
||||
write_data(filename_lan, lan_data)
|
||||
#if os.system("/bin/bash /home/pi/speedtesting/disable_eth.sh") == 0:
|
||||
# print('Disabled ethernet')
|
||||
# wlan_data = run_test()
|
||||
# if os.system("/bin/bash /home/pi/speedtesting/enable_eth.sh") == 0:
|
||||
# print('Enabled ethernet')
|
||||
# else:
|
||||
# print('Error enabling ethernet')
|
||||
# write_data(filename_wlan, wlan_data)
|
||||
#else:
|
||||
# print('Error disabling ethernet')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user