Each Gnutella message has a header. This header contains information
describing what kind of message it is, how much further it should be
sent and a unique identifier for the message. All fields in the
message header are in network byte order (big endian). Table
tbl:gnutellaheader shows the structure of the message header.
Table 3.1:Gnutella message header fields
Bytes
Description
0-15
Message ID (globally unique)
16
Payload type
17
TTL (Time To Live)
18
Hops
19-22
Payload length
The fields in the Gnutella message header have the following
meaning and semantics.
Message ID
is a 16-byte string that is globally unique
and identifies a message on the network. Gnutella version
0.6 states that byte 8 (if bytes are numbered 0-15) should
be all 1's to indicate that the id belongs to a modern
servent. Gnutella version 0.6 also states that byte 15
should be zero, since it is reserved for future use.
Payload type
denotes the type of message.
It should have one of the values shown in table
tbl:gnutellapayloadtype.
Table 3.2:Gnutella message header payload types
Value
Message type
0x00
Ping message
0x01
Pong message
0x02
Bye message (only Gnutella 0.6)
0x40
Push message
0x80
Query message
0x81
QueryHit message
Time to live
holds the number of times the message will
be forwarded by Gnutella servents before is is removed from
the network. Each servent decrements the TTL before
sending the message to another servent. When the
TTL reaches 0, the message will not be forwarded
further.
Hops
contains the number of hops the message has been
forwarded before reaching the current servent. As a message
is passed from servent to servent the TTL and
Hops fields satisfy the following condition.
TTL0 = TTLn + Hopsn
In this equation
TTL0 denotes the
initial TTL (which usually is 7) and
TTLn and
Hopsn is the value of
TTL and Hops after n hops.
Payload length
contains the length of the message
following the message header. No padding is used. Messages
should not be larger than 4 kB.