home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / UUCP_Blars.lzh / DOC / uucp_protocol_description < prev    next >
Text File  |  1991-09-23  |  51KB  |  1,387 lines

  1. Article 118 of comp.doc:
  2. Path: blars!usc!wupost!uunet!ogicse!ucsd!brian
  3. From: brian@ucsd.Edu (Brian Kantor)
  4. Newsgroups: comp.doc
  5. Subject: UUCP_PROTOCOL_DESCRIPTION
  6. Message-ID: <41781@ucsd.Edu>
  7. Date: 20 Sep 91 11:00:27 GMT
  8. Sender: root@ucsd.Edu
  9. Distribution: na
  10. Lines: 1372
  11. Approved: comp-doc@ucsd.edu
  12.  
  13. From: jeh@cmkrnl.uucp
  14. Newsgroups: comp.doc
  15. Subject: UUCP "g" Protocol Description
  16. Date: 2 Aug 91 17:58:08 PDT
  17. Organization: Kernel Mode Consulting, San Diego CA
  18.  
  19. Hi,
  20.  
  21. Following my sig is a document that describes the uucp 'g' protocol in fair
  22. detail.  
  23.  
  24. I've made a couple of tweaks to be able to send this through mail.  
  25. Before printing, use a text editor to do the following:
  26.  
  27.     o  Change all occurrences of the string ^L (two characters, 
  28.     a carat and an uppercase L) to a form-feed character
  29.  
  30.     o  Change all occurrences of the string ^H to a backspace
  31.     character (this is used in underlined sequences)
  32.  
  33.     --- Jamie Hanrahan, Kernel Mode Consulting, San Diego CA
  34. uucp protocol guru, VMSnet (DECUS uucp) Working Group, and
  35. Chair, VMS Internals Working Group, U.S. DECUS VAX Systems SIG 
  36. Internet:  jeh@dcs.simpact.com, hanrahan@eisner.decus.org, or jeh@crash.cts.com
  37. Uucp:  ...{crash,eisner,uunet}!cmkrnl!jeh
  38.  
  39. ^L
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.                            UUCP "G" PROTOCOL
  57.  
  58.  
  59.                              Session UN047
  60.  
  61.                        Fall 1990 DECUS Symposium
  62.  
  63.                            Las Vegas, Nevada
  64.  
  65.  
  66.                             Tuesday, 4pm-5pm
  67.  
  68.                       Pavilion 2, Las Vegas Hilton
  69.  
  70.  
  71.  
  72.                            Jamie E. Hanrahan
  73.         Chair, VMSnet (DECUS uucp) and Internals Working Groups
  74.                          DECUS VAX Systems SIG
  75.  
  76.                            Simpact Associates
  77.                           9210 Sky Park Court
  78.                           San Diego, CA 92123
  79.                          +1 619-565-1865 x1116
  80.                           jeh@dcs.simpact.com
  81.                            jeh@crash.cts.com
  82.                  {decwrl,scubed,crash,nosc}!simpact!jeh
  83. ^L
  84. UUCP "G" PROTOCOL                                                 Page 2
  85. UN047, Tuesday, 4-5 pm
  86.  
  87.  
  88. 1  INITIAL HANDSHAKE ("SHERE EXCHANGE")
  89.  
  90.  
  91.       o  Occurs after call placement and login
  92.  
  93.       o  Initiated by answering system
  94.  
  95.       o  All messages begin with \020 (ctrl-P, also known as DLE) and
  96.          end with \000 (NUL)
  97.  
  98.       o  Sent and received in "raw mode" (no carriage returns, line
  99.          feeds, etc.)
  100.  
  101.           ______________________________________________________________
  102.  
  103.           Caller                                                Answerer
  104.           ------>                                              <--------
  105.  
  106.           (places call, gets carrier,
  107.           gets login prompt, logs in)
  108.                                                  (uucico program starts)
  109.                                                   \020Shere=_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He\000
  110.           \020S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He\000
  111.                                                              \020ROK\000
  112.           ______________________________________________________________
  113.  
  114.  
  115.       o  _^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He's are the respective systems' uucp host names.
  116.  
  117.       o  Caller's S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He message may include any or all of the
  118.          following optional elements:
  119.  
  120.          S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He -Q_^Hs_^He_^Hq -x_^Hd_^Hb_^Hg -p_^Hg_^Hr_^Ha_^Hd_^He -vgrade=_^Hg_^Hr_^Ha_^Hd_^He
  121.  
  122.           -  _^Hs_^He_^Hq = call sequence number (or 0)
  123.  
  124.           -  _^Hd_^Hb_^Hg is a digit, answerer sets its debug level accordingly
  125.  
  126.           -  _^Hg_^Hr_^Ha_^Hd_^He indicates what class of files are being transferred
  127.              (e.g. mail, news, arbitrary files).  Taken from systems
  128.              file entry; not sent or supported by all systems.  Some
  129.              implementations support -p, some support -v, some both,
  130.              some neither.  (See discussion of "C." files later on)
  131.  
  132.       o  Old answerers may send just Shere instead of Shere=_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He .
  133.  
  134. The "ROK" message says that the answerer has accepted the call.
  135. Instead, the answerer may reject the call with any of the following
  136. messages:
  137.  
  138.       o  RLCK - answerer thinks it's already talking to that caller
  139.  
  140.       o  RCB - answerer wants to call the caller back (to avoid imposter
  141.          callers)
  142. ^L
  143. UUCP "G" PROTOCOL                                                 Page 3
  144. UN047, Tuesday, 4-5 pm
  145.  
  146.  
  147.       o  RBADSEQ - call sequence number is wrong (caller is an imposter,
  148.          or more likely, sequence numbers weren't updated properly at
  149.          one end or the other)
  150.  
  151.       o  RLOGIN - caller's login name (username) isn't known to
  152.          answerer's uucp (USERFILE or Permissions file)
  153.  
  154.       o  RYou are unknown to me - (yes, it really does send all of that)
  155.          caller's hostname isn't known to answerer (as determined by
  156.          L.sys or Systems file)
  157.  
  158. If caller receives any of these, it simply hangs up.  (The answerer
  159. hangs up after sending the reject message, possibly waiting a few
  160. seconds so that the modem disconnect won't prevent the message from
  161. reaching the caller.)
  162.  
  163. If answerer "accepts the call":
  164.  
  165.           ______________________________________________________________
  166.  
  167.           Caller                                                Answerer
  168.           ------>                                              <--------
  169.  
  170.                                                                P_^Hp_^Hr_^Ho_^Ht_^Hl_^Hi_^Hs_^Ht
  171.           U_^Hp_^Hr_^Ho_^Ht
  172.           ______________________________________________________________
  173.  
  174.  
  175. where
  176.  
  177.       o  _^Hp_^Hr_^Ho_^Ht_^Hl_^Hi_^Hs_^Ht is a list of the protocols (each identified by a
  178.          single letter, e.g. "g") supported by the answerer
  179.  
  180.       o  _^Hp_^Hr_^Ho_^Ht is a single protocol from _^Hp_^Hr_^Ho_^Ht_^Hl_^Hi_^Hs_^Ht selected by the
  181.          answerer
  182.  
  183.       o  Caller can send UN (and then hang up) if it supports no
  184.          protocols in common with answerer
  185.  
  186. At this point the two machines have agreed on a protocol.  We'll assume
  187. that it's the "g" protocol, so that the last two messages may have been
  188. something like
  189.  
  190.           ______________________________________________________________
  191.  
  192.           Caller                                                Answerer
  193.           ------>                                              <--------
  194.  
  195.                                                                     Pfgt
  196.           Ug
  197.           ______________________________________________________________
  198.  
  199.  
  200. At this point both systems call the gturnon() function, which causes the
  201. g data link protocol to start up.
  202. ^L
  203. UUCP "G" PROTOCOL                                                 Page 4
  204. UN047, Tuesday, 4-5 pm
  205.  
  206.  
  207. 2  G PROTOCOL PACKET FORMATS
  208.  
  209. All subsequent communication (until after the G protocol shutdown) is in
  210. "packet mode".
  211.  
  212.       o  Each packet has a six-byte header
  213.  
  214.       o  Control packets have _^Ho_^Hn_^Hl_^Hy a header
  215.  
  216.       o  Data packets have a header and a data segment
  217.  
  218.  
  219. 2.1  Packet Header Format
  220.  
  221.           +-------+-------+-------+-------+-------+-------+
  222.           |  DLE  |   K   | cklo  | ckhi  |  ctl  |  XOR  |
  223.           +-------+-------+-------+-------+-------+-------+
  224.  
  225. The first byte is _^Ha_^Hl_^Hw_^Ha_^Hy_^Hs DLE (octal 020, hex 10).
  226.  
  227. The second byte is the "K-byte".  For a control packet it is always 9
  228. (ie a tab character).  For data packets it indicates the transmitted
  229. (physical) length of the following data segment, as follows:
  230.  
  231.                 K-byte value    data seg. len. (bytes)
  232.                 ------------    ----------------------
  233.                       1                   32
  234.                       2                   64
  235.                       3                  128
  236.                       4                  256
  237.                       5                  512
  238.                       6                 1024
  239.                       7                 2048
  240.                       8                 4096
  241.                       9             control packet
  242.  
  243.  
  244. The third and fourth bytes are the low and high bytes, respectively, of
  245. a checksum computed on the data segment (if any) plus the control byte.
  246. (The checksum computation is described later.)
  247.  
  248. The fifth byte is a bitmapped command byte, described in the next
  249. section.
  250.  
  251. The last byte is a simple XOR of the middle four bytes.  The first and
  252. last bytes perform a framing and validation function for headers.
  253.  
  254.  
  255. 2.2  The Control Byte
  256.  
  257. The "control" byte is bit-mapped as follows:
  258.  
  259.                   7   6   5   4   3   2   1   0
  260.                 +-------+-----------+-----------+
  261.                 | T   T | X   X   X | Y   Y   Y |
  262.                 +-------+-----------+-----------+
  263. ^L
  264. UUCP "G" PROTOCOL                                                 Page 5
  265. UN047, Tuesday, 4-5 pm
  266.  
  267.  
  268. The T field denotes the type of packet:
  269.  
  270.         T value         packet type
  271.         -------         ------------------------------------------
  272.            0            control packet 
  273.            1            alternate channel data packet (unused in uucp)
  274.            2            long data block
  275.            3            short data block (to be described later)
  276.  
  277. The interpretations of the X and Y fields vary with the packet type
  278. (control vs. data).
  279.  
  280. For control packets the X field is the type of control packet and the Y
  281. field is a parameter, as follows:
  282.  
  283.         X value    name      Y field interpretation
  284.         -------    ------    ---------------------------------------
  285.            1       CLOSE     no significance
  286.            2       NAK       last correctly received packet number
  287.            3       SRJ       packet number to retransmit
  288.            4       ACK       last correctly received packet number
  289.            5       INITC     max window size to use
  290.            6       INITB     max data segment size to use
  291.            7       INITA     max window size to use
  292.  
  293.  
  294.       o  The "data segment size" on the INITB packet is encoded like the
  295.          KBYTE but with numbers one lower; e.g. an INITB packet with a Y
  296.          field of 1 indicates a data segment size of 64 bytes.
  297.  
  298.       o  Most descriptions of uucp refer to types 2 and 4 as "RJ"
  299.          (reject) and "RR" (receiver ready), respectively.
  300.  
  301.       o  SRJ ("selective reject") is not used in known implementations.
  302.  
  303.  
  304. 2.3  Data Packets
  305.  
  306. For data packets, the X field is the sequence number of the packet, and
  307. the Y field is the "ACK number" -- the sequence number of the last
  308. packet correctly received by the system sending the data packet.  (See
  309. the section on data transfer and acknowledgement.)
  310.  
  311. A data packet header is always followed by a data segment of size
  312. indicated by the Kbyte.
  313.  
  314.  
  315. 2.3.1  Long Data Packets
  316.  
  317. If the packet type is "long data", all 'n' bytes of the data segment
  318. (where 'n' is denoted by the Kbyte) contain data.
  319. ^L
  320. UUCP "G" PROTOCOL                                                 Page 6
  321. UN047, Tuesday, 4-5 pm
  322.  
  323.  
  324. 2.3.2  Short Data Packets
  325.  
  326. If the packet type is "short data", the data segment is still sent in
  327. its entirety, but the first one or two bytes indicate the _^Hd_^Hi_^Hf_^Hf_^He_^Hr_^He_^Hn_^Hc_^He
  328. between its physical (transmitted) length and the number of bytes to be
  329. passed to the presentation level (its "logical length"):
  330.  
  331.  
  332.       7   6   5   4   3   2   1   0
  333.     +---+---------------------------+
  334.     | 0 | length difference (1-127) |
  335.     +---+---------------------------+
  336.  
  337.     or, if the difference is too large to fit in seven bits,
  338.  
  339.       7   6   5   4   3   2   1   0   7   6   5   4   3   2   1   0
  340.     +---+---------------------------+-------------------------------+
  341.     | 1 | length difference(lo bits)| length difference (high bits) |
  342.     +---+---------------------------+-------------------------------+
  343.         first byte of data segment     second byte of data segment
  344.  
  345.  
  346. For example, a data packet with a physical segment size of 64 (Kbyte=2),
  347. but an effective (logical) length of zero, would be sent by sending a
  348. "short data" packet where the data segment consisted of a byte with the
  349. numeric value 64, e.g.
  350.  
  351.  
  352.       7   6   5   4   3   2   1   0
  353.     +---+---------------------------+
  354.     | 0 | 1   0   0   0   0   0   0 |
  355.     +---+---------------------------+
  356.  
  357.  
  358. followed by 63 additional bytes (whose contents would be ignored by the
  359. receiver).
  360.  
  361.  
  362. 3  G PROTOCOL ("DATA LINK LAYER") INITIALIZATION
  363.  
  364. G protocol is initialized via an exchange of the INITA, INITB, and INITC
  365. packets.  A simple approach:
  366.  
  367.       o  Each system starts sending INITA's to the other
  368.  
  369.       o  Upon receiving an INITA, send an INITB
  370.  
  371.       o  Upon receiving an INITB, send an INITC
  372.  
  373.       o  When both have sent and received an INITC, initialization is
  374.          complete
  375.  
  376. When the INITx packets are received each system sets its uucp parameters
  377. (data segment size and maximum transmit window size) to the _^Hs_^Hm_^Ha_^Hl_^Hl_^He_^Hr of
  378. what it can handle and what it gets from the packet.
  379. ^L
  380. UUCP "G" PROTOCOL                                                 Page 7
  381. UN047, Tuesday, 4-5 pm
  382.  
  383.  
  384. 4  G PROTOCOL DATA TRANSFER AND ACKNOWLEDGEMENT
  385.  
  386. After initialization, data packets are exchanged.  Thus, all subsequent
  387. traffic consists of Shortdata, Longdata, ACK, and NAK packets (until the
  388. end of the session, when CLOSE packets are exchanged).
  389.  
  390.       o  Each data packet must be _^Ha_^Hc_^Hk_^Hn_^Ho_^Hw_^Hl_^He_^Hd_^Hg_^He_^Hd by the receiver.
  391.  
  392.       o  Data packets can only be acknowledged in sequence.
  393.  
  394.       o  If a data packet arrives corrupted (as determined via
  395.          checksum), the receiver sends a NAK (requesting retransmission)
  396.          or simply does not send an ACK, allowing the sender to time out
  397.          awaiting an ACK (which has the same effect).
  398.  
  399.       o  The first packet sent by each transmitter has sequence number
  400.          one.  Packet sequence numbers are modulo 8 (ie 1, 2, ..., 7, 0,
  401.          1, ...)
  402.  
  403.       o  Uucp (in most implementations) uses a transmit window size of
  404.          more than 1 (typically 3, maximum 7 due to the three-bit packet
  405.          sequence numbers)
  406.  
  407.           -  After sending one data packet the sender need not wait for
  408.              an ACK before sending the next data packet, until _^Hw_^Hi_^Hn_^Hd_^Ho_^Hw
  409.              _^Hs_^Hi_^Hz_^He unACK'd packets have been sent
  410.  
  411.           -  Colloquially this is known as a "windowed" protocol.  (As
  412.              opposed to stop-and-wait, e.g. most Kermit implementations)
  413.  
  414.           -  After the transmit window is full (ie _^Hw_^Hi_^Hn_^Hd_^Ho_^Hw _^Hs_^Hi_^Hz_^He unACK'd
  415.              packets have been sent), transmitter must wait for an ACK
  416.              of (at least) the first packet in the transmit window
  417.              before sending another packet
  418.  
  419.       o  g protocol's _^Hr_^He_^Hc_^He_^Hi_^Hv_^He _^Hw_^Hi_^Hn_^Hd_^Ho_^Hw _^Hs_^Hi_^Hz_^He is 1 -- at any given time
  420.          there is only one packet which is valid to be received.
  421.  
  422.       o  An ACK provides the number of the last correctly-received
  423.          packet, and implies that all earlier packet numbers have also
  424.          been correctly received.  Thus a single ACK may acknowledge
  425.          multiple packets.
  426.  
  427.       o  The "ACK number" -- the number of the most recent correctly-
  428.          received message -- also appears in the Y field of the headers
  429.          of data packets.  If a system is about to acknowledge a packet,
  430.          but happens to have a data packet to send, it need not send an
  431.          explicit ACK; putting the number of the packet to be ACK'd in
  432.          the Y field of the data packet is sufficient.  This doesn't
  433.          happen often, because uucp's "upper layers" don't use the link
  434.          in both directions at once.
  435.  
  436.       o  A NAK provides _^Ht_^Hh_^He _^Hs_^Ha_^Hm_^He _^Hn_^Hu_^Hm_^Hb_^He_^Hr as an ACK but requests
  437.          retransmission of all outstanding packets with higher (modulo
  438.          8) numbers.
  439. ^L
  440. UUCP "G" PROTOCOL                                                 Page 8
  441. UN047, Tuesday, 4-5 pm
  442.  
  443.  
  444.       o  Both ACKs and NAKs provide acknowledgement for not only the
  445.          indicated packet but also all previous packets in the transmit
  446.          window ("stacked ACKs").
  447.  
  448. This is known as a "go back n" protocol.  It is relatively easy to
  449. implement but performance suffers when errors occur.
  450.  
  451. More complex protocols allow a receive window size of greater than one
  452. with "selective reject", and this was in fact the intent of the SRJ
  453. control packet.  An SRJ says "retransmit this one packet, I didn't get
  454. it right".  This avoids having to resend an entire transmit window to
  455. correct an error in just one packet.
  456. ^L
  457. UUCP "G" PROTOCOL                                                 Page 9
  458. UN047, Tuesday, 4-5 pm
  459.  
  460.  
  461. 4.1  A Simple Data Exchange
  462.  
  463.           ______________________________________________________________
  464.  
  465.           Sender                                                Receiver
  466.           ------>                                              <--------
  467.  
  468.           Data 1 
  469.                                                     (receives Data 1 ok)
  470.                                                                    Ack 1
  471.           Data 2
  472.                                                     (receives Data 2 ok)
  473.                                                                    Ack 2
  474.           (receives Ack 1)
  475.           Data 3
  476.                                                     (receives Data 3 ok)
  477.                                                                    Ack 3
  478.           (receives Ack 2)
  479.           Data 4
  480.                                               (receives Data 4 in error)
  481.                                                                    NAK 3
  482.           (receives Ack 3)
  483.           Data 5
  484.                                     (receives Data 5 ok but out of seq.)
  485.           (receives NAK 3)
  486.           (resends everything in window)
  487.           Data 4
  488.           Data 5
  489.                                                     (receives Data 4 ok)
  490.                                                                    Ack 4
  491.           Data 6
  492.                                                     (receives Data 5 ok)
  493.                                                                    Ack 5
  494.           (receives Ack 4)
  495.           Data 7
  496.                                       etc...
  497.           ______________________________________________________________
  498.  
  499.  
  500. 4.2  Data Link Layer:  Interesting Cases, Implementation Notes, And War
  501.      Stories
  502.  
  503. 4.2.1  Corrupted Packet Headers
  504.  
  505. When looking for a packet, the receiver should scan for a DLE, then read
  506. the next five bytes following and check the XOR.
  507.  
  508.       o  If the XOR check fails, the "packet header" cannot be trusted.
  509.          Scanning for the next DLE begins at the next byte following the
  510.          current DLE (_^Hn_^Ho_^Ht six bytes after it).
  511.  
  512.       o  If the XOR check succeeds, but something's wrong with the
  513.          header (illegal Kbyte value, for example), the receiver should
  514.          treat this the same as an XOR failure.  (XOR checks aren't all
  515.          that robust)
  516. ^L
  517. UUCP "G" PROTOCOL                                                Page 10
  518. UN047, Tuesday, 4-5 pm
  519.  
  520.  
  521. 4.2.2  Corrupted Data Segments
  522.  
  523. If the header on a data packet is good (XOR is okay), but the checksum
  524. indicates that the data segment is corrupt:
  525.  
  526.       o  Send a NAK to indicate receipt of a corrupted data packet (but
  527.          see below)
  528.  
  529.       o  Rescan the input looking for the next control packet, starting
  530.          with the first byte of the data segment
  531.  
  532. This seems counterintuitive; if we can trust the header it seems that we
  533. ought to be able to trust it to tell us how long the data segment is,
  534. and just skip it.
  535.  
  536. Suppose the file being received is a copy of just one direction of a
  537. uucp data transfer.  If we pay no attention to what's inside the data
  538. segments we see this (assuming 32-byte data segments, K = 1):
  539.  
  540.  
  541.         HHHHHH DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD HHHHHH DDDD...
  542.  
  543.         but since the data contains a uucp packet stream, the data 
  544.         fields contain
  545.  
  546.         HHHHHH ddddhhhhhhdddddddddddddddddddddd HHHHHH ddddddddddhhhhhh
  547.                                                                
  548.         1          2                            3          4     5
  549.  
  550.  
  551. Now, suppose that the header at 1 gets corrupted in transmission, so the
  552. XOR check fails.  We junk it and start looking for another DLE, and we
  553. find the "imbedded header" at 2.  It passes xor, so we interpret it as a
  554. data header, and read the next 32 characters.  If it happens to be the
  555. right packet number it'll fail on checksum, but more likely it's the
  556. wrong packet number; whatever, we send a NAK to tell the sender what we
  557. want, and resume scanning.  Since we rescan all of (what we thought was)
  558. the data segment, we'll find the DLE at 3...and we're back in sync.
  559.  
  560. If instead we had said "bad data segment, skip 32 characters" we'd be
  561. looking for the next header starting at 4.  We'd then find the next
  562. imbedded header at 5....  we'd eventually get back in sync, but it might
  563. take a LONG time!
  564.  
  565.  
  566. 4.2.3  Missing Packets (out-of-sequence Packets)
  567.  
  568. Uucp "g" protocol employs a receive window size of one; that is, there
  569. is only one packet that may be received at any time (the next one that
  570. follows the previous correctly-received packet).
  571.  
  572. If an out-of-sequence packet is received the correct response is to send
  573. a NAK (with the Y field, as always, being the number of the last good
  574. packet).
  575. ^L
  576. UUCP "G" PROTOCOL                                                Page 11
  577. UN047, Tuesday, 4-5 pm
  578.  
  579.  
  580. 4.2.4  Too Many NAKs
  581.  
  582. It is not good to send a NAK for every error condition.  Let's revisit
  583. the simple data exchange diagrammed previously:
  584.  
  585.           ______________________________________________________________
  586.  
  587.           Sender                                                Receiver
  588.           ------>                                              <--------
  589.  
  590.           Data 3
  591.                                                     (receives Data 3 ok)
  592.                                                                    Ack 3
  593.           (receives Ack 2)
  594.           Data 4
  595.                         (data 4 is corrupted on the link)
  596.                                                (receives Data 4 w/error)
  597.                                                               NAK 3 (#1)
  598.           (receives Ack 3)
  599.           Data 5
  600.                                            (receives Data 5 out of seq.)
  601.                                                               NAK 3 (#2)
  602.           Data 6
  603.                                            (receives Data 6 out of seq.)
  604.                                                               NAK 3 (#3)
  605.           (receives NAK 3 #1)
  606.           Data 4
  607.           Data 5
  608.           Data 6
  609.                                                     (receives Data 4 ok)
  610.                                                                    Ack 4
  611.           (receives NAK 3 #2)
  612.           Data 4
  613.           Data 5
  614.           Data 6
  615.           (receives Ack 4)
  616.                                            (receives Data 4 out of seq.)
  617.                                                                    NAK 4
  618.                                       etc...
  619.           ______________________________________________________________
  620.  
  621.  
  622.  
  623.       o  Unix uucps address this by being very "shy" about sending NAKs,
  624.          mostly just letting the sender time out.
  625.  
  626.          This works but hurts throughput.
  627.  
  628.       o  DECUS uucp keeps track of the number of received error packets
  629.          and sends the NAK only if the number modulo the window size =
  630.          1.  Thus we send the first NAK right away, but no more until at
  631.          least a window-size worth of packets have been received.
  632. ^L
  633. UUCP "G" PROTOCOL                                                Page 12
  634. UN047, Tuesday, 4-5 pm
  635.  
  636.  
  637. 4.2.5  Duplicate Packets
  638.  
  639. If a packet is received with a number that's already been received and
  640. ACKd it's either
  641.  
  642.       o  a duplicate of one we got earlier; our ACKs got lost, so the
  643.          sender timed out and is resending its window
  644.  
  645.       o  a future packet, and the intervening seven packets were bad
  646.          (but this can't happen, since max window size is seven, not
  647.          eight)
  648.  
  649. Since packets must always be acked in sequence, the only correct thing
  650. is to send a NAK indicating the last good (in sequence) received packet.
  651.  
  652.  
  653. 4.2.6  Miscellaneous
  654.  
  655. 4.2.6.1  Control Packet Priority
  656.  
  657. The control packet types denote the priority of the packets.  That is,
  658. if several control packets are to be sent, the lower-numbered ones are
  659. sent first.  (CLOSE before anything else, for example.) Control packets
  660. in turn have priority over data packets.
  661.  
  662.  
  663. 4.2.6.2  Varying Physical Packet Lengths
  664.  
  665. Although the protocol allows for data packets with different K values
  666. (physical lengths) to be sent in a session, in practice, both ends
  667. always use the value negotiated at the start of the session.
  668.  
  669.  
  670. 4.2.6.3  Interpacket Noise
  671.  
  672. The DLE that begins a packet should follow right on the heels of the
  673. previous packet.  Berkeley 4.3 uucp has a bug that causes it to send two
  674. null bytes between packets.  A robust implementation will _^Hn_^Ho_^Ht report
  675. errors when it encounters two null bytes while looking for a DLE.
  676.  
  677.  
  678. 4.2.6.4  Common Parameters
  679.  
  680. Almost all implementations seem to use a window size of 3 and a data
  681. packet physical length of 64 bytes (Kbyte = 2).  Some implementations
  682. will agree to use a larger window size or packet length, but do not do
  683. so correctly.
  684. ^L
  685. UUCP "G" PROTOCOL                                                Page 13
  686. UN047, Tuesday, 4-5 pm
  687.  
  688.  
  689. 4.2.6.5  Checksum Details
  690.  
  691. The checksum that is placed in the packet header for data packets has
  692. the value
  693.  
  694.                MAGIC - (chksum(buf,len) ^ (0xFF & cbyte))
  695.  
  696. For control packets, the checksum value is simply
  697.  
  698.                          MAGIC - (0xFF & cbyte)
  699.  
  700. where
  701.          buf is the data segment
  702.          len is its (physical) length
  703.          chksum() is shown below
  704.          cbyte is the value of the control byte
  705.          MAGIC is 0125252 (octal) (i.e. alternating bits set)
  706.  
  707. If a data packet is resent, the checksum must be recalculated, as the
  708. checksum includes the control byte and the Y field (last good received
  709. packet number) of the control byte might change between transmissions of
  710. the same data packet.
  711.  
  712. /*
  713.  * the checksum routine, copied from G. L. Chesson's article,
  714.  * modified by John Gilmore to reflect actual behavior 
  715.  * (see References)
  716.  */
  717.  
  718. int
  719. chksum(s,n)
  720. register unsigned char *s;
  721. register n;
  722. {
  723.         register short sum;
  724.         register unsigned short t;
  725.         register short x;
  726.  
  727.         sum = -1;
  728.         x = 0;
  729.         do {
  730.                 if (sum < 0) {
  731.                         sum <<= 1;
  732.                         sum++;
  733.                 }
  734.                 else
  735.                         sum <<= 1;
  736.                 t = sum;
  737.                 sum += *s++ & 0377;
  738.                 x += sum ^ n;
  739.                 if ((unsigned short)sum <= t)
  740.                         sum ^= x;
  741.         } while (--n > 0);
  742.  
  743.         return(sum);
  744. }
  745. ^L
  746. UUCP "G" PROTOCOL                                                Page 14
  747. UN047, Tuesday, 4-5 pm
  748.  
  749.  
  750. 5  FILE TRANSFER "MESSAGES" ("APPLICATION LAYER")
  751.  
  752. The data packets and acknowledgements form a _^Hr_^He_^Hl_^Hi_^Ha_^Hb_^Hl_^He _^Hd_^Ha_^Ht_^Ha _^Hl_^Hi_^Hn_^Hk which
  753. the two uucico programs use to exchange _^Hm_^He_^Hs_^Hs_^Ha_^Hg_^He_^Hs and _^Hf_^Hi_^Hl_^He_^Hs.
  754.  
  755. At the start of a uucp session the caller is in _^Hm_^Ha_^Hs_^Ht_^He_^Hr _^Hm_^Ho_^Hd_^He and the
  756. answerer is in _^Hs_^Hl_^Ha_^Hv_^He.  The caller searches its uucp spool directory for
  757. work (queued requests to send or receive files).  Each such "work
  758. request" results in an "S" (request to send), "R" (request to receive),
  759. or "X" (remote request for uucp) message being sent to the slave:
  760.  
  761.  
  762.         S _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hm_^Ha_^Hs_^Ht_^He_^Hr _^Ht_^Ha_^Hr_^Hg_^He_^Ht_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hs_^Hl_^Ha_^Hv_^He ...
  763.  
  764.         R _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hs_^Hl_^Ha_^Hv_^He _^Ht_^Ha_^Hr_^Hg_^He_^Ht_^Hf_^Hi_^Hl_^He_^H__^Ho_^Hn_^H__^Hm_^Ha_^Hs_^Ht_^He_^Hr ...
  765.  
  766.         X _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He _^Hu_^Hu_^Hc_^Hp_^Hh_^Ho_^Hs_^Ht_^H!_^Ht_^Ha_^Hr_^Hg_^He_^Ht_^Hf_^Hi_^Hl_^He ...  (not covered here)
  767.  
  768.  
  769. The slave will respond with one of:
  770.  
  771.  
  772.             (for send requests)
  773.  
  774.         SY              ok
  775.         SN2             not permitted
  776.         SN4             can't create temporary file
  777.  
  778.             (for receive requests)
  779.  
  780.         RY<mode>        ok (gives protection mode of file)
  781.         RN2             not permitted
  782.  
  783.  
  784. If the master receives any of the reject messages it simply looks for
  785. its next queued work request.
  786.  
  787. If the master receives an "ok", the master (for file send requests) or
  788. the slave (for file receive requests) sends the file to the other side.
  789. The receiver of the file then sends one of the following messages:
  790.  
  791.  
  792.         CN5             couldn't move temp file into place
  793.         CY              file received ok
  794.  
  795.  
  796. to the sender.
  797. ^L
  798. UUCP "G" PROTOCOL                                                Page 15
  799. UN047, Tuesday, 4-5 pm
  800.  
  801.  
  802. 6  ROLE EXCHANGE
  803.  
  804. When the master has no more queued work requests it asks the slave if it
  805. wants to hang up.  The slave then looks for work and, if any is found,
  806. the two systems exchange master and slave roles.
  807.  
  808. Example:  Slave has no work, hangup is agreed upon:
  809.  
  810.           ______________________________________________________________
  811.  
  812.           Master                                                   Slave
  813.           ------>                                                 <-----
  814.  
  815.           H
  816.                                                                       HY
  817.           HY
  818.                         (at this point both systems invoke
  819.                          the G protocol shutdown routine)
  820.           ______________________________________________________________
  821.  
  822.  
  823.  
  824. Example:  Slave has work, roles are exchanged:
  825.  
  826.           ______________________________________________________________
  827.  
  828.           Master                                                   Slave
  829.           ------>                                                 <-----
  830.  
  831.           H
  832.                                                                       HN
  833.  
  834.                        (at this point roles are exchanged)
  835.           Slave                                                   Master
  836.           ----->                                                 <------
  837.  
  838.                                                        S file1 file2 ...
  839.  
  840.           ______________________________________________________________
  841.  
  842.  
  843. When the new master runs out of work it will again ask the former master
  844. if it wants to hang up (as more work may have been queued on that side
  845. during its tenure as slave).  The process repeats until neither system
  846. finds any work for the other.
  847. ^L
  848. UUCP "G" PROTOCOL                                                Page 16
  849. UN047, Tuesday, 4-5 pm
  850.  
  851.  
  852. 7  SENDING AND RECEIVING MESSAGES AND FILES ("PRESENTATION LAYER")
  853.  
  854. 7.1  Sending Messages
  855.  
  856.  
  857.       o  Messages (S, SY, SNn, R, RY, RNn, CY, CNn, H, HY, HN) are sent
  858.          in longdata packets.
  859.  
  860.       o  Some uucps send the last (or only) part of a message in a
  861.          shortdata packet.
  862.  
  863.       o  As many packets as necessary for the message are used.
  864.  
  865.       o  The message is terminated by a null byte.
  866.  
  867.       o  Only one message is sent at a time.
  868.  
  869.       o  Some uucps seem to expect the rest of the packet to be padded
  870.          with nulls.
  871.  
  872.  
  873. 7.2  Sending Files
  874.  
  875.  
  876.       o  Since Unix, and therefore uucp, has no concept of "file
  877.          attributes", the file is simply copied, byte for byte, into
  878.          packets and transmitted.  (The file protection mode is sent
  879.          either as a parameter on the S message or with the RY message.)
  880.  
  881.       o  Transmission of a shortdata packet with logical length of zero
  882.          indicates end of file (that is, the previous packet contains
  883.          the last bytes in the file).
  884.  
  885. These details are specific to the "g" protocol -- thus "g" includes both
  886. the data link and presentation layers.
  887.  
  888.  
  889. 8  G PROTOCOL SHUTDOWN
  890.  
  891. When both systems have agreed (via H, HY, HY message exchange) to hang
  892. up, they each call the gturnoff() function, causing CLOSE control
  893. messages to be exchanged:
  894.  
  895.           ______________________________________________________________
  896.  
  897.           (either)                                              (either)
  898.           -------->                                            <--------
  899.  
  900.                                                                    CLOSE
  901.           CLOSE
  902.           ______________________________________________________________
  903.  
  904.  
  905. ^L
  906. UUCP "G" PROTOCOL                                                Page 17
  907. UN047, Tuesday, 4-5 pm
  908.  
  909.  
  910. 9  "OVER AND OUT"
  911.  
  912. After the data link layer has exchanged "CLOSE" messages, one more set
  913. of "over and out" messages is exchanged:
  914.  
  915.           ______________________________________________________________
  916.  
  917.           Caller                                                Answerer
  918.           ------>                                              <--------
  919.  
  920.           OOOOOO  (six "O"'s)
  921.                                                   (seven "O"'s)  OOOOOOO
  922.           ______________________________________________________________
  923.  
  924.  
  925. Note that since the "g" protocol has already been turned off, these
  926. message are _^Hn_^Ho_^Ht preceded by six-byte headers.  They are, however,
  927. preceded by DLE and terminated by NUL, as were the Shere, S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He,
  928. P_^Hp_^Hr_^Ho_^Ht_^Hs, etc., messages at the beginning of the session.
  929. ^L
  930. UUCP "G" PROTOCOL                                                Page 18
  931. UN047, Tuesday, 4-5 pm
  932.  
  933.  
  934. 10  A COMPLETE SESSION
  935.  
  936. Here the caller sends one file and receives one, after which the
  937. answerer sends one file.  (ACKs, NAKs, and retransmits for the g
  938. protocol are not shown.)
  939.  
  940.           ______________________________________________________________
  941.  
  942.           Caller                                                Answerer
  943.           ------>                                              <--------
  944.  
  945.           (places call, logs in, etc.)
  946.                                                  (uucico program starts)
  947.  
  948.               (subsequent transmissions are framed by DLE .... NUL)
  949.  
  950.                                                           Shere=_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He
  951.           S_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He
  952.                                                                      ROK
  953.                                                                     Pfgt
  954.           Ug
  955.  
  956.                   (subsequent packets have "g" protocol headers)
  957.  
  958.           Control(INITA)                                  Control(INITA)
  959.           Control(INITB)                                  Control(INITB)
  960.           Control(INITC)                                  Control(INITC)
  961.           Longdata(S fromfile1 tofile1 ...)
  962.                                                             Longdata(SY)
  963.           Longdata(file contents)
  964.           Longdata(file contents)
  965.                    ...
  966.           Shortdata(last few bytes of file)
  967.           Shortdata(logical length 0)
  968.                                                             Longdata(CY)
  969.           Longdata(R fromfile1 tofile1 ...)
  970.                                                             Longdata(RY)
  971.                                                  Longdata(file contents)
  972.                                                  Longdata(file contents)
  973.                                                           ...           
  974.                                        Shortdata(last few bytes of file)
  975.                                              Shortdata(logical length 0)
  976.           Longdata(CY)
  977.           Longdata(H)
  978.                                                             Longdata(HN)
  979.                                        Longdata(S fromfile1 tofile1 ...)
  980.           Longdata(SY)
  981.                                                  Longdata(file contents)
  982.                                                  Longdata(file contents)
  983.                                                           ...           
  984.                                        Shortdata(last few bytes of file)
  985.                                              Shortdata(logical length 0)
  986.           Longdata(CY)
  987.                                                              Longdata(H)
  988.           Longdata(HY)
  989.                                                             Longdata(HY)
  990. ^L
  991. UUCP "G" PROTOCOL                                                Page 19
  992. UN047, Tuesday, 4-5 pm
  993.  
  994.  
  995.           Control(CLOSE)                                  Control(CLOSE)
  996.  
  997.             (subsequent transmissions are framed only by DLE .... NUL)
  998.  
  999.           OOOOOO
  1000.                                                                  OOOOOOO
  1001.           ______________________________________________________________
  1002.  
  1003.  
  1004.  
  1005.  
  1006. 11  UUCP WORK FILES:  ORIGINS OF "S" AND "R" COMMANDS
  1007.  
  1008. The uucico programs at each system are driven by _^Hw_^Ho_^Hr_^Hk _^Hf_^Hi_^Hl_^He_^Hs in the uucp
  1009. spool directory.
  1010.  
  1011.       o  To decide whether to call a uucp neighbor, uucico looks for
  1012.          work files associated with the neighbor's uucp host name.
  1013.  
  1014.       o  When answering a call from a uucp neighbor, after the neighbor
  1015.          asks "do you want to hang up?", the answering uucico looks for
  1016.          work files associated with the calling system's uucp host name.
  1017.  
  1018.  
  1019. 11.1  Work File Names
  1020.  
  1021. An older work file naming convention is:
  1022.  
  1023.         C._^Hr_^He_^Hm_^Ho_^Ht_^He_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He _^Hg_^Hr_^Ha_^Hd_^He _^Hu_^Hn_^Hi_^Hq
  1024.  
  1025. For example,
  1026.  
  1027.         C.crashA8128
  1028.  
  1029.  
  1030.       o  "C." is a constant
  1031.  
  1032.       o  _^Hr_^He_^Hm_^Ho_^Ht_^He_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He is the uucp host name of the remote system (7
  1033.          chars max, even if the actual host name is longer)
  1034.  
  1035.       o  _^Hg_^Hr_^Ha_^Hd_^He is a single letter denoting the priority of the work
  1036.          request
  1037.  
  1038.          e.g. "A" is the most important, "Z" is very unimportant, and
  1039.          "N" is somewhere in between.  Since the files are found by
  1040.          searching the spool directory, and since files are kept in
  1041.          lexical order by file name, the most important files are found
  1042.          first.
  1043.  
  1044.          Some uucps can be configured to only place outbound calls for
  1045.          certain grades of work at certain times of day; for example,
  1046.          mail is typically assigned a very high grade, and one might
  1047.          want to transfer mail almost as soon as it is queued, with file
  1048.          transfers somewhat less important, and news being relegated to
  1049.          evenings and nights.
  1050. ^L
  1051. UUCP "G" PROTOCOL                                                Page 20
  1052. UN047, Tuesday, 4-5 pm
  1053.  
  1054.  
  1055.       o  uniq is four characters (four digits in older implementations)
  1056.          which make this work file name unique, even though other work
  1057.          files for the same uucp host, with the same grade, may exist.
  1058.  
  1059.       o  Newer systems use four or six alphanumeric characters, and case
  1060.          _^Hi_^Hs significant, e.g. C.noscMabcdef is a different file from
  1061.          C.noscMabcdeF.
  1062.  
  1063.       o  Some Unix implementations use different conventions.
  1064.  
  1065.           -  HoneyDanBer uses a different subdirectory for each neighbor
  1066.              system (the subdirectory name is the neighbor system's uucp
  1067.              host name).  (see references)
  1068.  
  1069.           -  One implementation uses one subdirectory for "C." files,
  1070.              and another for all data files.
  1071.  
  1072.       o  Other systems with restrictive file names (e.g. MS-DOS) can use
  1073.          different conventions, as long as the same functions can be
  1074.          performed.  For example,
  1075.  
  1076.                  uucp/spool/C.simpactA1234
  1077.  
  1078.          might become
  1079.  
  1080.                  C:UUCP\SPOOL\C\SIMPACT\A1234
  1081.  
  1082. After starting up in master mode, the uucico program processes each work
  1083. file associated with the remote system.
  1084.  
  1085. When no work files remain, the master mode uucico offers to switch roles
  1086. (i.e. it sends an "H" message to the slave).  The slave searches for
  1087. work files containing the master's host name.  If any are found, roles
  1088. are switched, otherwise the systems agree to hang up.
  1089.  
  1090.  
  1091. 11.2  Work File Contents
  1092.  
  1093. Each work file contains one or more "S", "R", or "X" (not covered here)
  1094. commands.  These are processed (i.e. sent to the neighbor, and the
  1095. indicated file transferred) in turn.
  1096.  
  1097.  
  1098. 11.2.1  "S" (send File From Master To Slave) Commands
  1099.  
  1100. Format:
  1101.         S _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He _^Ht_^Hr_^Hg_^Ht_^Hf_^Hi_^Hl_^He _^Hu_^Hs_^He_^Hr _^Ho_^Hp_^Ht_^Hs _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He _^Hm_^Ho_^Hd_^He _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy
  1102.  
  1103.  
  1104.       o  _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He is the fully-qualified pathname of the source file
  1105.  
  1106.       o  _^Ht_^Hr_^Hg_^Ht_^Hf_^Hi_^Hl_^He is the fully-qualified pathname to which the file is
  1107.          to be copied on the target system
  1108. ^L
  1109. UUCP "G" PROTOCOL                                                Page 21
  1110. UN047, Tuesday, 4-5 pm
  1111.  
  1112.  
  1113.       o  _^Hu_^Hs_^He_^Hr is the sending user's login name
  1114.  
  1115.       o  _^Ho_^Hp_^Ht_^Hs options, preceded by "-"
  1116.  
  1117.           -  c   send directly from _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He.  If absent, send from copy
  1118.              of file in spool directory, name given by _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He, and
  1119.              delete copy after transferring; in this case _^Hs_^Hr_^Hc_^Hf_^Hi_^Hl_^He is
  1120.              informational, providing the file's original name.
  1121.           -  m   notify sender by mail when copy is completed
  1122.           -  n   notify user _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy on target system when file arrives
  1123.  
  1124.          If no options are present, a hyphen appears here as a
  1125.          placeholder.
  1126.  
  1127.       o  _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He if "c" option present, "D.0"; if "c" absent, gives the
  1128.          name of the data file in the spool directory for uucico to
  1129.          send.
  1130.  
  1131.       o  _^Hm_^Ho_^Hd_^He is the Unix-style file protection mode (in octal) to be
  1132.          given to the new file
  1133.  
  1134.       o  _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy is the name of a user on the target system; present only
  1135.          if "n" option present
  1136.  
  1137.  
  1138. 11.2.2  "R" (Receive File From Slave To Master) Commands
  1139.  
  1140. Same as "S" commands, except _^Hd_^Ha_^Ht_^Ha_^Hf_^Hi_^Hl_^He, _^Hm_^Ho_^Hd_^He, and _^Hn_^Ho_^Ht_^Hi_^Hf_^Hy fields are not
  1141. present.
  1142.  
  1143.  
  1144. 11.3  Origins Of Work Files
  1145.  
  1146. Work files are created when:
  1147.  
  1148.       o  Users issue "uucp" commands
  1149.  
  1150.          (these are explicit requests to copy files to or from uucp
  1151.          neighbors)
  1152.  
  1153.       o  Users send mail which goes out via uucp
  1154.  
  1155.          (the "mailer" places the mail in a file in a spool directory,
  1156.          and creates the necessary work file to cause it to be sent to
  1157.          the first hop in the uucp path)
  1158.  
  1159.       o  "Route-through" uucp mail arrives
  1160.  
  1161.          (this is really just the same as the preceding case -- the
  1162.          "mailer" is seen as just another user)
  1163.  
  1164.       o  News is queued for transmission to another system
  1165.  
  1166.          (as with mail, the news transfer programs place the news batch
  1167.          in a file in the spool directory, and create the necessary work
  1168.          file)
  1169. ^L
  1170. UUCP "G" PROTOCOL                                                Page 22
  1171. UN047, Tuesday, 4-5 pm
  1172.  
  1173.  
  1174. 12  EXECUTION FILES ("X." FILES)
  1175.  
  1176. The X-file mechanism is used for _^Hr_^He_^Hm_^Ho_^Ht_^He _^Hc_^Ho_^Hm_^Hm_^Ha_^Hn_^Hd _^He_^Hx_^He_^Hc_^Hu_^Ht_^Hi_^Ho_^Hn.
  1177.  
  1178.       o  Receipt of a file named X.anything in the spool directory
  1179.          triggers the "uuxqt" program
  1180.  
  1181.       o  uuxqt interprets the X-file
  1182.  
  1183.       o  Typical uses are for mail and news
  1184.  
  1185.       o  The uux command allows users to request remote execution of
  1186.          arbitrary commands (permissions permitting)
  1187.  
  1188.  
  1189. 12.1  X-File Contents
  1190.  
  1191. The X-File contains one or more lines.  The first character on each line
  1192. specifies a command type.  It is followed by a blank and one or more
  1193. parameters which are interpreted according to the command type, as
  1194. follows:
  1195.  
  1196. (From a Usenet article by Dr. Peter Honeyman)
  1197.  
  1198.         C   command to be executed
  1199.         I   file name for command input
  1200.         O   file name for command output
  1201.         F   file required to be present before running command; optional
  1202.             second argument gives name for the file at execution time
  1203.         R   name of user who issued request (relative to the host named
  1204.             on the U line)
  1205.         U   second arg is name of host that passed this X. file to me;
  1206.             first arg is a user name on that host (overridden by R line)
  1207.         Z   send status notification (and error output) if command
  1208.             failed
  1209.         N   send no status notification if command failed
  1210.         n   send status notification if command succeeded
  1211.         B   return command input on error
  1212.         e   requests command be processed with sh(1)
  1213.         E   requests command be processed with exec(2)
  1214.         M   return status info to the named file on the requesting host
  1215.         #   comment line
  1216.  
  1217. Unrecognized lines are ignored, i.e. treated as comments.
  1218.  
  1219.  
  1220. 12.2  Example:  Sending Mail.
  1221.  
  1222. User jeh on system simpact sends mail to user bblue on uucp neighbor
  1223. crash.
  1224.  
  1225.      1.  simpact's mailer creates mail text file in spool directory
  1226.          (file name D.simpactA3214)
  1227. ^L
  1228. UUCP "G" PROTOCOL                                                Page 23
  1229. UN047, Tuesday, 4-5 pm
  1230.  
  1231.  
  1232.      2.  simpact's mailer creates what will become an X-file in
  1233.          simpact's spool directory (file name B.simpactA3214)
  1234.  
  1235.          U jeh simpact
  1236.          F D.simpactA3214
  1237.          I D.simpactA3214
  1238.          C rmail bblue
  1239.  
  1240.      3.  simpact's mailer creates work file in simpact's spool directory
  1241.          (file name C.crashA0001)
  1242.  
  1243.          S D.simpactA3214 D.simpactA3214 jeh - D.simpactA3214 0666
  1244.          S B.simpactA3214 X.simpactA3214 jeh - B.simpactA3214 0666
  1245.  
  1246.      4.  simpact calls system "crash" and interprets the work file,
  1247.          transferring the "D." and "B." files (in that order).
  1248.  
  1249.          Note that when the "B." file arrives at crash, its name is
  1250.          X.simpactA3214 (see the second "S" command in the C file
  1251.          above).
  1252.  
  1253.      5.  The uuxqt program at crash interprets the X file, using the
  1254.          file D.simpactA3214 as input to the command "rmail bblue".
  1255.  
  1256. Notes:
  1257.  
  1258.       o  Some systems use a different _^Hu_^Hn_^Hi_^Hq value in the file name for
  1259.          each locally-created file (instead of relying on the first
  1260.          letter to keep them separate).
  1261.  
  1262.       o  Some systems use the "D." prefix for both the mail message text
  1263.          and for the file that will become the "X." file on the target
  1264.          system.  (In this case, the _^Hu_^Hn_^Hi_^Hq value must be different for
  1265.          these two files)
  1266.  
  1267.       o  This mechanism is designed so that, even with a single spool
  1268.          directory and uncoordinated _^Hu_^Hn_^Hi_^Hq values, all file names will be
  1269.          unique:
  1270.  
  1271.           -  Only the local system creates "B." and "C." files.
  1272.  
  1273.           -  Only the remote system creates "X." files.
  1274.  
  1275.           -  Only the local system creates files called
  1276.              "D._^Hl_^Ho_^Hc_^Ha_^Hl_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He*".
  1277.  
  1278.           -  Only the remote system creates files called
  1279.              "D._^Hr_^He_^Hm_^Ho_^Ht_^He_^Hh_^Ho_^Hs_^Ht_^Hn_^Ha_^Hm_^He*".
  1280.  
  1281.  
  1282. 13  FILE NAME TRANSLATION
  1283.  
  1284. Systems with different file name syntax need not be barred from
  1285. participating in uucp transfers, and particularly not from mail and
  1286. news.
  1287. ^L
  1288. UUCP "G" PROTOCOL                                                Page 24
  1289. UN047, Tuesday, 4-5 pm
  1290.  
  1291.  
  1292. 13.1  Receiving Mail And News
  1293.  
  1294.  
  1295.       o  Only received "D." and "X." files are of concern.
  1296.  
  1297.       o  Local uucico maps file names specified by Unix system to local
  1298.          requirements when processing received "S" commands (in slave
  1299.          mode).
  1300.  
  1301.       o  Local uuxqt performs the _^Hs_^Ha_^Hm_^He translation when handling file
  1302.          names in the "X." file.
  1303.  
  1304.  
  1305. 13.2  Sending Mail And News
  1306.  
  1307.  
  1308.       o  Names of locally-created "B.", "C.", and "D." files can adhere
  1309.          to local conventions.
  1310.  
  1311.       o  When constructing the local work file ("C." file), build
  1312.          Unix-format _^Ht_^Hr_^Hg_^Ht_^Hf_^Hi_^Hl_^He names in the "S" commands.
  1313.  
  1314.  
  1315. 14  REFERENCES AND ACKNOWLEDGEMENTS
  1316.  
  1317. 14.1  Uucp Protocols
  1318.  
  1319. (The following two papers were instrumental both in preparing this
  1320. article and in implement uucp "g" for VMS.  I believe that all of the
  1321. material in these two papers is incorporated in this article.  I could
  1322. be wrong.)
  1323.  
  1324. Chuck Wegrzyn posted a Usenet article (date unknown) that described the
  1325. Shere exchange, over-and-out exchange, and the application layer.
  1326.  
  1327. "Packet Driver Protocol" by G. L. Chesson of Bell Laboratories (October
  1328. 5, 1988), distributed via Usenet and Internet, is the standard reference
  1329. on the the "g" protocol data link layer.
  1330.  
  1331.  
  1332. 14.2  The Uucp System
  1333.  
  1334. _^HM_^Ha_^Hn_^Ha_^Hg_^Hi_^Hn_^Hg _^Hu_^Hu_^Hc_^Hp _^Ha_^Hn_^Hd _^HU_^Hs_^He_^Hn_^He_^Ht by Tim O'Reilly and Grace Todino, (O'Reilly And
  1335. Associates, Newton, MA 02164), has a good description of the Shere
  1336. exchange and of work file and execution file contents.
  1337.  
  1338. "Uucp Implementation Description" by D. A. Nowitz, part of most complete
  1339. Unix documentation sets (check the _^HS_^Hu_^Hp_^Hp_^Hl_^He_^Hm_^He_^Hn_^Ht_^Ha_^Hr_^Hy _^HD_^Ho_^Hc_^Hu_^Hm_^He_^Hn_^Ht_^Hs volumes, if
  1340. present) provides a general description of each program in the uucp
  1341. suite.
  1342.  
  1343. "HoneyDanBer UUCP -- Bringing UNIX Systems into the Information Age" by
  1344. Bill Rieken and Jim Webb, _^H;_^Hl_^Ho_^Hg_^Hi_^Hn_^H:  (journal of the Usenix Association),
  1345. Volume 11, Numbers 3 and 4 (May/June and July/August, 1986).  Describes
  1346. "external" features of one of the newest Unix uucp implementations,
  1347. including new file name conventions, logging, and error handling.
  1348. ^L
  1349. UUCP "G" PROTOCOL                                                Page 25
  1350. UN047, Tuesday, 4-5 pm
  1351.  
  1352.  
  1353. 14.3  General
  1354.  
  1355. A widely-recognized work on the subject of data communications protocols
  1356. is _^HC_^Ho_^Hm_^Hp_^Hu_^Ht_^He_^Hr _^HN_^He_^Ht_^Hw_^Ho_^Hr_^Hk_^Hs by Andrew S. Tanenbaum (Prentice-Hall).  Algorithms
  1357. are included for several different types of windowed data link
  1358. protocols.
  1359.  
  1360. _^HK_^He_^Hr_^Hm_^Hi_^Ht_^H, _^HA _^HF_^Hi_^Hl_^He _^HT_^Hr_^Ha_^Hn_^Hs_^Hf_^He_^Hr _^HP_^Hr_^Ho_^Ht_^Ho_^Hc_^Ho_^Hl by Frank da Cruz (Digital Press),
  1361. provides a very lucid description of the sliding-window extension to
  1362. Kermit.  Although windowed Kermit differs in several important ways from
  1363. uucp "g", this material was of great assistance in designing the
  1364. windowed "g" implementation for DECUS uucp and in understanding the
  1365. subtle nuances of windowed protocols.
  1366.  
  1367.  
  1368. 14.4  Critiques And Proofreading
  1369.  
  1370. The following people graciously reviewed and send comments on early
  1371. versions of this paper:
  1372.  
  1373.       o  Christopher J. Ambler, chris@fubarsys.slo.ca.us,
  1374.          cambler@polyslo.calpoly.edu
  1375.  
  1376.       o  Jordan Brown, jbrown@jato.jpl.nasa.gov
  1377.  
  1378.       o  Eric Johansson
  1379.  
  1380.       o  Nick Pemberton, Lsuc, uunet!mnetor!aimed!nick
  1381.  
  1382.       o  Mark Pizzolato, decwrl!infopiz!mark
  1383.  
  1384. (end)
  1385.  
  1386.  
  1387.