Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward Error Correction #7

Open
wants to merge 62 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d8f64ef
reorder ipsec struct to fix compilation issues, change TSI in flute-t…
autumn-traveller Nov 24, 2022
05b0445
use switch cases for FEC type instead of if statements and added plac…
autumn-traveller Dec 1, 2022
85d63de
added FEC scheme as cli argument for transmitter and receiver demos
autumn-traveller Dec 1, 2022
79ab66c
added build script
SteezyE Dec 1, 2022
38e9310
simplified installation guide
SteezyE Dec 1, 2022
818aec4
fixed md5 calculation to no longer emit deprecated openssl warning
autumn-traveller Dec 1, 2022
dcb2085
document and cleanup calculate_md5() function
autumn-traveller Dec 1, 2022
75a5175
added freeRaptor submodule
SteezyE Dec 1, 2022
c96989b
modifying cmake and adding raptor fec files
SteezyE Dec 1, 2022
7fb4062
updated readme and .gitmodules for raptor submodule
autumn-traveller Dec 1, 2022
9b7bb6a
point submodule towards free raptor dev branch
autumn-traveller Dec 1, 2022
a014480
working on compiling/linking
SteezyE Dec 1, 2022
aa2d61c
fixed linking/compiling using build script
SteezyE Dec 1, 2022
0903042
cmakelists integration of freeRaptor
autumn-traveller Dec 1, 2022
df0cbb8
make raptor compiliation optional and define a RAPTOR_ENABLED macro
autumn-traveller Dec 1, 2022
f17fb91
add raptor submodule
SteezyE Dec 12, 2022
77f4725
add remote raptor repo to .gitmodules
SteezyE Dec 12, 2022
bdfc21e
changed submodule to fork of raptor lib
SteezyE Dec 12, 2022
c6a4eae
write donwloaded files to current directory, when building build in d…
autumn-traveller Dec 15, 2022
2428af1
flute-receiver: add cli argument for destination directory for downlo…
autumn-traveller Dec 15, 2022
cf834d0
handle invalid file paths properly, increment the correct ptr in enco…
autumn-traveller Dec 21, 2022
940afb9
abstract class definition for FEC object coding
autumn-traveller Dec 22, 2022
1d32734
fixed abstract definition so it compiles, and reintroduced FecOti str…
autumn-traveller Dec 22, 2022
5e8941b
integreate FecTransformer structure into fdt and file classes
autumn-traveller Dec 29, 2022
f046ebe
generation and parseing for raptor OTI, set codepoint in alc packets …
autumn-traveller Dec 29, 2022
a2d0b63
Switch freeRaptor to raptor
Etua Dec 30, 2022
909cc3c
use 256kB for target sub block size instead of 1MB
autumn-traveller Dec 30, 2022
f759caf
Added initial encoder implementation
Etua Jan 5, 2023
34df0b1
resolve merge conflict
SteezyE Jan 5, 2023
ab19d8a
fix merge conflict
SteezyE Jan 5, 2023
605f14f
resolve merge conflict
SteezyE Jan 5, 2023
04f24e2
remove old freeRaptor header
SteezyE Jan 5, 2023
e15daa2
cmake fix
SteezyE Jan 5, 2023
8accbbb
Check for nullptr in create_blocks
Etua Jan 5, 2023
088f3ba
Calculate bytes_read correctly
Etua Jan 5, 2023
27992b0
Replace TODOs
Etua Jan 5, 2023
d687102
Merge remote-tracking branch 'origin/raptor_integration' into raptor_…
Etua Jan 5, 2023
1421515
update submodule
autumn-traveller Jan 5, 2023
23689a2
dont calculate raptor parameters in partitioning() function, hardcode…
autumn-traveller Jan 5, 2023
39a6b64
finished raptor encoding + sending, removed compact no code subclass …
autumn-traveller Jan 5, 2023
6851b44
integrated raptor decoding functionality with libflute
SteezyE Jan 6, 2023
3087ddd
finish decoder, start SBN and ESI at 0, added process_symbol() functi…
autumn-traveller Jan 12, 2023
d1c7d7f
fixes for running receiver
autumn-traveller Jan 16, 2023
76da006
update raptor test.c
autumn-traveller Jan 17, 2023
5a6b7ab
fixed bad return in check_source_completion and allow fec transformre…
autumn-traveller Jan 17, 2023
9ddc9b3
simulate 1pcent packet loss during reception, but never on the FDT
autumn-traveller Jan 17, 2023
9f2f5e5
added github action to test the build process
autumn-traveller Jan 19, 2023
63d2e8d
use matrix of build and os options + fix compilation when raptor is d…
autumn-traveller Jan 19, 2023
8d27e4c
remove vim swap files
autumn-traveller Jan 19, 2023
71527ee
clean up build workflow
autumn-traveller Jan 19, 2023
1dee66a
fixed double free error
SteezyE Jan 20, 2023
b7a2f0c
option stop receiving after n files + minor fixes
autumn-traveller Jan 20, 2023
5abb85e
use mmap to read in files, dont simulate packet loss if there is no a…
autumn-traveller Jan 21, 2023
99082df
Fix error with accessing FDT under simulated packet loss
Etua Jan 24, 2023
1d9df0a
Free the Symbol data
Etua Jan 24, 2023
375f31a
Get rid of code-simulated paket loss
Etua Feb 10, 2023
efccec1
scripts for adding packet loss to loopback interface for testing
autumn-traveller Feb 10, 2023
4c07c03
deal with the last block case
autumn-traveller Feb 10, 2023
2db0561
calculate buffer offset correctly for multi block files + use delete[…
autumn-traveller Feb 11, 2023
730d3a2
only extract finished source blocks at the end of transmission
autumn-traveller Feb 12, 2023
28c034e
small fixes: memory deallocation in raptor and derived class destruct…
autumn-traveller Mar 8, 2023
5ddfac0
Small fixes + delete build.sh
autumn-traveller Jun 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build
on: [push]
jobs:
build:
strategy:
matrix:
build-type: [Release]
raptor: [ON, OFF]
os: [ubuntu-latest, ubuntu-22.04, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- name: check out repository code
uses: actions/checkout@v3
with:
submodules: recursive
- name: install dependencies
run: sudo apt install -y gcc ninja-build cmake libssl-dev libboost-all-dev libspdlog-dev libtinyxml2-dev libnl-3-dev pkg-config libconfig++-dev
- name: pre-cmake
run: cmake --version && mkdir ${{ github.workspace }}/build && echo `nproc` processing units available
- name: cmake
run: cmake -S ${{ github.workspace }} -B ${{ github.workspace }}/build -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} -DENABLE_RAPTOR=${{ matrix.raptor }}
- name: build
run: cd ${{ github.workspace }}/build && ninja -j`nproc`
- name: check for runtime linking errors in transmitter
run: ${{ github.workspace }}/build/examples/flute-transmitter --help
- name: check for runtime linking errors in receiver
run: ${{ github.workspace }}/build/examples/flute-receiver --help
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@

build/
.idea
cmake-build-debug/
cmake-build-debug/
html/
.vscode/
*.swp
flute_download_*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "raptor"]
path = raptor
url = https://github.com/SteezyE/raptor.git
49 changes: 37 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
cmake_minimum_required(VERSION 3.16)

project (libflute VERSION 0.11.0)
project (libflute VERSION 0.11.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_STANDARD_REQUIRED True)

set(CMAKE_CXX_FLAGS_DEBUG_INIT "-Wall -Wextra -Werror -g3")
set(CMAKE_C_FLAGS_DEBUG_INIT "-Wall -Wextra -Werror -g3")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-Wall -O3")
set(CMAKE_C_FLAGS_RELEASE_INIT "-Wall -O3")

find_package(Boost REQUIRED)
find_package(spdlog REQUIRED)
Expand All @@ -15,11 +19,14 @@ find_package(OpenSSL REQUIRED)
pkg_check_modules(TINYXML REQUIRED IMPORTED_TARGET tinyxml2)
pkg_check_modules(NETLINK REQUIRED IMPORTED_TARGET libnl-3.0)

option(ENABLE_RAPTOR "Enable support for Raptor FEC" ON)

add_subdirectory(examples)

include_directories(
"${PROJECT_BINARY_DIR}"
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/raptor

SYSTEM
${PROJECT_SOURCE_DIR}/utils
Expand All @@ -29,25 +36,44 @@ include_directories(

configure_file("include/Version.h.in" "Version.h")

link_directories(
)

set(CMAKE_CXX_CLANG_TIDY clang-tidy)

if(ENABLE_RAPTOR)
message(STATUS "Compiling raptor library for Raptor FEC support. To disable support build with -DENABLE_RAPTOR=OFF")
add_library(raptor STATIC)
target_sources(raptor
PRIVATE
raptor/bipartite.c raptor/decoder.c raptor/encoder.c raptor/galois.c raptor/gaussian.c raptor/pivoting.c raptor/random.c
PUBLIC
raptor/raptor.h
)
target_link_libraries(raptor LINK_PUBLIC m)
else()
message(STATUS "Skipping raptor library for Raptor FEC support. To enable support build with -DENABLE_RAPTOR=ON")
endif()

add_library(flute "")
target_sources(flute
PRIVATE
src/Receiver.cpp src/Transmitter.cpp src/AlcPacket.cpp src/File.cpp src/EncodingSymbol.cpp src/FileDeliveryTable.cpp src/IpSec.cpp
utils/base64.cpp
src/Receiver.cpp src/Transmitter.cpp src/AlcPacket.cpp src/File.cpp src/EncodingSymbol.cpp src/FileDeliveryTable.cpp src/IpSec.cpp utils/base64.cpp

PUBLIC
include/Receiver.h include/Transmitter.h include/File.h

)
target_include_directories(flute
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/include/
)
target_include_directories(flute PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/)

#add_library(flute src/Receiver.cpp src/Receiver.h src/AlcPacket.cpp src/File.cpp src/EncodingSymbol.cpp src/FileDeliveryTable.cpp)
if(ENABLE_RAPTOR)
add_compile_definitions(RAPTOR_ENABLED)
target_include_directories(flute PUBLIC ${CMAKE_CURRENT_LIST_DIR}/raptor/)
target_sources(flute
PRIVATE
src/RaptorFEC.cpp
PUBLIC
include/RaptorFEC.h
)
target_link_libraries(flute LINK_PUBLIC raptor)
endif()

target_link_libraries( flute
LINK_PUBLIC
Expand All @@ -58,4 +84,3 @@ target_link_libraries( flute
PkgConfig::TINYXML
PkgConfig::NETLINK
)

48 changes: 35 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,37 @@

## Installation guide

Installation of libflute consists of 3 simple steps:
Installation of libflute consists of 2 simple steps:
1. Getting the source code
2. Build setup
3. Building
2. Building

### Step 1: Getting the source code
````
cd ~
git clone https://github.com/5G-MAG/rt-libflute.git
````

### Step 2: Build setup
This repository uses git submodules so it must be cloned with the following command

````
cd libflute/
mkdir build && cd build
cmake -GNinja ..
git clone --recurse-submodules https://github.com/5G-MAG/rt-libflute.git
````

### Step 3: Building
If you had checked it out before the submodules were added or ran git clone withou the `--recurse-submodules` argument then initialise and update the submodules by running

```
git submodule update --init
```

### Step 2: Building
````
ninja
cd rt-libflute/
mkdir build
cd build
cmake ..
cmake --build .
````
(alternatively you can use the `build.sh` script to build in debug mode with raptor enabled)

Build options:

- "Enable Raptor": build with support for the raptor10-based forward error correction. On by default. Disable by passing the `-DENABLE_RAPTOR=OFF` option to cmake

## Usage

Expand Down Expand Up @@ -87,6 +96,19 @@ sudo setcap 'cap_net_admin=eip' ./flute-transmitter
sudo setcap 'cap_net_admin=eip' ./flute-receiver
````

### Optional: Forward Error Correction (FEC) for lossy environment

To use forward error correction to overcome packet loss during transmission add the option `-f 1` to the transmitter. The receiver needs no such option, just make sure that both of them were properly built/rebuilt with raptor enabled in the build options (this is the default).

To simulate packet loss over the loopback interface and test that FEC works, you can run the `setup_packet_loss_on_loopback` script, as root.

Then start a transmission as you usually would. Make sure to use the default ip address, since the script will reroute this to go through the loopback interface.

Finally revert the changes to your loopback interface and routing table with the `reset_loopback_settings` script.

## Documentation

Documentation of the source code can be found at: https://5g-mag.github.io/rt-libflute/

To generate it locally via doxygen run `doxygen` in the project root.
Then to view it open the local file `html/index.html` in a browser
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

rm -rf build
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -GNinja ..
ninja -j`nproc`
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ target_link_libraries( flute-transmitter
config++
flute
pthread
m
)
target_link_libraries( flute-receiver
LINK_PUBLIC
spdlog::spdlog
config++
flute
pthread
m
)
42 changes: 37 additions & 5 deletions examples/flute-receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Version.h"
#include "Receiver.h"
#include "File.h"
#include "flute_types.h"


using libconfig::Config;
Expand All @@ -52,6 +53,8 @@ static struct argp_option options[] = { // NOLINT
"Log verbosity: 0 = trace, 1 = debug, 2 = info, 3 = warn, 4 = error, 5 = "
"critical, 6 = none. Default: 2.",
0},
{"download-dir", 'd', "Download directory", 0 , "Directory in which to store downloaded files, defaults to the current directory otherwise", 0},
{"num-files", 'n', "Stop Receiving after n files", 0, "Stop the reception after n files have been received (default is to never stop)", 0},
{nullptr, 0, nullptr, 0, nullptr, 0}};

/**
Expand All @@ -64,6 +67,8 @@ struct ft_arguments {
const char *aes_key = {};
unsigned short mcast_port = 40085;
unsigned log_level = 2; /**< log level */
char *download_dir = nullptr;
unsigned nfiles = 0; /**< log level */
char **files;
};

Expand All @@ -89,6 +94,12 @@ static auto parse_opt(int key, char *arg, struct argp_state *state) -> error_t {
case 'l':
arguments->log_level = static_cast<unsigned>(strtoul(arg, nullptr, 10));
break;
case 'd':
arguments->download_dir = arg;
break;
case 'n':
arguments->nfiles = static_cast<unsigned>(strtoul(arg, nullptr, 10));
break;
default:
return ARGP_ERR_UNKNOWN;
}
Expand Down Expand Up @@ -155,18 +166,39 @@ auto main(int argc, char **argv) -> int {
}

receiver.register_completion_callback(
[](std::shared_ptr<LibFlute::File> file) { //NOLINT
[&](std::shared_ptr<LibFlute::File> file) { //NOLINT
spdlog::info("{} (TOI {}) has been received",
file->meta().content_location, file->meta().toi);
FILE* fd = fopen(file->meta().content_location.c_str(), "wb");
fwrite(file->buffer(), 1, file->length(), fd);
fclose(fd);
char *buf = (char*) calloc(256,1);
char *fname = (char*) strrchr(file->meta().content_location.c_str(),'/');
if(!fname){
fname = (char*) file->meta().content_location.c_str();
} else {
fname++;
}
if (arguments.download_dir) {
snprintf(buf,256,"%s/%s",arguments.download_dir, fname);
} else {
snprintf(buf,256,"flute_download_%d-%s",file->meta().toi, fname);
}
FILE* fd = fopen(buf, "wb");
if (fd) {
fwrite(file->buffer(), 1, file->length(), fd);
fclose(fd);
} else {
spdlog::error("Error opening file {} to store received object",buf);
}
free(buf);
if (file->meta().toi == arguments.nfiles) {
spdlog::warn("{} file(s) received. Stopping reception",arguments.nfiles);
receiver.stop();
}
});

// Start the IO service
io.run();
} catch (std::exception ex ) {
spdlog::error("Exiting on unhandled exception: %s", ex.what());
spdlog::error("Exiting on unhandled exception: {}", ex.what());
}

exit:
Expand Down
Loading