The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::OnlineCode::Decoder - Rateless Forward Error Correction Decoder

SYNOPSIS

use Net::OnlineCode::Decoder;
use strict;

# variables received from encoder:
my ($msg_id, $e, $q, $msg_size, $blocksize);

# calculated/local variables
my (@check_blocks,$message,$block_id);
my $mblocks = int(0.5 + ($msg_size / $blocksize));
my $rng     = Net::OnlineCode::RNG->new($msg_id);

my $decoder = Net::OnlineCode::Decoder->new(
  mblocks     => $mblocks,
  initial_rng => $rng,
  # ... pass e and q if they differ from defaults
);

my ($done,@decoded) = (0);
until ($done) {
  my ($block_id,$contents) = ...; # receive data from encoder
  push @check_blocks, $contents;

  $rng->seed($block_id);
  ($done,@decoded) = $decoder->accept_check_block($rng);

  # XOR check blocks together to decode each message block
  foreach my $decoded_block (@decoded) {
    my @xor_list = $decoder->xor_list($decoded_block);
    my $block = $check_blocks[shift @xor_list];
    fast_xor_strings(\$block, map { $check_blocks[$_] } @xor_list);

    # save contents of decoded block
    substr($message, $decoded_block * $blocksize, $blocksize) = $block;
  }
}
$message = substr($message, 0, $msg_size);  # truncate to correct size
print $message;                             # Done!

DESCRIPTION

This module implements the "decoder" side of the Online Code algorithm for rateless forward error correction. Refer to the the Net::OnlineCode documentation for the technical background

SEE ALSO

See Net::OnlineCode for background information on Online Codes.

This module is part of the GnetRAID project. For project development page, see:

https://sourceforge.net/projects/gnetraid/develop

AUTHOR

Declan Malone, <idablack@users.sourceforge.net>

COPYRIGHT AND LICENSE

Copyright (C) 2013 by Declan Malone

This package is free software; you can redistribute it and/or modify it under the terms of the "GNU General Public License" ("GPL").

The C code at the core of this Perl module can additionally be redistributed and/or modified under the terms of the "GNU Library General Public License" ("LGPL"). For the purpose of that license, the "library" is defined as the unmodified C code in the clib/ directory of this distribution. You are permitted to change the typedefs and function prototypes to match the word sizes on your machine, but any further modification (such as removing the static modifier for non-exported function or data structure names) are not permitted under the LGPL, so the library will revert to being covered by the full version of the GPL.

Please refer to the files "GNU_GPL.txt" and "GNU_LGPL.txt" in this distribution for details.

DISCLAIMER

This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the "GNU General Public License" for more details.