Scrambler: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(Added to description with connection to Descrambler block.)
(Added simple example for "Scrambler" and "Descrambler" blocks.)
 
Line 25: Line 25:
== Example Flowgraph ==
== Example Flowgraph ==


Insert description of flowgraph here, then show a screenshot of the flowgraph and the output if there is an interesting GUI. Currently we have no standard method of uploading the actual flowgraph to the wiki or git repo, unfortunately. The plan is to have an example flowgraph showing how the block might be used, for every block, and the flowgraphs will live in the git repo.
Here is a simple example flowgraph. This flowgraph uses a text file as a source. The text file consists of [https://en.wikipedia.org/wiki/ASCII ASCII] characters, meaning 8-bit characters.
 
[[File:ScramblerExampleFlowgraph.jpg|600px]]
 
When the flowgraph is running, the following time domain display shows the randomized bitstream.
 
[[File:ScramblerTimeDomainDisplay.png|600px]]
 
The receiver is a separate flowgraph, as follows:
 
[[File:DescramblerExampleFlowgraph.jpg|600px]]
 
The [[Descrambler]] flowgraph takes in the bitstream, derandomizes it, and sends it on. The [[Delay]] block, once accurately set, ensures that the follow-on block will align with the byte boundary such that the ASCII text will be readable.
 
[[File:DescramblerTimeDomainDisplay.png|600px]]
 
Once the delay is properly set, the terminal outputs the readable text:
 
[[File:NovelTextfromDescrambler.jpg|600px]]
 
== Python Function to Create Mask and Length from Polynomial Exponents ==


Here is a simple python-function to create the mask and length from the exponents of a polynomial:
Here is a simple python-function to create the mask and length from the exponents of a polynomial:

Latest revision as of 00:43, 26 July 2025


The Scrambler block is an implementation of a multiplicative scrambler. It takes an input bit stream and randomizes it using a linear feedback shift register (LFSR) where the feedback is fed into the LFSR itself.

Multiplicative-scrambler-7-stage-diagram.jpg

This is a block diagram of a 7-stage multiplicative scrambler with a LFSR with feedback taps (7,4).

This block works at the bit level. This means it works on the LSB only of the input data stream, i.e., on an "unpacked binary" stream, and produces the same format on its output.

This block is typically used for the transmit portion of a digital communication system, and works in conjunction with the Descrambler block. The Descrambler block, which is typically used in the receive system, will derandomize the output of the Scrambler block so long as they are each using the same Mask and Length. Further, because of the fundamental nature of multiplicative scramblers, the Descrambler block will self-synchronize with the randomized bitstream coming from the Scrambler block.

Parameters

Mask
Polynomial mask for LFSR. To calculate the required mask, reverse the order of the desired polynomial. For example, a maximal-length 7-stage LFSR could use taps (7,4). A mask for this implementation would be the binary value 0b001001, or in hex 0x9. A 5-stage LFSR with taps (5,3) would be 0b00101, or in hex 0x5.
Seed
Initial shift register contents. This is the fill condition of the LFSR.
Length
Shift register length. Must be <=63, meaning that the maximum polynomial is 64. The value of the Length is one less than the polynomial size. For example, a 7-stage LFSR also means a polynomial size of 7. The Length for this block would be 6.

Example Flowgraph

Here is a simple example flowgraph. This flowgraph uses a text file as a source. The text file consists of ASCII characters, meaning 8-bit characters.

ScramblerExampleFlowgraph.jpg

When the flowgraph is running, the following time domain display shows the randomized bitstream.

ScramblerTimeDomainDisplay.png

The receiver is a separate flowgraph, as follows:

DescramblerExampleFlowgraph.jpg

The Descrambler flowgraph takes in the bitstream, derandomizes it, and sends it on. The Delay block, once accurately set, ensures that the follow-on block will align with the byte boundary such that the ASCII text will be readable.

DescramblerTimeDomainDisplay.png

Once the delay is properly set, the terminal outputs the readable text:

NovelTextfromDescrambler.jpg

Python Function to Create Mask and Length from Polynomial Exponents

Here is a simple python-function to create the mask and length from the exponents of a polynomial:

 def make_mask(*exp):
     from functools import reduce
     return reduce(int.__xor__,map(lambda x:2**x,exp)),max(exp)-1
 mask,k = make_mask(5,3,0) # mask and length for p(x) = x^5 + x^3 + 1, a primitive polynomial in GF(2)

Source Files

C++ files
TODO
Header files
TODO
Public header files
TODO
Block definition
TODO