FrameDecoder for UDP stream
Jan Van Besien
janvanbesien at gmail.com
Thu May 6 07:41:16 EDT 2010
Hi
I am looking for ideas on how to implement something in netty.
I am writing a netty client (and test/mock server) for a binary UDP
protocol. The payload is protobuf and the transport layer is UDP. Each
protobuf message is splitted over different UDP packets. Each UDP packet
contains a header and a body. The body is a part of the protobuf
message, the header contains a conversation number (identifies a single
request-response conversation), a packet number and a total number of
packets (total meaning the total to get the whole protobuf payload) and
a length field describing how long the body is.
Downstream it looks like this (I think this is OK):
- my business logic handler creates protobuf messages
- a protobuf encoder encodes the message in binary format
- a custom OneToOneEncoder creates a ChunkedInput which creates the UDP
packets as described above
- a chunkedWriteHandler writes the chunks
I currently designed the upstream pipeline like this:
- (1) a lengthfieldbasedframedecoder to cope with potentially fragmented
UDP packets
- (2) something which assembles multiple "chunked" UDP packets into a
single protobuf message
- (3) a protobuf decoder
- (4) my business logic
The problem is (2). I think something based on a FrameDecoder is not
sufficient, because potentially multiple "conversations" are going on at
the same time. So I should have something which buffers all input per
ongoing conversation, and sends a message upstream when all packets for
a certain conversation have arrived. When that happens, it should clear
the buffer for this conversation, but not the others. Potentially I also
want to clear incomplete buffers after a certain timeout.
Is there something in netty on which I can build for this kind of
functionality?
Am I maybe complicating things too much? I am involved in the design of
the protocol as well, so things can still be changed.
Kind regards
Jan
More information about the netty-users
mailing list