sending packets with DatagramSocket, and calculating?
I want to make a speedtest which calculate download and upload speed. But
I have questions about it. For example; I am sending bytes with
datagramsocket, and i am calculating it too. And I have tested this on
several adsl connection. But i receiving different speed on calculate; I
mean first pc have 10mbit connection and i testing in 12 seconds and
receiving 17mb~ , second pc have 3mbit connection and receiving 10mb~ in
12 seconds. Here is sample of my code;
ds = new DatagramSocket();
b1 = new byte[65000];
ia = InetAddress.getByName("www.google.com");
t1 = new thr(); //this starts thread, which is calculating elapsed
time
while(end!=0){
dp = new DatagramPacket(b1, b1.length , ia, 3000);
ds.send(dp);
db+=ds.getSendBufferSize(); // calculate sended bytes
}//end while
/*
...
*/
byteToMb=db/1048576; // convert to sended mb
}
I have 2 threads, "end" is coming from other thread, its end when I reach
12 seconds to test. I calculating db as sended or received data? And im
confused , if it is uploading, how can i send 17 mb in 12 seconds ? cuz i
have 1mb(max) upload speed. And if it is downloading, why i am using
"ds.send(dp)" ? And my algorithm is true ? OR how can i test my speed
using sockets ? OR any ideas ? Thanks for help, Sorry for my English
No comments:
Post a Comment