By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

Measuring bandwidth used using PHP.

Markus
Expert 5K+
P: 6,050
I've had a good luck around for something along the lines of what i wanted, all to no avail.
Was just wondering if anyone knew of a way to record bandwidth usage?
Mar 1 '08 #1
Share this Question
Share on Google+
5 Replies


hsriat
Expert 100+
P: 1,654
I've had a good luck around for something along the lines of what i wanted, all to no avail.
Was just wondering if anyone knew of a way to record bandwidth usage?
Good Question! I'm looking forward is someone gives a good reply.

I can give you an idea though...

When user clicks on a bandwidth checking link, send some data to the user's browser. And when the data reaches completely, tell JavaScript to send it back.
Calculate time between start of sending and end of receiving that data.
Divide the data size by (4 * $seconds_taken). May be it could tell you the bandwidth.

But what if user is downloading or uploading something along with?

PS: Don't laugh!! :p
Mar 1 '08 #2

dlite922
Expert 100+
P: 1,584
Good Question! I'm looking forward is someone gives a good reply.

I can give you an idea though...

When user clicks on a bandwidth checking link, send some data to the user's browser. And when the data reaches completely, tell JavaScript to send it back.
Calculate time between start of sending and end of receiving that data.
Divide the data size by (4 * $seconds_taken). May be it could tell you the bandwidth.

But what if user is downloading or uploading something along with?

PS: Don't laugh!! :p

no one's laughing, i wouldn't have thought of that.....okay maybe i would have...but you went into detail.

I say so what if he's downloading something, that's his bandwidth currently at this time he's browsing the website, display the info (quality) based on that bandwidth.

If he comes back another time with more bandwidth he can see the better quality vido/flash/porn/etc...



-DM
Mar 7 '08 #3

hsriat
Expert 100+
P: 1,654
I say so what if he's downloading something, that's his bandwidth currently at this time he's browsing the website, display the info (quality) based on that bandwidth.
That's what I said in the second last line.

PS: Glad to know you didn't laugh. :D
Mar 7 '08 #4

Markus
Expert 5K+
P: 6,050
That's what I said in the second last line.

PS: Glad to know you didn't laugh. :D
I didn't laugh, either!

Could you elaborate on:
When user clicks on a bandwidth checking link, send some data to the user's browser. And when the data reaches completely, tell JavaScript to send it back.
?

Cheers
Mar 7 '08 #5

hsriat
Expert 100+
P: 1,654
When user clicks on the link, create a hidden iframe and give src of an HTML file, something like this:[html]<html>
<body onload="document.forms[0].submit()">
<form acton="return_data.php" method="post">
<input type="hidden" name="data" value="----------fake text of size say 50Kb---------" />
</form>
</body>
</html>[/html]
Since the iframe is hidden, nothing would be shown on the browser.

When the server gets the request from a user for that file, save start time somewhere (of course corresponding to the user id or IP), and when return_data.php gets back the whole data, save the end time.

I hope it can work, but not sure! This is just a first try. I've never done anything like this.
Mar 7 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.