In [ ]:
# https://github.com/alessandromaggio/pythonping
In [1]:
import pythonping
In [2]:
A = pythonping.ping('8.8.8.8')
In [3]:
A
Out[3]:
Reply from 8.8.8.8, 29 bytes in 6.11ms
Reply from 8.8.8.8, 29 bytes in 4.61ms
Reply from 8.8.8.8, 29 bytes in 3.16ms
Reply from 8.8.8.8, 29 bytes in 3.76ms

Round Trip Times min/avg/max is 3.16/4.41/6.11 ms
In [4]:
vars(A)
Out[4]:
{'_responses': [Reply from 8.8.8.8, 29 bytes in 6.11ms,
  Reply from 8.8.8.8, 29 bytes in 4.61ms,
  Reply from 8.8.8.8, 29 bytes in 3.16ms,
  Reply from 8.8.8.8, 29 bytes in 3.76ms],
 'stats_packets_sent': 4,
 'stats_packets_returned': 4,
 'verbose': False,
 'output': <ipykernel.iostream.OutStream at 0x133ab6a54e0>,
 'rtt_avg': 0.0044096249985159375,
 'rtt_min': 0.0031579999995301478,
 'rtt_max': 0.006113199997344054}
In [5]:
vars(A._responses[0])
Out[5]:
{'message': 45 60 00 1d 00 00 00 00 74 01 73 bd 08 08 08 08 c0 a8 02 0b 00 00 23 dd 97 22 01 00 44,
 'time_elapsed': 0.006113199997344054,
 'source_request': 08 00 1b dd 97 22 01 00 44,
 'repr_format': 'legacy'}
In [6]:
A._responses[0].time_elapsed
Out[6]:
0.006113199997344054
In [7]:
type(A._responses[0].time_elapsed)
Out[7]:
float
In [8]:
B = pythonping.ping('8.8.8.8', count=100)
In [9]:
B_list = [response.time_elapsed for response in B._responses]
In [10]:
type(B_list)
Out[10]:
list
In [11]:
import numpy as np
In [12]:
B_np = np.array(B_list)
In [13]:
import matplotlib.pyplot as plt
In [14]:
plt.xlabel("Ping")
plt.ylabel("Response time (ms)")
plt.plot(1000*B_np)
Out[14]:
[<matplotlib.lines.Line2D at 0x133ada80a60>]
In [15]:
C = pythonping.ping('8.8.8.8', count=1000, interval=1)
In [16]:
C_list = [response.time_elapsed for response in C._responses]
C_np = np.array(C_list)
In [17]:
plt.title("9:10 PM January 1, 2022")
plt.xlabel("Ping")
plt.ylabel("Response time (ms)")
plt.plot(1000*C_np)
Out[17]:
[<matplotlib.lines.Line2D at 0x133adc5ee90>]
In [18]:
np.savetxt('01-01-2023-910pm.csv', 1000*C_np, fmt='%.6f')