------------------------------------------------------------------------------ Mohamed G. Gouda Midterm 3 CS 356: Computer Networks Summer 2007 ------------------------------------------------------------------------------ Open Book 60 Minutes ------------------------------------------------------------------------------ 1. (10 points) The processes in a network p[i:0..n-1] are arranged in a unidirectional ring, where there is one channel from each process p[i] to process p[i +n 1]. Thus, each p[i] can receive messages only from p[i -n 1] and can send messages only to p[i +n 1]. The processes circulate only one chk message around the ring, and when this message is lost, process p[0] generates a new chk message that circulates around the ring. Each process p[i] has a boolean variable "up" whose value is assigned true, when and only when all the channels in the network are up. The processes in this network are specified as follows: process p[i : 1..n-1] var up : boolean, b : 0..1 begin rcv chk(b) from p[i -n 1] -> S.0 [] rcv error from p[i -n 1] -> skip [] timeout (Forall i, 0 <= i < n, #ch.p[i].p[i +n 1] = 0) -> S.1 end process p[0] const n var up : boolean, b : 0..1 begin rcv chk(b) from p[n-1] -> S.2 [] rcv error from p[n-1] -> skip [] timeout (Forall i, 0 <= i < n, #ch.p[i].p[i +n 1] = 0) ^ (Forall i, 1 <= i < n, up.p[i] = false) -> S.3 end Specify statements S.0, S.1, S.2, S.3. ------------------------------------------------------------------------------ 2. (10 points) A network p[i : 0..m-1, j : 0..n-1] consists of m regions of n processes each. The processes in this network generate data(x,y) messages and route them to their ultimate destinations, using hierarchical routing. The ultimate destination of each data(x,y) message is process p[x,y]. In each region i, process p[i,0] is "the gateway". This means that data messages that enter or leave region i do so by going through process p[i,0]. The gateways for each pair of regions are neighbors. Thus a data(x,y) that is generated in region i first travels in region i until it reaches p[i,0], then goes to p[x,0], then travels in region x until it reaches p[x,y]. A process in this network is specified as follows. process p[i : 0..m-1, j : 0..n-1] inp N : set{(i',j') | p[i',j'] is a neighbor of p[i,j]} up : array [N] of boolean prs : array [0..n-1] of N var x : 0..m-1, y : 0..n-1 par g : N begin true -> x, y := any, any; RTMSG [] rcv data(x,y) from p[g] -> RTMSG end Specify statement RTMSG. ------------------------------------------------------------------------------