3

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?

  • Could you please add a suitable name for your link? Also "third party": Where is it from? It follows a very unusual naming scheme: `_cc` means "complex in, complex out", and what you have there is "byte in, byte out", which would be called `_bb`. – Marcus Müller May 13 '16 at 14:29
  • Also, explain how you came up with the length and with the coefficients. Are these parameters sepcified externally, or are you reading them from the source code? – Marcus Müller May 13 '16 at 15:05
  • Also, no way your mask is correct; shifting a bit by 17 places wouldn't move it more than three bytes. – Marcus Müller May 13 '16 at 15:19
  • Also, make sure your'e not misinterpreting the bit shifts in the existing source code; this LFSR is shifted left! GNU Radio's LFSR is shifted right. – Marcus Müller May 13 '16 at 15:21
  • I admit that the convention used should have been _bb rather than _cc. It was a mistake by the author. I calculated the mask by following examples in the link. i.e x^4 + x^3 + x^0 = 0x19 * x^5 + x^3 + x^0 = 0x29 * x^6 + x^5 + x^0 = 0x61 . I was assuming that since the mask is of order 17, you would need at least 3 bytes = 24 bits. The polynomial used is G3RUH/K9NG [(x^17 + x^12 + 1)] – Moses Browne Mwakyanjala May 13 '16 at 22:21
  • but `(1<<17)|(1<<12)|(1<<0) == 0x21001`, not `0x210001`! – Marcus Müller May 14 '16 at 00:40
  • Yes. You are right. the mask i used was actually 0x021001. Sorry for the typo. What parameters should i use to make my descrambler working? I mean the mask, seed and length? – Moses Browne Mwakyanjala May 14 '16 at 12:03
  • I went online and stumbled upon a post where someone was able to solve the problem by using Mask = 0x21, length = 16. I tried and it did actually work with the data coming from a cubesat. How is that possible? Also, I tried to run further tests. I decided to create a new flowgraph and put add a scrambler before the descrambler. Both the scrambler and descrambler uses the same parameters (mask,length and seed). The flowgraph was like this [file source -> throttle -> packed-to-unpacked -> scrambler -> descrambler ->unpacked-to-packed -> udp sink. Unfortunately, it didnt work this time. – Moses Browne Mwakyanjala May 14 '16 at 13:48
  • maybe the polynomial is *really* 0x21 ^= x⁵+1 ? – Marcus Müller May 14 '16 at 13:52
  • I checked again. In the post, the author said that the scrambler used is a multiplicative one with the polynomial x^17 + x^12 + 1. He said that he will explain how he obtained the value of the mask as 0x21 in the next post. So Im waiting for his explanation. I still have one unanswered question. I was trying to run an end-to-end test by reading data from a file ( HEX 41 41 41 41 - ascii AAAA string) and scramble is with the scrambler above. After descrambling, the output I get is [82 82 82 82]. I tried it with other characters as well and the output seem to be a multiple of 2 of the input. – Moses Browne Mwakyanjala May 15 '16 at 10:41
  • I was under the impression that scrambling and descrambling are inverse operations which means that the output obtained after passing through a scrambler and descrambler will be unchanged. Isnt that the case? – Moses Browne Mwakyanjala May 15 '16 at 10:44
  • Can you link to any of that? – Marcus Müller May 15 '16 at 11:08
  • re: 0x41 vs 0x82: `a*2 == (a << 1)`. you are off by one bit position. – Marcus Müller May 15 '16 at 11:09
  • I did use the "correlate access code" block and get a positive result. All is good now. Thanks. – Moses Browne Mwakyanjala May 15 '16 at 14:07

1 Answers1

5

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.

mban
  • 422
  • 1
  • 6
  • 19