views:

212

answers:

3

Hello All.

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 is the latency.

I understand TCP, UDP are the popular ones. TCP is reliable but slower than UDP while UDP is not safe and I have to implement my own fault-handling codes.

I am just wondering are there any other protocols I can follow to send/receive small data between two normal home PCs?

by the term of normal home PCs, I assume that they have normal broadband (512kbps - 2Mkbps) and all around the world (maybe between US and Japan).

Another BIG question is that:

If I ping from one pc (in UK) to another (in Japan), I get 300ms latency. Is that possible to find one protocol or use TCP/UDP to send/receive 1KB data below this 300ms latency?? or ping should be the fastest way to know the lowest latency between two end points??

Thanks

A: 

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.

Reed Copsey
+1  A: 

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 pachket 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 ligjt and the congestion of the edge-routers.

John Gietzen
Thanks for the reply. How to utilise a TCP header or UDP header?
Jack
@Jack: You should research that, and come back and ask a new question if you are stumped.
John Gietzen
A: 

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.

Igor Korkhov
Ok, down-vote removed.
John Gietzen
@John Gietzen: that is exactly what is written. Yes, I automatically typed "TCP/IP" (and this is not true, of course), but 10 seconds later I edited my answer.
Igor Korkhov
@igor: I saw that and removed the down-vote.
John Gietzen