# Scrambling

Scrambling as a channel coding step masks transmitted bits by a pseudo-random sequence known at both receiver and transmitter in order to prevent long sequences of identical bits. Therefore, most scrambling coding operations do not introduce redundancy to the scrambled bit blocks, i.e. the code rate is usually $$R = 1$$.

class PseudoRandomGenerator(init_sequence, offset=1600)

Bases: object

A generator for pseudo-random bit sequences.

Generators with identical initialization will output identical random sequences. Implements pseudo-random generator as described in the 3GPP standard for Physical Channels and Modulation1.

Parameters
• init_sequence (np.ndarray) – A sequence of 31 bits initializing the generator.

• offset (int) – Gold sequence parameter controlling the sequence offset.

generate()

Generate the next bit within the pseudo-random sequence.

Returns

The generated bit.

Return type

int

generate_sequence(length)

Generate a new sequence of random numbers.

Parameters

length (int) – Length of the sequence to be generated.

Returns

A numpy array of dimension length containing a sequence of pseudo-random bits.

Return type

np.array

reset()

Resets the gernator to its default state.

This implies reverting the queues back to their original state (at rng position n = 0).

Return type

None

class Scrambler3GPP(seed=None)

Scrambler channel coding in the physical up- and down-link standard of the 3GPP.

See section 7.3.1.1 of the respective technical standard Physical Channels and Modulation1 for details.

Parameters

seed (np.ndarray, optional) – Seed used to initialize the scrambling sequence generation. Must contain a sequence of bits.

yaml_tag: str = 'SCRAMBLER_3GPP'

YAML serialization tag.

encode(data)

Encodes a single block of bits.

Bit encoding routine during data transmission, encoding a block of $$K_n$$ input bits into a block of $$L_n$$ code bits.

Parameters

bits (np.ndarray) – A numpy vector of $$K_n$$ bits, representing a single bit block to be encoded.

Returns

A numpy vector of $$L_n$$ bits, representing a single code block.

Return type

np.ndarray

Raises

ValueError – If the length of bits does not equal bit_block_size().

decode(code)

Decodes a single block of bits.

Bit decoding routine during data reception, decoding a block of $$L_n$$ code bits into a block of $$K_n$$ data bits.

Parameters

encoded_bits (np.ndarray) – A numpy vector of $$L_n$$ code bits, representing a single code block to be decoded.

Returns

A numpy vector of $$K_n$$ bits, representing a single data block.

Return type

np.ndarray

Raises

ValueError – If the length of encoded_bits does not equal code_block_size().

property bit_block_size: int

Data bit block size of a single coding operation.

In other words, the number of input bits within a single code block during transmit encoding, or the number of output bits during receive decoding. Referred to as $$K_n$$ within the respective equations.

Returns

Number of bits $$K_n$$.

Return type

int

property code_block_size: int

Code bit block size of a single coding operation.

In other words, the number of input bits within a single code block during receive decoding, or the number of output bits during transmit encoding. Referred to as $$L_n$$ within the respective equations.

Returns

Number of bits $$L_n$$.

Return type

int

class Scrambler80211a(seed=None)

Scrambler channel coding in the the 802.11a standard.

Refer to section 17.3.5.4 of IEEE2 for further details.

Parameters

seed (np.ndarray, optional) – Seed used to initialize the scrambling sequence generation. Must contain a sequence of 7 bits.

yaml_tag: str = 'SCRAMBLER_80211A'

YAML serialization tag.

property seed: numpy.array

Random sequence generator seed.

Resets the internal register queue used to generate the scrambling sequence.

Returns

Numpy vector containing the generator seed. Must be an array of dimension 7 containing only soft bits.

Return type

np.ndarray

Raises

ValueError – If seed does not contain exactly 7 bits.

encode(data)

Encodes a single block of bits.

Bit encoding routine during data transmission, encoding a block of $$K_n$$ input bits into a block of $$L_n$$ code bits.

Parameters

bits (np.ndarray) – A numpy vector of $$K_n$$ bits, representing a single bit block to be encoded.

Returns

A numpy vector of $$L_n$$ bits, representing a single code block.

Return type

np.ndarray

Raises

ValueError – If the length of bits does not equal bit_block_size().

decode(code)

Decodes a single block of bits.

Bit decoding routine during data reception, decoding a block of $$L_n$$ code bits into a block of $$K_n$$ data bits.

Parameters

encoded_bits (np.ndarray) – A numpy vector of $$L_n$$ code bits, representing a single code block to be decoded.

Returns

A numpy vector of $$K_n$$ bits, representing a single data block.

Return type

np.ndarray

Raises

ValueError – If the length of encoded_bits does not equal code_block_size().

property bit_block_size: int

Data bit block size of a single coding operation.

In other words, the number of input bits within a single code block during transmit encoding, or the number of output bits during receive decoding. Referred to as $$K_n$$ within the respective equations.

Returns

Number of bits $$K_n$$.

Return type

int

property code_block_size: int

Code bit block size of a single coding operation.

In other words, the number of input bits within a single code block during receive decoding, or the number of output bits during transmit encoding. Referred to as $$L_n$$ within the respective equations.

Returns

Number of bits $$L_n$$.

Return type

int

1(1,2)

Physical Channels and Modulation. ETSI, 07 2018. Version 15.2.0 Release 15. URL: https://www.etsi.org/deliver/etsi_ts/138200_138299/138211/15.02.00_60/ts_138211v150200p.pdf.

2

IEEE. IEEE standard for telecommunications and information exchange between systems - LAN/MAN specific requirements - Part 11: wireless medium access control (MAC) and physical layer (PHY) specifications: high speed physical layer in the 5 GHz band. IEEE Std 802.11a-1999, 1999. doi:10.1109/IEEESTD.1999.90606.