📄 lag.htm
字号:
<!--Header-->
<HTML>
<HEAD>
<TITLE>GPMega - Multiplayer Section - What is Lag?</TITLE>
<META NAME="DESCRIPTION" CONTENT="An informative overview which answers questions about multiplayer gaming over the internet. It discusses what exactly lag is, what causes it, and factors that contribute to it. Great for an intro to beginning to build a multiplayer game because it highlights what makes all muliplayer gamers mad...LAG!">
</HEAD>
<BODY BGCOLOR=#000000 TEXT=#FFFFFF LINK=#00FF00 VLINK=#00FF00 ALINK=#0000FF>
<!--End Header-->
<!--Advertiser-->
<CENTER>
<TABLE>
<TR>
<TD>
<A HREF="http://www.ugo.com/">
<IMG SRC="/GPMega/ugologo120.gif" BORDER=0 WIDTH=120 HEIGHT=60></A>
</TD>
<TD>
<IMG SRC="/GPMega/sponsored.gif" WIDTH=468 HEIGHT=10><br><br>
<SCRIPT LANGUAGE= "JavaScript">
<!--
var now = new Date();
var random_num = now.getSeconds();
document.write("<A HREF='http://www.ugo.net/RealMedia/ads/click_nx.cgi/www.perplexed.com/GPMega/multiplayer/lag.htm/" + random_num + "/@Top'>");
document.write("<IMG SRC='http://www.ugo.net/RealMedia/ads/adstream_nx.cgi/www.perplexed.com/GPMega/multiplayer/lag.htm/" + random_num + "/@Top' BORDER='0' WIDTH='468' HEIGHT='60'></A>");
//-->
</SCRIPT>
</TD>
</TR>
</TABLE>
</CENTER>
<!--End Advertiser-->
<!--Splitter-->
<BR>
<!--End Splitter-->
<!--Body-->
<FONT SIZE=2 FACE=Helvetica>
<STRONG>
<!--Top Navigation-->
<A NAME="top"></A>
<CENTER>
<TABLE WIDTH=75%>
<TR VALIGN=MIDDLE>
<TD ALIGN=LEFT>
<IMG SRC="gradsplit2.jpg" WIDTH=100% HEIGHT=1><BR><BR>
<A HREF="http://www.perplexed.com/GPMega/"><IMG SRC="logo.jpg" BORDER=0 ALT="Home" WIDTH=80 HEIGHT=47 ALIGN=CENTER></A>
<FONT COLOR=#666666 FACE=HELVETICA SIZE=-1><I>
This Article Is Taken From <A HREF="http://www.perplexed.com/GPMega/">The Game Programming MegaSite</A>, A Definitive Resource For Game Developers!
</I></FONT><BR>
<IMG SRC="gradsplit2.jpg" WIDTH=100% HEIGHT=1>
</TD>
</TR>
</TABLE>
</CENTER>
<BR><!--End Top Navigation-->
<!--Title-->
<H3 ALIGN=CENTER><font color="#FFEA00">W</font><font color="#FFD500">h</font><font color="#FFC000">a</font><font color="#FFAB00">t</font><font color="#FF9600"> </font><font color="#FF8100">i</font><font color="#FF6C00">s</font><font color="#FF5700"> </font><font color="#FF4200">L</font><font color="#FF2D00">a</font><font color="#FF1800">g</font><font color="#FF0300">?</font><BR><FONT SIZE=-2>By: <a href="mailto:ghowland@lupinegames.com">Geoff Howland</a></FONT></H3>
<!--End Title-->
<p>Lag is the bane of Internet gameplay, but what is it?
<p>Latency is the proper name for the time it takes a packet of information to
be sent from the sender to the receiver over a network. Lag is what it is generally
called and more specifically when it is noticeable. If the latency is low, you
don't notice any lag, the longer it takes a packet to cross the network, the
more lag you have.
<p>To understand why you have lag you need to understand how information is sent.
<H3><FONT COLOR=YELLOW><I>The Packet</I></FONT></H3>
<p>When information needs to be sent from your computer it first needs to be chopped
up into small pieces, these pieces are called packets. Your computer cant send
all its information at once because you cant be guaranteed that no one else
will try to send information at the same time and cut off your transmission.
Basically networks or any type of computer connection work just like a phone
conversation you would have with a friend. If you both talk at the same time,
its hard to understand what is being said clearly. If one of you talks and the
other listens, then it's easy to understand what each other is saying.
<p>One of the key things to understand about packets is that the longer the packet's
are, the longer it will take to send and the more likely you will be interrupted
by someone else. If you are interrupted you have to wait for a little while,
in which the network controller hopes the interrupting transmission has finished,
and then you send the packet again. When another packet interrupts your packet
it is called a collision.
<p>The more often you have collisions, the more lag you will have and collisions
are extremely common on the Internet as you have billions of packets of information
being sent all over the world, all the time.
<H3><FONT COLOR=YELLOW><I>The Ping</I></FONT></H3>
<p>A "ping" is both a term and a program used to determine how quickly
a packet can go to the destination and the destination can send a response back
that it got the packet, so it is measuring a round trip of information. Ping
times vary tremendously by what type of connection you have to your network,
how close you are to your destination and how much other information is trying
to be sent by other people at the same time.
<p>On a Local Area Network (LAN), that is a system of computers tied together
all in one basic location like a house or office, you can receive extremely
fast responses, usually less then 10 milliseconds if there is not a lot of transfers
happening. In an environment like this you will probably never notice a lag
unless someone starts doing one or more huge file transfers.
<p>If you are connecting to the Internet through a dial-in modem to an ISP (Internet
Server Provider), as most home users are, then you will receive much higher
ping times because your connection is hundreds of times slower than a LAN. Games
are however usually designed so that they will still work well on a dial-up
Internet connection, but there are a lot of factors that go in to the connection
moving smoothly.
<H3><FONT COLOR=YELLOW><I>Connection Speed</I></FONT></H3>
<p>The first thing that will limit your network connection is the speed at which your computer can talk to your ISP. Most modems today are at least 28.8K BAUD to 56K BAUD. BAUD means bits per second, and does not stand for anything, it was named after an engineer name Baudot. A bit is one switch that is either "on" or "off". To have enough information for a single character you need 8 bits, which equal a byte. However, because you are sending the information over a modem, you have to add on extra information so that the receiver knows he is listening to you correctly, so it actually takes 10 bits to send 1 byte. This makes calculating how many bytes you are sending easy however, as you just need to divide 28800 bits/second (28.8K BAUD) by 10 and end up with 2880 bytes per second.
<P>Although you may have a modem that say it is a 56K BAUD modem, it is unlikely you will ever receive rates higher than about 3400 bytes per second. When you do receive more it is usually because your modem is compressing the information sent, and when you download information that is already compressed or is not very compressible, you will not get those extra bursts of speed above about 3400 bytes/second.
<p>Enough of the history lesson, lets get into where this matters: the lag.
<H3><FONT COLOR=YELLOW><I>Birth of Lag: Building the Packet</I></FONT></H3>
<p>The first "bottleneck" where you will have problems sending and receiving information will be your modem. Your modem sends approximately 3400 bytes per second, your game will often update the screen to show you new visual information 30 times per second, or more.
<P>However, it is not necessary to update the network connection this quickly, as real movements and actions do not change as quickly as the eye can detect most often. Normally you will not need to have the network connection updated more than 10 times per second, leaving approximately 340 bytes per update in an ideal environment.
<P>To understand exactly what 340 bytes per update means, you need to understand what kind of information needs to be updated in the game and how many bytes each one of those pieces of information will take.
<P>Say we take a game like Quake, where you are able to turn in different directions, move in different directions, jump and shoot. Lets say we take just this information and try to update it and send it back and forth between the players. I wont bore anyone with more lessons on how computers operate at a low level, so you're just going to have to trust me on the math stuff unless you want to learn about it more or you already know it.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -