473,394 Members | 1,228 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 5641
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Yang Li Ke | last post by:
Hi guys, Im about to build a script which will log visitor time spent on my website. I got a few ideas about this, maybe checking visitors ip and storing that info in db with time in and then...
1
by: Mike Mallory | last post by:
Can Java perform two pings at one time and display the best ping time with the best result? Also, can Java perform two trace routes at one time and display the trace with the fewest hops? ...
0
by: Dave | last post by:
Hi I have tried to use PathPing, Ping etc to determine the rate of transfer of data between my machine and the database server. However I know that the transfer rate is slower due to the time it...
14
by: Egil Hansen | last post by:
Hi I'm wondering if its possible to write a javascript, that can ping a ip and return the average round trip time (like ping in dos/linux)? Regards, Egil.
2
by: Hari | last post by:
Hi, How can I find out what site a visitor has come from using ASP? Suppose my website is sample.com and I have one page in the website that is used by the visitor to request products and...
5
by: Deepak | last post by:
I am programing a ping application which pings various centers . I used timer loop and it pings one by one. Now when i finish pinging one center it should wait for the ping_completed function to...
1
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking...
8
by: TKowalcz | last post by:
Hello. I have a problem. I need to make a client-server application using sockets (easy). After they communicate server store information about client (IP, and some data). Later on i need to...
3
by: nagota | last post by:
Hi I want to load some xml data from the server running on mymachine (localhost), from a flash swf embedded on an external website. The localhost has crossdomain.xml as well, but the problem is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.