home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / int_prot.zip / INTERPRO.FAQ < prev   
Text File  |  1994-05-21  |  93KB  |  1,700 lines

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