home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / Documents / FAQ / Internet / tcptutor.txt < prev   
Text File  |  1993-01-27  |  93KB  |  1,757 lines

  1.  
  2. From: ski!ptsfa!ames!ucbcad!ucbvax!husc6!rutgers!topaz.rutgers.edu!hedrick
  3. Article 111 of comp.protocols.tcp-ip:
  4. ion: version B 2.10.2 9/18/84; site ski.UUCP
  5. Path: ski!ptsfa!ames!ucbcad!ucbvax!husc6!rutgers!topaz.rutgers.edu!hedrick
  6. >From: hedrick@topaz.rutgers.edu (Charles Hedrick)
  7. Newsgroups: comp.protocols.tcp-ip
  8. Subject: revised TCP/IP document, part I of II
  9. Message-ID: <13128@topaz.rutgers.edu>
  10. Date: 3 Jul 87 09:58:03 GMT
  11. Date-Received: 4 Jul 87 09:39:42 GMT
  12. Organization: Rutgers Univ., New Brunswick, N.J.
  13. Lines: 900
  14.  
  15.  
  16. The following is a revised (and I hope final) version of the TCP/IP
  17. introduction I posted a week ago.  It takes into account comments that
  18. I got from a number of helpful people, and adds a good deal of extra
  19. material.  Originally, I intended it to give my own staff enough
  20. background to read the RFC's.  It appears that there was a need for a
  21. bit more general introduction.  I have tried to do that, to the extent
  22. that I could.
  23.  
  24. Various people asked for permission to distribute it to their staff
  25. (or even customers).  I have added a copyright that tries to make it
  26. clear that this is OK.
  27.  
  28. If you don't have TCP/IP, and this convinces you that you should get
  29. it, the NIC (whose address is given in the last section) has a list of
  30. implementations.  However these days, most equipment vendors can
  31. supply TCP/IP, or point you to a 3rd party who can.
  32.  
  33. This posting is in two parts, because inews claimed that postings over
  34. 64K bytes were a bad idea.
  35.  
  36.                 -----------------------------------
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.                              Introduction
  50.                                   to
  51.                         the Internet Protocols
  52.  
  53.  
  54.  
  55.  
  56.  
  57.                       C                       R
  58.  
  59.                               C       S
  60.                   Computer Science Facilities Group
  61.                               C       I
  62.  
  63.                       L                       S
  64.  
  65.  
  66.                                RUTGERS
  67.                   The State University of New Jersey
  68.  
  69.  
  70.  
  71.  
  72.                              3 July 1987
  73.  
  74. This is an introduction to the Internet networking protocols (TCP/IP).
  75. It  includes  a  summary  of  the  facilities  available   and   brief
  76. descriptions of the major protocols in the family.
  77.  
  78. Copyright  (C)  1987,  Charles  L. Hedrick.  Anyone may reproduce this
  79. document, in whole or in  part,  provided  that:    (1)  any  copy  or
  80. republication  of  the entire document must show Rutgers University as
  81. the source, and must include this notice; and (2)  any  other  use  of
  82. this  material  must reference this manual and Rutgers University, and
  83. the fact that the material is copyright by Charles Hedrick and is used
  84. by permission.
  85.  
  86.  
  87.  
  88. Unix is a trademark of AT&T Technologies, Inc.
  89.  
  90.  
  91.  
  92.                           Table of Contents
  93.  
  94.  
  95.    1. What is TCP/IP?                                                1
  96.    2. General description of the TCP/IP protocols                    5
  97.        2.1 The TCP level                                             7
  98.        2.2 The IP level                                             10
  99.        2.3 The Ethernet level                                       11
  100.    3. Well-known sockets and the applications layer                 12
  101.        3.1 An example application: SMTP                             15
  102.    4. Protocols other than TCP: UDP and ICMP                        17
  103.    5. Keeping track of names and information: the domain system     18
  104.    6. Routing                                                       20
  105.    7. Details about Internet addresses: subnets and broadcasting    21
  106.    8. Datagram fragmentation and reassembly                         23
  107.    9. Ethernet encapsulation: ARP                                   24
  108.    10. Getting more information                                     25
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.                                   i
  148.  
  149.  
  150.  
  151. This document is a brief introduction to TCP/IP, followed by advice on
  152. what to read for more information.  This  is  not  intended  to  be  a
  153. complete  description.    It  can  give  you  a reasonable idea of the
  154. capabilities of the protocols.  But if you need to know any details of
  155. the  technology,  you  will  want  to  read  the  standards  yourself.
  156. Throughout the text, you will find references to the standards, in the
  157. form of "RFC" or "IEN" numbers.  These are document numbers. The final
  158. section of this  document  tells  you  how  to  get  copies  of  those
  159. standards.
  160.  
  161.  
  162.  
  163. 1. What is TCP/IP?
  164.  
  165.  
  166. TCP/IP  is a set of protocols developed to allow cooperating computers
  167. to share resources across a network.  It was developed by a  community
  168. of  researchers centered around the ARPAnet.  Certainly the ARPAnet is
  169. the best-known TCP/IP network.  However as of June, 87, at  least  130
  170. different  vendors  had products that support TCP/IP, and thousands of
  171. networks of all kinds use it.
  172.  
  173. First some basic definitions.  The most accurate name for the  set  of
  174. protocols we are describing is the "Internet protocol suite".  TCP and
  175. IP are two of the protocols in this suite.  (They  will  be  described
  176. below.)    Because  TCP and IP are the best known of the protocols, it
  177. has become common to use the term TCP/IP or IP/TCP  to  refer  to  the
  178. whole  family.  It is probably not worth fighting this habit.  However
  179. this can lead to some oddities.  For example, I  find  myself  talking
  180. about  NFS as being based on TCP/IP, even though it doesn't use TCP at
  181. all.  (It does use IP.  But it  uses  an  alternative  protocol,  UDP,
  182. instead  of TCP.  All of this alphabet soup will be unscrambled in the
  183. following pages.)
  184.  
  185. The Internet is a  collection  of  networks,  including  the  Arpanet,
  186. NSFnet, regional networks such as NYsernet, local networks at a number
  187. of University and research institutions,  and  a  number  of  military
  188. networks.  The term "Internet" applies to this entire set of networks.
  189. The subset of them that is managed by the  Department  of  Defense  is
  190. referred  to  as the "DDN" (Defense Data Network).  This includes some
  191. research-oriented networks, such as  the  Arpanet,  as  well  as  more
  192. strictly  military  ones.    (Because much of the funding for Internet
  193. protocol developments is done via  the  DDN  organization,  the  terms
  194. Internet  and  DDN  can  sometimes  seem  equivalent.)    All of these
  195. networks are connected to each other.  Users can  send  messages  from
  196. any  of  them  to  any other, except where there are security or other
  197. policy restrictions on access.    Officially  speaking,  the  Internet
  198. protocol  documents  are  simply  standards  adopted  by  the Internet
  199. community for its own use.  More recently, the Department  of  Defense
  200. issued a MILSPEC definition of TCP/IP.  This was intended to be a more
  201. formal definition, appropriate for use in  purchasing  specifications.
  202. However  most  of  the  TCP/IP community continues to use the Internet
  203. standards.  The MILSPEC version is intended to be consistent with it.
  204.  
  205. Whatever it is called, TCP/IP is a family of protocols.  A few provide
  206.                                   1
  207.  
  208.  
  209.  
  210. "low-level" functions needed for many applications.  These include IP,
  211. TCP, and UDP.  (These will be described in a bit more  detail  later.)
  212. Others are protocols for doing specific tasks, e.g. transferring files
  213. between computers, sending mail, or finding out who is  logged  in  on
  214. another   computer.      Initially  TCP/IP  was  used  mostly  between
  215. minicomputers or mainframes.  These machines had their own disks,  and
  216. generally  were self-contained.  Thus the most important "traditional"
  217. TCP/IP services are:
  218.  
  219.    - file transfer.  The file transfer protocol (FTP) allows a user on
  220.      any computer to get files from another computer, or to send files
  221.      to another computer.  Security is handled by requiring  the  user
  222.      to  specify  a  user  name  and  password for the other computer.
  223.      Provisions are made for handling file transfer  between  machines
  224.      with different character set, end of line conventions, etc.  This
  225.      is not quite the same thing as more recent "network file  system"
  226.      or  "netbios"  protocols, which will be described below.  Rather,
  227.      FTP is a utility that you run any time you want to access a  file
  228.      on  another  system.    You  use  it to copy the file to your own
  229.      system.  You then work with the local copy.   (See  RFC  959  for
  230.      specifications for FTP.)
  231.  
  232.    - remote  login.    The network terminal protocol (TELNET) allows a
  233.      user to log in on any other computer on the network.  You start a
  234.      remote session by specifying a computer to connect to.  From that
  235.      time until you finish the session, anything you type is  sent  to
  236.      the  other  computer.   Note that you are really still talking to
  237.      your own computer.  But the telnet program effectively makes your
  238.      computer invisible while it is running.  Every character you type
  239.      is sent directly to the other system.  Generally, the  connection
  240.      to  the  remote  computer  behaves much like a dialup connection.
  241.      That is, the remote system will ask you to  log  in  and  give  a
  242.      password, in whatever manner it would normally ask a user who had
  243.      just dialed it up.  When you log off of the other  computer,  the
  244.      telnet  program exits, and you will find yourself talking to your
  245.      own computer.  Microcomputer implementations of telnet  generally
  246.      include  a  terminal  emulator  for some common type of terminal.
  247.      (See RFC's 854 and 855 for specifications for  telnet.    By  the
  248.      way,  the  telnet protocol should not be confused with Telenet, a
  249.      vendor of commercial network services.)
  250.  
  251.    - computer mail.  This allows you to  send  messages  to  users  on
  252.      other  computers.    Originally, people tended to use only one or
  253.      two specific computers.  They  would  maintain  "mail  files"  on
  254.      those machines.  The computer mail system is simply a way for you
  255.      to add a message to another user's mail file.    There  are  some
  256.      problems  with  this  in  an environment where microcomputers are
  257.      used.  The most serious is that a micro is  not  well  suited  to
  258.      receive  computer  mail.    When you send mail, the mail software
  259.      expects to be able  to  open  a  connection  to  the  addressee's
  260.      computer, in order to send the mail.  If this is a microcomputer,
  261.      it may be turned off, or it may be running an  application  other
  262.      than  the mail system.  For this reason, mail is normally handled
  263.      by a larger system, where it is practical to have a  mail  server
  264.      running all the time.  Microcomputer mail software then becomes a
  265.                                   2
  266.  
  267.  
  268.  
  269.      user interface that retrieves mail from the mail  server.    (See
  270.      RFC  821  and  822 for specifications for computer mail.  See RFC
  271.      937 for a protocol designed for microcomputers to use in  reading
  272.      mail from a mail server.)
  273.  
  274. These  services  should  be  present  in any implementation of TCP/IP,
  275. except that micro-oriented implementations may  not  support  computer
  276. mail.  These traditional applications still play a very important role
  277. in TCP/IP-based networks.  However more recently,  the  way  in  which
  278. networks  are  used has been changing.  The older model of a number of
  279. large, self-sufficient computers is beginning to  change.    Now  many
  280. installations    have    several   kinds   of   computers,   including
  281. microcomputers, workstations, minicomputers, and  mainframes.    These
  282. computers  are  likely  to be configured to perform specialized tasks.
  283. Although people are still likely to work with one  specific  computer,
  284. that  computer  will  call on other systems on the net for specialized
  285. services.  This has  led  to  the  "server/client"  model  of  network
  286. services.    A server is a system that provides a specific service for
  287. the rest of the network.  A client is another system  that  uses  that
  288. service.    (Note  that the server and client need not be on different
  289. computers.  They could be  different  programs  running  on  the  same
  290. computer.)    Here  are  the  kinds  of servers typically present in a
  291. modern computer setup.  Note that these computer services can  all  be
  292. provided within the framework of TCP/IP.
  293.  
  294.    - network  file  systems.   This allows a system to access files on
  295.      another computer in a somewhat more  closely  integrated  fashion
  296.      than FTP.  A network file system provides the illusion that disks
  297.      or other devices from one system are directly connected to  other
  298.      systems.    There  is no need to use a special network utility to
  299.      access a file on another system.  Your computer simply thinks  it
  300.      has  some  extra disk drives.  These extra "virtual" drives refer
  301.      to the other system's disks.    This  capability  is  useful  for
  302.      several different purposes.  It lets you put large disks on a few
  303.      computers, but still give others access to the disk space.  Aside
  304.      from the obvious economic benefits, this allows people working on
  305.      several computers  to  share  common  files.    It  makes  system
  306.      maintenance  and  backup  easier, because you don't have to worry
  307.      about updating  and  backing  up  copies  on  lots  of  different
  308.      machines.    A  number  of  vendors  now  offer  high-performance
  309.      diskless computers.  These computers have no disk drives at  all.
  310.      They  are  entirely dependent upon disks attached to common "file
  311.      servers".   (See  RFC's  1001  and  1002  for  a  description  of
  312.      PC-oriented   NetBIOS   over   TCP.     In  the  workstation  and
  313.      minicomputer area, Sun's Network File System is more likely to be
  314.      used.    Protocol  specifications  for  it are available from Sun
  315.      Microsystems.)
  316.  
  317.    - remote printing.  This allows you to  access  printers  on  other
  318.      computers  as if they were directly attached to yours.  (The most
  319.      commonly used protocol is the remote  lineprinter  protocol  from
  320.      Berkeley  Unix.  Unfortunately, there is no protocol document for
  321.      this.  However the C code is easily obtained  from  Berkeley,  so
  322.      implementations are common.)
  323.  
  324.                                   3
  325.  
  326.  
  327.  
  328.    - remote  execution.   This allows you to request that a particular
  329.      program be run on a different computer.  This is useful when  you
  330.      can  do  most  of  your work on a small computer, but a few tasks
  331.      require the resources of a larger system.  There are a number  of
  332.      different  kinds  of remote execution.  Some operate on a command
  333.      by command basis.  That is, you request that a  specific  command
  334.      or  set  of commands should run on some specific computer.  (More
  335.      sophisticated versions will choose a system that  happens  to  be
  336.      free.)    However  there are also "remote procedure call" systems
  337.      that allow a program to  call  a  subroutine  that  will  run  on
  338.      another  computer.    (There  are  many  protocols  of this sort.
  339.      Berkeley Unix contains two servers to execute commands  remotely:
  340.      rsh  and  rexec.   The man pages describe the protocols that they
  341.      use.  The user-contributed software with Berkeley 4.3 contains  a
  342.      "distributed  shell"  that  will  distribute tasks among a set of
  343.      systems, depending upon load.  Remote procedure  call  mechanisms
  344.      have  been  a  topic  for research for a number of years, so many
  345.      organizations have implementations of such facilities.  The  most
  346.      widespread commercially-supported remote procedure call protocols
  347.      seem to be Xerox's Courier and Sun's RPC.  Protocol documents are
  348.      available  from  Xerox and Sun.  There is a public implementation
  349.      of Courier over TCP as part of the user-contributed software with
  350.      Berkeley  4.3.   An implementation of RPC was posted to Usenet by
  351.      Sun, and also appears as part of  the  user-contributed  software
  352.      with Berkeley 4.3.)
  353.  
  354.    - name  servers.    In  large  installations, there are a number of
  355.      different collections of names that have to  be  managed.    This
  356.      includes  users  and their passwords, names and network addresses
  357.      for computers, and accounts.  It becomes  very  tedious  to  keep
  358.      this data up to date on all of the computers.  Thus the databases
  359.      are kept on a small number of systems.  Other systems access  the
  360.      data over the network.  (RFC 822 and 823 describe the name server
  361.      protocol used to keep track of host names and Internet  addresses
  362.      on  the  Internet.    This  is  now a required part of any TCP/IP
  363.      implementation.  IEN 116 describes an older name server  protocol
  364.      that is used by a few terminal servers and other products to look
  365.      up host names.  Sun's  Yellow  Pages  system  is  designed  as  a
  366.      general  mechanism to handle user names, file sharing groups, and
  367.      other databases commonly used by Unix  systems.    It  is  widely
  368.      available  commercially.    Its  protocol definition is available
  369.      from Sun.)
  370.  
  371.    - terminal servers.  Many installations no longer connect terminals
  372.      directly  to  computers.    Instead they connect them to terminal
  373.      servers.  A terminal server is simply a small computer that  only
  374.      knows  how  to  run  telnet  (or some other protocol to do remote
  375.      login).  If your terminal is  connected  to  one  of  these,  you
  376.      simply  type the name of a computer, and you are connected to it.
  377.      Generally it is possible to have active connections to more  than
  378.      one  computer  at  the  same time.  The terminal server will have
  379.      provisions to switch between connections rapidly, and  to  notify
  380.      you  when  output  is  waiting for another connection.  (Terminal
  381.      servers use the telnet protocol, already mentioned.  However  any
  382.      real terminal server will also have to support name service and a
  383.                                   4
  384.  
  385.  
  386.  
  387.      number of other protocols.)
  388.  
  389.    - network-oriented  window  systems.      Until   recently,   high-
  390.      performance  graphics  programs had to execute on a computer that
  391.      had  a  bit-mapped  graphics  screen  directly  attached  to  it.
  392.      Network  window  systems  allow  a  program to use a display on a
  393.      different computer.  Full-scale network window systems provide an
  394.      interface  that  lets you distribute jobs to the systems that are
  395.      best  suited  to  handle  them,  but  still  give  you  a  single
  396.      graphically-based  user  interface.  (The most widely-implemented
  397.      window system is X. A  protocol  description  is  available  from
  398.      MIT's  Project  Athena.  A reference implementation is publically
  399.      available from MIT.  A number  of  vendors  are  also  supporting
  400.      NeWS,  a window system defined by Sun.  Both of these systems are
  401.      designed to use TCP/IP.)
  402.  
  403. Note that some of the  protocols  described  above  were  designed  by
  404. Berkeley,  Sun,  or other organizations.  Thus they are not officially
  405. part of the Internet protocol suite.   However  they  are  implemented
  406. using  TCP/IP, just as normal TCP/IP application protocols are.  Since
  407. the protocol definitions are not  considered  proprietary,  and  since
  408. commercially-support  implementations  are  widely  available,  it  is
  409. reasonable to think of these protocols as being  effectively  part  of
  410. the  Internet  suite.   Note that the list above is simply a sample of
  411. the sort of services  available  through  TCP/IP.    However  it  does
  412. contain   the  majority  of  the  "major"  applications.    The  other
  413. commonly-used protocols tend to be specialized facilities for  getting
  414. information  of  various  kinds, such as who is logged in, the time of
  415. day, etc.  However if you need a facility that is not listed here,  we
  416. encourage  you  to  look  through  the  current  edition  of  Internet
  417. Protocols (currently RFC 1011),  which  lists  all  of  the  available
  418. protocols,   and   also   to   look   at  some  of  the  major  TCP/IP
  419. implementations to see what various vendors have added.
  420.  
  421.  
  422.  
  423. 2. General description of the TCP/IP protocols
  424.  
  425.  
  426. TCP/IP is a layered set of protocols.  In  order  to  understand  what
  427. this  means,  it is useful to look at an example.  A typical situation
  428. is sending mail.  First, there is a protocol for mail.  This defines a
  429. set  of  commands which one machine sends to another, e.g. commands to
  430. specify who the sender of the message is, who it is being sent to, and
  431. then  the  text  of  the  message.  However this protocol assumes that
  432. there is a way to communicate  reliably  between  the  two  computers.
  433. Mail,  like  other  application  protocols,  simply  defines  a set of
  434. commands and messages to be sent.  It is designed to be used  together
  435. with  TCP and IP. TCP is responsible for making sure that the commands
  436. get through to the other end.  It keeps track of  what  is  sent,  and
  437. retransmitts anything that did not get through.  If any message is too
  438. large for one datagram, e.g. the text of the mail, TCP will  split  it
  439. up  into  several  datagrams,  and  make  sure  that  they  all arrive
  440. correctly.  Since these functions are needed  for  many  applications,
  441. they are put together into a separate protocol, rather than being part
  442.                                   5
  443.  
  444.  
  445.  
  446. of the specifications for sending mail.   You  can  think  of  TCP  as
  447. forming a library of routines that applications can use when they need
  448. reliable network communications with another computer.  Similarly, TCP
  449. calls  on the services of IP.  Although the services that TCP supplies
  450. are needed by  many  applications,  there  are  still  some  kinds  of
  451. applications  that  don't  need them.  However there are some services
  452. that every application needs.  So these services are put together into
  453. IP.    As  with TCP, you can think of IP as a library of routines that
  454. TCP calls on, but which is also available to applications  that  don't
  455. use  TCP.    This  strategy  of building several levels of protocol is
  456. called "layering".  We think of  the  applications  programs  such  as
  457. mail,  TCP, and IP, as being separate "layers", each of which calls on
  458. the services of the layer below it.   Generally,  TCP/IP  applications
  459. use 4 layers:
  460.  
  461.    - an application protocol such as mail
  462.  
  463.    - a  protocol  such  as  TCP  that  provides  services need by many
  464.      applications
  465.  
  466.    - IP, which provides the basic  service  of  getting  datagrams  to
  467.      their destination
  468.  
  469.    - the  protocols  needed to manage a specific physical medium, such
  470.      as Ethernet or a point to point line.
  471.  
  472. TCP/IP is based on the "catenet model".  (This is  described  in  more
  473. detail  in  IEN 48.)  This model assumes that there are a large number
  474. of independent networks connected together  by  gateways.    The  user
  475. should  be able to access computers or other resources on any of these
  476. networks.   Datagrams  will  often  pass  through  a  dozen  different
  477. networks  before  getting  to  their  final  destination.  The routing
  478. needed to accomplish this should be completely invisible to the  user.
  479. As  far  as  the  user  is concerned, all he needs to know in order to
  480. access another system is an "Internet address".  This  is  an  address
  481. that looks like 128.6.4.194.  It is actually a 32-bit number.  However
  482. it is normally written as 4 decimal numbers, each representing 8  bits
  483. of  the  address.  (The term "octet" is used by Internet documentation
  484. for such 8-bit chunks.  The term "byte" is not used, because TCP/IP is
  485. supported  by  some computers that have byte sizes other than 8 bits.)
  486. Generally the structure of the  address  gives  you  some  information
  487. about  how  to  get  to  the  system.  For example, 128.6 is a network
  488. number assigned by a central authority to Rutgers University.  Rutgers
  489. uses  the  next  octet  to  indicate  which of the campus Ethernets is
  490. involved.  128.6.4 happens to be an  Ethernet  used  by  the  Computer
  491. Science  Department.    The last octet allows for up to 254 systems on
  492. each Ethernet.  (It is 254 because 0 and  255  are  not  allowed,  for
  493. reasons  that  will  be  discussed  later.)  Note that 128.6.4.194 and
  494. 128.6.5.194 would be different systems.  The structure of an  Internet
  495. address is described in a bit more detail later.
  496.  
  497. Of  course  we  normally  refer  to  systems  by  name, rather than by
  498. Internet address.  When we specify a name, the network software  looks
  499. it  up  in  a  database,  and comes up with the corresponding Internet
  500. address.  Most of the network software deals strictly in terms of  the
  501.                                   6
  502.  
  503.  
  504.  
  505. address.  (RFC 882 describes the name server technology used to handle
  506. this lookup.)
  507.  
  508. TCP/IP is  built  on  "connectionless"  technology.    Information  is
  509. transfered  as  a sequence of "datagrams".  A datagram is a collection
  510. of data that is sent as a single message.  Each of these datagrams  is
  511. sent  through  the network individually.  There are provisions to open
  512. connections (i.e.  to start a conversation that will continue for some
  513. time).    However at some level, information from those connections is
  514. broken up into datagrams, and  those  datagrams  are  treated  by  the
  515. network  as  completely  separate.    For example, suppose you want to
  516. transfer a 15000 octet file.  Most networks can't handle a 15000 octet
  517. datagram.   So the protocols will break this up into something like 30
  518. 500-octet datagrams.  Each of these datagrams  will  be  sent  to  the
  519. other  end.    At  that point, they will be put back together into the
  520. 15000-octet file.  However while those datagrams are in  transit,  the
  521. network doesn't know that there is any connection between them.  It is
  522. perfectly possible  that  datagram  14  will  actually  arrive  before
  523. datagram  13.    It is also possible that somewhere in the network, an
  524. error will occur, and some datagram won't get through at all.  In that
  525. case, that datagram has to be sent again.
  526.  
  527. Note  by  the way that the terms "datagram" and "packet" often seem to
  528. be nearly interchangable.  Technically, datagram is the right word  to
  529. use  when  describing  TCP/IP.  A datagram is a unit of data, which is
  530. what the protocols deal with.  A packet is a physical thing, appearing
  531. on an Ethernet or some wire.  In most cases a packet simply contains a
  532. datagram, so there is  very  little  difference.    However  they  can
  533. differ.  When TCP/IP is used on top of X.25, the X.25 interface breaks
  534. the datagrams up into 128-byte packets.   This  is  invisible  to  IP,
  535. because  the  packets  are put back together into a single datagram at
  536. the other end before being processed by TCP/IP.  So in this case,  one
  537. IP  datagram  would  be carried by several packets.  However with most
  538. media, there are efficiency advantages to  sending  one  datagram  per
  539. packet, and so the distinction tends to vanish.
  540.  
  541.  
  542.  
  543. 2.1 The TCP level
  544.  
  545.  
  546. Two separate protocols are involved in handling TCP/IP datagrams.  TCP
  547. (the "transmission control protocol") is responsible for  breaking  up
  548. the  message  into  datagrams,  reassembling  them  at  the other end,
  549. resending anything that gets lost, and  putting  things  back  in  the
  550. right  order.  IP (the "internet protocol") is responsible for routing
  551. individual datagrams.  It may seem like TCP is  doing  all  the  work.
  552. And  in  small networks that is true.  However in the Internet, simply
  553. getting a datagram to its  destination  can  be  a  complex  job.    A
  554. connection  may require the datagram to go through several networks at
  555. Rutgers, a serial line to the John von Neuman Supercomputer Center,  a
  556. couple  of Ethernets there, a series of 56Kbaud phone lines to another
  557. NSFnet site, and more Ethernets on another campus.  Keeping  track  of
  558. the  routes  to all of the destinations and handling incompatibilities
  559. among different transport media turns out to be a complex job.    Note
  560.                                   7
  561.  
  562.  
  563.  
  564. that  the  interface  between TCP and IP is fairly simple.  TCP simply
  565. hands IP a datagram with a destination.   IP  doesn't  know  how  this
  566. datagram relates to any datagram before it or after it.
  567.  
  568. It  may  have occurred to you that something is missing here.  We have
  569. talked about Internet addresses, but not about how you keep  track  of
  570. multiple  connections  to  a given system.  Clearly it isn't enough to
  571. get a datagram to the right  destination.    TCP  has  to  know  which
  572. connection  this  datagram  is  part  of.  This task is referred to as
  573. "demultiplexing."  In fact, there are several levels of demultiplexing
  574. going  on in TCP/IP.  The information needed to do this demultiplexing
  575. is contained in a series of "headers".  A header is simply a few extra
  576. octets  tacked  onto  the  beginning of a datagram by some protocol in
  577. order to keep track of it.  It's a lot like putting a letter  into  an
  578. envelope  and  putting  an  address  on  the  outside of the envelope.
  579. Except with modern networks it happens several times.  It's  like  you
  580. put the letter into a little envelope, your secretary puts that into a
  581. somewhat bigger envelope, the campus mail center  puts  that  envelope
  582. into a still bigger one, etc.  Here is an overview of the headers that
  583. get stuck on a message that passes through a typical TCP/IP network:
  584.  
  585. We start with a single data stream, say a file you are trying to  send
  586. to some other computer:
  587.  
  588.    ......................................................
  589.  
  590. TCP  breaks  it  up into manageable chunks.  (In order to do this, TCP
  591. has to know how large a datagram your network can handle.    Actually,
  592. the TCP's at each end say how big a datagram they can handle, and then
  593. they pick the smallest size.)
  594.  
  595.    ....   ....   ....   ....   ....   ....   ....   ....
  596.  
  597. TCP puts a header at the front of each datagram.  This header actually
  598. contains  at least 20 octets, but the most important ones are a source
  599. and destination "port number" and  a  "sequence  number".    The  port
  600. numbers  are used to keep track of different conversations.  Suppose 3
  601. different people are transferring files.  Your TCP might allocate port
  602. numbers 1000, 1001, and 1002 to these transfers.  When you are sending
  603. a datagram, this becomes the "source" port number, since you  are  the
  604. source  of  the  datagram.    Of  course  the TCP at the other end has
  605. assigned a port number of its own for the conversation.  Your TCP  has
  606. to  know the port number used by the other end as well.  (It finds out
  607. when the connection starts, as we will explain below.)  It  puts  this
  608. in  the  "destination" port field.  Of course if the other end sends a
  609. datagram back to you, the source and destination port numbers will  be
  610. reversed,  since  then  it  will  be  the  source  and you will be the
  611. destination.  Each datagram has a sequence number.  This  is  used  so
  612. that  the  other  end  can make sure that it gets the datagrams in the
  613. right  order,  and  that  it  hasn't  missed  any.    (See   the   TCP
  614. specification for details.)  TCP doesn't number the datagrams, but the
  615. octets.  So if there are 500 octets of  data  in  each  datagram,  the
  616. first datagram might be numbered 0, the second 500, the next 1000, the
  617. next 1500, etc.  Finally, I will mention the  Checksum.    This  is  a
  618. number  that  is  computed by adding up all the octets in the datagram
  619.                                   8
  620.  
  621.  
  622.  
  623. (more or less - see the TCP spec).  The result is put in  the  header.
  624. TCP  at  the other end computes the checksum again.  If they disagree,
  625. then something bad happened to the datagram in transmission, and it is
  626. thrown away.  So here's what the datagram looks like now.
  627.  
  628.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  629.     |          Source Port          |       Destination Port        |
  630.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  631.     |                        Sequence Number                        |
  632.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  633.     |                    Acknowledgment Number                      |
  634.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  635.     |  Data |           |U|A|P|R|S|F|                               |
  636.     | Offset| Reserved  |R|C|S|S|Y|I|            Window             |
  637.     |       |           |G|K|H|T|N|N|                               |
  638.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  639.     |           Checksum            |         Urgent Pointer        |
  640.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  641.     |   your data ... next 500 octets                               |
  642.     |   ......                                                      |
  643.  
  644. If  we abbreviate the TCP header as "T", the whole file now looks like
  645. this:
  646.  
  647.    T....   T....   T....   T....   T....   T....   T....
  648.  
  649. You will note that there are items in  the  header  that  I  have  not
  650. described  above.    They  are  generally  involved  with managing the
  651. connection.  In order to make sure the datagram  has  arrived  at  its
  652. destination,  the  recipient  has  to  send back an "acknowledgement".
  653. This is a datagram whose "Acknowledgement number" field is filled  in.
  654. For  example,  sending  a  packet  with  an  acknowledgement  of  1500
  655. indicates that you have received all the data up to octet number 1500.
  656. If  the  sender  doesn't  get  an  acknowledgement within a reasonable
  657. amount of time, it sends the data  again.    The  window  is  used  to
  658. control  how  much  data can be in transit at any one time.  It is not
  659. practical to wait for each datagram to be acknowledged before  sending
  660. the  next  one.    That would slow things down too much.  On the other
  661. hand, you can't just keep sending, or a fast  computer  might  overrun
  662. the  capacity  of  a slow one to absorb data.  Thus each end indicates
  663. how much new data it is currently prepared to absorb  by  putting  the
  664. number  of  octets  in  its  "Window" field.  As the computer receives
  665. data, the amount of space left in its window decreases.  When it  goes
  666. to  zero, the sender has to stop.  As the receiver processes the data,
  667. it increases its window, indicating that it is ready  to  accept  more
  668. data.  Often the same datagram can be used to acknowledge receipt of a
  669. set of data and to give permission for  additional  new  data  (by  an
  670. updated  window).  The "Urgent" field allows one end to tell the other
  671. to skip ahead in its processing to a particular octet.  This is  often
  672. useful  for  handling asynchronous events, for example when you type a
  673. control character or other command that interrupts output.  The  other
  674. fields are beyond the scope of this document.
  675.  
  676.  
  677.  
  678.                                   9
  679.  
  680.  
  681.  
  682. 2.2 The IP level
  683.  
  684.  
  685. TCP  sends each of these datagrams to IP.  Of course it has to tell IP
  686. the Internet address of the computer at the other end.  Note that this
  687. is  all  IP  is concerned about.  It doesn't care about what is in the
  688. datagram, or even in the TCP header.  IP's job is  simply  to  find  a
  689. route for the datagram and get it to the other end.  In order to allow
  690. gateways or other intermediate systems to  forward  the  datagram,  it
  691. adds  its  own  header.  The main things in this header are the source
  692. and destination Internet address (32-bit addresses, like 128.6.4.194),
  693. the  protocol  number,  and  another  checksum.    The source Internet
  694. address is simply the address of your machine.  (This is necessary  so
  695. the  other  end  knows where the datagram came from.)  The destination
  696. Internet address is the address  of  the  other  machine.    (This  is
  697. necessary  so  any  gateways  in  the  middle  know where you want the
  698. datagram to go.)  The protocol number tells IP at  the  other  end  to
  699. send  the  datagram  to TCP.  Although most IP traffic uses TCP, there
  700. are other protocols that can use IP, so you  have  to  tell  IP  which
  701. protocol  to send the datagram to.  Finally, the checksum allows IP at
  702. the other end to verify that the header  wasn't  damaged  in  transit.
  703. Note  that TCP and IP have separate checksums.  IP needs to be able to
  704. verify that the header didn't get damaged in transit, or it could send
  705. a  message to the wrong place.  For reasons not worth discussing here,
  706. it is both more efficient and safer to have  TCP  compute  a  separate
  707. checksum  for  the  TCP  header  and  data.  Once IP has tacked on its
  708. header, here's what the message looks like:
  709.  
  710.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  711.     |Version|  IHL  |Type of Service|          Total Length         |
  712.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  713.     |         Identification        |Flags|      Fragment Offset    |
  714.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  715.     |  Time to Live |    Protocol   |         Header Checksum       |
  716.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  717.     |                       Source Address                          |
  718.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  719.     |                    Destination Address                        |
  720.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  721.     |  TCP header, then your data ......                            |
  722.     |                                                               |
  723.  
  724. If we represent the IP header by an "I",  your  file  now  looks  like
  725. this:
  726.  
  727.    IT....   IT....   IT....   IT....   IT....   IT....   IT....
  728.  
  729. Again,  the  header contains some additional fields that have not been
  730. discussed.  Most of them are beyond the scope of this document.    The
  731. flags  and fragment offset are used to keep track of the pieces when a
  732. datagram has to be split up.   This  can  happen  when  datagrams  are
  733. forwarded through a network for which they are too big.  (This will be
  734. discussed a bit more below.)  The time to live is  a  number  that  is
  735. decremented  whenever  the  datagram passes through a system.  When it
  736. goes to zero, the datagram is discarded.  This is done in case a  loop
  737.                                   10
  738.  
  739.  
  740.  
  741. develops  in the system somehow.  Of course this should be impossible,
  742. but  well-designed  networks  are  built  to  cope  with  "impossible"
  743. conditions.
  744.  
  745. At this point, it's possible that no more headers are needed.  If your
  746. computer happens to have a direct phone  line  connecting  it  to  the
  747. destination  computer,  or  to  a  gateway,  it  may  simply  send the
  748. datagrams out on the line (though likely a synchronous  protocol  such
  749. as  HDLC  would be used, and it would add at least a few octets at the
  750. beginning and end).
  751.  
  752.  
  753.  
  754. 2.3 The Ethernet level
  755.  
  756.  
  757. However most of our networks these days use Ethernet.  So now we  have
  758. to  describe  Ethernet's headers.  Unfortunately, Ethernet has its own
  759. addresses.  The people who designed Ethernet wanted to make sure  that
  760. no  two  machines  would  end  up  with  the  same  Ethernet  address.
  761. Furthermore, they  didn't  want  the  user  to  have  to  worry  about
  762. assigning  addresses.    So  each  Ethernet  controller  comes with an
  763. address builtin from the factory.  In order to  make  sure  that  they
  764. would  never have to reuse addresses, the Ethernet designers allocated
  765. 48 bits for the Ethernet address.  People who make Ethernet  equipment
  766. have  to  register  with  a  central  authority, to make sure that the
  767. numbers they assign don't overlap any other manufacturer.  Ethernet is
  768. a "broadcast medium".  That is, it is in effect like an old party line
  769. telephone.  When you send a packet out on the Ethernet, every  machine
  770. on  the  network sees the packet.  So something is needed to make sure
  771. that the right machine gets it.  As you might guess, this involves the
  772. Ethernet  header.    Every  Ethernet packet has a 14-octet header that
  773. includes the source and destination Ethernet address, and a type code.
  774. Each machine is supposed to pay attention only to packets with its own
  775. Ethernet address in the destination field.  (It's  perfectly  possible
  776. to  cheat,  which  is  one reason that Ethernet communications are not
  777. terribly secure.)  Note  that  there  is  no  connection  between  the
  778. Ethernet address and the Internet address.  Each machine has to have a
  779. table of what Ethernet address corresponds to what  Internet  address.
  780. (We  will  describe  how  this  table is constructed a bit later.)  In
  781. addition to the addresses, the header contains a type code.  The  type
  782. code is to allow for several different protocol families to be used on
  783. the same network.  So you can use TCP/IP, DECnet, Xerox  NS,  etc.  at
  784. the  same  time.   Each of them will put a different value in the type
  785. field.  Finally,  there  is  a  checksum.    The  Ethernet  controller
  786. computes a checksum of the entire packet.  When the other end receives
  787. the packet, it recomputes the checksum, and throws the packet away  if
  788. the  answer  disagrees  with the original.  The checksum is put on the
  789. end of the packet, not in the header.  The final result is  that  your
  790. message looks like this:
  791.  
  792.  
  793.  
  794.  
  795.  
  796.                                   11
  797.  
  798.  
  799.  
  800.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  801.     |       Ethernet destination address (first 32 bits)            |
  802.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  803.     | Ethernet dest (last 16 bits)  |Ethernet source (first 16 bits)|
  804.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  805.     |       Ethernet source address (last 32 bits)                  |
  806.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  807.     |        Type code              |
  808.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  809.     |  IP header, then TCP header, then your data                   |
  810.     |                                                               |
  811.         ...
  812.     |                                                               |
  813.     |   end of your data                                            |
  814.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  815.     |                       Ethernet Checksum                       |
  816.     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  817.  
  818. If  we  represent  the  Ethernet  header  with  "E",  and the Ethernet
  819. checksum with "C", your file now looks like this:
  820.  
  821.    EIT....C   EIT....C   EIT....C   EIT....C   EIT....C
  822.  
  823. When these packets are received by the other end, of  course  all  the
  824. headers  are  removed.    The  Ethernet interface removes the Ethernet
  825. header and the checksum.  It looks at the type code.  Since  the  type
  826. code  is the one assigned to IP, the Ethernet device driver passes the
  827. datagram up to IP.  IP removes the IP header.   It  looks  at  the  IP
  828. protocol  field.    Since  the  protocol  type  is  TCP, it passes the
  829. datagram up to TCP.  TCP now looks at the sequence number.    It  uses
  830. the  sequence  numbers  and  other  information  to  combine  all  the
  831. datagrams into the original file.
  832.  
  833. The ends our initial summary of TCP/IP.  There are still some  crucial
  834. concepts we haven't gotten to, so we'll now go back and add details in
  835. several areas.  (For detailed descriptions of the items discussed here
  836. see,  RFC  793  for  TCP,  RFC  791  for IP, and RFC's 894 and 826 for
  837. sending IP over Ethernet.)
  838.  
  839.  
  840.  
  841. 3. Well-known sockets and the applications layer
  842.  
  843.  
  844. So far, we have described how a stream  of  data  is  broken  up  into
  845. datagrams,  sent  to another computer, and put back together.  However
  846. something more is needed  in  order  to  accomplish  anything  useful.
  847. There  has  to  be  a  way for you to open a connection to a specified
  848. computer, log into it, tell it what file you  want,  and  control  the
  849. transmission  of  the  file.   (If you have a different application in
  850. mind, e.g. computer mail, some analogous protocol is needed.)  This is
  851. done  by  "application  protocols".  The application protocols run "on
  852. top" of TCP/IP.  That is, when they want to send a message, they  give
  853. the  message  to  TCP.   TCP makes sure it gets delivered to the other
  854. end.  Because TCP and IP take care of all the networking details,  the
  855.                                   12
  856.  
  857.  
  858.  
  859. applications  protocols can treat a network connection as if it were a
  860. simple byte stream, like a terminal or phone line.
  861.  
  862. Before going into more details about applications programs, we have to
  863. describe how you find an application.  Suppose you want to send a file
  864. to a computer whose Internet address  is  128.6.4.7.    To  start  the
  865. process,  you  need  more than just the Internet address.  You have to
  866. connect to the FTP server at the  other  end.    In  general,  network
  867. programs  are  specialized  for a specific set of tasks.  Most systems
  868. have separate programs  to  handle  file  transfers,  remote  terminal
  869. logins, mail, etc.  When you connect to 128.6.4.7, you have to specify
  870. that you want to talk to the FTP server.    This  is  done  by  having
  871. "well-known  sockets"  for  each  server.    Recall that TCP uses port
  872. numbers to keep track of  individual  conversations.    User  programs
  873. normally  use more or less random port numbers.  However specific port
  874. numbers are assigned to the programs that sit  waiting  for  requests.
  875. For  example,  if  you  want  to send a file, you will start a program
  876. called "ftp".  It will open a connection using some random number, say
  877. 1234,  for  the  port number on its end.  However it will specify port
  878. number 21 for the other end.  This is the official port number for the
  879. FTP server.  Note that there are two different programs involved.  You
  880. run ftp on your side.  This is a program designed to  accept  commands
  881. from  your  terminal  and  pass them on to the other end.  The program
  882. that you talk to on the other machine  is  the  FTP  server.    It  is
  883. designed  to  accept commands from the network connection, rather than
  884. an interactive terminal.  There is no need for your program to  use  a
  885. well-known  socket  number  for  itself.  Nobody is trying to find it.
  886. However the servers have to have well-known numbers,  so  that  people
  887. can  open  connections  to  them and start sending them commands.  The
  888. official  port  numbers  for  each  program  are  given  in  "Assigned
  889. Numbers".
  890.  
  891. Note  that  a  connection is actually described by a set of 4 numbers:
  892. the Internet address at each end, and the TCP port number at each end.
  893. Every  datagram  has  all  four of those numbers in it.  (The Internet
  894. addresses are in the IP header, and the TCP port numbers  are  in  the
  895. TCP header.)  In order to keep things straight, no two connections can
  896. have the same set of numbers.  However it is enough for any one number
  897. to  be  different.    For  example,  it  is perfectly possible for two
  898. different users on a machine to be sending files  to  the  same  other
  899. machine.    This  could  result  in  connections  with  the  following
  900. parameters:
  901.  
  902.                    Internet addresses         TCP ports
  903.     connection 1  128.6.4.194, 128.6.4.7      1234, 21
  904.     connection 2  128.6.4.194, 128.6.4.7      1235, 21
  905.  
  906. Since the same machines are involved, the Internet addresses  are  the
  907. same.    Since  they  are  both  doing  file transfers, one end of the
  908. connection involves the well-known port number  for  FTP.    The  only
  909. thing  that  differs is the port number for the program that the users
  910. are running.  That's enough of a difference.  Generally, at least  one
  911. end  of  the  connection asks the network software to assign it a port
  912. number that is guaranteed to be unique.   Normally,  it's  the  user's
  913. end, since the server has to use a well-known number.
  914.                                   13
  915.  
  916.  
  917. From: ski!ptsfa!ames!ucbcad!ucbvax!husc6!rutgers!topaz.rutgers.edu!hedrick
  918. Article 112 of comp.protocols.tcp-ip:
  919. ion: version B 2.10.2 9/18/84; site ski.UUCP
  920. Path: ski!ptsfa!ames!ucbcad!ucbvax!husc6!rutgers!topaz.rutgers.edu!hedrick
  921. >From: hedrick@topaz.rutgers.edu (Charles Hedrick)
  922. Newsgroups: comp.protocols.tcp-ip
  923. Subject: TCP/IP intro, part II of II
  924. Message-ID: <13129@topaz.rutgers.edu>
  925. Date: 3 Jul 87 09:59:22 GMT
  926. Date-Received: 4 Jul 87 09:40:01 GMT
  927. Organization: Rutgers Univ., New Brunswick, N.J.
  928. Lines: 827
  929.  
  930.  
  931.  
  932.  
  933.  
  934. Now  that  we  know  how  to  open  connections, let's get back to the
  935. applications programs.  As mentioned earlier, once TCP  has  opened  a
  936. connection,  we  have  something  that might as well be a simple wire.
  937. All the hard parts are handled by TCP and IP.  However we  still  need
  938. some  agreement  as  to  what we send over this connection.  In effect
  939. this is simply an agreement on what set of  commands  the  application
  940. will  understand,  and  the  format  in  which  they  are  to be sent.
  941. Generally, what is sent is a combination of commands and data.    They
  942. use  context  to  differentiate.  For example, the mail protocol works
  943. like this: Your mail program opens a connection to the mail server  at
  944. the  other end.  Your program gives it your machine's name, the sender
  945. of the message, and the recipients you want it sent to.  It then sends
  946. a  command saying that it is starting the message.  At that point, the
  947. other end  stops  treating  what  it  sees  as  commands,  and  starts
  948. accepting  the  message.  Your end then starts sending the text of the
  949. message.  At the end of the message, a special mark is sent (a dot  in
  950. the first column).  After that, both ends understand that your program
  951. is again sending commands.  This is the simplest way to do things, and
  952. the one that most applications use.
  953.  
  954. File  transfer  is  somewhat more complex.  The file transfer protocol
  955. involves two different connections.  It starts  out  just  like  mail.
  956. The user's program sends commands like "log me in as this user", "here
  957. is my password", "send me the file with this name".  However once  the
  958. command  to  send  data is sent, a second connection is opened for the
  959. data itself.  It would certainly be possible to send the data  on  the
  960. same  connection,  as  mail does.  However file transfers often take a
  961. long time.  The designers of the  file  transfer  protocol  wanted  to
  962. allow  the  user  to  continue  issuing commands while the transfer is
  963. going on.  For example, the user might make an inquiry,  or  he  might
  964. abort  the  transfer.    Thus  the designers felt it was best to use a
  965. separate connection for  the  data  and  leave  the  original  command
  966. connection  for  commands.    (It  is  also  possible  to open command
  967. connections to two different computers, and tell them to send  a  file
  968. from  one  to  the other.  In that case, the data couldn't go over the
  969. command connection.)
  970.  
  971. Remote terminal connections use another mechanism still.   For  remote
  972. logins,  there  is just one connection.  It normally sends data.  When
  973. it is necessary to send a command (e.g. to set the terminal type or to
  974. change  some  mode),  a special character is used to indicate that the
  975. next character is a command.  If the user happens to type that special
  976. character as data, two of them are sent.
  977.  
  978. We  are  not  going to describe the application protocols in detail in
  979. this document.  It's better to read the RFC's yourself.  However there
  980. are  a  couple of common conventions used by applications that will be
  981. described here.  First, the common network representation:  TCP/IP  is
  982. intended  to  be  usable  on  any  computer.    Unfortunately, not all
  983. computers agree on how data is represented.  There are differences  in
  984. character  codes  (ASCII  vs.  EBCDIC),  in  end  of  line conventions
  985. (carriage return, line feed, or a representation using counts), and in
  986. whether  terminals expect characters to be sent individually or a line
  987. at a time.   In  order  to  allow  computers  of  different  kinds  to
  988. communicate,   each   applications   protocol   defines   a   standard
  989.                                   14
  990.  
  991.  
  992.  
  993. representation.    Note  that  TCP  and  IP  do  not  care  about  the
  994. representation.    TCP  simply  sends octets.  However the programs at
  995. both ends have to agree on how the octets are to be interpreted.   The
  996. RFC  for  each  application  specifies the standard representation for
  997. that application.  Normally it  is  "net  ASCII".    This  uses  ASCII
  998. characters,  with end of line denoted by a carriage return followed by
  999. a line feed.  For remote login,  there  is  also  a  definition  of  a
  1000. "standard terminal", which turns out to be a half-duplex terminal with
  1001. echoing happening on the local machine.  Most applications  also  make
  1002. provisions  for  the  two  computers to agree on other representations
  1003. that they may find more convenient.  For example, PDP-10's have 36-bit
  1004. words.    There  is a way that two PDP-10's can agree to send a 36-bit
  1005. binary file.  Similarly, two systems that prefer full-duplex  terminal
  1006. conversations  can  agree  on  that.    However each application has a
  1007. standard representation, which every machine must support.
  1008.  
  1009.  
  1010.  
  1011. 3.1 An example application: SMTP
  1012.  
  1013.  
  1014. In order to give a bit better idea what is involved in the application
  1015. protocols,  I'm  going  to  show an example of SMTP, which is the mail
  1016. protocol.  (SMTP is "simple mail transfer protocol.)  We assume that a
  1017. computer called TOPAZ.RUTGERS.EDU wants to send the following message.
  1018.  
  1019.   Date: Sat, 27 Jun 87 13:26:31 EDT
  1020.   From: hedrick@topaz.rutgers.edu
  1021.   To: levy@red.rutgers.edu
  1022.   Subject: meeting
  1023.  
  1024.   Let's get together Monday at 1pm.
  1025.  
  1026. First,  note  that the format of the message itself is described by an
  1027. Internet standard (RFC 822).  The standard specifies the fact that the
  1028. message  must be transmitted as net ASCII (i.e. it must be ASCII, with
  1029. carriage return/linefeed to delimit lines).   It  also  describes  the
  1030. general  structure, as a group of header lines, then a blank line, and
  1031. then the body of the message.  Finally, it describes the syntax of the
  1032. header  lines in detail.  Generally they consist of a keyword and then
  1033. a value.
  1034.  
  1035. Note  that  the  addressee  is  indicated   as   LEVY@RED.RUTGERS.EDU.
  1036. Initially,  addresses were simply "person at machine".  However recent
  1037. standards have made things more flexible.  There  are  now  provisions
  1038. for  systems  to handle other systems' mail.  This can allow automatic
  1039. forwarding on behalf of computers not connected to the Internet.    It
  1040. can be used to direct mail for a number of systems to one central mail
  1041. server.  Indeed there is no requirement that an actual computer by the
  1042. name  of RED.RUTGERS.EDU even exist.  The name servers could be set up
  1043. so that you mail to department names, and each  department's  mail  is
  1044. routed  automatically to an appropriate computer.  It is also possible
  1045. that the part before the @ is something other than a user name.  It is
  1046. possible  for  programs  to be set up to process mail.  There are also
  1047. provisions  to  handle  mailing  lists,  and  generic  names  such  as
  1048.                                   15
  1049.  
  1050.  
  1051.  
  1052. "postmaster" or "operator".
  1053.  
  1054. The  way  the  message is to be sent to another system is described by
  1055. RFC's 821 and 974.  The program that is going to be doing the  sending
  1056. asks  the  name server several queries to determine where to route the
  1057. message.  The first query is to find out which  machines  handle  mail
  1058. for  the  name RED.RUTGERS.EDU.  In this case, the server replies that
  1059. RED.RUTGERS.EDU handles its own mail.  The program then asks  for  the
  1060. address of RED.RUTGERS.EDU, which is 128.6.4.2.  Then the mail program
  1061. opens a TCP connection to port 25  on  128.6.4.2.    Port  25  is  the
  1062. well-known  socket  used  for receiving mail.  Once this connection is
  1063. established, the mail program starts sending  commands.    Here  is  a
  1064. typical  conversation.  Each line is labelled as to whether it is from
  1065. TOPAZ or RED.  Note that TOPAZ initiated the connection:
  1066.  
  1067.     RED    220 RED.RUTGERS.EDU SMTP Service at 29 Jun 87 05:17:18 EDT
  1068.     TOPAZ  HELO topaz.rutgers.edu
  1069.     RED    250 RED.RUTGERS.EDU - Hello, TOPAZ.RUTGERS.EDU
  1070.     TOPAZ  MAIL From:<hedrick@topaz.rutgers.edu>
  1071.     RED    250 MAIL accepted
  1072.     TOPAZ  RCPT To:<levy@red.rutgers.edu>
  1073.     RED    250 Recipient accepted
  1074.     TOPAZ  DATA
  1075.     RED    354 Start mail input; end with <CRLF>.<CRLF>
  1076.     TOPAZ  Date: Sat, 27 Jun 87 13:26:31 EDT
  1077.     TOPAZ  From: hedrick@topaz.rutgers.edu
  1078.     TOPAZ  To: levy@red.rutgers.edu
  1079.     TOPAZ  Subject: meeting
  1080.     TOPAZ
  1081.     TOPAZ  Let's get together Monday at 1pm.
  1082.     TOPAZ  .
  1083.     RED    250 OK
  1084.     TOPAZ  QUIT
  1085.     RED    221 RED.RUTGERS.EDU Service closing transmission channel
  1086.  
  1087. First, note that commands all use normal text.  This is typical of the
  1088. Internet  standards.    Many  of  the  protocols  use  standard  ASCII
  1089. commands.  This makes it easy  to  watch  what  is  going  on  and  to
  1090. diagnose  problems.  For example, the mail program keeps a log of each
  1091. conversation.  If something goes wrong, the log  file  can  simply  be
  1092. mailed  to  the  postmaster.  Since it is normal text, he can see what
  1093. was going on.  It also allows a human to interact  directly  with  the
  1094. mail  server,  for  testing.  (Some newer protocols are complex enough
  1095. that this is not practical.  The commands would have to have a  syntax
  1096. that would require a significant parser.  Thus there is a tendency for
  1097. newer protocols to use binary formats.  Generally they are  structured
  1098. like  C or Pascal record structures.)  Second, note that the responses
  1099. all begin with numbers.  This is also typical of  Internet  protocols.
  1100. The  allowable  responses  are  defined  in the protocol.  The numbers
  1101. allow the user program to respond unambiguously.    The  rest  of  the
  1102. response  is  text,  which is normally for use by any human who may be
  1103. watching or looking at a log.  It has no effect on  the  operation  of
  1104. the  programs.  (However there is one point at which the protocol uses
  1105. part of the text of the response.)   The  commands  themselves  simply
  1106. allow  the  mail  program  on  one  end  to  tell  the mail server the
  1107.                                   16
  1108.  
  1109.  
  1110.  
  1111. information it needs to know in order to deliver the message.  In this
  1112. case,  the  mail  server  could  get the information by looking at the
  1113. message itself.  But for more complex cases, that would not  be  safe.
  1114. Every  session  must  begin  with  a HELO, which gives the name of the
  1115. system that initiated the connection.  Then the sender and  recipients
  1116. are specified.  (There can be more than one RCPT command, if there are
  1117. several recipients.)  Finally the data itself is sent.  Note that  the
  1118. text  of the message is terminated by a line containing just a period.
  1119. (If such a line appears in the message, the period is doubled.)  After
  1120. the  message  is  accepted,  the  sender  can send another message, or
  1121. terminate the session as in the example above.
  1122.  
  1123. Generally, there is a pattern to the response numbers.   The  protocol
  1124. defines  the  specific set of responses that can be sent as answers to
  1125. any given command.  However programs that don't want to  analyze  them
  1126. in  detail  can  just  look at the first digit.  In general, responses
  1127. that begin with a 2  indicate  success.    Those  that  begin  with  3
  1128. indicate  that some further action is needed, as shown above.  4 and 5
  1129. indicate errors.  4 is a "temporary" error, such as  a  disk  filling.
  1130. The  message should be saved, and tried again later.  5 is a permanent
  1131. error, such as a  non-existent  recipient.    The  message  should  be
  1132. returned to the sender with an error message.
  1133.  
  1134. (For  more  details about the protocols mentioned in this section, see
  1135. RFC's 821/822 for mail, RFC 959 for file transfer, and  RFC's  854/855
  1136. for  remote  logins.  For the well-known port numbers, see the current
  1137. edition of Assigned Numbers, and possibly RFC 814.)
  1138.  
  1139.  
  1140.  
  1141. 4. Protocols other than TCP: UDP and ICMP
  1142.  
  1143.  
  1144. So far, we have described only connections that use TCP.  Recall  that
  1145. TCP  is  responsible  for  breaking  up  messages  into datagrams, and
  1146. reassembling them properly.  However in  many  applications,  we  have
  1147. messages  that  will  always  fit in a single datagram.  An example is
  1148. name lookup.  When a user attempts to make  a  connection  to  another
  1149. system,  he  will  generally  specify  the system by name, rather than
  1150. Internet address.  His system has to translate that name to an address
  1151. before  it  can  do  anything.  Generally, only a few systems have the
  1152. database used to translate names to addresses.  So the  user's  system
  1153. will want to send a query to one of the systems that has the database.
  1154. This query is going to be very short.  It will certainly  fit  in  one
  1155. datagram.    So  will the answer.  Thus it seems silly to use TCP.  Of
  1156. course TCP does more than just break things up  into  datagrams.    It
  1157. also  makes  sure  that  the  data  arrives, resending datagrams where
  1158. necessary.  But for a question that fits  in  a  single  datagram,  we
  1159. don't  need  all the complexity of TCP to do this.  If we don't get an
  1160. answer after a few seconds, we can just ask again.   For  applications
  1161. like this, there are alternatives to TCP.
  1162.  
  1163. The most common alternative is UDP ("user datagram protocol").  UDP is
  1164. designed for applications where you don't need  to  put  sequences  of
  1165. datagrams  together.  It fits into the system much like TCP.  There is
  1166.                                   17
  1167.  
  1168.  
  1169.  
  1170. a UDP header.  The network software puts the UDP header on  the  front
  1171. of  your  data, just as it would put a TCP header on the front of your
  1172. data.  Then UDP sends the data  to  IP,  which  adds  the  IP  header,
  1173. putting  UDP's  protocol number in the protocol field instead of TCP's
  1174. protocol number.  However UDP doesn't do as much  as  TCP  does.    It
  1175. doesn't  split data into multiple datagrams.  It doesn't keep track of
  1176. what it has sent so it can resend if necessary.  About  all  that  UDP
  1177. provides  is  port  numbers,  so  that several programs can use UDP at
  1178. once.  UDP port numbers are used just like TCP port  numbers.    There
  1179. are  well-known  port numbers for servers that use UDP.  Note that the
  1180. UDP header is shorter than a TCP header.   It  still  has  source  and
  1181. destination  port  numbers,  and  a checksum, but that's about it.  No
  1182. sequence number, since it is not needed.  UDP is used by the protocols
  1183. that  handle  name  lookups (see IEN 116, RFC 882, and RFC 883), and a
  1184. number of similar protocols.
  1185.  
  1186. Another  alternative  protocol  is  ICMP  ("Internet  control  message
  1187. protocol").    ICMP  is  used  for  error messages, and other messages
  1188. intended for the TCP/IP software itself, rather  than  any  particular
  1189. user  program.  For example, if you attempt to connect to a host, your
  1190. system may get back an ICMP message saying "host unreachable".    ICMP
  1191. can  also be used to find out some information about the network.  See
  1192. RFC 792 for details of ICMP.  ICMP is  similar  to  UDP,  in  that  it
  1193. handles messages that fit in one datagram.  However it is even simpler
  1194. than UDP.  It doesn't even have port numbers in its header.  Since all
  1195. ICMP  messages are interpreted by the network software itself, no port
  1196. numbers are needed to say where a ICMP message is supposed to go.
  1197.  
  1198.  
  1199.  
  1200. 5. Keeping track of names and information: the domain system
  1201.  
  1202.  
  1203. As we indicated earlier, the network software generally needs a 32-bit
  1204. Internet  address  in  order  to open a connection or send a datagram.
  1205. However users prefer to deal with computer names rather than  numbers.
  1206. Thus  there  is  a database that allows the software to look up a name
  1207. and find the corresponding number.  When the Internet was small,  this
  1208. was  easy.  Each system would have a file that listed all of the other
  1209. systems, giving both their name and number.  There are  now  too  many
  1210. computers  for  this  approach to be practical.  Thus these files have
  1211. been replaced by a set of name servers that keep track of  host  names
  1212. and  the corresponding Internet addresses.  (In fact these servers are
  1213. somewhat more general than that.  This is just one kind of information
  1214. stored in the domain system.)  Note that a set of interlocking servers
  1215. are used, rather than a single central one.  There  are  now  so  many
  1216. different  institutions  connected  to  the  Internet that it would be
  1217. impractical for them to  notify  a  central  authority  whenever  they
  1218. installed  or moved a computer.  Thus naming authority is delegated to
  1219. individual institutions.  The name servers form a tree,  corresponding
  1220. to  institutional  structure.    The names themselves follow a similar
  1221. structure.  A typical example is the name BORAX.LCS.MIT.EDU.  This  is
  1222. a  computer  at  the Laboratory for Computer Science (LCS) at MIT.  In
  1223. order to find its Internet address,  you  might  potentially  have  to
  1224. consult  4  different  servers.  First, you would ask a central server
  1225.                                   18
  1226.  
  1227.  
  1228.  
  1229. (called the root) where the EDU server is.  EDU is a server that keeps
  1230. track of educational institutions.  The root server would give you the
  1231. names and Internet addresses of several servers for EDU.   (There  are
  1232. several  servers  at  each  level,  to allow for the possibly that one
  1233. might be down.)  You would then ask EDU where the server for  MIT  is.
  1234. Again,  it  would  give  you  names  and Internet addresses of several
  1235. servers for MIT.  Generally, not all of those servers would be at MIT,
  1236. to  allow for the possibility of a general power failure at MIT.  Then
  1237. you would ask MIT where the server for LCS is, and finally  you  would
  1238. ask one of the LCS servers about BORAX.  The final result would be the
  1239. Internet address for BORAX.LCS.MIT.EDU.    Each  of  these  levels  is
  1240. referred  to  as  a  "domain".  The entire name, BORAX.LCS.MIT.EDU, is
  1241. called a "domain name".    (So  are  the  names  of  the  higher-level
  1242. domains, such as LCS.MIT.EDU, MIT.EDU, and EDU.)
  1243.  
  1244. Fortunately,  you  don't really have to go through all of this most of
  1245. the time.  First of all, the root name servers also happen to  be  the
  1246. name  servers  for  the  top-level domains such as EDU.  Thus a single
  1247. query to a root  server  will  get  you  to  MIT.    Second,  software
  1248. generally  remembers answers that it got before.  So once we look up a
  1249. name at LCS.MIT.EDU, our software remembers where to find servers  for
  1250. LCS.MIT.EDU,  MIT.EDU,  and EDU.  It also remembers the translation of
  1251. BORAX.LCS.MIT.EDU.  Each of these pieces of information has a "time to
  1252. live"  associated with it.  Typically this is a few days.  After that,
  1253. the information expires and has to be looked up again.    This  allows
  1254. institutions to change things.
  1255.  
  1256. The  domain  system  is not limited to finding out Internet addresses.
  1257. Each domain name is a node in a database.  The node can  have  records
  1258. that  define  a number of different properties.  Examples are Internet
  1259. address, computer type, and a list of services provided by a computer.
  1260. A  program  can  ask  for  a  specific  piece  of  information, or all
  1261. information about a given name.  It is possible  for  a  node  in  the
  1262. database  to  be  marked as an "alias" (or nickname) for another node.
  1263. It is also possible to use the  domain  system  to  store  information
  1264. about users, mailing lists, or other objects.
  1265.  
  1266. There  is  an  Internet  standard  defining  the  operation  of  these
  1267. databases, as well as the protocols used  to  make  queries  of  them.
  1268. Every  network utility has to be able to make such queries, since this
  1269. is now the official way to evaluate host names.   Generally  utilities
  1270. will talk to a server on their own system.  This server will take care
  1271. of contacting the other servers for them.  This keeps down the  amount
  1272. of code that has to be in each application program.
  1273.  
  1274. The  domain  system  is  particularly  important for handling computer
  1275. mail.  There are entry types to define what computer handles mail  for
  1276. a  given  name, to specify where an individual is to receive mail, and
  1277. to define mailing lists.
  1278.  
  1279. (See RFC's 882, 883, and 973 for specifications of the domain  system.
  1280. RFC 974 defines the use of the domain system in sending mail.)
  1281.  
  1282.  
  1283.  
  1284.                                   19
  1285.  
  1286.  
  1287.  
  1288. 6. Routing
  1289.  
  1290.  
  1291. The   description  above  indicated  that  the  IP  implementation  is
  1292. responsible for getting datagrams to the destination indicated by  the
  1293. destination address, but little was said about how this would be done.
  1294. The task of finding how to  get  a  datagram  to  its  destination  is
  1295. referred to as "routing".  In fact many of the details depend upon the
  1296. particular implementation.  However some general things can be said.
  1297.  
  1298. First, it is necessary to understand the model on which IP  is  based.
  1299. IP assumes that a system is attached to some local network.  We assume
  1300. that the system can send datagrams to any  other  system  on  its  own
  1301. network.    (In  the  case  of  Ethernet, it simply finds the Ethernet
  1302. address of the destination system, and puts the datagram  out  on  the
  1303. Ethernet.)    The  problem  comes  when  a  system  is asked to send a
  1304. datagram to a system on a different network.  This problem is  handled
  1305. by  gateways.   A gateway is a system that connects a network with one
  1306. or more other networks.  Gateways  are  often  normal  computers  that
  1307. happen  to have more than one network interface.  For example, we have
  1308. a Unix machine that has two different Ethernet interfaces.  Thus it is
  1309. connected  to networks 128.6.4 and 128.6.3.  This machine can act as a
  1310. gateway between those two networks.  The software on that machine must
  1311. be  set  up  so that it will forward datagrams from one network to the
  1312. other.  That is, if a machine on network 128.6.4 sends a  datagram  to
  1313. the  gateway,  and  the  datagram is addressed to a machine on network
  1314. 128.6.3, the gateway will forward the  datagram  to  the  destination.
  1315. Major communications centers often have gateways that connect a number
  1316. of different  networks.    (In  many  cases,  special-purpose  gateway
  1317. systems provide better performance or reliability than general-purpose
  1318. systems acting as gateways.  A number of vendors sell such systems.)
  1319.  
  1320. Routing in IP is  based  entirely  upon  the  network  number  of  the
  1321. destination  address.    Each computer has a table of network numbers.
  1322. For each network number, a gateway is listed.  This is the gateway  to
  1323. be used to get to that network.  Note that the gateway doesn't have to
  1324. connect directly to the network.  It just has to be the best place  to
  1325. go  to  get there.  For example at Rutgers, our interface to NSFnet is
  1326. at the John von Neuman Supercomputer Center (JvNC). Our connection  to
  1327. JvNC  is  via  a  high-speed  serial line connected to a gateway whose
  1328. address is 128.6.3.12.  Systems on net 128.6.3 will list 128.6.3.12 as
  1329. the  gateway  for  many  off-campus  networks.  However systems on net
  1330. 128.6.4 will list 128.6.4.1 as the gateway to  those  same  off-campus
  1331. networks.    128.6.4.1  is  the  gateway  between networks 128.6.4 and
  1332. 128.6.3, so it is the first step in getting to JvNC.
  1333.  
  1334. When a computer wants to send a datagram, it first checks  to  see  if
  1335. the  destination address is on the system's own local network.  If so,
  1336. the datagram can be sent directly.  Otherwise, the system  expects  to
  1337. find an entry for the network that the destination address is on.  The
  1338. datagram is sent to the gateway listed in that entry.  This table  can
  1339. get quite big.  For example, the Internet now includes several hundred
  1340. individual networks.  Thus various strategies have been  developed  to
  1341. reduce  the size of the routing table.  One strategy is to depend upon
  1342. "default routes".  Often, there is only one gateway out of a  network.
  1343.                                   20
  1344.  
  1345.  
  1346.  
  1347. This  gateway might connect a local Ethernet to a campus-wide backbone
  1348. network.  In that case, we don't need to have  a  separate  entry  for
  1349. every  network  in  the  world.    We  simply define that gateway as a
  1350. "default".  When no specific  route  is  found  for  a  datagram,  the
  1351. datagram  is  sent to the default gateway.  A default gateway can even
  1352. be used when there are several gateways  on  a  network.    There  are
  1353. provisions  for  gateways  to  send a message saying "I'm not the best
  1354. gateway -- use this one instead."  (The message is sent via ICMP.  See
  1355. RFC  792.)  Most network software is designed to use these messages to
  1356. add entries to their routing tables.  Suppose network 128.6.4 has  two
  1357. gateways, 128.6.4.59 and 128.6.4.1.  128.6.4.59 leads to several other
  1358. internal Rutgers networks.  128.6.4.1 leads indirectly to the  NSFnet.
  1359. Suppose  we  set  128.6.4.59  as  a default gateway, and have no other
  1360. routing table entries.  Now what  happens  when  we  need  to  send  a
  1361. datagram  to  MIT?    MIT  is  network 18.  Since we have no entry for
  1362. network 18, the datagram will be sent to the default, 128.6.4.59.   As
  1363. it  happens,  this  gateway  is the wrong one.  So it will forward the
  1364. datagram to 128.6.4.1.  But it will also send back an error saying  in
  1365. effect: "to get to network 18, use 128.6.4.1".  Our software will then
  1366. add an entry to the routing table.  Any future datagrams to  MIT  will
  1367. then  go  directly to 128.6.4.1.  (The error message is sent using the
  1368. ICMP protocol.  The message type is called "ICMP redirect.")
  1369.  
  1370. Most IP experts recommend that individual computers should not try  to
  1371. keep  track  of  the  entire network.  Instead, they should start with
  1372. default gateways, and let the gateways tell them the routes,  as  just
  1373. described.   However this doesn't say how the gateways should find out
  1374. about the routes.  The gateways can't depend upon this strategy.  They
  1375. have  to  have fairly complete routing tables.  For this, some sort of
  1376. routing protocol is needed.  A routing protocol is simply a  technique
  1377. for  the  gateways  to  find each other, and keep up to date about the
  1378. best way to get to every network.   RFC  1009  contains  a  review  of
  1379. gateway  design  and  routing.    However rip.doc is probably a better
  1380. introduction to the subject.  It contains some tutorial material,  and
  1381. a detailed description of the most commonly-used routing protocol.
  1382.  
  1383.  
  1384.  
  1385. 7. Details about Internet addresses: subnets and broadcasting
  1386.  
  1387.  
  1388. As  indicated earlier, Internet addresses are 32-bit numbers, normally
  1389. written as 4 octets (in decimal), e.g. 128.6.4.7.  There are  actually
  1390. 3  different types of address.  The problem is that the address has to
  1391. indicate both the network and the host within the  network.    It  was
  1392. felt  that  eventually  there would be lots of networks.  Many of them
  1393. would be small, but probably 24 bits would be needed to represent  all
  1394. the  IP  networks.  It was also felt that some very big networks might
  1395. need 24 bits to represent all of their hosts.  This would seem to lead
  1396. to  48  bit  addresses.  But the designers really wanted to use 32 bit
  1397. addresses.  So they adopted a kludge.  The assumption is that most  of
  1398. the  networks will be small.  So they set up three different ranges of
  1399. address.  Addresses beginning with 1 to 126 use only the  first  octet
  1400. for  the network number.  The other three octets are available for the
  1401. host number.  Thus 24 bits are available for hosts.  These numbers are
  1402.                                   21
  1403.  
  1404.  
  1405.  
  1406. used  for large networks.  But there can only be 126 of these very big
  1407. networks.  The Arpanet is one, and there are a  few  large  commercial
  1408. networks.    But  few  normal organizations get one of these "class A"
  1409. addresses.  For normal large organizations, "class  B"  addresses  are
  1410. used.    Class  B  addresses  use the first two octets for the network
  1411. number.  Thus network numbers are 128.1 through 191.254.  (We avoid  0
  1412. and  255,  for  reasons  that  we  see below.  We also avoid addresses
  1413. beginning with 127, because that is used by some systems  for  special
  1414. purposes.)    The  last  two  octets  are available for host addesses,
  1415. giving 16 bits of host address.   This  allows  for  64516  computers,
  1416. which should be enough for most organizations.  (It is possible to get
  1417. more than one class B address, if you run  out.)    Finally,  class  C
  1418. addresses  use  three  octets,  in  the  range 192.1.1 to 223.254.254.
  1419. These allow only 254 hosts on each network, but there can be  lots  of
  1420. these  networks.   Addresses above 223 are reserved for future use, as
  1421. class D and E (which are currently not defined).
  1422.  
  1423. Many large organizations find it convenient to  divide  their  network
  1424. number into "subnets".  For example, Rutgers has been assigned a class
  1425. B address, 128.6.  We find it convenient to use the third octet of the
  1426. address to indicate which Ethernet a host is on.  This division has no
  1427. significance outside of Rutgers.  A computer  at  another  institution
  1428. would treat all datagrams addressed to 128.6 the same way.  They would
  1429. not look at the third octet of the address.   Thus  computers  outside
  1430. Rutgers  would  not have different routes for 128.6.4 or 128.6.5.  But
  1431. inside Rutgers, we treat 128.6.4 and 128.6.5 as separate networks.  In
  1432. effect, gateways inside Rutgers have separate entries for each Rutgers
  1433. subnet, whereas gateways outside  Rutgers  just  have  one  entry  for
  1434. 128.6.  Note  that  we  could  do  exactly  the  same thing by using a
  1435. separate class C address for each Ethernet.   As  far  as  Rutgers  is
  1436. concerned,  it  would be just as convenient for us to have a number of
  1437. class C addresses.  However using class C addresses would make  things
  1438. inconvenient for the rest of the world.  Every institution that wanted
  1439. to talk to us would have to have a separate entry for each one of  our
  1440. networks.   If every institution did this, there would be far too many
  1441. networks for any reasonable gateway to keep track of.  By  subdividing
  1442. a  class B network, we hide our internal structure from everyone else,
  1443. and  save  them  trouble.    This  subnet  strategy  requires  special
  1444. provisions in the network software.  It is described in RFC 950.
  1445.  
  1446. 0  and  255  have  special  meanings.  0 is reserved for machines that
  1447. don't know their address.  In certain circumstances it is possible for
  1448. a  machine not to know the number of the network it is on, or even its
  1449. own host address.  For example, 0.0.0.23 would be a machine that  knew
  1450. it was host number 23, but didn't know on what network.
  1451.  
  1452. 255  is  used for "broadcast".  A broadcast is a message that you want
  1453. every system on the network to see.    Broadcasts  are  used  in  some
  1454. situations  where you don't know who to talk to.  For example, suppose
  1455. you need to look  up  a  host  name  and  get  its  Internet  address.
  1456. Sometimes  you  don't know the address of the nearest name server.  In
  1457. that case, you might send the request as a broadcast.  There are  also
  1458. cases  where a number of systems are interested in information.  It is
  1459. then less expensive to send a single broadcast than to send  datagrams
  1460. individually  to  each host that is interested in the information.  In
  1461.                                   22
  1462.  
  1463.  
  1464.  
  1465. order to send a broadcast, you use an address that is  made  by  using
  1466. your  network  address, with all ones in the part of the address where
  1467. the host number goes.  For example, if you are on network 128.6.4, you
  1468. would   use   128.6.4.255  for  broadcasts.    How  this  is  actually
  1469. implemented depends upon the medium.   It  is  not  possible  to  send
  1470. broadcasts  on the Arpanet, or on point to point lines.  However it is
  1471. possible on an Ethernet.  If you use an Ethernet address with all  its
  1472. bits  on (all ones), every machine on the Ethernet is supposed to look
  1473. at that datagram.
  1474.  
  1475. Although the official broadcast address for  network  128.6.4  is  now
  1476. 128.6.4.255,  there  are  some  other addresses that may be treated as
  1477. broadcasts by certain implementations.  For convenience, the  standard
  1478. also  allows  255.255.255.255 to be used.  This refers to all hosts on
  1479. the local network.  It is often simpler to use 255.255.255.255 instead
  1480. of  finding out the network number for the local network and forming a
  1481. broadcast address such as 128.6.4.255.   In  addition,  certain  older
  1482. implementations  may  use  0  instead  of  255  to  form the broadcast
  1483. address.    Such  implementations  would  use  128.6.4.0  instead   of
  1484. 128.6.4.255  as  the  broadcast  address on network 128.6.4.  Finally,
  1485. certain older implementations may not understand about subnets.   Thus
  1486. they consider the network number to be 128.6.  In that case, they will
  1487. assume a broadcast address  of  128.6.255.255  or  128.6.0.0.    Until
  1488. support  for  broadcasts is implemented properly, it can be a somewhat
  1489. dangerous feature to use.
  1490.  
  1491. Because 0 and 255 are used for unknown and broadcast addresses, normal
  1492. hosts  should never be given addresses containing 0 or 255.  Addresses
  1493. should never begin with 0, 127, or any number above  223.    Addresses
  1494. violating these rules are sometimes referred to as "Martians", because
  1495. of rumors that the Central University of Mars is using network 225.
  1496.  
  1497.  
  1498.  
  1499. 8. Datagram fragmentation and reassembly
  1500.  
  1501.  
  1502. TCP/IP is designed for use  with  many  different  kinds  of  network.
  1503. Unfortunately,  network  designers  do not agree about how big packets
  1504. can be.  Ethernet packets can be 1500 octets long.    Arpanet  packets
  1505. have  a  maximum  of around 1000 octets.  Some very fast networks have
  1506. much larger packet sizes.  At first, you might think  that  IP  should
  1507. simply  settle  on  the  smallest  possible size.  Unfortunately, this
  1508. would cause serious performance problems.    When  transferring  large
  1509. files, big packets are far more efficient than small ones.  So we want
  1510. to be able to use the largest packet size possible.  But we also  want
  1511. to  be  able  to  handle  networks  with  small limits.  There are two
  1512. provisions for this.  First, TCP has the ability to "negotiate"  about
  1513. datagram  size.  When a TCP connection first opens, both ends can send
  1514. the maximum datagram size they can  handle.    The  smaller  of  these
  1515. numbers  is  used  for  the  rest  of the connection.  This allows two
  1516. implementations that can handle big datagrams to use  them,  but  also
  1517. lets  them  talk  to  implementations that can't handle them.  However
  1518. this doesn't completely solve the problem.  The most  serious  problem
  1519. is  that the two ends don't necessarily know about all of the steps in
  1520.                                   23
  1521.  
  1522.  
  1523.  
  1524. between.  For example, when sending data between Rutgers and Berkeley,
  1525. it is likely that both computers will be on Ethernets.  Thus they will
  1526. both  be  prepared  to  handle  1500-octet  datagrams.    However  the
  1527. connection will at some point end up going over the Arpanet.  It can't
  1528. handle packets of that size.  For this reason, there are provisions to
  1529. split   datagrams   up   into   pieces.    (This  is  referred  to  as
  1530. "fragmentation".)  The IP header  contains  fields  indicating  the  a
  1531. datagram  has  been split, and enough information to let the pieces be
  1532. put back together.  If a gateway connects an Ethernet to the  Arpanet,
  1533. it must be prepared to take 1500-octet Ethernet packets and split them
  1534. into pieces that will fit on the Arpanet.    Furthermore,  every  host
  1535. implementation  of  TCP/IP  must  be prepared to accept pieces and put
  1536. them back together.  This is referred to as "reassembly".
  1537.  
  1538. TCP/IP implementations differ in the approach they take to deciding on
  1539. datagram  size.    It  is  fairly  common  for  implementations to use
  1540. 576-byte datagrams whenever they can't verify that the entire path  is
  1541. able  to  handle larger packets.  This rather conservative strategy is
  1542. used because of the number of implementations with bugs in the code to
  1543. reassemble  fragments.    Implementors  often try to avoid ever having
  1544. fragmentation occur.  Different implementors take different approaches
  1545. to  deciding  when  it  is safe to use large datagrams.  Some use them
  1546. only for the local network.  Others will use them for any  network  on
  1547. the   same   campus.    576  bytes  is  a  "safe"  size,  which  every
  1548. implementation must support.
  1549.  
  1550.  
  1551.  
  1552. 9. Ethernet encapsulation: ARP
  1553.  
  1554.  
  1555. There was a brief discussion earlier about what IP datagrams look like
  1556. on  an  Ethernet.    The  discussion  showed  the  Ethernet header and
  1557. checksum.  However it left one hole: It didn't say how to  figure  out
  1558. what Ethernet address to use when you want to talk to a given Internet
  1559. address.  In fact, there is a separate protocol for this,  called  ARP
  1560. ("address  resolution protocol").  (Note by the way that ARP is not an
  1561. IP protocol.  That is, the ARP datagrams  do  not  have  IP  headers.)
  1562. Suppose  you  are  on  system  128.6.4.194  and you want to connect to
  1563. system 128.6.4.7.  Your system will first verify that 128.6.4.7 is  on
  1564. the  same network, so it can talk directly via Ethernet.  Then it will
  1565. look up 128.6.4.7 in its ARP table, to see if  it  already  knows  the
  1566. Ethernet  address.    If  so, it will stick on an Ethernet header, and
  1567. send the packet.  But suppose this system is not  in  the  ARP  table.
  1568. There  is  no  way  to  send the packet, because you need the Ethernet
  1569. address.  So it  uses  the  ARP  protocol  to  send  an  ARP  request.
  1570. Essentially  an  ARP  request  says  "I  need the Ethernet address for
  1571. 128.6.4.7".  Every system listens to ARP requests.  When a system sees
  1572. an  ARP  request  for itself, it is required to respond.  So 128.6.4.7
  1573. will see the request, and will respond with an  ARP  reply  saying  in
  1574. effect "128.6.4.7 is 8:0:20:1:56:34".  (Recall that Ethernet addresses
  1575. are 48 bits.  This is 6 octets.  Ethernet addresses are conventionally
  1576. shown  in  hex,  using  the punctuation shown.)  Your system will save
  1577. this information in its ARP table, so future packets will go directly.
  1578. Most  systems  treat the ARP table as a cache, and clear entries in it
  1579.                                   24
  1580.  
  1581.  
  1582.  
  1583. if they have not been used in a certain period of time.
  1584.  
  1585. Note by the way that ARP requests must be sent as "broadcasts".  There
  1586. is  no  way  that  an  ARP  request  can be sent directly to the right
  1587. system.  After all, the whole reason for sending  an  ARP  request  is
  1588. that  you  don't know the Ethernet address.  So an Ethernet address of
  1589. all ones is  used,  i.e.  ff:ff:ff:ff:ff:ff.    By  convention,  every
  1590. machine  on  the Ethernet is required to pay attention to packets with
  1591. this as an address.  So every system sees every ARP  requests.    They
  1592. all  look to see whether the request is for their own address.  If so,
  1593. they respond.  If not, they could just ignore it.   (Some  hosts  will
  1594. use  ARP  requests  to update their knowledge about other hosts on the
  1595. network, even if the request isn't for them.)  Note that packets whose
  1596. IP  address  indicates broadcast (e.g. 255.255.255.255 or 128.6.4.255)
  1597. are also sent with an Ethernet address that is all ones.
  1598.  
  1599.  
  1600.  
  1601. 10. Getting more information
  1602.  
  1603.  
  1604. This directory contains  documents  describing  the  major  protocols.
  1605. There  are literally hundreds of documents, so we have chosen the ones
  1606. that seem most important.  Internet standards are called RFC's.    RFC
  1607. stands  for  Request  for  Comment.   A proposed standard is initially
  1608. issued as a proposal, and given an RFC number.   When  it  is  finally
  1609. accepted,  it is added to Official Internet Protocols, but it is still
  1610. referred to by the RFC number.   We  have  also  included  two  IEN's.
  1611. (IEN's  used  to  be  a  separate  classification  for  more  informal
  1612. documents.  This classification no longer exists -- RFC's are now used
  1613. for  all  official  Internet documents, and a mailing list is used for
  1614. more informal reports.)  The convention is that  whenever  an  RFC  is
  1615. revised, the revised version gets a new number.  This is fine for most
  1616. purposes, but it causes problems with two documents: Assigned  Numbers
  1617. and  Official  Internet  Protocols.  These documents are being revised
  1618. all the time, so the RFC number keeps changing.  You will have to look
  1619. in rfc-index.txt to find the number of the latest edition.  Anyone who
  1620. is seriously interested in TCP/IP should read the  RFC  describing  IP
  1621. (791).    RFC 1009 is also useful.  It is a specification for gateways
  1622. to be used by NSFnet.  As such, it contains an overview of  a  lot  of
  1623. the  TCP/IP technology.  You should probably also read the description
  1624. of at least one of the application protocols, just to get a  feel  for
  1625. the  way  things  work.    Mail is probably a good one (821/822).  TCP
  1626. (793) is of course a very basic specification.  However  the  spec  is
  1627. fairly  complex,  so  you should only read this when you have the time
  1628. and patience to think about it carefully.  Fortunately, the author  of
  1629. the  major  RFC's  (Jon Postel) is a very good writer.  The TCP RFC is
  1630. far easier to read than you would expect, given the complexity of what
  1631. it  is  describing.    You  can  look at the other RFC's as you become
  1632. curious about their subject matter.
  1633.  
  1634. Here is a list of the documents you are more likely to want:
  1635.  
  1636.      rfc-index list of all RFC's
  1637.  
  1638.                                   25
  1639.  
  1640.  
  1641.  
  1642.      rfc1012   somewhat fuller list of all RFC's
  1643.  
  1644.      rfc1011   Official Protocols.  It's useful to scan  this  to  see
  1645.                what tasks protocols have been built for.  This defines
  1646.                which  RFC's  are  actual  standards,  as  opposed   to
  1647.                requests for comments.
  1648.  
  1649.      rfc1010   Assigned  Numbers.  If you are working with TCP/IP, you
  1650.                will probably want a hardcopy of this as  a  reference.
  1651.                It's  not  very  exciting  to  read.   It lists all the
  1652.                offically defined well-known ports and  lots  of  other
  1653.                things.
  1654.  
  1655.      rfc1009   NSFnet  gateway  specifications.  A good overview of IP
  1656.                routing and gateway technology.
  1657.  
  1658.      rfc1001/2 netBIOS: networking for PC's
  1659.  
  1660.      rfc973    update on domains
  1661.  
  1662.      rfc959    FTP (file transfer)
  1663.  
  1664.      rfc950    subnets
  1665.  
  1666.      rfc937    POP2: protocol for reading mail on PC's
  1667.  
  1668.      rfc894    how IP is to be put on Ethernet, see also rfc825
  1669.  
  1670.      rfc882/3  domains (the database used to go  from  host  names  to
  1671.                Internet  address  and back -- also used to handle UUCP
  1672.                these days).  See also rfc973
  1673.  
  1674.      rfc854/5  telnet - protocol for remote logins
  1675.  
  1676.      rfc826    ARP - protocol for finding out Ethernet addresses
  1677.  
  1678.      rfc821/2  mail
  1679.  
  1680.      rfc814    names and ports - general  concepts  behind  well-known
  1681.                ports
  1682.  
  1683.      rfc793    TCP
  1684.  
  1685.      rfc792    ICMP
  1686.  
  1687.      rfc791    IP
  1688.  
  1689.      rfc768    UDP
  1690.  
  1691.      rip.doc   details of the most commonly-used routing protocol
  1692.  
  1693.      ien-116   old  name  server  (still  needed  by  several kinds of
  1694.                system)
  1695.  
  1696.      ien-48    the  Catenet  model,   general   description   of   the
  1697.                                   26
  1698.  
  1699.  
  1700.  
  1701.                philosophy behind TCP/IP
  1702.  
  1703. The following documents are somewhat more specialized.
  1704.  
  1705.      rfc813    window and acknowledgement strategies in TCP
  1706.  
  1707.      rfc815    datagram reassembly techniques
  1708.  
  1709.      rfc816    fault isolation and resolution techniques
  1710.  
  1711.      rfc817    modularity and efficiency in implementation
  1712.  
  1713.      rfc879    the maximum segment size option in TCP
  1714.  
  1715.      rfc896    congestion control
  1716.  
  1717.      rfc827,888,904,975,985
  1718.                EGP and related issues
  1719.  
  1720. To those of you who may be reading this document remotely  instead  of
  1721. at  Rutgers:  The  most  important  RFC's  have  been collected into a
  1722. three-volume set, the DDN Protocol Handbook.  It is available from the
  1723. DDN  Network  Information  Center,  SRI  International, 333 Ravenswood
  1724. Avenue, Menlo Park, California 94025 (telephone: 800-235-3155).    You
  1725. should  be able to get them via anonymous FTP from sri-nic.arpa.  File
  1726. names are:
  1727.  
  1728.   RFC's:
  1729.     rfc:rfc-index.txt
  1730.     rfc:rfcxxx.txt
  1731.   IEN's:
  1732.     ien:ien-index.txt
  1733.     ien:ien-xxx.txt
  1734.  
  1735. rip.doc is available  by  anonymous  FTP  from  topaz.rutgers.edu,  as
  1736. /pub/tcp-ip-docs/rip.doc.
  1737.  
  1738. Sites with access to UUCP but not FTP may be able to retreive them via
  1739. UUCP from UUCP host rutgers.  The file names would be
  1740.  
  1741.   RFC's:
  1742.     /topaz/pub/pub/tcp-ip-docs/rfc-index.txt
  1743.     /topaz/pub/pub/tcp-ip-docs/rfcxxx.txt
  1744.   IEN's:
  1745.     /topaz/pub/pub/tcp-ip-docs/ien-index.txt
  1746.     /topaz/pub/pub/tcp-ip-docs/ien-xxx.txt
  1747.   /topaz/pub/pub/tcp-ip-docs/rip.doc
  1748.  
  1749. Note that SRI-NIC has the entire set of RFC's and IEN's,  but  rutgers
  1750. and topaz have only those specifically mentioned above.
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.                                   27
  1757.