# Scrambler Mask, Seed and Lenght

**URL:** <https://www.ruby-forum.com/t/scrambler-mask-seed-and-lenght/241952>\
**Category:** GNU Radio\
**Created:** [May 15, 2015, 8:26am UTC](https://www.ruby-forum.com/t/scrambler-mask-seed-and-lenght/241952 "2015-05-15T08:26:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 15, 2015, 8:26am UTC](https://www.ruby-forum.com/t/scrambler-mask-seed-and-lenght/241952/1 "2015-05-15T08:26:02Z")

</div>

Hi,

the default values for the parameters of the scrambler block are the  
following:  
Mask: 0x8A  
Seed: 0x7F  
length:7

Is this a 7-bit scrambler? If yes, why the mask corresponds to an 8-bit  
number? (0x8A = ‘10001010’)  
What is the polynomial that corresponds to this mask?  
According to this link (which I found as reference):  
[http://wiki.spench.net/wiki/GNU\_Radio\_Notes#GLFSR\_Source](http://wiki.spench.net/wiki/GNU_Radio_Notes#GLFSR_Source)

the mask 0x8A is related with the polynomial x^8+x^4+x^2+1

Is that correct? Do I miss something or is there an error on default  
values?

Thank you!

---

<div class="post-metadata">

**Author:** ![Thanasis\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ea924/32.png) [@Thanasis\_B](https://www.ruby-forum.com/u/Thanasis_B)\
**Post date:** [May 15, 2015, 2:29pm UTC](https://www.ruby-forum.com/t/scrambler-mask-seed-and-lenght/241952/2 "2015-05-15T14:29:24Z")

</div>

On Fri, May 15, 2015 at 1:32 AM, Marcus Müller  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> So, yes, I think I agree, and length should at least be 8 here (your  
> polynomial has degree 7), and it’s a bit uncommon to see a LFSR being used  
> without the x^0 coefficient.

Agree. This was a poor implementation decision by someone who clearly  
didn’t know what he was doing at the time 🙂

I’ve been wanting to fix this for a long time; looks like 3.8 would be a  
good chance to break this properly.

---

<div class="post-metadata">

**Author:** ![Thanasis\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ea924/32.png) [@Thanasis\_B](https://www.ruby-forum.com/u/Thanasis_B)\
**Post date:** [May 15, 2015, 10:38am UTC](https://www.ruby-forum.com/t/scrambler-mask-seed-and-lenght/241952/3 "2015-05-15T10:38:38Z")

</div>

HI Thanasis,  
first things first: That is gr::digital::scrambler\_bb, which has doxygen  
documentation [1].  
The length is really just the length of the underlying shift register –  
which ought to be at least (order of generator poly)+1, ie.  
floor(log2(mask))+1  
I recommend having a quick glance at its source code [2], revealing that  
it’s actually but a block wrapper around gr::digital::lfsr[3].  
If I read lfsr’s code correctly, you’re right, the highest bit of the  
mask will always be ignored, because it [4] will always be ANDed with a  
0:  
unsigned char newbit = (popCount( d\_shift\_register & d\_mask  
)%2)^(input & 1);  
since d\_shift\_register never sees the 8th bit being set:  
d\_shift\_register = ((d\_shift\_register\>\>1) |  
(newbit\<\<d\_shift\_register\_length));

So, yes, I think I agree, and length should at least be 8 here (your  
polynomial has degree 7), and it’s a bit uncommon to see a LFSR being  
used without the x^0 coefficient.

Best regards,  
Marcus

[1]  
[http://gnuradio.org/doc/doxygen/classgr\_1\_1digital\_1\_1scrambler\_\_bb.html#details](http://gnuradio.org/doc/doxygen/classgr_1_1digital_1_1scrambler__bb.html#details)  
[2]

> <https://github.com/gnuradio/gnuradio/blob/master/gr-digital/lib/scrambler_bb_impl.cc>

[3] [GNU Radio Manual and C++ API Reference: gr::digital::lfsr Class Reference](http://gnuradio.org/doc/doxygen/classgr_1_1digital_1_1lfsr.html)  
[4]  
[gnuradio/gr-digital/include/gnuradio/digital/lfsr.h at master · gnuradio/gnuradio · GitHub](https://github.com/gnuradio/gnuradio/blob/master/gr-digital/include/gnuradio/digital/lfsr.h#L128)

---

<div class="post-metadata">

**Author:** ![Thanasis\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/7ea924/32.png) [@Thanasis\_B](https://www.ruby-forum.com/u/Thanasis_B)\
**Post date:** [May 15, 2015, 3:20pm UTC](https://www.ruby-forum.com/t/scrambler-mask-seed-and-lenght/241952/4 "2015-05-15T15:20:49Z")

</div>

ok until 3.8 how can I use this block without making mistakes?

If for example want the following polynomials (copy from [1])

```
               x^4 + x^3 + x^0 = 0x19
               x^5 + x^3 + x^0 = 0x29
               x^6 + x^5 + x^0 = 0x61

```

do I have to set the length to 5,6,7 respectively?

[1]

> <https://github.com/gnuradio/gnuradio/blob/master/gr-digital/include/gnuradio/digital/lfsr.h#L50-L52>

2015-05-15 15:28 GMT+03:00 Johnathan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
