CS 580 Client-Server Spring Semester, 2004 Gnutella |
||
---|---|---|
© 2004, All Rights Reserved, SDSU & Roger Whitney San Diego State University -- This page last updated 23-Mar-04 |
Gnutella
Basic Idea
Servent connects to 1 or more remote servents
Can
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
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
Header
|
Desciptor
ID
|
Payload
Descriptor
|
TTL
|
Hops
|
Payload
Length
|
Byte offset |
0
- 15
|
16
|
17
|
18
|
19
- 22
|
Value |
Meaning |
0x00 |
Ping |
0x01 |
Pong |
0x40 |
Push |
0x80 |
Query |
0x81 |
QueryHit |
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
Ping 0x00
No more content other then header
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
|
|
|
|
Query 0x80
|
Minimum
Speed
|
Search
Criteria
|
Byte offset |
0
- 1
|
|
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
|
|
|
|
|
|
Result Set
|
File
Index
|
File
Size
|
File
Name
|
Byte offset |
0
- 3
|
|
|
Extended Query Hit
|
Number
of hits
|
Port
|
IP
Address
|
Speed
|
Result
Set
|
Trailer
|
Servent
Identifier
|
Byte offset |
0
|
|
|
|
|
|
|
|
Vender
Code
|
Open
Data Size
|
Open
Data
|
Private
data
|
Byte offset |
0
- 3
|
4
|
5
|
|
Push (0x40)
|
Servent
Identifier
|
File
Index
|
IP
Address
|
Port
|
Byte offset |
0
- 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
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