Date: Fri, 13 May 2005 09:35:55 +0900 From: Ganbold <ganbold@micom.mng.net> To: Adam Maloney <adam@whee.org> Cc: freebsd-hackers@FreeBSD.org Subject: Re: upload speed test problem Message-ID: <6.2.1.2.2.20050513092211.031e6cc0@202.179.0.80> In-Reply-To: <Pine.GSO.4.60.0505120749190.2099@titan> References: <6.2.1.2.2.20050512180519.03403540@202.179.0.80> <Pine.GSO.4.60.0505120749190.2099@titan>
next in thread | previous in thread | raw e-mail | index | archive | help
Adam, Thanks a lot. You are completely right. I tested it on my modem, turned off and on Modem Compression option and checked the result. I corrected my program using random data. ............... URL url = new URL(web_site); URLConnection connection = url.openConnection(); connection.setDoOutput(true); connection.setUseCaches(false); DataOutputStream dos = new DataOutputStream(connection.getOutputStream()); byte ab[] = createPacket(buffer_len); int totalBytes = buffer_len; int maxBufferSize = 51200; int bytesAvailable = totalBytes; int tempBufferSize = 0; int bytesSent = 0; int bufferSize = Math.min(bytesAvailable, maxBufferSize); while(bytesAvailable > 0){ dos.write(ab, 0, bufferSize); bytesAvailable -= bufferSize; bufferSize = Math.min(bytesAvailable, maxBufferSize); } dos.writeBytes("\r\n"); int totalBytesSent = dos.size(); System.out.println("\nTotal Bytes Sent: " + totalBytesSent); dos.flush(); dos.close(); BufferedReader in = new BufferedReader( new InputStreamReader( connection.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null){ // System.out.println(inputLine); } in.close(); endtime1 = System.currentTimeMillis(); test_time = endtime1 - starttime1; uploaded_size = totalBytesSent; return showSpeed(starttime1,endtime1,"Upload",totalBytesSent); ............... private byte[] createPacket(int len) { Random r = new Random(); byte[] pkt = new byte[len]; r.nextBytes(pkt); return(pkt); } ............... thanks again, Ganbold At 10:10 PM 5/12/2005, you wrote: >On Thu, 12 May 2005, Ganbold wrote: > >>Result is unbelievable, it is something like 500kbps for 56kbps Dial-Up >>connection, which is completely wrong. > >It looks like the form data that the client is POSTing is all "a", >correct? The modem is probably compressing this data. > >I wrote a speed test in perl a number of years ago to do both upload and >download testing. Here are some things I found, maybe they will help you: > >You must use data that doesn't compress well, or, as you've seen, dial-up >modems will compress it and report speeds much higher than is possible. > >It is better to pre-generate the random data, rather than try and read >from /dev/random on the fly. I realized that by having my script suck 5 >or 10 megabytes of randomness out of /dev/random every time it ran, I was >accelerating the heat-death of the universe. You don't want to cause the >heat-death of the universe either, do you? (Actually, either pre-generate >random files, or read from /dev/urandom, which doesn't block when it runs >out of randomness) > >IE Sucks. > >The way my script worked was, I had a form page that the user selected the >file size to test with, and hit Submit. This submitted to my CGI that >generated a new HTML form with a hidden input field containing the random >data of the size they selected. It also contained a hidden field with a >timestamp of when the page began to execute. I used javascript to >automatically submit the form when the page load completed. Mozilla would >submit this form as soon as page load completed. For some odd reason, IE >would wait a couple of seconds before submitting the data. So I had to >(oh this is so ugly, I don't want to say it), define an IE fudge factor, >and subtract a couple of seconds from the upload time if the client was IE. > >I also realized that I had to add a META tag to cause the pages not to be >cached. Furthermore, I had to add something to look at the client's HTTP >headers and look for signs of an HTTP proxy (proxies usually add a header >or two, depending on how they're configured). If a proxy was detected, I >could either spit out a warning to the user that the speeds reported could >be inaccurate, or I could simply refuse to continue. > >On the plus side, overall the test worked pretty well. > >HTH, > >Adam >_______________________________________________ >freebsd-hackers@freebsd.org mailing list >http://lists.freebsd.org/mailman/listinfo/freebsd-hackers >To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6.2.1.2.2.20050513092211.031e6cc0>