Reputation: 550
I'm trying to use the GNU Radio descrambling blocks. I have a block written by a third party that takes of descrambling. The polynomial used is x17 + x12 + 1.
The code is given below
descrambler_cc_impl::descrambler_cc_impl()
: gr::sync_block("descrambler_cc",
gr::io_signature::make(1, 1, sizeof(unsigned char)),
gr::io_signature::make(1, 1, sizeof(unsigned char)))
{
lsr = 0;
}
/*
* Our virtual destructor.
*/
descrambler_cc_impl::~descrambler_cc_impl()
{
}
int
descrambler_cc_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
int i;
for (i = 0; i < noutput_items; i++) {
out[i] = (lsr & 1) ^ ((lsr >> 12) & 1) ^ ((lsr >> 17) & 1);
lsr = lsr << 1;
lsr = lsr | (in[i] & 1);
}
// Tell runtime system how many output items we produced.
return i;
}
Now I want to use the GNU Radio descrambler block. From
this link, I calculated the descrambling parameters as follows : Mask - 0x0210001 ; seed - 0x00; length - 24.
Unfortunately, it is not working as its counterpart in the code shown above. Could someone provide guidance as to why this is not working?
Upvotes: 3
Views: 3056
Reputation: 550
Sorry for a late update on the answer. The explanation below will clear everything up
The GNU Radio block Descrambler implements a multiplicative descrambler of a given mask, seed and
length. The mask can be calculated from the scrambling polynomial. In GNU Radio, the polynomial has
to be written in little-endian bit order before the mask is calculated. For the polynomial above, p(x) = x^17 + x^12 + 1
, the mask is calculated by arranging the coefficients of lower powers first i.e. coef(x^1), coef(X^2) ... coef(x^17) for p(x) above
. This is shown below:
mask = 0000 0000 0010 0001 = 0x0021
.
From the source code of this block, it can be deduced that length in this context is the number of bits a shift register needs to shift when a new bit is being inserted. Therefore, length can be calculated as
length = deg (p (x)) − 1
which is, for our case, 17 - 1 = 16.
Upvotes: 5