Yet another networking question.

I know I see networking questions on the forums every few days and I guess today I will be “that guy”.

I have functional networking for my app, basically using an IRC server for the clients to communicate. I liked the idea of being able to create a network of servers for communication using some well tested server software (ircd). Then using services and bots to manage users and to check the sanity of messages sent by clients. This idea could probably work for an MMORPG but for an FPS, IRC has too many features to prevent spamming and is just not designed for how I wanted to use it.

Right now my client uses asyncore to connect to the IRC server and sends strings to be interpreted by the other clients.

I have finally came to terms with needing to write my own server. I still like the idea of a communication server for both bots and clients to connect but I need to figure out the best way to create the server and the best tool for the job.

Right now I am considering:

  • Asyncore, Twisted, and Panda3d Networking stuffs.

Here are some of my requirements:

  • Fast, small, and secure(ssl?)

I will be hosting all of the servers and maintaining all of the accounts. I am looking for any opinions or suggestions on any of the above libraries or better ways to reach my end goal.

Thanks for any advise and please let me know if you have any questions.

  • Daniel.

PS: If you are looking for a place to host some server software you are developing you can look on www.lowendbox.com I was able to find a decent VPS in Dallas (my home town) for $5 per month.

Bookmarked, one of these days I would love my own gentoo vpn :slight_smile:

Short version: Except for the peer2peer network model, all game servers have a communication server component. It is how clients talk to the server. I do not know of any out of box game server packages (maybe pygame has some examples?).

Using IRC is a novel concept, I like it. I am not sure what you mean by “IRC has too many features to prevent spamming.” Does that mean that you have been using existing servers and you have been banned for it :wink:

You are correct though, IRC is designed for chat and while you could write or find your own IRC server to extend, and esentally that is what you can do with your asyncore server if you extended to follow RFC 1459.

Async, twisted, and panda3d are esentally a network communication layer. Client sends them info and they re-send it to anyone who is listening. You obviously will want to add code that listens to the messages and acts appropriately. In a classic client-server model you will want the server to know the entire game state. Clients send “I am moving forward” and the server responds “you are now in position 5,0,0.”

Bots can be just like any other client as far as the server is concerned and connect in the same manner, but instead of the client interpreting mouse and keyboard events and send the network command, the botclient will issue the commands based on some ai.

You may want to watch the video on the OTP server in the video section of the documentation for some ideas on how to structure your server.

Yup! You got the idea. I was under the impression servers for games like Quake and Half-Life basically were the communication server and did all kinds of game state stuff before sending one client’s updates to the other clients. I wanted to break my server down a bit so that there is one communication server, and then bots that could be spawned depending on amount of players and player locations.

My first test to see if I could even use IRC was done using freenode however that was just connecting and sending a few messages. Then I set up an ngIRCd server locally (on my mac) it was the only IRCd that worked out of the box using ports.

Once I got the VPS I set up an unrealIRCd to use. It has been a constant battle to fight the anti spam features. I had to recompile it with a “fake lag” option taken out. I had to fix it to stop ignoring clients for sending “too many” messages. Now it is not letting my clients spawn/join/leave channels as quick as I would like.

I have decided to stop fighting it and just build something on my own. I am trying to choose which of those tool kits would be best for the job.

My questions are:

I need it to be fast, its an FPS, can I get away with TCP or do I need to use UDP? Is python networking going to be fast enough or should I write something in C++? Is Twisted or the Panda networking stuff done in C and wrapped for python?

I need it to be light, I plan to do all the server hosting, $5 VPS only have like 256mb of memory (irc and anope services only required 25mb at idle)

Players will have logins to their accounts, how do I keep this data safe? Should I consider SSL or just encrypt important stuff and hope it doesn’t get sniffed? I have heard that asyncore does not play too nice with SSL.

My networking so far has been just sending strings of data, It would be nice to be able to send Vec3 and other datatypes but not sure if this would just make things more complicated for me.

Thanks again for any advise you guys might have.

  • Daniel.

i cant answer all your questions but. for an fps, you’d most likely use udp for your data, tcp can, depending on the connection, cause horrible lags. python is fast enough. i was able to push 10MByte data over my loopback device using python. so. no need to worry unless you actually get to the point where it’s too slow (which is unlikely for an FPS with comparbly few players). as for security. ahm i dont exactly know but you can send string messages around. if you encrypt those, your account-data should be quite ok i guess. i’m not a security expert though.

I was afraid of that. How much more difficult is it to program for UDP than TCP. I think I have to account for packets showing up out of order and other craziness. Does anyone have experience with the twisted or panda networking? I assume I should just go with panda if no one suggests otherwise.

Both UDP and TCP are good protocols to use for video games and applications. There is no one better than the other, it’s only deppend of your needs.
If you want to create a shooter game where monsters arrive from everywhere each half sec and you need to fire on them and run all the time (for exemple UncleSam) than UDP will be the good choice. But if there is an accurate strategy to follow in your game and the other players will suffer of any missed data received/sent than you must choose TCP.
I heard of some other protocls than mix UDP and TCP but I don’t know more than that. I can only imagine that UDP is used as the main protocol for its speed and when crucial information are exchanged, the data are sent constantly (each 10sec or so) untill the main block arrived with the adequate signature and then an aknowledge is sent back to the sender…

The very first server and client I programmed was with Panda, so I don’t know about other engines. But for sure (as said Thomas) Python is good for all networking stuff and it’s most probably that there is some C++ behind the Panda netwoking code you’ll use…
About the difficulty, I would say that it remain in the period it will take to write your whole server and client code. Count one or three days to understand Panda’s features and a couple of months to write your server and I’m affraid that you’ll find this difficulty whatever the tool you’ll choose.

Regarding the difficulty from writing in UDP than TCP. My understanding is that they are only protocols that you use. You just say to Panda to choose one of them and Panda will handle the rest which means your code will remain the same…
(anybody, correct me if I’m wrong regarding that last point)

Thank you for the information. I was not saying TCP was better than UDP. As I understand it, TCP is considered a reliable protocol where UDP is unreliable.

When data is sent via TCP it is broken into packets and reassembled by the receiver automagically. The programmer does not need to account for packets getting dropped or arriving out of order because the TCP protocol takes care of all this.

In UDP, packets are sent and hopefully received but there is no guarantee that the packets will arrive. UDP does not send acknowledgment of receipt or keep track of the order.

See: devmaster.net/wiki/UDP_vs_TCP

This is why I think it could be more difficult to program for UDP vs TCP. Now I have to create the reliability logic or maintain a TCP connection for important data and then listen for UDP packets for the less important data.

Does anyone have an example of setting up a simple UDP client-server using the Panda3D libraries? (The manual uses TCP for an example)

Since UDP is “connectionless” does that mean if my clients are behind a firewall they will not be able to receive UDP packets unless they forward specific ports?

Please let me know if I am becoming a pest.

Thanks,
Daniel.

Here is a link to some functional UDP networking code:

discourse.panda3d.org/viewtopic.php?t=9364

I am linking this to thread in hopes that anyone searching for a UDP networking example has a little easier time finding it.