You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Sebastian Wagner <se...@gmail.com> on 2009/09/14 17:52:16 UTC
how to prevent or use the TCP-Socket (or the network layer) when it
wraps/cuts packets together?
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.
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?
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?
thanks,
sebastian
--
Sebastian Wagner
http://www.webbase-design.de
http://openmeetings.googlecode.com
http://www.laszlo-forum.de
seba.wagner@gmail.com
Re: how to prevent or use the TCP-Socket (or the network layer) when
it wraps/cuts packets together?
Posted by Sebastian Wagner <se...@gmail.com>.
I use this class to make a single Packet:
http://pastebin.ch/4245
thanks,
sebastian
2009/9/14 Leandro Cruz <le...@gmail.com>
> Are you using any protocol codec factory?How do you format your
> bytes/messages before writing them to the socket?
>
> --
> Leandro Rodrigo Saad Cruz
>
>
> On Mon, Sep 14, 2009 at 12:52 PM, Sebastian Wagner <seba.wagner@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.
> >
> >
> > 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?
> >
> > 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?
> >
> >
> > thanks,
> > sebastian
> >
> >
> > --
> > Sebastian Wagner
> > http://www.webbase-design.de
> > http://openmeetings.googlecode.com
> > http://www.laszlo-forum.de
> > seba.wagner@gmail.com
> >
>
--
Sebastian Wagner
http://www.webbase-design.de
http://openmeetings.googlecode.com
http://www.laszlo-forum.de
seba.wagner@gmail.com
Re: how to prevent or use the TCP-Socket (or the network layer) when
it wraps/cuts packets together?
Posted by Leandro Cruz <le...@gmail.com>.
Are you using any protocol codec factory?How do you format your
bytes/messages before writing them to the socket?
--
Leandro Rodrigo Saad Cruz
On Mon, Sep 14, 2009 at 12:52 PM, Sebastian Wagner <se...@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.
>
>
> 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?
>
> 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?
>
>
> thanks,
> sebastian
>
>
> --
> Sebastian Wagner
> http://www.webbase-design.de
> http://openmeetings.googlecode.com
> http://www.laszlo-forum.de
> seba.wagner@gmail.com
>
Re: how to prevent or use the TCP-Socket (or the network layer) when
it wraps/cuts packets together?
Posted by Ashish <pa...@gmail.com>.
>
> Yes the code I am working on will go into the OpenMeetings Project. I am
> working on this to improve the Desktop Sharing and Recording.
Great :-) Since you are using Red5, you already have MINA in your project.
Have starred the project. Will try to keep up with its development.
thanks
ashish
Re: how to prevent or use the TCP-Socket (or the network layer) when
it wraps/cuts packets together?
Posted by Ashish <pa...@gmail.com>.
>
> Yes the code I am working on will go into the OpenMeetings Project. I am
> working on this to improve the Desktop Sharing and Recording.
>
Forgot to provide link to codec page. Refer this page
http://mina.apache.org/codec-repository.html, to see what all codec
are available. This may possibly help you in implementing your own
codec.
thanks
ashish
Re: how to prevent or use the TCP-Socket (or the network layer) when
it wraps/cuts packets together?
Posted by Sebastian Wagner <se...@gmail.com>.
you're right, I think I run exactly into the pitfall explained at
http://mina.apache.org/tutorial-on-protocolcodecfilter.html:
*TCP guarantees delivery of all packets in the correct order.* But there is
no guarantee that one write operation on the sender-side will result in one
read event on the receiving side.**
I think thats my problem
Yes the code I am working on will go into the OpenMeetings Project. I am
working on this to improve the Desktop Sharing and Recording.
sebastian
2009/9/14 Ashish <pa...@gmail.com>
> On Mon, Sep 14, 2009 at 9:22 PM, Sebastian Wagner <se...@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
>
--
Sebastian Wagner
http://www.webbase-design.de
http://openmeetings.googlecode.com
http://www.laszlo-forum.de
seba.wagner@gmail.com
Re: how to prevent or use the TCP-Socket (or the network layer) when
it wraps/cuts packets together?
Posted by Ashish <pa...@gmail.com>.
On Mon, Sep 14, 2009 at 9:22 PM, Sebastian Wagner <se...@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