SDSU CS 580 Client-Server
Spring Semester, 2004
Gnutella
Previous    Lecture Notes Index    Next    
© 2004, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 23-Mar-04


Reference


The Gnutella Protocol Specification v0.4, Document Revision 1.2, http://www9.limewire.com/developer/gnutella_protocol_0.4.pdf



Doc 20, Gnutella Slide # 2

Gnutella







Doc 20, Gnutella Slide # 3
Basic Idea


Servent connects to 1 or more remote servents

Can



To get a file from a servent




Doc 20, Gnutella Slide # 4
Basic Protocol

Connect to another servent with

   GNUTELLA CONNECT/<protocol version string>\n\n

Where <protocol version string> is 0.4

If the remote servent accepts the connection it must respond with

   GNUTELLA OK\n\n


Both servents then can then send messages


Doc 20, Gnutella Slide # 5

Requests and Responses


Ping – who is on the network

Pong – response to a ping

Query – search the network for data

QueryHit – response to query

Push – Used to allow servents work behind firewall

Each Request/Response starts with a header

Doc 20, Gnutella Slide # 6

Header



Desciptor ID
Payload Descriptor
TTL
Hops
Payload Length
Byte
offset
0 - 15
16
17
18
19 - 22

Descriptor ID

16 byte string
Uniquely identifies Request/Response

Payload Descriptor

Value
Meaning
0x00
Ping
0x01
Pong
0x40
Push
0x80
Query
0x81
QueryHit

TTL
Time to live

Number of times message will be forwarded by servents

Many servents will set TTL to 5 if is it larger

Each servent that gets the message reduces TTL by one before forwarding the message


Doc 20, Gnutella Slide # 7
Hops

Number of times message has been forwarded

Each servent that gets the message increase Hop by one before forwarding

Payload Length

Length of rest of message



Doc 20, Gnutella Slide # 8

Ping 0x00


No more content other then header


Doc 20, Gnutella Slide # 9

Pong 0x01


Sent only in response to a ping

Servent can cache pongs of other servents



Port
IP Address
Number of files shared
Number of kilobytes shared
Byte
offset
0 - 1




Port

Port that responding servent can accept incoming connections


IP Address

IP Address of responding servent

This field uses big-endian format


Doc 20, Gnutella Slide # 10

Query 0x80




Minimum Speed
Search Criteria
Byte
offset
0 - 1


Minimum Speed

Minimum speed (of connection) in kb/second of servents that should respond to this message

Search Criteria

Nul (0x00) terminated search string

Length of string must be included in the payload length field


Doc 20, Gnutella Slide # 11

QueryHit (0x81)


Sent in response to a Query

Descriptor ID in header should contain same value as the Query


Number of hits
Port
IP Address
Speed
Result Set
Servent Identifier
Byte
offset
0






Number of hits

Number of hits in the result set

Port

Port number on which responding servent can accept incoming connections

IP Address

IP Address of responding servent

This field uses big-endian format

Speed

Speed of responding host’s connection in kb/second


Doc 20, Gnutella Slide # 12
Result Set



File Index
File Size
File Name
Byte
offset
0 - 3



File Index

A number used by host to identify the file

File Size
Size in bytes of the file

File Name

Double-nul (0x0000) terminated name of the file

Servent Identifier

A 16-byte string uniquely identifying the responding servent on the network.

“This is typically some function of the servent’s network address”


Doc 20, Gnutella Slide # 13
Extended Query Hit



Number of hits
Port
IP Address
Speed
Result Set
Trailer
Servent Identifier
Byte
offset
0








Trailer


Vender Code
Open Data Size
Open Data
Private data
Byte
offset
0 - 3
4
5


How do we know if the trailer exists?

How do we know the length of the private data?



Doc 20, Gnutella Slide # 14

Push (0x40)




Servent Identifier
File Index
IP Address
Port
Byte
offset
0 - 15




Servent Identifier

A 16-byte string uniquely identifying the servent on the network that should push the file

File Index

Index of the file to push

IP Address

IP Address of to which the file should be pushed

This field uses big-endian format

Port

Port to which the file should be pushed

Doc 20, Gnutella Slide # 15

Some Routing


Pong messages

Can only be send along path the carried the Ping

Servents should not forward a pong if they did not see the ping

QueryHit

Can only be send along path the carried the Query

Servents should not forward a query hit if they did not see the query


Push

Can only be send along path the carried the QueryHit

Servents should not forward a push if they did not see the query hit

Fowarding

Forward all Ping and Querys to all directly connected servents except to the one that sent it

Decrement TTL and increment Hops field

Don’t forward messages that you have seen before

Doc 20, Gnutella Slide # 16

File Downloads


In response to a QueryHit download the file by using http.

Request the file uses following format:


GET /get/<File Index>/<File Name>/ HTTP/1.0\r\n
Connection: Keep-Alive\r\n  
Range: bytes=0-\r\n  
User-Agent: Gnutella\r\n 3  \r\n

Remote servent responses with:

HTTP 200 OK\r\n
Server: Gnutella\r\n
Content-type: application/binary\r\n
Content-length: fileSize\r\n
\r\n

Copyright ©, All rights reserved.
2004 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.

Previous    visitors since 23-Mar-04    Next