Restored from previous forum. Originally posted by ricardo.
Hi, Its me again making questions.
Im trying, as i post in a message a few days ago, to comunicate with a Gnutella server (or servant).
In the protocol papers they said:
Note 2: All fields in the following structures are in little-endian
byte order unless otherwise specified.
Note 3: All IP addresses in the following structures are in IPv4
format. For example, the IPv4 byte array
0xD0 0x11 0x32 0x04
byte 0 byte 1 byte 2 byte 3
represents the dotted address 208.17.50.4.
and in other place they say:
Message ID A 16-byte string (GUID) uniquely identifying the
message on the network.
Servants SHOULD store all 1's (0xff) in byte 8 of the
GUID. (Bytes are numbered 0-15, inclusive.) This
serves to tag the GUID as being from a modern
servant.
Servants SHOULD initially store all 0's in byte 15 of
the GUID. This is reserved for future use.
The other bytes SHOULD have random values.
Payload Indicates the type of message
Type 0x00 = Ping
0x01 = Pong
0x02 = Bye
0x40 = Push
0x80 = Query
0x81 = Query Hit
[/b]
Im not sure if i understand this...
When they say: 16 byte string (will its rules), its like
Structure Gnutella
MessageID.b[16]
TTL.b[1]
Hops.b[1]
Payload.b[1]
EndStructure
Test.Gnutella
PokeS(@Test\MessageID[0],"3456789102345609")
Another question... how can i write the Ping, etc.
0x00 = Ping 0x01 = Pong 0x02 = Bye 0x40 = Push
0x80 = Query 0x81 = Query Hit
Maybe i will have more questions in a few minutes (i will continue reading the Gnutella Protocl), i hope that some charitative soul answers my multiple questions : )
The pages that im reading (if someone else has interest) is:
http://groups.yahoo.com/group/the_gdf/f ... 6draft.txt
Little-endian and bytes (Gnutella file sharing)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
Hi,
let me tell you, what I know about all this...
> Note 2: All fields in the following structures are in little-endian
> byte order unless otherwise specified.
'little-endian' order means, that all bytes are reversed. This thingy comes from
old intel machines, which did that all the time, they were called 'little-endian'
Sou you'll need to read the values backwards:
This get's hard, when it comes to WORDS or LONG Values, but it doesn't seem
that you'll need them.
> Note 3: All IP addresses in the following structures are in IPv4
> format. For example, the IPv4 byte array
This is easy, you have four bytes representing the ip:
That's it, nothing more.
> Im not sure if i understand this...
> When they say: 16 byte string (will its rules), its like
Looks correct to me, only the MessageID.b[16] should be changed to 15 as
mentioned in my above example.
Note that byte 15 must be 0, but if you Poke a String with 15 chars, the 16th
well be the terminating NULL Character, so that's already done.
> Another question... how can i write the Ping, etc.
About Ping: see here...
viewtopic.php?t=1106
About the other stuff, i don't know about this, sorry. (what is Pong? - PingPong?)
That's all, hope it helps...
Timo
--
If it stinks, it's chemistry. If it moves, it's biology.
If it does not work, It's computer science.
Hi,
let me tell you, what I know about all this...
> Note 2: All fields in the following structures are in little-endian
> byte order unless otherwise specified.
'little-endian' order means, that all bytes are reversed. This thingy comes from
old intel machines, which did that all the time, they were called 'little-endian'
Sou you'll need to read the values backwards:
Code: Select all
Structure Gnutella
MessageID.b[15] ; should be 15, becourse it starts with 0
TTL.b[1]
Hops.b[1]
Payload.b[1]
EndStructure
Test.Gnutella
message.s = "Hello World" ; just to show, what you'll have to do
Dim Temp.b(15)
PokeS(@Temp(0), message)
For i = 0 to 15
Test\MessageID[15-i] = Temo[i] ; reverse everything
next i
that you'll need them.
> Note 3: All IP addresses in the following structures are in IPv4
> format. For example, the IPv4 byte array
This is easy, you have four bytes representing the ip:
Code: Select all
IP.s = Chr(byte0.b) + "." + Chr(byte1.b) + "." + Chr(byte2.b) + "." + Chr(byte3.b)
> Im not sure if i understand this...
> When they say: 16 byte string (will its rules), its like
Looks correct to me, only the MessageID.b[16] should be changed to 15 as
mentioned in my above example.
Note that byte 15 must be 0, but if you Poke a String with 15 chars, the 16th
well be the terminating NULL Character, so that's already done.
> Another question... how can i write the Ping, etc.
About Ping: see here...
viewtopic.php?t=1106
About the other stuff, i don't know about this, sorry. (what is Pong? - PingPong?)
That's all, hope it helps...
Timo
--
If it stinks, it's chemistry. If it moves, it's biology.
If it does not work, It's computer science.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
Thanks Freak !!
About the ping question,
Another question... how can i write the Ping, etc.
0x00 = Ping
0x01 = Pong
0x02 = Bye
0x40 = Push
0x80 = Query
0x81 = Query Hit
Im only asking wich character or numbers are the 0x00, 0x01,0x02,0x40,0x80,0x81
I think i have to put in the
Structure Gnutella
MessageID.b[16]
TTL.b[1]
Hops.b[1]
Payload.b[1]
EndStructure
Test.Gnutella
The 0x00, 0x01,0x02,0x40,0x80 or 0x81
But how do i write it? Why do i need to write in every case (0x00, 0x01,0x02,0x40,0x80,0x81)because next example are wrong
PokeS(@Test\Payload[0],"0x01")
Thanks in advance
Thanks Freak !!
About the ping question,
Another question... how can i write the Ping, etc.
0x00 = Ping
0x01 = Pong
0x02 = Bye
0x40 = Push
0x80 = Query
0x81 = Query Hit
Im only asking wich character or numbers are the 0x00, 0x01,0x02,0x40,0x80,0x81
I think i have to put in the
Structure Gnutella
MessageID.b[16]
TTL.b[1]
Hops.b[1]
Payload.b[1]
EndStructure
Test.Gnutella
The 0x00, 0x01,0x02,0x40,0x80 or 0x81
But how do i write it? Why do i need to write in every case (0x00, 0x01,0x02,0x40,0x80,0x81)because next example are wrong
PokeS(@Test\Payload[0],"0x01")
Thanks in advance
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
Now I understand...
0x40 is a Value, in HEX format. In some programing languege (don't ask me which)
it is written like that.
Just replace the '0x' with '$' like this: $40
And just write: Test\Payload[0] = $40
One more thing i saw:
> Structure Gnutella
> MessageID.b[16]
> TTL.b[1]
> Hops.b[1]
> Payload.b[1]
> EndStructure
Why those [1]'s at the end? Do you really need 2 bytes each time? well, if not,
just cut this off.
That's it...
Timo
--
If it stinks, it's chemistry. If it moves, it's biology.
If it does not work, It's computer science.
Edited by - freak on 04 August 2002 02:22:10
Now I understand...
0x40 is a Value, in HEX format. In some programing languege (don't ask me which)
it is written like that.
Just replace the '0x' with '$' like this: $40
And just write: Test\Payload[0] = $40
One more thing i saw:
> Structure Gnutella
> MessageID.b[16]
> TTL.b[1]
> Hops.b[1]
> Payload.b[1]
> EndStructure
Why those [1]'s at the end? Do you really need 2 bytes each time? well, if not,
just cut this off.
That's it...
Timo
--
If it stinks, it's chemistry. If it moves, it's biology.
If it does not work, It's computer science.
Edited by - freak on 04 August 2002 02:22:10
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ricardo.
I understand (i think i do ).
Now i CAN connect to the BearShare server (sending html-like headers), and then i receive binery data... i cant interpret it !!!
I hope that someone with more knowledge about receiving and managing this kind of data want to help me developing this BearShare client.
I think that this is the structure that i have to receive (in little-endian)
Structure Gnutella
MessageID.b[15]
PType.b[1]
TTL.b[1]
Hops.b[1]
Payload.b[4]
EndStructure
Thanks !!
I understand (i think i do ).
Now i CAN connect to the BearShare server (sending html-like headers), and then i receive binery data... i cant interpret it !!!
I hope that someone with more knowledge about receiving and managing this kind of data want to help me developing this BearShare client.
I think that this is the structure that i have to receive (in little-endian)
Structure Gnutella
MessageID.b[15]
PType.b[1]
TTL.b[1]
Hops.b[1]
Payload.b[4]
EndStructure
Thanks !!