LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Ping and timeout (https://www.linuxquestions.org/questions/linux-newbie-8/ping-and-timeout-495881/)

sjuk 10-26-2006 05:22 PM

Ping and timeout
 
I need to ping something :) and get a response fast. If the "thing" doesn't answer the dafault timeout is too long. How can i make it faster?

I think it should be something like:

ping -w0.05 10.0.0.1

but i cant get it to work.

:newbie:

pljvaldez 10-26-2006 05:34 PM

You can just hit Ctrl+C if it's taking too long.

gilead 10-26-2006 05:37 PM

The -w switch just tells ping how long to wait before timing out and exiting - it doesn't actually speed up the time of the response. The response time mainly depends on the network latency and can't be set using ping.

sjuk 10-27-2006 01:59 AM

Thanx guys, but it's not what i need.

I'm making a php script to ping a large wlan. That means every time the page loads it will ping about 200 routers. If six of those routers are offline i will have to wait 1 minute for the page to load with the default timeout. If one of the routers dont responde in 50ms I can assume there is something wrong, and it should time out.

shell_exec("ping -c1 -t0.05 10.0.0.51");

works fine on windows, but on linux the timeout is just to long.

Please help!

:Pengy:

gilead 10-27-2006 03:03 PM

My apologies - I see what you mean. I haven't been able to get -w working for values less than 1 second here.
Code:

$ time ping -w 1 -c1 165.86.4.1
PING 165.86.4.1 (165.86.4.1) 56(84) bytes of data.

--- 165.86.4.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms


real    0m1.005s
user    0m0.000s
sys    0m0.004s

Setting TTL with -t 1 gives the following results here though:
Code:

$ time ping -t 1 -c1 165.86.4.1
PING 165.86.4.1 (165.86.4.1) 56(84) bytes of data.
From 203.55.xxx.8 icmp_seq=1 Time to live exceeded

--- 165.86.4.1 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms


real    0m0.018s
user    0m0.000s
sys    0m0.000s
$ time ping -t 1 -c1 localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.074 ms

--- localhost ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.074/0.074/0.074/0.000 ms

real    0m0.003s
user    0m0.000s
sys    0m0.000s


sjuk 10-31-2006 03:44 AM

Hi again and thanx for the reply.

Still cant get it to work. Maybe its the shell_exec command that works differently on linux and this post should in a php forum. Ill look around.

Thanx again

sic


All times are GMT -5. The time now is 05:32 AM.