Homework 9 Solutions

22C:116, Fall 1998

Douglas W. Jones
  1. Part A: The following messages placed in the transport-in queue:
    ( new-session, session-id, queue-id )
    ( end-session, session-id )
    ( datagram, session-id, data )
    
    The following messages are placed in the network-in queue:
    ( datagram, network-address, (session-id, data) )
    
    The following messages are placed in the session-in queues:
    ( datagram, data )
    
    Note that the network layer need not understand that the session-id is included with the data, but it must be there, and at the far end of the net, the network layer must deliver the session-id along with the data to the transport layer. It may be convenient to use a uniform format for all datagrams in all queues, so the session-id and network-address may be included in datagrams placed in the session-in queue, and the network-address may be included with datagrams placed in the transport-in queue. These extra fields would simply be ignored in these contexts, with their values treated as meaningless or undefined.

    Part B: A crucial detail has been omitted from the specification for this problem! No mention was made of how a session is established -- that is, no mention was made of messages sent through the transport layer and used to establish connections between the session layer on one machine and the session layer on another machine elsewhere in the network.

  2. A client-server interaction involves the creation of a brief connection or session between client and server. One way to do this would be to use sockets to create a temporary session. So, the client would operate as follows:
    	use socket() to create a SOCK_STREAM socket
    	use connect() to connect the socket to a the RPC server
    	use write() to send the RPC parameters to the server
    	use read() to read the results
    	use close() to terminate the conneciton
    
    The server would operate as follows:
    	repeat the following:
    	  use socket() to create a SOCK_STREAM socket
    	  use accept() to allow a client to connect to this server
    	  use read() to read RPC parameters from the client
    	  call the procedure
    	  use write() to return results to the client
    	  use close() to terminate the connection
    

  3. Problem 11 on page 461 of the text asks how to locate the first byte of a message, given that the order of the bytes in a word varies from machine to machine. The answer is that messages are always sent in byte sequential form, so the first byte sent will be the first byte received. If the sending machine stores bytes low-to-high in a word, then the first byte sent will be the low byte of the first word of the message. If the receiving machine stores bytes in high-to-low order, the first byte received will be the high byte of the first word. The position of the first byte in the first word of the message depends only on the local machine! Furthermore, if the message buffer is addresses as an array of characters instead of as an array of words, the first byte will always be byte 0 of the buffer!

  4. Problems 13 on page 461 of the text asks if writing the first block of a file is an idempotent operation. Yes it is. If this write operation is repeated, the result is the same as if it had been done only once.

    Problems 14 on page 461 of the text asks:

    Part A Is reading and writing files on a server idempotent? Yes.

    Part B Is compiling a program idempotent? Yes.

    Part C Are remote banking transactions idempotent? No!