| 1 | BEP: 26
|
|---|
| 2 | Title: Zeroconf Peer Advertising and Discovery
|
|---|
| 3 | Version: $Revision$
|
|---|
| 4 | Last-Modified: $Date$
|
|---|
| 5 | Author: Robin Perkins <robin DOT perkins AT internode DOT on DOT net>
|
|---|
| 6 | Status: Draft
|
|---|
| 7 | Type: Standards Track
|
|---|
| 8 | Content-Type: text/x-rst
|
|---|
| 9 | Created: 10-May-2008
|
|---|
| 10 | Post-History:
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | Abstract
|
|---|
| 14 | ========
|
|---|
| 15 |
|
|---|
| 16 | `Zeroconf`_ is a collection of protocols including ipv4 link local
|
|---|
| 17 | networking, `mDNS`_, and `DNS service-discovery`_. This document aims
|
|---|
| 18 | to outline an extension for BitTorrent clients to allow them to find
|
|---|
| 19 | peers on a local-link network using the zeroconf `DNS
|
|---|
| 20 | service-discovery`_ system. It was written in the hope that clients
|
|---|
| 21 | could standardise the way in which they found peers on the local-link
|
|---|
| 22 | in order to maximize the functionality of the BitTorrent protocol.
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | Rationale
|
|---|
| 26 | =========
|
|---|
| 27 |
|
|---|
| 28 | Many networks today consist of computers that have a fast network
|
|---|
| 29 | connection (tens or hundreds of megabits/s) to a local area network,
|
|---|
| 30 | in addition to a relatively slower (hundreds of kilobits/s or a few
|
|---|
| 31 | megabits/s) connection to the wider internet. Such networks exist in
|
|---|
| 32 | places such as university colleges, defence barracks and community
|
|---|
| 33 | wifi networks. If two hosts on the same (fast) local-link network
|
|---|
| 34 | wish to download the same torrent at the moment they only share
|
|---|
| 35 | packets across their slow internet connection. The BitTorrent Zeroconf
|
|---|
| 36 | Peer Advertising and Discovery Extension will allow automatic
|
|---|
| 37 | discovery of these peers to each other so that packets can be quickly
|
|---|
| 38 | transfered across the fast local network as opposed to across their
|
|---|
| 39 | slow internet connections. Effectively the effort of downloading the
|
|---|
| 40 | torrent can now be distributed between the hosts on a local-link
|
|---|
| 41 | network.
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | Requirements
|
|---|
| 45 | ============
|
|---|
| 46 |
|
|---|
| 47 | In order to facilitate the BitTorrent Zeroconf Peer Advertising and
|
|---|
| 48 | Discovery Extension each host is going to be required to run a
|
|---|
| 49 | zeroconf service discovery daemon. This is relatively trivial as there
|
|---|
| 50 | are many available for free but two particularly good zeroconf
|
|---|
| 51 | implementations are:
|
|---|
| 52 |
|
|---|
| 53 | 1. Apple's `Bonjour`_ for Mac OS X (included by default), Windows and POSIX systems
|
|---|
| 54 |
|
|---|
| 55 | 2. `Avahi`_ recommended for Linux and BSD clients and already available in many Linux and BSD distributions.
|
|---|
| 56 |
|
|---|
| 57 | Note that you can only run one zeroconf instance per host due to it
|
|---|
| 58 | binding to specific ports on your network interfaces, so it is **not**
|
|---|
| 59 | recommended to build the whole zeroconf daemon/server into your
|
|---|
| 60 | client. It is much better plug into a system wide service using the
|
|---|
| 61 | API's: it cuts down your code and allows other services e.g. http, ftp
|
|---|
| 62 | to advertise themselves using the same daemon.
|
|---|
| 63 |
|
|---|
| 64 | Method
|
|---|
| 65 | ======
|
|---|
| 66 |
|
|---|
| 67 | Each host will be required to publish (via zeroconf) the service type
|
|---|
| 68 | _bittorrent._tcp. with the instance name as the torrent peer-id (in
|
|---|
| 69 | hex).
|
|---|
| 70 |
|
|---|
| 71 | ``<peer-id>._bittorrent._tcp.``
|
|---|
| 72 |
|
|---|
| 73 | Then clients need publish a subservice that is the torrent info hash (in hex). The result will be something in the form of:
|
|---|
| 74 |
|
|---|
| 75 | ``<peer-id>._<info-hash>._sub._bittorrent._tcp.``
|
|---|
| 76 | e.g.
|
|---|
| 77 | ``4d336d342d312d2d343834616435313564343437._32f17bbf96bdc77de85bb91ff8d56f124e817c0a._sub._bittorrent._tcp.``
|
|---|
| 78 |
|
|---|
| 79 | The above-mentioned zeroconf implementations provide good
|
|---|
| 80 | documentation for developers on how to do this. If the client uses the
|
|---|
| 81 | same peer-id for all torrents it has loaded, then for each additional
|
|---|
| 82 | torrent file, only the subservice needs to be added. If the client
|
|---|
| 83 | uses a different peer-id for each torrent then a
|
|---|
| 84 | _bittorrent._tcp. service will have to be added for each torrent file
|
|---|
| 85 | with the respective subservice. This is also true if each torrent uses
|
|---|
| 86 | a different port.
|
|---|
| 87 |
|
|---|
| 88 | In simple terms you can publish subtypes using the Apple Bonjour API
|
|---|
| 89 | by passing them as a comma separated list after the service type (you
|
|---|
| 90 | don't need to pass in the "_sub" label, since mDNSResponder will
|
|---|
| 91 | automatically add it for you).
|
|---|
| 92 |
|
|---|
| 93 | ``"_bittorrent._tcp,_info-hash1,_info-hash2,_info-hash3"``
|
|---|
| 94 |
|
|---|
| 95 | For the Avahi C API use the function
|
|---|
| 96 | ``avahi_entry_group_add_service()`` to establish the parent
|
|---|
| 97 | _bittorrent._tcp service and
|
|---|
| 98 | ``avahi_entry_group_add_service_subtype()`` with
|
|---|
| 99 | ``_<info-hash>._sub._bittorrent._tcp.`` as the 'type' parameter to
|
|---|
| 100 | establish the subservices. For both functions the <peer-id> should be
|
|---|
| 101 | used for the 'name' parameter.
|
|---|
| 102 |
|
|---|
| 103 | Clients will need to browse for _<info-hash>._sub._bittorrent._tcp in
|
|---|
| 104 | order to discover peers participating in the same torrent. Once again
|
|---|
| 105 | good documentation is provided on how to browse for zeroconf services
|
|---|
| 106 | in the above implementations. The replies will be in the form of
|
|---|
| 107 | <peer-id>._bittorrent._tcp. Note: Some Macintosh official bittorrent
|
|---|
| 108 | clients have a zeroconf implementation built in that publishes its
|
|---|
| 109 | services in the form of:
|
|---|
| 110 |
|
|---|
| 111 | ``_bittorrent-<info-hash>._tcp.``
|
|---|
| 112 | i.e.
|
|---|
| 113 | ``_bittorrent-32f17bbf96bdc77de85bb91ff8d56f124e817c0a._tcp.``
|
|---|
| 114 |
|
|---|
| 115 | However this does not comply with RFC 2782 as the service name needs
|
|---|
| 116 | to be 14 characters or less in addition to the fact that it is not a
|
|---|
| 117 | service type but in fact a service instance it is advertising. Clients
|
|---|
| 118 | may choose to also browse for these services for backwards
|
|---|
| 119 | compatibility purposes (minimal effect - only one client is known to
|
|---|
| 120 | do this) however they should not publish in this format.
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 | Considerations
|
|---|
| 124 | ==============
|
|---|
| 125 |
|
|---|
| 126 | Clients should consider a couple of options when implementing the
|
|---|
| 127 | BitTorrent Zeroconf Peer Advertising and Discovery Extension
|
|---|
| 128 | specifically:
|
|---|
| 129 |
|
|---|
| 130 | * an option to not advertise torrents via zeroconf
|
|---|
| 131 |
|
|---|
| 132 | * an option not to upload limit local-link peers (or possibly have a separate rule).
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 | Thoughts
|
|---|
| 136 | ========
|
|---|
| 137 |
|
|---|
| 138 | * I suspect the published peer-id need not be the hexed string as I
|
|---|
| 139 | have it now. A simple unique string may be all that is required
|
|---|
| 140 | (i.e. a hostname or a human readable computer name) with any
|
|---|
| 141 | uniqueness conflicts handled by zeroconf automatically. We
|
|---|
| 142 | ultimately only need to know what is on offer (as denoted by the
|
|---|
| 143 | info-hash) and where to get it (the resolved IP address).
|
|---|
| 144 |
|
|---|
| 145 | * The mainline client and others may like to examine
|
|---|
| 146 | `pybonjour`_. pybonjour provides a pure-Python interface to Apple
|
|---|
| 147 | `Bonjour`_ and compatible DNS-SD libraries (such as `Avahi`_).
|
|---|
| 148 |
|
|---|
| 149 | * Newer zeroconf implementations such as Bonjour include support for
|
|---|
| 150 | wide area service discovery. (Avahi can browse but not publish these
|
|---|
| 151 | yet). This may be another consideration in support of this BEP.
|
|---|
| 152 |
|
|---|
| 153 | * May make a nice companion to BEP 9.
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 | References
|
|---|
| 157 | ==========
|
|---|
| 158 |
|
|---|
| 159 | .. _`Zeroconf`: Zero Configuration Networking (Zeroconf)
|
|---|
| 160 | http://www.zeroconf.org
|
|---|
| 161 |
|
|---|
| 162 | .. _`mDNS`: Multicast Domain Name System (mDNS)
|
|---|
| 163 | http://www.multicastdns.org
|
|---|
| 164 |
|
|---|
| 165 | .. _`DNS service-discovery`: DNS service-discovery (DNS-SD)
|
|---|
| 166 | http://www.dns-sd.org
|
|---|
| 167 |
|
|---|
| 168 | .. _`Avahi`: Avahi
|
|---|
| 169 | http://www.avahi.org
|
|---|
| 170 |
|
|---|
| 171 | .. _`Bonjour`: Apple's Bonjour
|
|---|
| 172 | http://developer.apple.com/networking/bonjour/
|
|---|
| 173 |
|
|---|
| 174 | .. _`pybonjour`: pybonjour
|
|---|
| 175 | http://o2s.csail.mit.edu/o2s-wiki/pybonjour
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 | Copyright
|
|---|
| 179 | =========
|
|---|
| 180 |
|
|---|
| 181 | This document has been placed in the public domain.
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 | ..
|
|---|
| 186 | Local Variables:
|
|---|
| 187 | mode: indented-text
|
|---|
| 188 | indent-tabs-mode: nil
|
|---|
| 189 | sentence-end-double-space: t
|
|---|
| 190 | fill-column: 70
|
|---|
| 191 | coding: utf-8
|
|---|
| 192 | End:
|
|---|
| 193 |
|
|---|