Each field in the basic Kermit packet is one character long, except the data field, as shown Figure 9-40. The fields are: Kermit Packet Format ==================== +------+------+------+------+------ - - - --+-------+ | MARK | LEN | SEQ | TYPE | DATA | CHECK | +------+------+------+------+------ - - - --+-------+ Figure 9-40 MARK A single control character that marks the beginning of the ==== packet, Control-A (SOH, ASCII 1) by convention, but it may be redefined. LEN The number of characters within the packet that follow this === field, up to and including the check field, in excess-32 notation. In basic Kermit, this number ranges from 3 (#) when the data field is empty to 94 (~) when the data field contains the maximum of 91 characters. LEN The number of characters within the packet that follow this === field, up to and including the check field, in excess-32 notation. In basic Kermit, this number ranges from 3 (#) when the data field is empty to 94 (~) when the data field contains the maximum of 91 characters. TYPE The packet type, a single literal ASCII character from among ==== those shown in Table 9-14, or others to be presented later. A complete list is given in Appendix C. DATA The contents of the packet, if any contents are required in ==== the given type of packet, encoded or interpreted according to the packet type, and encoding options in effect. CHECK A block check on the characters in the packet between, but not ===== including, the mark and the block check itself. A single- character arithmetic checksum is the normal block check, and all Kermit programs must support it. Only six bits of the arithmetic sum are included, and only eight bits are required to accumulate and calculate it. So that all the bits of each data character contribute to this quantity, bits 6 and 7 of the final value are added to the quantity formed by bits 0-5. Thus if s is the arithmetic sum of the ASCII characters, CHECK = tochar((s + ((s & 192)/64)) & 63) where "&" is the bitwise AND operator. The block check is based on the values of all the characters in the packet, starting with LEN and ending with the final character in the DATA field (or if the DATA field is empty, the packet type). The high-order bit is not included if it is being used for parity, but it is included if it is being used for data. Basic Kermit Packet Types ========================= S Send Initiation. I'm about to send files, and here are my parameters. F File Header, the name of the file which is about to come. D File Data. Z End of File. B Break Transmission, end of transaction. Y Acknowledgment N Negative Acknowledgment E Fatal Error Table 9-14 Packet Types ============ Y Acknowledgment (ACK). Data according to what kind of packet is being acknowledged. N Negative Acknowledgment (NAK). Data field always empty. S Send Initiation. Data field contains unencoded initialization string. Tells receiver to expect files. ACK to this packet also contains unencoded initialization string. I Initialize. Data field contains unencoded initialization string. Sent to server to set parameters prior to a command. ACK to this packet also contains unencoded initialization string. F File Header. Indicates file data about to arrive for named file. Data field contains encoded file name. ACK to this packet may contain encoded name receiver will store file under. X Text Header. Indicates screen data about to arrive. Data field contains encoded heading for display. A File Attributes. Data field contains unencoded attributes. ACK may contain unencoded corresponding agreement or refusal, per attribute. D Data Packet. Data field contains encoded file or screen data. ACK may contain X to interrupt sending this file, Z to interrupt entire transaction. Z End of file. Data field may contain D for Discard. B Break transmission. E Error. Data field contains encoded error message. R Receive Initiate . Data field contains encoded file name. C Host Command. Data field contains encoded command for host's command processor K Kermit Command. Data field contains encoded command for Kermit command processor. T Timeout psuedopacket, for internal use. Q Block check error psuedopacket, for internal use. G Generic Kermit Command. Data field contains a single character subcommand, followed by zero or more length-encoded operands, encoded after formation: I Login [<%user[%password[%account]]>] For use when a Kermit server is kept perpetually running on a dedicated line. This lets a new user obtain an identity on the server's host system. If the data field is empty, the user's identity and file access rights are removed, and the server is left waiting for a new login command. C CWD, Change Working Directory [<%directory[%password]>] This sets the default directory or area for file transfer on the server's host. With no operands, this command sets the default area to be the user's own default area. L Logout, Bye This shuts down the server entirely, causing the server itself to log out its own job. This is for use when the server has been started up manually by the user, who then wishes to shut it down remotely. For a perpetual dedicated server, this command is equivalent to an empty login command. F Finish (Shut down the server, but don't logout) Tops-20 exits to the EXEC, but can continue. D Directory [<%filespec>] Send a directory listing to the user. The user program can display it on the terminal or store it in a file, as it chooses. The directory listing should contain file sizes and creation dates as well as filenames, if possible. A wildcard or other file-group designator may be specified to ask the server to list only those files that match. If no operand is given, all files in the current area should be shown. U Disk Usage Query [<%area>] The server responds with the amount of space used and the amount left free to use, in K bytes (or other units, which should be specified). E Erase (delete) <%filespec> The response may be an empty ACK, an ACK with data, or an entire transaction. T Type <%filespec> Sends the specified file or file group, indicating (by starting with an X packet rather than an F packet, or else by using the Type attribute) that the file is to be displayed on the screen rather than stored on disk. R Rename <%oldname %newname> Changes the name of (or moves) the file or files as indicated. The string indicating the new name may contain other attributes, such as protection code, permitted in file specifications by the host. K Copy <%source %destination> Produces a new copy of the file or file group, as indicated, leaving the source file(s) unmodified. W Who's logged in? [<%user ID or network host[%options]>] With no arguments, lists all the users who are logged in on the server's host system. If an argument is specified, provides more detailed information on the specified user or network host. M Send a short Message <%destination%text> Send the given short (single-packet) message to the indicated user's screen. H Help [<%topic>] Tops-20 parses nothing and gives a canned response Q Server Status Query Not defined P Program <%[program-filespec] [%program-commands]> This command has two arguments, program name (filespec), and command(s) for the program. The first field is required, but may be left null (zero length). If it is null, the currently loaded program is specified program is loaded and started. If a program command is given, it is fed to the program as an initial command (for instance, as a command line argument on systems that support that idea). In any case, the output of the program is sent back in packets as either a long or short reply, as previously described. J Journal <%command[%argument]> This command controls server transaction logging. The data field contains one of the following: + Begin/resume logging transactions. If a filename is given, close any currently open transaction and then open the specified file as the new transaction log. If no name is given, but a log file was already open, resume logging to that file. If no filename was given and no log was open, the server should open a log with a default name, like TRANSACT.LOG. The filename should be returned in the ACK. - Stop logging transactions, but don't close the current transaction log file. C Stop logging and close the current log. Transaction logging is the recording of the progress of file transfers. It should contain entries showing the name of each file transferred, when the transfer began and ended, whether it was completed successfully, and if not, why. V Variable <%command[%argument[%argument]]> The command can be S or Q. The first argument is the variable name. The second argument, if any, is the value. S Set the specified variable to the specified value. If the value is null, then undefine the variable. If the variable is null then do nothing. If the variable did not exist before, create it. The server should respond with an ACK if successful, and Error packet otherwise. Q Query the value of the named variable. If no variable is supplied, display the value of all active variables. The server responds with either a short or long reply, as described above. If a queried variable does not exist, a null value is returned.