/* Test the Reed-Solomon codecs * for various block sizes and with random data and random error patterns * * Copyright 2002 Phil Karn, KA9Q * May be used under the terms of the GNU Lesser General Public License (LGPL) */ #include #include #include #include #include "fec.h" struct etab { int symsize; int genpoly; int fcs; int prim; int nroots; int ntrials; } Tab[] = { {2, 0x7, 1, 1, 1, 10 }, {3, 0xb, 1, 1, 2, 10 }, {4, 0x13, 1, 1, 4, 10 }, {5, 0x25, 1, 1, 6, 10 }, {6, 0x43, 1, 1, 8, 10 }, {7, 0x89, 1, 1, 10, 10 }, {8, 0x11d, 1, 1, 32, 10 }, {8, 0x187, 112,11, 32, 10 }, /* Duplicates CCSDS codec */ {9, 0x211, 1, 1, 32, 10 }, {10,0x409, 1, 1, 32, 10 }, {11,0x805, 1, 1, 32, 10 }, {12,0x1053, 1, 1, 32, 5 }, {13,0x201b, 1, 1, 32, 2 }, {14,0x4443, 1, 1, 32, 1 }, {15,0x8003, 1, 1, 32, 1 }, {16,0x1100b, 1, 1, 32, 1 }, {0, 0, 0, 0, 0}, }; int exercise_char(struct etab *e); int exercise_int(struct etab *e); int exercise_8(void); int main(){ int i; srandom(time(NULL)); printf("Testing fixed CCSDS encoder...\n"); exercise_8(); for(i=0;Tab[i].symsize != 0;i++){ int nn,kk; nn = (1<symsize) - 1; unsigned char block[nn],tblock[nn]; int errlocs[nn],derrlocs[nn]; int i; int errors; int derrors,kk; int errval,errloc; int erasures; int decoder_errors = 0; void *rs; if(e->symsize > 8) return -1; /* Compute code parameters */ kk = nn - e->nroots; rs = init_rs_char(e->symsize,e->genpoly,e->fcs,e->prim,e->nroots,0); if(rs == NULL){ printf("init_rs_char failed!\n"); return -1; } /* Test up to the error correction capacity of the code */ for(errors=0;errors <= e->nroots/2;errors++){ /* Load block with random data and encode */ for(i=0;isymsize) - 1; int block[nn],tblock[nn]; int errlocs[nn],derrlocs[nn]; int i; int errors; int derrors,kk; int errval,errloc; int erasures; int decoder_errors = 0; void *rs; /* Compute code parameters */ kk = nn - e->nroots; rs = init_rs_int(e->symsize,e->genpoly,e->fcs,e->prim,e->nroots,0); if(rs == NULL){ printf("init_rs_int failed!\n"); return -1; } /* Test up to the error correction capacity of the code */ for(errors=0;errors <= e->nroots/2;errors++){ /* Load block with random data and encode */ for(i=0;i