home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!destroyer!ncar!noao!rstevens
- From: rstevens@noao.edu (W. Richard Stevens)
- Subject: Re: TCP, UDP protocols vs. Unix domain protocols
- Message-ID: <1992Nov6.164445.7870@noao.edu>
- Sender: news@noao.edu
- Nntp-Posting-Host: gemini.tuc.noao.edu
- Organization: National Optical Astronomy Observatories, Tucson, AZ, USA
- References: <1992Nov6.150756.10830@eecs.nwu.edu>
- Date: Fri, 6 Nov 1992 16:44:45 GMT
- Lines: 34
-
- >When a process communicates with another process on the same host using TCP
- >(or UDP), are packets actually put on the network, which then come right back
- >to the host? Or is the communication handled by the kernel (as with the Unix
- >domain protocols)?
-
- Glancing through the current BSD sources the data goes through TCP (or UDP)
- then through IP before it's detected that it's really for the local host.
- Then the packet makes its way back up through IP and TCP.
-
- There are two ways to send it to the local host: to the special IP address
- configured for the loopback interface (normally 127.0.0.1) in which case
- IP just sends it to that driver. The loopback driver output routine just
- puts the packet onto IP's input queue. The other way is to send it to
- your actual IP address. In this case it looks like the packet makes it
- into the ARP code [arpresolve()] where it's detected that the packet is for
- the local host. There's a flag here "useloopback" that default's to 1.
- If this flag is true, the packet is just sent to the loopback driver
- (same as for 127.0.0.1). If the flag is false, however, the packet is
- actually put onto the wire. The comment in the code says that some
- boards can't receive packets that they send, which is why it defaults
- to 1. But, someone at Xerox told me last week that this is really
- false, and if the board can't receive its own transmissions then either
- the board or the driver is broken. (I don't know how true this is.)
- If your kernel defines the variable "useloopback" check what its value
- is, and try setting it to 0 and see what happens :-)
-
- So the bottom line is that using TCP causes the packet to go through
- TCP and IP, whereas a Unix domain stream socket avoids this. As to
- how much you save by using the Unix domain socket, I've never measured
- this.
-
- Realize that other implementations may do things completely differently.
-
- Rich Stevens (rstevens@noao.edu)
-