Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
uTorrent Transport Protocol library
C++ C Python Makefile
Failed to load latest commit information.
VS2012 Undo unintentional changes to VS2012 solutions
prop_sheets Separate runtime property sheet
.gitignore cleanup_wine
LICENSE Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
Makefile Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
README.md a note in the readme on Packaging and API
libutp-2012.vcxproj.filters Change name of compatibility source file.
libutp-2013.vcxproj Update solutions and projects to VS2013
libutp_inet_ntop.cpp Compatibility for pre-Vista win32
libutp_inet_ntop.h Add missing header.
parse_log.py initial import
ucat.c Minor #include fixups, to compile on FreeBSD
utp.h Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
utp_api.cpp Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
utp_callbacks.cpp cleanup_winsockapi
utp_callbacks.h Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
utp_hash.cpp cleanup_winsockapi: adjustment of a few warning fixes
utp_hash.h cleanup_winsockapi: adjustment of a few warning fixes
utp_internal.cpp cleanup_winsockapi: adjustment of a few warning fixes
utp_internal.h Make libutp build on XP, Win32 post-XP, and POSIX.
utp_packedsockaddr.cpp Make libutp build on XP, Win32 post-XP, and POSIX.
utp_packedsockaddr.h Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
utp_templates.h Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
utp_types.h Revert "on gcc, handle #define PACKED_ATTRIBUTE"
utp_utils.cpp Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)
utp_utils.h Merge BitTorrent libutp changes from uTorrent 3.4 (alpha)

README.md

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 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.

Examples

See the utp_test and utp_file directories for examples.

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.

Related Work

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

Something went wrong with that request. Please try again.