Skip to main content
GameDev.net gamedev.net
🔒 Locked

Test my networking

Started by xDan Nov 29, 2006 at 9:25 AM 12 replies 3.6k views
Original Post
xDan
xDan
Hi. If anybody feels like testing this it would be great! http://games.xzist.org/temp/unholybeta.zip It's not a game yet, just a test. It works fine when I compile it to run locally, with two instances on my machine. However I don't know if it works over the actual internet. I did try one test with another person, and they were not able to connect to me, but this may be a problem with my university firewall or some NAT thing I don't know about. I'm hoping that it would work for other people. I will leave it running in the background all the same! :) It uses UDP port 27960 also http on port 80 to connect to the master server php script (you can specify a http proxy too). In the menu you can select "join game" which *should* connect to anyone else who is playing. Or select "new game" and others *should* be able to connect to you. Not that there's much to do yet, but the in game controls are: wsad - move q/e - change weapon mouse left - shoot mouse right - jump space - "zoom" alt+enter - change windowed/full screen Thanks! If you manage to connect to anyone else let me know! Also there is a temporary bot to test shooting.
Wan
Wan
Seems to be connect properly, even with my firewall turned on.
At the end I got the message "no games available", but I guess that makes sense.

stdout.txt:

Welcome to the alpha!Any future updates will bedisplayed here. Or anything elsethat I so desire.Http Operation: listNot using http proxy...Testing peer: xxx.xxx.xxx.xxx   <-- that was my ip :)Connecting from 0 to the peer ceb5b13eTesting peer: 144.124.220.63Connecting from 0 to the peer 3fdc7c90Testing peer: 206.57.90.223Connecting from 0 to the peer df5a39ceTesting peer: 85.137.6.131Connecting from 0 to the peer 83068955Testing peer: 82.175.74.2Connecting from 0 to the peer 24aaf52Testing peer: 86.141.218.173Connecting from 0 to the peer adda8d56Testing peer: 80.126.171.25Connecting from 0 to the peer 19ab7e50
xDan
xDan
Quote:
At the end I got the message "no games available"

I have had the game running since I posted so you should have connected to me...! One of those IPs is mine. :( So it doesn't seem to be working.

I wonder, is there a way to know if a port is actually open (outgoing and inbound)? (as I can't be sure, i've allowed it my university firewall options but you never can tell if they're blocking something).

Also i've read about NAT and NAT punch through (all the top google hits), but I don't really understand it. How can I tell if I need to worry about this?
From what I read this is just about determining the IP. But presumably, since the external php script records a player's IP, then it is valid. And can be connected to. Or is there something i've missed? Also I read about NAT assigning ports for different users or something. Does this affect the port my game uses?

Some possibly relavent notes:
- my external IP seems to be static
- the game uses ENet. The (local) host is created on port 27960. Other peers are connected to on this port. Is it right to have in and out ports the same? Or is there no distinction, is there just one port.

The connection that *does* work (when it is connecting to the master server) is just downloading the recent IP list from my website. It's the actual peer to peer connection that I need testing.

I don't know if this is very clear. This is my first networked game and i've no real idea how to go about debugging it.

Thanks :)


another thought: does a connection take some time? such as on a slow internet connection like mine. The current time out waiting for it to succeed is 10 seconds.
Gagyi
Gagyi
I dont know if it helps, but I used UDP in my last network "game", and it worked on NAT-NAT connections.
If both clients send data to the other, both NATs will know where to route the UDP messages.
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)
Ozymandias42
Ozymandias42
Quote:
Original post by Gagyi
I dont know if it helps, but I used UDP in my last network "game", and it worked on NAT-NAT connections.
If both clients send data to the other, both NATs will know where to route the UDP messages.


Wait, what?

Seems like you need a third computer no matter what. Even if both clients knew the public IP address of the other machine, and even if both clients knew the port number the other machine opened up, they still wouldn't know the public port number the router opened up, which would likely be different.

I can imagine that for high port numbers, it's likely the routers might pick the same port number, but it's far from guaranteed.

Unless I'm missing something?
xDan
xDan
I was under the impression that after deciding (and hard coding) the port my game uses That was That.

But does this mean a router or something can change the port?

I don't understand how this router IP changing *thing* works! Can anyone explain in simple terms?
hplus0603
hplus0603
This is because of "NAT" and is explained in detail in the Forum FAQ as well as references pointed at from there.
enum Bool { True, False, FileNotFound };
xDan
xDan
I have read the FAQ, and various websites on it but I still had trouble understanding it. :(

But I think I do now after some re reading.

So, my problem is, how can the PHP script find out the peer's NAT box port, as it's just receiving a http request. It doesn't seem possible.

However something is described here:
http://www.cynicalstuff.com/nat-traversal-solutions-for-independent-developers
But it doesn't mention how the php script knows the port. Does anyone understand that method?

Thanks
Karja
Karja
Oh, the peers themselves would have to check what ports that are used! Let's take an example:

Player 1 wants to connect to player 2, and decides what UDP port he will listen to. He passes this information to the HTTP server, along with the PHP request. The server stores this information and then waits for the matching connection request.

After a little time, player 2 also wants to connect, so he does the same thing. By now the server knows the ports that both clients will be listening to, so he sends them their respective information at (roughly) the same time.

When the clients receive this information, they start sending. Which, with all probability, will result in NAT opening up for that combination of IP/port. And since they have a HTTP server to coordinate, they can ensure that they open up at roughly the same time.

Sorry for not making it clearer in my blog entry!
xDan
xDan
I have an issue with this:

"Player 1 wants to connect to player 2, and decides what UDP port he will listen to. He passes this information to the HTTP server,"

I can send the listen port to the php script, but isn't this just the port used internally behind the NAT box? And the NAT box chooses a different return port, which is what other peers should specify.

Unless the NAT box always uses the same port as the clients listen port. But it doesn't seem that is right as the NAT box would only be able to support one game client in its LAN.

Quote:
Sorry for not making it clearer in my blog entry!

You probably made it quite clear, i'm just not understanding the NAT thing. :( Thankyou!
Karja
Karja
Haha... You know, I'm beginning to think that I need to set up a few routers at home to test this more thoroughly. Just like you say, the ports ought to get mismatched after the NAT.

I thought I had a perfectly clear image of how the NAT mapping should happen when I wrote the blog entry, but I must have been drunk or something - now I can't think of a single way that a UDP punch through would work without an external proxy. But I'm sure that I've seen examples of it, so there must be some magic with the UDP-specific NAT mapping going on that I'm too tired to think of now. :)

If I can be arsed, I'll see if I can set up a test for this at home some day.
xDan
xDan
This seems to be similar to what you descibe (well to me anyway ;)). I still don't understand how it avoids the port issue though.
hplus0603
hplus0603
Quote:
It doesn't seem possible.


You're right; a PHP script cannot serve as a NAT introducer (as we typically know and use them).
enum Bool { True, False, FileNotFound };
Gagyi
Gagyi
Well, yes, my game had an introducer... I didnt know that NATs do not chose the same port as output.

[Edited by - Gagyi on December 5, 2006 2:54:07 PM]
-----------------------------------"After you finish the first 90% of a project, you have to finish the other 90%." - Michael Abrashstickman.hu <=my game (please tell me your opinion about it)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.