473,321 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

best way to calculate transfer rate?

I have a server application that accepts file transfers (utilitzing
tcplistener) and was wondering how I would efficiently go about
determining the calculate transfer rate while I am transferring the
file. The Sub where the transfer actually takes place is called
asynchronously.

The (psuedo) code in the Sub goes something like this:

While byteCount < filesize
bytesRead = Bytes read from NetworkStream
Write bytes just read in to file via a FileStream object
byteCount += bytesRead
Update progress bar for transfer
End While

I have tried somehow using a TimeSpan object to attempt to calculate
after I update the progress bar, but that has proved to not only work
for me, but it makes the transfer rate display not update evenly.

I've looked on the net for any samples of this, but could not turn up
anything.

Aug 20 '06 #1
2 6143
Hello ms****@gmail.com,

You'll want to run an average over a chunk of time.. I would suggest somewhere
around 5-10 seconds.
You can take a look at performace counters for high precision timers..

bytedReceived / unitsOfTime = bytesPerUnit..
TotalBytes / bytesPerUnit = ETAinUnits

-Boo
I have a server application that accepts file transfers (utilitzing
tcplistener) and was wondering how I would efficiently go about
determining the calculate transfer rate while I am transferring the
file. The Sub where the transfer actually takes place is called
asynchronously.

The (psuedo) code in the Sub goes something like this:

While byteCount < filesize
bytesRead = Bytes read from NetworkStream
Write bytes just read in to file via a FileStream object
byteCount += bytesRead
Update progress bar for transfer
End While
I have tried somehow using a TimeSpan object to attempt to calculate
after I update the progress bar, but that has proved to not only work
for me, but it makes the transfer rate display not update evenly.

I've looked on the net for any samples of this, but could not turn up
anything.

Aug 20 '06 #2
Thanks for the suggestion. Only question left is, what would be the
best way to time a transfer this way, taking into account that multiple
transfers across multiple connections can all be happening at once (the
sub containing the actual file transfer code is called asynchronously)?

For example, if I were to use a Timer, I'd have to create a new Timer
object for each connection, but then somehow have an Elapsed event that
could be called from any of those Timers, and would update the transfer
rate accordingly. That's what I'm confused about. Or do the high
precision timers you're talking about not utilize events?

Thanks again

GhostInAK wrote:
Hello ms****@gmail.com,

You'll want to run an average over a chunk of time.. I would suggest somewhere
around 5-10 seconds.
You can take a look at performace counters for high precision timers..

bytedReceived / unitsOfTime = bytesPerUnit..
TotalBytes / bytesPerUnit = ETAinUnits

-Boo
I have a server application that accepts file transfers (utilitzing
tcplistener) and was wondering how I would efficiently go about
determining the calculate transfer rate while I am transferring the
file. The Sub where the transfer actually takes place is called
asynchronously.

The (psuedo) code in the Sub goes something like this:

While byteCount < filesize
bytesRead = Bytes read from NetworkStream
Write bytes just read in to file via a FileStream object
byteCount += bytesRead
Update progress bar for transfer
End While
I have tried somehow using a TimeSpan object to attempt to calculate
after I update the progress bar, but that has proved to not only work
for me, but it makes the transfer rate display not update evenly.

I've looked on the net for any samples of this, but could not turn up
anything.
Aug 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: grant | last post by:
hi folks: Does anyone know how to calculate the shipping rate on Fedex? There was a web module to handle the web query for rate at http://grd.fedex.com/cgi-bin/rrr2010.exe?func=Rate Currently...
2
by: None | last post by:
I'm using the HttpWebRequest/Response methods and I'm trying to figure out how to calculate the effective transfer rare the file is being received at (like you see in IE when you download...
0
by: Bob | last post by:
Hi. I'm developed a simple Transfer File program just to test the NetworkStream class. I want to know how can i get the transfer rate speed. Does someone know how to do it? And... what's the size...
2
by: zolof | last post by:
Hi, I want customers to be able to transfert files to my server (not forcefully a Web server). What is the fastest solution ? For the moment I see 3 possibilities: .NET remoting hosted by IIS...
3
by: Peter Silva | last post by:
Hi folks, I have a need in a network data distribution application to send out data to folks who want it using the protocol of their choice. I´d like it to support a variety of protocols and I...
1
by: aaapaul | last post by:
What is the best way to transfer the necessary files of a website to the webserver. In VS2003 there was a possibility to say Project copy -only files, which are necessary for running ! I...
0
by: Rahat Ali | last post by:
hi every one,i am doing a project now a days in which i want to know the data a clint or a local machine is receiving from internet or server also the bandwidth it is consuming.thanks
1
by: whatazor | last post by:
Hi, how can I calulate transfer rate to a host , without using a file ? can ping module (written by Jeremy Hylton) be useful ?
10
by: Lykus | last post by:
I have created a table for customer bills, and a table for customer profiles which contains rates associated with them specifically. The problem is that after a new rate change has been imposed I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.