------------------------------------------------------------------------------- Mohamed G. Gouda CS 356 Spring 2007 Homework 2 ------------------------------------------------------------------------------- 1. (4 points) Design a full-duplex connection protocol between two processes p and q. Each of the two proceses has two boolean variables conr and cons, where conr stands for connection-to-receive (data messages) from the other process and cons stands for connection-to-send (data messages) to the other process. Initially the two conr variables and the two cons variables are false. When process p sends a crqst message to q and receives back crply, it assigns its conr and cons the value true and starts to send and receive data messages. Later process p assigns cons the value false, stops sending data messages (but still accepts received data messages), and starts sending drqst messages to q. When p receives drply messages from q, it assigns its conr and cons the value false. When process q receives a crqst message from p, it can assign its conr the value true and send a crply message to p. It can also assign its conr the value false and assign its conr and cons the value false. When q receives a data message from p and its conr has the value true, it assigns its cons the value true. When cons in process q has the value true, q can send data messages to process p. Finally, when q receives a drqst message from p, q assigns its conr and cons the value false and sends a drply message to p. Specify processes p and q in this protocol. ------------------------------------------------------------------------------- 2. (3 points) The corruption detection protocol in section 8.1 is bit-based. It is required to modify this protocol to make it byte-based. For example, in the modified protocol, a data block consists of m*n data bytes and the parity added to each data block consists of n parity bytes. Also, each message sent from p to q is of the form byte(u), where u is in the range 0..255. The data and parity arrays in process p in the modified protocol are specified as follows: inp dp : array[integer] of 0..255 var pp : array[0..n-1] of 0..255, Both p and q use a function xor defined as follows: u := xor(v,w) where each of u,v and w is in the range 0..255 and xor returns the bit-wise exclusive-or of the two bytes v and w. Specify process p in the modified protocol. ------------------------------------------------------------------------------- 3. (3 points) Design a protocol for forward recovery from n-bounded re-order. Process p in this protocol sends data(t,s) messages to process q where t is an integer that represents the message text and s is a sequence number in the range 0..(2n-1). The data structure of process p in this protocol is as follows: process p const n inp txt : array[integer]of integer var i : integer, {index of txt, init. 0} s : 0..(2n-1) {seq. number of next message, init. 0} The data structure of process q in this protocol is as follows process q const n var txt : array[integer]of integer, i : integer, {index of txt, init. 0} exp : 0..(2n-1), {seq. # of exp. message init. 0} bff : array[0..(2n-1)] of boolean, {init. false} rcvt : array[0..(2n-1)] of integer, {received text out of order} t : integer, {received text} s : 0..(2n-1) {received seq. number} Specify processes p and q in this protocol. -------------------------------------------------------------------------------