469,338 Members | 8,430 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

how to measure the ping time between the visitor and my website ??

hello !

I would like to measure the time a user needs to connect to my website.
In other words, to perform a ping between my website and the user's
computer.

I'm scratching my head as to how i can do that. Does anyone know a good way
to make this happen?

thanks a lot,

alexandre
Jul 17 '05 #1
14 5341
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
hello !

I would like to measure the time a user needs to connect to my website.
In other words, to perform a ping between my website and the user's
computer.

I'm scratching my head as to how i can do that. Does anyone know a good way to make this happen?

thanks a lot,

alexandre

Here you go
<?
$ip = $_SERVER['REMOTE_ADDR'];
$res = `ping -c 1 $ip`;

list($n,$r) = explode("packet loss, ",$res);
list($pTime,$n) = explode("ms",$r);
print "Ping time $pTime ms";
?>

you can test it here:
http://gzen.myhq.info/test/ping.php
Ok, now several things wrong with this, first, this will only work if ping
packets are allowed through the entire netork from you to them, inside thier
network if they are in say a corporate building. Now if they are behind a
firewall, you will only get times to the firewall. (depends on firewall, but
most likely, firewall times)

Now, this also assumes they dont have any type of stupid software like
black-ice, (sorry to offend, but if you have a software firewall installed
on the machine you are trying to protect, your an idiot, get a solution
before the machine you are protect!) -- ok sorry about that

Also, the route that someone uses to send packets to you is not nessasarily
the route the packets take from you to them. For example. At one of my data
centers, outgoing data is routed through the least congested pipe.

--
Mike Bradley
http://gzen.myhq.info -- free online php tools

Jul 17 '05 #2
thanks a lot mike.

I'm gettting 0 ms all the time. Is that normal ?
Also, would this work on a virtual server? I heard Virtual servers don't
let you execute commands with php, as you could use it to execute "rm -rf /"
or other bad things. So, they set this in their php.ini.
What do you think ?

thanks again,

alexandre
PS: nice website :)

"CountScubula" <me@scantek.hotmail.com> wrote in message
news:jK****************@newssvr29.news.prodigy.com ...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
hello !

I would like to measure the time a user needs to connect to my website.
In other words, to perform a ping between my website and the user's
computer.

I'm scratching my head as to how i can do that. Does anyone know a good way
to make this happen?

thanks a lot,

alexandre


Here you go
<?
$ip = $_SERVER['REMOTE_ADDR'];
$res = `ping -c 1 $ip`;

list($n,$r) = explode("packet loss, ",$res);
list($pTime,$n) = explode("ms",$r);
print "Ping time $pTime ms";
?>

you can test it here:
http://gzen.myhq.info/test/ping.php
Ok, now several things wrong with this, first, this will only work if ping
packets are allowed through the entire netork from you to them, inside

thier network if they are in say a corporate building. Now if they are behind a
firewall, you will only get times to the firewall. (depends on firewall, but most likely, firewall times)

Now, this also assumes they dont have any type of stupid software like
black-ice, (sorry to offend, but if you have a software firewall installed on the machine you are trying to protect, your an idiot, get a solution
before the machine you are protect!) -- ok sorry about that

Also, the route that someone uses to send packets to you is not nessasarily the route the packets take from you to them. For example. At one of my data centers, outgoing data is routed through the least congested pipe.

--
Mike Bradley
http://gzen.myhq.info -- free online php tools


Jul 17 '05 #3
The test on my server, is a virual host, I have around 65 virtuals on that
server
rm -fr will only work on files that are the same owner/group permission
as far as 0ms, not sure, you must be realy, realy, close to me, but I didnt
see you at the office coffee maker :)

--
Mike Bradley
http://gzen.myhq.info -- free online php tools
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
thanks a lot mike.

I'm gettting 0 ms all the time. Is that normal ?
Also, would this work on a virtual server? I heard Virtual servers don't
let you execute commands with php, as you could use it to execute "rm -rf /" or other bad things. So, they set this in their php.ini.
What do you think ?

thanks again,

alexandre
PS: nice website :)

"CountScubula" <me@scantek.hotmail.com> wrote in message
news:jK****************@newssvr29.news.prodigy.com ...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
hello !

I would like to measure the time a user needs to connect to my website. In other words, to perform a ping between my website and the user's
computer.

I'm scratching my head as to how i can do that. Does anyone know a
good way
to make this happen?

thanks a lot,

alexandre


Here you go
<?
$ip = $_SERVER['REMOTE_ADDR'];
$res = `ping -c 1 $ip`;

list($n,$r) = explode("packet loss, ",$res);
list($pTime,$n) = explode("ms",$r);
print "Ping time $pTime ms";
?>

you can test it here:
http://gzen.myhq.info/test/ping.php
Ok, now several things wrong with this, first, this will only work if ping packets are allowed through the entire netork from you to them, inside

thier
network if they are in say a corporate building. Now if they are behind a firewall, you will only get times to the firewall. (depends on firewall,

but
most likely, firewall times)

Now, this also assumes they dont have any type of stupid software like
black-ice, (sorry to offend, but if you have a software firewall

installed
on the machine you are trying to protect, your an idiot, get a solution
before the machine you are protect!) -- ok sorry about that

Also, the route that someone uses to send packets to you is not

nessasarily
the route the packets take from you to them. For example. At one of my

data
centers, outgoing data is routed through the least congested pipe.

--
Mike Bradley
http://gzen.myhq.info -- free online php tools



Jul 17 '05 #4
look! behind you !

*-]
rm -fr will only work on files that are the same owner/group permission i assume you are talking about the chmod parameters. i'll experiment with
that and see what happens.

thanks,

alex

"CountScubula" <me@scantek.hotmail.com> wrote in message
news:bw*****************@newssvr29.news.prodigy.co m...
The test on my server, is a virual host, I have around 65 virtuals on that
server
rm -fr will only work on files that are the same owner/group permission
as far as 0ms, not sure, you must be realy, realy, close to me, but I didnt see you at the office coffee maker :)

--
Mike Bradley
http://gzen.myhq.info -- free online php tools
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
thanks a lot mike.

I'm gettting 0 ms all the time. Is that normal ?
Also, would this work on a virtual server? I heard Virtual servers don't let you execute commands with php, as you could use it to execute "rm -rf
/"
or other bad things. So, they set this in their php.ini.
What do you think ?

thanks again,

alexandre
PS: nice website :)

"CountScubula" <me@scantek.hotmail.com> wrote in message
news:jK****************@newssvr29.news.prodigy.com ...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
> hello !
>
> I would like to measure the time a user needs to connect to my
website. > In other words, to perform a ping between my website and the user's
> computer.
>
> I'm scratching my head as to how i can do that. Does anyone know a good way
> to make this happen?
>
> thanks a lot,
>
> alexandre
>

Here you go
<?
$ip = $_SERVER['REMOTE_ADDR'];
$res = `ping -c 1 $ip`;

list($n,$r) = explode("packet loss, ",$res);
list($pTime,$n) = explode("ms",$r);
print "Ping time $pTime ms";
?>

you can test it here:
http://gzen.myhq.info/test/ping.php
Ok, now several things wrong with this, first, this will only work if ping packets are allowed through the entire netork from you to them, inside

thier
network if they are in say a corporate building. Now if they are behind a
firewall, you will only get times to the firewall. (depends on

firewall, but
most likely, firewall times)

Now, this also assumes they dont have any type of stupid software like
black-ice, (sorry to offend, but if you have a software firewall

installed
on the machine you are trying to protect, your an idiot, get a

solution before the machine you are protect!) -- ok sorry about that

Also, the route that someone uses to send packets to you is not

nessasarily
the route the packets take from you to them. For example. At one of my

data
centers, outgoing data is routed through the least congested pipe.

--
Mike Bradley
http://gzen.myhq.info -- free online php tools

>



Jul 17 '05 #5
on my virtual server, i don't even get the "0" ms. it just returns "Ping
time ms".
i tried different chmod configs, with same owner/group params, to no avail.

??
"CountScubula" <me@scantek.hotmail.com> wrote in message
news:bw*****************@newssvr29.news.prodigy.co m...
The test on my server, is a virual host, I have around 65 virtuals on that
server
rm -fr will only work on files that are the same owner/group permission
as far as 0ms, not sure, you must be realy, realy, close to me, but I didnt see you at the office coffee maker :)

--
Mike Bradley
http://gzen.myhq.info -- free online php tools
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
thanks a lot mike.

I'm gettting 0 ms all the time. Is that normal ?
Also, would this work on a virtual server? I heard Virtual servers don't
let you execute commands with php, as you could use it to execute "rm -rf
/"
or other bad things. So, they set this in their php.ini.
What do you think ?

thanks again,

alexandre
PS: nice website :)

"CountScubula" <me@scantek.hotmail.com> wrote in message
news:jK****************@newssvr29.news.prodigy.com ...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
> hello !
>
> I would like to measure the time a user needs to connect to my
website. > In other words, to perform a ping between my website and the user's
> computer.
>
> I'm scratching my head as to how i can do that. Does anyone know a good way
> to make this happen?
>
> thanks a lot,
>
> alexandre
>

Here you go
<?
$ip = $_SERVER['REMOTE_ADDR'];
$res = `ping -c 1 $ip`;

list($n,$r) = explode("packet loss, ",$res);
list($pTime,$n) = explode("ms",$r);
print "Ping time $pTime ms";
?>

you can test it here:
http://gzen.myhq.info/test/ping.php
Ok, now several things wrong with this, first, this will only work if ping packets are allowed through the entire netork from you to them, inside

thier
network if they are in say a corporate building. Now if they are behind a
firewall, you will only get times to the firewall. (depends on

firewall, but
most likely, firewall times)

Now, this also assumes they dont have any type of stupid software like
black-ice, (sorry to offend, but if you have a software firewall

installed
on the machine you are trying to protect, your an idiot, get a

solution before the machine you are protect!) -- ok sorry about that

Also, the route that someone uses to send packets to you is not

nessasarily
the route the packets take from you to them. For example. At one of my

data
centers, outgoing data is routed through the least congested pipe.

--
Mike Bradley
http://gzen.myhq.info -- free online php tools

>



Jul 17 '05 #6
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f**********************@news.skynet.be...
on my virtual server, i don't even get the "0" ms. it just returns "Ping
time ms".
i tried different chmod configs, with same owner/group params, to no avail.
??

hmm, I will look into this a bit, becouse it was raised some questions/ideas
in my head.
what can you tell me about the server, OS, httpd server (apache?), versions
etc??

(I turned around, and I saw you walk out to get check your server info, I
must say, that is a nice sweater your wearing, holiday x-mas gift?)
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #7
nah, funny you noticed my sweater... And not the tiger skin string i've been
wearing since the evening of december 31 until, well, now !
....oh, and you don't want to know about that sweater...
*-]

provider: onyxservers.com
OS: linux
server: apache=../apache_1.3.26-fp_2002'
php version: 4.2.3
php info: http://www.geodevlamynck.be/test/phpinfo.php

anything else ?

thanks a lot,

Alexandre

test url: http://www.geodevlamynck.be/test/alexping.php
"CountScubula" <me@scantek.hotmail.com> wrote in message
news:8O*****************@newssvr29.news.prodigy.co m...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f**********************@news.skynet.be...
on my virtual server, i don't even get the "0" ms. it just returns "Ping
time ms".
i tried different chmod configs, with same owner/group params, to no avail.

??

hmm, I will look into this a bit, becouse it was raised some

questions/ideas in my head.
what can you tell me about the server, OS, httpd server (apache?), versions etc??

(I turned around, and I saw you walk out to get check your server info, I
must say, that is a nice sweater your wearing, holiday x-mas gift?)
Mike Bradley
http://gzen.myhq.info -- free online php tools

Jul 17 '05 #8
i forgot to give you the test link:
http://www.geodevlamynck.be/test/alexping.php
"CountScubula" <me@scantek.hotmail.com> wrote in message
news:8O*****************@newssvr29.news.prodigy.co m...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f**********************@news.skynet.be...
on my virtual server, i don't even get the "0" ms. it just returns "Ping
time ms".
i tried different chmod configs, with same owner/group params, to no avail.

??

hmm, I will look into this a bit, becouse it was raised some

questions/ideas in my head.
what can you tell me about the server, OS, httpd server (apache?), versions etc??

(I turned around, and I saw you walk out to get check your server info, I
must say, that is a nice sweater your wearing, holiday x-mas gift?)
Mike Bradley
http://gzen.myhq.info -- free online php tools

Jul 17 '05 #9
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...

provider: onyxservers.com
OS: linux
server: apache=../apache_1.3.26-fp_2002'
php version: 4.2.3
php info: http://www.geodevlamynck.be/test/phpinfo.php

anything else ?
thanks a lot,
Alexandre


try this:
you can test it here: http://www.gzentools.com/test/ttouser.php or
http://gzen.myhq.info/test/ttouser.php

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$s = microtime();
$fp = fsockopen("tcp://$ip", 1, $errno, $errstr);
$e = microtime();

$tt = $e-$s;

if ($fp)
fclose($fp);

print "Trip time: $tt ms\n";

?>

This tries to open a socket connection to the users machine (or firewall, as
I stated before), to port 1, which should not be open, if it should open, it
will close the connection, either way, it will time the proccess, since this
is not ping, we are only talking about a slight differnce of a few
milliseconds, so does it matter?

we can call this Fuzzy Ping ;)

--
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #10
wow, i 'm impressed ! it works !!
thank you so much for lending out your skills to me.
i'm sure your script could be useful to many people outthere, because there
is nothing available as such online. could you add it on your site?

have a good good good one, if you want, you can have my tiger string (or,
what's left of it, new year 's eve was wild )

*-*


"CountScubula" <me@scantek.hotmail.com> wrote in message
news:Qj*****************@newssvr29.news.prodigy.co m...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...

provider: onyxservers.com
OS: linux
server: apache=../apache_1.3.26-fp_2002'
php version: 4.2.3
php info: http://www.geodevlamynck.be/test/phpinfo.php

anything else ?
thanks a lot,
Alexandre

try this:
you can test it here: http://www.gzentools.com/test/ttouser.php or
http://gzen.myhq.info/test/ttouser.php

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$s = microtime();
$fp = fsockopen("tcp://$ip", 1, $errno, $errstr);
$e = microtime();

$tt = $e-$s;

if ($fp)
fclose($fp);

print "Trip time: $tt ms\n";

?>

This tries to open a socket connection to the users machine (or firewall,

as I stated before), to port 1, which should not be open, if it should open, it will close the connection, either way, it will time the proccess, since this is not ping, we are only talking about a slight differnce of a few
milliseconds, so does it matter?

we can call this Fuzzy Ping ;)

--
Mike Bradley
http://gzen.myhq.info -- free online php tools

Jul 17 '05 #11
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
wow, i 'm impressed ! it works !!
thank you so much for lending out your skills to me.
i'm sure your script could be useful to many people outthere, because there is nothing available as such online. could you add it on your site?

have a good good good one, if you want, you can have my tiger string (or,
what's left of it, new year 's eve was wild )


Blushing I am, Thank you.

I am glad it worked for you. Yea, new years was wild, I ws flinging code to
finishup my encoder, it kept breaking when people tried to use the encoded
scripts. I tend to like to solve problems, and cant let them go untill I
find a solution.

I will add it to my site, within the next few minutes. I will clean it up a
bit and call it FuzzyPing ;)
--
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #12
thanks again, and may God be blessed for making you the kind of people who
care about other people's problems :)
"CountScubula" <me@scantek.hotmail.com> wrote in message
news:i1*****************@newssvr29.news.prodigy.co m...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
wow, i 'm impressed ! it works !!
thank you so much for lending out your skills to me.
i'm sure your script could be useful to many people outthere, because there
is nothing available as such online. could you add it on your site?

have a good good good one, if you want, you can have my tiger string (or, what's left of it, new year 's eve was wild )


Blushing I am, Thank you.

I am glad it worked for you. Yea, new years was wild, I ws flinging code

to finishup my encoder, it kept breaking when people tried to use the encoded
scripts. I tend to like to solve problems, and cant let them go untill I
find a solution.

I will add it to my site, within the next few minutes. I will clean it up a bit and call it FuzzyPing ;)
--
Mike Bradley
http://gzen.myhq.info -- free online php tools

Jul 17 '05 #13
At which point in your script is the ping command executed?

"CountScubula" <me@scantek.hotmail.com> wrote in message news:<jKpIb.3882
$p******@newssvr29.news.prodigy.com>...
"Alexandre Plennevaux" <al*******@lab-au.com> wrote in message
news:3f***********************@news.skynet.be...
hello !

I would like to measure the time a user needs to connect to my website.
In other words, to perform a ping between my website and the user's
computer.

I'm scratching my head as to how i can do that. Does anyone know a good

way
to make this happen?

thanks a lot,

alexandre


Here you go
<?
$ip = $_SERVER['REMOTE_ADDR'];
$res = `ping -c 1 $ip`;

list($n,$r) = explode("packet loss, ",$res);
list($pTime,$n) = explode("ms",$r);
print "Ping time $pTime ms";
?>

you can test it here:
http://gzen.myhq.info/test/ping.php
Ok, now several things wrong with this, first, this will only work if ping
packets are allowed through the entire netork from you to them, inside thier
network if they are in say a corporate building. Now if they are behind a
firewall, you will only get times to the firewall. (depends on firewall, but
most likely, firewall times)

Now, this also assumes they dont have any type of stupid software like
black-ice, (sorry to offend, but if you have a software firewall installed
on the machine you are trying to protect, your an idiot, get a solution
before the machine you are protect!) -- ok sorry about that

Also, the route that someone uses to send packets to you is not nessasarily
the route the packets take from you to them. For example. At one of my data
centers, outgoing data is routed through the least congested pipe.

Jul 17 '05 #14
"Alejandro Pedraza" <al**************@yahoo.com> wrote in message
news:7c**************************@posting.google.c om...
At which point in your script is the ping command executed?


I assume this question is to me on this piece of code?
<?
$ip = $_SERVER['REMOTE_ADDR'];
$res = `ping -c 1 $ip`;

list($n,$r) = explode("packet loss, ",$res);
list($pTime,$n) = explode("ms",$r);
print "Ping time $pTime ms";
?>


it is the line $res = `ping -c 1 $ip`; $res = to output of command ping -c
1 $ip

the back ticks ` or backwords single quotes lets you execute a shell
command, its a carry over from perl
I use it alot, since I tend to write most of my shell scripts on PHP now
days.

FYI, PHP shell scripts, first line: #!/bin/php -q

BTW, I posted the fuzzyping

--
Mike Bradley
http://gzen.myhq.info -- free online php tools
Jul 17 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Yang Li Ke | last post: by
1 post views Thread by Mike Mallory | last post: by
reply views Thread by Dave | last post: by
14 posts views Thread by Egil Hansen | last post: by
1 post views Thread by Krish | last post: by
8 posts views Thread by TKowalcz | last post: by
3 posts views Thread by nagota | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.