lokinet/libutp
2019-08-02 10:29:08 +01:00
..
CMakeLists.txt Fix log tag after cmake changes 2019-02-15 20:49:10 +00:00
libutp_inet_ntop.cpp switch to a simulation of epoll 2018-11-19 04:29:39 -06:00
libutp_inet_ntop.h strip extra unneeded code from libutp 2018-09-19 20:39:45 -05:00
LICENSE implement utp link protocol 2018-09-04 08:41:25 -04:00
Makefile implement utp link protocol 2018-09-04 08:41:25 -04:00
parse_log.py Fix lifetime issues in llarp_findOrCreate* function calls 2019-01-03 23:10:32 +00:00
README.md implement utp link protocol 2018-09-04 08:41:25 -04:00
utp_api.cpp implement utp link protocol 2018-09-04 08:41:25 -04:00
utp_callbacks.cpp implement utp link protocol 2018-09-04 08:41:25 -04:00
utp_callbacks.h implement utp link protocol 2018-09-04 08:41:25 -04:00
utp_hash.cpp implement utp link protocol 2018-09-04 08:41:25 -04:00
utp_hash.h Allow builds on MSVC (#518) 2019-04-19 13:24:33 -05:00
utp_internal.cpp remove limit 2019-08-01 08:20:35 -04:00
utp_internal.h Fix gcc trunk warnings 2019-08-02 10:29:08 +01:00
utp_packedsockaddr.cpp Fixup one ASAN warning 2019-03-29 01:02:41 +00:00
utp_packedsockaddr.h implement utp link protocol 2018-09-04 08:41:25 -04:00
utp_templates.h implement utp link protocol 2018-09-04 08:41:25 -04:00
utp_utils.cpp Allow builds on MSVC (#518) 2019-04-19 13:24:33 -05:00
utp_utils.h implement utp link protocol 2018-09-04 08:41:25 -04:00

libutp - The uTorrent Transport Protocol library.

Copyright (c) 2010 BitTorrent, Inc.

uTP is a TCP-like implementation of LEDBAT documented as a BitTorrent extension in BEP-29. uTP provides reliable, ordered delivery while maintaining minimum extra delay. It is implemented on top of UDP to be cross-platform and functional today. As a result, uTP is the primary transport for uTorrent peer-to-peer connections.

uTP is written in C++, but the external interface is strictly C (ANSI C89).

The Interface

The uTP socket interface is a bit different from the Berkeley socket API to avoid the need for our own select() implementation, and to make it easier to write event-based code with minimal buffering.

When you create a uTP socket, you register a set of callbacks. Most notably, the on_read callback is a reactive callback which occurs when bytes arrive off the network. The write side of the socket is proactive, and you call UTP_Write to indicate the number of bytes you wish to write. As packets are created, the on_write callback is called for each packet, so you can fill the buffers with data.

The libutp interface is not thread-safe. It was designed for use in a single-threaded asyncronous context, although with proper synchronization it may be used from a multi-threaded environment as well.

See utp.h for more details and other API documentation.

Example

See ucat.c. Build with:

make ucat

Building

uTP has been known to build on Windows with MSVC and on linux and OS X with gcc. On Windows, use the MSVC project files (utp.sln, and friends). On other platforms, building the shared library is as simple as:

make

To build one of the examples, which will statically link in everything it needs from libutp:

cd utp_test && make

Packaging and API

The libutp API is considered unstable, and probably always will be. We encourage you to test with the version of libutp you have, and be mindful when upgrading. For this reason, it is probably also a good idea to bundle libutp with your application.

License

libutp is released under the MIT license.

Research and analysis of congestion control mechanisms can be found here.