• Welcome to Valhalla Legends Archive.
 

Protocols

Started by Ban, March 04, 2005, 04:47 PM

Previous topic - Next topic

Ban

What exactly are the pros and cons of using a plain-text protocol over binary, or vice-versa?

Hdx

Well, The major one that I can think of, is that it is harder to crack a binary(w/e you want to call it) protocall, then it is a plain-text one.

Also the fact that you can use Bytes to represent numbers, so you can use the byte 0xFF to represent 255. With in hex I beleave would be 32 35 35, Or w/e witch is three times as long. So it saves some space.

I beleace it is easier to use bytes representing diffrent packets then it is to have text representing diffrent packets.
0xFF insted of "[UserTalk]"
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Eric

I had a conversation about this with iago a while back...

http://www.madzlair.net/madzb/forums/index.php?topic=49.0

Basically, it all comes down to speed vs. portability.

Newby

Quote from: LoRd[nK] on March 04, 2005, 05:18 PM
Basically, it all comes down to speed vs. portability.
Yes, the few milliseconds slower the text-based protocol is makes one hell of a difference. =P
- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

iago

For portability, text-based is better
For ease of debugging, text-based is better
For teaching people how to use it, text-based is better

If you require complexity with more information stored, you may neither either a binary protocol or xml.  I would recommend xml for the reasons above.

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Kp

Binary's actually quite portable; the only thing to watch for is people who try to use the wrong endianness.  Text protocols are also more of a nuisance to write parsers for, whereas a binary protocol can often be handled with just a few jump tables.  Also, text-based protocols are inherently more bloated, which can become a nuisance if you're exchanging enough traffic that you actually start hitting your bandwidth limit.  (Think about why people started discussing "binary XML"!)

Ease of "cracking" a protocol really doesn't depend all that much on text vs. binary.  For instance, consider the BNCS chatgate protocol.  Without the extra junk field of "USER", "JOIN", "LEAVE", etc., it'd be about as resistant to attack as the bnbinary protocol, since both are just exchanges of numbers with user chosen strings thrown in.  The bnbinary protocol is of course more compact for the amount of information it passes.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

tA-Kane

Quote from: Kp on March 04, 2005, 06:10 PMThe bnbinary protocol is of course more compact for the amount of information it passes.
Which of course would save a bundle on Battle.net's bandwidth costs.

Think of it this way. You're sending a 100 megabyte file as binary. Now change all those bytes into numeric strings. Your file has now jumped in size by two to three times. That's double to triple the amount of time it takes to transfer the file. That's double to triple the amount of bandwidth use.

The only real advantage that text-based protocols provide over binary-based protocols is that it's a crapload easier to read them on-the-fly. No special parsers are needed. Binary protocols are smaller, faster, and usually a lot easier to handle (eg, write code for) in most good languages with competent programmers (eg, "how do i get the integer into the string" wouldn't be competent).

I would choose a binary protocol over a text protocol any day.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

MyndFyre

Quote from: tA-Kane on March 04, 2005, 09:27 PM
Think of it this way. You're sending a 100 megabyte file as binary. Now change all those bytes into numeric strings. Your file has now jumped in size by two to three times. That's double to triple the amount of time it takes to transfer the file. That's double to triple the amount of bandwidth use.
Interestingly enough, that's true except for users on a modem connection, where binary compression has more effectiveness on text data than binary data.  :P

At least, as far as I can tell.  :P
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Adron

Quote from: MyndFyre on March 04, 2005, 10:29 PM
Interestingly enough, that's true except for users on a modem connection, where binary compression has more effectiveness on text data than binary data.  :P

At least, as far as I can tell.  :P

I don't think you've experimented enough then. The size increase by far outweighs the compression improvement :)


Quote from: iago on March 04, 2005, 05:57 PM
For portability, text-based is better
For ease of debugging, text-based is better
For teaching people how to use it, text-based is better

For portability, text-based becomes a pain as soon as you involve \r\n vs \n, different decimal separators (,.), different thousand separators ( &nbsp;), different date formats (##/##/##, ####-##-##), etc. Just consider parsing and generating all the various Date headers you can find in a mail, and compare that to if they'd just sent a simple time_t....

For ease of debugging, debugging a parser for a text protocol can get much more of a pain than debugging a binary protocol depending on what kind of bugs you're having. A binary protocol with easily separatable top-level packets (say length-prefixed) shouldn't be any more difficult to debug than a text based one.

Teaching people to use it may be easier though, especially teaching them to use it through telnet :)

Ban

So far the only real advantage I see of using a binary over text-based is the fact that it requires a few bytes less of data, perhaps text-based was a strain back when 56k was the standard, but with DSL and Cable around I don't see how it is that binary would be better for a small-ish server

Kp

Quote from: Ban on March 05, 2005, 05:31 PM
So far the only real advantage I see of using a binary over text-based is the fact that it requires a few bytes less of data, perhaps text-based was a strain back when 56k was the standard, but with DSL and Cable around I don't see how it is that binary would be better for a small-ish server

Have you actually read all the responses in this thread?  We explain that there're advantages to binary protocols, such as simpler design of parsers and less bandwidth usage.  I'm getting rather tired of dealing with people who use the argument that "it doesn't matter because the hardware can handle the inefficient approach"; also, remember that many people are not yet on broadband connections.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

Ban

Quote from: Kp on March 05, 2005, 07:09 PM
Quote from: Ban on March 05, 2005, 05:31 PM
So far the only real advantage I see of using a binary over text-based is the fact that it requires a few bytes less of data, perhaps text-based was a strain back when 56k was the standard, but with DSL and Cable around I don't see how it is that binary would be better for a small-ish server

Have you actually read all the responses in this thread? We explain that there're advantages to binary protocols, such as simpler design of parsers and less bandwidth usage. I'm getting rather tired of dealing with people who use the argument that "it doesn't matter because the hardware can handle the inefficient approach"; also, remember that many people are not yet on broadband connections.

Yes, I have read all the responses Kp, and that is the conclusion have I have drawn. a text-based protocol is easier to implement and understand, and if your worried about security there are easy ways to fix that (encryption w/ session key, hashing, whole differn't topic). I don't see how binary has any major advantage over text-based protocols unless your talking about filetransfers or extremely high bandwith usage situations.

Adron

There are some other common weaknesses to text based protocols. If you want to transfer user-input data in a text-based protocol, you need to use some kind of escape sequences. The parsing of those escape sequences easily get much more complex than if you had chosen a binary protocol from the start. If you make a mistake and the user can generate an escape sequence, you're in for evil debugging or exploits.

shout

Is it really that much harder to make a parser? You could probably make a simple parser in 5 minutes.

iago

To whoever said that bandwidth is a factor: text compresses very well, so use a text protocol and compress it.  Compare the file size of MS Word documents (binary files) to equivilant OpenOffice files (gzipped xml), and you'll see a big difference. 

To whoever said that things like dates/escape sequences need to be standardized: xml.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*