Hi,
I'm trying to detect if some devices in my network are connected and rensponding to ping.
I've run into a problem, the later requests time out.
This leads me to believe, that the HTTP requests are handled in series and can not execute multiple commands simultaneously.
If I launch multiple terminal sessions and send pings in there, they can run in parallel.
Is this expected behaviour, or bug?
Thanks for reply,
Jan
My test setup:
RouterOS version: 7.20.4
dispatch powershell script, which starts processes, that ping individual devices in parallel by launching python script:
pings.ps1:
$IPs = '192.168.88.16', '192.168.88.18', '192.168.88.25', '192.168.88.12', '192.168.88.11', '192.168.88.44', '192.168.88.17', '192.168.88.19', '192.168.88.20', '192.168.88.26', '192.168.88.14', '192.168.88.5', '192.168.88.100', '192.168.88.101', '192.168.88.102', '192.168.88.103', '192.168.88.191', '192.168.88.105', '192.168.88.106', '192.168.88.21', '192.168.88.24', '192.168.88.13'
foreach($IP in $IPs){
Start-Process -FilePath "python" -NoNewWindow -ArgumentList ".\dispatchping.py", $IP
}
dispatchping.py:
import requests
from requests.auth import HTTPBasicAuth
import sys
Username = "admin"
Password = "XXXXXXXXXXXXXXXXXX"
addr = sys.argv[1]
print("ping", addr)
URL = f"http://192.168.88.1/rest/ping"
try:
res = requests.post(
URL,
auth=HTTPBasicAuth(Username, Password),
data = f'{{"address":"{addr}","count":"4"}}',
timeout=10
)
except requests.exceptions.Timeout:
print("ERR_CONN")
exit(-1)
print(res.json()[0]["packet-loss"])
this outputs
ping 192.168.88.25
ping 192.168.88.16
ping 192.168.88.12
ping 192.168.88.44
ping 192.168.88.19
ping 192.168.88.11
ping 192.168.88.17
ping 192.168.88.5
ping 192.168.88.26
ping 192.168.88.101
ping 192.168.88.14
ping 192.168.88.20
ping 192.168.88.100
ping 192.168.88.191
ping 192.168.88.102
ping 192.168.88.103
ping 192.168.88.21
ping 192.168.88.106
ping 192.168.88.105
ping 192.168.88.13
ping 192.168.88.24
100
100
0
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
ERR_CONN
if I dispatch with waiting on each request:
$IPs = '192.168.88.16', '192.168.88.18', '192.168.88.25', '192.168.88.12', '192.168.88.11', '192.168.88.44', '192.168.88.17', '192.168.88.19', '192.168.88.20', '192.168.88.26', '192.168.88.14', '192.168.88.5', '192.168.88.100', '192.168.88.101', '192.168.88.102', '192.168.88.103', '192.168.88.191', '192.168.88.105', '192.168.88.106', '192.168.88.21', '192.168.88.24', '192.168.88.13'
foreach($IP in $IPs){
Start-Process -FilePath "python" -NoNewWindow -ArgumentList ".\dispatchping.py", $IP -Wait
}
every ping works as expected:
ping 192.168.88.16
0
ping 192.168.88.18
100
ping 192.168.88.25
100
ping 192.168.88.12
0
ping 192.168.88.11
100
ping 192.168.88.44
0
ping 192.168.88.17
0
ping 192.168.88.19
100
ping 192.168.88.20
100
ping 192.168.88.26
100
ping 192.168.88.14
100
ping 192.168.88.5
0
ping 192.168.88.100
100
ping 192.168.88.101
0
ping 192.168.88.102
0
ping 192.168.88.103
100
ping 192.168.88.191
0
ping 192.168.88.105
0
ping 192.168.88.106
0
ping 192.168.88.21
100
ping 192.168.88.24
0
ping 192.168.88.13
100