IMFile

IMFile

A Free And Unlimited BT / HTTP / HTTPS / eD2k Download Software From Singapore

BitTorrent's local service discovery mechanism

Local Service Discovery (LSD) is a mechanism that provides a similar function to SSDP (Simple Service Discovery Protocol). It uses UDP multicast over HTTP to announce its presence in a specific group to local neighbors. This allows other local devices to know what services are provided by the device, facilitating communication and data transfer between them. LSD can serve as a primary peer source for local transfers and can also complement other sources that operate only on global unicast addresses.

LSD uses the following multicast groups: A) 239.192.152.143:6771 (org-local) and B) [ff15::efc0:988f]:6771 (site-local).

Implementation note: Since multicast groups are more extensive than local LAN, the IP_MULTICAST_TTL socket option may need to be set to a value greater than the default value.

The announce message format for the LSD protocol is as follows:

BT-SEARCH * HTTP/1.1\r\n
      Host: <host>\r\n
      Port: <port>\r\n
      Infohash: <hash>\r\n
      cookie: <cookie (optional)>\r\n
      \r\n
      \r\n

Host: This field needs to comply with the specifications of RFC 2616 section 14.23 and RFC 2732. It specifies the multicast group address to which the announce message is sent. RFC 2616 is the specification document for HTTP/1.1, which defines various information about the HTTP protocol. Section 14.23 describes the format of the Host header. The Host header is used to specify the hostname and port number of the target server for the request. RFC 2732 is a URL standard that allows the use of IPv6 addresses to represent hostnames in URLs. This means that IPv6 addresses can be used in the Host header of the LSD protocol to represent multicast group addresses.

Port: This field specifies the port number that the BitTorrent client is listening on, encoded in base-10 ASCII.

Hash: This field is a 40-character hexadecimal encoded infohash value that uniquely identifies a torrent file.

When sending multiple infohashes, care should be taken to avoid packet lengths exceeding 1400 bytes to avoid MTU/fragmentation issues. When the packet length exceeds the maximum transmission unit (MTU) size during network transmission, IP fragmentation occurs, which reduces network transmission efficiency and increases the risk of packet loss.

Cookie: This is an opaque value that is completely unknown and invisible to the client. It only needs to be sent to the client without further explanation. The purpose of this value is to allow the client to filter when receiving its own announce requests to avoid duplicate processing. Any additional header information that a client does not understand should be ignored to ensure forward compatibility.

Implementation:
First, if a client is participating in a swarm, it should send an LSD announce every 5 minutes on each interface so that other clients can know of its existence and connect to it. To avoid causing multicast storms in large networks, a client can send a maximum of one announcement per minute.

Second, if a client is downloading or uploading more than 5 torrents simultaneously, it can choose to alternate sending announcements on each torrent or include multiple infohashes in a single announcement (to differentiate between different torrents). Other clients can use this information to establish connections with the client.

When a client receives an LSD announcement from another client, it needs to determine the IP address of the remote client based on the UDP source address.

In summary, Local Service Discovery (LSD) is a mechanism in the BitTorrent protocol used for discovering other BitTorrent clients within a local network. When a BitTorrent client starts, it broadcasts its presence through LSD and receives broadcast information from other clients, establishing peer-to-peer connections.

LSD quickly discovers other clients within a local network by using UDP multicast. Additionally, LSD can be used in conjunction with other local service discovery protocols, such as mDNS, to further improve the efficiency of discovering devices within a local network.

LSD is an important component of the BitTorrent protocol as it accelerates node discovery in P2P downloads, improving download speed and stability.

Reference links:

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.