BSD 4_4 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 6 Dec 1988 07:06:20 +0000 (23:06 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Tue, 6 Dec 1988 07:06:20 +0000 (23:06 -0800)
Work on file usr/src/share/doc/iso/wisc/debug.nr
Work on file usr/src/share/doc/iso/wisc/def.nr
Work on file usr/src/share/doc/iso/wisc/eicon.nr
Work on file usr/src/share/doc/iso/wisc/errors.nr
Work on file usr/src/share/doc/iso/wisc/ipc.nr

Synthesized-from: CSRG/cd3/4.4

usr/src/share/doc/iso/wisc/debug.nr [new file with mode: 0644]
usr/src/share/doc/iso/wisc/def.nr [new file with mode: 0644]
usr/src/share/doc/iso/wisc/eicon.nr [new file with mode: 0644]
usr/src/share/doc/iso/wisc/errors.nr [new file with mode: 0644]
usr/src/share/doc/iso/wisc/ipc.nr [new file with mode: 0644]

diff --git a/usr/src/share/doc/iso/wisc/debug.nr b/usr/src/share/doc/iso/wisc/debug.nr
new file mode 100644 (file)
index 0000000..352eeee
--- /dev/null
@@ -0,0 +1,1043 @@
+.\"$Header: debug.nr,v 1.4 88/12/06 16:05:36 nhall Exp $
+.\"$Source: /usr/argo/doc/kernel/RCS/debug.nr,v $
+.\"
+.\"    Program names should be in italics
+.\"
+.NC "Debugging, Testing, and Statistics"
+.sh 1 "Introduction"
+.pp
+This section describes the methods used 
+to test and debug the ARGO kernel.
+Three facilities are used in combination: 
+debug options,
+simple statistics gathering, 
+and
+protocol event tracing.
+Many of the debug options
+simply cause information to be printed on the console, but
+several of these options cause
+TP to behave pathologically
+so that errors are be introduced in desirable ways.
+.pp
+TP and CLNP keep simple statistics.
+These statistics include such things as the total
+number of PDUs that are sent and received, 
+a count of various types of errors
+that can be encountered when parsing an incoming PDU,
+and the average and standard deviation of round trip times for 
+transport PDUs.
+These statistics are useful for debugging.
+For example,
+if an incoming CC TPDU is rejected because one of the optional
+parameters is faulty, this are noted in the statistics.
+The statistics are kept on a system-wide basis rather than
+on a per-connection basis.
+They can be printed or cleared by user-level utility programs.
+.pp
+The tracing facility allows selective tracing of events.
+Events are grouped into categories relating to different
+functions of TP.
+For example, it is possible to 
+trace only the events that pertain to acknowledgments.
+.pp
+At run time the debugging and tracing options can
+be set and cleared by privileged utility programs.
+Each of these facilities is described in more
+detail below.
+.sh 1 "Debugging"
+.pp
+Most of the debugging options
+print messages on the console.
+Kernel printing is done by busy-waiting at high priority,
+so debugging options should be used very sparingly.
+A sample of the code is:
+.(b
+.nf
+\fC
+IFDEBUG(D_TPINPUT)
+     printf("tp_input m 0x%x tpdu_len 0x%x\n", m, tpdu_len);
+ENDDEBUG
+\fR
+.fi
+.)b
+.sp 1
+.lp
+IFDEBUG and ENDDEBUG are macros that are defined in one of two ways.
+If the system is configured with the ARGO_DEBUG
+option, an array 
+\fCargo_debug[128]\fR
+is declared, and
+IFDEBUG and ENDDEBUG are defined thus:
+.(b 
+.nf
+\fC
+#define IFDEBUG(option) if(argo_debug[option]) {
+#define ENDDEBUG  ; }
+\fR
+.fi
+.)b
+.lp
+If the system is configured without the ARGO_DEBUG option, these
+two macros resolve to the C comment delimiters, \fC/*\fR and \fC*/\fR,
+causing all the debugging code lying between the macros
+to be elided.
+.pp
+TP, CLNP, and CONS debugging can be enabled independently. 
+All debugging requires that the code be compiled with the 
+option ARGO_DEBUG. 
+The \fIconfig(8)\fR option CLNP_DEBUG will include debugging printfs for CLNP. 
+TP_DEBUG has the same effect for TP.
+.pp
+The array elements of \fCargo_debug[]\fR are set by
+the utility program
+\fIbark\fR, 
+which reads and writes
+\fC/dev/kmem\fIN\fR.
+See the manual page \fIbark(8)\fR.
+.pp
+Several debugging options cause TP to behave pathologically,
+for the purpose of reproducing difficult-to-reproduce
+error conditions that the protocol must correct.
+For example, the 
+\fID_DROP\fR, or \fIbark -on T.drop\fR
+option causes 
+\fItp_input()\fR
+to discard TPDUs on a pseudo-random basis.
+These will be described below.
+.sh 1 "Statistics"
+.pp
+.sh 2 "CLNP Statistics"
+.pp
+CLNP keeps a set of statistics related to its operation. 
+Statistics include such things as NPDUs sent, received, and dropped. 
+These statistics are stored in the global structure \fIclnp_stat\fR.
+The utility program \fInetstat(8)\fR may be used to print these statistics.
+.sh 2 "TP Statistics"
+.pp
+TP keeps a set of running counts of certain events.
+The statistics include such things as the numbers 
+of each type of TPDU sent and received, TPDUs dropped,
+and the numbers of occurrences of certain types of errors.
+The statistics are stored in the global structure \fItp_stat\fR.
+The utility programs 
+\fItpstat\fR and
+\fItpmon\fR
+read \fC/dev/kmem\fIN\fR
+and prints the contents of the statistics structure
+in a human-readable form.
+\fITpstat\fR prints the statistics on any ascii screen or printer.
+\fITpmon\fR uses the \fIcurses\fR library and assumes that is has
+a screen or window of size 53(long) X 80(wide), and it updates the
+screen every 30 seconds.
+.pp
+\fITpstat\fR and \fItpmon\fR can be used to clear the statistics (set them
+all to zero); the \fB-c\fR option causes the statistics to be cleared.
+.pp
+Statistics are observed using \fItpstat(8)\fR
+to clear statistics before a test, and to print
+the statistics after the test.
+See the manual pages \fItpstat(8)\fR and \fItpmon(8)\fR.
+.sh 1 "Tracing"
+.pp
+.sh 2 "CLNP Tracing"
+.pp
+CLNP does not support event tracing.
+.sh 2 "TP Tracing" 
+.pp
+The tracing facility consists of a circular buffer (an array)
+of structures that are written by the kernel at various times, 
+and a utility program that reads \fC/dev/kmem\fIN\fR
+to interpret the contents of the buffer.
+The trace structure is a union of the structures that
+will be interpreted by the utility program.
+A trace event consists of a call to the trace routine \fItpTrace\fR
+with a set of arguments containing the information relevant to the
+event being traced.
+The procedure tpTrace is actually called through a macro \fItptrace\fR.
+For example,
+.(b
+.nf
+\fC
+IFTRACE(D_INPUT)
+     tptrace(TPPTtpduin, h->tpdu_type, h, h->tpdu_li+1, 0, 0);
+ENDTRACE
+\fR
+.fi
+.)b
+.pp
+The tracing macros are defined in the same manner as the 
+debugging macros:
+.(b
+.nf
+\fC
+#define IFTRACE(option) if(tp_traceflags[option]) {
+#define ENDTRACE  }
+\fR
+.fi
+.)b
+.lp
+If the kernel is configured with the option TPPT, these macros
+are defined as shown above, but if the TPPT option is not
+used, these macros become C-style comment delimiters.
+.pp
+The tracing procedure copies \fIh->tpdu_li + 1\fR bytes beginning at
+location \fIh\fR into a trace structure in the circular buffer.
+The utility program \fItppt\fR
+reads the trace structure, 
+interprets the data as a TPDU header,  
+and prints the header in hexadecimal form, with a banner identifying
+the event as an incoming TPDU:
+.(b
+.nf
+\fC
+1a: Ref 22     arg 14(0xe),    @ 91990 : 0000.453125   tpdu
+INPUT  total len 22
+HDRLEN:  21+1  CR_TPDU_type    cdt 0(0x0)      dref 0x0
+                + 0: 0x15 0xe0 0x00 0x00   4: 0x00 0x03 0x00 0xc1 
+                + 8: 0x06 0x74 0x70 0x70  12: 0x69 0x6e 0x67 0xc2 
+                +16: 0x02 0x00 0x07 0xc0  20: 0x01 0x08 0x00 0x00 
+
+\fR
+.fi
+.)b
+.pp
+In addition to the data copied from the arguments to tpTrace(), 
+each trace structure contains
+a time stamp and an event sequence number, and in many cases, the
+connection reference to which the traced event applies.
+The utility program \fItppt\fR is be used to turn on and off the
+tracing options.
+.pp
+This facility can be used for debugging the source
+code as well as for studying the behavior of the protocol.
+For example, by adding the appropriate trace events,
+it is possible to "see" the resequencing function of TP
+working when a debug option is used to cause
+TPDUs to be dropped occasionally.
+.pp
+See the manual page \fItppt(8)\fR. 
+.sh 1 "Testing"
+.pp
+.sh 2 "CLNP Testing"
+.pp
+CLNP was tested in two rather different ways. 
+The first method of testing used the
+raw CLNP interface with the program \fIclnptest\fR.
+\fIclnptest\fR allows a user to send or receive CLNP NSDUs. 
+With \fIclnptest\fR, a user can send CLNP NSDUs with various
+combinations of options and observe the result.
+.pp
+The second method of testing CLNP was to have TP use CLNP as its network
+layer protocol. 
+This method provides a good stress test for CLNP. 
+Unfortunately, TP generally calls CLNP in the same manner, so that not all
+of the CLNP options are exercised.
+.sh 3 "Clnptest"
+.pp
+The program \fIclnptest\fR can be invoked as either 
+a reader or as a writer:
+.(b
+\fC
+clnptest <options>
+\fR
+.)b
+The \fI-r\fR option invokes \fIclnptest\fR as a reader, the
+\fI-w\fR option invokes it as a writer. 
+Other options allow the user to indicate the destination, number of NSDUs, 
+size of NSDUs,
+and NSDUs options. 
+See \fIclnptest(8)\fR for more information.
+.pp
+\fIclnptest\fR is normally used in the following manner. 
+On one machine, invoke \fIclnptest\fR as a reader:
+.(b
+\fC
+clnptest -r
+\fR
+.)b
+On a different machine, transmit an NSDU.
+For example, to test the source route function, one invokes:
+.(b
+\fC
+clnptest -w -h a -oR "b, c, d"
+\fR
+.)b
+This sends an NSDU to host 'a', source routing it via
+hosts 'b', 'c', and 'd'.
+.sh 3 "The Troll"
+In order to test CLNP reassembly certain errors must be generated. 
+The mechanism used has two parts, 
+the user program \fIclnptroll\fR, which enables and disables
+the generation of these errors, and the 
+kernel resident error-creation routines.
+.pp
+Troll options allow one to duplicate an NSDU with a specified frequency. 
+The kernel must be compiled with the \fIconfig\fR option \fITROLL\fR
+in order to include troll code.
+See \fIclnptroll(8)\fR for more information.
+.sh 3 "Debugging CLNP"
+.pp
+The following sections describe the \fIbark\fR options 
+appropriate for testing parts of CLNP. 
+Refer to \fIbark(8)\fR for more information about debugging
+using \fIbark\fR..
+.sh 4 "Sending NSDUs"
+.pp
+Turning on the \fIbark\fR
+option \fIC.output\fR causes information to be
+printed whenever an NSDU is transmitted. 
+Translation of NSAP addresses to SNPA can be monitored by turning on 
+the \fIC.un\fR, or \fIC.lan\fR options. 
+Parts of outgoing NSDUs can be dumped when the \fIC.dumpout\fR
+option is on.
+Routing activity can be watched by turning on \fIC.route\fR and \fIC.iso\fR.
+Information about CLNP option processing is available with \fIC.options\fR.
+.sh 4 "Forwarding NSDUs"
+.pp
+The \fIforward\fR switch will cause debugging information to be displayed
+whenever NSDUs are forwarded.
+.sh 4 "Receiving NSDUs"
+.pp
+Information is displayed about incoming NSDUs when the \fIC.input\fR
+option is enabled. 
+A portion of incoming NSDUs can be dumped by turning on the 
+\fIC.dumpin\fR option.
+.sh 4 "Fragmentation and Reassembly"
+.pp
+The options \fIC.frag\fR and \fIC.reass\fR turn on debugging for the 
+CLNP fragmentation and reassembly functions.
+.sh 2 "TP Testing"
+.pp
+Five services were used for most of the testing:
+the \fIdiscard\fR service,
+the \fIecho\fR service, 
+the \fIremote login\fR service, 
+the \fIremote shell\fR service, 
+and
+the \fIsimple file transfer\fR service.\**
+.(f
+\** In fact, ancestors of these services were used for testing the
+ARGO transport implementation during development.
+These programs in their original forms were very cumbersome to use;
+consequently they evolved to become the services described here.
+.)f
+Each service consists of a daemon process or server that listens
+on a well-known transport selector (which is listed in the 
+ARGO directory service), and an active process that contacts the
+server.
+Four of these services,  
+discard, echo, remote login, and remote shell,
+are supported by the
+\fIisod\fR suite of daemons, which is a
+version of the \fIinetd\fR programs that uses
+the ISO protocol suite.
+.sh 3 "The Discard Service"
+The discard server listens on the transport selector
+registered in the ARGO directory service for the application
+"discard".
+The server accepts incoming connection requests, 
+receives TSDUs, and throws away the TSDUs.
+It never initiates a disconnect, but expects its peer
+to disconnect the transport connection.
+.PP
+The program \fItpdiscard\fR connects to the
+discard server.
+The transport service and protocol options it uses are those
+indicated in the ARGO directory service.
+By changing the directory service entry for the 
+discard service, each of the transport service options and
+protocol options can be demonstrated.
+See the manual pages
+\fItpdiscard(8)\fR,
+\fItp(4p)\fR,
+and 
+\fIisodir(5)\fR
+for more information.
+.sh 3 "The Echo Service"
+The echo server listens on the transport selector
+registered in the ARGO directory service for the application
+"echo".
+The server accepts incoming connection requests, 
+receives TSDUs, and returns the TSDUs to the sender.
+It never initiates a disconnect, but expects its peer
+to disconnect the transport connection.
+.pp
+The 
+program \fItpping\fR connects to the
+echo server.
+The transport service and protocol options it uses are those
+indicated in the ARGO directory service.
+By changing the directory service entry for the 
+echo service, each of the transport service options and
+protocol options can be demonstrated.
+See the manual pages
+\fItpping(8)\fR,
+\fItp(4p)\fR,
+and 
+\fIisodir(5)\fR
+for more information.
+.sh 3 "The Remote Login Service"
+The remote login server listens on the transport selector
+registered in the ARGO directory service for the application
+"login".
+The server accepts incoming connection requests,
+implements the BSD remote login protocol, checks permissions using
+the \fC~/.rhosts\fR, and \fC/etc/passwd\fR files, and
+uses the ARGO directory service to discover name-to-NSAP-address
+mappings.
+If the remote user is authorized to log in to the end system on which
+the server runs, a login is started.
+.pp
+The program \fIrlogin.iso\fR connects to the remote login server.
+The transport service and protocol options it uses are those
+indicated in the ARGO directory service.
+By changing the directory service entry for the 
+login service, each of the transport service options and
+protocol options can be demonstrated.
+See the manual pages
+\fIrlogin.iso(8)\fR,
+\fItp(4p)\fR,
+and 
+\fIisodir(5)\fR
+for more information.
+.sh 3 "The Remote Shell Service"
+The remote shell server listens on the transport selector
+registered in the ARGO directory service for the application
+"shell".
+The server accepts incoming connection requests,
+implements the BSD remote command authorization protocol, 
+checks permissions using
+the \fC~/.rhosts\fR, and \fC/etc/passwd\fR files, and
+uses the ARGO directory service to discover name-to-NSAP-address
+mappings.
+If the remote user is authorized to execute a shell on
+the end system on which
+the server runs, a shell is started.
+.pp
+The program \fIrcp.iso\fR connects to the remote shell server to 
+effect a remote copy.
+The transport service and protocol options it uses are those
+indicated in the ARGO directory service.
+By changing the directory service entry for the 
+shell service, each of the transport service options and
+protocol options can be demonstrated.
+See the manual pages
+\fIrcp.iso(8)\fR,
+\fItp(4p)\fR,
+and 
+\fIisodir(5)\fR
+for more information.
+.sh 3 "The Simple File Transfer Service"
+.pp
+The last service consists of a pair of programs,
+\fItpfileget\fR and
+\fItpfileput\fR,
+which cooperate to transfer one file.
+The passive program, \fItpfileget\fR,
+listens on the transport selector registered in the ARGO directory service
+to support the application named "tptestsel".
+The sending program, \fItpfileput\fR, 
+connects to the passive program, transfers in one TSDU
+the file named on the \fItpfileput\fR command line, and waits for the
+passive end to close the connection.
+\fITpfileget\fR 
+opens a file of the name given on its command line,
+accepts one connection request, receives 
+one TSDU, writes the contents of that TSDU to the opened file,
+and when it receives the end-of-TSDU indication,
+\fItpfileget\fR closes the transport connection.
+The transport service options and protocol options used by
+\fItpfileput\fR are determined by the ARGO directory service
+record that describes the applicaition "tptestsel".
+See the manual pages
+\fItpfileget(8)\fR,
+\fItp(4p)\fR,
+and 
+\fIisodir(5)\fR
+for more information.
+.sh 3 "Internal TP Testing"
+.pp
+The methods used to test each of the various functions
+of TP are described in this section.
+One or more of the services described above were used, while
+the TP activity was observed with tracing or debugging or both.
+The statistics were cleared before each test and inspected
+after each test.
+Each test can be run with different protocol and service options,
+by changing the transport parameters in records
+in the ARGO directory service file.
+See the manual pages
+\fItpstat(8)\fR,
+\fItpmon(8)\fR,
+\fItppt(8)\fR,
+\fIbark(8)\fR,
+\fItp(4p)\fR,
+and 
+\fIisodir(5)\fR
+for more information.
+.sh 4 "Normal and Expedited Data Transfer:"
+.pp
+TSDUs are 
+distinguished by the presence or absence of the
+EOTSDU bit in the \fIflags\fR parameter of the
+\fIsendv()\fR system call.
+The data of a TSDU are copied into chains of \fImbufs\fR
+in the kernel so that the end of a TSDU lies in an mbuf
+with the \fIm_act\fR field non-zero.
+The end of a TSDU never lies in the middle of an
+mbuf.
+This is true on the receiving side as well.
+On output, the segmenting function,
+the function that copies user data into mbuf chains
+reorganizes mbuf chains into TPDUs,
+is observed using several debug options
+and trace options
+in the routines \fIsosend()\fR 
+and \fItp_sbsend()\fR.
+On input, the reassembling mechanism
+is observed in the routine \fItp_stash()\fR.
+The debug options 
+\fBT.ndata\fR, 
+\fBT.sb\fR, and 
+\fBT.xpd\fR
+print information 
+pertinent to this function.
+.pp
+Expedited data complicates the matter of segmenting
+because markers must be kept in the chains of outgoing
+TPDUs to indicate the precedence of expedited data TPDUs
+over normal data TPDUs.
+The pertinent trace options are \fBT.sb\fR and \fBT.ndata\fR.
+With the trace and (or) debugging options on,
+and with \fItpdiscard\fR running, one can observe the segmentation
+and reassembly of TPDUs.
+.pp
+Using the file transfer programs to transfer a file,
+then transferring it back with \fIrcp\fR (the TCP version) if necessary, and
+using
+\fIdiff\fR, one can see that data are transferred correctly.
+The \fBT.input\fR trace option creates a readable hexadecimal dump of incoming TPDUs.
+The 
+\fBT.emit\fR
+trace option creates the same sort of dump for outgoing
+TPDUs in \fItp_emit()\fR.
+Sequencing
+can be observed by using the 
+\fBT.ndata\fR
+and 
+\fBT.input\fR
+or 
+\fBT.emit\fR
+trace options
+to see the sequence numbers assigned to TPDUs.
+.pp
+The
+\fBT.drop\fR
+debug option causes \fItp_input()\fR
+to throw away occasional TPDUs.
+(The formula for determining when to discard a TPDU
+is ad hoc and simplistic.  It causes TPDUs to be
+discarded frequently but not so frequently that the 
+receiving side has no chance to recover.)
+With tracing on and the file transfer programs running,
+resequencing can be observed
+and the correctness of the transferred data
+can be verified with \fIdiff(1)\fR.
+.pp
+The use of both normal and extended formats
+can be observed with the \fBT.input\fR and \fBT.emit\fR trace options.
+.pp
+The following statistics are of interest:
+.(b
+.nf
+\fIn\fR connections used extended format
+\fIn\fR connections allowed transport expedited data
+\fIn\fR connections turned off checksumming
+\fIn\fR connections dropped due to retrans limit
+\fIn\fR EOT bits on incoming TPDUs
+\fIn\fR EOT bits on outgoing TPDUs
+\fIn\fR XPD marks discarded
+\fIn\fR XPD stopped data flow \fIm\fR times
+\fIn\fR DTs out of order
+\fIn\fR DTs not in window 
+\fIn\fR duplicate DTs
+\fIn\fR XPDs not in window
+\fIn\fR XPDs w/o credit to stash
+\fIn\fR DT (sent)
+\fIn\fR DT (received)
+\fIn\fR DT (retransmitted)
+\fIn\fR XPD (sent)
+\fIn\fR XPD (received)
+\fIn\fR random DTs dropped
+.fi
+.)b
+.sh 4 "Checksumming, use and non-use:"
+.pp
+The checksum generation and checking
+routines were first written and debugged as user-level
+routines before they were modified for kernel use.
+The kernel routines may be observed with the 
+\fBT.chksum\fR
+debug option.
+Various sizes of mbufs can be created by creative use of the
+ARGO directory service, particularly by changing the value of the
+attribute \fItp.tpdusize\fR.
+There is no trace option for checksumming.
+Checksumming has been used with transfers to and from at least
+one other TP implementation.
+.pp
+The statistics that are pertinent to checksumming are:
+.(b
+.nf
+\fIn\fR connections turned off checksumming
+\fIn\fR invalid checksums
+.fi
+.)b
+.sh 4 "Acknowledgment:"
+.pp
+Acknowledgment can be observed by using the 
+debug and trace options
+\fBT.aks\fR,
+\fBT.akr\fR,
+\fBT.input\fR,
+\fBT.emit\fR,
+and
+\fBT.driver\fR.
+The transport driver (finite state machine) and the routine 
+\fItp_goodack()\fR dump information appropriate to acknowledgments.
+If the \fBT.ndata\fR, and \fBT.emit\fR or \fBT.input\fR trace options are used 
+along with the \fBT.aks\fR and \fBT.akr\fR trace options,
+a complete picture of the data transfer and acknowledgment
+activity can be created.
+The acknowledgments for expedited data are traced with
+the 
+\fBT.xpd\fR
+trace option.
+The routine \fItp_goodXack()\fR and the finite state
+machine dump information when the
+\fBT.xpd\fR
+debug and trace options are used.
+To cause expedited data to be generated,
+the -e or -E option on the discard programs or the file
+transfer programs are used.
+To observe the different acknowledgment strategies,
+the protocol options were changed in the ARGO directory service.
+.pp
+The pertinent statistics are:
+.(b
+.nf
+\fIn\fR AK (received)
+\fIn\fR AK (sent)
+ACK reasons:
+\fIn\fR not acked immediately
+\fIn\fR strategy==each
+\fIn\fR strategy==fullwindow
+\fIn\fR duplicate DT
+\fIn\fR EOTSDU
+\fIn\fR reordered
+\fIn\fR user rcvd
+\fIn\fR fcc reqd
+.fi
+.)b
+.pp
+The smoothed average round trip time is kept
+for outgoing TPDUs for each transport connection 
+and for the entire TP entity.
+The time each TPDU is transmitted is recorded, and when an acknowledgment
+arrives, the round trip time is computed for the lowest
+sequence number that this AK TPDU acknowledges.
+The computation of round trip times can be observed
+in a trace with the
+\fBT.rtt\fR
+option.
+.pp
+In addition to average round trip times, the kernel
+maintains the standard deviation of the round trip times.
+This statistic is kept for each connection and for the entire
+TP entity.
+In fact, four such sets of statistics are kept for the TP entity:
+.np
+for traffic not on a public data network (PDN) and on the same network as this end system,
+.np
+for traffic not on a public data network (PDN) and on not the same network as this end system,
+.np
+for traffic on a public data network (PDN) and on the same network as this end system,
+and
+.np
+for traffic on a public data network (PDN) and not on the same network as this end system.
+The determination of whether traffic is on the same network as this end system
+is based on the "network portion" of the peer's NSAP-address.
+For more information about this, see the section of this document titled
+\fB"Network Layer Routing"\fR.
+.pp
+The smoothed average round trip time statistics for a given
+can be observed with the -t option to
+\fItpstat(8)\fR.
+The global round trip statistics can be observed with  the -s option to
+\fItpmon(8)\fR.
+.sh 4 "Flow Control:"
+.pp
+Flow control activity is the transfer of credit information
+from end to end and the proper use of that information.
+To see that it works properly, one must observe three
+things:
+the receiving window must shut down and reopen, 
+the sender must transmit enough TPDUs to fill the receiver's window 
+but no more, and the receiver must renege previously advertised credit.
+These three behaviors have been observed as follows.
+.pp
+Tracing with the 
+\fBT.ndata\fR, 
+\fBT.aks, \fR
+\fBT.akr, \fR
+\fBT.emit\fR 
+and 
+\fBT.input\fR 
+trace options
+are used.
+The program \fItpdiscard\fR or a simple file transfer
+is run with various window
+and maximum TPDU sizes, various acknoledgment strategies, and
+various retransmission strategies,
+and the activity is observed with the trace.
+The debug option
+\fBT.reneg\fR
+must be used to fake a reneging of credit, since
+the ARGO transport entity does not renege its advertised credit
+under normal operation.
+At the beginning of a connection a closed window may almost always
+be observed.
+The receiving user process may be stopped 
+to force a window to shut down.
+The interesting statistics are
+.(b
+.nf
+\fIn\fR times local cdt reneged (receiving)
+\fIn\fR foreign window closed (sending)
+\fIn\fR faked reneging of cdt
+\fIn\fR DT TPDUs (sent)
+\fIn\fR DT TPDUs (received)
+\fIn\fR AK TPDUs (sent)
+\fIn\fR AK TPDUs (received)
+ACK reasons:
+\fIn\fR not acked immediately
+\fIn\fR strategy==each
+\fIn\fR strategy==fullwindow
+\fIn\fR duplicate DT
+\fIn\fR EOTSDU
+\fIn\fR reordered
+\fIn\fR user rcvd
+\fIn\fR fcc reqd
+.fi
+.)b
+.sh 4 "Retransmission and retention until acknowledgment:"
+.pp
+To observe that the sender retains TPDUs until they are
+acknowledged, one needs only to use the
+\fBT.drop\fR
+debug option to cause TPDUs to be dropped by the receiving side.
+They are then retransmitted by the sender
+and finally dropped when the acknowledgment arrives.
+That the buffers used to hold retained TPDUs are freed 
+can be observed by 
+running \fInetstat(8)\fR with the -m option
+on a quiescent system to observe the number of mbufs in use,
+then
+running a test with the 
+\fBT.drop\fR debug option on to cause retransmission,
+and 
+finally
+running netstat -m again after the test is over,
+to see that all the mbufs have been freed by TP.
+The actual retransmission activity can be observed in a trace
+with the
+\fBT.ndata, \fR
+\fBT.emit\fR and 
+\fBT.input\fR trace options.
+The retransmission strategy to be used is controlled by the
+ARGO directory service.
+The statistics
+.(b
+.nf
+\fIn\fR DT (retransmissions)
+\fIn\fR XPD (retransmissions)
+\fIn\fR CR (retransmissions)
+\fIn\fR CC (retransmissions)
+\fIn\fR DR (retransmissions)
+.fi
+.)b
+.lp
+indicate the number of retransmissions that actually occurred.
+.sh 4 "Timers:"
+.pp
+The debug and trace option
+\fBT.timer\fR
+dumps information about the timers as they are set,
+as they are cancelled, and as they expire.
+The statistics
+.(b
+.nf
+\fIn\fR ticks 
+\fIn\fR timers set 
+\fIn\fR timers expired 
+\fIn\fR timers cancelled
+\fIn\fR inactive timers cancelled
+\fIn\fR connections dropped due to retrans limit
+\fIn\fR CCs sent to zero dref
+.fi
+.)b
+.lp
+are printed for both the E-type timers and for the C-type timers.
+The effect of timers can be seen by observing retransmissions.
+Two simple ways to force retransmissions are:
+.np
+to use the \fBT.zdref\fR debug option,
+which causes CCs to contain a zero destination reference,
+so that connection establishment will time out, and
+.np
+to attempt to open a connection to a transport selector on which
+no process is listening.
+Either of these actions, along with the 
+\fBT.connect\fR
+trace or debug option will permit
+observation of the timeout facilities.
+.sh 4 "TPDU creation and parsing:"
+.pp
+TPDUs are created for output in 
+\fItp_emit()\fR.
+The 
+\fBT.emit\fR
+trace
+option dumps TPDUs as they are transmitted.
+\fITp_input()\fR parses TPDUs on input.
+The 
+\fBT.input\fR
+trace
+option dumps TPDUs as they are received.
+The debug options \fBT.emit\fR and \fBT.input\fR dump a lot of excess information
+to the console, and are used primarily for debugging
+extremely pathological behavior.
+.pp
+By tracing the execution of 
+\fItpdiscard\fR or a simple file transfer,
+with a variety protocol and service options,
+using the 
+\fBT.connect,\fR
+\fBT.emit,\fR
+\fBT.input,\fR
+\fBT.ndata,\fR
+\fBT.aks,\fR
+\fBT.akr,\fR
+and 
+\fBT.xpd\fR
+options,
+one can verify the correct placement of TPDU options
+on all types of TPDUs.
+The interesting statistics are
+.(b
+.nf
+\fIn\fR variable parameters ignored 
+\fIn\fR invalid parameter codes
+\fIn\fR invalid parameter values
+\fIn\fR invalid dutypes
+\fIn\fR invalid negotiation failures
+\fIn\fR invalid destinagion referencess
+\fIn\fR invalid suffix parameters
+\fIn\fR invalid checksums
+\fIn\fR connections used extended format
+\fIn\fR connections allowed transport XPD
+\fIn\fR connections turned off checksumming
+\fIn\fR TP 4 connections 
+\fIn\fR TP 0 connections 
+.fi
+.)b
+.sh 4 "Separation and concatenation:"
+.pp
+Concatenation is not supported by this implementation.
+Separation is supported, however, and to test separation,
+some sort of concatenated TPDUs had to be created.
+The code for this is no longer supported.
+After testing locally with some temporary code to create concatenated
+TPDUs,
+the ARGO transport implementation was tested with another transport
+implementation that does generate concatenated TPDUs.
+The interesting statistics are:
+.(b
+.nf
+\fIn\fR concatenated TPDUs
+\fIn\fR TPDUs input
+.fi
+.)b
+.sh 4 "Length limits for TPDUs:"
+.pp
+Some TPDUs may take user data:
+the CR, CC, DR, DT, and XPD.
+All of these but the DT TPDU have limits to the amount
+of data they may carry.
+The limits are enforced for CR, CC, and DR TPDUs by
+\fItp_ctloutput()\fR,
+the routine that accepts data from the user.
+The limit for XPD TPDUs is enforced by
+\fItp_usrreq()\fR, which accepts expedited
+data from the user.
+To test the effectiveness of the checks on output, one may attempt
+to send expedited data with amounts larger than the limit (16 bytes).
+.pp
+On input the limits are checked in
+\fItp_input()\fR.
+To test the effectiveness of the checks on input, it was necessary
+to create an illegally large TPDU.
+The
+\fBT.badsize\fR
+debug option
+does this - it will turn a legitimate
+XPD TPDU into a XPD TPDU with 18 bytes
+of expedited data.
+The interesting statistics are:
+.(b
+.nf
+\fIn\fR illegally large XPD TPDU
+\fIn\fR invalid length
+.fi
+.)b
+.sh 4 "Frozen References:"
+.pp
+The key issue here is to see that references are not reassigned
+until the reference timer expires.
+This can be observed by watching the timer activity as described
+above and by observing the reference numbers chosen for sockets
+with the \fBT.emit\fR
+or \fBT.input\fR trace options, which trace the TPDU headers.
+.sh 4 "Inactivity Control:"
+.pp
+Inactivity control can be observed by turning on the trace options
+\fBT.aks\fR, \fBT.akr\fR and \fBT.emit\fR
+during a simple file transfer.
+In the middle of the transfer, if the sender process
+is stopped, both TP entities continue
+to send acknowledgments. 
+This can be observed in the trace.
+If the file tranfer is between machines, taking down one of the machines
+will cause the inactivity timer on the other machine to expire.
+The TP entity will respond to this by sending a DR TPDU
+to close the connection, which can be observed in the trace.
+The expiration of the timer can be observed in a trace if the
+\fBT.driver\fR option is used.
+This option traces all events and state changes in the 
+TP
+finite state machine.
+.sh 4 "Connection establishment:"
+.pp
+The process of connection establishment can be observed with the
+\fBT.connect\fR
+trace and debug options, and
+the 
+\fBT.driver \fR
+trace option.
+Various states of the connection establishment state machine
+may be observed with the
+the debug option
+\fBT.zdref\fR.
+This option
+causes \fItp_input()\fR
+to change the foreign reference on an incoming CC TPDU to zero,
+eventually causing the CC TPDU to be dropped,
+retransmissions of the CC to occur,
+and the connection to time out before being established.
+The statistics of interest are:
+.(b
+.nf
+\fIn\fR CCs sent to zero dref
+\fIn\fR invalid dest refs
+\fIn\fR CC (received)
+\fIn\fR CC (sent)
+\fIn\fR CC (retransmitted)
+\fIn\fR (connections) timed out on retrans
+.fi
+.)b
+.sh 4 "Disconnection:"
+.pp
+Various states of the connection breakdown part of the state machine
+may be observed with the
+the trace options
+\fBT.input\fR
+or
+\fBT.emit\fR, 
+\fBT.driver\fR
+and
+running the
+discard or file transfer programs.
+.sh 4 "Association of TPDUs with Transport Connection:"
+.pp
+The problem of locating a transport connection
+given a TPDU is handled in 
+\fItp_input()\fR in one of two ways.
+For an incoming CR TPDU, the transport suffix
+is used to locate a transport protocol
+control block (PCB), to which a transport
+connection is made by creating a new socket and PCB.
+For all other TPDU types, the destination reference is used
+to locate the appropriate transport connection.
+This is done by scanning the list of reference blocks.
+Debug and trace options
+were used to debug these sections of code but have since been
+removed due to their effect on the readability 
+and maintainability of this code.
+The trace options
+\fBT.connect\fR
+and
+\fBT.newsock\fR
+creates trace records that contain the address of the
+socket as well as that of the PCB
+when a socket is opened.
+When a TPDU arrives for a given socket,
+the trace records created by the
+\fBT.input \fR
+option will also contain the address of the PCB that is found
+in 
+\fItp_input()\fR.
+These two addresses can be compared in the trace output to observe
+that the proper association is made.
+.sh 4 "Protocol Errors and the ER TPDU:"
+.pp
+Certain types of errors are intended to evoke the response
+from the TP entity of sending an ER or a DR TPDU.
+The routine
+\fItp_error_emit()\fR
+creates ER and DR TPDUs for this purpose.
+The debug and trace option
+\fBT.erroremit\fR
+dumps information about the activity of this routine.
+Since ER TPDUs are not generated under normal circumstances,
+the parsing of ER TPDUs was tested in this
+implementation by code that generated (illegitimate) ER TPDUs,
+This code was removed because it significantly complicated code maintenance.
+.sh 4 "User Interface:"
+.pp
+The debug and trace options
+\fBT.request\fR, 
+\fBT.params,\fR
+\fBT.indication\fR 
+and
+\fBT.syscall\fR and
+dump information about the user interface.
+Most of the debugging code added to the socket-layer
+routines for debugging has since been removed so that
+the source (which is functionally unchanged from the 4.3 release)
+would not unnecessarily be changed.
+\fIRlogin.iso\fR, the TP version of remote login,
+exercises some of the original BSD data transfer system calls 
+(\fIread()\fR and \fIwrite()\fR)
+rather than \fIsendv()\fR and \fIrecv()\fR.
+The interesting statistics are
+.(b
+.nf
+\fIn\fR EOT indications
+\fIn\fR user rcvd
+\fIn\fR connections used extended format
+\fIn\fR connections allowed transport XPD
+\fIn\fR connections turned off checksumming
+\fIn\fR TP 4 connections 
+\fIn\fR TP 0 connections 
+.fi
+.)b
diff --git a/usr/src/share/doc/iso/wisc/def.nr b/usr/src/share/doc/iso/wisc/def.nr
new file mode 100644 (file)
index 0000000..1e691bf
--- /dev/null
@@ -0,0 +1,144 @@
+.NC "Definitions"
+.sh 1 "General Terms"
+.ip "Kernel" 5
+The source code or binary module for the Acis Operating System 
+(also know as AOS and IBM/4.3).
+.ip "User process" 5
+An instance of a program that is 
+running in unprivileged mode, in the unprivileged address space 
+commonly know as "user address space", in other words, not
+part of the kernel.
+.ip "IPC" 5
+Interprocess communication, the mechanism by which two different
+user processes send messages to each other.
+.ip "Unix, AOS" 5
+ACIS Operating System, the IBM ACIS port of Berkeley Unix 4.3BSD.
+.ip "PCB, pcb" 5
+Protocol control block.  Each instance of a protocol machine
+keeps status information, addresses, and in some cases queues
+in a pcb for each connection or socket.
+.ip "Domain" 5
+In the Berkeley Unix environment, a domain is an abstract entity which
+comprises a network architecture, addressing scheme, address format, 
+network protocols, and transport protocols.
+.sh 1 "Transport Layer Terms"
+.ip "ISO 8073"
+ISO Draft International Standard 8073, Transport Protocol Specification
+.ip "TP" 5 
+The collection of transport
+classes that have been implemented in ARGO, classes 0 and 4.
+Also means the ARGO implementation of TP. 
+.ip "TP 0" 5 
+Transport class 0.
+.ip "TP 4" 5 
+Transport class 4.
+.ip "Transport entity" 5
+Software or hardware that implements the elements of procedure
+described in ISO 8073.
+.ip "Transport user" 5
+User process that make use of the services
+provided by a transport entity.
+.ip "Transport service interface" 5
+The syntax and semantics of the set of procedures, functions, and system calls
+that are invoked by a transport user, 
+through which the services of the transport entity are delivered.
+.ip "TPDU" 5
+Transport protocol data unit, a packet that is
+passed from one transport entity to another.
+.ip "TSDU" 5
+Transport service data unit, the logical unit of data that is
+passed from a transport entity to a transport user, or from
+a transport user to a transport entity.
+.ip "CR TPDU" 5
+Connection request TPDU. 
+.ip "CC TPDU" 5
+Connection confirm TPDU.
+.ip "DR TPDU" 5
+Disconnect request TPDU.
+.ip "DC TPDU" 5
+Disconnect confirm TPDU.
+.ip "DT TPDU" 5
+Normal data TPDU.
+.ip "XPD TPDU" 5
+Expedited data TPDU.
+.ip "AK TPDU" 5
+Normal data acknowledgment TPDU.
+.ip "XAK TPDU" 5
+Expedited data acknowledgment TPDU.
+.ip "ER TPDU" 5
+Error TPDU.
+.sh 1 "Network Layer Terms"
+.ip "ISO 8473"
+ISO Draft International Standard 8473, connectionless network protocol.
+.ip "CONS"
+Connection Oriented Network Service.
+.ip "COSNS"
+Connection Oriented Sub-Network Service.
+.ip "CLNS"
+Connectionless Network Service.
+.ip "CLNP"
+Connectionless Network Protocol, or ISO 8473.
+.ip "Network Entity"
+Software or hardware that implements the elements of procedure described
+in ISO 8473.
+.ip "Network Service User"
+Software components that make use of the services provided by a network
+entity.
+.ip "Network Service Provider"
+Software components that provide the services of a network entity.
+.ip "NSAP"
+Network Service Access Point. The point at which the OSI network service
+is made available to the network service user by the network service
+provider.
+.ip "NSAP address"
+Information that the network service provider needs to identify an
+NSAP. The source and destination address fields of a CLNP packet
+are NSAP addresses.
+.ip "ES"
+End system. A system running the complete suite of OSI protocols which can
+act as an end point for communication.
+.ip "IS"
+Intermediate system. A system running the OSI layers 1, 2, and 3 which
+can act only a packet router.
+.ip "SNPA"
+The Subnetwork Point of Attachement is the point where a \fIreal\fR 
+end or intermediate system is attached to a \fIreal\fR subnetwork.
+.ip "SNPA address"
+Information that a \fIreal\fR subnetwork need to identify a \fIreal\fR end 
+or intermediate system. This is commonly referred to as the hardware address.
+.ip "NPDU"
+Network Protocol Data Unit. The unit of data which is exchanged between
+network entities.
+.ip "DT NPDU"
+Normal data NPDU.
+.ip "ER NPDU"
+Error report NPDU.
+.ip "Initial NPDU"
+A NPDU carrying the whole of the user data from an N-UNITDATA request.
+.ip "Derived NPDU"
+a NPDU whose field ar identical to those of an initial NPDU, except that it
+carries only a segment of the user data from an N-UNITDATA request.
+.ip "Segment"
+A distinct unit of data consisting of part or all of the user data provided
+in the N-UNITDATA request and delivered in the N-UNITDATA indication.
+.ip "Segmentation"
+The act of generation two or more derived NPDUs from an initial or derived
+NPDU.
+.ip "Fragment"
+A DoD Internet Protocol term with the same meaning as "segment". Used
+synonymously with "segment."
+.ip "Fragmentation"
+A DoD Internet Protocol term with the same meaning as "segmentation". Used
+synonymously with "segmentation."
+.ip "Reassembly"
+The act of regenerating an initial NPDU from two ore more derived NPDUs.
+.ip "MTU"
+Maximum transmission unit.  The maximum size of a packet that can be
+transmitted on a medium or through a protocol.
+For example, the MTU of the TP protocol is 8192 bytes, the MTU
+of and Ethernet device is 1500 bytes, and the MTU of the OSI Network
+service is 512 bytes.
+.ip "Network interface"
+The device used to attach a computer to a network, for example,
+an Ethernet adapter, or a Token Ring adapter.
+This unfortunate terminology is inherited from BSD Unix.
diff --git a/usr/src/share/doc/iso/wisc/eicon.nr b/usr/src/share/doc/iso/wisc/eicon.nr
new file mode 100644 (file)
index 0000000..64db4aa
--- /dev/null
@@ -0,0 +1,729 @@
+.sh 2 "X.25 Public Data Network Support"
+.pp
+This ARGO release includes support for an X.25 Public Data Network (PDN)
+in the form of a device driver for the Eicon Technology
+Network Adapter \**.
+.(f
+This adapter, its software, and its documentation are
+available from Eicon Technology Corporation, 3452 Ashby Street, Montreal,
+Quebec, Canada H4R 2C1.
+.)f
+The adapter and its software, together with
+the ARGO \fIecn(4)\fR driver, implement
+the X.25 packet layer protocol as required to support the OSI connection
+oriented network service.
+The remainder of this section of this manual
+destribes the ARGO device driver (hereinafter called "the driver")
+for the Eicon Technology Network Adapter (hereinafter called "the adapter"),
+the interface between the driver
+and the CONS software described above, and the interface
+between the driver and the software on the adapter.
+.sh 3 "Software Modules"
+.lp
+The modules relevant to the design of the driver are listed below.
+.ip "\fICONS -\fR"
+The Connection Oriented Network Service (CONS) provides the upper ISO layers
+with an interface to the PDN. 
+In this release,
+the PDN is 1980 X.25, although support for 1984 X.25 is included.
+CONS can receive requests
+from the CLNP entity and
+from the OSI transport entity.
+In addition, the CONS module 
+supports \fIioctl()\fR commands used by 
+\fIifconfig(8)\fR to configure 
+the X.25 network address and to
+declare the adapter to be up or down. 
+See \fIcons(4p)\fR.
+.ip "\fIDriver -\fR"
+The driver accepts commands from CONS, formats these commands 
+for the adapter, and interprets error indications delivered by the adapter.  
+This driver supports all the UNIX configuration device structures. 
+See \fIecn(4)\fR.
+.ip "\fIEcnconf -\fR"
+\fIEcnconf\fR is a program that allows the privileged user to
+reconfigure
+the options offered by the software on the adapter. 
+\fIEcnconf\fR can be run at any time. 
+See \fIecnconf(8)\fR.
+.ip "\fIEcnload -\fR"
+\fIEcnload\fR is a program that downloads Eicon Technology software
+to the adapter and passes the configuration changes made 
+with the \fIecnconf\fR program to the driver. 
+\fIEcnload must be run only when the X.25 link is considered down\fR.
+See \fIecnload(8)\fR. 
+.ip "\fIEcnstat -\fR"
+\fIEcnstat\fR is a program that
+prints the connection state information and counters kept by
+the adapter and by the driver.
+The statistics include the number of sends and receives,
+active connections, and errors.
+For more information, see \fI ecnstat(8)\fR.
+.ip "\fIAdapter -\fR"
+The adapter's interface to the driver is the Network Control
+Block and Request Vector that exist within the adapter's shared memory (often
+called the "Common Data Area").
+This is described in detail below.
+.sh 3 "Interactions Among the Modules"
+.lp
+The commands
+passed between CONS and the driver can be any one of the \fIECN\fR
+commands outlined in the
+sections "ECN Requests" and "ECN Replies", below.
+CONS uses the \fCecnrestart()\fR procedure for restart requests,
+\fCecnshutdown()\fR procedure for shutdown requests, and 
+\fCecnoutput()\fR procedure for all
+normal data transfer requests. 
+CONS uses the \fCecnioctl()\fR procedure call for
+servicing adapter status requests from the X.25 statistics program \fIecnstat\fR.
+.lp
+Commands passed between the driver and the adapter can
+be any one of the network control block (\fINCB\fR)
+commands described in the section "NCB Commands", below.
+All commands to and from the adapter are
+communicated in the Network Control Block and Request Vector within
+the adapter's Common Data Area.
+.lp
+\fIEcnload\fR starts the 
+Eicon Technology Network Adapter software on the adapter
+and downloads the validated configuration
+to the driver.
+.sh 3 "ECN Requests"
+.lp
+The \fIECN\fR request types that CONS can pass to the driver are listed below.
+.ip "\fIECN_STOP - (by calling ecnshutdown())\fR"
+This request instructs the driver to restart the network but not to listen for 
+any incoming calls. 
+CONS issues this request in response to an \fIioctl()\fR command
+issued by the utility program \fIifconfig\fR, when
+\fIifconfig\fR is used to bring down the adapter.
+.ip "\fIECN_RESTART - (by calling ecnrestart())\fR"
+This request instructs the driver to restart the network \fIand\fR to listen 
+and accept any incoming calls. 
+CONS issues this request in response to an \fIioctl()\fR command
+issued by the utility program \fIifconfig\fR, when
+\fIifconfig\fR is used to bring the adapter up.
+.ip "\fIECN_CALL - 0x90\fR"
+This request instructs the driver to place
+a call request
+to the specified DTE.
+.ip "\fIECN_CLEAR - 0x92\fR"
+This request instructs the driver to clear a given virtual circuit. 
+All outbound data are acknowledged by the remote DTE
+before the circuit is cleared.
+.ip "\fIECN_SEND - 0x94\fR"
+This request instructs the driver to transmit a data buffer across a given 
+virtual circuit.
+.ip "\fIECN_RESET - 0x04\fR"
+This request instructs the driver to reset the given virtual circuit and
+clear out all outstanding requests
+associated with that virtual circuit.
+.ip "\fIECN_STATUS - 0xb4 (exclusively through ecnioctl())\fR"
+This requests instructs the driver to 
+solicit the adapter's current connection state information and
+counters.
+.sh 3 "ECN Replies"
+.lp
+The \fIECN\fR responses
+the driver can give
+to CONS are listed below.
+.ip "\fIECN_CONNECT - 0x01\fR"
+This reply notifies CONS that the driver has established a virtual circuit
+connection initiated by the remote DTE.
+.ip "\fIECN_ACCEPT - 0x03\fR"
+This reply notifies CONS that an ECN_CALL request has succeeded. The
+reply contains a pointer to a protocol control block.
+.ip "\fIECN_REFUSE - 0x02\fR"
+This reply notifies CONS that a previous \fIECN_CALL\fR request has failed.
+The reply contains a pointer to a protocol control block.
+.ip "\fIECN_CLEAR - 0x92\fR"
+This reply notifies CONS that a given virtual circuit has been cleared
+either by the DCE or by the remote DTE.
+.ip "\fIECN_RECEIVE - 0x95\fR"
+This reply notifies CONS that the driver has received a data packet from
+the remote DTE.
+.ip "\fIECN_RESET - 0x04\fR"
+This reply notifies CONS that the virtual circuit has been reset either
+by the DCE or by the remote DTE.
+.ip "\fIECN_ACK - 0x05\fR"
+This reply tells CONS that the associated ECN_SEND request has been been
+completed by the adapter.
+.sh 3 "NCB Commands"
+.lp
+The driver hides from the CONS module
+many of the idiosyncrasies of the adapter's 
+software interface
+by mapping many of the above \fIECN\fR requests into corresponding
+\fINCB\fR commands. Below is a list of requests that the driver can place to
+the adapter. For each request that the driver places to the adapter, the adapter
+returns with a command completion.
+.ip "\fINCB_CALL - 0x90\fR"
+This command creates a virtual circuit. 
+.ip "\fINCB_LISTEN - 0x91\fR"
+This command tells the adapter that our host is
+willing to accept incoming calls. 
+.ip "\fINCB_CLEAR (and NCB_ABORT) - 0x92\fR"
+This command clears a virtual circuit. An option exists to clear the circuit
+immediately, without waiting first for outstanding acknowledgments.
+.ip "\fINCB_SEND (and NCB_RESET) - 0x94\fR"
+This command sends data to the remote DTE. An option is
+available for resetting the
+virtual circuit. This command can return a status indicating that the
+circuit has been cleared by the DCE or the remote DTE.
+.ip "\fINCB_RECEIVE - 0x95\fR"
+This command tells the adapter that our host is
+willing to receive data on a given virtual circuit. This command can return
+received data, a reset circuit, M-, D-, and Q-bits, interrupt packets,
+or a cleared circuit.
+.ip "\fINCB_STATUS - 0xb4\fR"
+This command queries the adapter about 
+the status of a virtual circuit.
+The driver uses this command to support the ECN_STATUS request.
+.ip "\fINCB_RESTART - 0xb2\fR"
+This command restarts the network. This command requires that a corresponding
+configuration file be passed down to the adapter.
+.bp
+.sh 3 "ECN Request and Reply Structure"
+.lp
+Below is
+the data structure used in CONS-driver 
+communications.
+This data structure is a parameter to the 
+\fIecnoutput()\fR procedure.
+\fC
+.nf
+/* Eicon Driver Request Structure -- used between CONS and the driver */
+
+struct eicon_request {
+    struct ecn_ncb  eicon_req_ncb;   /* the network control block       */
+    caddr_t         eicon_req_pcb;   /* CONS pcb used on CALL requests  */
+    int             eicon_req_state; /* used internally by the driver   */
+    int             eicon_retry_cnt; /* used internally by the driver   */
+    int             eicon_more;      /* used internally by the driver   */
+    u_char          eicon_reason;    /* source of CLEAR requests        */
+};
+\fR
+.lp
+The \fCeicon_req_ncb\fR field in the eicon request structure is of
+type \fCecn_ncb\fR, defined in the following section. This structure stores 
+the command block
+that the driver uses in communicating with the adapter. 
+The command block contains a \fIlogical session number\fR (LSN),
+which identifies a virtual circuit.
+Requests such as ECN_CALL are made without an LSN to identify
+a circuit.
+When an LSN is not available, the request is identified by
+the field
+\fCeicon_req_pcb\fR, which is a pointer to a CONS protocol control block. 
+The \fCeicon_req_state\fR field is used by the driver to keep track 
+of the status of the given request. 
+The following list defines the various values for this field:
+.ip "\fIREQ_NEW\fR"
+The driver recognizes a new request, has placed the request into the driver's 
+own request queue, but has yet to interrupt the
+adapter. (The driver maintains a pointer \fCecn_pending_req\fR that indicates
+whether an interrupt to the adapter is outstanding. If one is outstanding, the
+driver places any new requests in this \fIREQ_NEW\fR state. If an interrupt 
+is not
+outstanding, the driver places the request immediately in the 
+\fIREQ_INTERRUPT\fR state defined below.)
+.ip "\fIREQ_INTERRUPT\fR"
+The driver has dequeued the CONS request, assigned \fCecn_pending_req\fR to
+point to the request, and
+interrupted the adapter for a chance to post this request.
+.ip "\fIREQ_POSTED\fR"
+The driver has sent the request to the adapter.
+.ip "\fIREQ_COMPLETE\fR"
+The driver has just completed the request, and if necessary, is now posting 
+it to CONS.
+.lp
+The \fCeicon_retry_cnt\fR field in the eicon request structure keeps track
+of how many times the driver has tried posting this command to the adapter.
+After the second retry, the driver gives up and performs the appropriate
+error routine. 
+The \fCeicon_more\fR field defines a \fIRECEIVE\fR request that
+has been re-posted to the adapter to take care of m-bit transfers.
+The \fCeicon_reason\fR field quantifies the reason for a connection being
+cleared. These reasons are defined in the include file \fCiso_errno.h\fR.
+.lp
+Any data associated with the request are linked to the request through the
+request mbuf's \fCm_next\fR field. 
+This is done so that when
+the driver calls the \fIMFREE_M\fR deallocation routine, both the request 
+and the data are freed together.
+.lp
+The following chart defines those fields within the eicon request structure
+that are relevant in any CONS request
+to the driver via the \fIecnoutput()\fR call. 
+.sp
+.sz 8
+.TS
+center,box,tab(:);
+c s s s s
+c||c s s s
+c||c|c|c|c
+l||l|l|l|l.
+\fBField Definitions for CONS \(-> Driver Requests\fR
+_
+\fI:Request Types (CONS \(-> Driver)\fR
+\fIField:ECN_CALL:ECN_CLEAR:ECN_SEND:ECN_RESET\fR
+=
+\fIncb\(->command\fR:0x90:0x92:0x94:0x04 
+_
+\fIncb\(->loc_ses_num\fR:T{
+.na
+leave as zero
+T}:VC #:VC #:VC #
+_
+\fIncb\(->info\fR:0x0:0x0:0x0:0x2
+_
+\fIeicon_req_pcb\fR:T{
+.na
+address of CONS' protocol control block
+T}:NULL:NULL:NULL
+_
+\fIeicon_req_data\fR:T{
+.na
+address of mbuf containing contents of Call Request packet (including DTE address, facilities, and call user data)
+T}:T{
+.na
+NULL or address of mbuf containing contents of Clear Request packet
+T}:T{
+.na
+address of mbuf containing contents of user data
+T}:T{
+.na
+NULL or the address of mbuf containing a one byte Reset Diagnostic code
+T}
+.TE
+.sz 10
+.sh 3 "Structure of the Network Control Block (NCB)"
+.lp
+The \fCecn_ncb\fR structure is used by the driver to
+make requests of the adapter. 
+\fC
+.nf
+/* Network Control Block -- used between the driver and the Eicon adapter */
+
+struct ecn_ncb {
+    u_char      command;        /* command field                         */
+    u_char      retcode;        /* return code field                     */
+    u_char      lsn;            /* local session number                  */
+    u_char      info;           /* additional information                */
+    caddr_t     buffer;         /* pointer to data buffer's mbuf         */
+    u_short     length;         /* buffer length                         */
+    u_char      callname[16];   /* module name on NA "X25"               */
+    u_char      appl_name[16];  /* application name                      */
+    u_char      rxto;           /* receive timeout in secs               */
+    u_char      txto;           /* send(tx) timeout in secs              */
+    caddr_t     post;           /* NULL                                  */
+    u_char      lana_num;       /* specifies Eicon Tech NA               */
+    u_char      cmd_cplt;       /* command status                        */
+    u_char      reserve[14];    /* reserved area                         */
+};
+\fR
+.sp
+.lp
+The chart below defines those fields that are relevant in any
+reply passed by the driver back up to CONS.
+.sp
+.sz 7
+.TS
+center,box,tab(:);
+c s s s s s s
+c||c s s s s s 
+c||c|c|c|c|c|c
+l||l|l|l|l|l|l.
+\fBField Definitions for Driver \(-> CONS Replies\fR
+_
+\fI:Reply Types (Driver \(-> CONS)\fR
+\fIField:ECN_CONNECT:ECN_ACCEPT:ECN_REFUSE:ECN_CLEAR:ECN_RECEIVE:ECN_RESET\fR
+=
+\fIncb\(->command\fR:0x01:0x03:0x02:0x92:0x95:0x04
+_
+\fIncb\(->loc_ses_num\fR:VC #:VC #:ignore:VC #:VC #:VC #
+_
+\fIncb\(->info\fR:ignore:ignore:ignore:ignore:T{
+.na
+Interrupt received (bit 0), D-bit set (bit 6), and/or Q-bit set (bit 7). Zero
+info field implies a normal receive.
+T}:ignore
+_
+\fIeicon_req_pcb\fR:NULL:T{
+.na
+address of CONS's protocol control block
+T}:T{
+.na
+address of CONS's protocol control block
+T}:ignore:ignore:ignore
+_
+\fIeicon_req_data\fR:T{
+.na
+NULL or address of mbuf containing contents of Call Indication packet 
+T}:T{
+.na
+NULL or address of mbuf containing contents of Call Connected data 
+T}:T{
+.na
+NULL or address of mbuf containing contents of Call Cleared data
+T}:T{
+.na
+NULL or address of mbuf containing contents of Call Cleared data
+T}:T{
+.na
+address of mbuf containing contents of user data
+T}:T{
+.na
+NULL or address of mbuf containing one byte Reset Diagnostic code
+T}
+_
+\fIeicon_reason\fR:ignore:ignore:T{
+.na
+reason for refusal
+T}:T{
+.na
+reason for clear
+.T}:ignore:T{
+.na
+reason for reset
+T}
+.TE
+.sz 10
+.bp
+.sh 3 "Internal Driver Data Sructures"
+.lp
+The main driver data structure
+is the \fIecn_softc\fR structure.
+This structure keeps track of the interface request queue 
+(\fCecn_if\fR and \fCecn_pending_req\fR), 
+magic addresses on the adapter (\fCecn_iom_base, ecn_mem_base,\fR and 
+\fCecn_data_base\fR), 
+error statistics (\fCecn_errors\fR), the state
+of each virtual circuit (\fCecn_vc_state\fR), the state of the \fILISTEN\fR
+request (\fCecn_listen_pending\fR), and the current caller (\fCecn_cause\fR).
+\fC
+.nf
+struct ecn_softc {
+    int             ecn_errors[NCB_MAX][ST_MAX]; 
+    int             ecn_cause[CAUSE_MAX];  /* ecn_work() causes              */
+    struct mbuf     *ecn_pending_req;      /* waiting for command req        */
+    char            ecn_listen_pending;    /* boolean = listen req pending?  */
+    char            ecn_vc_state[LSN_MAX]; /* the current state of each vc   */
+    struct ecn_device      
+                    *ecn_iom_base;         /* base address of io map         */
+    struct ecn_request_vector
+                    *ecn_mem_base;         /* base address of memory map     */
+    caddr_t         ecn_data_base;         /* base address for data area     */
+    struct ifnet    ecn_if;                /* queue of new requests          */
+}
+\fR
+.so figs/ecn_queue.nr
+.sh 2 "Queueing in the Driver"
+.lp
+.CF
+illustrates the queueing mechanism used by the driver.
+.lp
+CONS queues its data transfer requests at the end of the queue managed by
+\fCecn_if\fR field in the \fCecn_softc\fR structure. 
+At this point, each request has the state value of 
+\fIREQ_NEW\fR. 
+Once the driver notifies the adapter that it has a command to post,
+the driver dequeues the first request from the \fCecn_if\fR queue 
+and sets the pointer
+\fCecn_pending_req\fR to point to the request. 
+At this point, the request is in the \fIREQ_INTERRUPT\fR state.
+.lp
+Once the driver posts the request to the adapter, it 
+dequeues the next request in the \fCecn_if\fR queue, reassigns the 
+\fCecn_pending_req\fR pointer, and then indicates to the adapter 
+that it is ready to post another request. 
+The driver no longer has to keep track of the previous request, 
+because for every reply, the adapter includes the associated 
+mbuf pointer. 
+While the request is outstanding, the request is in the \fIREQ_POSTED\fR state.
+.so figs/ecn_vc.nr
+.lp
+After the adapter completes the command, the driver may want to reply to CONS.
+It does this by placing its reply in CONS's \fCconsintrq\fR queue, defined as
+an external \fCifqueue\fR in the driver code.
+.sh 2 "Virtual Circuit States"
+.lp
+The \fCecn_vc_state\fR array in the \fCecn_softc\fR structure above keeps track
+of the state of each virtual circuit (VC).
+This is necessary to avoid handing
+the adapter any commands that may not apply during a given state. 
+This mechanism
+is especially useful in dealing with unexpected aborts or clears where there
+is the potential for all outstanding commands to complete with errors. 
+By changing
+states, the driver can prevent redundant commands (like clears and aborts)
+from being passed either to the adapter or to CONS. 
+.lp
+The driver only keeps track of four different states, as illustrated in 
+.CF
+.
+These states are:
+.ip "\fIVC_NO_CONNECTION\fR"
+When a virtual circuit is in this state, the virtual circuit does not exits.
+Only \fICALL\fR and \fILISTEN\fR commands are valid.
+.ip "\fIVC_DATA_XFER\fR"
+All commands, except \fICALL\fR and \fILISTEN\fR commands are valid once the
+connection exists.
+.ip "\fIVC_RESET_IN_PROGRESS\fR"
+In this state, either the driver has issued an \fINCB_RESET\fR or it has 
+received a reset error code on the completion of a command. 
+Only reissued \fIRESET\fR commands and \fIRECEIVE\fRs are
+valid. 
+\fIRECEIVE\fR is valid in this state because the adapter uses the
+completion of this command to hand back the cause of the reset (the RESET
+INDICATION packet).
+.ip "\fIVC_CLEAR_IN_PROGRESS\fR"
+The driver has either issued an \fINCB_CLEAR\fR command or has just
+received a clear error code on the completion of a command. 
+Within this state, only reissued
+\fICLEAR\fR and \fIABORT\fR commands are valid.
+.sh 2 "Error Statistics"
+.lp
+With the \fCecn_errors\fR field in the \fCecn_softc\fR structure,
+the driver maintains a two dimensional array of counters
+if the frequencies of errors.
+In order to inspect this array easily with
+the kernel debugger, the first index to every command ( <command, 0> ) is
+reserved for a four character ASCII command identifier.
+.bp
+.sh 3 "The Driver State Machine"
+.sh 2 "Handling of Normal Command Completions"
+.lp
+The chart below lists
+all the available adapter request types, at what level each of
+these requests can be used, options, and the driver's action after a normal
+completion of the command.
+.sp
+.sz 7
+.TS
+center,box,tab(:);
+c s s s
+c|c s|c
+c|c|c|c
+l|l|l|l.
+\fBNormal Completion Handling\fR
+_
+\fINCB:Options:Action Based on Normal Competion of\fR
+\fICommand:To Adapter:From Adapter:Driver\(->Adapter Command\fR
+=
+\fINCB_RESTART\fR:none:none:T{
+.na
+dequeue the request, and issue an NCB_LISTEN request to the adapter.
+T}
+_
+\fINCB_CALL\fR:none:connected:T{
+.na
+dequeue the request, pass an ECN_ACCEPT reply to CONS, and issue a RECEIVE to
+the adapter.
+T}
+_
+\fINCB_LISTEN\fR:T{
+.na
+use zero-length Call User Data and a zero-length Calling DTE address
+T}:none:T{
+.na
+dequeue the request, pass an ECN_CONNECT to CONS, and issue a RECEIVE to the
+adapter. Re-issue another NCB_LISTEN
+for another possible virtual circuit connection.
+T}
+_
+\fINCB_CLEAR\fR:T{
+.na
+normal clearing with all outstanding ACKs returned 
+T}:none:T{
+.na
+dequeue the request.
+T}
+:_:_:_
+:T{
+.na
+immediate clearing 
+T}:none:T{
+.na
+dequeue the request.
+T}
+_
+\fINCB_SEND\fR:T{
+.na
+normal send
+T}:none:T{
+.na
+dequeue the request and reply to CONS with an ECN_ACK.
+T}
+:_:_:_
+:T{
+.na
+reset the virtual circuit
+T}:none:T{
+dequeue the request.
+T}
+_
+\fINCB_RECEIVE\fR:none:T{
+.na
+normal, uncomplicated receive
+T}:T{
+.na
+dequeue the request and bcopy the data into the request's associated mbuf. Ship to CONS. Re-issue another NCB_RECEIVE.
+T}
+:_:_:_
+:none:T{
+.na
+m-bit set
+T}:T{
+.na
+same as above (adapter does the resegmentation automatically).
+T}
+:_:_:_
+:none:T{
+.na
+d-bit set
+T}:T{
+.na
+same as above.
+T}
+:_:_:_
+:none:T{
+.na
+q-bit set
+T}:T{
+.na
+same as above.
+T}
+:_:_:_
+:none:T{
+.na
+interrupt received
+T}:T{
+.na
+same as above.
+T}
+:_:_:_
+:none:T{
+.na
+reset received
+T}:T{
+dequeue the request, send an ECN_RESET back up to CONS, and issue another 
+receive.
+T}
+.TE
+.sz 10
+.sp
+.uh "CONS \(-> Driver"
+.lp
+All entries in this column indicate that the CONS module can send this request 
+down to the driver.  Command names in parenthesis define the mapping between
+the \fIECN\fR and \fINCB\fR commands.
+.uh "Driver \(-> Adapter"
+.lp
+All checks in this column indicate that the driver can send this request
+to the adapter. The last column in the above table defines what the driver must
+do upon normal completion of the command from the adapter. 
+Note that not all driver-to-adapter
+commands have a CONS-to-driver equivalent. 
+This shows that this 
+command request is generated within the driver, rather than originating from
+the CONS driver.
+.uh "Driver \(-> CONS"
+.lp
+All entries in this column indicate that the driver can send this reply  
+back to CONS. Command names in parenthesis define  the mapping between 
+the \fIECN\fR and \fINCB\fR commands.
+.bp
+.sh 3 "Handling of Errors upon Command Completion"
+.lp
+Below is listed all the driver request and pseudo request types, along with the
+actions the driver must perform given a command completion error delivered by
+the Eicon Network Adapter.
+.sp
+.sz 7
+.TS
+center,box,tab(:);
+c  s s s s s s s
+c||c s s s s s s
+c||c|c|c|c|c|c|c
+c||c|c|c|c|c|c|c
+l||l|l|l|l|l|l|l.
+\fBError Completion Handling\fR
+_
+:\fIAction Based on Error Completion of Driver \(-> Adapter Command\fR
+\fIError Returned\fR:_:_:_:_:_:_:_
+\fI:NCB_CALL:NCB_LISTEN:NCB_CLEAR:NCB_ABORT:NCB_RESET:NCB_SEND:NCB_RECEIVE\fR
+=
+\fIST_BAD_LEN\fR:<soft-error>:<soft-error>:<soft-error>:<soft-error>:<soft-error>:<soft-error>:<soft-error>
+_
+\fIST_INVALID\fR:<soft-error>:<soft-error>:<dequeue>:<dequeue>:<dequeue>:<dequeue>:<dequeue>
+_
+\fIST_COMMAND_TO\fR:<retry>:<retry>:<retry>:<retry>:<abort>:<abort>:<retry>
+_
+\fIST_ISSUE_ANOTHER_RCV\fR:<refuse>:<retry>:<retry>:<retry>:<abort>:<abort>:T{
+.na
+requeue request and increment "more" count
+T}
+_
+\fIST_BAD_LSN\fR:<soft-error>:<soft-error>:<dequeue>:<dequeue>:<dequeue>:<dequeue>:<dequeue>
+_
+\fIST_NO_RESOURCES\fR:<retry>:<retry>:<retry>:<retry>:<abort>:<abort>:<retry>
+_
+\fIST_CALL_CLEARED\fR:<refuse>:<retry>:<retry>:<retry>:<clear>:<clear>:<clear>
+_
+\fIST_COMMAND_CANCELLED\fR:<refuse>:<retry>:<retry>:<retry>:<abort>:<abort>:<abort>:
+_
+\fIST_NO_CIRCUITS\fR:<refuse>:<retry>:<retry>:<retry>:<abort>:<abort>:<abort>
+_
+\fIST_CALL_UNSUCCESSFUL\fR:<refuse>:<retry>:<retry>:<retry>:<abort>:<abort>:<abort>
+_
+\fIST_INCORRECT_CALLNAME\fR:<soft-error>:<soft-error>:<soft-error>:<soft-error>:<soft-error>:<soft-error>:<soft-error>
+_
+\fIST_X25_RESET\fR:<refuse>:<retry>:<retry>:<retry>:<dequeue>:<dequeue>:<retry>
+_
+\fIST_TOO_MANY_COMMANDS\fR:<retry>:<retry>:<retry>:<retry>:<abort>:<abort>:<retry>
+_
+\fIST_L1_NO_DATA_SET_READY\fR:<refuse>:<retry>:<retry>:<retry>:<abort>:<abort>:<abort>
+_
+\fIST_L1_NO_CLEAR_TO_SEND\fR:<refuse>:<retry>:<retry>:<retry>:<abort>:<abort>:<abort>
+_
+\fIST_L1_NO_CLOCK\fR:<refuse>:<retry>:<retry>:<retry>:<abort>:<abort>:<abort>
+.TE
+.sz 10
+.sp
+.lp
+Each of the actions from the above chart are defined as follows.
+.ip "\fI<abort>\fR -"
+The driver should clear the connection by issuing an \fINCB_ABORT\fR 
+to the adapter and sending an \fIECN_CLEAR\fR to CONS.
+.ip "\fI<refuse>\fR -"
+The driver should send an \fIECN_REFUSE\fR back to CONS.
+.ip "\fI<dequeue>\fR -"
+The driver should simply dequeue the request. Usually these errors occur when a
+reset or clear occurs on the adapter while the driver is in the midst of
+issuing the command which subsequently completes with an error status.
+.ip "\fI<clear>\fR -"
+The driver should send an \fIECN_CLEAR\fR back up to CONS.
+.ip "\fI<retry>\fR -"
+The driver should requeue the request if and only if the 
+\fCecn_retry_cnt\fR field in the request structure does not exceed the
+retry maximum. 
+.ip "\fI<soft-error>\fR -"
+This action only takes place when a software error has occurred. The driver 
+should
+print the error to the console in big bold letters and then panic.
+.bp
+.sh 3 "The IFP Flags"
+.lp
+The IFP flags in the standard \fCifnet\fR structure
+should be used in the following way.
+.ip "\fIIFF_UP on -\fR"
+This flag is set by the driver only after the procedure \fIecnrestart()\fR
+successfully completes.
+.ip "\fIIFF_UP off -\fR"
+This flag is set immediately upon entry into the procedure \fIecnshutdown()\fR.
+.ip "\fIIFF_RUNNING on -\fR"
+This flag is set on whenever the \fIecnwork()\fR procedure is active, eg. the
+driver is actually doing something.
+.ip "\fIIFF_RUNNING off -\fR"
+This flag is turned off upon exit from the \fIecnwork()\fR procedure.
diff --git a/usr/src/share/doc/iso/wisc/errors.nr b/usr/src/share/doc/iso/wisc/errors.nr
new file mode 100644 (file)
index 0000000..51b5eb5
--- /dev/null
@@ -0,0 +1,363 @@
+.\"$Header: errors.nr,v 1.2 88/12/06 16:06:07 nhall Exp $
+.\"$Source: /usr/argo/doc/kernel/RCS/errors.nr,v $
+.NC "Error Handling"
+This section describes the various ways that the ARGO kernel 
+handles errors.
+For the purpose of this description,
+errors are divided into
+three classes : user errors, remote-end errors, and internal errors.
+These three classes of errors and the way 
+the ARGO kernel handles them are described below.
+.sh 1 "Network Layer Errors"
+.pp
+The following section describes how errors are handled by CLNP.
+.sh 2 "User Errors"
+.pp
+User errors occur when attempting to send a CLNP packet. These errors
+are reflected back to the caller of \fIclnp_output()\fR as the return value
+of the function. The following table indicates the types of errors possible
+and their associated return codes:
+.(b L
+.TS
+tab(+), expand box;
+l l.
+Problem+Return Code
+=
+Unsupported option selected+EINVAL
+Incorrect address+ENAMETOOLONG
+Insufficient \fImbufs\fR+ENOBUFS
+Can't route packet+ENETUNREACH,EHOSTUNREACH
+Insufficient \fImbufs\fR+ENOBUFS
+.TE
+.)b
+.sh 2 "Remote-end Errors"
+.pp
+An error that occurs as the result of incoming NPDU
+is a remote-end error.  
+.pp
+In the case of CONS, 
+the majority of these are addressing problems,
+PDN-generated errors (network or gateway congestion, number busy),
+or higher layer negotiation problems.
+All ISO 8208 diagnostic codes that may appear in a call clearing packet
+are passed up to the higher layer.
+Some of the higher layer protocols pass this error indication to the
+user level program as well.
+The CONS statistics that are maintained by the "glue" module
+include counters for each of the possible
+ISO 8208 diagnostic codes seen on incoming packets.
+In addition to these error codes, there are some codes that may appear
+due to device driver problems when an NPDU arrives, for example,
+the driver may run out of buffers.
+All possible errors that may occur in the CONS module are listed
+in the file
+\fC<netargo/iso_errno.h>\fR,
+and the values listed in this file are passed to the user level
+program in the global integer variable \fIerrno\fR.
+The ARGO library
+\fClibisodir.a\fR
+includes an expanded version of
+\fIperror()\fR that interprets these extra values.
+.pp
+In the case of CLNP,
+the most remote-end errors are parsing errors.
+When a remote-end error is discovered, processing of the NPDU stops. The
+NPDU is discarded, and if error reporting is not disabled, and ER NPDU
+is sent back to the source of the offending packet. The following
+tables show the errors that may occur, and the error reason 
+that will specified when the ER NPDU is returned.
+.pp
+The following general errors may occur while parsing an NPDU:
+.(b L
+.TS
+tab(+), box, expand;
+l l.
+Problem+Error Reason
+=
+NPDU arrives before interface is configured+ADDR_DESTUNREACH
+Packet too short or too big+GEN_INCOMPLETE
+Protocol identification wrong+GEN_HDRSYNTAX
+Version wrong+DISC_UNSUPPVERS
+Lifetime expired+TTL_EXPTRANSIT
+Incorrect checksum+GEN_BADCSUM
+Address section too short+GEN_INCOMPLETE
+Segment section too short+GEN_INCOMPLETE
+Options section too short+GEN_INCOMPLETE
+Unknown packet type+GEN_HDRSYNTAX
+Can't route packet (forwarding)+ADDR_DESTUNREACH
+.TE
+.)b
+The following errors are related to options processing:
+.(b L
+.TS
+tab(+), box, expand;
+l l.
+Problem+Error Reason
+=
+Duplicate option+GEN_DUPOPT
+Unknown option+DISC_UNSUPPTOPT
+Security format bad+GEN_HDRSYNTAX
+Security option present+DISC_UNSUPPSECURE
+Source route format bad+SRCRT_SYNTAX
+Record route too short+GEN_INCOMPLETE
+Record route format bad+GEN_HDRSYNTAX
+QOS format bad+GEN_HDRSYNTAX
+Priority format bad+GEN_HDRSYNTAX
+Error reason format bad+GEN_HDRSYNTAX
+Error reason on non-ER NPDU+DISC_UNSUPPOPT
+Error reason absent from ER NPDU+GEN_HDRSYNTAX
+.TE
+.)b
+.sh 2 "Internal Errors"
+.pp
+Internal errors occur as a result of a programmer error. These errors
+will result in a kernel \fIpanic()\fR. The following panics have been
+coded into CLNP:
+.(b L
+.TS
+tab(+), box, expand;
+l l.
+\fIPanic()\fR message+Reason
+=
+clnp_init: no raw clnp+The raw clnp protocol is not
++configured into the kernel.
+_
+clnp_srcaddr: ifp does not match interface+The ifp
++passed to \fIclnp_srcaddr()\fR is invalid.
+.TE
+.)b
+.sh 1 "Transport Layer Errors"
+.pp
+.sh 2 "User Errors"
+.pp
+TP handles these errors in the "standard"
+way for 4.3BSD:
+it causes an E\fIxxx\fR error constant (from the
+list in /sys/h/errno.h)
+to be put into the user program's
+global variable \fIerrno\fR.
+In most routines, in particular
+those routines called directly or indirectly
+the by system-call routines,
+this is done
+by simply returning
+this integer value. 
+The errors that fall into this category are described
+in the following table:
+.(b L
+.TS
+expand box tab(+);
+l l.
+Error+Meaning
+=
+EAFNOSUPPORT+Attempting to use an address family
+ +other than AF_ISO and AF_INET.
+_
+ENOPROTOOPT+TP was not configured at boot time.
+_
+ESOCKTNOSUPPORT+The given socket type is not supported.
+_
+EPROTOTYPE+Attempting to use an inappropriate transport
+ +class for the network service. (e.g. class 0 over CLNS)
+ +or attempting to use an unknown network service.
+_
+EISCONN+Attempting to perform on a connected socket an action 
+ +that is permitted only on unconnected sockets.
+_
+ENOTCONN+Attempting to perform on an unconnected socket an
+ +action that is permitted only on connected sockets.
+_
+EMSGSIZE+Trying to send more data than are permitted on 
+ +connect, disconnect, or expedited data PDUs.
+_
+ENOTSOCK+The integer argument passed in the system
+ +call is not a socket descriptor or is a socket but
+ +has no transport pcb.
+_
+EINVAL+Some argument to the system call is invalid.
+_
+EOPNOTSUPP+Some command argument to the system call is invalid
+ +or the operation is not supported.
+_
+EACCES+An unprivileged user tried to use a privileged command.
+_
+ETOOMANYREFS+TP ran out of reference blocks.
+_
+ENOBUFS+TP ran out of memory (mbufs).
+.TE
+.)b
+Errors that should be reported to the user
+by \fIerrno\fR but which occur asynchronously
+are detected by the socket layer when the value
+of the field \fIso_error\fR in the socket
+structure is non-zero.
+This is used to report such errors as 
+ECONNRESET,
+ECONNABORTED, and
+ECONNTIMEDOUT, which are really remote-end errors.
+.sh 2 "Remote-end Errors"
+.pp
+An error that occurs is the result of a timer
+or is a result of an 
+incoming TPDU
+is a remote-end error.
+The majority of these errors are parsing errors.
+They also include some protocol errors.
+Some of these errors cause the connection to be
+closed locally.
+It is unfortunate that when a connection is closed,
+the kernel will not permit the user program to perform
+anything on the socket in question, so the user cannot
+inquire about the reason for disconnection.
+There is no clean way to pass this information to a
+signal handler either, since the process being signalled
+may be swapped out at the time.
+Some of these errors cause TP to return an ER TPDU
+or a DR TPDU to the sending site.
+Some have no effect on the connection locally.
+These errors and their effects are described below.
+.(b L
+.TS
+expand box tab(+);
+l l l.
+Error+Meaning+Return code or action taken
+=
+Retransmission+The remote end has not responded +ETIMEDOUT
+timeout+to repeated attempts to send.+ 
+ +This can occur during connection+ 
+ +or after connection establishment.+ 
+_
+Inactivity+The remote end has not sent anything +ETIMEDOUT
+timeout+within the last \fIx\fR time, where+
++\fIx\fR is a locally defined+
++large value.+ 
+_
+Unacceptable+An unacceptable TPDU has arrived, and the+TPDU dropped
+TPDU +remote end can be identified.+possibly DR/ER returned
+_
+DR TPDU+A DR TPDU arrived, with any+Disconnect indication,
+arrived+value in the reason field.+so_error == ECONNRESET
+_
+ER TPDU+An ER TPDU arrived, with any+Disconnect indication,
+arrived+anything in the reason field.+so_error == ECONNABORTED
+.TE
+.)b
+TPDUs may be unacceptable for a variety of reasons:
+.(b L
+.TS
+expand box tab(+);
+l l.
+Problem+Action taken by TP
+=
+No connection at destination+Respond with DR, reason: session entity
+reference or reference frozen+not attached to TSAP
+_
+Invalid destination reference+Respond with DR, reason: mismatched 
++references
+_
+Invalid parameter code+Respond with ER, cause: inval. param. code
+_
+Invalid DU type+Respond with ER, cause: invalid TPDU type
+_
+Invalid version number+ Respond with ER, cause: inval. param. code
+_
+Invalid suffix value+Respond with ER, cause: inval. param. value
+_
+Suffix missing or is of+Respond with DR, reason:
+invalid length+header or parameter length invalid
+_
+Invalid checksum+packet discarded
+_
+Can't find a connection+Respond with DR, reason:
+for (dest ref, src ref) pair+mismatched references
+_
+Old ACK TPDU+packet discarded, possibly send ACK w/ FCC
+_
+Class requested isn't supported+Respond with DR, reason: +negotiation failed
+_
+Invalid TPDU size parameter+Respond with ER, cause: inval. param. value
+_
+Illegal amount of data+Respond with DR, reason:
+on CR, CC, DR, or XPD+header or parameter length invalid
+_
+Header length and length+Respond with DR, reason:
+indicator field of TPDU don't agree+header or parameter length invalid
+.TE
+.)b
+.lp
+The file \fC<argo/iso_errno.h>\fR is a list
+of the error codes and diagnostic that can be returned
+from the peer transport entity in a DR TPDU or an ER TPDU,
+and those that can be returned from the CONS, initiated by the DCE,
+the remote DTE, or by the local network adapter.
+These error values are too numerous to list here.
+Most of them are taken from the ISO 8208 standard and the ISO 8073 standard.
+The ARGO distribution contains an expanded form of the BSD library
+routine \fIperror()\fR that prints an error messages for a given
+\fIerrno\fR value.
+.sh 2 "Internal Errors"
+.pp
+Some internal errors are the result of 
+a lack of resources such as buffers.
+These are reported to the user with the
+global variable
+\fIerrno\fR
+set to a value from
+\fC<errno.h>\fR.
+The errors that fall into this category are described
+in the following table:
+.(b L
+.TS
+expand box tab(+);
+l l.
+Return code+Problem
+=
+ENOBUFS+TP ran out of mbufs.
+_
+EPROTONOOPT+TP hasn't been configured.
+_
+ETOOMANYREFS+TP ran out of (unfrozen) reference numbers.
+.TE
+.)b
+.pp
+Other
+internal errors are coding errors
+or errors of misinterpretation of a specification.
+They result in the printing of a message on the 
+console followed by a system panic.
+The following panics have been coded into TP:
+.(b L
+.TS
+expand box tab(+);
+l l.
+\fIPanic()\fR message+Problem
+=
+tp_emit CR/CC+The length indicator field of a TPDU is longer than the
+ +amount of space in an mbuf; TP is attempting to send a
+ +CR TPDU that is too large (perhaps legal but too large for 
+ +this implementation to manage).
+_
+tp_rcvoob: unexpected cluster+An incoming XPD TPDU was put into a cluster 
+ +mbuf by a lower layer.
+_
+tp timeout table overflow+The system ran out of structures for TP timers.
+_
+tp: T_DETACH+The connected socket that is being detached has 
+ +no parent socket.
+_
+tp_soisdisconnected+The socket head queue is 
+ +corrupted.
+_
+tp_soisdisconnecting+The socket head queue is 
+ +corrupted.
+_
+tpclnp_input: bad clnp_len +The length parameter passed by clnp
+ +is bad.
+_
+iso_control: SIOCDIFADDR+ioctl() system call passed down
+iso_control: SIOCSIFADDR+a null interface pointer
+_
+sofree dq+The list of socket structures is
+ +is inconsistent.
+.TE
+.)b
diff --git a/usr/src/share/doc/iso/wisc/ipc.nr b/usr/src/share/doc/iso/wisc/ipc.nr
new file mode 100644 (file)
index 0000000..9f9d962
--- /dev/null
@@ -0,0 +1,372 @@
+.NC "The Design of Unix IPC"
+.sh 1 "General"
+.pp
+The ARGO implementation of 
+TP and CLNP was designed to fit into the AOS
+kernel
+as easily as possible.
+All the standard protocol hooks are used.
+To understand the design, it is useful to have
+read 
+Leffler, Joy, and Fabry:
+\*(lq4.2 BSD Networking Implementation Notes\*(rq July 1983.
+This section describes the
+design of the IPC support in the AOS kernel.
+.sh 1 "Functional Unit Overview"
+.pp
+The 
+AOS
+kernel
+is a monolithic program of considerable size and complexity.
+The code can be separated into parts of distinct function,
+but there are no kernel processes per se.
+The kernel code is either executed on behalf of a user
+process, in which case the kernel was entered by a system call, 
+or it is executed on behalf of a hardware or software interrupt.
+The following sections describe briefly the major functional units 
+of the kernel.
+.\" FIGURE
+.so figs/func_units.nr
+.CF
+shows the arrangement of these kernel units and 
+their interactions.
+.sh 2 "The file system."
+.pp
+.sh 2 "Virtual memory support."
+.pp
+This includes protection, swapping, paging, and
+text sharing.
+.sh 2  "Blocked device drivers (disks, tapes)."
+.pp
+All these drivers share some minor functional units,
+such as buffer management and bus support
+for the various types of busses on the machine.
+.sh 2 "Interprocess communication (IPC)."
+.pp
+This includes 
+support for various protocols, 
+buffer management, and a standard interface for inter-protocol
+communication.
+.sh 2 "Network interface drivers." 
+.pp
+These drivers are closely tied to the IPC support. 
+They use the IPC's buffer management unit rather
+than the buffers used by the blocked device drivers.
+The interface between these drivers and the rest of the kernel 
+differs from the interface used by the blocked devices.
+.sh 2 "Tty driver" 
+.pp
+This is terminal support, including the user interface
+and the device drivers.
+.sh 2 "System call interface." 
+.pp
+This handles signals, traps, and system calls.
+.sh 2 "Clock." 
+.pp
+The clock is used in various forms by many
+other units.
+.sh 2 "User process support (the rest)." 
+.pp
+This includes support for accounting, process creation, 
+control, scheduling, and destruction.
+.pp
+.sh 2 "IPC"
+.pp
+The major functional unit that supports IPC
+can be divided into the following smaller functional
+units.
+.sh 3 "Buffer management." 
+.pp
+All protocols share a pool of buffers called \fImbufs\fR:
+.(b
+\fC
+.TS
+tab(+);
+l s s s.
+struct mbuf {
+.T&
+l l l l.
++struct mbuf+*m_next;+/* next buffer in chain */
++u_long+m_off;+/* offset of data */
++short+m_len;+/* amount of data */
++short+m_type;+/* mbuf type (0 == free) */
++u_char+m_dat[MLEN];+/* data storage */
++struct mbuf+*m_act;+/* link in 2-d structure */
+};
+.TE
+\fR
+.)b
+.pp
+There are two forms of mbufs - small ones and large ones.
+Small ones are 128 octets in 
+AOS
+and 256 octets
+in the ARGO release. Small mbufs are copied by byte-to-byte
+copies.
+The data in these mbufs are kept in the character
+array field \fIm_dat\fR in the mbuf structure
+itself.
+For this type of mbuf, the field \fIm_off\fR is positive,
+and is the offset to the beginning of the data from
+the beginning of the mbuf structure itself.
+Large mbufs, called \fIclusters\fR, are page-sized
+and page-aligned.
+They may be \*(lqcopied\*(rq by multiply mapping the pages they occupy.
+They consist of a page of memory plus a small mbuf structure 
+whose fields are used
+to link clusters into chains, but whose \fIm_dat\fR array is 
+not used.
+The \fIm_off\fR field of the structure 
+is the offset (positive or negative) from the
+beginning of the mbuf structure to the beginning
+of the data page part of the cluster.
+In the case of clusters, the offset is always out of the
+bounds of the \fIm_dat\fR array and so it is alway possible
+to tell from the \fIm_off\fR field whether an mbuf structure
+is part of a cluster or is a small mbuf.
+All mbufs permanently reside in memory.
+The mbuf management unit manages its own page table. 
+The mbuf manager keeps limited statistics on the quantities and
+types of buffers in use.
+Mbufs are used for many purposes, and most of these purposes
+have a type associated with them.
+Some of the types that buffers may take are
+MT_FREE (not allocated), MT_DATA,
+MT_HEADER, MT_SOCKET (socket structure),
+MT_PCB (protocol control block),
+MT_RTABLE (routing tables),
+and
+MT_SOOPTS (arguments passed to \fIgetsockopt()\fR and 
+\fIsetsockopt()\fR.
+Data are passed among functional units by means
+of queues, the contents of which are
+either chains of mbufs or groups of chains of mbufs.
+Mbufs are linked into chains with the \fIm_next\fR field.
+Chains of mbufs are linked into groups with the \fIm_act\fR
+field.
+The \fIm_act\fR field allows a protocol to retain packet
+boundaries in a queue of mbufs.
+.sh 3 "Routing." 
+.pp
+Routing decisions in the kernel are made by the procedure \fIrtalloc()\fR.
+This procedure will scan the kernel routing tables (stored in mbufs)
+looking for a route. A route is represented by
+.(b
+\fC
+.TS
+tab(+);
+l s s s.
+struct rtentry {
+.T&
+l l l l.
++u_long+rt_hash;+/* to speed lookups */
++struct sockaddr+rt_dst;+/* key */
++struct sockaddr+rt_gateway;+/* value */
++short+rt_flags;+/* up/down?, host/net */
++short+rt_refcnt;+/* # held references */
++u_long+rt_use;+/* raw # packets forwarded */
++struct ifnet+*rt_ifp;+/* interface to use */
+}
+.TE
+\fR
+.)b
+When looking for a route, \fIrtalloc()\fR will first hash the entire destination
+address, and scan the routing tables looking for a complete route. If a route
+is not found, then \fIrtalloc()\fR will rescan the table looking for a route
+which matches the \fInetwork\fR portion of the address. If a route is still
+not found, then a default route is used (if present). 
+.pp
+If a route is found, the entity which called \fIrtalloc()\fR can use information
+from the \fIrtentry\fR structure to dispatch the datagram. Specifically, the
+datagram is queued on the interface identified by the interface 
+pointer \fIrt_ifp\fR.
+.sh 3 "Socket code." 
+.pp
+This is the protocol-independent part of the IPC support.
+Each communication endpoint (which may or may not be associated
+with a connection) is represented by the following structure:
+.(b
+\fC
+.TS
+tab(+);
+l s s s.
+struct socket {
+.T&
+l l l l.
++short+so_type;+/* type, e.g. SOCK_DGRAM  */
++short+so_options;+/* from socket call */
++short+so_linger;+/* time to linger @ close */
++short+so_state;+/* internal state flags */
++caddr_t+so_pcb;+/* network layer pcb */
++struct protosw+*so_proto;+/* protocol handle */
++struct socket+*so_head;+/* ptr to accept socket */
++struct socket+*so_q0;+/* queue of partial connX */
++short+so_q0len;+/* # partials on so_q0 */
++struct socket+*so_q;+/* queue of incoming connX */
++short+so_qlen;+/* # connections on so_q */
++short+so_qlimit;+/* max # queued connX */
++struct sockbuf+{
+++short+sb_cc;+/* actual chars in buffer */
+++short+sb_hiwat;+/* max actual char count */
+++short+sb_mbcnt;+/* chars of mbufs used */
+++short+sb_mbmax;+/* max chars of mbufs to use */
+++short+sb_lowat;+/* low water mark (not used yet) */
+++short+sb_timeo;+/* timeout (not used ) */
+++struct mbuf+*sb_mb;+/* the mbuf chain */
+++struct proc+*sb_sel;+/* process selecting */
+++short+sb_flags;+/* flags, see below */
++} so_rcv, so_snd;
++short+so_timeo;+/* connection timeout */
++u_short+so_error;+/* error affecting connX */
++short+so_oobmark;+/* oob mark (TCP only) */
++short+so_pgrp;+/* pgrp for signals */
+}
+.TE
+\fR
+.)b
+.pp
+The socket code maintains a pair of queues for each socket,
+\fIso_rcv\fR and \fIso_snd\fR.
+Each queue is associated with a count of the number of characters
+in the queue, the maximum number of characters allowed to be put
+in the queue, some status information (\fIsb_flags\fR), and
+several unused fields.
+For a send operation, data are copied from the user's address space
+into chains of mbufs.
+This is done by the socket module, which then calls the underlying
+transport protocol module to place the data
+on the send queue. 
+This is generally done by 
+appending to the chain beginning at \fIsb_mb\fR.
+The socket module copies data from the \fIso_rcv\fR queue
+to the user's address space to effect a receive operation.
+The underlying transport layer is expected to have put incoming
+data into \fIso_rcv\fR by calling procedures in this module.
+.in -5
+.sh 3 "Transport protocol management."
+.pp
+All protocols and address types must be \*(lqregistered\*(rq in a
+common way in order to use the IPC user interface.
+Each protocol must have an entry in a protocol switch table.
+Each entry takes the form:
+.(b
+\fC
+.TS
+tab(+);
+l s s s.
+struct protosw {
+.T&
+l l l l.
++short+pr_type;+/* socket type used for */
++short+pr_family;+/* protocol family */
++short+pr_protocol;+/* protocol # from the database */
++short+pr_flags;+/* status information */
++++/* protocol-protocol hooks */
++int+(*pr_input)();+/* input (from below) */
++int+(*pr_output)();+/* output (from above) */
++int+(*pr_ctlinput)();+/* control input */
++int+(*pr_ctloutput)();+/* control output */
++++/* user-protocol hook */
++int+(*pr_usrreq)();+/* user request: see list below */
++++/* utility hooks */
++int+(*pr_init)();+/* initialization hook */
++int+(*pr_fasttimo)();+/* fast timeout (200ms) */
++int+(*pr_slowtimo)();+/* slow timeout (500ms) */
++int+(*pr_drain)();+/* free some space (not used) */
+}
+.TE
+\fR
+.)b
+.pp
+Associated with each protocol are the types of socket
+abstractions supported by the protocol (\fIpr_type\fR), the
+format of the addresses used by the protocol (\fIpr_family\fR),
+the routines to be called to perform
+a standard set of protocol functions (\fIpr_input\fR,...,\fIpr_drain\fR),
+and some status information (\fIpr_flags\fR).
+The field pr_flags keeps such information as
+SS_ISCONNECTED (this socket has a peer),
+SS_ISCONNECTING        (this socket is in the process of establishing
+a connection),
+SS_ISDISCONNECTING (this socket is in the process of being disconnected),
+SS_CANTSENDMORE (this socket is half-closed and cannot send),
+SS_CANTRCVMORE (this socket is half-closed and cannot receive).
+There are some flags that are specific to the TCP concept
+of out-of-band data.
+A flag SS_OOBAVAIL was added for the ARGO implementation, to support
+the TP concept of out-of-band data (expedited data).
+.sh 3 "Network Interface Drivers" 
+.pp
+The drivers for the devices attaching a Unix machine to a network
+medium share a common interface to the protocol
+software.
+There is a common data structure for managing queues,
+not surprisingly, a chain of mbufs.
+There is a set of macros that are used to enqueue and
+dequeue mbuf chains at high priority.
+A driver 
+delivers an indication to a protocol entity when
+an incoming packet has been placed on a queue by 
+issuing a
+software
+interrupt.
+.sh 3 "Support for individual protocols." 
+.pp
+Each protocol is written as a separate functional unit.
+Because all protocols share the clock and the mbuf pool, they
+are not entirely insulated from each other.
+The details of TP are described in a section that
+follows.
+.\"*****************************************************
+.\" FIGURE
+.so figs/unix_ipc.nr
+.pp
+.CF
+shows the arrangement of the IPC  support.
+.pp
+The AOS
+IPC was designed for DoD Internet protocols, all of
+which run over DoD IP.
+The assumptions that DoD Internet is the domain
+and that DoD IP is the network layer 
+appear in the code and data structures in numerous places.
+For example, it is assumed that addresses can be compared
+by a bitwise comparison of 4 octets.
+Another example is that the transport protocols all directly call
+IP routines.
+There are no hooks in the data structures through
+which the transport layer can choose a network level protocol.
+A third example is that the host's local addresses
+are stored in the network interface drivers and the drivers
+have only one address - an Internet address.
+A fourth example is that headers are assumed to
+fit in one small mbuf (112 bytes for data in AOS).
+A fifth example is this:
+It is assumed in many places that buffer space is managed
+in units of characters or octets.
+The user data are copied from user address space into the kernel mbufs
+amorphously
+by the socket code, a protocol-independent part of the kernel.
+This is fine for a stream protocol, but it means that a
+packet protocol, in order to \*(lqpacketize\*(rq the data,
+must perform a memory-to-memory copy
+that might have been avoided had the protocol layer done the original
+copy from user address space.
+Furthermore, protocols that count credit in terms of packets or
+buffers rather than characters do not work efficiently because
+the computation of buffer space is not in the protocol module,
+but rather it is in the socket code module.
+This list of examples is not complete.
+.pp
+To summarize, adding a new transport protocol to the kernel consists of
+adding entries to the tables in the protocol management
+unit, 
+modifying the network interface driver(s) to recognize
+new network protocol identifiers, 
+adding the
+new system calls to the kernel and to the user library,
+and
+adding code modules for each of the protocols,
+and correcting deficiencies in the socket code,
+where the assumptions made about the nature of 
+transport protocols do not apply.