Setting Up Online FPS Game Servers purchased copies of Half-Life 2, Counter-Strike:Source, etc., are registered against the player s Steam account. With their Steam account a player can also purchase additional games online without ever holding a CD or DVD again. Installing Half-Life 2 on a home PC involves installing a Steam client that subsequently auto-launches whenever the PC restarts. By making Steam an integral part of the Half- Life 2 experience, Valve also ensure that patches to their flagship games are pushed out as uniformly and expeditiously as possible. In this section, we will discuss the installation and set-up of a dedicated Half-Life 2 multiplayer (HL2MP) server that can be reached by players from around the Internet. 12.3.1 Obtaining and Installing the Linux Dedicated Server Valve s Steam service actually simplifies the steps you need to know for initially installing the dedicated server. For now, we will assume that your intended server host has a keyboard and monitor and is running at least a basic text console (the installer does not use any menus and does not require a GUI). Create (or ask the system administrator to create) a dedicated user account for running the HL2MP server (for example, user name hl 2 and a home directory of /home/hl2/ ). This helps to keep all your HL2MP server activities distinct from other users on the server host. HL2MP does not need root (administrator) privileges to run. For the rest of this description you are assumed to be logged in as the hl 2 user. Figure 12.6 shows the steps for initially retrieving the Steam client. Use the command fetch (or a similar command wget ) to retrieve hldsupdatetool.bin from the main Steam site. Make the file executable ( chmod 755 ), then execute it. This extracts a new executable called steam . Run this once without any command line parameters, and it will automatically update itself over the Internet. If you were to now re-run ./steam without parameters, you would get its usage message on the screen. Figure 12.7 shows the command line you must now use to begin installing the HL2MP server itself. These particular options tell the Steam client to update (and download in its entirety if necessary) the hl2mp server components and place them in directory hl2mp (relative to the current directory, i.e. /home/hl2/hl2mp ). The final line shows you what files and subdirectories have been installed. At the time of writing, the full installation takes around 671 Mbytes of disk space. You can re-run the Steam client at any time to check for updates. Figure 12.8 shows the output when run immediately after our first installation there is nothing to update. (Of course, by the time you read this the specific versions of each component are likely to be different.) /home/hl2% fetch http://www.steampowered.com/download/hldsupdatetool.bin /home/hl2% chmod 755 ./hldsupdatetool.bin /home/hl2% ./hldsupdatetool.bin /home/hl2% ./steam Checking bootstrapper version … Getting version 14 of Steam HLDS Update Tool Downloading.. .. . . .. . .. . Steam Linux Client updated, please retry the command /home/hl2% Figure 12.6 Using the Steam installer to update itself
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Adult Web Hosting services
198 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games Table 12.3 Client-side settings controlling network traffic Variable Role Default Rate Maximum data rate (in bytes per 5000 25,000 second) the client wishes to receive (depends on snapshots from the server network speed ) cl maxpackets Rate (in packets per second) at which 30 client will send command packets to the server Snaps Rate (in packets per second) at which 20 client wishes to receive snapshots from server server on a Windows machine, you should launch 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. Installation involves downloading and running the version 2.55 installer, and then downloading and running the 2.60 patch (see Table 12.1). Assuming you took the default installation locations, your WET client and server files are most likely stored under C:Program FilesWolfenstein Enemy Territory , and the dedicated server executable is ETDED.exe . When launched from the command line, ETDED.exe uses the same command line options as previously described for the dedicated Linux server. The hierarchy of folders and sub-folders under C:Program FilesWolfenstein Enemy Territory replicates that of the Linux installation. 12.2.11 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 WET game-play, in-game physics, and the PunkBuster anti-cheat system [PBUSTER]. Documentation installed along with WET itself (mentioned earlier) provides a starting point for further reading, and there are numerous sites around the Internet with suggestions on how to tweak game-play and add mods (modifications) such as ETPro [ETPRO05]. 12.3 Half-Life 2 Half-Life 2 was released as a single-player FPS game in late 2004 by Valve [VALV2005], an innovative successor to the original Half-Life [HALFLIFE2004]. Included in the client software, Half-Life 2: Deathmatch allows multiplayer, online death-match style of play. An upgraded version of Counter-Strike, the team-play modification of Half-Life, was also released as Counter-Strike: Source . One of the most significant aspects of Half-Life 2 was Valve s launch of Steam an entirely revamped client authentication and software distribution system [STEAM2004]. All players must establish Steam accounts, which are then used for authentication and validation purposes (even when playing the single-player mission). A player s legitimately
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Inexpensive Web Hosting services
Setting Up Online FPS Game Servers Setting sv wwwDownload to 1 will enable your server to redirect clients to a web site from which they can download new maps and mods. The actual web site is specified by setting sv wwwBaseURL . For example: +set sv_wwwBaseURL http://www.mydomain.com/mymaps would cause new clients to retrieve additional maps and mods from http://www. mydomain.com/mymaps/etmain/ (in other words, the mymaps/etmain/ directory on the www.mydomain.com website). Since the webserver can be an entirely different machine to the game server (and indeed may be anywhere else on the Internet), this approach can significantly improve download speeds for clients attaching to your server for the first time. If the redirection fails, and sv wwwFallbackURL contains a valid URL, the client will attempt to display the webpage referred to by sv wwwFallbackURL . This backup webpage should contain instructions on how to manually retrieve the maps and/or mods used by your game server. 12.2.9 Network Performance Configuration Table 12.2 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. Table 12.3 lists a number of client-side variables and settings affecting the network traffic generated by your server. The settings in Table 12.2 on the server side can override settings in Table 12.3 requested at the client side. Chapter 10 provides a discussion of the underlying principles. 12.2.10 Running a Windows Server In principle, you can start a listen server from within a WET client on a Windows machine. However, this is really only suitable for private, local games. To host a public Table 12.2 Server-side settings controlling network traffic Variable Role Default sv maxrate Upper bound on rate (the maximum snapshot rate 0 (unlimited) in bytes/second requested by the client) sv minping Clients with ping below this value will not be 0 allowedto jointhe server sv maxping Clients with ping above this value will not be 0 (unlimited) allowedto jointhe server sv lanforcerate 1: If clients are on a local LAN, force their rate and 1 snaps settings to highest possible. 0: disable this feature sv allowdownload 1: Allow download of new maps and mods from 1 server. 0: disable this feature sv dl maxrate Rate limit in bytes/second for downloading maps and 42,000 (although mods to clients (if sv allowdownload is 1) in practice often lower)
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Inexpensive Web Hosting services
196 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games Figure 12.5 Using Rcon within XQF to access a server at 192.168.10.1:27960 (client logged in from 192.168.10.99) in clear-text over the Internet along with the requested server-side command. (The actual rcon command is sent as an ASCII text string rcon rconpasswd rcon command ina UDP packet to the game server s active port.) 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). 12.2.8 Automatic Downloading of Maps and Mods New maps and mods (extensions to the base game engine) are often released by third- party developers. If you run your server with one or more new maps, or a game mod, clients cannot connect unless they too have the same maps and mods installed at their end. Clients can manually retrieve and install the necessary maps and mods before connecting to your server, or the server itself can automatically download the necessary maps and mods when the client first connects. Server downloads of new maps and mods is controlled by the sv allowdownload option set it to 1 (the default) to enable downloads, or 0 to block downloads (the client must be manually updated). Traditional downloading involves data being streamed out to the client by the game server itself, and is usually capped at the snapshot rate (in bytes/second) requested by the client. (And in any case some online discussion of WET suggest the maximum achievable rate is around 13 Kbyte/sec.) Although appropriate for game-play, this can be quite slow for downloading files hundreds or thousands of kilobytes long. (And if you want to further limit the impact of map downloads on the game server, set sv dl maxRate to an even lower value.) If you are connected via a LAN or other high-speed link to the server, WET offers an alternative approach downloads from a separate web site.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Inexpensive Web Hosting services
Setting Up Online FPS Game Servers However, you will usually want to start the game server and then leave returning only occasionally to monitor activities and perhaps modify parameters. For this you need to enable logging and rcon (remote console). To track server activity, you enable logging with +set g log logfilename either on the command line or in the server.cfg file you use, to carry the server s main configuration settings. The server log output will then be directed to the file logfilename . By default, this file will be placed under /home/et/.etwolf/etmain , but the actual location can be changed with +set fs homepath newdirectory . So, for example, the following line: /home/et/% etded +set g_log mylog +set fs_homepath /home/et/blah/ would force the game server s log output to be sent to /home/et/blah/etmain/mylog . Changing fs homepath is useful when running multiple instances of WET server on the same host you can use a separate fs homepath for each server. The main WET server, mods and PunkBuster will create their logging and configuration subdirectories below fs homepath. A relative fs homepath is interpreted relative to /home/et/enemy-territory/ . Thus using: +set fs_homepath blah the logfile is /home/et/enemy-territory/blah/etmain/mylog, and using: +set fs_homepath /home/et/blah the logfile is /home/et/blah/etmain/mylog. If you are using a modified game (a mod, such as ETPro [ETPRO05]) the logfile will appear under the mod s name inside the directory pointed to by fs homepath, rather than under etmain . Remote control of your game server is possible through the rcon facility. Rcon is a client-side console command that passes text to the server, and prints the server s output back onto the client s console window. Rcon access to a server is enabled by setting an rcon password with +set rconpassword password . For example, to set the rcon password to mypass you would start the server with: +set rconpassword mypass Then from a client you could execute the status command on the server with: /rconpassword mypass /rcon status (You only need to enter the /rconpassword line once, then use multiple/rcon commands as necessary.) Rcon functionality is also available in tools such as the GUI-based XQF server- discovery tool [XQF05]. Figure 12.5 shows XQF s Rcon console in action in this case the number of players has been checked, the server s name checked, then changed from myserver to newservername and then the change confirmed. Unfortunately, the rcon mechanism has an important weakness. Every time an rcon command is executed, the client (or third-party application such as xqf) sends the rconpassword
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Mac Web Hosting services
194 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games Private subnet 192.168.10/24 Game Server on port 27960 192.168.10.50 NAPT-enabled router etmaster.idsoftware.com:27950 The Internet 192.168.10.2144.133.92.248 Potential players Addresses and ports are re-mapped between private network and ISP Outbound: Source192.168.10.50:27960 becomes 144.133.92.248:47831 Inbound: Packets to144.133.92.248:47831 go to 192.168.10.50:27960 Figure 12.4 Example of game server behind a NAT router For example, let us assume that your server is on a local LAN at 192.168.10.50:27960 and your NAT router s external, public IP address is 144.133.92.248 (Figure 12.4). Your game server s registration packet was re-mapped on the way to etmaster.idsoftware.com so that it appeared to originate from 144.133.92.248:47831. Your NAT router simultaneously established another internal mapping such that UDP packets coming back from etmaster.idsoftware.com:27950 to 144.133.92.248:47831 are re-mapped and forwarded on the internal LAN to 192.168.10.50:27960. The problem is that your NAT router has no rules to handle UDP packets coming in to 144.133.92.248:47831 from anyone else on the Internet. Prospective players probing your server at 144.133.92.248:47831 will receive no answer. The solution is to manually configure your NAT router such that all packets coming in to 144.133.92.248:47831 from anywhere are re-mapped and forwarded on the internal LAN to 192.168.10.50:27960. In fact, the general approach is to create a bi-directional mapping rule stating (effectively) that 144.133.92.248:47831 on the outside is equivalent to 192.168.10.50:27960 on the inside network, regardless of who wants to talk to us . (Every NAT-capable router has its own technique and terminology for configuring such mappings. You will need to consult the userguide for your own router for details.) With this additional rule, your game server will be playable by people located on the public side of your NAT router. You may use any free UDP port you like on the public side of your NAT router. Players who find you through the automated server-discovery mechanisms will usually be unaware of your server s actual port number so long as they can probe your server and connect they will be happy. 12.2.7 Monitoring and Administration When started from the command line the game server prints information to the screen and accepts keyboard input in real time, allowing you to monitor server state and modify server configuration parameters. For example, you could type status to find out the names of all clients currently connected, along with their current ping time, IP address and port number.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Mac Web Hosting services
Setting Up Online FPS Game Servers This creates a minimalist, local server starting on the oasis map which can be probed by, and connected to by clients on your LAN. (In the absence of other configurations, the server will enter the campaign mode, and eventually move on to the next map in the campaign sequence.) Clients can discover servers on their local LAN by broadcasting server-discovery getinfo probes (UDP packets sent to IP address 255.255.255.255). Each time the client presses the refresh list button on their PlayOnline ServerBrowser server selection screen (when in Source:Local mode), eight UDP broadcast probes are sent two each to ports 27960, 27961, 27962 and 27963. This normally triggers a response from any of the dedicated servers on the local LAN that are listening on one of the four common WET ports. Note one interesting caveat: if you run a LAN-only game using +set dedicated 1 and also specify the game server s local IP address with +set net ip w.x.y.z the server appears to ignore the server-discovery queries being sent to 255.255.255.255. In this case, each client will need to manually specify the server s IP address and port number in order to connect. 12.2.5 Ports You Need Open on Firewalls It is entirely possible you have a firewall between your server and the outside world. If so, you must ensure that the server can send packets outbound to port 27950 on remote Internet hosts (to register with etmaster.idsoftware.com, and possibly other master servers) and receive inbound packets to whatever port you run the server itself (typically 27960). 12.2.6 Dealing with Network Address Translation A number of additional considerations exist if your server host is behind a router doing Network Address Translation (NAT). This can occur if your server is on a home or small corporate LAN sharing a single broadband connection to the outside world. As noted in Chapter 4, NAT (or more precisely NAPT) makes multiple hosts in a hidden network appear to be a single, large host to the rest of the Internet. This is achieved by mapping all the hidden (or inside ) IP addresses to a single external IP address, and then re-mapping TCP and UDP port numbers to ensure every application flow retains a unique 5-tuple of IP source and destination addresses and port numbers. An issue arises when you try to run a public server from behind a NAT router. The server registration process involves your server sending the ASCII text heartbeat ETServer-1 to etmaster.idsoftware.com:27950 in a single UDP packet. (If your server subsequently shuts down gracefully, it will send the ASCII text heartbeat ETFlatline-1 in another UDP packet to etmaster.idsoftware.com:27950, removing your server from the master server s list of active servers.) Upon receipt of the registration message, the master server engages in a short handshake to confirm your server is up and valid. Your server is now advertised as being at the IP source address and source UDP port number from which your server s registration message arrived. If your server is behind a NAT router, the master server sees the public IP address and port number used by the NAT router to represent your internally hosted game server.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Mac Web Hosting services
192 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games The usual way to start a dedicated server is to run etded with a number of command line options. For example: /home/et/% etded +set net_port 27985 +set dedicated 2 +exec server.cfg This particular set of options instructs the server to run on a non-standard UDP port 27985 ( +set net port 27985 ) and register with etmaster.idsoftware.com:27950 ( +set dedicated 2 ), then pull the rest of its configuration details from a file named server.cfg located in one of two locations: /home/et/enemy-territory/etmain/ /home/et/.etwolf/etmain/ (or other, specified by fs homepath) In fact, almost everything you might want to configure can be placed in server.cfg. A default server.cfg is created when you first installed WET, which documents many useful parameters and settings. An alternative configuration file can be specified on the command line with: /home/et/% etded +exec alternative.cfg The file alternative.cfg will be searched for in the two directories mentioned above, and used instead of the default server.cfg file. If you are running on a host with multiple IP interfaces, you may wish to explicitly identify which IP interface should be advertised by the WET server. For example, the following command line specifies that the server advertises itself (and only exists on) IP address 192.168.1.50: /home/et/% etded +set net_ip 192.168.1.50 +exec server.cfg (In this case, unless server.cfg contained any directives to the contrary, the server will attempt to use UDP port 27960.) Add +set sv maxclients NN to establish a limit of NN players on your server (the default is 20). If you are simply experimenting while deciding what configuration parameters to use, note that the server does not actually go live until it is told what map to play. If you have no map specified in your server.cfg file, use +map MMM on the command line (e.g. +map oasis ). If you chose to run a public server, you will begin to see inbound probe traffic from remote clients within minutes (or even seconds) of your server registering with etmaster.idsoftware.com (as discussed in Chapter 9). 12.2.4 Starting a LAN Server Use +set dedicated 1 to establish a private, unadvertised server that will only respond to direct queries from people who already know the server s IP address and port number. For example, use something like: /home/et/% etded +set dedicated 1 +map oasis
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Mac Web Hosting services
Setting Up Online FPS Game Servers Ultimately, you will have 270 MB of files installed under /home/et/enemy-territory along with symlinks from /home/et/bin/et and /home/et/bin/etded pointing to the same named files under /home/et/enemy-territory/. If you manually specified a directory to unpack the installation, you will now need to manually clean it up with: /home/et/% rm -rf /home/et/ettmp Because the WET installer uses a text-based interface you may also do this installation process while remotely logged into the server host from elsewhere (for example, over an ssh connection [SSH2005]). This is most convenient when your server host is already mounted in remote rackspace without a dedicated keyboard and monitor. 12.2.3 Starting the Server Having installed WET you now have access to the official documentation on your local filesystem, located at: /home/et/enemy-territory/Docs/Help/index.htm You now have two choices either launch a listen server from the game client s graphical interface or run a dedicated server with no graphical interface. Our interest is solely in the latter case you are running a dedicated server on a host that is tucked away in a rack in a closed room somewhere. A couple of technical decisions need to be made before starting your dedicated server. What UDP port will it run on? Is this for local LAN play, or available for anyone on the Internet? What is the maximum number of supportable players? (There are also some game-specific questions you need to consider, such as what game type and map rotation do I want? . In part, these are subjective decisions that depend largely on your motives for running a server. Detailed descriptions of how to set up various game types are outside the scope of this book.) By default, a WET server will bind itself to UDP port 27960 on the local server host (or automatically try one port higher if the default is in use). However, you can explicitly specify an alternative port if another process on the server host is already using port 27960 (for example, another WET server, or a Quake III Arena server). You can specify whether or not your dedicated server registers with idSoftware s Enemy Territory master server (etmaster.idsoftware.com). You should not register if you just want to run a private server (even if it is on the Internet) or if you are running locally on an isolated LAN. Player slots should be limited based on your available network capacity and processor speed. The official documentation (noted earlier) recommends 30 MHz per player slot , and thus recommends ~1 GHz for 32 players, 500 Mhz for 16 players and 250 MHz for eight players. Use the discussion in Chapter 10 to estimate your per-player network bandwidth requirements.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Mac Web Hosting services
190 Networking and Online Games: Understanding and Engineering Multiplayer Internet Games Figure 12.1 Installer requesting installation location Figure 12.2 Installer requesting symlink location Figure 12.3 Chose both ET and PunkBuster host, or you are running multiple game servers on a single host separate instances of WET can be installed under different user accounts). The installer will also ask for a location to place two symlinks for WET (Figure 12.2). We suggest /home/et/bin rather than the default /usr/local/bin (ensure /home/et/bin exists and is listed in your user s PATH environment variable before launching the installer). These symlinks allow you to launch the et client simply by typing et , and the et dedicated server simply by typing etded at a command line prompt. You then have the option of installing PunkBuster along with the main WET client and server code (Figure 12.3) [PBUSTER]. We recommend installing PunkBuster even if you do not expect to use it all the time. You will then be asked to accept the PunkBuster license conditions. Files from the temporary directory (/home/et/ettmp, if you followed the example above) are then copied over to /home/et/enemy-territory . You are finally offered a choice of automatically creating KDE or GNOME desktop shortcuts before installation completes.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Mac Web Hosting services