Search code examples
clinuxpingbusyboxtiny-core-linux

Is there a way to ping faster in Busy Box or Tiny Core Linux?


Solution at end of this post.

By default the time is set to one second, and under the usual iputils version of ping there is an option to reduce this number with the -i switch. I need to ping faster, as I have 120 pings in a certain test that needs to be run many times.

I tried modifying the source of ping.c from the busybox source but I don't know much about compiling and I get the error "could not be found libbb.h" and I couldn't find anyone else with a similar error on busybox.

Does anyone know of a way for me to ping faster than 1 per second, I am hoping to go down to 0.1 or 0.05 seconds if at all possible.

Thanks in advance

Solution

In case anyone comes looking for an answer, the solution I came up with was much better. If you write a script to ping with the -c 1 flag, and count the failures yourself you can ping much faster.

Example:

fails=0
for i in `seq 1 20`
do
  x=`ping -c 1 192.168.1.1 | grep received | cut -d' ' -f4`
  if [ x -eq 0 ]
  then
    fails=$(($fails+1))
  fi
done
echo $fails fails

done


Solution

  • You are correct in that you have to modify the ping.c file. As you have determined, BusyBox ping does not support the -i switch.

    What platform are you building this for? A PC, an embedded system?

    Option 1: Modify ping.c from BusyBox and recompile BusyBox. To do this, you would use 'make' in the root of the BusyBox project.

    user@linux:~/busybox-1.19.2$ make

    Option 2: It might be easier and more simplistic to leave BusyBox alone and get ping.c from another archive such as iputils. This supports the -i switch and goes as low as 0.2 seconds. To compile ping.c:

    user@linux:~/iputils-s20101006$ make ping