View Single Post
  #1 (permalink)  
Old March 23rd, 2002
Smilin' Joe Fission Smilin' Joe Fission is offline
Gnutella Veteran
 
Join Date: March 14th, 2002
Location: Canada
Posts: 121
Smilin' Joe Fission is flying high
Question Need help with byte formats

Forgive my newbieness but I have a couple questions that I'm sure someone here can help me answer.

I'm a bit confused over some of this byte ordering stuff. I'm developing a servent of my own and this is probably the first application I've dealt with in which "big-endian" and "little-endian" byte formats have become an issue.

So, here's where my confusion starts. I've read the "Gnutella Protocol Specification v0.4" doc and early on there are 2 notes (in bold) that read: "Note 1: All fields in the following structures are in little-endian byte order unless otherwise specified." and "Note 2: All IP addresses in the following structures are in IPv4 format. For example, the IPv4 byte array: 0xD0, 0x11, 0x32, 0x04 represents the dotted address 208.17.50.4." OK, I can agree with that... no problem.

I suppose where I start to get confused is later on when the document goes into its description on the various packet formats. Along with the standard description of the IP address field on each packet, in bold it has a note stating "This field is in big-endian format." Does this mean I have to reverse the IP address before sending it out (ie. using the example given, the IP address would be essentially sent as 4.50.17.208)? Or is any conversion required for the IP field at all?

What about other numeric values like "Number of files shared" and "Number of Kilobytes shared" in a Pong packet for example? Do those need to be converted to big-endian as well? The reason I ask is that I downloaded some free code for a particular servent ("coyotella" written in Visual Basic) and in referring to that code, it seems that almost every numeric value is being converted to big-endian format before it's sent, which to me sounds wrong if I am to take "Note 1" (as it appears above) at its word.

Of course, I might be missing something along the way... might Winsock itself require the byte ordering to be reversed? (I think I read something somewhere that said that.) I'm just real confused right at the moment. Maybe I'm just reading too much into things. Then again, maybe I'm just slow. Hopefully one of you Gnutella gurus can help me out.

Any help is GREATLY appreciated.

Oh, and if it makes any difference, I'm developing my servent in Visual Basic 6.0.... ya ya, I know, funny laugh laugh... why don't I develop it in a REAL language? I dunno... "maybe later" is all I can say to that.

Thanks.

-SJF

Last edited by Smilin' Joe Fission; March 23rd, 2002 at 10:54 PM.
Reply With Quote