Greetings,
I've just done parsing UDP packets sent to multicast channel, via java for =
grated subproject.
I'm testing code with Ganglia 2.5.6, so sorry, if my question is asked too =
late. I've searched
mail-list by keywords "XDR", "gmond UDP" but haven't found proper answer (m=
ay be just searched not
very well).
--- so question is ---
user defined metrics data (type, name, value - all are ASCII characters s=
equences) is encoded
"as an unsigned integer (size), and followed by the n bytes of the string=
". RFC1832.
So, here is question: for what purpose packets contain '\0' at the end of=
string, adding 1 to string
length? (NOTE: It's not 32bit bound align zeroes, they are following this=
'\0').
Of course, for practical usage in C/C++ code (and other languages which a=
re operating zero-ended
strings), it's better to count string-end symbol. But even in case of suc=
h languages,
there is no big problem to increment recieved value before using.
May be I am wrong, but it's not very good idea for true portability.
I've got issue with automatic loading of classes by name (such names "uin=
t32\0" were not found,
cause, java doesn't use zero-ended strings, and '\0' is also translated t=
o symbol, basing on
local machine native charset), now I'm correcting string length manually =
and that is somehow weird.
PS:
removing that zero will save you about 3 bytes of traffic per packet wit=
h user defined metrics ;),
and sometimes even more on encoding values like "99.0".
Example:
00 00 00 10 43 50 55 5F =A6 74 65 6D 70 65 72 61 74 ...>CPU_temp=
erat
75 72 65 00 00 00 00 05 =A6 34 33 2E 30 00 00 00 00 ure....=A643=
.0....
00 00 00 08 43 65 6C 63 =A6 69 75 73 00 00 00 00 03 ...=95Celciu=
s....=A6
00 00 00 3C 00 00 00 00 =A6 3E 51 99 42 F2 48 06 00 ...<....>Q=
=D9B=AAH=A6.
72 00 00 00 72 00 00 00 =A6 01 00 5E 02 0B 47 00 07 r...r...O.^O=
>G.=95 =20
Look at this 4 useless zeroes after 43.0.
=20
---------------------
Thanks for paying attention.
--=20
Best wishes,
Alexey
|