Re:Open Sourcing the Stupid-Simple Messaging Protocol
by beagle3 on Friday September 11, 2015 @06:01PM
(#10206412)
I assume you're coming from a hardware perspective - HDLC/PPP parsing in hardware might make sense in niche cases; though most protocols benefit much more from the flexibility and upgrade possibilities of a software implementation.
In this case, it is a messaging protocol. The incoming message essentially must be copied somewhere, therefore space must be allocated to store it, and therefore the length must be known.
CRLF require either two passes (one to get string length, another to copy data) or continuously expanding storage, both of which are significantly more expensive than just parsing a short number in the beginning of the string.
Re:Open Sourcing the Stupid-Simple Messaging Protocol
by jhallenworld on Saturday September 12, 2015 @03:25PM
(#10209018)
PPP in hardware is for IP over SONET at 2.5 - 40 Gbps, good luck doing it in software...
In hardware there is no malloc- instead there is a pool of pages and the string would be stored as a linked list of such pages. Linux socket buffers do the same thing.
The CRLF encoding is not so bad in this case: read 8 characters, in parallel detect CR. If there is no CR in your word, just append the data to the buffer. When you do have a CR, it's a big pain: you need to save the last word with byte masks, then shift any remaining for the next input (and the entire next string is shifted by this left-over balance). You could try to make all strings a multiple of 8 in length to avoid this, but this adds overhead to the message so is inefficient- the hardware will just have to do it.
OK, so now in your new format the hardware has to parse a variable length decimal number and convert it to binary (ideally in parallel), very fun! You could make the conversion byte at a time, but it's slow. You need to implement overflow detection.
At the very least use hex instead of decimal. Even in software you may need overflow detection. This is easy in hex, not so much in decimal. Better is to require the number to be a multiple of four or eight digits, even though this is a waste of bandwidth.