FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP socket and NAT
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: PHP socket and NAT [message #177127 is a reply to message #177122] Thu, 23 February 2012 13:04 Go to previous messageGo to previous message
SL is currently offline  SL
Messages: 20
Registered: February 2012
Karma:
Junior Member
>> NAT typically is used to change IP-addresses (and maybe port).
>> If A and B are in the same LAN I expect they can address each other
>> directly.
>> For example:
>> A IP: 192.168.178.22
>> B IP: 192.168.178.25
>>
>> Once you go outside your LAN, you (might) need NAT.
>>
>> And sockets have little to do with NAT.
>> A IP package arrives at a certain IP on a certain port: If some
>> socket is listening on that port on that machine, the package will
>> be handled by the listening process.
>>
>> NAT itself is performed by routers and such, not by some service
>> listening to a port.
>>
>> SO in short: No you have to care about it.
>>
>> Disclaimer: If you are talking IP6, things are different.
>>
>> Regards,
>> Erwin Moller
>>
>
> An additional example of NAT that makes things clear.
> This is how it was explained to me when I wanted to know about NAT.
>
> Suppose you have 10 computers on your LAN, and 1 internet gateway
> (some ADSL modem for example).
> All you 10 computers can connect to the internet because they use the
> routers IP address as the gateway.
>
> The router has an INTERNAL (LAN-side) IP address.
> Let's say this LAN-IP is 192.168.178.1
>
> The router also has an EXTERNAL (Internet-side) IP address.
> Let's say internet-side IP is 69.147.94.94. (I made the numbers up)
>
> Now, suppose a few people on the LAN are visiting some websites.
> Suppose compA has IP address 192.168.178.22. (On the LAN)
> Suppose compA has IP address 192.168.178.50. (On the LAN)
>
> CompA (192.168.178.22): requests www.google.com
> CompB: (192.168.178.50)requests www.php.net
>
> The router receives these requests from the LAN side, and sends the
> requests to www.google.com and www.php.net.
> The servers from Google and PHP answer the requests, and send them
> back to the router's IP address (being 69.147.94.94).
>
> Now the problem: How should the router handle these answers? Should it
> send them to 192.168.178.22 or 192.168.178.50, or even another IP on
> the LAN?
>
> This is where NAT comes into the picture.
> It works like this:
> 1) Router receives request from 192.168.178.22 (=LAN)for
> www.google.com. 2) Router thinks up some random port that is not is
> use, eg 33000. 3) Router stores this portnumber (33000) in a table
> together with the requesting LAN IP-address (192.168.178.22).
> 4) Router sends the request to www.google.com TOGETHER with the
> instruction to answer on port 33000.
> 5) When Google answers, the router looks up the portnumber, ans sees
> what (internal) IP-address made this request. This way the router can
> see which internal IP-adress made what request because they all get
> random assigned portnumbers.
>
> That is NAT in short.
>
> So I don't expect you have to worry about that in your case.
>

This example clears the air. So the key is the router comes up with random
port number, and the reply specifies that port number.

Thanks a lot.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: chat on web, Ajax ?
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 09:15:54 GMT 2024

Total time taken to generate the page: 0.05242 seconds