class decoder

Scope: kodo_slide

In header: #include <kodo_slide/decoder.hpp>

Brief description

Implementation of a complete Random Linear Network coding sliding window decoder.

Member functions (public)

uint64_t coefficient_vector_size () const
void generate (uint8_t * coefficients)
bool is_symbol_decoded (uint64_t index) const
uint64_t pop_back_symbol ()
uint64_t push_front_symbol (uint8_t * symbol)
uint64_t rank () const
void read_source_symbol (uint8_t * symbol, uint64_t index)
void read_symbol (uint8_t * symbol, uint8_t * coefficients)
void set_seed (uint64_t seed_value)
void set_trace_stdout ()
void set_window (uint64_t lower_bound, uint64_t symbols)
void set_zone_prefix (const std::string & zone_prefix)
uint64_t stream_lower_bound () const
uint64_t stream_symbols () const
uint64_t stream_upper_bound () const
uint64_t symbol_size () const
uint64_t symbols_decoded () const
uint64_t symbols_missing () const
uint64_t symbols_partially_decoded () const
uint64_t window_lower_bound () const
uint64_t window_symbols () const
uint64_t window_upper_bound () const

Description

To build a decoder use the kodo_slide::decoder_factory .

Member Function Description

uint64_t coefficient_vector_size ()

Returns:
The size of the coefficient vector in the current window in bytes. The number of coefficients is equal to the number of symbols in the window. The size in bits of each coefficients depends on the finite field chosen. A custom coding scheme can be implemented by generating the coding vector manually. Alternatively the built-in generator can be used. See decoder::set_seed (…) and decoder::generate (…).

void generate (uint8_t * coefficients)

Generate coding coefficients for the symbols in the coding window according to the specified seed (see decoder::set_seed (…)).

Parameter coefficients:
Buffer where the coding coefficients should be stored. This buffer must be decoder::coefficient_vector_size() large in bytes.

bool is_symbol_decoded (uint64_t index)

Parameter index:
Index of the symbol to check.
Returns:
True if the symbol is decoded (i.e. it corresponds to a source symbol), and otherwise false.

uint64_t pop_back_symbol ()

Remove the “oldest” symbol from the stream. Increments the decoder::stream_lower_bound() .

Returns:
The index of the symbol being removed

uint64_t push_front_symbol (uint8_t * symbol)

Adds a new symbol to the front of the decoder. Increments the number of symbols in the stream and increases the decoder::stream_upper_bound() .

Parameter symbol:
Pointer to the symbol. Note, the caller must ensure that the memory of the symbol remains valid as long as the symbol is included in the stream. The caller is responsible for freeing the memory if needed. Once the symbol is popped from the stream.
Returns:
The stream index of the symbol being added.

uint64_t rank ()

The rank of a decoder indicates how many symbols have been partially or fully decoded. This number is also equivalent to the number of pivot elements we have in the stream.

Returns:
The rank of the decoder

void read_source_symbol (uint8_t * symbol, uint64_t index)

Add a source symbol at the decoder. A source symbol is a unit of data originating from the source that has not been encoded. It is not necessary to call the decoder::set_window() function before reading a source symbol. However, the symbol must be within the stream i.e. the following conditions must hold:

uint8_t* data = "... some data ...";
uint64_t index = 32; // The index of the source symbol

assert(index >= decoder.stream_lower_bound());
assert(index < decoder.stream_upper_bound());
decoder.read_source_symbol(data, index);
Parameter symbol:
Buffer containing the source symbol’s data.
Parameter index:
The index of the source symbol in the stream

void read_symbol (uint8_t * symbol, uint8_t * coefficients)

Decodes a coded symbol according to the coding coefficients. Both buffers may be modified during this call. The reason for this is that the decoder will directly operate on the provided memory for performance reasons. Before calling this function you need to instruct the decoder how to map the coding coefficients to the stream. This is done using the decoder::set_window() function. When reading a coded symbol from the encoder, these are the typical operations performed:

  1. Read the seed and encoding window from the incoming packet
  2. Call the decoder::set_seed() and decoder::set_window() functions to update the state of the decoder.
  3. Call the decoder::generate() to generate the coding coefficients
  4. Pass the encoded symbol and the coding coefficients to the decoder::read_symbol() function.
Parameter symbol:
Buffer representing a coded symbol.
Parameter coefficients:
The coding coefficients used to create the encoded symbol

void set_seed (uint64_t seed_value)

Seed the internal random generator function. If using the same seed on the decoder and decoder the exact same set of coefficients will be generated.

Parameter seed_value:
A value for the seed.

void set_trace_stdout ()

Enables tracing in a stack. The output will be written to standard out.

void set_window (uint64_t lower_bound, uint64_t symbols)

The window represents the symbols which will be included in the next decoding. The window cannot exceed the bounds of the stream. Example: If window_lower_bound=4 and window_symbol=3 the following symbol indices will be included 4,5,6

Parameter lower_bound:
Sets the index of the oldest symbol in the window.
Parameter symbols:
Sets number of symbols within the window.

void set_zone_prefix (const std::string & zone_prefix)

Sets a zone prefix for the tracing output. The zone prefix will be appended to all the output. This makes it possible to have two stacks that both trace to standard out, but still differentiate the output.

Parameter zone_prefix:
The zone prefix to append to all tracing zones

uint64_t stream_lower_bound ()

Returns:
The index of the oldest symbol known by the decoder. This symbol may not be inside the window but can be included in the window if needed.

uint64_t stream_symbols ()

Returns:

The total number of symbols known at the decoder. The number of symbols in the decoding window MUST be less than or equal to this number. The total range of valid symbol indicies is

for (uint64_t i = 0; i < stream_symbols(); ++i)
{
    std::cout << i + stream_lower_bound() << "\n";
}

uint64_t stream_upper_bound ()

Returns:
The upper bound of the stream. The range of valid symbol indices goes from [ decoder::stream_lower_bound() , decoder::stream_upper_bound() ). Note the stream is a half-open interval. Going from decoder::stream_lower_bound() to decoder::stream_upper_bound() - 1.

uint64_t symbol_size ()

Returns:
The size of a symbol in the stream in bytes.

uint64_t symbols_decoded ()

Returns:
The number of decoded symbols in the stream.

uint64_t symbols_missing ()

Returns:
The number of missing symbols in the stream.

uint64_t symbols_partially_decoded ()

Returns:
The number of partially decoded symbols in the stream.

uint64_t window_lower_bound ()

Returns:
The index of the “oldest” symbol in the coding window.

uint64_t window_symbols ()

Returns:
The number of symbols currently in the coding window. The window must be within the bounds of the stream.

uint64_t window_upper_bound ()

Returns:
The upper bound of the window. The range of valid symbol indices goes from [ decoder::window_lower_bound() , decoder::window_upper_bound() ). Note the window is a half-open interval. Going from decoder::window_lower_bound() to decoder::window_upper_bound() - 1.