Author | Message | Time |
---|---|---|
Luxer | I have been messing around with Kanes BNLS tester, and finaly managed to mimic it. The only thing I am having a problem with is the first character of the packet. It seems to be differnt every time I change somthing. FYI: I am using packet 0x02. Could somone please tell me how to get that first character? | September 10, 2004, 10:17 PM |
Kp | [quote author=Luxer link=board=17;threadid=8616;start=0#msg79584 date=1094854629]I have been messing around with Kanes BNLS tester, and finaly managed to mimic it. The only thing I am having a problem with is the first character of the packet. It seems to be differnt every time I change somthing. FYI: I am using packet 0x02. Could somone please tell me how to get that first character?[/quote] The first and second bytes are the length field of the header of the first message. So, every time you change the length of the packet, the first byte will of course change. | September 10, 2004, 11:02 PM |
Luxer | OK... So the length of my packet goes in the first byte (or character)? | September 10, 2004, 11:05 PM |
Kp | [quote author=Luxer link=board=17;threadid=8616;start=0#msg79589 date=1094857546]OK... So the length of my packet goes in the first byte (or character)?[/quote] No. Read the BNLS protocol specification. | September 10, 2004, 11:57 PM |
Myndfyr | [quote author=Luxer link=board=17;threadid=8616;start=0#msg79589 date=1094857546] OK... So the length of my packet goes in the first byte (or character)? [/quote] I don't think reading the BNLS protocol spec will necessarily help. Luxer doesn't understand what little-endian is. Let's say you have a length field (as in the case of BNLS). If you want to use one byte (that's eight bits) to store it, you can choose to interpret the number as signed (which means either positive or negative, and the most significant bit determines whether or not the number is negative) to get values from -128 to 127; or you can interpret it as unsigned (all values are positive), which gives you another power of two to work with in values, from 0 to 255. When dealing with values larger, though, there are four different types of integral numbers that are common among the platforms: Byte -- an eight-bit value, which we just described. Word -- a sixteen-bit, or two-byte, value. Double Word, or DWORD -- a thirty-two bit, or four-byte, value. Quad Word, or QWORD -- a sixty-four bit, or eight-byte, value. The range of numbers you can use varies based on whether or not you use signed or unsigned numbers: Byte -- Signed: -2[sup]7[/sup] to ( 2[sup]7[/sup]-1 ). Unsigned: 0 to 2[sup]8[/sup]-1 Word -- Signed: -2[sup]15[/sup] to ( 2[sup]15[/sup]-1 ). Unsigned: 0 to 2[sup]16[/sup]-1 Double Word -- Signed: -2[sup]31[/sup] to ( 2[sup]31[/sup]-1 ). Unsigned: 0 to 2[sup]32[/sup]-1 Quad Word -- Signed: -2[sup]63[/sup] to ( 2[sup]63[/sup]-1 ). Unsigned: 0 to 2[sup]64[/sup]-1 Another issue the two major chip manufacturers, Motorola and Intel, faced when dealing with numerical representation was how to represent multi-byte numbers; specifically, where do the most-significant bytes go in memory? Motorola chose to use big-endian, because the "big end" (the most significant byte) comes first. Intel, om the other hand, chose little-endian, because the least significant byte comes first. What does this have to do with your size? BNLS uses two bytes for the length, a word value. The first byte is the little part, and will change most frequently. The second byte is the more significant bits -- bits 8 through 15 (indexed at 0). Since these are more significant (you'd need to go beyond a length of 255), they change less frequently than the bits in the first byte. Hope that clarifies and answers your question. | September 11, 2004, 12:30 AM |
Vision | [Kp edit: removed content of post which is not only completely wrong, but indicates a complete lack of understanding of the current context by the original poster. There is no magic 0xff associated with BNLS, Vision.] | September 11, 2004, 1:42 AM |
Luxer | :-\ I guess I did not ask my question correctly. How do I find out what the first two bits of a packet should be? | September 11, 2004, 1:15 PM |
Kp | [quote author=Luxer link=board=17;threadid=8616;start=0#msg79674 date=1094908520] :-\ I guess I did not ask my question correctly. How do I find out what the first two bits of a packet should be?[/quote] Compute the packet length, then perform a bitwise and with 3. | September 11, 2004, 4:23 PM |
Luxer | [quote author=Kp link=board=17;threadid=8616;start=0#msg79699 date=1094919800] [quote author=Luxer link=board=17;threadid=8616;start=0#msg79674 date=1094908520] :-\ I guess I did not ask my question correctly. How do I find out what the first two bits of a packet should be?[/quote] Compute the packet length, then perform a bitwise and with 3. [/quote] Two things: Bitwise And, or Bitwise OR? Is there a differnance? Say my packet was: Byte 1: ? Byte 2: ? Byte 3: 02 Byte 4: 00 After byte 4: Someusername (Say this was 10 bytes) After that: 00 (1 byte) After that: Somepassword (say this was 10 bytes) Would I bitwise 25? Or do I not include the first two bytes in a bitwise? | September 11, 2004, 5:11 PM |
Myndfyr | You're a moron. Really. First of all, the reason Kp said you should perform a bitwise AND with three, is because you asked how to determine the first two bits. So did you read my post? You should be able to figure it out from that. But if not.... 1.) If the length is 255 or less, the length goes in the first byte, and 0 in the second byte. 2.) If the length is more than 255, you perform a bitwise AND with 255 and the length, and put that result in the first byte. Then, you shift 255 to the left by 8, AND that with the length, shift that value right by 8, and then that's the second byte. BNLS uses little-endian byte order. If you didn't understand the above list, then you should be able to figure out how to do it from the post I made above. | September 11, 2004, 6:55 PM |
Luxer | Oh, now I get it. Sorry, I am just used to using GOOD servers. I did not realize that BNLS is cruddy.... (No offense to Skywing... He did it like bnet, not like it should be) "Send everything in ASCII, the universal language for computers, and you'll never have to worry about endianness." -BlankeyRat Thanks for your time, bye! A note to mods: He flames me, I flame him. [quote author=MyndFyre link=board=17;threadid=8616;start=0#msg79714 date=1094928916] You're a moron. Really. First of all, the reason Kp said you should perform a bitwise AND with three, is because you asked how to determine the first two bits. So did you read my post? You should be able to figure it out from that. But if not.... 1.) If the length is 255 or less, the length goes in the first byte, and 0 in the second byte. 2.) If the length is more than 255, you perform a bitwise AND with 255 and the length, and put that result in the first byte. Then, you shift 255 to the left by 8, AND that with the length, shift that value right by 8, and then that's the second byte. BNLS uses little-endian byte order. If you didn't understand the above list, then you should be able to figure out how to do it from the post I made above. [/quote] | September 11, 2004, 7:07 PM |
St0rm.iD | [quote author=Luxer link=board=17;threadid=8616;start=0#msg79716 date=1094929630] I did not realize that BNLS is cruddy.... (No offense to Skywing... He did it like bnet, not like it should be) [/quote] 1. That's a great way to get help 2. If you're bitching about endianness, then hot damn, Intel is cruddy, too. So is AMD. 3. I didn't realize that...YOUR MOM is cruddy. [quote] "Send everything in ASCII, the universal language for computers, and you'll never have to worry about endianness." -BlankeyRat [/quote] Holy shit, that's a great idea! Let's have computer data, which doesn't need to be human-readable as it is, transmitted in an overly verbose language? Why fit 255 values into 1 byte, when we can fit 10!?!?!? That's such a fantastic idea; instead of just copying the memory into an int variable, now we get to have the fun time of parsing it! PLUS, we get to worry about which base its in! That solves SO MANY problems! [quote] A note to mods: He flames me, I flame him. [/quote] The only person around here who gets away with that is me, shithead. Not to mention Myndfyre's a cool guy. | September 11, 2004, 8:00 PM |
Myndfyr | [quote author=Luxer link=board=17;threadid=8616;start=0#msg79716 date=1094929630] Oh, now I get it. Sorry, I am just used to using GOOD servers. I did not realize that BNLS is cruddy.... (No offense to Skywing... He did it like bnet, not like it should be) "Send everything in ASCII, the universal language for computers, and you'll never have to worry about endianness." -BlankeyRat [/quote] That's the most idiotic thing I've ever heard. Why not triple or quadruple the size of data? Yes! That would just be markedly efficient!!! [quote author=Luxer link=board=17;threadid=8616;start=0#msg79716 date=1094929630] Thanks for your time, bye! [/quote] Are you finally leaving? Don't let the door hit you on your way out. | September 11, 2004, 8:20 PM |
Kp | Not only do I not get flamed for giving him answers that are technically exactly what he wants (but still completely useless since he asked the wrong question), but he then goes on to insult everybody else that really did try to help him? I'm very offended to be left out of this! Besides which, Myndfyre's very succinct remark that Luxer is a moron seems right on target, based on his performance in this thread. I hardly consider it a flame, since Luxer definitely goes on to prove Myndfyre quite correct. Luxer's probably the type of guy who thinks XML is the be-all end-all of data storage because it's text-based rather than packed data. :) [Edit: fixed typo.] | September 11, 2004, 8:52 PM |
LivedKrad | Hmm.. why again did he want the first two bits of the packet? I believe it was mentioned at least three times that the packet length is stored as a WORD. A WORD as Myndfyre said, was two bytes. In which case, it would only be necessary to shift the two places and hold the value in some sort of Long value. Unless Luxer made a typo, I'd also call him a moron. Edit: Fixed a typo. | September 12, 2004, 2:16 PM |