Lowest Latency small size data Internet transfer protocol? c#

前端 未结 3 844
梦毁少年i
梦毁少年i 2021-01-22 08:59

I am doing a Internet Gaming project which involving keeping sending small size of data (between 1K to 50K) over the Internet between two normal home PCs. The key I care about i

相关标签:
3条回答
  • 2021-01-22 09:08

    If you want to communicate over the Internet you are forced to use IP family of protocols. That doesn't prevent you from creating your own protocol on top of IP, but it won't be faster in terms of latency, of course. All you can do is implement compression in order to minimize payload sent over the wire.

    0 讨论(0)
  • 2021-01-22 09:09

    You will never beat ping commands for latency, since they use ICMP, which is about the most lightweight option out there.

    Typically, for gaming situations, UDP is used, primarily because of the speed involved. With a good broadband connection, TCP should be fine, and will make life easier since you have guarantees about delivery that are otherwise missing from UDP.

    That being said, for gaming purposes, 1K, and especially 50K, is a very large amount of data, especially if this needs to be sent continuously. If you're sending that much data, expect and plan for the latency - often this means anticipating what will happen across the wire, and compensating when the data comes through, instead of waiting on the data to arrive.

    0 讨论(0)
  • 2021-01-22 09:18

    A TCP header is 32 bytes, while a UDP header is only 16 bytes. In addition, since UDP lacks flow control there will never be a case where the client asks the server to slow down. UDP is almost definitely going to be the fastest. An ICMP packet has a header that is 20 bytes, and is probably going to be slightly slower than UDP.

    My official recommendation is to use UDP, with some "dropped packet" detection at the receiving end. This is how all of the Quake games and all of the Half-Life/Source games work.

    On the topic of pinging between UK and Japan, the latency is going to be near identical for any protocol used. Most of that is dictated by the speed of light and the congestion of the edge-routers.

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