Douglas W. Jones
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.
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