Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
uTorrent Transport Protocol library
branch: master

This branch is 111 commits behind bittorrent:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
utp_config_lib
utp_file
utp_test
LICENSE
README.md
StdAfx.h
parse_log.py
templates.h
utp.cpp
utp.def
utp.h
utp.sln
utp.vcproj
utp_config_example.h
utp_utils.cpp
utp_utils.h
utypes.h
win32_inet_ntop.cpp
win32_inet_ntop.h

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.

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. We don't have a makefile yet to build static or shared libraries. Here's how you can build one of the examples, which will link in everything it needs from libutp:

cd utp_test && make

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.