US 7426674 B2 Abstract Method of generating cyclic redundancy checks (CRCs) for a message with N data blocks. The method includes calculating a partial CRC for an out of order data block and storing the result, generating, using a division operation, a CRC remainder multiplier associated with the out of order data block and storing the result, repeating the calculating and generating steps until all N data blocks for the message are received, and combining the results of the calculating step and the generating step.
Claims(9) 1. A method of generating cyclic redundancy checks (CRCs) for a message with N data blocks, comprising:
calculating a partial CRC for an out of order data block and storing the result;
generating, using a division operation, a CRC remainder multiplier associated with the out of order data block and storing the result;
repeating the calculating and generating steps until all N data blocks for the message are received;
combining the results of the calculating step and the generating step;
calculating a CRC for an in order data block using any previously computed in order CRC; and
starting a first CRC engine for calculating the CRC for the in order data block, and starting the first CRC engine and a second CRC engine for calculating the partial CRC for the out of order data block, wherein the first CRC engine and the second CRC engine are adapted to be implemented on one of a same physical hardware and a different physical hardware.
2. The method of
3. A method of generating cyclic redundancy checks (CRCs) for a message with N data blocks, comprising:
calculating a partial CRC for an out of order data block and storing the result;
generating, using a division operation, a CRC remainder multiplier associated with the out of order data block and storing the result;
repeating the calculating and generating steps until all N data blocks for the message are received;
combining the results of the calculating step and the generating step;
calculating a CRC for an in order data block using any previously computed in order CRC; and
initializing a CRC engine with a CRC remainder for the in order block, the CRC remainder being a result of a prior CRC computation.
4. A method of generating cyclic redundancy checks (CRCs) for a message with N data blocks, comprising:
calculating a partial CRC for an out of order data block and storing the result;
generating, using a division operation, a CRC remainder multiplier associated with the out of order data block and storing the result;
repeating the calculating and generating steps until all N data blocks for the message are received;
combining the results of the calculating step and the generating step; and
initializing a first CRC engine with a partial CRC remainder and a second CRC engine with the CRC remainder multiplier, the partial CRC remainder and the CRC remainder multiplier being a result of a prior partial CRC computation.
5. The method of
6. A method of generating cyclic redundancy checks (CRCs) for a message with N data blocks, comprising:
calculating a partial CRC for an out of order data block and storing the result;
repeating the calculating and generating steps until all N data blocks for the message are received; and
combining the results of the calculating step and the generating step,
wherein the calculating step includes calculating the partial CRC according to crc_b[k]=CRC (B
_{k}), where crc_b[k] is the partial CRC for data block k and B_{k }is the data block bit pattern of data block k.7. A method of generating cyclic redundancy checks (CRCs) for a message with N data blocks, comprising:
calculating a partial CRC for an out of order data block and storing the result;
repeating the calculating and generating steps until all N data blocks for the message are received; and
combining the results of the calculating step and the generating step,
wherein the generating step includes generating the remainder multiplier according to crc
_{—}2[k]=CRC (2^{Sk}), where crc_{—}2[k] is the remainder multiplier for data block k, and S_{k }is the bit length of data block k.8. The method of
_{k }plus one bit to a CRC engine.9. A method of generating cyclic redundancy checks (CRCs) for a message with N data blocks, comprising:
calculating a partial CRC for an out of order data block and storing the result;
repeating the calculating and generating steps until all N data blocks for the message are received; and
combining the results of the calculating step and the generating step,
wherein the N data blocks contain at least one data block of the N data blocks that is one of a different length and a same length.
Description The present application is a continuation of U.S. application Ser. No. 10/605,436 filed Sep. 30, 2003, now U.S. Pat. No. 7,010,469 issued on Mar. 7, 2006, the disclosure of which is expressly incorporated by reference herein in its entirety. 1. Field of the Invention The present invention generally relates to a method of computing partial cyclic redundancy checks (CRCs) and, more particularly, a method for computing partial CRCs in real time for variable length data blocks and packets. 2. Background Description Reliable transmission of data typically involves computation of error detecting checks, such as cyclic redundancy checks (CRCs), to support a wide range of protocols and transmission mediums. For example, the iSCSI (Internet Small Computer Systems Interface) standard provides a mechanism for exchanging SCSI commands and data over TCP/IP (Transmission Control Protocol/Internet Protocol). iSCSI defines a PDU (Protocol Data Unit) for the exchange between an iSCSI initiator and target. iSCSI PDUs may not be aligned to TCP segments or IP datagrams, because the TCP layer treats the data passed to and from an upper layer as a byte stream. Since TCP may break the byte stream at any arbitrary point, PDUs may not be aligned to TCP segments so that portions of PDUs may appear within a TCP segment. The iSCSI standard defines a CRC32 check to verify the integrity of PDU headers and data payloads. One difficulty in computing CRC remainders is that portions of a PDU may arrive out of order from the network. The out of order delivery is a result of the underlying TCP/IP protocols used to transfer iSCSI PDUs. Traditional implementations of generating CRC remainders depend on the data being processed in order. The result of these behaviors of TCP/IP is that portions of an iSCSI PDU may be contained in different Ethernet packets which may arrive out of order. It is typically more difficult for hardware to compute the CRC when Ethernet frames (or similar frames) arrive out of order. The CRC algorithm itself creates part of the problem because the CRC result for a byte of data is dependent on all prior bytes over which the CRC is protecting. Thus, the CRC computation is not associative. The second factor is that the iSCSI PDUs are not aligned within any of the lower level portions of the protocol. Thus, a PDU boundary may occur anywhere within the data portion of a TCP segment and hence in the lower layers as well. Another factor impacting the CRC generation is the increasing speed of networks. At higher speeds there is less time to process each packet. This has resulted in a number of approaches to offload the TCP/IP processing from the host onto specialized hardware and/or other processors. These approaches also minimize the number of times data is moved within a system. Ideally, the CRC generation should be accomplished as part of the other packet handling requirements. Computing the CRC after all the parts of a PDU have been received consumes additional memory and bus bandwidth. Computing CRCs on the fly or in real time as PDUs arrive would be more efficient and flexible. In an aspect of the invention, a method is provided for generating cyclic redundancy checks (CRCs) for a message with N data blocks that includes the steps of calculating a partial CRC for an out of order data block and storing the result, generating a CRC remainder multiplier associated with the out of order data block and storing the result, repeating the calculating and generating steps until all N data blocks for the message are received, and combining the results of the calculating step and the generating step. In another aspect of the invention, an apparatus for generating cyclic redundancy checks (CRCs) for a message with N data blocks is provided. The apparatus comprising a component to calculate a partial CRC for an out of order data block and to store the result, a component to generate a CRC remainder multiplier associated with the out of order data block and to store the result, and a component to combine the results of the calculated partial CRC and the generate remainder multiplier. In another aspect of the invention, a computer program product is provided comprising a computer usable medium having readable program code embodied in the medium and includes a first component to calculate a partial CRC for an out of order data block and storing the result, a second component to generate a remainder multiplier associated with the out of order data block and storing the result, and a third component to combine the results of the first component and the second component. The foregoing and other objects, aspects and advantages will be better understood from the following detailed description of embodiments of the invention with reference to the drawings, in which: This invention is directed to computing partial CRCs by computing remainders of the powers of two as data blocks are received, instead of, for example, pre-computing them and storing them in a table. Although not shown, assuming there are a finite number of possible sizes, it is anticipated that a pre-computed table could be included in this embodiment. CRCs are prevalent in many transmission mediums and protocol topologies. The term “data block” (also referred to as “block”) refers to the smallest units of data which is a continuous sequence of bits. Data blocks may arrive out of order because the underlying transport mechanism such as Ethernet packets, for example, may arrive out of order. The term “message” refers to a set of one or more data blocks which have a defined order. The mapping of messages to packets breaks a message into data blocks. The term “packet” typically refers to a unit of data which is transmitted intact over a network. A packet may contain portions of one or more messages. A packet may contain other information as defined by the appropriate network protocol. A packet may arrive out of order and hence a data block contained in the packet may arrive out of order. The term “packet data” is the message protected by a CRC. The term “PDU” (protocol data unit) is an ISCSI term and is a type of message transferred over an Ethernet network. The term “data segment” refers to an ISCSI term and is typically an optional portion of a PDU and may also be a type of message. TCP processes data in a byte stream to and from an application such as iSCSI. Thus, the iSCSI PDUs are not aligned in any fashion within TCP/IP packets as they flow over a network. Parts of one or more iSCSI PDUs may be contained in a TCP/IP packet as well as an iSCSI PDU may spread over many TCP/IP packets, a situation that this invention handles more flexibly. An aspect behind CRC checking is that a long bit string, a message, for example, may be characterized by the remainder calculated when that bit string is divided by a specific, shorter, divisor bit string. This divisor bit string is also referred to as the generating polynomial, and the remainder is the CRC value, or just CRC, of the original bit string. When a message is transmitted, this remainder is generated and transmitted as well. When the message is received, the remainder is recomputed and compared with the transmitted remainder. With a high probability that depends on the choice of generating polynomial, if the received and recomputed remainders match, then the message was transmitted and received without error. There are two properties of remainders that are required by any partial CRC approach. First, the remainder of a sum of terms is equal to the sum of the remainders of those terms. Second, the remainder of a product of terms is equal to the product of the remainders of those terms. The division operation used to compute the remainders treats bit strings as binary polynomial coefficients, and along with all other operations on the remainders themselves, uses modulo-2 arithmetic (no carries), for computational efficiency. To insure that all operations on remainders are themselves remainders except for the divisor, a subtraction or division with the divisor is applied as needed. The message over which the CRC is computed is represented in terms of data blocks as follows:
That is, there are P data blocks each containing S bits, and the B The CRCs for the powers of two are pre-computed and put in a table for exponents from 1 to L, where L is the number of data blocks in the largest possible packet:
When all data blocks of a message have been received, the CRC of the message is computed from the tabulated data as:
where these sums and products are defined except for the generating polynomial, as previously described. The invention provides a method for computing the full CRC from partial CRC computations in which any number of data blocks may comprise a message, and data block lengths are variable. To allow any number of data blocks per message, the expression for the Message is modified to:
For fixed length data blocks, only crc Further flexibility is provided by the invention to accommodate variable length data blocks, as follows, built on the basic form of Equation No. 1:
where S As each B At the same time, a pattern of the same length (plus one bit) is fed through a second CRC engine (see Both the crc_b[k] and crc Where poly is the generating polynomial and % is the remainder operator. An advantage to this approach is that there is no pre-computed table, and no restriction on the data block, message, or packet sizes. A CRC32 hardware engine may be placed in the networking dataflow to minimize bus and memory bandwidth as illustrated by the inclusion of CRC Engine Referring to The expression Hcrc (x,y) represents the hardware computation of the partial CRC of block x, starting with a remainder of y. Once all blocks have been received, the final computation of the message CRC may be performed in software (alternatively may be performed in hardware) using the partial CRC values computed over the N blocks and corresponding powers of 2. As an optimization, blocks that are received in order may be processed by the hardware computation shown on the right hand side of the flowchart. In this case, the previously computed CRC is used as the initial remainder in the computation, which eliminates the corresponding iterations of the final computation. The process continues at step If not, at step If the block is in order at step If at step By way of further example, the optimization effect of the invention is illustrated by assuming that a message consists of six blocks, which are received in the order: B For the final computation, B In another embodiment, if the block prior to the current block has been received (not necessarily immediately prior to the immediate block) and resulted in a partial CRC calculation, then the results from the prior block may be used to initialize both CRC engines. By way of example, consider the block stream B Another embodiment may include precomputing the values which would be from the second CRC engine and place them in a table. This approach may be implemented in either hardware or software. The invention may be utilized over a wide range of protocols and varying sizes of data blocks when the number of data blocks to be received is not known at the beginning of a packet or message transmission. The invention provides for substantial optimization and reduction of required processing and does not require the use of pre-computed powers of two. Initializing the CRC engines with data from a prior CRC computation result permits data blocks from different messages to be received correctly when intermixed by the network. While the invention has been described in terms of embodiments, those skilled in the art will recognize that the invention can be practiced with modifications and in the spirit and scope of the appended claims. Patent Citations
Non-Patent Citations
Referenced by
Classifications
Rotate |