home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / sealink.lzh / SEALINK.DOC < prev   
Text File  |  1987-02-09  |  12KB  |  271 lines

  1.                                      SEALINK
  2.  
  3.                              File Transfer Protocol
  4.  
  5.                                  9 February 1987
  6.  
  7.  
  8.  
  9.           (C) COPYRIGHT 1986,87 by System Enhancement Associates, Inc.
  10.  
  11.  
  12.  
  13.      This document describes briefly the  SEAlink  file  transfer  protocol
  14.      developers' package.  SEAlink is a sliding  window  protocol  that  is
  15.      fully  backwards compatible with XMODEM in all tested implementations.
  16.  
  17.      The intent of SEAlink is to provide a file transfer protocol that does
  18.      not  suffer  from  propagation  delays,  such  as  are  introduced  by
  19.      satellite relays or packet switched  networks.  Actual  tests  of  the
  20.      enclosed  routines  has  shown  that  SEAlink  is capable of virtually
  21.      eliminating propagation delays and turnaround delays.  File  transfers
  22.      between New Jersey and Hawaii,  which normally suffer a degradation of
  23.      50% or more  due  to  satellite  relays,  proceed  as  fast  as  local
  24.      transfers.  Even transfers within the local exchange are speeded up by
  25.      up to 20% at 2400 baud by the elimination of turnaround delays.  Large
  26.      volume  tests  show  that SEAlink is capable of coming to within 2% of
  27.      the theoretical minimum time for data transfer.
  28.  
  29.  
  30.  
  31.      The developers' package contains the following files:
  32.  
  33.          SEALINK.DOC    This document.
  34.          SEALINK.C      A set of C routines for implementing SEAlink.
  35.          CLINK.EXE      A sample TTY program that implements SEAlink.
  36.  
  37.  
  38.  
  39.      You are granted a license to use this code in your  programs,  and  to
  40.      adapt  it to your particular situation and needs,  subject only to the
  41.      following conditions:
  42.  
  43.      1) You must refer to it as the SEAlink protocol,  and  you  must  give
  44.         credit to System Enhancement Associates.
  45.  
  46.      2) If  you  modify  it in such a way that your version cannot converse
  47.         with the original code as supplied by us,  then you should refer to
  48.         it as "SEAlink derived",  or as a "variation of SEAlink",  or words
  49.         to that effect.
  50.  
  51.      In short,  we're not asking for any money,  but we'd like to get  some
  52.      credit for our work.
  53.  
  54.  
  55.      This  document  is  not  meant  to  be  a  rigorous  definition of the
  56.      protocol.  The code provided should serve to document the details  and
  57.      fine  points  of  implementing SEAlink.  We will,  however,  present a
  58.      brief synopsis of how SEAlink adds sliding windows to XMODEM,  and why
  59.      XMODEM doesn't mind.
  60.  
  61.      First of all,  SEAlink adds a block number to the ACK and NAK used  in
  62.      XMODEM.(1)  We  thus  create  "ACK/NAK  packets",  with  the following
  63.      structure:
  64.  
  65.          Byte 0:   ACK, NAK, or C
  66.          Byte 1:   Block number
  67.          Byte 2:   One's compliment of block number
  68.  
  69.      This is identical in form to the first three bytes of a  data  packet,
  70.      except that the SOH has been replaced with an ACK or NAK.(2)
  71.  
  72.      From the receiver's point of view,  it does not matter if  the  trans-
  73.      mitter  is using sliding window or not.  The receiver simply sends ACK
  74.      and NAK packets as appropriate.  Any XMODEM driver tested to date will
  75.      simply ignore this excess data behind the ACK or NAK.
  76.  
  77.      From the transmitter's point of view,  it just barely matters  if  the
  78.      receiver can handle sliding window.  The transmitter always acts as if
  79.      it  is  sending sliding window,  but varies the window size.  If it is
  80.      seeing valid block numbers and check values behind the  received  ACKs
  81.      and NAKs,  it sets the window size to six blocks.  Otherwise,  it sets
  82.      the  window  size  to  one  block.  The  result is that it only "sends
  83.      ahead" if the receiver can handle it.
  84.  
  85.      It  should  be  a fairly simple matter to apply the underlying SEAlink
  86.      logic to almost any variant of XMODEM.
  87.  
  88.  
  89.      The  SEAlink  routines  provided  in  this package are also capable of
  90.      passing system dependent information,  such as true file size and time
  91.      of  last modification.  This data is passed in a special header block.
  92.      The header block looks exactly like any other block, except that it is
  93.      block number zero.
  94.  
  95.      This is still backwards compatible with XMODEM,  as a SEAlink receiver
  96.      does  not  mind if block zero is missing,  and any XMODEM receiver yet
  97.      tested will regard block zero as a duplicate block and ACK it.
  98.  
  99.      The data portion of block zero contains the following fields:
  100.  
  101.  
  102.          Offset    Size      Contents
  103.          ======    ====      ========
  104.  
  105.             0        4       Original file length.
  106.             4        4       Date  and  time  file  was  last mofified,  in
  107.                              seconds since 1979.
  108.             8       17       Original  file  name,  as  a  null  terminated
  109.                              string.
  110.            25       15       Name  of  transmitting  program,   as  a  null
  111.                              terminated string.
  112.            40       88       Null filler and expansion area.
  113.  
  114.  
  115.      (1) XMODEM/CRC uses a "C" in place of  a  NAK  to  indicate  CRC  error
  116.          detection.  SEAlink  follows  this convention,  and supports either
  117.          checksum or CRC.  For brevity,  this document will use the term NAK
  118.          to mean either a true NAK (hex 15) or a C (hex 43).
  119.      (2) See previous footnote.
  120.  
  121.      Any field which the transmitter cannot support should be  set  to  all
  122.      zeros.  Conversly,  the  receiver  should ignore any null fields.  The
  123.      receiver may ignore any field which he cannot support.
  124.  
  125.  
  126.  
  127.      The  routines  enclosed  in  this package should be reasonably easy to
  128.      implement in your application.  We have attempted to exclude  compiler
  129.      dependent and system dependent logic from these routines.
  130.  
  131.  
  132.      You will need to alter our references to our communications driver  to
  133.      conform  to  your  own driver.  The communications related routines we
  134.      use are:
  135.  
  136.          com_putc(c)         Output character c to comm port.
  137.  
  138.          int com_getc(t)     Get character from comm port within  t  tenths
  139.                              of   a  second.   Return  EOF  if  time  limit
  140.                              expires.
  141.  
  142.          com_dump()          Discard any pending output without sending it.
  143.  
  144.  
  145.      In  addition,  we  use  the  following  routines for controlling timed
  146.      loops:
  147.  
  148.          long timerset(t)    Set a timer.  Returns a timer value which will
  149.                              expire in t tenths of a second.
  150.  
  151.          int timeup(z)       Check a timer.  Returns true if  timer  z  has
  152.                              expired yet, or false otherwise.
  153.  
  154.  
  155.      These routines also make reference to the following functions for
  156.      system dependent information, which is optional:
  157.  
  158.          filestat(name,&fs)  Read directory entry for  a  file  and  return
  159.                              system dependent information.
  160.  
  161.          setstamp(f,dtg)     Set a file's date/time of last modification.
  162.  
  163.  
  164.  
  165.  
  166.      The SEAlink  implementation  provided  in  this  package  is  used  by
  167.      invoking the two primary routines:
  168.  
  169.  
  170.          int xmtfile(name)             /* transmit a file */
  171.          char *name;                   /* name of file to transmit */
  172.  
  173.      This  routine is used to send a file.  One file is sent at a time.  If
  174.      the  name  is blank (name is null or *name points to a null),  then an
  175.      end of transmission marker is sent.
  176.  
  177.      This routine returns a one if the file is successfully transmitted, or
  178.      a zero if a fatal error occurs.
  179.  
  180.  
  181.          char *rcvfile(name)           /* receive a file */
  182.          char *name;                   /* name of file (optional) */
  183.  
  184.      This routine is used to receive a file.  One file is  received.  If  a
  185.      name is specified for the file,  then that name WILL be used,  and any
  186.      name  sent  by  the transmitter will be ignored.  If the name is blank
  187.      (name is null or *name points to a null),  then the  transmitter  must
  188.      provide a name for the file.
  189.  
  190.      This routine returns a pointer to  the  name  of  the  file  that  was
  191.      received.  If the file transfer is not successful, then a null pointer
  192.      is returned.
  193.  
  194.      The  pointer  returned  by  rcvfile()  points to a static data buffer.
  195.      This does not have to be freed (and should not be),  but  it  will  be
  196.      overwritten the next time rcvfile() is called.
  197.  
  198.      The  rcvfile()  function  works  on a temporary file whose name is the
  199.      same as the final file,  but with a dash ("-") added at the beginning.
  200.      If  a  file  transfer  is  aborted,  then  this temporary file will be
  201.      retained.  An aborted file transfer will not harm a pre-existing  file
  202.      of the same name.
  203.  
  204.  
  205.  
  206.      These  routines  can  be  used  for  either  single  or  multiple file
  207.      transfers.
  208.  
  209.      To  send  multiple  files,  send  each  file one by one until either a
  210.      transmit fails or all files are sent.  If all  files  are  sent,  then
  211.      signal the end by calling xmtfile() with a null pointer.
  212.  
  213.      To receive multiple files,  call rcvfile() repeatedly until it returns
  214.      a null pointer.
  215.  
  216.  
  217.  
  218.      This  package includes a demonstration program named CLINK (pronounced
  219.      "clink"),  which is a  simple  TTY  program  for  doing  SEAlink  file
  220.      transfers.  CLINK  does  not  perform  any  sort of terminal emulation
  221.      whatsoever.  However,  she will make use of the ANSI.SYS screen driver
  222.      if you have it installed.
  223.  
  224.  
  225.      CLINK may be used in either of two ways: interactive mode or command
  226.      mode.
  227.  
  228.      To use CLINK in the interactive mode, give the command "CLINK" with no
  229.      arguments.  Press  the  "ESCape"  key to give a command to CLINK.  The
  230.      command "?" (question mark) instructs CLINK to tell you what  commands
  231.      she understands.
  232.  
  233.      To  use  CLINK  in the command mode,  give the command "CLINK" with an
  234.      argument.  There are three arguments you can give CLINK in the command
  235.      mode.  These are:
  236.  
  237.       1) Receive files;  Do this with a command of the form:
  238.  
  239.               CLINK R
  240.  
  241.          CLINK  will  attempt  to receive one or more files from COM1,  and
  242.          will terminate as soon as all files  are  received,  or  when  the
  243.          transfer aborts.
  244.  
  245.       2) Transmit files; Do this with a command of the form:
  246.  
  247.               CLINK T <filename> ...
  248.  
  249.          CLINK  will  attempt  to transmit the listed files over COM1,  and
  250.          will terminate as soon as all files are sent,  or the transfer  is
  251.          aborted.  <filename> may be one or more file names with or without
  252.          drive and path specifiers.  Wildcards may be used.
  253.  
  254.       3) Give help;  If you type:
  255.  
  256.               CLINK ?
  257.  
  258.          or any invalid command,  CLINK will display a  brief  reminder  of
  259.          what arguments she understands in command mode.
  260.  
  261.      In all cases, CLINK in the command mode will not alter the serial port
  262.      other than to set eight data bits,  one stop bit,  and no parity.  Any
  263.      previously installed serial drivers will be  replaced,  and  the  baud
  264.      rate will not be changed.
  265.  
  266.  
  267.  
  268.      CLINK comes with her own serial driver built in for the IBM PC  family
  269.      and true compatibles,  but she is capable of using any standard FOSSIL
  270.      driver.
  271.