A µTP (Micro/uTorrent Transport Library) library implemented in Rust
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2017-05-07 12:49:41 +01:00
benches Fix Packet benchmarks 2016-09-03 18:37:31 +01:00
examples Expunge all instances of unwrap in examples 2015-10-25 12:22:16 +00:00
src Force PacketHeader's representation to be predictable 2016-12-30 23:18:25 +00:00
tests Check thread status on tests 2015-10-26 15:30:07 +00:00
.gitignore Update gitignore. 2014-08-09 15:37:12 +01:00
.travis.yml Add compiler flag to improve coverage accuracy 2016-09-07 21:35:13 +01:00
appveyor.yml Add appveyor configuration file. 2015-05-17 10:27:27 +01:00
Cargo.toml (cargo-release) start next development iteration 0.7.1-pre 2017-05-07 12:49:41 +01:00
CHANGELOG.md Bump version to 0.6.3 2015-10-23 10:23:03 +01:00
COPYRIGHT Add licensing terms (MIT + Apache). 2014-07-23 16:13:29 +01:00
LICENSE-APACHE Add licensing terms (MIT + Apache). 2014-07-23 16:13:29 +01:00
LICENSE-MIT Add licensing terms (MIT + Apache). 2014-07-23 16:13:29 +01:00
README.md Replace coveralls badge with codecov 2016-08-17 22:09:30 +01:00

rust-utp

Crate Version Build Status Windows Build Status codecov Dependency Status

A Micro Transport Protocol library implemented in Rust.

API documentation

Overview

The Micro Transport Protocol is a reliable transport protocol built over UDP. Its congestion control algorithm is LEDBAT, which tries to use as much unused bandwidth as it can but readily yields to competing flows, making it useful for bulk transfers without introducing congestion in the network.

The current implementation is somewhat incomplete, lacking a complete implementation of congestion control. However, it does support packet loss detection (except by timeout) the Selective Acknowledgment extension, handles unordered and duplicate packets and presents a stream interface (UtpStream).

Usage

To use utp, add this to your Cargo.toml:

[dependencies]
utp = "*"

Then, import it in your crate root or wherever you need it:

extern crate utp;

Examples

The simplest example program would be:

extern crate utp;

use utp::UtpStream;
use std::io::Write;

fn main() {
    // Connect to an hypothetical local server running on port 8080
    let addr = "127.0.0.1:8080";
    let mut stream = UtpStream::connect(addr).expect("Error connecting to remote peer");

    // Send a string
    stream.write("Hi there!".as_bytes()).expect("Write failed");

    // Close the stream
    stream.close().expect("Error closing connection");
}

Check out the files under the "examples" directory for more example programs, or run them with cargo run --example <example_name>.

Roadmap

  • congestion control
  • proper connection closing
    • handle both RST and FIN
    • send FIN on close
    • automatically send FIN on drop if not already closed
  • sending RST on mismatch
  • setters and getters that hide header field endianness conversion
  • SACK extension
  • handle packet loss
    • send triple-ACK to re-request lost packet (fast resend request)
    • rewind send window and resend in reply to triple-ACK (fast resend)
    • resend packet on ACK timeout
  • stream interface
  • handle unordered packets
  • duplicate packet handling
  • listener abstraction
  • incoming connections iterator
  • time out connection after too many retransmissions
  • path MTU discovery

License

This library is distributed under similar terms to Rust: dual licensed under the MIT license and the Apache license (version 2.0).

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.