home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / programm / 5192 < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.3 KB  |  47 lines

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