FILE TRANSFER METHOD AND APPARATUS USING HASH NUMBERS

Abstract: The present invention facilitates and speeds the transmission of a copy of a new file (13) to a receiving computer (2) where the receiving computer (2) has an old file (23). The sending computer (1) does not know the status or content of the old file (23). As a preliminary step, the receiving computer divides the old file into segments, and calculates a hash number for each segment. The receiving computer (2) then transmits these hash numbers to the sending computer (1). The sending computer (1) examines each segment in the new file (13) to determine which, if any, segments in the new file (13) have hash numbers that match the hash numbers received from the receiving computer (2). The sending computer (1) sends to the receiving computer (2) those bytes from the new file (13) that are not part of any matching segment and an indication where matching segments fit into the new file (13). Finally, the receiving computer (2) constructs a copy of the new file (13C) from the bytes received and from the matching segments in the old file (23).

Description: FILE TRANSFER METHOD AND APPARATUS USING HASH NUMBERS Field of the Invention: The present invention relates to electronic computers and more particularly to the transfer of files between computers. Background of the Invention: There are a wide variety of commercially available computer programs which facilitate transferring files between computers utilizing modems and telephone lines. Among such commercially available programs are: "Crosstalk" marketed by DCA Corp of Atlanta, Georgia; "QModem" marketed by Forgin Inc. of Cedar Falls Iowa; and, "Close-Up", marketed by Norton Lambert Corp of Santa Barbara, CA. The physical characteristics of normal telephone lines limit the transmission speed which can be used to transmit data over such lines. In order to shorten the time required to transmit data, various data compression and error correcting protocols are in widespread use. It is known that when a file on a particular computer is being updated, the transmission time can be shorted by merely transmitting information which relates to the "differences" or the "delta" between the present file and the previously transmitted file. The technique of only transmitting the delta between two files is only applicable in situations where the sending system knows the state of the file at the receiving station. The present invention provides a technique for rapidly transmitting files between computers where the computer receiving the information has a file stored thereon, but where the sending computer does not know the state (i.e. the exact contents) of the file at the receiving computer. Summary of the Invention: The present invention facilitates the transmission of a file (hereinafter referred to as the new file) from a first computer to a second computer, in a situation where the second computer has a file (hereinafter referred to as the old file) but where the first computer does not know the status or content of the old file. With the present invention, as a preliminary step, the second computer divides the old file into segments, and calculates a hash number for each segment. The second computer transmits these hash numbers to the first computer. The first computer examines each possible segment in the new file to determine which if any segments in the new file have hash numbers which correspond to the hash numbers received from the second computer (such segments are hereinafter called matching segments). The first computer sends to the second computer those bytes from the new file that are not part of any matching segment and an indication of which matching segments fit into the new file. The second computer constructs copy of the new file from the bytes received and from the matching segments in the old file. Brief Description of the Drawings: Figure 1 is an overall block diagram of the computer systems. Figure 2 is a block diagram of the actions that take place at the receiving computer. Figure 3A is an example of a Segment Profile Table. Figure 3B is a table giving an example of information transmitted by the sending computer. Figure 4 is a block diagram of the actions that take place at the sending computer. Detailed Description of a Preferred embodiment: Two interconnected computers that can be used to practice the invention are shown in Figure 1. A sending computer 1 is connected to a receiving computer 2 via modems 3 and 4 and a telephone line 7. A new file 13, is stored in computer 1. The preferred embodiment of the invention described herein can be used to transfer a copy of file 13 from computer 1 to computer 2. The copy of the file 13 which resides in computer 2 after the transfer operation is designated 13C. It is shown in dotted lines in Figure 1 since it is only present in computer 2 after the transfer operation is complete. Computer 1 has a conventional internal RAM memory 11 which has stored therein a number of programs and files. It is noted that while various programs and files are shown as being in the RAM memory 11 of computer 1, a substantial part of these programs and files could alternatively be stored on other types conventional storage devices such as on magnetic disks. How the various programs and files are stored is not particularly relevant to the present invention and it can be in any conventional manner. As shown in Figure 1, the computer memory 11 includes an operating system 14, a communication program 15, a file manipulation program 16, a new file 13 and other files 12. The operating system 14 can for example be the DOS operating system that is marketed by Microsoft Corporation and the communications program 15 can be a conventional communication program for a DOS type of computer. The new file 13 is the file which computer 1 will transferred to computer 2 utilizing the present invention. It is noted that as used herein the term "transferring a file" should be understood as synonymous with the more precise terms "transferring a copy of a file". Furthermore as will be explained hereinafter in alternative embodiments of the invention, the "file" being transferred may merely be a designated string of bytes and not a complete file in the sense that a DOS file is a complete file. The file manipulation program 16, and related program 26 in computer 2, are the programs which implement the main parts of the present invention as hereinafter described. The operations performed by these programs are shown in block diagram form in Figures 2 and 4. The computer 2 is substantially identical to the computer 1 and the components in computer 2, other than the files, are identical. Computer 2 includes memory 21, operating system 24, file manipulation program 26, communication program 25 and a file designated "old file" 23. It is noted that new file 13, and old file 23, are merely illustrative of files that are typically stored on personal computers and work stations. Typically a computer will have many stored files and often the user of a computer has a desire and need to transfer a file to another computer. There are many existing programs and protocols designed for this purpose. Many of these protocols involve various types of compression. Conventional communication programs 15 and 25 may or may not use the conventional type of compression techniques for transmitting data. The present invention relates to the particular information which is transmitted in order to transmit a complete file. The actual transmission mechanism for transmitting the information may be conventional. The present invention takes a new and different approach to the file transfer task. The present invention recognizes and takes advantage of the fact that many times when a file is being transferred from a first computer to a second computer, there are files stored at the second computer that are related in some way to the file that is being transmitted. For example, new file 13 may be a updated version of the old file 23. Alternatively, the new file 13 may be a file in the format of a particular word processor document such a WordPerfect. The document may for example by a contract. The old file 23 may a WordPerfect document where the document in file 23 may be an unrelated contract. The present invention takes advantage of the fact that such seemingly unrelated files may contain a substantial number of identical stings of bytes. For example, some of the similar bytes may be formatting information, others similar bytes may be type fonts, others similar bytes may be similar phrases that appear in the two documents, etc. With the present invention similarities between a new file (i.e. the file being transmitted) and a document at the receiving computer are detected and used to speed the transmission of the new file. The present invention also takes advantage that present day modems 3 and 4 can operate in a full duplex mode where information is transferred simultaneously in two directions. The present invention utilizes bi- directional transfer of information between computers to speed the transfer of information in one direction. The preferred embodiment described herein performs the following major steps in order to transfer a copy of new file 13 from computer 1 to computer 2. a) A file stored on computer 2 is selected for designation as old file 23. b) Computer 2 divides the old file 23 into 128 byte segments and calculates a hash number (e.g. a CRC number) for each 128 byte segment of the old file 23. c) Computer 2 sends to computer 1 the hash numbers for the segments of file 23. Computer 1 stores these hash numbers in a Segment Profile Table (SPT). d) Computer 1 calculates hash numbers for each possible segment in the new file 13 and compares these hash numbers to the hash numbers it has received from computer 2. Segments in the new file which have hash numbers that correspond to the hash number of a segment in the old file are termed matching segments. e) Bytes in the new file that are not part of any matching segment are transmitted from computer 1 to computer 2. f) Matching segments are not transmitted from computer 1 to computer 2. Instead the computer 1 sends computer 2 an indication that a particular matching segment fits at a particular place in the file being constructed at computer 2. The location where the segments from the old file 23 fit into the copy 13C of the new file is evident from the sequence in which bytes from the new file and segment identifications are transmitted. g) Computer 2 constructs a copy 13C of the new file 13 from the transmitted bytes and from matching segments copied from the old file. At the beginning of the transmission process after a file on computer 2 has been designated as old file 23, computer 1 has an empty SPT. At this point computer 1 begins calculating the hash number of the first segment in new file 13. Since the SPT is empty the calculated hash numbers will not match any hash number in the SPT. Since no match is found, computer 1 sends the first byte in the first segment of file 13 to computer 2. A new byte from file 13 is then be added to the segment and a new hash number calculated. The process repeats. At the same time that computer 1 is examining segments of new file 13, computer 23 is calculating hash numbers for segments in old file 23 and transmitting these values to computer 1 for storage in the SPT. As time progresses, the SPT will contain more and more entries and matches between hash numbers computer by computer 1 and information in the SPT will begin to occur. When computer 1 finds a matching segment (i.e. a segment that has a hash number that matches one of the hash numbers in the SPT), computer 1 merely sends computer 2 an indication that a match has been detected and that computer 2 should copy a particular segment from the old file into the new file. When computer 1 finds a matching segment and transmits this information to computer 2, computer 2 will insert the matching segment from the old file 23 immediately after the last byte that was received from computer 1. Thus the sequence information is received by computer 2 indicates where segments from the old file 23 should be inserted in the copy 13C of the new file. Segments from old file 23 are identified in the SPT by the offset of the first byte in the segment. Thus when computer 1 sends to computer 2 the identification of a segment (i.e. the offset of the first byte of a segment) the computer 2 can identify which part of the old file 23 should be copied into the copy 13C of the new file 13 that is being constructed. The type of hash number used in the preferred embodiment of the invention described herein is the well known cyclical redundancy check (CRC) number. The manner of calculating such numbers is well known. It is noted that while as described herein, the calculated CRC number is described as uniquely identifies a specific segment, as is well known, this is only correct in a practical sense and not in a strict mathematical sense. Errors can occur in that the same CRC can sometimes be calculated for two different segments. The number of such "errors" is so low as to be negligible and as described herein the CRC numbers are assumed to represent unique file segments. The number of possible duplications (i.e. errors) can be further reduced by using a longer CRC polynomial. As is well know, for computational efficiency, the length of the CRC is best chosen to match the size of the computer's registers. In situations where the length of the CRC is dictated by other considerations, two concatenated CRC numbers can be used to reduce the number of "errors". The manner of calculating CRC numbers is well know and forms no part of the present invention. Instead of using CRC numbers as hash numbers, the other well known types of hash numbers could be used. Each of the above major steps will now be explained in detail as will their purpose and how they are carried out. Figures 2 and 4 are program flow diagrams showing the operations that take place on computers 1 and 2. Figure 3A is a diagram showing the information stored in the SPT. Figure 3B is a table illustrating a representative sequence of information that is transmitted from computer 1 to computer 2. It is noted that data can simultaneously flow in both directions over communication line 7 from modem 3 to modem 4 and from modem 4 to modem 3. That is line 7 operates in full duplex mode. Modems and communication programs that handle duplex communication are well known. The unique method and apparatus of the present invention takes advantage of the ability to transfer data in the reverse direction without slowing the transfer of data in the forward direction in order to speed the transfer of the file in the forward direction. Two processes take place on receiving computer 2. First a CRC number is calculated for each segment in the old file. This first processes includes receiving the file name and file type of the new file from computer 1 and determining which file stored at computer 2 will be designated as the old file. Second, computer 2 receives bytes and segment identifications from computer 1 and a copy 13C of the new file 13 is constructed. As shown in Figure 2, the first process which takes place on computer 2 is indicated by blocks 201 to 206 and the second process is indicated by blocks 210 to 214. At the initiation of a file transfer operation, computer 1 send to computer 2, the file name and file type of the file which will be transmitted (block 201). Computer 2 selects a file (block 202) which will be used as old file 23 based upon the following priorities: 1) Same file name and file type. If no such file, then, 2) Same file type and same file name except for two characters. If no such file, then, 3) Same file type. If no such file, then, 4) Same file name. If no such file, then, 5) Longest available file. It is noted that various alternative ways could also be used to identify which file on computer 2 will be designated as "old file" 23. Next (block 203) the first 128 byte segment is read from the file designated as old file 23 and the CRC number for this segment is calculated (block 204). The calculated CRC number is sent to computer 1 (block 205). It is noted that as computer 1 receives a sequence of CRC numbers, the offset of the beginning of the segment used to calculate each CRC number is merely the offset of the segment used to calculate the previous number increased by 128. The operations in block 203, 204 and 205 repeat until the end of file is detected at which time the old file is closed (block 206). The operations indicated by blocks 203, 204 and 205, in effect divide the old file 23 into segments, each 128 bytes long, a CRC is calculated for each of these segments, and the CRC values are transmitted to computer 1. At the same time the operations indicated by blocks 202 to 206 are taking place, computer 2 is receiving information from computer 1. This is indicated by block 210 to 214. Typical modern day computers can easily handle such multitasking on a time shared basis. Initially computer 1 sends computer 2 a series of bytes from the new file 13 (block 210). As the process progresses, identification of segments from old file 23 (block 212) will be received interspersed with bytes from new file 13. How this occurs will be explained later with reference to figures 3B and 4. The receiving computer 2 builds the copy 13C of the new file 13 (block 213) from the bytes received from computer 1 and from segments from old file 23 (when it receives a segment identification). Finally an end of file indication is received (block 214) and the process is complete. The CRC numbers that are sent from computer 2 to computer 1 are assembled in computer 1 in a Segment Profile Table (SPT) such as that shown in Figure 3A. It is noted that the numbers 0 to 8 shown in the first column of Figure 3A are shown in Figure 3A merely for convenience of illustration. In the actual SPT, since each segment is 128 bytes long, the segment identifications ind the actual SPT would be the offset of the beginning of each segment (i. e. the numbers 0 to 8 multiplied by 128). The operations which take place at computer 1 are shown in Figure 4. As with the computer 2, two process proceed simultaneously (i.e. in a multitasking mode) at computer 1. First there is a calculating and sending operation indicated by blocks 401 to 410 and second there is the receiving operation indicated by blocks 421 and 422. When a file transfer is initiated the first step (block 401) involves transferring the file name and file type of the new file 13 (i.e. the name of the file being transferred) from computer 1 to computer 2. Next a file pointer is set to "0" (block 402) and the first one hundred and twenty eight bytes are read from new file 13 and the CRC of this first segment is calculated (block 403). The CRC so calculated is compared to the CRC numbers in the SPT (block 405). When the operation begins, no CRC numbers will as of yet been received from computer 2 and the SPT will be empty, thus no match will be found. The first byte in the segment will therefore be sent to computer 2 (block 407), the effect of that one byte on the CRC is subtracted from the calculated CRC (block 408), the next byte read from the file, and a new CRC calculated (block 409). If the end of the file has not been reached (block 404), the new CRC will be compared to the contents of the SPT and the operation proceeds. If there is a match between the calculated CRC number and a CRC number in the SPT, the segment number of the file from the SPT will be sent to computer 2 (block 406) and an entirely new 128 byte segment will be read from the file (block 403). The above process continues until and end of file indication is detected (block 404). When the end of file indication is detected, the bytes remaining (which could be up to 127 bytes) are sent to computer 2 (block 410). As indicated by block 421, the computer 1 receives the CRC numbers calculated as indicated in Figure 2. Computer 1 uses these numbers (block 422) to build a Segment Profile Table (SPT) as indicated in Figure 3A. An example of the sequence in which information is transmitted from computer 1 to computer 2 is given in Figure 3A. The reference numbers in the first column of figure 3A are merely for reference during the explanation of the table. The second column gives the information transmitted and the third column is merely an brief explanation to facilitate and understanding of Figure 3A. As indicated by line LI, the first information transmitted from computer 1 to computer 2 is the file name and file type of the new file 13. This information is used by computer 2, to select a file which will be used as old file 23. Next in the example shown, bytes 1- 57 of the file are transmitted. This indicates that for the particular file in question the first fifty seven times through the loop formed by blocks 403 to 405 in Figure 4, no matching CRC was found in the SPT. Next as indicated by line L3, block 405 in figure 4 determines that the segment of the new file being examined has the same CRC number as does segment 3 in the old file. Computer 1 merely sends to computer 2 an indication that after putting the first 57 bytes (i.e. line L2 from Figure 3B) into the file 13C, computer 2 should copy segment 3 from the old file 23 into the new file 13C. The process then proceeds through lines L4 to L7 etc. It is noted that line L7 in figure 3A shows that the same segment from the old file can be used more than once in constructing the new file 13C. It is noted that the technique used to determine which file on computer 2 is designated as the old file is not particularly relevant to the present invention. Various techniques could be used as an alternative to that shown above. Naturally if the old file selected closely resembles the new file 13, less bytes and more segments identifications could be transmitted by computer 1 thereby reducing the transmission time. It is also noted that the segments used in the above described preferred embodiment are 128 bytes long. Longer or shorter segments could be selected depending upon the particular nature of the files being transmitted. Furthermore the segment length could be made dependent on various factors such as whether there is a file in computer 2 with the same file name and file type as the file in the sending computer or the file type of the file begin transferred. In the above described preferred embodiment, the information in the SPT is only used to transmit one file, herein designated new file 13. It is noted that the SPT from each transmission operation can be saved such that subsequent transmissions have at their disposal a large SPT which defines segments in a plurality of files on the receiving computer. Similar segments which could be identified in a number of different files on the receiving computer could then be used to speed the transmission of one new file. That is the copy of the new file would be made from segments which are identified in a number of files on the receiving computer. While in the preferred embodiment described above, a file of the type used in DOS based computers was transferred from computer 1 to computer 2, it should be understood that in alternative embodiments, the invention could be used to transfer other types of "files" between computers. For example the invention could be used to transfer a particular string of bytes from one computer to a second computer. Thus, it should be understood that the present invention can be used to transfer any string of bytes (herein termed a "file") from one computer to a second computer. It is noted that herein computer 2 divides file 23 into segments and calculates a CRC for each such segment, while computer 1, calculates a CRC for each possible segment, i.e each 128 byte segment following each byte in the file. It is noted that in alternative embodiments, computer two could also calculate hash numbers for segments starting a various points in the file or computer 1 could calculate CRC numbers by first dividing the file into fixed length segments and later going back and re-dividing the file into segments starting at different places in the file. While the invention has been described with reference to a preferred embodiment thereof, it will be understood that the alternatives mentioned and various other alternatives could be chosen without departing from the spirit and scope of the invention. The invention is limited solely by the limitations in the appended claims.

Claims: We claim : 1) A method of transferring a particular file from a first computer to a second computer, said second computer having therein a second file, said method comprising the steps of: a) analyzing said second file and generating a hash number for segments thereof, b) transferring said hash numbers to said first computer and storing them in a table, d) analyzing said particular file to determine segments thereof that have hash numbers corresponding to hash numbers in said table, segments in said particular file which have hash numbers corresponding to hash numbers in said table comprising a first set of segments, e) sending to the second computer those parts of the first file which are not part of any segment in said first set of segments, and sending to the second computer an indication of the segments that are in said first set of segments, and f) combining at said second computer the parts of said particular file that were transmitted with designated parts of the second file to construct a replica of said particular file. 2) The method recited in claim 1 wherein said table is a Segment Profile Table having a list of segments and an indication of the hash number for each segment in the list of segments. 3) The method recited in claim 1 wherein said hash numbers are cyclical redundancy check numbers. 4) The method recited in claim 1 wherein said particular file is a new file. 5) The method recited in claim 1 including the step of sending the name of said particular file from said first computer to said second computer. 6) The method recited in claim 5 wherein said second computer has stored therein a plurality of files and including the step of selecting a file at said second computer which forms said second file. 7) The method recited in claim 6 wherein said selection is based on the name of said particular file which was sent form said first computer to said second computer. 8) A system for transferring a particular file from a first computer to a second computer, said second computer having therein a second file, said ∑ /stem comprising the steps of: a) means for analyzing said second file and generating a hash number for each segment thereof, b) means for transferring said hash numbers to said first computer and storing them in a table, d) means for analyzing said particular file to determine segments thereof that have hash numbers corresponding to hash numbers in said table, segments in said particular file which have hash numbers corresponding to hash numbers in said table comprising a first set of segments, e) means for sending to the second computer those parts of the first file which are not part of any segment in said first set of segments, and sending to the second computer an indication of the segments that are in said first set of segments, and f) means for combining at said second computer the parts of said particular file that were transmitted with designated parts of said second file to construct a replica of the said particular file. 9) The system recited in 8 wherein said hash numbers are cyclical redundancy check (CRC) numbers. 10) A system for transferring a first string of bytes from a first computer to a second computer, said second computer having a second string of bytes stored thereon, the string stored on said second computer being devisable into segments, means for transferring to said first computer a plurality of hash numbers calculated from segments in said second string of bytes, each hash number uniquely identifying the content of the segment from which it was calculated, means for identifying a set of segments in said first string of bytes which have hash numbers corresponding to hash numbers transferred from said second computer to said first computer, means for transferring from said first computer to said second computer the portions of said particular file which are not in any segments in said set of segments, and an indication of which segments from said second set of bytes has a corresponding segment in said first string of bytes, means in said second computer for forming a third string of bytes from the segments in the string of bytes on said second computer identified in said set of segments, and from the parts of said first string of bytes which are transmitted to said second computer.

Inventors: HARLAN JIM, THOMAS HENRY EDWARD, HARLAN, JIM, THOMAS, HENRY, EDWARD
Applicants: NORTON LAMBERT CORP, NORTON-LAMBERT CORP.
Application year: 1994
Main classification: G06F13
IPC codes: G06F12, G06F13, H04L29