📄 rfc-0_6-draft.html
字号:
<html><!-- #BeginTemplate "/Templates/index_page.dwt" --><body bgcolor="#FFFFFF" text="#000000"><?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><head><!-- #BeginEditable "doctitle" --> <title>Gnutella Protocol Development</title><!-- #EndEditable --></head> <p style="text-align: center"><a href="../index.html"><img alt="Our blue logo"src="../Templates/images/banner.gif" width="368" height="58" border="0" /></a></p><p style="text-align: center"></p><p style="text-align: center">Gnutella Protocol Development </p><p style="text-align: center"><a href="../index.html">Home </a>:: <a href="../developer/index.html">Developer </a>:: <a href="../press/index.html">Press </a>:: <a href="../research/index.html">Research</a> :: <a href="../servents/index.html">Servents</a></p><!-- #BeginEditable "body" --><pre>Network Working Group T. KlingbergRequest for Comments: NNNN R. ManfrediCategory: Informational June 2002 Gnutella 0.6Status of this Memo This is a draft.Copyright Notice Copyright (C) 2002, Tor Klingberg & Raphael Manfredi All Rights Reserved. Permission is granted to make verbatim copies of this document, provided the Copyright Notice is preserved.Rights of Free Implementation The authors of the various proposals that make up this document grant the rights to anyone to freely implement those proposals. Gnutella is an Open Protocol, where the specifications are public and free of any patent.Table of Contents 1 Introduction 1.1 Purpose 1.2 Requirements 1.3 Terminology 1.4 Extending the protocol 2 Protocol Definition 2.1 Initiating a Connection 2.2 Gnutella Messages 2.2.1 Message Header 2.2.2 Ping (0x00) 2.2.3 Pong (0x01) 2.2.4 Use of Ping and Pong messages 2.2.4.1 A simple pong caching scheme 2.2.4.2 Other pong caching schemes 2.2.5 Query (0x80) 2.2.6 Query Hit 2.2.7 Use of Query and Query Hit 2.2.7.1 Forwarding and routing of Query and Query Hit messages 2.2.7.2 When and how to send new Query messages. 2.2.7.3 When and how to respond with Query Hit messages. 2.2.8 Push (0x40) 2.2.9 Bye (0x02) 2.3 GGEP Extension blocks 2.3.1 GGEP Format 2.3.2 Creating Extension IDs 3 Protocol Usage 3.1 Flow Control 3.2 Network Structure 3.2.1 Ultrapeer system 3.2.2 Query Routing Protocol (unfinished) 4 File Transfer 4.1 Normal File Transfer 4.2 Firewalled servents 4.3 Busy Servents 4.4 Sharing 5 Security Considerations 5.1 Threats against individual Gnutella participants 5.2 Threats against the Gnutella network 5.3 Threats against third parties 6 Credits Appendix 1 HUGE (Hash/URN Gnutella Extensions) Appendix 2 XML Appendix 3 Finding a Gnutella host Appendix 4 When to open or accept new Gnutella connections Appendix 5 Gnutella network traffic compression1 Introduction1.1 Purpose Gnutella is a decentralized peer-to-peer system. It allows theparticipants to share resources from their system for others tosee and get, and locate resources shared by others on the network.Resources can be anything: mappings to other resources, cryptographickeys, files of any type, meta-information on keyable resources, etc.However, the semantics for locating and handling resources other thanplain files are not specified in this document.Each participant launches a Gnutella program, which will seek out other Gnutella nodes to connect to. This set of connected nodes carries the Gnutella traffic, which is essentially made of queries, replies to those queries, and also other control messages to facilitate the discovery of other nodes.Users interact with the nodes by supplying them with the list ofresources they wish to share on the network, can enter searches forother's resources, will hopefully get results from those searches,and can then select those resources amongst the results: if thoseresources are files, for instance, they can download them. But onecan imagine other types of resources that, once fetched, will bringmore than their content value.Resource data exchanges between nodes are negotiated using the standard HTTP protocol. The Gnutella network is only used to locate the nodes sharing those resources.This document is intended for readers with a fair knowledge of network programming, but do not require any previous Gnutella experience. Still, other implementations of this protocol will giveuseful information about implementation techniques that is not included in this document. A list of Gnutella programs can be found at http://www.gnutelliums.com1.2 RequirementsThe key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT","SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in thisdocument are to be interpreted as described in RFC 2119 [34].1.2.1 The Gnutella Development Forum (the GDF)The Gnutella Development Forum is a good place to find more Gnutella documentation, proposals about changes and extensions and to discuss Gnutella development with other developers. The message archive is also a good source for information about the protocol and its implementation. Some of the links in this document requires membership in the Gnutella Development Forum. Everyone is, of course,allowed to become a member. The GDF is located at http://groups.yahoo.com/group/the_gdfThere are many other forums for discussing Gnutella development as well.1.3 TerminologyServent A program participating in the Gnutella network is called a servent. The words "peer", "node" and "host" have similar meanings, but refers to a network participant rather than a program. When a servent have a clear client or server role the words "client" or "server" may be used. The word "client" is sometimes used as a synonym for servent. This is a contraction of "SERVer" and "cliENT", Some other documents use the word "servant" instead of servent.Message Messages are the entity in which information is transmitted over the network. Sometimes the word "packet" is used with the same meaning. Some other documents use the word "descriptor"GUID Globally Unique IDentifier. This is a 16-byte long value made of random bytes, whose purpose it is to identify servents and messages. This identification is not a signature, just a way to identify network entities in a unique manner.1.4 Extending the protocolThis document is the definition of the Gnutella 0.6 protocol. Servents MAY extend the protocol or even change parts of it (for example by compressing or encrypting the messages), but servents MUST always stay compatible with servents that follow this specification. If a servent, for example, wants to compress the Gnutella messages, it MUST first make sure the remote host of a connection can decompress the stream (during handshake), and otherwise leave the messages uncompressed. Servents MAY chose not to accept a connection with a servent that does not support a feature, but MUST always make sure that the Gnutella network is not split into separate networks. Separate networks for special purposes are, of course, allowed but then it is no longer the Gnutella network, but another network. This protocol also allows for extensions inside many messages. Such extensions can pass through servents that do not know about the extension to reach servents that do.2 Protocol DefinitionThe Gnutella protocol defines the way in which servents communicate over the network. It consists of a set of messages used for communicating data between servents and a set of rules governing the inter-servent exchange of messages. Currently, the following messages are defined:Ping Used to actively discover hosts on the network. A servent receiving a Ping message is expected to respond with one or more Pong messages.Pong The response to a Ping. Includes the address of a connected Gnutella servent, the listening port of that servent, and information regarding the amount of data it is making available to the network.Query The primary mechanism for searching the distributed network. A servent receiving a Query message will respond with a Query Hit if a match is found against its local data set.QueryHit The response to a Query. This message provides the recipient with enough information to acquire the data matching the corresponding Query.Push A mechanism that allows a firewalled servent to contribute file-based data to the network.Bye An optional message used to inform the remote host that you are closing the connection, and your reason for doing so.2.1 Initiating a ConnectionA Gnutella servent connects itself to the network by establishing a connection with another servent currently on the network. Techniques for finding the first host are described in Appendix 3. Once the first connection is established, the addresses of more hostswill be supplied over the network. The default Gnutella port is 6346,but servents MAY use any unused port. If the desired port is used (probably by another Gnutella servent) the servent SHOULD attempt to listen on another port. This listening port is advertised by theservent through the Pong messages.Techniques and rules for how to select what other Gnutella hosts to connect to and when to accept connection requests can be found in Appendix 4.Once the address of another servent on the network is obtained, a TCP/IP connection to the servent is created, and a handshaking sequence is initiated. The client is the host initiating the connection and the server is the host receiving it. "<cr>" refers to ASCII character 13 (carriage return), and "<lf>" to 10 (new line). 1. The client establishes a TCP connection with the server. 2. The client sends "GNUTELLA CONNECT/0.6<cr><lf>". 3. The client sends all capability headers--except for vendor-specific headers--each terminated by "<cr><lf>", with an extra "<cr><lf>" at the end. 4. The server responds with "GNUTELLA/0.6 200 <string><cr><lf>". <string> SHOULD be "OK", but servents SHOULD just look for the "200" code. 5. The server sends all its headers, in the same format as in (3). 6. The client sends "GNUTELLA/0.6 200 OK<cr><lf>, as in (4) if after parsing the server's headers, it still wishes to connect. Otherwise, it needs to reply with an error code and close the connection. 7. The client sends any vendor-specific headers as needed, in the same format as (3). 8. Both client and server send binary messages at will, using the information gained in (3) and (5). All headers SHOULD be registered with the GDF database athttp://groups.yahoo.com/group/the_gdf/database?method=reportRows&tbl=9(Requires GDF membership)Headers follow the standards described in RFC822 and RFC2616. Eachheader is made of a field name, followed by a colon, and then the value. Each line ends with the <cr><lf> sequence, and the end of theheaders is marked by a single <cr><lf> line. Each line normally starts a new header, unless it begins with a space or an horizontal tab (ASCII codes 32 and 9 in decimal, respectively), in which case itcontinues the preceding header line. The extra spaces and tabs may be collapsed into a single space as far as the header value goes. For instance: First-Field: this is the value of the first field<cr><lf> Second-Field: this is the value<cr><lf> of the<cr><lf> second field<cr><lf> <cr><lf>The header above is made of two fields, "First-Field" and "Second-Field" whose values are respectively "this is the value of the first
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -