anon.mixminion.fec
Class PureCode
java.lang.Object
anon.mixminion.fec.FECCode
anon.mixminion.fec.PureCode
- Direct Known Subclasses:
- Pure16Code
public class PureCode
- extends FECCode
This class, along with FECMath, provides the implementation of the pure
Java 8 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 |
PureCode(int k,
int n)
|
PureCode(int k,
int n,
char[] encMatrix)
|
Method Summary |
void |
decode(byte[][] pkts,
int[] pktsOff,
int[] index,
int packetLength,
boolean shuffled)
This method takes an array of encoded packets and decodes them. |
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(byte[][] src,
int[] srcOff,
byte[] repair,
int repairOff,
int index,
int packetLength)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
FEC_MAGIC
public static final int FEC_MAGIC
- See Also:
- Constant Field Values
fecMath
protected static final FECMath fecMath
encMatrix
protected char[] encMatrix
PureCode
public PureCode(int k,
int n)
PureCode
public PureCode(int k,
int n,
char[] encMatrix)
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".
- Specified by:
encode
in class FECCode
- 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(byte[][] src,
int[] srcOff,
byte[] repair,
int repairOff,
int index,
int packetLength)
decode
public void decode(byte[][] pkts,
int[] pktsOff,
int[] index,
int packetLength,
boolean shuffled)
- 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.
- Specified by:
decode
in class FECCode
- 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.
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object