ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Algorithm-FEC/README
Revision: 1.1
Committed: Tue Sep 9 05:52:49 2003 UTC (23 years ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 NAME
2     Convert::FEC - Forward Error Correction using Vandermonde Matrices
3    
4     SYNOPSIS
5     use Convert::FEC;
6    
7     DESCRIPTION
8     This module is an interface to the fec library by Luigi Rizzo et al.,
9     see the file README.fec in the distribution for more details.
10    
11     This library implements a simple ("encoded_packets","data_packets")
12     erasure code based on Vandermonde matrices. The encoder takes
13     "data_packets" packets of size "block_size" each, and is able to produce
14     up to "encoded_packets" different encoded packets, numbered from 0 to
15     "encoded_packets-1", such that any subset of "data_packets" members
16     permits reconstruction of the original data.
17    
18     Allowed values for "data_packets" and "encoded_packets" must obey the
19     following equation:
20    
21     data_packets <= encoded_packets <= MAXBLOCKS
22    
23     Where "MAXBLOCKS=256" for the fast implementation and "MAXBLOCKS=65536"
24     for the slow implementation (the implementation is chosen
25     automatically).
26    
27     $fec = new data_packets, encoded_packets, blocksize
28     $fec->set_encode_blocks ([array_of_blocks])
29     Sets the data blocks used for the encoding. Each member of the array
30     can either be:
31    
32     * a string of size "blocksize" "exactly".
33     This is useful for small files (encoding entirely in memory).
34    
35     * a filehandle of a file of size "blocksize" "exactly".
36     This is useful when the amount of data is large and resides in
37     single files.
38    
39     * a reference to an array containing a filehandle and, optionally,
40     an offset into that file.
41     This is useful if the amount of data is large and resides in a
42     single file. Needless to say, all parts must not overlap and
43     must fit into the file.
44    
45     If your data is not of the required size (i.e. a multiple of
46     "blocksize" bytes), then you must pad it (e.g. with zero bytes) on
47     encoding, and truncate it after decoding.
48    
49     If called without arguments, the internal storage associated with
50     the blocks is freed again.
51    
52     $block = $fec->encode (block_index)
53     Creates a single encoded packet of index "block_index", which must
54     be between 0 and "encoded_packets-1" (inclusive). The blocks from 0
55     to "data_packets-1" are simply copies of the original data blocks.
56    
57     The encoded block is returned as a perl scalar (so the blocks should
58     fit into memory. If this is a problem for you mail me and I'll make
59     it a file.
60    
61     $fec->decode ([array_of_blocks], [array_of_indices])
62     Decode "data_packets" of blocks (see "set_encode_blocks" for the
63     "array_of_blocks" parameter).
64    
65     Since these are not necessarily the original data blocks, an array
66     of indices (ranging from 0 to "encoded_packets-1") must be supplied
67     as the second arrayref.
68    
69     Both arrays must have exactly "data_packets" entries.
70    
71     After decoding, the blocks will be modified in place (if necessary),
72     and the array of indices will be updates to reflect the changes: The
73     n-th entry in the indices array is the index of the n-th data block
74     of the file.
75    
76     That is, if you call this function with "indices = [4,3,1]", with
77     "data_packets = 3", then this array will be returned: "[0,2,1]".
78     This means that input block 0 corresponds file block 0, input block
79     1 to file block 2 and input block 2 to data block 1.
80    
81     You can just iterate over this array and write out the corresponding
82     data block (although this is inefficient).
83    
84     Only input blocks with indices >= "data_packets" will be modified,
85     blocks that already contain the original data will just be
86     reordered.
87    
88     This method destroys the block array as set up by
89     "set_encode_blocks".
90    
91     $fec->copy_block ($srcblock, $dstblock)
92     Utility function that simply copies one block (specified like in
93     "set_encode_blocks") into another. This, btw., destroys the blocks
94     set by "set_encode_blocks".
95    
96     If you don't understand why this helps, feel free to ignore it :)
97    
98     COMPATIBILITY
99     The way this module works is compatible with the way freenet
100     (<http://freenet.sf.net>) encodes files. Comaptibility to other file
101     formats or networks is not know, please tell me if you find more
102     examples.
103    
104     SEE ALSO
105     Net::FCP. And the author, who might be happy to receive mail from
106     any user, just to see that this rather rarely-used module is
107     actually being used (except for freenet ;)
108    
109     BUGS
110     * largely untested, please change this.
111     * file descriptors are not supported, but should be.
112     * utility functions for files should be provided.
113     * 16 bit version not tested
114    
115     AUTHOR
116     Marc Lehmann <pcg@goof.com>
117     http://home.schmorp.de
118