upload speed test problem

Ganbold ganbold at micom.mng.net
Fri May 13 00:36:25 GMT 2005


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 at freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>



More information about the freebsd-hackers mailing list