Detecting data loss during FTP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Detecting data loss during FTP
# 1  
Old 06-17-2003
Question Detecting data loss during FTP

Hi,

How we can detect that there has been a data loss during FTP, throught Shell scripting?

I have gone through FTP return codes, but, none indicate that there has been any data loss.

Can we use FTP return code 226 as an indication that during file transfer there has been no data loss? If, yes how good this assumption would be?

TiA,
Sameer.
# 2  
Old 06-17-2003
FTP is based on TCP which guarantees reliable data transmission. If a TCP packet is garbled or fails to arrive, the TCP layer will not acknowledge it. That causes the sender to retransmit. The FTP program has no way to know this happens.

If the TCP layer cannot transmit the data, the file will not be transferred. So all you need to do is see if the file was transferred.
# 3  
Old 06-18-2003
Hi,

That means the occurance for code 226 is an indication that there has been no data loss.

One of my colleague gave me the suggestion to this that, I should transfer another dummy file of say, 1 byte and I should check the status for both the file. If I get the ok status of both the file than that means that there is no data loss.
According to him this has been done in other project and it has been successful.

Well, I am not quite convinced!! Smilie
If the return code 226 it-self is indication of no data loss than why should I go for transffering another file, and complicate my code?

What do you say? Can this new technique be of any help?

TiA,
Sameer.
# 4  
Old 06-18-2003
Transfering another file is a good idea IF you put the verifiable information into it about the main file you were sending. On a ftp from one UNIX system to another, I put the output of ls -s mymainfile.dat into filesize.dat. Then on the receiving side, the cron job that runs waits for filesize.dat to start processing (this also insures that the main file is completed since it went first).
It gets the information on the size of the file and compares it.

You could (if going from UNIX to UNIX) also use the sum command.
# 5  
Old 06-18-2003
The algorithms that sum originally used have been discredited. If you use the sum command, use -p so that you get a crc check. Or just use cksum instead. The crc algorithm is the champ as far as detecting data corruption. That is why the TCP layer is performing a crc on every arriving packet.

The only time I have ever seen the "flag file" used is to know when the last of a collection of files have arrived. Once the flag file appears, you know that you have everything and you can use the data. I do not understand why your colleague's advice in this case. You will have to ask him to explain.

Nor do I understand your fixation on the the 226 return code. I am unable to tell if you think 226 means that file was transferred ok or if you think that 226 means there was a problem. But that doesn't matter, neither view is correct.

According to the rfc:
Quote:
226 Closing data connection.
Requested file action successful (for example, file transfer or file abort).
226 really just means that the data connection is closed. In the case of an abort, it is clear that the file has not been transferred. It is common to close the data connection after a file has been transferred, but it is not required. The data connection is not held open for all eternity under any conditions. If you open a data connection, the time will come that it is closed.
Quote:
The data connection shall be closed by the server under the conditions described in the Section on Establishing Data Connections. If the data connection is to be closed following a data transfer where closing the connection is not required to indicate the end-of-file, the server must do so immediately. Waiting until after a new transfer command is not permitted because the user-process will have already tested the data connection to see if it needs to do a "listen"; (remember that the user must "listen" on a closed data port BEFORE sending the transfer request). To prevent a race condition here, the server sends a reply (226) after closing the data connection (or if the connection is left open, a "file transfer completed" reply (250) and the user-PI should wait for one of these replies before issuing a new transfer command).
Paying close attention to the arrivial of a 226 would be crucial if you were writing an ftp client. That is not what you're doing.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Solaris

Packet loss on ce interface.

Hi, I am using the ce interface on my Solaris 9 server and there is significant packet loss when transmitting large packets. Does anyone have a fix for this? ----10.1.0.0 PING Statistics---- 51 packets transmitted, 42 packets received, 17% packet loss round-trip (ms) min/avg/max =... (12 Replies)
Discussion started by: sparcman
12 Replies

2. Shell Programming and Scripting

Download data from ftp.

Dear all, I am beginner to shell scripting. I have to download more than 1k files from ftp site. link is below ftp://ftp.ncbi.nih.gov/genomes/Bacteria/ Earlier i was using wget url, for download but the problem is some times folder names get changed, i don't know how to move in directories... (4 Replies)
Discussion started by: admax
4 Replies

3. IP Networking

packet loss problem

I have 4 network ports on our T5240 sun server. all but 1 gives packet losses (nxge1) nxge0 gives on average 50% packet loss, very bad. nxge2 gives on average 1-2% packet loss. nxge3 gives on average 20% packet loss. Is there a tool or something to help me find the problem? (11 Replies)
Discussion started by: photon
11 Replies

4. Shell Programming and Scripting

Detecting a successfull FTP connection

I have a question. My company has to send a file to another company. The cron script currently just sends the file. However, every now and then the other companies ftp server is down. I wanted to alter my script to detect if the server is up before I attempt to send the file. My idea follows #... (2 Replies)
Discussion started by: beilstwh
2 Replies

5. UNIX for Advanced & Expert Users

Response time under packet loss

I am experiencing a problem where under a dial condition I am experiencing packet loss, which is failrly normal, but the response to the packet loss is taking bewteen 6 and 10 seconds. Could someone please advise what the industry standard is on the response time under a packet loss senario. (1 Reply)
Discussion started by: shane
1 Replies

6. UNIX for Advanced & Expert Users

data corruption with ftp transfer

Hi again, first of all thanks for you help on my last problem, the problem is solved now. But I have many problem :) This time, I transfered a big file, ~3,5 GByte, with ftp from a Sun machine to a linux box, RedHat 7.3. But the file recieved on the Linux Box is corrupt, with smaller files... (12 Replies)
Discussion started by: malcom
12 Replies
Login or Register to Ask a Question