On Mon, Sep 14, 2009 at 9:22 PM, Sebastian Wagner <seba.wag...@gmail.com> wrote:
> hi,
>
>
> I have a Client-SocketConnector and Server-SocketAcceptor. So all about TCP.
> I send TCP-Packets with a size of around 1200Bytes but I always receive
> Packages with a length of 2048, 4096, 8192, ...
> I mark all Packets that I do send with a sequence number before sending => I
> see that packages are missing.
>
> So some packets are missing and others are much bigger. I guess TCP does
> wrap my packages together to have a optimal frame size when send over the
> network.

Missing packets with TCP? this is something hard to believe. Can you
cross check again.

>
>
> How do you deal with this?
> Actually it does not make sense to me that I send Packets of one size and
> receive something different.
> But anyway if this is the way TCP works (or optimizes the throughput) thats
> fine ...  but the problem is => how do I get my Packets in the same
> structure that I've send again?

You have to assemble them using ProtocolDecoders.

The way it works is, you have to know when your packet starts and end.
Either in form of a prefixed header etc.
Once you detect that, you need to consume the input till you detect
the end. This shall continue.

Have a look at this
http://mina.apache.org/report/trunk/xref/org/apache/mina/filter/codec/prefixedstring/PrefixedStringDecoder.html

>
> What is your strategy for that? Make every packet *exactly* 1024 Bytes and
> cut everything again on the Receivers end?
> Or am I on the complete wrong lane?

Depends on what you need. You are on track, and hope you shall
complete your implementation soon.
Please do explore the examples, along with MINA Codec package
(http://mina.apache.org/report/trunk/xref/org/apache/mina/filter/codec/package-frame.html).

By any chance are you exploring this to be used in openmeetings?

-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Reply via email to