Tags:
create new tag
, view all tags

Internet (TCP/UDP) Ports

In the course of trying to understand in more detail (but at a general level), how a web browser interacts with a web server, I realized I needed a little better understanding of ports (as in a web server being set up on port 80). I asked some questions on our local lvlug list and got a good understanding.

For now, I've pretty much just quoted the posts from that thread.

%SECTION{summary}%

See:

Contents

The Questions

With respect to ports on the Internet (as in web servers are typically
on port 80...):

   * Do those ports have anything to do with "real" I/O ports (like
the 64K ports available on the 80x86 series?  (I don't think they do,
put I thought I'd ask for confirmation -- my surmise is that these
"ports" are more a virtual thing, part of the Ethernet specification.
Or, maybe, these ports are synonymous (sp?) with  sockets?)

   * When you talk to a www server on, for example, port 80, I think
of that as being port 80 on the server machine.  But, does that port
80 also somehow refer to the port used on the browser machine?
(Replies are sent back on port 80?)

   * If so, is it also possible to have different ports used on the
two machines, like port 80 on the server talking to port 2000 (just to
pick a number) on the browser?

Any other insights or relevant links will be appreciated.

Aside: Assuming these ports are different than the 64K hardware I/O
ports, what is an appropriate name for these ports-- would you call
them Ethernet ports, Internet ports, IP ports, ...?

The Answers

* Randy Kramer  [2005-01-02T11:10:15]
>    * Do those ports have anything to do with "real" I/O ports (like
> the 64K ports available on the 80x86 series?  (I don't think they do,
> put I thought I'd ask for confirmation -- my surmise is that these
> "ports" are more a virtual thing, part of the Ethernet specification.

No.

> Or, maybe, these ports are synonymous (sp?) with  sockets?)

Not quite.  A socket is an actual connection from one port to another.
When I connect to the IRC server, I'm opening a socket from (say)
cheshirecat.manxome.org:25910 to irc.thelinkuxlink.net:6667

>    * When you talk to a www server on, for example, port 80, I think
> of that as being port 80 on the server machine.  But, does that port
> 80 also somehow refer to the port used on the browser machine?
> (Replies are sent back on port 80?)

No.  With TCP, there is one socket connection used for bidirectional
traffic.  Most operating systems will open outgoing connections on
high-numbered ports which are not used for any well-known service.

>       * If so, is it also possible to have different ports used on the
> two machines, like port 80 on the server talking to port 2000 (just to
> pick a number) on the browser?

See my answer about IRC.  (IRC is a TCP-based protocol.)

> Any other insights or relevant links will be appreciated.

Read the amazingly informative TCP/IP Illustrated, volume 1, by W.
Stevens.  It is probably the best comprehensive introduction to TCP/IP
networking ever written.

If you make it through the first ten chapters, you will know more about
networking than any MCSE you are likely to meet.

> Aside: Assuming these ports are different than the 64K hardware I/O
> ports, what is an appropriate name for these ports-- would you call
> them Ethernet ports, Internet ports, IP ports, ...?

They are TCP or UDP ports, depending on the protocol used.  You will
almost never need to say this explicitly, since context will make it
clear.  "I ran a server on port 92" and "the modem is on port 5" will
never make you think that the server is on a IO port or that the modem
is a TCP device.

--
rjbs

One Clarification

> I'm not totally clear--when my browser talks to a server somewhere on
> its port 80, my machine is using some (unspecified) high-numbered
> port?  (And a socket is connecting the two.)

Basically, yes.

Fetch some resources over http sometime and look at netstat while you're
doing it.  An example line:
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  192.168.1.197.65035    cluster.perl.com.http  ESTABLISHED

--
rjbs

Socket for TCP vs. UDP

Q

Because UDP is connectionless (iiuc), and TCP is (creates) a
connection, is the term (and concept of a)  socket more appropriate
for  TCP (vs. UDP)?

A

"connectionless" is a less accurate term than the canonical "stateless."
One still conencts (using the C "connect()" function, for example) a UDP
socket, which is basically pointing it at the destination to allow
writing.

If a TCP socket is a bidirectional pipeline between two ports, a UDP
socket is an aimed gun, ready to fire off packets.  This is a lousy
analogy, but it's close enough.

--
rjbs

One point that should be born in mind regarding Microsoft's implementation of TCP and UDP. rjbs is correct in his description of these two protocols but Microsoft haven't implemented UDP correctly. It is a barely documented fact that Microsoft's UDP protocol is not "connectionless" in that it sends back a receipt packet.

We only discovered it when writing a UDP protocol based app that kept on failing when the receiving server was turned off! After many hours we found a technote on MSDN to this effect.

-- SteveMayes - 17 Feb 2005

Contributors

  • () RandyKramer - 02 Jan 2005
  • Ricardo Signes - 02 Jan 2005 (via email to the lvlug list)
  • If you edit this page: add your name here; move this to the next line; and if you've used a comment marker (your initials in parenthesis), include it before your WikiName.

Revision Comment

%SECTION{last_revision}%
  • %DATE% —

Page Ratings

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2005-02-17 - SteveMayes
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look