Can TCP be implemented via UDP?

2019-03-08 19:47发布

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 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?

I vaguely remember something about 7 layers but i am unsure if protocol was one of the layers and i am unsure if TCP is impossible to simulate/implement perfectly when using UDP across the network. Does anyone have any ideas or information about such projects?

9条回答
神经病院院长
2楼-- · 2019-03-08 20:22

If you're asking if you can use UDP as a Layer 2, then the answer is yes, sort of. There are various protocols that allow you to create a tunnel to another network using a UDP transport, such as L2TP and even IPsec (with NAT traversal). You could also do it at the application layer.

If you're asking if TCP can be implemented in UDP, the answer is no. First, TCP packets and UDP packets have an incompatible format. Second, TCP and UDP have different protocol numbers (seen in the IP header) which means that TCP traffic destined for a UDP port would not be passed to the correct upper-layer protocol.

查看更多
姐就是有狂的资本
3楼-- · 2019-03-08 20:23

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.

查看更多
我命由我不由天
4楼-- · 2019-03-08 20:27

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.

查看更多
登录 后发表回答