Solved

Calculating upload speed

Posted on 2004-08-24
11
793 Views
Last Modified: 2011-10-03
hi.

I'm trying to calculate my upload speed so I can do an auto configure on my app.  This is how I do it but it does not seem to give me anywhere near my actual upload speed (I checked on DSLREPORTS.com)

1. create a buffer of 500,000 bytes
2. Start timer .. start = ::GetTickcout() and send data to server
3. wait for response from server telling me it's got all the data
4. end timer end = ::GetTickcout() and deduct any overhead from the server to process to data.
5. calculate like so ... (500,000 / (end - start) ) / 1024 = XXKB upload

my upload is usual around 200k+ but using this method gives me a result of 20k .. Any ideas ???

Thanks
0
Comment
Question by:alsmorris
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 19

Expert Comment

by:drichards
ID: 11889613
Do you convert GetTickCount() - I assume that's what you mean - to seconds?  Seems formula should be:

(500,000/(end-start)*1000)/1024

to account for the fact that GetTickCount() is in milliseconds.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 11889828
Are you sure that 200k+ is 200 KBytes/sec. If it is 200 KBits/sec ~= 25KBytes/sec the results could be explained.

Did you wait 2-3 seconds or 20-30 seconds for output?

Regards, Alex
0
 
LVL 22

Expert Comment

by:grg99
ID: 11891028
Most home connections are setup with 75% of the bandwidth allocated for DOWNLAODS to your computer, and only the rest for uploads.  This matches most people's needs (lots of stuff coming to your computer, jsut a little typing going back).

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:alsmorris
ID: 11894220
drichards yes sorry I do convert to seconds before I do the calculation.

Alex - I have ran my test at www.dslreports.com/stest .. well I have cable not DSL but it still works there ...  Here is the results I just ran there .. it takes about 27sec to return.

2004-08-25 12:05:07 EST: 1416 / 229
Your download speed : 1450188 bps, or 1416 kbps.
A 177 KB/sec transfer rate.
Your upload speed : 235233 bps, or 229 kbps.


Here is the actual code:

int CTestUpload::RunUploadTest()
{

      CProtocol* pServerProtocol = new CProtocol;
      DWORD dwAmountOfData = 500000;
      char* pszData = new char[dwAmountOfData] ;
      memset(pszData,33,dwAmountOfData);

      DWORD dwStartTime = ::GetTickCount(); //start time ms

               //Sends packet to server and returns on response
      pServerProtocol->CreateRequest(pszData,dwAmountOfData);

      DWORD dwEndTime = ::GetTickCount(); //endtime ms
      //Overhead send back from server
      int noverhead = atoi(pServerProtocol->m_pDataFromServer); //already in secs

      float dwTimeTaken = (float)(dwEndTime - dwStartTime) / 1000.00;
      
      float dblKBSec = (float)(dwAmountOfData / (dwTimeTaken - noverhead) ) / 1024.00;


      if (pszData)
      {
            delete [] pszData;
            pszData = NULL;
      }
      if (pServerProtocol)
      {
            delete pServerProtocol;
            pServerProtocol = NULL;
      }

      return 0;

}
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 220 total points
ID: 11894771
Upload speed 229 kbps ~= 27KB/sec

That isn't far away from your results? As grg99 already told you, upload speed normally is much less than download speed, and you are uploading, don't you?

Regards, Alex




0
 

Author Comment

by:alsmorris
ID: 11894952
Hi Alex...

ok .. I'm getting it !  I got mixed up.. So the  calc is actually 229 kbps * 8 (bits per byte) = KB/sec.  ??

Thanks

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 11895016
Yes, but maybe you have to divide rather than to multiply ;-)

     229 kilobits/second  divided by  8 == 28.625 kilobytes/second

Regards, Alex
0
 

Author Comment

by:alsmorris
ID: 11895157
:) Oh yeah :P
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 30 total points
ID: 11895928
Also, what's the point of using 1024 instead of 1000?  

1024 makes sense when you're dealing with things that come in binary powers. But thruput is just a number.

0
 

Author Comment

by:alsmorris
ID: 11896137
grg.. I guess your right .. Just trying to get an idea of how much data I can safely send.

by the way anyone know what the upload speed is for a 56k modem ?

Thanks
0
 

Author Comment

by:alsmorris
ID: 11905871
according to a website I found a V90 56k modem can upload at 33.6kbps if anyone is interested ... Thank everyone for the help!!! I'll close out this question!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IdTCPClient1->Disconnect(); not working 3 86
C++ question 3 74
c++ using a LPCOLESTR * and adding a string varaible to the Pointer 2 74
Outlook 13 76
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question