Can TCP be implemented via UDP?

后端 未结 9 1756
后悔当初
后悔当初 2021-01-31 08:45

I had a strange idea. I heard of software which from my understanding uses UDP to transfer files decreasing the overhead found in TCP packets.

If my app requires TCP and

相关标签:
9条回答
  • 2021-01-31 09:11

    You can simulate something like a connection over UDP, and you as well can add reliability checks and ordering and retransmission and so on. - but then, it still isn't TCP, it just acts the way.

    Of course, one of the ends can be a kind of "hub" or "proxy" which does an adaption. Then you don't have a 2-end solution, but in fact a 4 end solution - one pair with "real" TCP and the other with the "self-knitted" "TCP" - which you put together with an appropriately crafted program.

    0 讨论(0)
  • 2021-01-31 09:14

    Both TCP and UDP are built on top of the IP, but the TCP uses different packet structure and at the layer-2 it is not possible to mimic the TCP using UDP packets.

    Of course, if you have the control on both the source and destination, then it is possible to create a reliable UDP tunnel for the TCP packets. This would require some internal information (packet number, ack/nack flags) in the body of the UDP packet.

    There is an interesting project http://udt.sourceforge.net/

    It is a broadcast-capable reliable file transfer mechanism built on top the UDP.

    0 讨论(0)
  • 2021-01-31 09:16

    If my app requires TCP and my LAN has software setup to communicate with another datacenter on the other side of the coast with software setup on their end. Would it be possible to send the actual data via UDP but than simulating TCP on both ends?

    No. A UDP socket is in a different namespace from a TCP socket. You will be unable to write UDP at one end and send or receive TCP at the other end. TCP and UDP are peer protocols; both exist at the layer above IP. You can't use one to spoof the other.

    0 讨论(0)
  • 2021-01-31 09:16

    Hmm, I believe so. You'd need to use a proxy at both ends, but it should be possible.

    The biggest problem you are going to run into is that UDP is designed with the idea that you don't care if some of the packets don't ever make it to the other end.

    Here's a link with some more info:

    http://www.cyberciti.biz/faq/key-differences-between-tcp-and-udp-protocols/

    IMHO, it's not a good idea to transmit files via UDP.

    0 讨论(0)
  • 2021-01-31 09:17

    PseudoTCP is a protocol which implements TCP algorithms on top of the UDP. It was introduced since the NAT traversal for TCP is much more complicated than UDP. But some P2P applications do need a reliable data transfer among nodes.

    So far as I know, there are two PseudoTCP variations: Libjingle and Libnice.Libjingle is an open source library from google which was initially for gtalk. You could take a look at file sharing example from libjingle: https://developers.google.com/talk/libjingle/file_share. Recently, Chrome desktop also use PseudoTCP implementation from libjingle for reliable connections.

    0 讨论(0)
  • 2021-01-31 09:19

    Yes, you can develop a protocol on UDP that simulates TCP. However, if you simulated TCP fully, it would technically have more overhead. Because TCP is implement as the packet and your simulated TCP is implemented in the body of the packet.

    If you only need one or two features of TCP (such as basic ordering), then implementing it in UDP is useful.

    Halo uses 2-3 (IIRC) UDP protocols that simulate different features of TCP, then full fledged TCP for initializing game-states. I Shot You First Networking, GDC publication

    For example, in one case, they send 3 duplicate UDP packets to overcome packet loss.

    If you control the software on both ends, and it is cost-effective to build your own protocol, then UDP can be versatile.

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