[
http://jira.jboss.com/jira/browse/JGRP-324?page=comments#action_12417636 ]
Richard Achmatowicz commented on JGRP-324:
------------------------------------------
Adding in some comments which were previously sent by email:
Wireformats for UDP
JGroups peers can receive UDP packets, where the destination address may be
a unicast address or a multicast address. Both types of packets have the same
payload format (i.e. when we strip off the UDP header, we are left with a
payload with the same format). It is this payload which Wireshark will have
to dissect.
JGroups uses message bundling to put several Messages into one UDP packet.
Bundling can either be turned on or turned off, so we have to be able to
handle both formats.
UDP payload (non-bundled)
-------------------------
version (2 bytes)
flags (1 byte)
Message (variable length)
UDP payload (bundled)
---------------------
version (2 bytes)
flags (1 byte)
length (4 bytes)
Address (variable length)
Message (first bundled message - variable length)
Message (second bundled message variable length)
...
Message ('length' bundled message- variable length)
NOTES:
1. In order to dissect these packets, we need to be able to dissect Address
and Message. Address is read using Util.readAddress(). Message is read using
Message.readFrom()
2. version format:
e.g. JGroups 2.6.2
* X = 0-31 for major versions
* Y = 0-31 for minor versions
* Z = 0-63 for micro versions
See the org.jgroups.Version class for algorithm on how to decode the version.
3. flags format:
LIST (0x1)
MULITCAST (0x10)
OOB (0x100)
4. We can tell whether bundling is turned on by the value the expression (flags &
LIST):
* if (flags & LIST == false), then after reading version and flags, we expect
only one message in the packet
* if (flags & LIST == true), then after reading version and flags, we read
length and expect 'length' messages in the packet
In order to dissect the UDP payload, we need to be able to dissect serialized Address and
Message objects.
------------------
Address wireformat
------------------
Address is a JGroups class which represents an 'address'. Depending on the
transport
we are using, this could be an <IP address, port> combination, or a JMS topic.
The in-memory value of an Address is written/serialized using Util.writeAddress().
The wireformat is:
isnull (variable length)
isIpAddress (variable length)
contents (variable length)
The values isnull ("is the address equal to null?") and isIpAddress("is the
address
an IpAddress instance") are encoded Boolean values.
Contents is variable and involves shipping classes across the wire.
See the method org.jgroups.util.Util.writeAddress() for the specifc details.
------------------
Message wireformat
------------------
Message is a JGroups class and represents data shipped around the system.
Messages contain the following data elements:
dest_addr - destination address of the Message
src_addr - source address of the Message
flags - flags
data - payload of the message
list of headers - headers which Protocols use to store information
Messages are written to the wire using the method org.jgroups.Message.writeTo().
The wireformat is:
leading (1 byte)
flags (1 byte)
dest_addr (variable length)
src_addr (variable length)
buflen (4 bytes)
buf ('buflen' bytes)
numhdrs (2 bytes)
(Key, Header) (first Header - variable length)
(Key, Header) (second Header -variable length)
...
(Key, Header) ('numhdrs' Header - variable length)
NOTES:
1. leading is a set of flags indicating which elements have been written to
the wireformat and which have not.
DEST_SET (0x0000001)
SRC_SET (0x0000010)
BUF_SET (0x0000100)
IPADDR_DEST (0x0010000)
IPADDR_SRC (0x0100000)
SRC_HOST_NULL (0x1000000)
2. flags indicate properties of the Message, whether it is out of bound, etc.
OOB (0x001)
LOW_PRIO (0x010)
HIGH_PRIO (0x100)
3. dest_addr and src_addr are written using either IpAddress.writeTo()
or Util.writeAddress(), depending on whether the Address is an IpAddress
instance or not. I suspect that almost all will be IpAddress instances.
See the method org.jgroups.Message.writeTo() for the specifc details on how
Message is serialized.
------------------------
(Key, Header) wireformat
------------------------
Header is a JGroups class, and each protocol will have its own
versions (e.g. TPHeader, FRAGHeader, etc.) which are subclasses of Header.
Each Message has zero or more Headers associated with it. Each Header
entry consists of a key and a value (e.g. ("UDP", TPHeader),
("FRAG", FRAGHeader), etc.)
The wireformat is:
key (variable length)
magic (2 bytes)
class (variable length, only if magic == -1)
size (2 bytes)
contents (variable length)
NOTES:
1. key is the UTF8 encoding of the key String (e.g. "FRAG")
2. magic is the magic number of the Header class
3. class is the UTF8 encidong of the Header class name, and is only
present if magic == -1
4. size is the size of the serialized Header class
5. contents is the serialized Header class contents, which is created by:
Header class is streamable -> Header.writeTo()
Header class is non-streamable -> Header.writeExternal()
Comments
--------
1. We need to dissect and represent Addresses
2. We need to dissect and represent Messages and their contents.
3. We need to dissect and represent Headers and their contents. Given that Headers are
classes of varying types, we just need a representation for the key attributes of the
class.
Ethereal plugin for JGroups
---------------------------
Key: JGRP-324
URL:
http://jira.jboss.com/jira/browse/JGRP-324
Project: JGroups
Issue Type: Feature Request
Reporter: Bela Ban
Assigned To: Richard Achmatowicz
Priority: Minor
Fix For: 2.x
Write a C implementation of an ethereal plugin which understands the JGroups wire format
and displays information about the JGroups messages (e.g. sender, receiver, headers) in
ethereal.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira