Jump to content

FTP transfer rate


Recommended Posts

Hello all. I am using FTP to tranfer a file from a remote server. I want to be able to monitor the download progress but I don't know how to do that. Getting the file size is not a problem, but how can I find out how much data has been trasferred at a given point during the download?

Thanks in advance for all the help.

MikeC

Link to comment

Hello all. I am using FTP to tranfer a file from a remote server. I want to be able to monitor the download progress but I don't know how to do that. Getting the file size is not a problem, but how can I find out how much data has been trasferred at a given point during the download?

Thanks in advance for all the help.

MikeC

Link to comment
QUOTE(Mike C @ Nov 26 2007, 11:30 AM)
Hello all. I am using FTP to tranfer a file from a remote server. I want to be able to monitor the download progress but I don't know how to do that. Getting the file size is not a problem, but how can I find out how much data has been trasferred at a given point during the download?
I would doubt it unless you've got some way of monitoring the packet transfers directly on the FTP port.
Link to comment
QUOTE(Mike C @ Nov 26 2007, 11:30 AM)
Hello all. I am using FTP to tranfer a file from a remote server. I want to be able to monitor the download progress but I don't know how to do that. Getting the file size is not a problem, but how can I find out how much data has been trasferred at a given point during the download?
I would doubt it unless you've got some way of monitoring the packet transfers directly on the FTP port.
Link to comment

QUOTE(Mike C @ Nov 26 2007, 10:30 AM)

Hello all. I am using FTP to tranfer a file from a remote server. I want to be able to monitor the download progress but I don't know how to do that. Getting the file size is not a problem, but how can I find out how much data has been trasferred at a given point during the download?

If you're using a command-line FTP client, it might output its status to stdout. If you can get the client to send that output continuously to a file, you might be able to poll that file from your application and parse out the most current information. That's all kinds of ugly, though, and pretty unlikely to work :P.

Another option, if you know the size of the file you're downloading in advance and the local filename you're downloading to, would be to just poll the size of the local file as it's downloaded, and divide that by the total number of bytes you're expecting. This, too, depends a bit on your FTP client; if your client preallocates the file on disk it won't work. That's only half as ugly as my first suggestion.

Link to comment

QUOTE(Mike C @ Nov 26 2007, 10:30 AM)

Hello all. I am using FTP to tranfer a file from a remote server. I want to be able to monitor the download progress but I don't know how to do that. Getting the file size is not a problem, but how can I find out how much data has been trasferred at a given point during the download?

If you're using a command-line FTP client, it might output its status to stdout. If you can get the client to send that output (or any other status) continuously to a file, you might be able to poll that file from your application and parse out the most current information. That's all kinds of ugly, though, and pretty unlikely to work :P.

Another option, if you know the size of the file you're downloading in advance and the local filename you're downloading to, would be to just poll the size of the local file as it's downloaded, and divide that by the total number of bytes you're expecting. This, too, depends a bit on your FTP client; if your client preallocates the file on disk it won't work. That's only half as ugly as my first suggestion.

Link to comment

Thanks for the suggestion everyone.

I am planning on using the Labview internet toolkit VIs for this project but was unable to find any output indicating how much data was received at any point in time. Justin's suggestion of polling the file size of the downloded file might work but I agree that it's not very elegant.

How do other programs (FTP clients, browsers, download utilities, etc) know how much data was received?

MikeC

Link to comment

QUOTE(Mike C @ Nov 27 2007, 08:22 AM)

How do other programs (FTP clients, browsers, download utilities, etc) know how much data was received?

Other programs know the progress because they are the program doing the file transfer. They're the ones actively sitting on the port receiving packets, unzipping the headers and handling the packets accordingly. The LV Internet Toolkit VIs are doing this, but they are high level APIs (download this file) not low level APIs (wait for packet on port XYZ). You can write such VIs using the Internet toolkit and create your own implementation of the FTP protocol, which you would call to wait for one packet, update some display, then wait for the next packet. Wouldn't be trivial but it is possible.

Link to comment

QUOTE(Mike C @ Nov 27 2007, 09:22 AM)

Thanks for the suggestion everyone.

I am planning on using the Labview internet toolkit VIs for this project but was unable to find any output indicating how much data was received at any point in time. Justin's suggestion of polling the file size of the downloded file might work but I agree that it's not very elegant.

If you want to use the internet toolkit you certainly can go into the VI library and modify it in such a way to provide somehow some information in a global variable about the current size. The internet toolkit FTP VIs if you dig into them, does basically read multiple blocks inside a loop writing them to the desired file, until all data has been retrieved or the connection is aborted.

There is no current progress information because the high level VI to download a file is written in such a way to only return on a finished download or on error. So there would be never a meaningful progress return value from that VI itself. The information you want to know is deeper inside that VI hierarchy and you will have to modify those VIs somewhat to give you that information in a meaningful way.

Rolf Kalbermatter

Link to comment

QUOTE(rolfk @ Nov 27 2007, 04:41 PM)

If you want to use the internet toolkit you certainly can go into the VI library and modify it in such a way to provide somehow some information in a global variable about the current size. The internet toolkit FTP VIs if you dig into them, does basically read multiple blocks inside a loop writing them to the desired file, until all data has been retrieved or the connection is aborted.

There is no current progress information because the high level VI to download a file is written in such a way to only return on a finished download or on error. So there would be never a meaningful progress return value from that VI itself. The information you want to know is deeper inside that VI hierarchy and you will have to modify those VIs somewhat to give you that information in a meaningful way.

Rolf Kalbermatter

After Aristos' comment I started looking into the low level vis and found that there is a single vi (tcp read) in a loop that reads a specific amount of data (4kb by default) every iteration until the entire file is downloaded. I guess I need to do some rearraging in order to get the info I want.

Thanks for all the help everyone.

Mike C

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.