Jump to content


Photo

bandwidthmeter script


  • Please log in to reply
No replies to this topic

#1 tech123

tech123
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 24 July 2006 - 01:57 PM

Hi, I set up a speed test script on my server (specifcally, bandwidhthmeter - http://gambitdesign....bandwidthmeter/). I am trying to test the speed on my server which transfers data via satellite. Needless to say, the script times out repeatedly because the transfer time takes so long. Is there any way to prevent the script from timing out, specifically a few lines of code to add/change? I am sending a few different file size types.


This is the part of the script that does the actual grunt work of finding the speed --

<?php

//	$data_file = "payload.bin";
//	$fd = fopen ($data_file, "rb");
//	if (isset($_GET['kbps'])) {
//		$test_kbytes = ($_GET['kbps'] / 8) * 10;  //set the download to take 10 seconds
//		if ($test_kbytes > 3000) {
//			$test_kbytes = 3000;
//		}
//	} else {
		$test_kbytes = $default_kbyte_test_size;
//	}
	
	$contents = fread ($fd, $test_kbytes * 1024);
		
	echo "<!-- $contents -->";
	fclose ($fd);

?>

<script>
<!--
	time          = new Date();
	endtime       = time.getTime();
	if (endtime == starttime)
		{downloadtime = 0
		}
	else
	{downloadtime = (endtime - starttime)/1000;
	}

	kbytes_of_data = <?php echo $test_kbytes; ?>;
	linespeed     = kbytes_of_data/downloadtime;
	kbps          = (Math.round((linespeed*8)*10*1.024))/10;

	<?php
			$nexturl = "results.php?kbps=' + kbps + '&downloadtime=' + downloadtime + '&KB=' + kbytes_of_data + '&recorded=1";
	?>

	nextpage='<?php echo $nexturl; ?>';
	document.location.href=nextpage
// -->
</script>

I've commented out the test_kbyte part b/c I am not using an "initialmeter" to find an initial reading. Do I have to change something with the Date() function? or should I actually define the time and endtime with numeric values? Any help would be appreciated, thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users