TCP multicast and multithreading

拜拜、爱过 提交于 2019-12-18 17:12:39

问题


I need to come up with clients that can multicast to other clients reliably. That implies I'll be using TCP to connect reliably between clients within a multicast group. Doesn't that come up to n^2 number of connections? That seems a little silly to me. Wouldn't/shouldn't there be a way to more easily multicast with reliability?

EDIT: UNIX/C

EDIT: i didn't clarify how multithreading comes into play. but if i was to open up n^2 connections, i figured, i'd be multithreading and that's even more complication than i would want.


回答1:


There are several reliable multicast solutions.

  • DDS (Data distribution service)
  • Norm Protocol
  • PGM

I've tried the first two ones.

Norm is simple, works like standard udp multicast but incorporates nacks... excelent if you do not need more. There are some implementations that aslo support bandwidth adaptation and other improvements.

DDS is a step forward. It's really great (I know the RTI implementation and it works great) and has a lot of capabilities as well as a very good though design. It's based on reliable and fault tolerancy and there's an open implementation.

By the way, at least DDS and NORM do not require n^2 connections. They work like multicast udp.




回答2:


Depending on your target platform....

You could take a look at Pragmatic General Multicast. This is, as I understand, what Microsoft MSMQ and Tibco Rendezvous use and it can be accessed via Winsock (see: http://msdn.microsoft.com/en-us/library/ms740125(VS.85).aspx).




回答3:


You need to take a look at 0MQ which is a high speed Messaging System which has as one of it's abilities reliable multicast using the Pragmatic General Multicast (PGM) using OpenPGM.

There was an article on it recently in lwn.net:

0MQ: A new approach to messaging




回答4:


multicast and TCP are mutually exclusive.

Implementing reliable delivery over UDP is nuts. Nobody does this since 1980s and it is impossible to do as good as any cheap TCP stack, in terms of performance and BW overhead. Correction: sometimes it is done manually, but only over exotic transports, such as extremely long or narrow pipes.

N^2 connections is not very silly. A connection with 1Hz keepalives does not cost much. What costs is the traffic. This is what your design needs to focus on.




回答5:


Sure there is a more efficient way - you stay using UDB, and reimplement reliable sending yourself. Not trivial, though. But at least you only need to keep sent packets ONCE on the sending site.




回答6:


PGM is an option, as mentioned above. The issue we had with it is that if a client can't keep up with reading incoming data, it get's disconnected.

Since we never could reliable guarantee 'fast enough' clients, we've implemented our own reliability protocol on top of UDP multicast. The implementation is not fully generic when it comes to dynamic connects/disconnects, but it might work for you. You can find the implementation here:

http://www.equalizergraphics.com/cgi-bin/viewvc.cgi/trunk/src/lib/net/rspConnection.h?view=markup http://www.equalizergraphics.com/cgi-bin/viewvc.cgi/trunk/src/lib/net/rspConnection.cpp?view=markup




回答7:


Just a thought, but does your work need to be done with a networking protocol. You might also look at implementing this with a message service, with a publish-subscribe based model.

If you do need networking, then you're going to have to deal with either lots of connections, or ensuring delivery yourself. Make very sure of your requirements before going down that road.



来源:https://stackoverflow.com/questions/2453109/tcp-multicast-and-multithreading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!