Название-Сеть в Играх 2006год_Язык-Eng
.pdf
204 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games
Figure 12.9 Using Rcon from within Half-Life 2 client console to access a server at 192.168.10.1: 27015 (client logged in from 192.168.10.99)
an error message because the server requires an rcon password. So you set the rcon password with ‘rcon password mypass’, and then repeat the ‘rcon status’ command. Now you receive the server’s console output back (seeing that there’s one person, the author, on this LAN-only server). You can issue other commands too, such as ‘rcon sv lan’ to report the status of the LAN-only flag.
You only need to enter the ‘rconpassword’ line once, then use multiple ‘rcon’ commands as necessary.
HL2’s rcon service runs over TCP to the server’s game-play port (27015, unless ‘-port’ was specified when the server started up). Unfortunately, the rcon mechanism has an important weakness. Every time an rcon command is executed, the client sends the rconpassword in clear-text over the Internet along with the requested server-side command. Anyone sniffing the IP network between your client and your server will easily be able to extract your rcon password and begin remotely interfering with your server. For this reason, rcon should only be used from client machines that have direct IP connectivity to the server (or at least have connectivity over a path that can be trusted).
At the time of writing XQF [XQF05] did not support ‘rcon’ to HL2MP servers, although this may well have been added subsequently.
12.3.7 Network Performance Configuration
Table 12.4 lists a number of server-side variables and settings affecting the network traffic generated by your server.
Server-side variables can be set on the command line or in server.cfg file (except for ‘-tickrate’, which must be set on the command line).
Table 12.5 lists a number of client-side variables and settings affecting the network traffic generated by your server.
The settings in Table 12.4 on the server side can override settings in Table 12.5 requested at the client side. Chapter 10 provides a discussion of the underlying principles.
12.3.8 Running a Windows Server
In principle, you can start a ‘listen server’ from within a Half-Life 2 client on a Windows machine. However, this is really only suitable for private, local games. To host a public
Setting Up Online FPS Game Servers |
205 |
|||||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
Table 12.4 Server-side settings controlling network traffic |
|
|
|
||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Variable |
|
|
|
|
|
Role |
Default |
||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sv minrate |
|
Lower bound on ‘rate’ (the maximum |
0 |
|
|
||||||||
|
|
|
|
|
|
|
|
snapshot rate in bytes/second requested |
|
|
|
|||||
|
|
|
|
|
|
|
|
by the client) |
|
|
|
|||||
|
|
|
sv maxrate |
|
Upper bound on ‘rate’ (the maximum |
0 (unlimited) |
||||||||||
|
|
|
|
|
|
|
|
snapshot rate in bytes/second requested |
|
|
|
|||||
|
|
|
|
|
|
|
|
by the client) |
|
|
|
|||||
|
|
|
sv |
minupdaterate |
Lower bound on cl updaterate (the |
10 |
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client-side requested snapshot rate). |
|
|
|
|||||
|
|
|
|
|
|
|
|
Server will send at this rate if |
|
|
|
|||||
|
|
|
|
|
|
|
|
cl updaterate is too low |
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
sv |
maxupdaterate |
Upper bound on cl updaterate (the |
60 |
|
|
||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|||
|
|
|
|
|
|
|
|
client-side requested snapshot rate) |
|
|
|
|||||
|
|
|
-tickrate |
|
Sets the server’s internal tick rate (in ticks |
66 |
|
|
||||||||
|
|
|
|
|
|
|
|
per second). Can only be set on the |
|
|
|
|||||
|
|
|
|
|
|
|
|
command line |
|
|
|
|||||
|
|
|
|
|
|
|
|
|||||||||
|
Table 12.5 Client-side settings controlling network traffic |
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|||||||
|
Variable |
|
|
|
Role |
Default |
||||||||||
|
|
|
|
|
|
|
|
|
||||||||
|
rate |
|
|
Maximum data rate (in bytes per second) |
(depends on client |
|||||||||||
|
|
|
|
|
|
|
|
the client wishes to receive snapshot data |
‘network’ setting) |
|||||||
|
|
|
|
|
|
|
|
from the server |
|
|
|
|||||
|
cl |
|
cmdrate |
Rate (in packets per second) at which client |
30 |
|
|
|||||||||
|
|
|
|
|
|
|
|
will send command packets to the server |
|
|
|
|||||
|
cl |
|
updaterate |
Rate (in packets per second) at which client |
20 |
|
|
|||||||||
|
|
|
|
|
|
|
|
wishes to receive snapshots from server |
|
|
|
|||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server on a Windows machine, you should download the Windows equivalent of the dedicated Linux server described in this chapter. Most of the differences exist only in the name of the executable used to launch the server, and the syntax of filenames and pathnames.
Valve provides an automatic update tool called hldsupdatetool.exe, located at http:// www. steampowered.com/download/hldsupdatetool.exe. Download this tool and launch it without any options. It will update itself, and is then ready to be used to pull down the server itself. You will be prompted by hldsupdatetool.exe to specify a directory into which you would like to store your dedicated server. Two obvious choices would be C:\srcds\ or C:\hl2mp\ – it is up to you. Once the tool has updated itself, launch it again with the same options as for the Linux updater, e.g.:
hldsupdatetool.exe -command update -game hl2mp -dir c:\hl2server
(The primary difference is how we locate and specify directories.)
206 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games
Once all files have been downloaded, you can launch the dedicated server in a similar fashion to the Linux server. For example, to launch HL2MP with map dm overwatch, LAN-only and rcon password of ‘mypass’, use this line:
c:\hl2server\srcds.exe -game hl2mp -console +map dm_overwatch +sv_lan 1 +rcon_password mypass
You may find it useful to create a short batch file that loops forever, automatically restarting the server if it crashes for some reason.
12.3.9 Further Reading
It is not really within the scope of this book to provide a tutorial on tweaking server configuration options, as most of them relate to HL2MP game-play, in-game physics, and the VAC system. There are numerous sites around the Internet with suggestions on how to tweak game-play and add ‘mods’ (modifications). A good place to start would be Valve’s own Steam Forums at http://steampowered.com.
12.4 Configuring FreeBSD’s Linux-compatibility Mode
FreeBSD is popular in many server configurations. With its Linux-compatibility mode FreeBSD makes a good platform for hosting dedicated game servers. In this section, we will discuss two key steps that must be performed before running a dedicated Linux game server under FreeBSD. The first is to ensure the correct Linux-compatibility libraries are installed. The second is to ensure the FreeBSD kernel is ‘ticking’ fast enough.
12.4.1 Installing the Correct Linux-compatibility Libraries
Details of FreeBSD’s Linux binary compatibility are described in Chapter 10 of the online FreeBSD documentation [FBLINUX] and will not be repeated here. FreeBSD 5.4 was current at the time of writing, and a number of Linux-compatibility options exist.
Linux binary compatibility means that a Linux application (an ‘executable’ binary file previously compiled under Linux) runs natively on a FreeBSD host. There is no processor emulation occurring – compatibility is implemented within the FreeBSD kernel’s loader function. When a Linux application is launched, the FreeBSD kernel will re-write sections of the application’s internal executable code before starting the program. (The Linux application’s calls into the Linux kernel for things like disk access, network access and memory management are replaced with equivalent calls into the FreeBSD kernel.) After the re-writes are complete, the application begins execution as though nothing has happened. Many standard Linux libraries are installed under ‘/compat/linux’ on the FreeBSD host, enabling dynamically linked applications to operate properly.
The main point to recognise is that Linux compatibility is easily configured by installing a ‘Port’ or ‘Package’ onto your existing FreeBSD system. A number of different compatibility environments are available, reflecting some different Linux distributions. If you want to run Half-Life 2 dedicated server you will need the libraries based on Red Hat Linux 8.0, rather than the default (as of FreeBSD 5.4) based on Red Hat Linux 7.x.
Setting Up Online FPS Game Servers |
207 |
|
|
If you are already connected to the Internet and logged in as root, simply execute:
% pkg_add -r linux_base-8
All the necessary files will be automatically retrieved over the Internet to install a compatibility environment based on Red Hat Linux 8.0. This package will also support the WET dedicated Linux server.
So, if you have a FreeBSD server available it is entirely reasonable to host Linux-based dedicated game servers on this machine.
12.4.2 Ensuring the Kernel ‘Ticks’ Fast Enough
Most operating systems have some form of internal ‘software clock’ ticking along at a fixed rate, used by programs that wish to regularly ‘wake up and do something’. This is true of Windows, Linux and FreeBSD. (This tick rate is not to be confused with a game server’s own internal tick rate, discussed earlier in the book. The two tick rates can be entirely different.)
At least up until FreeBSD 5.4, the kernel’s own tick timer defaulted to 100 ticks per second. Given the way dedicated game servers are written, this tick rate is way too low.
Fortunately, the FreeBSD tick rate can be adjusted without recompiling the kernel. Simply add the following line to the file /boot/loader.conf and reboot the machine.
kern.hz="1000"
Once rebooted the kernel will be ticking 1000 times a second, a much better rate when hosting game servers. (You could even set it faster – the limit really depends on how much CPU load your machine can tolerate. There is a small, fixed amount of processing overhead incurred for each tick of the kernel’s clock, regardless of what all the applications are doing.)
You can check or confirm your kernel’s current tick rate with the following command:
sysctl kern.clockrate
Increasing the kernel’s own tick rate is important for any system hosting an online dedicated game server, whether it be Linux, FreeBSD or Windows. The simple fact is that a game server’s own activities are generally limited by the kernel’s own tick timer.
For example, an HL2MP dedicated server on a standard FreeBSD 5.4 host is limited to sending at most (kern.clockrate/2) snapshots per second to each client, regardless of the game server’s own tickrate (which defaults to 66). Given a default kernel tick rate of 100, your HL2MP server would be unable to send more than 50 snapshots per second to each client. The game server’s own default sv maxupdaterate setting of 60, and default tick rate of 66, are rendered meaningless.
Running a FreeBSD server host at, for example, 150 ticks per second would limit the HL2MP server to 75 snapshots per second to each client. Setting the kernel’s tick rate to 1000 ensures that sv maxupdaterate, cl updaterate and the HL2MP game server’s own tickrate become the proper limiting factors.
In summary: the maximum snapshots per second rate to each client is the smaller of sv maxupdaterate, the game server’s tickrate, and half the underlying operating system’s software tick rate. It is essential to reconfigure your FreeBSD’s default 100 ticks per second to something more like 1000 ticks per second.
208 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games
References
[DUMMYNET] dummynet, “Dummynet – Traffic Shaper, Bandwidth Manager and Delay Emulator”, http:// www.FreeBSD.org/cgi/man.cgi?query=dummynet&sektion=4, 2004.
[ETPRO05] ET Pro, “ET Pro – The Enemy Territory Competition Mod”, http://etpro.anime.net/.
[FBLINUX] FreeBSD Handbook, “Chapter 10 Linux Binary Compatibility”, (http://www.freebsd.org/doc/ en US.ISO8859-1/books/handbook), 2005.
[HALFLIFE2004] H A L F – L I F E 2, http://half-life2.com, 2004.
[LEE2005] S. Zander, I. Leeder and G. Armitage, “Achieving Fairness in Multiplayer Network Games through Automated Latency Balancing”, ACM SIGCHI International Conference on Advances in Computer Entertainment Technology (ACE2005), Valencia,Spain, June 2005.
[PBUSTER] PunkBuster, “PunkBuster Online Countermeasures,” http://www.punkbuster.com/, Accessed 2006. [RIZ1997] L. Rizzo, “Dummynet: A simple approach to the evaluation of network protocols”, ACM Computer
Communication Review, Vol. 27, No. 1, pp. 31–41, 1997. [SSH2005] OpenSSH, http://www.openssh.org, 2005.
[STEAM2004] Welcome to Steam, http://www.steampowered.com/, 2004. [VALV2005] Valve, http://www.valvesoftware.com, 2005.
[WET2005] Wolfenstein, http://games.activision.com/games/wolfenstein as of October 2005. [XQF05] XQF Game Server Browser, http://www.linuxgames.com/xqf/index.shtml, 2005.
13
Conclusion
By the end of a book both the authors and readers realise there is much more ‘out there’ that we have not, and simply could not, cover. We can be sure of one thing in this field of networking and online games – the specific technologies and games will continue to evolve rapidly and have a deeper impact on society, but the underlying issues and principles will remain. To that end we conclude with pointers to a small collection of online resources – places to find the latest news, more technical details, and forums discussing game and networking technologies.
13.1 Networking Fundamentals
We have provided an introduction to TCP, UDP and IP networking in this book, without stressing too much on the details. A number of books are available that focus specifically on IP networking issues, including the following well-known texts:
•“Internetworking with TCP/IP Vol. I: Principles, Protocols, and Architecture” by Douglas E. Comer (5th edition June 30, 2005) Prentice Hall; ISBN: 0131876716
•“TCP/IP Illustrated, Volume 1: The Protocols” by W. Richard Stevens (January 1994) Addison-Wesley Pub Co; ISBN: 0201633469
•“Computer Networks” by Andrew S. Tanenbaum (4th edition August 9, 2002) Prentice Hall; ISBN: 0130661023
Various sources of online information exist. The Internet Engineering Task Force (IETF) and Institute of Electrical and Electronic Engineers (IEEE) both have websites where you can obtain copies of their standards documents describing a wide variety of Internet and link layer technologies.
•Internet Engineering Task Force (IETF)
◦http://www.ietf.org
•Institute of Electrical and Electronic Engineers (IEEE)
◦http://www.ieee.org
•IEEE Working Group for Wireless LANs
◦http://www.ieee802.org/11
Networking and Online Games: Understanding and Engineering Multiplayer Internet Games
Grenville Armitage, Mark Claypool, Philip Branch 2006 John Wiley & Sons, Ltd
210 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games
IETF documents crop up in a number of chapters, known as ‘RFCs’ (from their traditional name, ‘Requests for Comment’). A somewhat user-unfriendly search tool is available at http://www.ietf.org/rfc.html (you must know the RFC number), or go to http://www.rfceditor.org/to search on various text fields.
The Association for Computing Machinery (ACM, http://www.acm.org) also provides a wide range of publications covering networking and computing topics. A number of ACM publications and special interest group (SIG) journals and conference proceedings touch on issues relevant to networked game development. These include:
•SIGCHI (http://www.acm.org/sigchi)
•Computers In Entertainment (http://www.acm.org/pubs/cie.html)
•SIGCOMM (http://www.acm.org/sigcomm)
•SIGGRAPH (http://www.siggraph.org/)
13.2 Game Technologies and Development
A number of online websites and resources exist, covering various aspects of game distribution, research, development and design. These include the following:
•http://www.theesa.com/
◦Entertainment Software Association: ‘The ESA works with the government at all levels to make the voice of its members heard on a wide range of crucial legislative and public policy issues, including intellectual property protection, content regulation, and efforts to regulate the Internet’.
•http://www.gamasutra.com/
◦Gamasutra: ‘The Art & Business of making games’. Currently an excellent and active site for all things to do with game development, the games industry and game technology.
•http://www.gamespy.com/
◦GameSpy: hosts a wide variety of game-specific forums, file download areas, and so on (consoles and PCs).
•http://www.igda.org/
◦‘The International Game Developers Association is a non-profit professional membership organization that advocates globally on issues related to digital game creation’.
•http://www.gamedev.net/
◦GameDev.net: ‘all your game development needs’. Another site with information for game developers.
•http://www.gdconf.com/
◦Game Developer’s Conference
•http://www.gamespot.com/
◦Gamespot.
•http://www.3dgamers.com/
◦3D Gamers (news, downloads)
•http://www.digiplay.org.uk/
◦Digiplay Initiative: ‘Research into computer gamers and the industry they are part of’.
Conclusion |
211 |
|
|
13.3 A Note Regarding Online Sources
It has become commonplace to utilise online resources to find answers to questions, example code or opinions on all sorts of topics. Search engines, such as Google (www. google.com) and Yahoo (www.yahoo.com), have become an entry point to a vast range of websites with information. Community-edited resources, such as Wikipedia (‘The Free Online Encyclopedia’, www.wikipedia.com), have become fascinating sources of facts and fiction. Information can be of high quality (created by people who care about the accuracy and relevance of their material) or of entirely dubious quality (created by people concerned more with opinion than accuracy, or created months and years in the past and subsequently never updated to reflect a changing reality).
The best sources of information are normative – where the website is run by the organisation who created the facts or opinions you wish to read and/or cite. Secondary sources, those who summarise or purport to reflect the facts of a situation they did not create or own, can be reliable to a degree. You should always consider carefully the nature of your source’s relationship to the information and facts about which your source purports to report. Where normative sources exist, they should always be utilised in preference to secondary sources. Search engines can be very helpful in locating normative sources for information you may have initially discovered through a secondary source (such as an online newspaper or game developer’s forum).
Keep in mind that web-based content can change in seconds, so the information you saw at a particular URL at time X may have changed when someone else accesses the site sometime later. For example, Wikipedia cautions readers to keep track of precisely when they saw a particular version of any given article, because they can change so frequently (http://en.wikipedia.org/wiki/Wikipedia:Citing Wikipedia). When following an online reference given by someone else, remember that the version you see now may differ from what your secondary source saw in the past.
Index
3G, 132–134, 177
802.11b, 31, 35, 129, 131, 135 802.11e, 131, 179
802.11g, 129, 135 802.15, 177
Access network
data link layer, 125 physical layer, 124–125
Access Point (AP), 31, 129 Address resolution, 56–58
Address resolution protocol (ARP), 56, 141
ADSL network, 127–128 Age of Mythology, 183 Arcade games, 9–10 ARQuake, 34, 37
Artificial network condition considerations for creating, 107–108
Asheron’s Call, 22
Asymmetric Digital Subscriber Line (ADSL), 64, 128
Asynchronous Transfer Mode (ATM), 72 Atari, 10
Atari Football, 10
Augmented Reality (AR), 34–39, 182 Aura, 96
Autonomous Systems (ASs), 53 Avatar, 5, 89, 93, 109
BATS, 37 Battle.net, 24
Best Effort, 1, 42, 45, 76, 178 Bit error, 75
Blizzard, 22–24
Bluetooth, 2, 34, 125, 129, 134–135, 177 Border Gateway Protocol (BGP), 54
Broadband, 2, 62, 74, 75, 83 modem, 74
router, 73
Broadband Access Network, 121–136, 179
characteristics of, 121–123 role of, 121
Broadcast, 46–47 directed, 51
Byte stuffing, 74
Cable Modem (CM), 64, 73, 122, 124, 126, 127
Cable networks, 125–126 head-end, 125, 126
Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA), 73, 131
Cave, 39 CDMA2000, 132, 133 cdmaOne, 132, 133
Cellular Broadband Networks, 123 Cellular network, 132–134
Cheat, 108–118 client-side, 111–115 network-layer, 115–116 server-side, 109–111
Cheat-mitigation, 108–118 Cheating
methods, classification of, 109 Classless Inter Domain Routing (CIDR),
50 Client-server, 84, 87 Clock
hardware, 152 software, 107, 207
Code Division Multiplexing (CDM), 125
Networking and Online Games: Understanding and Engineering Multiplayer Internet Games
Grenville Armitage, Mark Claypool, Philip Branch 2006 John Wiley & Sons, Ltd
