Skip to main content

File Delivery over Unidirectional Transport (FLUTE)

Project description

Rust Python Docs.rs Crates.io Rust Dependency codecov

FLUTE - File Delivery over Unidirectional Transport

Massively scalable multicast distribution solution

The library implements a unidirectional file delivery, without the need of a return channel.

RFC

This library implements the following RFCs

RFC Title Link
RFC 6726 FLUTE - File Delivery over Unidirectional Transport https://www.rfc-editor.org/rfc/rfc6726.html
RFC 5775 Asynchronous Layered Coding (ALC) Protocol Instantiation https://www.rfc-editor.org/rfc/rfc5775.html
RFC 5661 Layered Coding Transport (LCT) Building Block https://www.rfc-editor.org/rfc/rfc5651
RFC 5052 Forward Error Correction (FEC) Building Block https://www.rfc-editor.org/rfc/rfc5052
RFC 5510 Reed-Solomon Forward Error Correction (FEC) Schemes https://www.rfc-editor.org/rfc/rfc5510.html
3GPP TS 26.346 Extended FLUTE FDT Schema (7.2.10) https://www.etsi.org/deliver/etsi_ts/126300_126399/126346/17.03.00_60/ts_126346v170300p.pdf

UDP/IP Multicast files sender

Transfer files over a UDP/IP network

use flute::sender::Sender;
use flute::sender::ObjectDesc;
use flute::sender::Cenc;
use flute::core::UDPEndpoint;
use std::net::UdpSocket;
use std::time::SystemTime;

// Create UDP Socket
let udp_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
udp_socket.connect("224.0.0.1:3400").expect("Connection failed");

// Create FLUTE Sender
let tsi = 1;
let oti = Default::default();
let config = Default::default();
let endpoint = UDPEndpoint::new(None, "224.0.0.1".to_string(), 3400);
let mut sender = Sender::new(endpoint, tsi, &oti, &config);

// Add object(s) (files) to the FLUTE sender (priority queue 0)
let obj = ObjectDesc::create_from_buffer(b"hello world", "text/plain",
&url::Url::parse("file:///hello.txt").unwrap(), 1, None, None, None, Cenc::Null, true, None, true).unwrap();
sender.add_object(0, obj);

// Always call publish after adding objects
sender.publish(SystemTime::now());

// Send FLUTE packets over UDP/IP
while let Some(pkt) = sender.read(SystemTime::now()) {
    udp_socket.send(&pkt).unwrap();
    std::thread::sleep(std::time::Duration::from_millis(1));
}

UDP/IP Multicast files receiver

Receive files from a UDP/IP network

use flute::receiver::{writer, MultiReceiver};
use flute::core::UDPEndpoint;
use std::net::UdpSocket;
use std::time::SystemTime;
use std::rc::Rc;

// Create UDP/IP socket to receive FLUTE pkt
let endpoint = UDPEndpoint::new(None, "224.0.0.1".to_string(), 3400);
let udp_socket = UdpSocket::bind(format!("{}:{}", endpoint.destination_group_address, endpoint.port)).expect("Fail to bind");

// Create a writer able to write received files to the filesystem
let writer = Rc::new(writer::ObjectWriterFSBuilder::new(&std::path::Path::new("./flute_dir"))
    .unwrap_or_else(|_| std::process::exit(0)));

// Create a multi-receiver capable of de-multiplexing several FLUTE sessions
let mut receiver = MultiReceiver::new(writer, None, false);

// Receive pkt from UDP/IP socket and push it to the FLUTE receiver
let mut buf = [0; 2048];
loop {
    let (n, _src) = udp_socket.recv_from(&mut buf).expect("Failed to receive data");
    let now = SystemTime::now();
    receiver.push(&endpoint, &buf[..n], now).unwrap();
    receiver.cleanup(now);
}

Application-Level Forward Erasure Correction (AL-FEC)

The following error recovery algorithms are supported

  • No-code
  • Reed-Solomon GF 2^8
  • Reed-Solomon GF 2^8 Under Specified
  • Reed-Solomon GF 2^16
  • Reed-Solomon GF 2^m
  • RaptorQ
  • Raptor

The Oti module provides an implementation of the Object Transmission Information (OTI) used to configure Forward Error Correction (FEC) encoding in the FLUTE protocol.

use flute::sender::Oti;
use flute::sender::Sender;
use flute::core::UDPEndpoint;

// Reed Solomon 2^8 with encoding blocks composed of
// 60 source symbols and 4 repair symbols of 1424 bytes per symbol
let endpoint = UDPEndpoint::new(None, "224.0.0.1".to_string(), 3400);
let oti = Oti::new_reed_solomon_rs28(1424, 60, 4).unwrap();
let mut sender = Sender::new(endpoint, 1, &oti, &Default::default());

Content Encoding (CENC)

The following schemes are supported during the transmission/reception

  • Null (no compression)
  • Deflate
  • Zlib
  • Gzip

Files multiplex / Blocks interleave

The FLUTE Sender is able to transfer multiple files in parallel by interleaving packets from each file. For example:

Pkt file1 -> Pkt file2 -> Pkt file3 -> Pkt file1 -> Pkt file2 -> Pkt file3 ...

The Sender can interleave blocks within a single file. The following example shows Encoding Symbols (ES) from different blocks (B) are interleaved. For example:

(B 1,ES 1)->(B 2,ES 1)->(B 3,ES 1)->(B 1,ES 2)->(B 2,ES 2)...

To configure the multiplexing, use the Config struct as follows:

use flute::sender::Sender;
use flute::sender::Config;
use flute::sender::PriorityQueue;
use flute::core::UDPEndpoint;

let mut config = Config {
    // Interleave a maximum of 3 blocks within each file
    interleave_blocks: 3,
    ..Default::default()
};

// Interleave a maximum of 3 files in priority queue '0'
config.set_priority_queue(PriorityQueue::HIGHEST, PriorityQueue::new(3));

let endpoint = UDPEndpoint::new(None, "224.0.0.1".to_string(), 3400);
let mut sender = Sender::new(endpoint, 1, &Default::default(), &config);

Priority Queues

FLUTE sender can be configured with multiple queues, each having a different priority level. Files in higher priority queues are always transferred before files in lower priority queues. Transfer of files in lower priority queues is paused while there are files to be transferred in higher priority queues.

use flute::sender::Sender;
use flute::sender::Config;
use flute::sender::PriorityQueue;
use flute::core::UDPEndpoint;
use flute::sender::ObjectDesc;
use flute::sender::Cenc;

// Create a default configuration
let mut config: flute::sender::Config = Default::default();

// Configure the HIGHEST priority queue with a capacity of 3 simultaneous file transfer
config.set_priority_queue(PriorityQueue::HIGHEST, PriorityQueue::new(3));

// Configure the LOW priority queue with a capacity of 1 file transfer at a time
config.set_priority_queue(PriorityQueue::LOW, PriorityQueue::new(1));

let endpoint = UDPEndpoint::new(None, "224.0.0.1".to_string(), 3400);
let mut sender = Sender::new(endpoint, 1, &Default::default(), &config);

// Create an ObjectDesc for a low priority file
let low_priority_obj = ObjectDesc::create_from_buffer(b"low priority", "text/plain",
&url::Url::parse("file:///low_priority.txt").unwrap(), 1, None, None, None, Cenc::Null, true, None, true).unwrap();

// Create an ObjectDesc for a high priority file
let high_priority_obj = ObjectDesc::create_from_buffer(b"high priority", "text/plain",
&url::Url::parse("file:///high_priority.txt").unwrap(), 1, None, None, None, Cenc::Null, true, None, true).unwrap();

// Put Object to the low priority queue
sender.add_object(PriorityQueue::LOW, low_priority_obj);

// Put Object to the high priority queue
sender.add_object(PriorityQueue::HIGHEST, high_priority_obj);

Python bindings

PyPI version

Installation

pip install flute-alc

Example

Flute Sender python example

    from flute import sender

    # Flute Sender config parameters
    sender_config = sender.Config()

    # Object transmission parameters (no_code => no FEC)
    # encoding symbol size : 1400 bytes
    # Max source block length : 64 encoding symbols
    oti = sender.Oti.new_no_code(1400, 64)

    # Create FLUTE Sender
    flute_sender = sender.Sender(1, oti, sender_config)

    # Transfer a file 
    flute_sender.add_file("/path/to/file", 0, "application/octet-stream", None, None)
    flute_sender.publish()

    while True:
        alc_pkt = flute_sender.read()
        if alc_pkt == None:
            break

        #TODO Send alc_pkt over UDP/IP

Flute Receiver python example

    from flute import receiver

    # Write received objects to a destination folder
    receiver_writer = receiver.ObjectWriterBuilder("/path/to/dest")

    # FLUTE Receiver configuration parameters
    receiver_config = receiver.Config()

    tsi = 1

    # Create a FLUTE receiver with the specified endpoint, tsi, writer, and configuration
    udp_endpoint = receiver.UDPEndpoint("224.0.0.1", 1234)
    flute_receiver = receiver.Receiver(udp_endpoint, tsi, receiver_writer, receiver_config)

    while True:
        # Receive LCT/ALC packet from UDP/IP multicast (Implement your own receive_from_udp_socket() function)
        # Note: FLUTE does not handle the UDP/IP layer, you need to implement the socket reception mechanism yourself
        pkt = receive_from_udp_socket()

        # Push the received packet to the FLUTE receiver
        flute_receiver.push(bytes(pkt))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

flute_alc-1.3.3-pp39-pypy39_pp73-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded PyPy manylinux: glibc 2.34+ x86-64

flute_alc-1.3.3-pp38-pypy38_pp73-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded PyPy manylinux: glibc 2.34+ x86-64

flute_alc-1.3.3-cp311-cp311-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.34+ x86-64

flute_alc-1.3.3-cp310-cp310-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

flute_alc-1.3.3-cp39-cp39-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.34+ x86-64

flute_alc-1.3.3-cp38-cp38-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.34+ x86-64

flute_alc-1.3.3-cp37-cp37m-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.34+ x86-64

File details

Details for the file flute_alc-1.3.3-pp39-pypy39_pp73-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for flute_alc-1.3.3-pp39-pypy39_pp73-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4ecbb4fb4acb482d861990da3063a3ee870220b7a7fc22b63af6a5f78bf15b6a
MD5 bdb5cbdd790ada66e301f768c2e57e0e
BLAKE2b-256 62d8fa6ec2754e33e557a113f6d5ab2b7a229827f99cdb5f3e8420727609c75b

See more details on using hashes here.

File details

Details for the file flute_alc-1.3.3-pp38-pypy38_pp73-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for flute_alc-1.3.3-pp38-pypy38_pp73-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6d98d44af6448037cc21a2cb7f1fbfe7d20e45278ae36faad8618ca1ab8b564a
MD5 5f2e084b77e1850247edce5d2ca941e3
BLAKE2b-256 6561874a58a619b1c2947e4d2511828bacc95a37674c02d1e1a16eae653b3a94

See more details on using hashes here.

File details

Details for the file flute_alc-1.3.3-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for flute_alc-1.3.3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e3b77288dcb2d3d033e347abd59f6e49a04ea95f03ab33bce5b4b8aa0f8a5f01
MD5 335e491dcb31a49e55eb7a526983fc2f
BLAKE2b-256 bf89a340bf9ebbe7fd6e21157db3d5763af879e87b55429e8947425f6e31f0e3

See more details on using hashes here.

File details

Details for the file flute_alc-1.3.3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for flute_alc-1.3.3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 35da7dcd8b5108c823c7d239b010ebf34daff881ec81beb7dab8ee417c4fb00c
MD5 66f3bb31e9e9613577aba184f4fbe7d5
BLAKE2b-256 67c72889a499a7c18db796e14fd0e3da7d8d84b734f931cad265dc92c505d95f

See more details on using hashes here.

File details

Details for the file flute_alc-1.3.3-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for flute_alc-1.3.3-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 36b7080fd2d3ddcb2beaa339b71d1a25f43707e50f55c8dc490883d659304789
MD5 f65433c27f1ab0e59bfa814104f6b302
BLAKE2b-256 1406a1309a4e0d8c593c73e78ebd8c87ac5cea03aa63fe464059a233d4e86de6

See more details on using hashes here.

File details

Details for the file flute_alc-1.3.3-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for flute_alc-1.3.3-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 fcaf2f3bbffce6fe90d74623467d8237aa6221bb138b7bb253c7dc2e52ba2e52
MD5 e1068ffb03e828baef168ee55524a5bb
BLAKE2b-256 90d82efaa42f6aac13823b2fdf7401355a3345d166c053dc3bbdba7442684289

See more details on using hashes here.

File details

Details for the file flute_alc-1.3.3-cp37-cp37m-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for flute_alc-1.3.3-cp37-cp37m-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a25e26849bfa148f7d11e9ede9760a5311dea229d20ffbb2c16c77208e5cec8d
MD5 8dd61aa972d15a9fde58fb9e65db05fa
BLAKE2b-256 2d1f030dcea8a941a9d3537db8656e166e1accc86d6d724742d563368ac14d08

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page