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)[source]

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 Modulation[1].

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

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

generate()[source]

Generate the next bit within the pseudo-random sequence.

Returns:

The generated bit.

Return type:

int

generate_sequence(length)[source]

Generate a new sequence of random numbers.

Parameters:

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

Return type:

ndarray

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

reset()[source]

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)[source]

Bases: Encoder, Serializable

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 Modulation[1] for details.

Parameters:

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

decode(code)[source]

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().

encode(data)[source]

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().

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\).

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\).

yaml_tag: str = 'SCRAMBLER_3GPP'

YAML serialization tag.

class Scrambler80211a(seed=None)[source]

Bases: Encoder, Serializable

Scrambler channel coding in the the 802.11a standard.

Refer to section 17.3.5.4 of IEEE[2] for further details.

Parameters:

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

decode(code)[source]

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().

encode(data)[source]

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().

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\).

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\).

property seed: ndarray

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.

yaml_tag: str = 'SCRAMBLER_80211A'

YAML serialization tag.