How to Make My Own Game Server? - Page 1
Forum section: electronics / general

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 25, 2019, 05:21:37 pm
content: this will be a lot to ask and reveals my incompetency in this area... so i must confess, i'm total clueless, but it came across my mind and wonder how this is done... since this is many questions, please just direct me to the correct guideline links or explain it in 101 for dummy basic, any derailing may expand a thread to infinity of uselessness... for example, i know making a game software is very difficult task, let alone providing a game server for everybody in the globe to play multiplayer mode. i just want the very basic stuff, and if possible the diy stuff and i can program or do at home, let say a tic tac toe game server where a person from this location can compete with another person on different country. but also would like to know how complex game such as 3D game can share environment game across player etc... googling will just give me some monthly fee to a game server, thats not what i want. without further ado, actually i dont know what i dont know, so i just get to the simple questions...1) how to make a server? i have a pc, ok... connect it to internet and thats it? how do i get a unique IP address? through internet registars? ISP? or what?2) how to avoid ddos attack on a simple server? i heard big corp like amazon have "elastic infrastructure" to deal with this. is this requires many pc connected in someway? or some IP virtualiation? how about a simple limited budget, possibly a single PC server. is there a hope to dodge ddos attack? educate me please.ok now on to a specialized server... game server, assuming (1) and (2) is taken cared of, esp the (1), i know a little bit info of opening a port for a server sw etc, but what i want to know... lets take an example to make thing simpler, lets say a 3D game? like Battlefield or whatever game you know famous out there, i'm not a hardcore gamer so i dont know. its 3D game, it has a map and environment, where all people can play together at the same place at the same time. if i and you log in to the same game, and i shoot you. i see you dead in my PC, and the info sent to the game server and then sent to you, and you see you are dead shoot by me, things like that... how all this data is managed by a game server? how the 3D map is shared? is it stored in the game server? or stored in the users PC? the server only tells every clients, ok "load this scene" and everybody got loaded, and then i moved this direction, and server got notified i moved this direction and tell everybody that Mechatrommer moved this direction, and then everybody saw me moved this direction.... any info on this level of details somewhere? or guide 101 for dummies for such a thing?well looks like not so many question isnt it?as i said. i might not know what i dont know... any thought? thanks.

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 25, 2019, 06:00:59 pm
content: something like this maybe...https://stackoverflow.com/questions/2847929/how-online-game-clients-are-able-to-exchange-data-through-internet-so-fasthttps://developer.valvesoftware.com/wiki/Source_Multiplayer_Networkinghttps://developer.valvesoftware.com/wiki/Sourceany other thoughts are welcomed...

author: Nominal Animal
author_rank: Super Contributor
timestamp: October 26, 2019, 03:02:34 am
content: Quote from: Mechatrommer on October 25, 2019, 05:21:37 pmA server is just a computer that accepts incoming connections.A service is a program that accepts incoming connections.Typical internet services customers get are very asymmetric. Maximum download bandwidth (from internet to customer) is often almost an order of magnitude more than upload bandwidth (customer to internet). Providers often have all sorts of firewalls in place to stop or reduce port scanning of clients' computers, and may even stop connections to specific ports (standard services use a fixed TCP and/or UDP port number, between 1 and 65535).Internet service providers usually have a different contract for customer servers. These are usually more expensive.A better option is to rent the hardware and the internet connection as a package, with the physical hardware somewhere in a server hall you often cannot get physical access to. This is calledhosting. (Well, if you rent a specific physical server, then physical access is often possible to arrange, but isn't usually easy.) Currently, the best bang for buck is to rent a virtual server. Essentially, the service provider provides an internet connection suitable for a server, and a virtual machine (virtualized using processor features, not just hand-wavy "virtual" virtual) with limited CPU power and storage capacity, but usually with the basic OS maintained by the provider, and data backed up regularly. You can usually easily switch to beefier virtual server with little extra cost as your needs change.Quote from: Mechatrommer on October 25, 2019, 05:21:37 pmThrough your internet service provider. They usually buy entire ranges (that can be quite small), and then rent a fixed IP for you.Note that domain name system, DNS, is a separate service. It manages the mapping between names and IP addresses (likewww.nominal-animal.netto188.165.143.18). You can rent a specific name from a domain name registrar, but to associate it with an IP address, you'll also need to rent domain name services. Usually, you buy this service through your hosting provider, as good hosting providers have good packages for this.Quote from: Mechatrommer on October 25, 2019, 05:21:37 pmDistributed Denial of Service attacks are essentially just a lot of clients connecting to your service. They either use up the entire network bandwidth for that server, or all of available processing resources, so that the service essentially jams. (Technically, that requests cannot be serviced in a reasonable time.) If the connections are secured using SSL/TLS, a major issue is that the initial handshake is very CPU intensive.You cannot really protect anything against a DDOS; you can only mitigate such events.Howto mitigate DDOS situations -- or even normal situations where your service becomes suddenly inundated with clients, because it was discussed in a Slashdot article (Slashdot effect), or maybe went viral on Fakebook, Twatter, or Utube, or similar --, depends on the service itself.Game services can mitigate DDOS by separating the initial connection (login or registration) to separate machines from the machines doing the realtime services. The initial service passes the client information and symmetric key(s) used to protect the communications to the realtime service; and the realtime service simply dumps a client if a symmetrically encrypted message does not validate.Symmetric ciphers are used because they are fast. They are called symmetric, because both ends must know the same key; one end uses it to encrypt, the other to decrypt. Sometimes two different keys are used, one each for the direction of the data flow; especially when the key itself is changed (to avoid certain other types of attacks). Initial connection cannot use symmetric ciphers, and are typically based on public-key cryptography and key exchange protocols, that are orders of magnitude slower.Some hosting providers do provide DDOS mitigation services. There are many ways of providing that, but in the simplest case, it is a selective firewall that blocks new connections when the protected server says it cannot handle more concurrent clients, and only allows already established connections through. (Note that each TCP/IP and UDP/IP connection is identified by two pairs: sender IP and port, and recipient IP and port.)A smart game server can provide some level of robustness against DDOS attacks, by maintaining a firewall that only accepts incoming data from specific IP address and port pairs. (In Linux, this means that the kernel does receive each such packet, but discards all but speficially allowed ones. While this does consume CPU resources, it does allow saturating a typical 100 Mbit/s network connection without the machine keeling over due to insufficient CPU resources.)Unfortunately, there is no universal hammer that solves all DDOS issues. Software engineers who have maintained game servers under DDOS attacks could describe much better strategies, but a lot of it is Secret Sauce...Quote from: Mechatrommer on October 25, 2019, 05:21:37 pmWell, yes. They just throw enough network bandwidth and CPU resources at the beleagured service, so that it can service all the incoming requests -- or at least service the real ones, and sufficiently process the attack requests to drop them on the floor.Quote from: Mechatrommer on October 25, 2019, 05:21:37 pmWell, that's not exactly how it works.The game server is not just an information relay; it nowadays also has to be a kind of a referee. So, when you shoot at another gamer in your own machine, it sends that information to the server for the server to make the decision. The server makes the decision, and forwards the result to all players in the same room/zone (well, anyone that is affected by the information).Then, on your computer, you see the other player either getting shot or not.The reason is that a lot of gamers are assholes, who will try everything they can to win, and often modify their copy of the game (through run-time modifications, or mods). In the earliest multiplayer games, each game instance would make the decisions locally, but nowadays, that is not safe anymore. (Some games do still do it that way, but keep enough logs on the game server, to check the data afterwards to see if a player cheats more than once. It varies; Secret Sauce again.)This is also whyping times, or data packet roundtrip time, is so important to gamers. If you have long ping times, more stuff has time to happen on the game server before your actions are noted.One reason computational physicists are sometimes valued in game development teams, is that they have experience withpredictor-corrector methods. Essentially, during the time local game events are sent to the game server, the local instance runs in "predictor mode", where actions aretentative. You have minimal lag, but sometimes the predictor is so far off from what actually happens, that the correction due to response from game server causes a human-noticeable glitch. Typical examples are a player falling off the same cliff twice, or falling off and then magically not, continuing traipsing along that cliff.(I could go on and on about such algorithms, and some of their properties; like gear5 predictor-corrector and how it is used in molecular dynamics simulations to allow longer time steps, and how that corresponds to minimizing the effects of lag in games.. but I'm waffling already.)Quote from: Mechatrommer on October 25, 2019, 05:21:37 pmCarefully, and both the server and the clients have a copy of the same data.At the very start of the game, each player should have an exact copy of the game server state. This includes not just the map, but all properties of all interactive objects and players and non-player characters. This is essential, because as the game progresses, it allows the server to update the state on all clients by simply sending thedelta, the difference or change in the state.Note that often only the most important information is transferred. For example, if a player throws a crate, there is no need to transfer the coordinates in real time; rather, the trajectory is modelled as a curve (as a function of time), and the coefficients of that curve are transferred instead. If a player destroys a crate, there is no need to describe how the pieces fly around, as it is just visual candy; instead, the game server just tells the other players when and how the crate was destroyed, and they show a roughly appropriate animation.(In many games, passing through doorways between zones has funny glitches because of this. In one zone, the doorway may be closed, and in the other, open. So, when the player sees the door open, they see the other players in the other zone running futilely against an invisible door; and in the other zone, they see a player emerge through a closed door. To avoid this, the server would need to maintain a single set of information about doors crossing zones, but that can violate the single-zone assumption about communications about events, so there may not be any "clean" way to fix such issues without causing significant overhead on the game server.)Player movement is one of the things that requires heavy predictor-corrector algorithm use to keep everything "smooth", instead of things happening in visible steps (of packet roundtrip time). Another approach is to let each player be a fixed timestep duration ahead of other players on their local machines, but adjust the others movements and firing to compensate. This allows for absolutely smooth operation, but player actions do not exactly match across all player machines -- but their results still do.Quote from: Mechatrommer on October 25, 2019, 05:21:37 pmI don't know if this helped any, but I got to talk about stuff I like to talk, so it was a win for me

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 26, 2019, 04:10:40 am
content: Quote from: Nominal Animal on October 26, 2019, 03:02:34 amthere are many hints and keywords there, enough to get me started on some basic, thanks.

author: Mechatrommer
author_rank: Super Contributor
timestamp: July 01, 2020, 10:01:58 am
content: Quote from: KimberlyJames on July 01, 2020, 09:04:02 amyes, a dedicated server with real physical server and real and fixed IP address, but... this was few months back of idea i still wish i can make one, but the truth is, i wont have much time to dedicate myself into this i'll need someone else with the same enthusiasm to do it. this is a whole Wonderland once think deeper into the rabbit hole, ie Game Server SW development. real/realtime world engine, space/time/waves/kinematics synchronization in the reality of unideal world with high latency interconnections environment. let alone the 3D engine which is the very basic thing is already a daunting task. on another side, economically speaking, one will need a thick money in the first place to set this all things up, IP address monthly/anually subscription/fee, the server machine, and then more machines as number of users went up exponentially before any real income can surface etc... and then need to think how to setup proper servers nodes or what not, or things like elastic servers like Amazon did.. what a dream!