[JBoss JIRA] Closed: (NETTY-95) Length field based frame decoder

Trustin Lee (JIRA) jira-events at lists.jboss.org
Wed Dec 17 06:47:54 EST 2008


     [ https://jira.jboss.org/jira/browse/NETTY-95?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trustin Lee closed NETTY-95.
----------------------------

    Resolution: Done


I've just checked in LengthFieldBasedFrameDecoder which works as described above.  Needs documentation though (will be documented during beta or release candidate phase.)  Please note that the decoded frame includes the whole message with the length field (+ header) even if the length field is the only prefix (i.e. lengthFieldOffset is 0).

> Length field based frame decoder
> --------------------------------
>
>                 Key: NETTY-95
>                 URL: https://jira.jboss.org/jira/browse/NETTY-95
>             Project: Netty
>          Issue Type: Feature Request
>          Components: Handler
>            Reporter: Trustin Lee
>            Assignee: Trustin Lee
>             Fix For: 3.1.0.ALPHA3
>
>
> In proprietary protocol, it is very common that a message starts with a length field.  For example, a message could contain the length of the message body as its first field:
>   * (length) 0x00 0x00 0x00 0x04 (data) 0xca 0xfe 0xba 0xbe
> In some cases, the length field could stand for the length of the 'whole' message, which includes the length of the length field itself:
>   * (length) 0x00 0x00 0x00 0x08 (data) 0xca 0xfe 0xba 0xbe
> In some other cases, the length field could be located in the middle of a message which is prepended by fixed-length header:
>   * (header) 0xab 0xbc 0xcd 0xde 0xef (length) 0x00 0x00 0x00 0x04 (data) 0xca 0xfe 0xba 0xbe
> Also, the length of the length field can be either an unsigned byte, an unsigned short integer, an unsigned medium integer, an unsigned integer, or some wider type - a user should be able to specify the length of the length field.
> To support all these cases, the following parameters are required:
>   * the position of the length field (0 for the first two cases and 5 for the last case above) - the sensible default should be 0.
>   * the length of the length field (4 for all the three cases above) - there should be no default because it varies between protocols.
>   * the length modifier (0, -4, 0 respectively, -9 if the third example's length field meant the length of the whole message (i.e. 13-9 = 4)).
> These three parameters should cover most cases where a length field is specified.  Please let me know if there's any case that I am missing, although more complicated cases could be taken care in a custom codec.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the netty-dev mailing list