Homework 7

22C:116, Fall 1997

Due Monday Oct. 27, 1997, in class

Douglas W. Jones

    The Following list gives the ASCII control characters, sorted with comments about the levels in the ISO protocol to which they appear to belong:

    NULL 00 ^@
    Any layer will do; it can be ignored by all layers!

    SOH 01 ^A
    STX 02 ^B
    ETX 03 ^C
    EOT 04 ^D
    ETB 17 ^W
    data-link layer for bus-structured links (like Ethernet).
    network layer, if addresses name machines.
    transport layer, if addresses name logical recipients.

    ENQ 05 ^E
    ACK 06 ^F
    NAK 15 ^U
    CAN 18 ^X
    the data link layer, network layer or transport layers could all use these for flow control or error correction.

    BEL 07 ^G
    presentation layer.

    BS 08 ^H
    HT 09 ^I
    LF 0A ^J
    VT 0B ^K
    FF 0C ^L
    CR 0D ^M
    presentation layer.

    SO 0E ^N
    SI 0F ^O
    presentation layer.

    DLE 10 ^P
    SUB 1A ^Z
    appropriate at any layer below the applications layer where a control character used at a higher level must be recoded to avoid conflict with lower layer uses of that character.

    DC1 11 ^Q
    DC2 12 ^R
    DC3 13 ^S
    DC4 14 ^T
    these appear to be application layer tools, since they're very specific to the old teletype hardware that supported them.

    SYN 16 ^V
    clearly a data link layer issue.

    EM 19 ^Y
    possibly applicable at the data link layer.

    ESC 1B ^[
    possibly the most appropriate uses are at the application level

    FS 1C ^\
    GS 1D ^]
    RS 1E ^^
    US 1F ^_
    these appear to be strictly applicable to the application level

  1. Here is an implementation outline for the classic ASCII based protocol suite based on SOH address STX message ETX trailer EOT, with an ENQ/ACK/NAK protocol used for flow control and error detection. This assumes a network with point-to-point asynchronous message links, where each machine has multiple links to other machines.

    Because we assume that messages is of fixed maximum size, each machine can have a buffer pool, where each buffer is big enough to hold one message. Each buffer will have the following fields:

       address -- the machine to which the message is addressed
       length -- the length of the message
       msg -- the text of the message (fills most of the buffer!)
    
    Each bidirectioal asynchronous link L is associated a queues of buffers, L.out, holding messages to be transmitted on L. In addition, a single queue of messages net.in, holds messages awaiting routing by the network layer, and host.in holds messages addressed to this host from the network layer. The overall structure of the system is as follows:
                            Higher Levels
                 hostput()              --> hostget()
                    |                  |
                    |               host.in
                    V                  |
             --> net.in --> router ---> 
            |                          |
            |                       link.out
       .... | .......................  |  .........
            |                          V
        link input  -- linkstat -> link output
            ^       ----               |
            |            \             |
        serial.in          ------> serial.out
            |                          |
            |                          V
       serial input              serial output
      service routine          interrupt service 
    
    The hostput routine awaits a free buffer, assembles the message into it, and puts the message in the net.in queue. The hostget routine blocks awaiting a message from the host.in queue, returns it to the caller, and returns the buffer to the free buffer pool.

    The router is a process that awaits messages in the net.in queue and then puts them in the appropriate queue. Messages addressed to this site get put in the host.in queue, all others go into the queue for some link, where the particular link used depends on the routing algorithm. If the network is small and has a fixed topology, each router could keep a table giving the outgoing link to use for each network address.

    The serial input and output interrupt service routines for each link communicate with higher layers through FIFO queues of characters. Above this level, the link layer consists of two processes, a link input process and a link output process.

    The link output process takes messages from the link.out queue and forms them into a stream of characters on the serial.out queue, using SOH, STX, ETX etc to format them, and sending an ENQ at the end of each message to find out if it was received correctly. After this, it awaits an ACK or NAK on the linkstat queue, and retransmits after NAK, or sends the next message after ACK.

    The link input process receives characters from the serial.in queue. It recognizes ACK and NAK responses from the remote link input process and places them in the linkstat queue, and it extracts messages from the stream to place into the net.in queue. On receipt of an ENQ, if the previous message was received correctly and successfully placed in the net.in queue, it sends an ACK in the serial.out queue. If the checksum didn't match or if something prevented it from putting the message in the net.in queue, for example, if there were no buffers available, it responds with NAK.

  2. Background Consider the idea that a server in a client-server system can be thought of as implementing the semantics of a single object O of class C with methods M1, M2, M3, etc. in an object oriented design. Calls to methods of O become RPC calls to routines in the server.

    The Problem, part A Given code to implement the class C, outline the code for a "wrapper" that converts this code into a server.

        server wrapper
            create instance O of class C
            repeat
                await message
                break message into 
                case type of
                 1: result = O.M1(body)
                 2: result = O.M2(body)
                 3: result = O.M3(body)
                end case
                send result to return-addr
            forever
    
    The Problem, part B Outline the code for a stub version of class C that could be used by clients to communicate with your wrapper.
        class Cstub
            state
                server-address
    
            initialization
                find server-address of wrapper
    
            method M1(params)
                send  to server-address
                await result
                return result
    
            method M2(params)
                send  to server-address
                await result
                return result
    
            method M3(params)
                send  to server-address
                await result
                return result