NYCPHP Meetup

NYPHP.org

[nycphp-talk] A little network help

John Lacey jlacey at att.net
Fri Jul 16 10:25:29 EDT 2004


LeeEyerman at aol.com wrote:

> That was my initial reaction too, but how would you then route the 
> http, ftp, etc requests with just one static ip from the ISP?

caught the tail end of this convo... the "routing" of the various server 
requests, e.g. http, ftp, etc is handled not by the IP address, but by 
the Destination Port in the TCP header.

For example, let's say a packet arrives at your router and matches your 
IP address (disregard "internal" vs. "external" addresses). The router 
then forwards the packet to your box over the Ethernet LAN.  Once in the 
box, the IP layer process (software) forwards the packet up to the TCP 
process.  TCP examines the Destination Port and essentially asks: "what 
service/process is waiting for requests on this port?"
Assuming an httpd server is running (e.g. apache), that server "signed 
up" to receive requests on Port 80.  TCP then "forwards" the request to 
the httpd process.  Of course, it's a bit more complicated than that, 
since TCP doesn't really "forward" the request to Apache, but schedules 
that service to run by placing it's process id (PID) in the O/S 
scheduler's "ready queue".  But that's the essence of it.

If, on the other hand, an FTP request came in, the IP address gets it to 
the box as above.  But this time the TCP Destination Port is Port 21, 
which is the port ftp waits on for requests.  If an SSH request came in, 
and the sshd server was running, a packet directed to Port 22 would "end 
up" being sent to sshd.

There's a couple examples and hope that helps.
John




More information about the talk mailing list