5 releases

0.1.4 Apr 23, 2024
0.1.3 Apr 22, 2024
0.1.2 Apr 22, 2024
0.1.1 Apr 22, 2024
0.1.0 Apr 22, 2024

#1109 in Network programming

Download history 316/week @ 2024-04-22

316 downloads per month

Custom license

43KB
853 lines

mptcp-rs

A helper crate to create Multipath TCP (MPTCP) sockets.

Features

The crate currently supports:

  • std::net::TcpStream and std::net::TcpListener
  • support Linux
  • support tokio
  • support async-std
  • support MacOS (TcpStream only)

Usage

To create an MPTCP stream:

use mptcp::MptcpStreamExt;

let stream = TcpStream::connect_mptcp("www.google.com:443").unwrap();

The connect_mptcp method handles falling back to a TCP socket in case MPTCP is not available on the system. Use connect_mptcp_force if you require to use MPTCP.

To create an MPTCP listener:

use mptcp::MptcpListenerExt;

let listener = TcpListener::bind_mptcp("localhost:8080").unwrap();

Similarly to the Stream. The bind_mptcp method handles falling back to a TCP socket in case MPTCP is not available on the system. Use bind_mptcp_force if you require to use MPTCP.

Use the into_socket() to retrieve to retrieve a TcpStream or TcpListener to be reused in existing libraries. MPTCP sockets provides the same API as TCP sockets.

You can also check whether a TcpStream uses an underlying MPTCP socket using:

use mptcp::{MptcpExt, MptcpStatus};

let stream : TcpStream = ...;
println!("stream uses mptcp: {}", matches!(stream.mptcp_status(), MptcpStatus::Mptcp { .. }));

Tokio support can be enabled via feature: tokio. Usage is similar for std lib by importing mptcp::tokio::MptcpStreamExt.

License

This project is licensed under the MIT License.

Dependencies

~2–33MB
~500K SLoC