CheckSum
From FIXwiki
FIX Field 10
| Tag | Name | Type | Enumerated | First introduced | Deprecated |
|---|---|---|---|---|---|
| 10 | CheckSum | String | FIX.2.7 |
Three byte, simple checksum (see Volume 2: "Checksum Calculation" for description). ALWAYS LAST FIELD IN MESSAGE; i.e. serves, with the trailing <SOH>, as the end-of-message delimiter. Always defined as three characters. (Always unencrypted)
Notes
Error in FIX Specification:
The above description incorrectly refers to Volume 2 of the specification for a definition of the checksum calculation. In fact the description is in the FIX Transport volume of the spec.
For everyone's convenience, here is the definition as taken from the spec:
The checksum of a FIX message is calculated by summing every byte of the message up to but not including the checksum field itself. This checksum is then transformed into a modulo 256 number for transmission and comparison. The checksum is calculated after all encryption is completed, i.e. the message as transmitted between parties is processed. For transmission, the checksum must be sent as printable characters, so the checksum is transformed into three ASCII digits. For example, if the checksum has been calculated to be 274 then the modulo 256 value is 18 (256 + 18 = 274). This value would be transmitted as |10=018| where "10=" is the tag for the checksum field. A sample code fragment to generate the checksum field is as follows:
char *GenerateCheckSum( char *buf, long bufLen )
{
static char tmpBuf[ 4 ];
long idx;
unsigned int cks;
for( idx = 0L, cks = 0; idx < bufLen; cks += (unsigned int)buf[ idx++ ] );
sprintf( tmpBuf, ā%03dā, (unsigned int)( cks % 256 ) );
return( tmpBuf );
}
Categories: Field | FIX.2.7 | FIX.3.0 | FIX.4.0 | FIX.4.1 | FIX.4.2 | FIX.4.3 | FIX.4.4 | FIX.5.0 | FIXT.1.1 | FIX.5.0SP1 | FIX.5.0SP2 | StandardTrailer | SpecError