Gnutella Forums  

Go Back   Gnutella Forums > Gnutella News and Gnutelliums Forums > General Gnutella Development Discussion
Register FAQ The Twelve Commandments Members List Calendar Arcade Find the Best VPN Today's Posts

General Gnutella Development Discussion For general discussion about Gnutella development.


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old December 28th, 2001
veniamin's Avatar
Devotee
 
Join Date: December 17th, 2001
Posts: 24
veniamin is flying high
Default

I made more tests with my code and after reading Ramihyn's message i found this bug(?)

I declared a record for the header of each message something like:
Header = Record
ID: TGUID;
Function: Byte;
TTL:byte;
Hops:byte;
Datalength: Integer(???)
end;

in the last line i declared the data length as an Integer (it is 4 bytes) which is acceptable for the Gnutella Protocol but when i send a ping message with datalength value as zero the server got a response of 33 00 00 00h instead of 00 00 00 00h. So i declared Datalength as a DWORD (which is also 4 bytes) and the problem fixed. Maybe there are more bugs like this one...

Thak you for your help...
Reply With Quote
  #12 (permalink)  
Old December 28th, 2001
Connoisseur
 
Join Date: August 9th, 2001
Location: Philadelphia, PA, USA
Posts: 358
cultiv8r is flying high
Default

Quote:
Originally posted by veniamin

Header = Record
ID: TGUID;
Function: Byte;
TTL:byte;
Hops:byte;
Datalength: Integer(???)
end;
Ah! Someone's using Delphi (or Pascal)!

Well, for that, I will give you the records used in my Cultiv8r client

Hopefully you can use them. Keep in mind that the records are packed! I'm using pointers to them, because I can easily reference them from memory that way - I read the entire message before processing.

Code:
Type
  // AKA Descriptor Header
  _PGHeader = ^_TGHeader;
  _TGHeader = packed record
    MsgID   : TGUID;
    Func    : byte;
    TTL     : byte;
    Hops    : byte;
    DataLen : integer;
  end;

  _PPong = ^_TPong;
  _TPong = packed record // 0x01
    Port      : word;
    IP        : integer;
    FileCount : dword;
    TotalSize : dword;
  end;

  // BYE packet - this is a proposal, see the GDF
  _PByeHead = ^_TByeHead;
  _TByeHead = packed record // 0x02
    Code : word;
  end;

  // Query Hit
  _PQueryResultHeader = ^_TQueryResultHeader;
  _TQueryResultHeader = packed record // 0x81
    Results : byte;
    Port    : word;
    IP      : integer;
    Speed   : integer;
  end;

  // Query Hit Result set
  _PQueryResultRecordHeader = ^_TQueryResultRecordHeader;
  _TQueryResultRecordHeader = packed record
    FileIndex : integer;
    FileSize  : integer;
  end;

  // Just the vendor ID m'am!
  _PQueryResultFooterExtensionHeader = ^_TQueryResultFooterExtensionHeader;
  _TQueryResultFooterExtensionHeader = packed record
    VendorID : array[0..3] of char;
  end;

  //  EQHD As used by many clients, ala BearShare
  _PQueryResultFooterExtensionDataOne = ^_TQueryResultFooterExtensionDataOne;
  _TQueryResultFooterExtensionDataOne = packed record
    DataLength : byte;
    Flag1,
    Flag2      : byte;
  end;

  // The GUID at the very end of the Query Hit
  _PQueryResultFooter = ^_TQueryResultFooter;
  _TQueryResultFooter = packed record
    ClientID : TGUID;
  end;

  // Push baby, Push!
  _PPush = ^_TPush;
  _TPush = packed record
    ClientID  : TGUID;
    FileIndex : integer;
    IP        : integer;
    Port      : integer;
  end;
Also, most newer clients use GUID marking. So you could use this snippet for creating your GUIDs:

Code:
function CreateGUID : TGUID;
begin
  CoCreateGUID(Result);

  Result.D4[0] := $FF;
  Result.D4[7] := $0;
end;
-- Mike
Reply With Quote
  #13 (permalink)  
Old December 29th, 2001
Morgwen's Avatar
lazy dragon - retired mod
 
Join Date: October 14th, 2001
Location: Germany
Posts: 2,927
Morgwen is flying high
Default

Hi Mike!

Nice to see you here!

Morgwen
Reply With Quote
  #14 (permalink)  
Old December 29th, 2001
veniamin's Avatar
Devotee
 
Join Date: December 17th, 2001
Posts: 24
veniamin is flying high
Default

Thank you a lot cultiv8r... but i have them...

except the snippet for the GUID markink...

my problem is that i cant make my client to connect to another servant.
i send the GNUTELLA CONNECT/0.4, i take the right reply and then nothing...
even if i send a ping message the servant disconnects me.
Reply With Quote
  #15 (permalink)  
Old December 29th, 2001
Connoisseur
 
Join Date: August 9th, 2001
Location: Philadelphia, PA, USA
Posts: 358
cultiv8r is flying high
Default

You've got to make sure that the client accepts incoming connections and connections from a local host (local loop for example).

I recommend getting Gnucleus, since this client is following the Gnutella specs quite closely. The more widely spread ones, like BearShare, have a tendency to do things their own way.

It is also very important that you send nothing more for each packet than specified in the descriptor's payload length, hence my use of packed records, etc. The TTL should be > 0 and the Hops should be set at 0.

If that fails, try outputting (like in a Tmemo object) what you and the other side have sent.

-- Mike
Reply With Quote
  #16 (permalink)  
Old January 2nd, 2002
veniamin's Avatar
Devotee
 
Join Date: December 17th, 2001
Posts: 24
veniamin is flying high
Default

I have finally managed to connect to another servant.
I used the Gnotella client and made a connections succesful. I also tried to connect using Bearshare but it always disconnects my client. Thank you people for your help.
Reply With Quote
  #17 (permalink)  
Old January 5th, 2002
veniamin's Avatar
Devotee
 
Join Date: December 17th, 2001
Posts: 24
veniamin is flying high
Default

any Delphi Programmers outhere?

I am trying to "understand" the data receiving from a connection. I am using a TMemoryStream as a buffer and i manage to "understand" the first Pong Reply. After that i am getting raw data. Any help? Maybe a pseydo code will help.
Reply With Quote
  #18 (permalink)  
Old January 5th, 2002
Connoisseur
 
Join Date: August 9th, 2001
Location: Philadelphia, PA, USA
Posts: 358
cultiv8r is flying high
Default

Always read the header first. Then read the amount of bytes specified in the Payload Descriptor, whether or not it is too big for that particular message. You then handle the data you DO know (like with a pong, you know where the IP and port is located). For the data that you DON'T know, you dump on screen or in a log file so you can inspect the data (or, say, load it into a hex editor).

-- Mike
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spin-off of Gnutella Protocol? PhreakerONE General Gnutella Development Discussion 0 June 6th, 2002 03:57 PM
gnutella protocol Unregistered General Gnutella / Gnutella Network Discussion 2 May 19th, 2002 11:23 AM
Gnutella protocol and hostcaches bateman23 General Gnutella Development Discussion 5 January 9th, 2002 04:42 AM
gnutella protocol v0.6? chuckles42 Gnucleus (Windows) 0 September 15th, 2001 09:11 AM
Gnutella protocol to sloppy? Tiago s1x General Gnutella Development Discussion 3 August 6th, 2001 05:20 PM


All times are GMT -7. The time now is 01:33 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.