I'm currently building a transparent proxy in Java. This transparent proxy is placed between a client and a server, using iptables to redirect the TCP flow.
From the point of view of the TCP communication, I have the following dialog :
Client Server | ---- TCP Packet 1 ---> | | ---- TCP Packet 2 ---> | | <--- TCP Packet 3 ---- | | <--- TCP Packet 4 ---- |
From the point of view of the transparent proxy (using sockets), I get :
Client Server | ---- TCP Payloads from packet 1 + 2 ---> | | <--- TCP Payloads from packet 3 + 4 ---- |
My problem is that the sockets are putting together multiple TCP payloads together. I would like to avoid this behavior.
I could circumvent the problem using the size of the packets, but this size is not constant. I tried using the tcpNoDelay option, but also no luck with that. I used the networking framework netty, but I get the same problem.
Is there a way to avoid this concatenation of TCP payloads in Java ?