1This file describes the VDMFEC file format. 2 3Output blocks have the format: 4 5 u_char[packlen] data output packet of length packlen 6 u_char blkid block id [0..N-1] 7 u_char K the FEC K parameter 8 u_char[16] hash MD5 hash of packet + blkid 9 10Output blocks are usually a multiple of the media block or sector 11size (e.g., 512, 1024, 18K, etc.) and packlen = blocksize - 18. 12We store K because small K syndromes on decoding can result in 13false positives (file decoded with no error messages but bad data). 14There's really no good way to store N and the blocksize, you need 15those values to be able to read the file at all. 16 17Note that GF_BITS must be 8 or the block id and K fields will overflow. 18 19A packet, prior to encoding, has one of the following formats, either: 20 21 u_int32_t clen number of data bytes in this chunk 22 u_int32_t chkid chunk id or CHUNK_FINAL for the last one 23 u_char[dlen] data packet data 24 25for the first packet in a chunk, where dlen = packlen - 8, or 26 27 u_char[packlen] data packet data 28 29for the other K - 1 input packets in a chunk. These K packets are encoded 30(expanded) and output as N output blocks. clen and chkid are written in 31network byte order. 32 33A chkid of CHUNK_FINAL marks the end of the file. This is useful when 34reading from raw devices that don't have an explicit EOF indication, and 35also for detecting file truncation. Since CHUNK_FINAL is -1, the output 36stream can have at most 2^32 chunks. Since chunks can be very large this 37isn't a problem. 38 39The maximum size of a chunk is (blocksize - 18) * K - 8. Chunks with less 40data than this are padded with zero prior to encoding. 41