Detecting Broadband?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

neel_basu wrote:This Php Script Takes A Very Little Time To Test The Speed But If you Use Java Applet Or Flash To test It It Would take Too Much Time Thats Very Annoying For A Visitor
neel_basu wrote:No This Code Is To Test The Connection Speed
He Can Code Like This
If the $speed Is Greater That 256 kbs Then Video Would Be Streemed
else Not
That's just it, it doesn't in any way, shape or form test the connection speed. Your code asks PHP to push data to output buffers, that's it. The best it's testing is how fast memory transfers from PHP's buffers to the web server's (and possibly how long it takes the web server to dump that output at the requester if it decides to output anything yet.)
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Wouldn't It meet What he Needs
if $speed Is comparetively more for a Visitor His Connection Speed Is Also More than Those Visitors Who's $speed Is less than That Visitor
Its A Simple Logic
kingconnections
Forum Contributor
Posts: 137
Joined: Thu Jul 14, 2005 4:28 pm

Post by kingconnections »

Not really cause all it is doing is measuring the speed of how fast your server can load the script. Your server could be busy sending billions of spam at that moment in time and it would cause the speed according to your script to be slower. It in no way shape or form measures the users browsing speed.

Correct me if I am wrong, and I am not trying to be an ass here, but your basing your logic on how fast your server can shove stuff to the output buffer.


Your server could be busy doing something else at that exact time, thus slowing the time down.

I just want to understand this logic.

Thanks!!!
:D
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

1. Look There Is No Way To Make A Short time Speed Test Script Compleately 100% Server Independent Its not 3007 Its 2006
2. Look Whats The Script echo's <!--0--> Its A very Shoet Text So I Dont Think it would effect too much
3. If You Use Java Applet or Flash For Speed Testing Thats Also not 100% Server Indepentent
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It doesn't matter if it's server independent, it does matter whether you are testing the connection versus data pushing power however. ;) Something that's done from the client side (or interacts with it) likely offers a more accurate solution set.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Quick lesson in how internet web page serving happens:
  • User opens browser;
  • User types web address into address bar of browser;
  • User hits 'Enter';
  • A request is sent over their network connection to their ISP's server; (THIS IS HALF OF WHAT THE OP ASKED FOR)
  • The ISP server handles the request to the web server being sought;
  • The web server sends a response back to the client through the users network connection; (THIS IS THE OTHER HALF OF WHAT THE OP ASKED FOR)
@neel_basu, what you are measuring is the speed in which the web server can process a page output up to the response point. You are in no way measuring the users internet connection speed. If I was on a dial up or T1 connection, your test would return the same data as it is measuring the performance of the web server in relation to serving a page to the response buffer, not downstream to the client.

Internet connection speeds are measured between the client and the server, not on the server, so PHP would have absolutely no way of being able to do this as it is a SERVER SIDE LANGUAGE.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

neel_basu, I really wish you would stop capitalizing every word.

Everah is right, by the way.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

I think Nobody Looked At the Code Carefully
===============================
First Tell Me [ Yes ] or [ No ]
When Your Opening A Site Such as msn.com if Your Connection is Slow more time would be required to get the page .

This Is How Does The Script works
-----------------------------------------------
1. A Visitor sends Request To This Page
2. It Holds That Time To A Variable
3. The scipt Sends <!--N--> as Its Responce To The Client (View The Sorce After Loading The Page)( as its Hidden comment You Have to view Source To See it )
4.It Sends <!--N--> $test_size time Thats 1024 By Default
5. After Sending It 1024 Times It Holds The Current Time
6. And Then It Calcullates The Speed With the Help Of That Time Difference
7. No If You'r Using A Slow Connection This Time Dfference Would Be More In Your Case and Vise versa
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

... I give up .. :roll:
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Please Read My Preavious Post
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm sorry, you have no idea what you're talking about neel_basu, and I'm not going to waste my time repeating myself yet again just to further your post count beyond this point. Good day, sir.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

neel_basu wrote:I think Nobody Looked At the Code Carefully
===============================
First Tell Me [ Yes ] or [ No ]
When Your Opening A Site Such as msn.com if Your Connection is Slow more time would be required to get the page .

This Is How Does The Script works
-----------------------------------------------
1. A Visitor sends Request To This Page
2. It Holds That Time To A Variable
3. The scipt Sends <!--N--> as Its Responce To The Client (View The Sorce After Loading The Page)( as its Hidden comment You Have to view Source To See it )
4.It Sends <!--N--> $test_size time Thats 1024 By Default
5. After Sending It 1024 Times It Holds The Current Time
6. And Then It Calcullates The Speed With the Help Of That Time Difference
7. No If You'r Using A Slow Connection This Time Dfference Would Be More In Your Case and Vise versa
This will be my last addition to this thread. YOU ARE TALKING ABOUT PROCESSING SPEED NOT CONNECTION SPEED.

Code: Select all

<?php
/* SURFING SPEED DETECTER SCRIPT */

function tmdf($a, $b)
{
    // Split the variable $a into two parts on a ' ' char
    list($a_dec, $a_sec) = explode(" ", $a);
    
    // Split the variable $a into two parts on a ' ' char
    list($b_dec, $b_sec) = explode(" ", $b);
    
    // Return a calculated value
    return $b_sec - $a_sec + $b_dec - $a_dec;
}

function tstspd($test_size)
{
    // Flush the output buffer
    flush();
    /*
        FROM THE PHP MANUAL (http://www.php.net/flush
        void flush ( void )
    
        Flushes the output buffers of PHP and whatever backend PHP is using (CGI, a web server, etc). This effectively tries 
        to push all the output so far to the user's browser.
    
        flush() has no effect on the buffering scheme of your webserver or the browser on the client side. Thus you need to 
        call both ob_flush() and flush() to flush the output buffers.
    
        Several servers, especially on Win32, will still buffer the output from your script until it terminates before 
        transmitting the results to the browser.
    
        Server modules for Apache like mod_gzip may do buffering of their own that will cause flush() to not result in data 
        being sent immediately to the client.
    
        Even the browser may buffer its input before displaying it. Netscape, for example, buffers text until it receives an 
        end-of-line or the beginning of a tag, and it won't render tables until the </table> tag of the outermost table is 
        seen.
    
        Some versions of Microsoft Internet Explorer will only start to display the page after they have received 256 bytes 
        of output, so you may need to send extra whitespace before flushing to get those browsers to display the page. 
    */
    
    // Get the microtime value
    $start_time = microtime();
    
    //You Can Change The $comment As You Wish
    $comment = "<!--N-->";
    
    // Find out how long the string comment is
    $len = strlen($comment);
    
    // Loop from 0 to $test_size, incrementing by the length of string $comment
    // THIS ENTIRE LOOP IS HANDLED ON THE SERVER
    for($i = 0; $i < $test_size; $i += $len)
    {
        echo $comment;
    }
    
    // Flush the output buffer again
    flush();
    
    /*
        Set duration to the value of the time it was when we started 
        to the time it was when PHP finished processing
        
        THIS HAS NOTHING TO DO WITH CONNECTION SPEED
    */ 
    $duration = tmdf($start_time, microtime());
    
    // If PHP spent any time on the process...
    if($duration != 0)
    {
        // Send back the $test_size divided by the PHP process time divided by 1024
        return $test_size / $duration / 1024;
    }
    else
    {
        // Send back the natural logarithm of 0 (which I think is 1)
        return log(0);
    }
}

// Testing
$speed = tstspd(1024);

//More Accrecy Block Started
if ($speed > 50)
{
    $speed = tstspd(10240);
    
    if($speed > 500)
    {
        $speed = tstspd(102400);
    }
}

//More Accurecy Block Ended
echo sprintf("Helllo User Your Net Surfing Speed is %0.3f kb/s", $speed);
?>
I am done with this now.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

/agree "feyd" "Everah"
Z3RO21
Forum Contributor
Posts: 130
Joined: Thu Aug 17, 2006 8:59 am

Post by Z3RO21 »

So I read this and had a good little laugh and wanted to try it for myself. These are some values it gave me for my net speed.
Results wrote:12685.526 kb/s
5558.026 kb/s
5209.961 kb/s
2982.955 kb/s
Hmm these values have a wide range... If infact this script in anyway calculated internet connection speed these would be closer in value if I am not mistaken. Just saying I agree with everyone else who says this doesn't work.
User avatar
neel_basu
Forum Contributor
Posts: 454
Joined: Wed Dec 06, 2006 9:33 am
Location: Picnic Garden, Kolkata, India

Post by neel_basu »

Well In this Reply I am just Informing That I Have Just Uploaded It To A Server Temporarily. You Can Test It

It Will Tell Your Current Net Surfing Speed
http://neel.t35.com/tst_spd.php
As Opera Tells At The Time Of Surfing

Please Refresh The Page if required
Post Reply