ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Algorithm-FEC/README
Revision: 1.2
Committed: Tue Sep 9 23:21:54 2003 UTC (23 years ago) by root
Branch: MAIN
Changes since 1.1: +8 -9 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 NAME
2 root 1.2 Algorithm::FEC - Forward Error Correction using Vandermonde Matrices
3 root 1.1
4     SYNOPSIS
5 root 1.2 use Algorithm::FEC;
6 root 1.1
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 root 1.2 $fec->set_blocks ([array_of_blocks])
29 root 1.1 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 root 1.2 Decode "data_packets" of blocks (see "set_blocks" for the
63 root 1.1 "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 root 1.2 This method destroys the block array as set up by "set_blocks".
89 root 1.1
90 root 1.2 $fec->copy ($srcblock, $dstblock)
91 root 1.1 Utility function that simply copies one block (specified like in
92 root 1.2 "set_blocks") into another. This, btw., destroys the blocks set by
93     "set_blocks".
94 root 1.1
95     If you don't understand why this helps, feel free to ignore it :)
96    
97     COMPATIBILITY
98     The way this module works is compatible with the way freenet
99     (<http://freenet.sf.net>) encodes files. Comaptibility to other file
100     formats or networks is not know, please tell me if you find more
101     examples.
102    
103     SEE ALSO
104     Net::FCP. And the author, who might be happy to receive mail from
105     any user, just to see that this rather rarely-used module is
106     actually being used (except for freenet ;)
107    
108     BUGS
109     * largely untested, please change this.
110     * file descriptors are not supported, but should be.
111     * utility functions for files should be provided.
112     * 16 bit version not tested
113    
114     AUTHOR
115     Marc Lehmann <pcg@goof.com>
116     http://home.schmorp.de
117