Class VDMFec_JNI

java.lang.Object
  |
  +--VDMFec_JNI

public class VDMFec_JNI
extends java.lang.Object

This is an erasure code based on Vandermonde matrices class.

WARNING: the following class can be much more lower than native implementation due to the Java Virtual Machine, furthermore this is only encapsulation of native code, hence portability of original code is NOT improve.


Field Summary
static int GF_BITS
          The following parameter defines how many bits are used for field elements.
static int KK
          Number of maximum source packets Must be inferior to 255, use in main test programme
static int SZ
          Size of packet Size in bytes of each packet to generate
 
Constructor Summary
VDMFec_JNI()
           
 
Method Summary
static int fec_decode(int code, byte[][] pkt, int[] index, int sz)
          fec_decode : decode fec packets of the session
static void fec_encode(int code, byte[][] src, byte[] fec, int index, int sz)
          fec_encode : encode one fec packet
static void fec_free(int p)
          fec_free : free some space Function allowing to free memory allocated in native environement
static int fec_new(int k, int n)
          fec_new : create a new encoder for a fec session This contains k,n and the encoding matrix.
static void init_fec()
          init_fec : initialize fec sessions
static void main(java.lang.String[] args)
          main : main function, launched from Java Virtual Machine Create k packets of size sz of random data, encodes them, and tries to decode.
static int test_decode(int code, int k, int[] index, int sz, java.lang.String s)
          test_decode : test function of VDM Library the following is only test code and can be safely omitted in applications.
static void TICK(long[] t, int index)
          TICK : Take a timestamp
static void TOCK(long[] t, int index)
          TOCK : Compute a time interval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GF_BITS

public static final int GF_BITS
The following parameter defines how many bits are used for field elements. The code supports any value from 2 to 16 but fastest operation is achieved with 8 bit elements This is the only parameter you may want to change.

KK

public static final int KK
Number of maximum source packets

Must be inferior to 255, use in main test programme


SZ

public static final int SZ
Size of packet

Size in bytes of each packet to generate

Constructor Detail

VDMFec_JNI

public VDMFec_JNI()
Method Detail

TICK

public static void TICK(long[] t,
                        int index)
TICK : Take a timestamp

Parameters:
t - (IN) array of reference times
index - (IN) position in t where to put the new reference

TOCK

public static void TOCK(long[] t,
                        int index)
TOCK : Compute a time interval

Parameters:
t - (IN) array of reference times
index - (IN) position in t where old reference is and where new reference will be put

fec_new

public static int fec_new(int k,
                          int n)
fec_new : create a new encoder for a fec session

This contains k,n and the encoding matrix.

Returns:
descriptor of the (struc fec_parms *) native type

fec_free

public static void fec_free(int p)
fec_free : free some space

Function allowing to free memory allocated in native environement

Parameters:
p - (IN) descriptor of the (struc fec_parms *) native type

init_fec

public static void init_fec()
init_fec : initialize fec sessions

fec_encode

public static void fec_encode(int code,
                              byte[][] src,
                              byte[] fec,
                              int index,
                              int sz)
fec_encode : encode one fec packet

Parameters:
code - (IN) descriptor of the (struc fec_parms *) native type
src - (IN) pointer to n data packets
dst - (OUT) pointer to computed output packet
index - (IN) value used for computation
sz - (IN) size of each packets

fec_decode

public static int fec_decode(int code,
                             byte[][] pkt,
                             int[] index,
                             int sz)
fec_decode : decode fec packets of the session

Parameters:
code - (IN) pointer to code descriptor
pkt - (IN-OUT) pointers to received packets
index - (IN) values used for computation
sz - (IN) size of each packet

Returns:
correct vector

test_decode

public static int test_decode(int code,
                              int k,
                              int[] index,
                              int sz,
                              java.lang.String s)
test_decode : test function of VDM Library

the following is only test code and can be safely omitted in applications. Creates k packets of size sz of random data, encodes them, and tries to decode. Index contains the permutation entry.

Parameters:
code - (IN) pointer to code descriptor
k - (IN) number of maximum source packets
index - (IN) value used for computation
sz - (IN) size of each packet
s - (IN) description of the test

Returns:
number of errors

main

public static void main(java.lang.String[] args)
main : main function, launched from Java Virtual Machine

Create k packets of size sz of random data, encodes them, and tries to decode. Index contains the permutation entry.

Parameters:
args - (IN) arguments of function (not used)