Permalink
Browse files

docs

  • Loading branch information...
chris-gc committed Jan 19, 2014
1 parent 1236980 commit 46f1e61c0ff742f08b533420352bd456da6851b4
Showing with 28 additions and 12 deletions.
  1. +22 −10 README.md
  2. +6 −2 include/wirehair.h
View
@@ -59,7 +59,7 @@ starting from 0 and incremented by one each time:
~~~
char block[1300];
int ID = 0;
unsigned int ID = ...;
if (!wirehair_write(encoder, ID, block)) {
exit(1);
@@ -85,7 +85,7 @@ A decoder object should be created by providing the size of the message
and the number of bytes per block:
~~~
int bytes = 1000000;
int bytes = 1000000..;
int block_bytes = 1300;
wirehair_state decoder = 0;
@@ -107,21 +107,33 @@ To check how many blocks are in the message:
To decode a message one received block at a time:
~~~
char *message = new char[bytes];
int ID = 0;
unsigned int ID = ...;
// If there is a chance of decoding the message now,
// If reading is done,
if (wirehair_read(decoder, ID, block)) {
// If message can be reconstructed,
if (wirehair_reconstruct(decoder, message)) {
// Decoding message complete
char *message = new char[bytes];
}
// Decode message
wirehair_reconstruct(decoder, message);
}
~~~
Note that the `wirehair_reconstruct` function is used to produce the
decoded message. This is suitable for file transfer applications.
For packet error correction, a more suitable function is provided:
~~~
char block[1300];
unsigned int ID = ...;
wirehair_reconstruct_block(decoder, ID, block);
~~~
The [Shorthair project](https://github.com/catid/shorthair) is designed
to implement efficient variable-length packet error correction using
Wirehair on the backend.
Similar to the encoder, you may either free or reuse the decoder object
in the exact same way as the encoder.
View
@@ -119,7 +119,9 @@ extern int wirehair_read(wirehair_state E, unsigned int id, const void *block);
* Reconstruct the message after reading is complete.
*
* Preconditions:
* message contains enough space to store the entire decoded message
* message contains enough space to store the entire decoded message (bytes)
*
* May return 0 to indicate a failure.
*/
extern int wirehair_reconstruct(wirehair_state E, void *message);
@@ -130,7 +132,9 @@ extern int wirehair_reconstruct(wirehair_state E, void *message);
* rather than for file transfer.
*
* Preconditions:
* block ptr buffer contains enough space to hold the block
* block ptr buffer contains enough space to hold the block (block_bytes)
*
* May return 0 to indicate a failure.
*/
extern int wirehair_reconstruct_block(wirehair_state E, unsigned int id, void *block);

0 comments on commit 46f1e61

Please sign in to comment.