Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Q: NAT effects on games built with OpenPlay
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q: NAT effects on games built with OpenPlay



> At 04:40 PM 3/20/2002 -0700, Lane Roathe wrote:
>>> I was wondering if OpenPlay games distinquish between two connections to a
>>> multiplayer game from the same IP, like what happens when two players behind
>>> a NAT firewall connect to an internet-hosted game?
>>>
>>> Does it distinguish by the port number from that IP, or just the IP, for
>>> instance?
>>
>> I believe that the NAT handles this translation, and OpenPlay is
>> completely unaware of it. My understanding is that the NAT server marks
>> the outgoing packets with information that identifies the returning
>> packets so that the NAT server can than send the packets to the
>> originating internal IP address.
>
> This is generally true. The "tagging" is actually done by changing the
> source of the packets to come from a unique (for that gateway) port number.
>
> However, the question is still a valid one: "does OpenPlay differentiate
> between clients purely with source IP, or does it look (correctly) at the
> source IP/port pair".

OpenPlay correctly uses an IP address and port pair. As a matter of fact,
since it is just a transport protocol (although abstracted one layer up),
there is no way it could work with only an IP address.


>> This means that you can have multiple players connect to an outside host,
>> but can't have host a game when behind a NAT (since there is no way to
>> identify the server from outside).
>
> Actually, there a solution here: port based redirection. For example, if
> you want to run a web server behind a NAT, you could configure all inbound
> traffic to port 80 to particular internal IP address (how you configure
> this is software/hardware dependant). For the perspective of the client,
> the external IP of the gateway is the server.
>
> Of course, this solution requires that the user know which ports need to be
> redirected for a particular application.

Otherwise known as "port mapping", this is taken care of by the owner of the
NAT resource, which as you say will often be the end user. OpenPlay doesn't
get involved in this.

>> Please note that I'm not a networking expert, so this may be incorrect
>> but the end result is what I experience on my local NAT system.
>
> Various NAT's can behave a little differently, but there are some critical
> rules you can use to improve compatibility:
>
> 1) Never transmit your concept of your own IP to the far end, unless you
> are explicitly prepared to handle the NAT case. The IP the your peer sees
> and the IP that you see may be different. That's OK.
>
> 2) Always have the client initiate "extra" connections to the server, never
> try to have the server connect back to the client on the client's apparent
> IP address. This will break many NATs/firewalls.
>
> 3) Be very careful with UDP. Because UDP is connectionless, it provide
> special challenges for NAT. In particular:
>
> 3a) Most NATs only keep UDP mappings alive by timeout, usually a couple of
> minutes. (There are exceptions, such as the WGIC, which have software on
> the internal LAN machines to watch when UDP sockets and opened and closed,
> this isn't really a NAT though, but I digress...). This means that you
> should send at least one packet a minute to be sure the connection will
> stay up. Not a problem for most action games ;-)
>
> 3b) The client must send the first UDP packet, not the server (this is
> similar to (2)). The server machine should always send UDP packets back to
> the same *port* that the client first used. Otherwise, the NAT probably
> won't recognise the UDP mapping.
>

All of this is correct and is well understood by most of the networking
programmers on this list (I think). OpenPlay itself is completely oblivious
to whether NAT is occurring somewhere along the route. The developer
himself must understand (and account for, if he wants to) all of the
warnings that you listed above.

I hope that your original question has been answered.


Randy Thompson
_______________________________________________
openplay-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/openplay-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Q: NAT effects on games built with OpenPlay (From: Timothy Wayper <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.