0

I foud some Stack Overflow questions such as Ping Application in Android. It uses it like this:

Process process = Runtime.getRuntime().exec(
            "/system/bin/ping -c 8 " + url);

How can I specify the packet size and the ping times? For example, I want to ping 10 times, and specify the package length is 1472 bytes. How can I do that? Sample code is preferred.

When I modify to

Process process = Runtime.getRuntime().exec(
            "/system/bin/ping -c 8 -s 1472" + url);

it does not work. Why?

Community
  • 1
  • 1
lgw150
  • 170
  • 1
  • 3
  • 13

1 Answers1

2

The options for the ping command are:

shell@android:/ $ ping 
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
        [-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
        [-M mtu discovery hint] [-S sndbuf]
        [ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
alex
  • 6,359
  • 1
  • 23
  • 21
  • thanks,but you mean that i can modify above to this:Process process = Runtime.getRuntime().exec( "/system/bin/ping -c 8 -s 1472 " + url);? – lgw150 Apr 12 '13 at 09:20