Broadcast like UDP with the reliability of TCP

后端 未结 16 1422
陌清茗
陌清茗 2021-01-30 02:30

I\'m working on a .net solution that is run completely inside a single network. When users make a change to the system, I want to launch an announcement and have everyone else h

相关标签:
16条回答
  • 2021-01-30 03:11

    You'd definitely want to look into Pragmatic General Multicast:

    While TCP uses ACKs to acknowledge groups of packets sent (something that would be uneconomical over multicast), PGM uses the concept of Negative Acknowledgements (NAKs).

    For further G-diving, the term you're looking for is reliable multicast. Also take a look at Multipath TCP.

    0 讨论(0)
  • 2021-01-30 03:13

    I think there are three options, broadly speaking:

    1. Instead of broadcasting UDP, you could create an entity (a thread, process, server, service, or whatever the thing is that exists in your solution) that keeps a list of subscribers and sends unicast UDP messages to them.
    2. Use UDP multicast, but you'll have to write some sort of mechanism that would take care of reliable delivery for you (i.e., retries, timeouts, etc). This also means you have to get a reply from your clients.
    3. If you're not afraid of experimental transport protocols, you might look here for suggestions.,
    0 讨论(0)
  • 2021-01-30 03:15

    Create a TCP server. Have each client connect. In your TCP protocol with the clients, create each packet with a 2-byte prefix of the total size of the following message.

    Clients then call read(max_size=2) on the socket to determine the size of the next message, and then read(max_size=s) to collect the message.

    You get reliable, ordered messages, simple. You don't need a messaging framework for this one.

    0 讨论(0)
  • 2021-01-30 03:16

    Why build something from scratch if you can use library? Especially for such small project?

    Try use Emcaster which itself using reliable multicast messaging - PGM, is written in .NET and with full source. You will get nice pub/sub engine with topic filtering readily available. Or you can learn from code how to do it and base your own extension on it.

    0 讨论(0)
  • 2021-01-30 03:23

    I think the most irritating feature of TCP in these scenarios is the ability/way of sorting incoming packets to their original order - the concept of a stream. You cannot read a byte until the byte before it arrived.

    If you can live without it, you have your chance to have your protocol, fast and reliable, but not for ordering of packets! It's simply impossible to manage both of them, because you cannot order your bytes until you receive an other copy of a lost packet, that's the main tradeoff.

    0 讨论(0)
  • 2021-01-30 03:26

    You might want to look into RFC 3208 "PGM Reliable Transport Protocol Specification".

    Here is the abstract:

    Pragmatic General Multicast (PGM) is a reliable multicast transport
    protocol for applications that require ordered or unordered,
    duplicate-free, multicast data delivery from multiple sources to
    multiple receivers. PGM guarantees that a receiver in the group either receives all data packets from transmissions and repairs, or is able to detect unrecoverable data packet loss. PGM is specifically intended as a workable solution for multicast applications with basic reliability requirements. Its central design goal is simplicity of operation with due regard for scalability and network efficiency.

    0 讨论(0)
提交回复
热议问题