diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 360f9d2f..27770e72 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -3,7 +3,8 @@ Summary [Intermodal](./introduction.md) -- [BitTorrent BEP Support](./bep-support.md) -- [Alternatives & Prior Art](./prior-art.md) -- [BitTorrent References](./bittorrent-references.md) -- [UDP Tracker Protocol](./udp-tracker-protocol.md) +- [Bittorrent](./bittorrent.md) + - [BEP Support](./bittorrent/bep-support.md) + - [Alternatives & Prior Art](./bittorrent/prior-art.md) + - [UDP Tracker Protocol](./bittorrent/udp-tracker-protocol.md) + - [References](./bittorrent/references.md) diff --git a/book/src/bittorrent.md b/book/src/bittorrent.md new file mode 100644 index 00000000..c536512d --- /dev/null +++ b/book/src/bittorrent.md @@ -0,0 +1,4 @@ +Bittorrent +========== + +This page intentionally left blank. diff --git a/book/src/bep-support.md b/book/src/bittorrent/bep-support.md similarity index 100% rename from book/src/bep-support.md rename to book/src/bittorrent/bep-support.md diff --git a/book/src/prior-art.md b/book/src/bittorrent/prior-art.md similarity index 99% rename from book/src/prior-art.md rename to book/src/bittorrent/prior-art.md index 6f66abec..9f2860a7 100644 --- a/book/src/prior-art.md +++ b/book/src/bittorrent/prior-art.md @@ -1,5 +1,5 @@ Alternatives & Prior Art ------------------------- +======================== | Name | UI | Language | Notes | |-----------------------------------------------------------------------------------|-------------------------|------------|-------------------------------------------------------------------------------------------------------------------------------------------| diff --git a/book/src/bittorrent-references.md b/book/src/bittorrent/references.md similarity index 86% rename from book/src/bittorrent-references.md rename to book/src/bittorrent/references.md index 6e544c35..5567bdd5 100644 --- a/book/src/bittorrent-references.md +++ b/book/src/bittorrent/references.md @@ -1,5 +1,5 @@ -BitTorrent References ---------------------- +References +========== | URL | Description | |:------------------------------------------------------------|:--------------------------------------------------------------------------------------------------| @@ -8,3 +8,4 @@ BitTorrent References | https://wiki.theory.org/index.php/Main_Page | Wiki with lots of information about all aspects of the BitTorrent protocol and implementations. | | https://archive.org/details/2014_torrent_archive_organized) | Massive 158 GiB archive containing 5.5 million torrents, assembled in 2014. | | https://github.com/internetarchive/dweb-transport | Github repository hosting The Internet Archive's distributed web and BitTorrent-related software. | +| https://libtorrent.org/udp_tracker_protocol.html | UDP tracker protocol description. | diff --git a/book/src/udp-tracker-protocol.md b/book/src/bittorrent/udp-tracker-protocol.md similarity index 85% rename from book/src/udp-tracker-protocol.md rename to book/src/bittorrent/udp-tracker-protocol.md index 83cfae20..174e9224 100644 --- a/book/src/udp-tracker-protocol.md +++ b/book/src/bittorrent/udp-tracker-protocol.md @@ -1,5 +1,5 @@ -Bittorrent UDP-tracker protocol -=============================== +UDP Tracker Protocol +==================== This description of the UDP tracker protocol is adapted from [this page](https://libtorrent.org/udp_tracker_protocol.html) by Arvid Norberg. @@ -24,6 +24,15 @@ table. When a message is followed by a structure labeled _repeating:_, the rest of the message is zero or more of that structure. +Fields with type `[T; N]` are `N` instances of values of type `T` with no extra +padding. + +Fields with type `[T; NAME]` are `NAME` instances of values of type `T` with no +extra padding, where `NAME` is an integer field of the same message. + +Files with type `[T]` are zero or more instances of values of type `T` with no +extra padding, which make up any trailing bytes of the message. + Actions ------- @@ -48,11 +57,11 @@ Events Error ------ -| size | name | description | +| type | name | description | |------|----------------|-------------------------------------------| | i32 | action | | | i32 | transaction_id | | -| i8[] | error_string | rest of packet is string describing error | +| [i8] | error_string | rest of packet is string describing error | Connect ------- @@ -117,7 +126,7 @@ Scrape ### Request -| size | name | +| type | name | |------|----------------| | i64 | connection_id | | i32 | action | @@ -125,20 +134,20 @@ Scrape _repeating:_ -| size | name | +| type | name | |----------|-----------| | [i8; 20] | info_hash | ### Response -| size | name | +| type | name | |------|----------------| | i32 | action | | i32 | transaction_id | _repeating:_ -| size | name | description | +| type | name | description | |------|------------|----------------------------------------------| | i32 | complete | peers in swarm that have finished downloding | | i32 | downloaded | times torrent has been downloaded | @@ -167,11 +176,11 @@ The packet will have authentication information appended to it. where `packet` is the bytes of the packet, less the final 8 bytes that are `passwd_hash`. -| size | name | description | -|-------|-----------------|-----------------------------------| -| i8 | username_length | | -| i8[] | username | length given by `username_length` | -| u8[8] | passwd_hash | | +| type | name | +|------------------------|-----------------| +| i8 | username_length | +| [i8; `username_length` | username | +| [u8; 8] | passwd_hash | ### Request String @@ -181,10 +190,10 @@ torrent is allowed to be tracked by a tracker for instance. It could also be used to authenticate users by generating torrents with unique tokens in the tracker URL for each user. The extension body has the following format: -| size | name | description | -|------|----------------|----------------------------------| -| i8 | request_length | | -| i8[] | request_string | length given by `request_length` | +| type | name | +|------------------------|----------------| +| i8 | request_length | +| [i8; `request_length`] | request_string | `request_string` is the string that comes after the hostname and port in the UDP tracker URL. Typically this starts with "/announce" The bittorrent client