You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by oscarcs <os...@hotmail.com> on 2007/12/11 03:51:48 UTC

Many sockets over single socket

I must develop a system made of nodes in a tree layout. Each node (computer)
has many children and only one father. 

Each node sends TCP messages (using a propietary protocol) to the father, an
the father itself must send the messages to the grandfather and so on.

I have been using MINA to solve many of the communications concerns, but now
i have some doubts.

My questions are:

1. Is there a way to simulate at the lowest posible level, many sockets over
a single socket?. I mean, using a single socket to send to the grandfather
all the messages comming from the children, so i can reuse the procotol
logic in all the levels.

2. If not, another aproach would be replicate all the child socktets in all
the levels, so at the upper level i will end with a single machine with too
many sockets. How much is the overhead (in reources or CPU) of using
multiple sockets vs. single socket?. Is there any limit? 

Sorry for my english. 

Thanks in advance.
-- 
View this message in context: http://www.nabble.com/Many-sockets-over-single-socket-tp14266741s16868p14266741.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Many sockets over single socket

Posted by oscarcs <os...@hotmail.com>.
Each child connect to the father on the same port, but the problem isn't in
the father as the server, the problem is in the father as a client to the
grandfather.

Then i must decide use one socket for each child to send the data received
from them to the grandfather and reuse the protocol logic, or implement a
new protocol to send all the children messages to the grandfather over one
single socket.

The second case is more complex because i must implement a new protocol that
allows multiplexing messages from the children, and the protocol involves
some sinchronization to know what message to send next on after
reconnection.

The first case is more simple but i am afraid that so many sockets at the
top level could be a problem on terms of memory and CPU resources and,
perhaps, network traffic (I am wondering how much).

The third solution is an hibrid: many "virtual" sockets over a single real
socket. This allows using one single socket but reusing the protocol. 

To do that, the best approach could be the lower layer of the communications
(MINA) using a single real socket but simulating multiple "virtual" sockets
at the upper layer (protocol). So, for example, when MINA detects the
disconnection of the real socket, fires many "socketClosed" callbacks, one
for each "virtual socket". 


elihusmails wrote:
> 
> Are the fathers listening on the same port for the children?  Or does each
> child connect to the father on a different port?
> 
> 
> On Dec 10, 2007 9:51 PM, oscarcs <os...@hotmail.com> wrote:
> 
>>
>> I must develop a system made of nodes in a tree layout. Each node
>> (computer)
>> has many children and only one father.
>>
>> Each node sends TCP messages (using a propietary protocol) to the father,
>> an
>> the father itself must send the messages to the grandfather and so on.
>>
>> I have been using MINA to solve many of the communications concerns, but
>> now
>> i have some doubts.
>>
>> My questions are:
>>
>> 1. Is there a way to simulate at the lowest posible level, many sockets
>> over
>> a single socket?. I mean, using a single socket to send to the
>> grandfather
>> all the messages comming from the children, so i can reuse the procotol
>> logic in all the levels.
>>
>> 2. If not, another aproach would be replicate all the child socktets in
>> all
>> the levels, so at the upper level i will end with a single machine with
>> too
>> many sockets. How much is the overhead (in reources or CPU) of using
>> multiple sockets vs. single socket?. Is there any limit?
>>
>> Sorry for my english.
>>
>> Thanks in advance.
>> --
>> View this message in context:
>> http://www.nabble.com/Many-sockets-over-single-socket-tp14266741s16868p14266741.html
>> Sent from the Apache MINA Support Forum mailing list archive at
>> Nabble.com
>> .
>>
>>
> 
> 
> -- 
> --------------------------------
> The adjuration to be "normal" seems shockingly repellent to me; I see
> neither hope nor comfort in sinking to that low level. I think it is
> ignorance that makes people think of abnormality only with horror and
> allows
> them to remain undismayed at the proximity of "normal" to average and
> mediocre. For surely anyone who achieves anything is, essentially,
> abnormal.
>     Dr. Karl Menninger
> 
> 

-- 
View this message in context: http://www.nabble.com/Many-sockets-over-single-socket-tp14266741s16868p14282909.html
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Many sockets over single socket

Posted by Mark <el...@gmail.com>.
Are the fathers listening on the same port for the children?  Or does each
child connect to the father on a different port?


On Dec 10, 2007 9:51 PM, oscarcs <os...@hotmail.com> wrote:

>
> I must develop a system made of nodes in a tree layout. Each node
> (computer)
> has many children and only one father.
>
> Each node sends TCP messages (using a propietary protocol) to the father,
> an
> the father itself must send the messages to the grandfather and so on.
>
> I have been using MINA to solve many of the communications concerns, but
> now
> i have some doubts.
>
> My questions are:
>
> 1. Is there a way to simulate at the lowest posible level, many sockets
> over
> a single socket?. I mean, using a single socket to send to the grandfather
> all the messages comming from the children, so i can reuse the procotol
> logic in all the levels.
>
> 2. If not, another aproach would be replicate all the child socktets in
> all
> the levels, so at the upper level i will end with a single machine with
> too
> many sockets. How much is the overhead (in reources or CPU) of using
> multiple sockets vs. single socket?. Is there any limit?
>
> Sorry for my english.
>
> Thanks in advance.
> --
> View this message in context:
> http://www.nabble.com/Many-sockets-over-single-socket-tp14266741s16868p14266741.html
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>


-- 
--------------------------------
The adjuration to be "normal" seems shockingly repellent to me; I see
neither hope nor comfort in sinking to that low level. I think it is
ignorance that makes people think of abnormality only with horror and allows
them to remain undismayed at the proximity of "normal" to average and
mediocre. For surely anyone who achieves anything is, essentially, abnormal.
    Dr. Karl Menninger

Re: Many sockets over single socket

Posted by Eero Nevalainen <ee...@indagon.com>.
Trustin Lee wrote:
> On Dec 11, 2007 11:51 AM, oscarcs <os...@hotmail.com> wrote:
>> I must develop a system made of nodes in a tree layout. Each node (computer)
>> has many children and only one father.
>>
>> Each node sends TCP messages (using a propietary protocol) to the father, an
>> the father itself must send the messages to the grandfather and so on.
>>
>> I have been using MINA to solve many of the communications concerns, but now
>> i have some doubts.
>>
>> My questions are:
>>
>> 1. Is there a way to simulate at the lowest posible level, many sockets over
>> a single socket?. I mean, using a single socket to send to the grandfather
>> all the messages comming from the children, so i can reuse the procotol
>> logic in all the levels.
> 
> Yes.  MINA is all about an abstract API, so you can implement a
> meta-transport that does what you want.
> 
>> 2. If not, another aproach would be replicate all the child socktets in all
>> the levels, so at the upper level i will end with a single machine with too
>> many sockets. How much is the overhead (in reources or CPU) of using
>> multiple sockets vs. single socket?. Is there any limit?
> 
> I'd suggest you open as many sockets as the number of cores of your
> machine at least, and each socket could host multiple sockets.  If you
> can implement a virtual socket, then it shouldn't be that difficult to
> implement.
> 
> It would be really a great addition to MiNA project if such a facility
> is provided out of the box.

Hmm, this sounds very much like SCTP or like BEEP channels. beep4j 
builds on MINA so it might have something similar already implemented.

-Eero

Re: Many sockets over single socket

Posted by Trustin Lee <tr...@gmail.com>.
On Dec 11, 2007 11:51 AM, oscarcs <os...@hotmail.com> wrote:
>
> I must develop a system made of nodes in a tree layout. Each node (computer)
> has many children and only one father.
>
> Each node sends TCP messages (using a propietary protocol) to the father, an
> the father itself must send the messages to the grandfather and so on.
>
> I have been using MINA to solve many of the communications concerns, but now
> i have some doubts.
>
> My questions are:
>
> 1. Is there a way to simulate at the lowest posible level, many sockets over
> a single socket?. I mean, using a single socket to send to the grandfather
> all the messages comming from the children, so i can reuse the procotol
> logic in all the levels.

Yes.  MINA is all about an abstract API, so you can implement a
meta-transport that does what you want.

> 2. If not, another aproach would be replicate all the child socktets in all
> the levels, so at the upper level i will end with a single machine with too
> many sockets. How much is the overhead (in reources or CPU) of using
> multiple sockets vs. single socket?. Is there any limit?

I'd suggest you open as many sockets as the number of cores of your
machine at least, and each socket could host multiple sockets.  If you
can implement a virtual socket, then it shouldn't be that difficult to
implement.

It would be really a great addition to MiNA project if such a facility
is provided out of the box.

> Sorry for my english.

Thanks for your perfect English.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6