473,545 Members | 289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6153
Hello ms****@gmail.co m,

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.co m,

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
6251
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 it is not available, I wonder if there still has a similar module like that. I did some search on the Fedex sites and find out they have several...
2
5484
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 something). I have already learned how to do a "progress bar" type solution, which lets me calculate percentages. This is different however, because rate...
0
1218
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 limit for the transfer buffer? I set the buffer size to 1MB. It's ok? This is the code: private void TransferFile(Socket clientConnection, string...
2
1351
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 using Http transport and binary formatter, XML Web service using WSE 3 and a WebClient sending the file to an ASP.NET page.
3
2511
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 don´t want to implement any of them :-) http, ftp (via ftplib) , https (dunno how yet), ssl, ssh, sftp (via paramiko) The thing is... I want...
1
1392
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 can´t find the same in VS 2005 ! greetings aaapaul
0
1002
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
2120
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
3522
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 want to be able to look at an old bill, via a report, and have it reflect the "old" rate within proper historical context. I'm looking for suggestions...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5969
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.