anon.mixminion.fec
Class Pure16Code
java.lang.Object
anon.mixminion.fec.FECCode
anon.mixminion.fec.PureCode
anon.mixminion.fec.Pure16Code
public class Pure16Code
- extends PureCode
This class, along with FECMath, provides the implementation of the pure
Java 16 bit FEC codes. This is heavily dervied from Luigi Rizzos original
C implementation. See the file "LICENSE" along with this distribution for
additional copyright information.
(c) Copyright 2001 Onion Networks
(c) Copyright 2000 OpenCola
- Author:
- Justin F. Chapweske (justin@chapweske.com), JAP-Team -- made some changes
Fields inherited from class anon.mixminion.fec.FECCode |
k, n |
Constructor Summary |
Pure16Code(int k,
int n)
Notes about large N support:
you can just generate the top k*k vandermonde matrix, call it V,
then invert it, then when you have k blocks generate a matrix M
with the k rows you need and E = M* V^{-1} is the encoding matrix
for the systematic code which you then need to invert to perform
the decoding. |
Method Summary |
void |
decode(byte[][] pkts,
int[] pktsOff,
int[] index,
int packetLength,
boolean inOrder)
This method takes an array of encoded packets and decodes them. |
protected char[][] |
decode(char[][] pkts,
int[] pktsOff,
int[] index,
int numChars)
|
void |
encode(byte[][] src,
int[] srcOff,
byte[][] repair,
int[] repairOff,
int[] index,
int packetLength)
encode accepts as input pointers to n data packets of size sz,
and produces as output a packet pointed to by fec, computed
with index "index". |
protected void |
encode(char[][] src,
int[] srcOff,
char[] repair,
int repairOff,
int index,
int numChars)
ASSERT: index >= k && index < n |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
fecMath
protected static final FECMath fecMath
Pure16Code
public Pure16Code(int k,
int n)
- Notes about large N support:
you can just generate the top k*k vandermonde matrix, call it V,
then invert it, then when you have k blocks generate a matrix M
with the k rows you need and E = M* V^{-1} is the encoding matrix
for the systematic code which you then need to invert to perform
the decoding. Probably there is a fast way to invert E given that M
is also a vandermonde matrix so it is "easy" to compute M^{-1}
encode
public void encode(byte[][] src,
int[] srcOff,
byte[][] repair,
int[] repairOff,
int[] index,
int packetLength)
- encode accepts as input pointers to n data packets of size sz,
and produces as output a packet pointed to by fec, computed
with index "index".
- Overrides:
encode
in class PureCode
- Parameters:
src
- An array of k
byte[]'s that contain the source
packets to be encoded. Often these byte[]'s are actually references
to a single byte[] that contains the entire source block, then you must
simply vary the srcOff's to pass it in in this fashion. src[0] will
point to the 1st packet, src[1] to the second, etc.srcOff
- An array of integers which specifies the offset of each
each packet within its associated byte[].repair
- Much like src, variable points to a number of buffers
to which the encoded repair packets will be written. This array should
be the same length as repairOff and index.repairOff
- This is the repair analog to srcOff.index
- This int[] specifies the indexes of the packets to be
encoded and written to repair
. These indexes must be
between 0..n (should probably be k..n, because encoding < k is a NOP)packetLength
- the packetLength in bytes. All of the buffers
in src and repair are assumed to be this long.
encode
protected void encode(char[][] src,
int[] srcOff,
char[] repair,
int repairOff,
int index,
int numChars)
- ASSERT: index >= k && index < n
decode
public void decode(byte[][] pkts,
int[] pktsOff,
int[] index,
int packetLength,
boolean inOrder)
- Description copied from class:
FECCode
- This method takes an array of encoded packets and decodes them. Before
the packets are decoded, they are shuffled so that packets that are
original source packets (index < k) are positioned so that their
index within the byte[][] is the same as their packet index. If the
shuffled
flag is set to true then it is assumed that
the packets are already in the proper order. If not then they will
have the references of the byte[]'s shuffled within the byte[][]. No
data will be copied, only references swapped. This means that if the
byte[][] is wrapping an underlying byte[] then the shuffling proceedure
may bring the byte[][] out of sync with the underlying data structure.
From an SPI perspective this means that the implementation is expected
to follow the exact same behavior as the shuffle() method in this class
which means that you should simply call shuffle() if the flag is false.
- Overrides:
decode
in class PureCode
- Parameters:
pkts
- An array of k
byte[]'s that contain the repair
packets to be decoded. The decoding proceedure will copy the decoded
data into the byte[]'s that are provided and will place them in order
within the byte[][]. If the byte[][] is already properly shuffled
then the byte[]'s will not be moved around in the byte[][].pktsOff
- An array of integers which specifies the offset of each
each packet within its associated byte[].index
- This int[] specifies the indexes of the packets to be
decoded. These indexes must be between 0..npacketLength
- the packetLength in bytes. All of the buffers
in pkts are assumed to be this long.
decode
protected char[][] decode(char[][] pkts,
int[] pktsOff,
int[] index,
int numChars)
toString
public java.lang.String toString()
- Overrides:
toString
in class PureCode