Now I am implementing UDP server to gather sflow datagrams using netty library.
Here is my setting for udp server.
ChannelFactory factory = new NioDatagramChannelFactory(this.threadPool.getScheduledExecutor());
ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory(){
public ChannelPipeline getPipeline(){
ChannelPipeline lChannelPipeline = Channels.pipeline();
lChannelPipeline.addLast("sflowmessagedecoder", new SflowMessageDecoder());
lChannelPipeline.addLast("handler", new SflowCollectorHandler());
return lChannelPipeline;
}
});
bootstrap.setOption("receiveBufferSize", 65536);
bootstrap.bind(new InetSocketAddress(port));
The problem is that when I receive a sflow datagram (about 1300 bytes long, this can be checked using wireshark), netty only reads about 700 bytes, this can be checked by channelbuffer's size, of the datagram from the channelbuffer.
However, I use java.net.* libraries such as DatagramSocket.class and DatagramPacket.class, it receives sflow datagram correctly (about 1300 bytes).
Somebody can help me? Due to this, I cannot parse sflow datagram correctly.
Thanks.