Internet speed
김민석
http://www.emanueleferonato.com/2006/05/31/determine-connection-speed-with-php/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$kb=512;
echo "streaming $kb Kb...<!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '.');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
?>
Done. Analysis and considerations:
2: Declaring how much Kb I want to transmit to accomplish the test. This value can also be passed in POST or GET. In my example it is
declared.
3: I write I am downloading data, and open a comment tag. Everithing I am sending from now on will not be displayed. It’s not necessary, but
prevents the browser to be fullfilled of chars.
4: Flush the chache
5-6: Saving actual timestamp
7-9: For $kb times I send 1024 chars (1Kb) and flush the cache
11-12: Saving actual timestamp
13: Calculating difference between start and finish timestamps
14: Closing comment tag and writing test result, calculated as Kb/time
Done… very easy isn’t it?
http://www.hackingwithphp.com/13/9/0/flushing-output
Internet speed 인터넷 속도를 측정해보자
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$kb=512;
echo "streaming $kb Kb...<!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '.');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
?>
서버의 아웃풋을 내는 성능이
무한대라고 볼 때,
그래서 순간 아웃풋을 발생시킨다고 할 때,
전송한 데이터 / 걸린 시간
위 방법으로 클라이언트의 전송속도를 알 수 있다?
내 생각에는 위 코드는
서버의 성능을 나타내는 것일 뿐이지,
‘클라이언트’ 또는 ‘클라이언트-서버’ 간의 인터넷 속도를
나타내지 못할 거 같다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$kb=512;
echo "streaming $kb Kb...<!-";
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
echo str_pad('', 1024, '.');
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
?>
Php의 Backend에,
flush를 통한 출력이 어떻게 처리되는지를
이해해야지, 명확히 알 수 있을 거 같다.
Apache http web server의 경우,
다양한 서버사이드 언어를 모듈을 달아서 만질 수 있는데,
php의 경우 mod_php가 그것이다.
적어도 Apache에서 PHP를 돌리는 방법은 두가지가 있다.
CGI와 mod_php
https://kldp.org/node/73386
Internet speed 인터넷 속도를 측정해보자
https://kldp.org/node/73386
아직 더 봐야겠다.
CGI에 대한 개념을 잡는데 아주 좋은 쓰레드
https://httpd.apache.org/docs/2.2/ko/howto/cgi.html
https://www.ibm.com/support/knowledgecenter/en/SSSHTQ_8.1.0/com.ibm.netcool_OMNIbus.doc_8.1.0/webtop/wip/reference/web_cust_envvariablesincgiscripts.html
http://www.cgi101.com/book/ch3/text.html
http://www.perl.or.kr/tipsinaction/control_flow/local_env
GET 요청은 QUERY_STRING 환경변수로 데이터를 넘기는 것이군.
CGI 프로그램에 클라이언트가 보낸 데이터를 보낸다.
데이터는 웹 양식 form 이고, 이렇게 보내는 걸 POST라 한다.
CGI 프로그램의 STDIN으로 전달한다. 전달하는 형식은 위와 같다.
그 형식이 종종 URL 뒤에 붙기도 하는데, 그런 경우는
이런 문자열을 유용한 정보로 처리해야 하겠네. 그런 라이브러리와 모듈이 있구나.
https://en.wikipedia.org/wiki/CGI.pm
그렇겠네.
HTML은 자꾸 변하고,
(브라우저 마다 결국 다르고)
producing HTML 하는 것은 unmaintained 되기 쉽겠네.
v5.22 of perl에서 없어졌는데, CGI가 현재 잘 안쓰이는 것과 관련 있겠네.
CGI 프로그램은 대체로 이런 느낌이겠군.
빨간 박스 아래
부분이 실제 내용일 것.
환경변수 가져오고. 쿠키 셋. 헤드타입. stdout...
https://boutell.com/cgic/#howto
Internet speed 인터넷 속도를 측정해보자
https://www.binarytides.com/php-output-content-browser-realtime-buffering/
그래서.. 좀 더 코드를 보면
또한 출력된 데이터가 타고 가는 라인이
일반적으로 어느 속도를 갖느냐에 따라서,
$kb 값을 더 크게 수정하는 것이 옳을 수 있다는 의견.
내 생각에는 $kb가 아주 커야지.. 의미가 있지 않나?
돌아와서......
내 생각과 비슷한듯.
RTT를 구하기 위해서는
Javascript 단에서의 방법이 나을 듯함.
https://stackoverflow.com/questions/5529718/how-to-detect-internet-speed-in-
javascript?
utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
//JUST AN EXAMPLE, PLEASE USE YOUR OWN PICTURE!
var imageAddr = "http://www.kenrockwell.com/contax/images/g2/examples/31120037-5mb.jpg";
var downloadSize = 4995374; //bytes
function ShowProgressMessage(msg) {
if (console) {
if (typeof msg == "string") {
console.log(msg);
} else {
for (var i = 0; i < msg.length; i++) {
console.log(msg[i]);
}
}
}
var oProgress = document.getElementById("progress");
if (oProgress) {
var actualHTML = (typeof msg == "string") ? msg : msg.join("<br />");
oProgress.innerHTML = actualHTML;
}
}
function InitiateSpeedDetection() {
ShowProgressMessage("Loading the image, please wait...");
window.setTimeout(MeasureConnectionSpeed, 1);
};
if (window.addEventListener) {
window.addEventListener('load', InitiateSpeedDetection, false);
} else if (window.attachEvent) {
window.attachEvent('onload', InitiateSpeedDetection);
}
function MeasureConnectionSpeed() {
var startTime, endTime;
var download = new Image();
download.onload = function () {
endTime = (new Date()).getTime();
showResults();
}
download.onerror = function (err, msg) {
ShowProgressMessage("Invalid image, or error downloading")
}
startTime = (new Date()).getTime();
var cacheBuster = "?nnn=" + startTime;
download.src = imageAddr + cacheBuster;
function showResults() {
var duration = (endTime - startTime) / 1000;
var bitsLoaded = downloadSize * 8;
var speedBps = (bitsLoaded / duration).toFixed(2);
var speedKbps = (speedBps / 1024).toFixed(2);
var speedMbps = (speedKbps / 1024).toFixed(2);
ShowProgressMessage([
"Your connection speed is:",
speedBps + " bps",
speedKbps + " kbps",
speedMbps + " Mbps"
]);
}
그러나 다른 인터넷 속도 테스트와 많은 차이가 있음..
이유가 무엇일까?
https://codereview.stackexchange.com/questions/140573/python-internet-speed-
testing?
utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
https://www.accelebrate.com/blog/pandas-bandwidth-python-tutorial-plotting-results-
internet-speed-tests/

More Related Content

PPTX
6. html5 캔버스
PDF
PHP에서 GCM 푸시 빠르게 보내기 (feat. Async / Generator)
PDF
네트워크 공격 실습 보고서
PPTX
Mysql old password 깨기
PPTX
HTTP 완벽 가이드 / 20장 리다이렉션과 부하균형
PDF
[APM] Homepage bbs
PPTX
[PHPFest 2013] High performance Javascript
PPTX
mongoDB 3 type modeling in production
6. html5 캔버스
PHP에서 GCM 푸시 빠르게 보내기 (feat. Async / Generator)
네트워크 공격 실습 보고서
Mysql old password 깨기
HTTP 완벽 가이드 / 20장 리다이렉션과 부하균형
[APM] Homepage bbs
[PHPFest 2013] High performance Javascript
mongoDB 3 type modeling in production

Similar to Internet speed 인터넷 속도를 측정해보자 (20)

PDF
처음배우는 자바스크립트, 제이쿼리 #4
PPT
ch04
PDF
Front-end Development Process - 어디까지 개선할 수 있나
PDF
MongoDB 도입을 위한 제언
PDF
MongoDB 도입을 위한 제언 @krmug
KEY
Html5 performance
PDF
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End
PDF
Clova extension에서 OAuth 계정 연동 구현
PDF
Resource Handling in Spring MVC
PDF
하이퍼레저 패브릭 데이터 구조
PDF
테스트
PPTX
Mongo db 최범균
PPTX
Cdr with php
PPTX
Html5
PPTX
HeadFisrt Servlet&JSP Chapter 3
 
PDF
성공적인 게임 런칭을 위한 비밀의 레시피 #3
PDF
What's new in IE11
PPTX
Lan3 강향리 2013 겨울방학 기말아웃풋
PPTX
PHP 함수와 제어구조
PDF
채팅 소스부터 Https 주소까지
처음배우는 자바스크립트, 제이쿼리 #4
ch04
Front-end Development Process - 어디까지 개선할 수 있나
MongoDB 도입을 위한 제언
MongoDB 도입을 위한 제언 @krmug
Html5 performance
[제3회 스포카콘] React + TypeScript + GraphQL 으로 시작하는 Web Front-End
Clova extension에서 OAuth 계정 연동 구현
Resource Handling in Spring MVC
하이퍼레저 패브릭 데이터 구조
테스트
Mongo db 최범균
Cdr with php
Html5
HeadFisrt Servlet&JSP Chapter 3
 
성공적인 게임 런칭을 위한 비밀의 레시피 #3
What's new in IE11
Lan3 강향리 2013 겨울방학 기말아웃풋
PHP 함수와 제어구조
채팅 소스부터 Https 주소까지
Ad

More from 민석 김 (15)

PPTX
PDF
off-policy methods with approximation
PDF
Multi armed bandit
PDF
NN and PDF
PDF
Kanerva machine
PDF
Shouting at gwanghwamun
PDF
ML 60'~80' new paradigm 1
PDF
벽 생성기 Wall generator
PDF
복소수와 오일러 공식
PDF
Bayesian nets 발표 3
PDF
Bayesian nets 발표 1
PDF
Bayesian nets 발표 2
PDF
AI 인공지능이란 단어 읽기
PDF
Hopfield network 처음부터 공부해보기
PDF
VAE 처음부터 알아보기
off-policy methods with approximation
Multi armed bandit
NN and PDF
Kanerva machine
Shouting at gwanghwamun
ML 60'~80' new paradigm 1
벽 생성기 Wall generator
복소수와 오일러 공식
Bayesian nets 발표 3
Bayesian nets 발표 1
Bayesian nets 발표 2
AI 인공지능이란 단어 읽기
Hopfield network 처음부터 공부해보기
VAE 처음부터 알아보기
Ad

Internet speed 인터넷 속도를 측정해보자