script log and choice the best frequency between 5000-5900

hello guys

i need a script for log and choice the best frequency between 5000-5900
best frequency = higher bandwidth (test by ap ping with 60000 packet size)

example :

loop { }
script set frequency 5000 and ping 172.16.1.1 with 60000 packet size
if result is ok (host reachable and pinging),
then frequency 5010 set (log) to line 3 on file.rsc (on file)

script set frequency 5005 and ping 172.16.1.1 with 60000 packet size
if result is ok (host reachable and pinging),
then frequency 5010 set (log) to line 3 on file.rsc (on file)

script set frequency 5010 and ping 172.16.1.1 with 60000 packet size
if result is ok (host reachable and pinging),
then frequency 5010 set (log) to line 3 on file.rsc (on file)

script set frequency 5010 and ping 172.16.1.1 with 60000 packet size
if result is no (host unreachable),
then change frequency (go to next frequency)

please help me

by something with spectral scan and you don’t need such tase of time!