Author Topic: Proposed Net Fix  (Read 23399 times)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« on: January 24, 2008, 11:52:36 PM »
I've been having some ideas for a new net fix.

Previously, we attempted to patch a few bytes here and there to make the network protocol work from behind NAT routers. The patch dealt with the issue of the encapsulated IP, but not with the issue of ports. Basically it let people play, provided they could properly setup port forwarding. Actually fixing it so port forwarding wasn't required would have been a much larger patch.

Seems the port issue was fairly important though, as most people have resorted to using Hamachi to play. It also seemed to make patching less critical, since pretty much everyone could play now, they just needed to install Hamachi. Of course some people refuse so use Hamachi and have stopped playing, so maybe this still needs to be addressed after all.


Anyways, I think we might finally know enough about how the network system in OP2 works to actually replace the core component that is responsible for all the NAT problems, including both the IP and port translation. This can mean two things in particular. One, that unassisted, people could play direct IP, where only the game host needs port forwarding, (and only 1 port would need to be forwarded). Two, that we could design a new networking component to make use of some sort of game matchmaking system. With that in place, not even the host would require port forwarding. Basically anybody would be able to play without any configuration using the match making system, and if that ever goes down, or this site ever dissapears over time, then simple port forwarding for the host would be enough for anyone with the fix. (The fix being required by all players of course).


As for how this could be done....

At the multiplayer menu, where you choose the type of network game (TCP/IPX/Modem/Serial/SIGS), each button activates some object that takes the user through all the screens to start the network game, and in so doing, also creates the underlying network object to transport all the messages between clients, and establishes all the connections. Now this first initial object is very simple, with only 4 virtual functions, and no member variables. As such, it's very easy to replace. Also, the objects are assumed to be statically constructed, and an array of object pointers is used to access them. We could simply overwrite one of the pointers in that table to install a new object that would take the user through a different set of pre-game setup windows, and create a different network object.

Now, the game Join/Host window is fairly simple, and can be reused since it's not tied to any one protocol and it not responsible for creating any of the network objects that need to be replaced. (It already is reused by the different protocols). However the code that controls the following screens gets fairly dependent on the network component that needs replacement, and as such would probably need to be replaced as well. This would include the broadcast/search for games, and the create game screen. But since these screens sort of suck anyways, why not just replace them all? Well... ok, that's a bit much work. The pre-game setup window, where you can chat with opponents, choose color, etc., is fairly independent of the underlying network type. Once you've reached that screen, the needed network object is already created and functioning. We could just use that screen as is, since we'll need to create a network object that's compatible with Outpost 2 anyways, so we can save a bit of work here. At least for now anyways.

It would be nice to somehow combine the max player setting, and the game type with the pre-game setup screen, so the host doesn't need to abort and remake to change those settings. But that's quite a bit bigger of a project. It would also have been nice to do better checksumming of files and actually dermining who and what file is different, and it would also have been nice to allow auto downloading of missing files. But again, too big of a project for now. (Btw, definately need some sort of security confirmation before downloading any DLLs, and maybe tech tree files as well).


So, the proposed change then is to replace the object that controls the sequence of windows to setup a game, (and install that object in the required table), to replace the intermediate windows, and to replace the underlying network object that is responsible for making all the network connections where all the NAT troubles lie.


Ok, so how big of a project would this be? Well, initially I thought this could be done with a couple days of hard work, which means I've already spent about a week on it, and it'll probably take at least a month.

Currently, I've replaced the object that controls the sequence of windows, and replaced one of the table entries to install this object. I've created an intermediate window layout using the dialog editor in MSVC, and I'm able to get that displayed in game nicely skinned. There's pretty much no code behind that user interface yet, but it does pop up the pre-game setup window when you click create or join, and the cancel button will take you back. I've got just enough of an underlying network component written to keep the pre-game setup window happy and not crash or behave too oddly. Create actually makes it looks pretty normal, but join just sort of leaves it waiting to receive settings from some game host, which of course will never come because the underlying network component is not even close to finished.

Most of the work needed is in getting the new GUI to work, and writing the network protocol to search for and join games, as well as start the game (i.e., the whole "Replicating Players List" part). That will probably end up being a fairly substantial amount of code. After that, we might also consider writing some sort of game match making system.


Here's what the current intermediate screen looks like:
(in-game, skinned)


(in MSVC, unskinned)



I was also thinking that clicking cancel at the pre-game setup window should bring the user back to this window, rather than all the way back to the main menu.

Anyways, let me know what you think of the user interface. Or better yet, if you have suggestions, make the changes yourself. I'm attaching the .rc file that contains the dialog resource. You can edit it yourself in MSVC, or any other dialog editor that understands .rc files.
« Last Edit: January 24, 2008, 11:59:09 PM by Hooman »

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Proposed Net Fix
« Reply #1 on: January 25, 2008, 07:13:22 AM »
Very nice work indeed. If you want to do this project then good luck to you and im sure we all look forward to the results and information.

Ive allways thought Hamachi is a good enough fix for us and now that we have it we should spend time on other projects instead of making out own hamachi. Just my opinion tho.

But yes there are some problems with the interface such as it going back to main menu on cancel and having to go back to change the max players etc.

Looking good but I know there is a long way to go. Thanks Hooman.

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Proposed Net Fix
« Reply #2 on: January 25, 2008, 02:53:18 PM »
Hmm... looking at the server browser, I think you should space out the window a bit more, make it bigger, and move the manual connect thing to the bottom and make it a dropdown like what's already in 1.3.4.

Quote
Ive allways thought Hamachi is a good enough fix for us and now that we have it we should spend time on other projects instead of making out own hamachi. Just my opinion tho.
I disagree. Hamachi is, quite frankly, a pile of s***. Remember the IP shuffling bug from not too long ago? Plus, the whole thing about us having to have tons of networks and having to know which network a game is hosted on (and who the host is if broadcast is broken for you), etc.
« Last Edit: January 25, 2008, 05:06:41 PM by Arklon »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Proposed Net Fix
« Reply #3 on: January 25, 2008, 06:17:45 PM »
Hmmm...
Hamachi... WON Replacement... Hamachi... WON Replacement...
I hate tough decisions, so I'm glad this is an easy one.
I'd have to say a potential WON replacement SantaWalks all over Hamachi.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #4 on: February 01, 2008, 02:42:59 AM »
Slight update. I changed the GUI a tiny bit.





There has also been some progress on getting it to actually work. Still buggy though, and needs more work. But, I finally got a two player game working. It hangs when I try three players though. Have to drop someone before it can continue.

The whole game server idea hasn't been worked on at all yet. But the current protocol should hopefully make that support easy to add later.



Finally, after so many days of not quite being able to get Join to work. Then a brief hiccup where game start wouldn't work. But, that was an easy fix once I got that far. Now I just have to find all my other mistakes, and why 3 player games aren't working. That and why quit didn't seem to work during the pre-game setup. The host ended up dropping the quit player for not responding. But, like I said. It's still a little buggy.
 

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #5 on: February 02, 2008, 05:18:34 AM »
Ok, I've got a working version that so far appears to be fairly stable. I'm attaching it for anyone who wants to test. I'm using the /loadmod parameter to test it out. Copy the DLL into a subfolder in the Outpost 2 folder, say /NetPatch, and then use "Outpost2.exe /loadmod NetPatch" to load it. If you're doing this from a destop link, make sure the parameter /loadmod appears after the closing quote for the filename of the executable, as in:
"C:\SIERRA\Outpost 2 Divided Destiny\Outpost2.exe" /loadmod NetPatch
The new user interface is found under the "Serial" option in the multiplayer menu. I figured it was a good place for testing, since serial is an unlikely option for anyone to use anymore.



For the curious:
Seems I ran into a problem that I'd only ever read about previously. I had mixed New from my DLL with Delete from Outpost2.exe. It was trying to free memory from a different heap from which it was allocated. Very bad. But, it was an easy fix once I realized this and the memory problem I'd run into went away. Previously when starting games the tech file would get loaded over one of the network objects, thus corrupting it's memory. It was initially very disenchanting to see a text string over the network object, as I was fairly sure it wasn't a pointer error on my part. I wasn't exactly looking forward to debuggin that problem after all the other ones I'd gotten through. But, turns out it wasn't that bad. Plus it gave me an excuse to look a little more into new/delete.  :)


Oh, and I fixed the minor bugs I had earlier. Some slight efficiency loss, but it all seems to work now. Any bugs you find I probably don't know about yet, so be sure to tell me.

It's still not feature complete though, and I may have taken some slight shortcuts along that way that might be a bit odd at first. (Like it saves the player name, and the address list when the dialog box is closed, such as when a game is starting, or even if it's closing because cancel was clicked).


Since there is no game server working yet, the host needs to have port 47800 fowarded to host from behind a (NAT) router. Nobody else should need to worry about port fowarding at all though.



Enjoy. Hope it works for you.  :)
« Last Edit: February 02, 2008, 05:21:44 AM by Hooman »

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Proposed Net Fix
« Reply #6 on: February 02, 2008, 01:35:14 PM »
Well, the entire process seems much faster, now. Creating, finding, and joining games is faster, the initialization stuff is faster, and the game plays faster. But that was only with two people, so...
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Proposed Net Fix
« Reply #7 on: February 02, 2008, 02:11:40 PM »
This seems to work using Hamachi IP's and regular IP's, even with Hamachi on and the advanced network settings fix applied. It even shows the IP's as regular/Hamachi in the in game net stats.
Perhaps you should add a status bar at the bottom of the OPU net dialog that tells you what it's doing and can tell you if something goes wrong.

Edit: It may be that the host ignores Hamachi altogether. I'll need to do some more testing (and 3 player testing), though.
« Last Edit: February 02, 2008, 06:17:43 PM by Arklon »

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
Proposed Net Fix
« Reply #8 on: February 02, 2008, 06:32:41 PM »
Why would the game be faster Sirbomber? Its the same network code?

Nice work Hooman.

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Proposed Net Fix
« Reply #9 on: February 02, 2008, 06:43:55 PM »
Quote
Why would the game be faster Sirbomber? Its the same network code?
I'm just telling you my observations.
Try it yourself if you don't believe me.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Proposed Net Fix
« Reply #10 on: February 03, 2008, 11:43:01 AM »
Quote
Why would the game be faster Sirbomber? Its the same network code?

Nice work Hooman.
It's not the same network code. The network object gets replaced.

By the way, one of the bugs I noticed, if you clicked Join and there was no game listed in the box, it caused a crash. That should be trivial to fix.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #11 on: February 03, 2008, 03:18:17 PM »
Ahh yes, thanks for the reminder.

I don't get a crash for that, but I'll look into it. I did put some code to check if a game was selected or not, but it never seemed to work. Was supposed to pop up a message box, but it never did. Since it didn't crash for me, and there were other bigger problems at the time, I just didn't bother to look into it.



The network code was replaced, so it's possibly a bit faster. I'd be surprised if it was noticable though. There's no extra layer of buffering with the network packets anymore, or stupid linked list traversals that like to touch lots of pages, so it should be a little more cache friendly. I figure if the winsock API already buffers the packets, why bother doing it myself? (There might still be unreplaced code higher up that does stupid linked list traversals like that though).

It will likely have an artifically inflated ping time during game join though. Mainly because I'm not using a seperate thread to check for and reply to certain network packets. Instead it has to wait for a timer to fire before doing any network transactions. A little sick, I know, but it was quite a bit easier than the alternatives. Plus, I definately didn't want to add extra threads for such a simple task. Seems uneeded and wasteful. Besides, you'd still have to pay for a context switch to do any network processing. Currently the timer is set to 50 ms. The ping time displayed during game join may jump by about as much as that, but it shouldn't affect gameplay at all. The timer is only used to search for games (and hence to calculate that ping time).



Oh, btw, (in regards to Hamachi testing), I noticed something about part of the network code that didn't get replaced. During pre-game setup, the clients only send packets to the host, and then the host periodically broadcasts the current game setup to everyone else. So if the host is on ham, then either ham or direct IP may be able to join the game (I'm a little uncertain), but you'll likely have trouble once a game starts if some people are using direct IP and others are using Hamachi. The people using direct IP probably won't be able to communicate with people on Hamachi. (The Hamachi IPs will be invalid to people not using Hamachi, and so they won't be able to send packets to them).

At any rate, one of the ideas behind this patch is so people don't need to use Hamachi. The only reason to use it, is if the host can't forward ports. In which case, try and find someone else who can host, or everyone should play using Hamachi.


Edit: I found and fixed the Join bug. Seems I checked for a null pointer, but I didn't check if the value being casted to that pointer was valid.


Edit2: I also remembered some of the message boxes are graphically ugly. I'll have to look into that.

Also, self reminder to make sure the info from the list of games get's freed when it's no longer used. I'm pretty sure it just clears the list view (which actually holds the pointers), and so the memory is never reclaimed. This needs to be done both when the list view is cleared when searching for games, and when the window closes.

Oh, and I haven't done anything to reorder the list of saved IPs. So, BlackBox, if you feel like posting the code you used to do that, I'd appreciate it.
 
« Last Edit: February 03, 2008, 03:33:04 PM by Hooman »

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Proposed Net Fix
« Reply #12 on: February 04, 2008, 08:12:49 PM »
Hooman, what happens if the host fails, drops, or quits? You probably want to add code that selects a new host, one of the players that are left that have port 47800 forwarded and have the lowest average latency between all the players.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #13 on: February 04, 2008, 08:29:20 PM »
Host is irrelevant at that point. By then everybody has everyone else's real external IP. They continue normally. The designation of Host is only really relevant during the pre-game setup. Maybe during resynchronization as well, in terms of organizing the resynch and setting the new state, but the higher level protocol that wasn't replaced would be responsible for that. Port forwarding should be irrelevant for resynchronizing, as no new "connections" are formed at that point.

(* I use the term connection lightly, as UDP doesn't really use connections).

Actually, the only person that doesn't know their own external IP is the original game host. Not that it matters, since they won't send network messages to themselves.
 

Offline Arklon

  • Administrator
  • Hero Member
  • *****
  • Posts: 1269
Proposed Net Fix
« Reply #14 on: February 04, 2008, 08:44:29 PM »
Ah, I see. Glad that's not a problem.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #15 on: February 05, 2008, 05:22:45 AM »
I'm attaching a new version. I made a few slight bug fixes, and some user interface improvements. (Basically, I completed some, but not all of the things I was originally planning to do).


There has been no (real) net changes, so this version should work with the previous posted version. No need for other people to download this version just so you can try it out.


The following changes were made:
The server address list will now remember new entries, and will move the most recently used entry to the top of the list
Hot keys were added for all options
The tab order has been corrected
The Search option has been made the default action  (just press enter)
The games list now uses full row select
Double clicking a listed game will attempt to join it
Clicking join without a game selected can no longer cause crashes
A status display was added at the bottom of the window  (let me know about what messages you'd like to see there, as it's not very developed yet)
The server address can now accept both address and port numbers  (* see note below)

Example Addresses:
192.168.1.2   [Send request to 192.168.1.2, on the default port (47800)]
127.0.0.1:777  [Send request to 127.0.0.1 (localhost) on port 777]
localhost:777  [Send request to localhost (127.0.0.1) on port 777]
:777   [Broadcast to the LAN on port 777]

Either address component can be missing. If the port is not specified, or the string after the ":" converts to the integer 0, then the default port of 47800 is used. If the address part is missing, then it defaults to broadcasting over the LAN. Also, if the address string isn't an IP address in numerical format, then a host lookup is performed. (But that's old news).


* Note: I have not yet upgraded the user interface to allow hosting on a port other than 47800.  (But the code underneath allows it).


As I said earlier, this is mostly just user interface improvements. I haven't gotten around to working on a game server yet. It's probably going to need some slight user interface changes to accomodate additional options. (Such as specifying the host port, and making advertising to the game server optional).



[Random reflection, mainly aimed at BlackBox for comment]

I'm also slightly tempted to use a seperate socket to listed for game search queries. Then it wouldn't need to recreate the main socket to remove the binding if the game is cancelled. If this is done, then the reply from the game host would of course be sent on the main unbound socket, and the client would use the return address on that packet for all further communications. That way NAT still won't be an issue. The main reason why I'm thinking of the change is to do with how the game server will be integrated. Once a game server is in place, the host won't need to bind at all, and can just use the regular socket. In which case, I see no reason to have a bound socket around. Plus, the bind can fail if the port is already in use, so if it's not needed, it should probably be avoided. Also, when the game is advertised, there will be some latency if the game server is to respond. If the server is down, then the client won't be certain for some time. The host will then need a bound port to accept client connections. If the decision is made early, then (if the client doesn't bind) the client would be left waiting to realize the game server was down before it would bind and actually be able to host without the server. If the client does bind, then the bind could fail, even though it could potentially have hosted the game using the game server (if it's up) anyways, and it would also be stuck using a bound port when an unbound one would do. Of course sending data out on the socket will implicitly bind it, so maybe I'm being a little anal about all this. Of course, since the socket gets implicitly bound when data is sent out, this means recreating the socket when going into host mode, as it'll get bound when the search query is sent out, as it automatically is when the new window opens.

Basically, I'm tempted to create a main socket once, which never gets recreated, and then create an additional socket for hosting, which only listens for game search queries, but isn't used for the replies.

[End reflection]

 

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #16 on: February 23, 2008, 05:13:48 PM »
Some people are reporting problems at game start. I had some logging code to dump the players list when I was testing, but I disabled it in the previous two released versions since it seemed to be working fine at the time. I've re-enabled it for anyone doing any testing. If you have problems, be sure to send me a copy of Log.txt, which should appear in the Outpost2 folder. Make sure you do this immediately after the problem, since the log file is overwritten each time you start Outpost2.


I've also made a few small changes, but again, nothing that breaks compatibility with earlier versions. I mixed this version with previous ones in a recent test.

Changes include eating spaces and tabs at the start of server addresses, so it won't fail if you accidentally paste a space or tab in there. It also updates the number of packets and bytes received, so it won't always display as 0 in the net stats.

Oh, and some rudimentary support for a game server was adding using settings from the .ini file. But I haven't gotten a game server done, so no sense yet in making the changes to enable it. By default it will remain disabled.
« Last Edit: February 23, 2008, 07:05:28 PM by Hooman »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #17 on: March 10, 2008, 03:02:22 AM »
Well, I spent a few hours working on this project today, and I got a game server working. It still needs a bit of work before I try opening one to public testing though.

In particular it was compiled and tested under Windows, but any 24/7 game server is likely to be running on some unix based machine. It also seems to have higher CPU usage than I expected. I had a Sleep call in it, but it didn't seem to do anything, so I might need to rework a small part to keep to CPU usage down to a reasonable level. (Probably using select, or something like that). It also doesn't release memory after claiming it, so it'll use whatever memory it needed at peek usage until it's shut down. It does recycle memory that's been claimed though, so it shouldn't be too bad.

I'd also like to finish a few hacker hardening features, so it'll take more than just some random script kiddie to bring down the server should someone want to cause trouble. It's got a number of security features built in already to help prevent some of the more common attacks, but some are incomplete, and I'd like to check for more possible problems.

I'd also like to add some extra performance counters, and a way to remotely check them, so I can make sure the server is running as expected when it's put into use.
 

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Proposed Net Fix
« Reply #18 on: March 10, 2008, 11:02:05 AM »
I'd probably be willing to help with a Unix port of this if you want. About CPU usage and nonblocking IO, even though this is probably not a huge concern due to the low number of open sockets there will be (when compared with larger servers out there), kqueue or epoll would be a faster way to go than select() (there is a library out there called libevent which has some sort of standard API that will try and use kqueue or epoll, and fall back to select if the OS doesn't support either of those).

As far as performance counters go, it would be fairly straightforward to link it up to the web server (from there the server could be controlled using the web as well, would save the trouble of having to write administrative commands directly into the interface with the client).

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #19 on: March 11, 2008, 02:54:19 AM »
Ok, I've got the CPU issue worked out, and it's now up and running on a unix based machine.

Btw, what OS does the server use? I figure I should do a bit more testing on different flavours of Linux or other Unix variants, since I ran into more trouble than I expected. I figured with winsock being based on a Unix API, porting shouldn't be too bad, but it seems there are more subtle differences than I really cared to know about.

Btw, does that library you mentioned work on Windows? I've heard about those alternatives before, but I don't remember much anymore. Although, I probably won't bother to change anything now without reason. It only needs to wait on 1 socket, and maybe do a few periodic updates, and it's working just fine with select. It shows up as 0% CPU usage on Windows in Task Manager, and the total system load on my Unix machine is less than 1% (and it's running other things too, which are active).

I wouldn't be too sure how to go about integrating the performance counters with a web server. I was sort of thinking of just mem copying a counter struct to a network packet, and send it off. I would need to add a few extra messages to do it, but that's no problem (query/response). Probably just make a simple command line client to fetch and dump the values to the console. Although, it might be nice for people to checkup on some of the stats (number games played, etc.).


Anyways, I needed to make a few changes to the client (bug fixes), so there will be a new version up for download in the near future. It truncated some of the address strings if they were too long when loading from the .ini file, and it was also stripping the port number from them before saving them to the combo box. It also had no default port specified for the game server (or address family either, which was a bigger issue).



Edit: Oh, btw, I forgot to mention this earlier. But the problems people have reported seem to be associated with symmetric NAT. Currently, my changes will not do much to help people whose router uses Symmetric NAT. I had a few ideas to help with this, but Symmetric NAT is actually quite a nasty beast, so I might not come up with a perfect solution. (I'm half tempted to suggest people with it get a new router  :P ). When I first read about the different types of NAT, I read that Symmetric NAT is rather uncommon and usually only found in large corporate networks. This doesn't seem to be the case after all. Some home routers do use Symmetric NAT. I've also heard that some routers have a "Gaming Mode", and for one model that I read about, it uses Symmetric NAT if that option is turned off. If you enable Gaming Mode, then it uses Cone NAT, which shouldn't be a problem for this patch. At any rate, I'll try to tackle the problem later on down the road. (Btw, how does Hamachi deal with it?) I suppose we could always use the game server as a relay if we really needed to. (Although I'd rather use other players if possible).
 
« Last Edit: March 11, 2008, 03:03:47 AM by Hooman »

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
Proposed Net Fix
« Reply #20 on: March 12, 2008, 11:36:00 AM »
The server is running a Linux 2.6.x kernel on standard 32bit x86 hardware so if you stick to standard Unix API's and headers the program should work fine. (Yes, that's right script kiddies... I just divulged some "important" information about the server's OS. Now hack us).

Linux does support both epoll and kqueue I believe if you were gonna use that (though looking now at it you probably wouldn't get that much of a performance gain by using it, if you only have 1 socket).

Libevent does work on windows but I don't think it uses the winsock2 features like overlapped socket IO, etc. (Looks a lot like it was one of those unix libraries that was quickly ported to windows just so unix programs that used it would work on windows without major changes). It probably falls back to select() on windows, is my assumption.

As far as the stats thing goes, probably just have a fastCGI daemon listening on a unix domain socket (or maybe a couple of them). One of them is for the webserver (the web side of things), the other one could be used for the game server to communicate with the fastCGI daemon. (Or perhaps just integrate the web daemon into the game server itself).

Regarding hamachi, they don't release any information on how it works. (Well, for symmetric NAT, they might just relay stuff thru the server. There is capability for that in hamachi).

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #21 on: March 15, 2008, 11:30:12 PM »
Ok, here is a slight bug fix version. I've been busy writing a game server, and it seems to be working. This latest client update will be needed to connect.

Like earlier versions, copy it into a "NetPatch" folder inside the Outpost2 folder, and start OP2 with the usual "/loadmod NetPatch" parameter. To enable the game server support, you also need to add the appropriate entries to Outpost2.ini. I'm running a test server on one of my machines currently. Don't expect it to stay up for very long. This is just a short testing phase. Anyways, the settings to add to the Outpost2.ini file (just at the end of the file is good), are:

Code: [Select]
[GameServer]
GameServerAddr=68.146.70.0:47777

Note that the address is dynamic, so it's pretty much guaranteed to change eventually.


Please post if this works for you, or any issues you may experience. (Excessive lag? Quirky behavior? Crashes? etc.)


Edit: Just a reminder, this works under the "Serial" option in the multiplayer menu. I didn't want to overwrite any of the more useful multiplayer options until some more testing and development is done.

Edit2: For the host address, you can enter the game server's name (68.146.70.0:47777), or the host's name. That was that small change I was forgetting to make.... Have the client auto check the game server's address for a list of games, rather than simply broadcast to the LAN. It'll send back a list of all hosted games. Make sure someone has a game hosted on there first, or you won't be able to see anything.

Edit3: Updated the download slightly. It'll now check the game server for a list of games automatically when you open the serial option. (If the Outpost2.ini file settings are not entered, then it'll fall back to a LAN broadcast). Just make sure you enter in the Outpost2.ini file settings.

Edit4: Attachment updated. Fixed a bug that was causing trouble when joining games listed by the server. (They appeared in the list fine, and if you typed the server address in manually, join would work. Turns out the address family field of the address was wrong, causing errors when trying to send the join request. This field is now correctly initialized.)
« Last Edit: March 16, 2008, 02:56:24 AM by Hooman »

Offline Tellaris

  • Sr. Member
  • ****
  • Posts: 460
Proposed Net Fix
« Reply #22 on: March 20, 2008, 06:06:51 PM »
Found a bug for ya, Hooman. If you don't refresh, but leave it, and somebody keeps recreating the game, the new games get listed... but underneath the old one. A minor issue, cleared up by searching again, but just throwing it out there
Spell Checker!   The PoWeR tOoL
Click Here For Coolness
Self Proclaimed OPU Help desk.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Proposed Net Fix
« Reply #23 on: March 20, 2008, 09:12:17 PM »
Yeah, I'm aware of that. I've been meaning to put some sort of timeout there to remove old entries, or do some sort of host address comparison, and limit it to 1 per unique (ip, port) pair.

I also want to make sure the protocol is reasonably secure against hacker attempts to bring the system down. Such as someone spamming the server with false hosted games, or trying to remove someone else's hosted games from the server.

I was also thinking of adding some sort of connected players list, so people don't feel so alone when nobody has a game hosted, and so they aren't left to wonder if the server is even working. I might leave that for a version 2 or something though.


The biggest issue I think I need to tackle right now though, is symmetric NAT. It works with cone NAT, or for connections without a router, but there are still issues with routers that use symmetric NAT. I've run into two people on IRC with such routers, so it's not quite a non issue (as I originally hoped it'd be). Right now, it seems such a person can host a game if they've forwarded 47800, and the client looks for their IP explicitly. It doesn't work if they try to join using the game server. (Although, the game server would at least tell you their IP, you just couldn't double click to join). The simple solution might be to require such routers to forward a known port (such as 47800). It would require a few minor protocol changes, so more downloads. I've also thought of a few ideas to try some sort of punch through using narrowed port scanning based on the other known external port numbers that other clients see. (They tend to clump together).



... but for now, I'm immediately distracted by another project that has nothing to do with OP2.  :P  I'll probably get back to it once people start asking me about it on IRC or something.

Offline OriginalOP2

  • Newbie
  • *
  • Posts: 8
Proposed Net Fix
« Reply #24 on: March 29, 2008, 07:28:26 AM »
So this game is still kicking? Thats good :)
This game was my life for a few years when it was hot. It better not die!
I am very excited about this Net fix. I got my lan buddys playing op2 a few weeks ago and they love it.