aboutsummaryrefslogtreecommitdiff
path: root/pipermail/nel/2001-July/000494.html
blob: 5eb1404dd6e7093afe5b9154e6b431f9fb143e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
 <HEAD>
   <TITLE> [Nel] TCP vs. UDP</TITLE>
   <LINK REL="Index" HREF="index.html" >
   <LINK REL="made" HREF="mailto:svferro%40earthlink.net">
   <LINK REL="Previous"  HREF="000492.html">
   <LINK REL="Next" HREF="000496.html">
 </HEAD>
 <BODY BGCOLOR="#ffffff">
   <H1>[Nel] TCP vs. UDP</H1>
    <B>Sal</B> 
    <A HREF="mailto:svferro%40earthlink.net"
       TITLE="[Nel] TCP vs. UDP">svferro@earthlink.net</A><BR>
    <I>Fri, 6 Jul 2001 18:32:46 -0400</I>
    <P><UL>
        <LI> Previous message: <A HREF="000492.html">[Nel] TCP vs. UDP</A></li>
        <LI> Next message: <A HREF="000496.html">[Nel] TCP vs. UDP</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#494">[ date ]</a>
              <a href="thread.html#494">[ thread ]</a>
              <a href="subject.html#494">[ subject ]</a>
              <a href="author.html#494">[ author ]</a>
         </LI>
       </UL>
    <HR>  
<!--beginarticle-->
<PRE>&gt;<i> In a first step, we would like to know your opinion about this choice. And
</I>&gt;<i> in a next step, we'll do some test about ping/packet lost and so on to
</I>&gt;<i> compare TCP and UDP, and we'll need your help to do that.
</I>&gt;<i>
</I>&gt;<i> Vianney Lecroart
</I>
    I've coded small scale 3d client/server systems in both TCP and UDP
while developing software for Worldforge, and have playtested both systems.
The end result was that UDP gameplay just seemed smoother, especially under
low latency/bad connections.  Even when I had inserted code to purposely
drop packets, gameplay was still surprisingly bearable.

    On my LAN or for persons with fast links to the server TCP was not
really noticeably slower, though.  So with very low latency, and little
packet loss TCP would be the better choice, but unfortunately that isn't the
case for the internet just yet.  A lot of people are behind slow links,
shared internet connections, or in unfortunate locations... for some people
overseas my TCP-based software was almost unplayable, where UDP was still at
least minimally usable.  If you guys do end up benchmarking TCP vs. UDP, be
sure to test over a simulated low-latency, and/or 'noisy' link.  Drop
packets randomly, simulate possible internet conditions.  I'm sure you will
come to the same results I did.

    The majority of problems I've had with UDP are firewall related. And
they were almost all serverside, ie a person trying to run a UDP server
behind a firewall and unable to map ports/etc. to let clients connect.
Clientside, however there was very little trouble, it worked through my
ipmasq firewall without problems, for one, and others had been testing
behind firewalls also.

    However, a bit of 'reinventing TCP' was needed for the reliable data.
This is unavoidable, some messages need to be sent and can't be
ignored/dropped. And I agree that the OS's TCP implementation is probably
more efficient than one drawn up for a video game.  But I don't think using
both UDP and TCP is worth the trouble to gain a reliable data transmission
stream.  I just don't think the performance improvement would be significant
enough to justify the implementation... Let me explain why I think so.

    Now, say you were sending a 10 MB file over the internet to a friend.
_Every_ packet must make it to the peer or the file would be corrupt. Every
packet must be acknowledged somehow, using some crc, sequence number... etc.
I haven't looked at any actual TCP implementation's source code, but I'll
bet it does all sorts of compromising between packet transmission and
acknowledgement frequency,  message sizes, etc. and over the course of
sending 10 Million packets (ok, maybe less for a 10 MB file)  it probably
saves a considerable amount of time over some dumb UDP code that
acknowledges say, every 10 packets or some other simplistic mechanism.

    Yes, in that situation, reinventing TCP would be a bad idea... and yes,
it is definately a better choice than UDP, which in fact is why almost every
internet protocol uses TCP.  But in our case we aren't sending a 10MB file,
we're sending short messages to tell the client/server something important.
ie a 'player X has died' message, which could be maybe a dozen bytes in
size. All the fancy optimization that an OS's TCP stack does over the course
of time wouldn't be of much use here.  Also, in sending a 10MB file you dont
care about latency, and you know what the next few thousand packets are
going to consist of beforehand, whereas in a video game this is not the
case. The optimizations TCP gives you would only take effect if you were
sending large, continuous blocks of data.

    So for the gameplay networking layer I suggest UDP.  The only exception
in my opinion is for things like automatic client-patching, or downloading
of media.  In that case,  having the client make an HTTP connection to a web
server, or something similair is a *much* better choice than using the
'gameplay networking' layer to send this data.

    The software I spoke of here is all in Worldforge's (www.worldforge.org)
CVS repository.  The software I tested with was XClient, and XServer, which
are both in CVS.

    The UDP networking library I created and used in XClient/XServer, which
I recommend taking a look at, is called 'XUDP' (not the library that Dave
posted about, but has the same name :-/) is also in Worldforge CVS. I
extracted the UDP networking code from the GPLed Quake1 src, and converted
it into a general C++ OO UDP networking library. It contains code for both
reliable and unreliable transmission of data.  Credit should go mostly to
John Carmack of Id software for the code. I just abstracted, and tweaked a
bit for use in an MMORPG setting. It might be helpful if you guys decide to
go with UDP for Nel.

    Anyway, sorry for the long winded rant. Hope this helps some, and keep
up the great work!

- Sal





</pre>







<!--endarticle-->
    <HR>
    <P><UL>
        <!--threads-->
	<LI> Previous message: <A HREF="000492.html">[Nel] TCP vs. UDP</A></li>
	<LI> Next message: <A HREF="000496.html">[Nel] TCP vs. UDP</A></li>
         <LI> <B>Messages sorted by:</B> 
              <a href="date.html#494">[ date ]</a>
              <a href="thread.html#494">[ thread ]</a>
              <a href="subject.html#494">[ subject ]</a>
              <a href="author.html#494">[ author ]</a>
         </LI>
       </UL>
</body></html>