------------------------------------------------------------------------------ Mohamed G. Gouda Midterm 1 CS 356: Computer Networks Spring 2007 ------------------------------------------------------------------------------ Open Book 80 Minutes ------------------------------------------------------------------------------ 1. (10 points) Design an array of two processes p[i:0..1] that exchange data messages. The exchange of data messages is assumed to be error-free At each instant the number of data messages sent by p[0] is no more than 5 plus the number of data messages sent by p[1], and the number of data messages sent by p[1] is no more than 7 plus the number of data messages sent by p[0]. A sketch of the process array is as follows: process p[i:0..1] inp n : integer {n.p[0]=5 and n.p[1]=7} var ... begin ... end ------------------------------------------------------------------------------ 2. (10 points) Consider a network that consists of two processes p and q. Process p sends an infinite sequence of data messages to process q, and q sends back an ack message for each data message that it receives from p. Data and ack messages can be lost but are neither corrupted nor re-ordered. The data messages have alternating sequence numbers in the range 0..1. Thus the sequence of data messages sent by p is as follows: data(0); data(1); data(0); data(1); ... After process p sends a data(b) message to process q, p waits until one of the following two events happens: either p receives an ack message from q, and in this case p sends the next data(1-b) message to q and the cycle repeats or p detects that the sent data(b) message or the corresponding ack message is lost and in this case p re-sends the data(b) message to q, and the cycle repeats. Specify processes p and q in this protocol. ------------------------------------------------------------------------------