The goal is to write a script that measures the response time of a Google server to the ping command and plots the results as a histogram.
So far this is my code for obtaining a 10 ping latency dataset:
import subprocess
from subprocess import check_output, Popen, call, PIPE, STDOUT
latency = []
p = Popen('ping -n 10 google.com', stdout = PIPE, stderr = STDOUT, shell = True)
for line in p.stdout:
lntxt = line.decode('utf-8').rstrip()
words = lntxt.split(' ')
if words[0] == 'Reply':
print(words[4])
latency.append(words[4])
print(latency)
Using this the output should be something like this:
[5, 13, 12, 11, 9, 11, 11, 4, 12, 10]
Then i would like to plot the latencies. I would appreciate any help with the plotting part.
Thanks in advance.
