------------------------------------------------------------------------------ Mohamed G. Gouda CS 356 Spring 2014 Homework 2 ------------------------------------------------------------------------------ 1. (A Connection Protocol) (7 points) Consider a network that consists of one process array p[i: 0..n-1] and one process q. Each process p[i] in the process array can attempt to establish a connection with process q, but process q cannot at any instant accept to be participating in more than r connections, where n >= r. Thus if process q receives a crqst message from a process p[i] when q is participating in r connections, then q sends back a drply message, otherwise q sends back a crply message. Specify the processes p[i: 0..n-1] and q using the AP notation. 2. (A Corruption-Detection Protocol) (3 points) Show that there is an integer r such that the corruption-detection protocol discussed in class will not detect any corruption burst of length r in a block of m*1 data bits. Solution 1. process p[i : 0..n-1] inp m : integer var conp:boolean {init false} cansnd: 0..m begin timeout ~conp ^ ((#ch.p[i].q + #ch.q.p[i]) = 0) --> send crqst to q [] rcv crply from q --> conp, cansnd := true, m [] conp --> if cansnd>0 --> send data to q; cansnd := cansnd-1 [] true --> send drqst to q; cansnd := 0 fi [] rcv drply from q --> conp := false [] rcv error from q --> skip end process q const n inp r: integer {n>=r} var conq: array[0..n-1] of boolean cancon: 0..r {init. r} par j : 0..n-1 begin rcv crqst from p[j] --> if conq[j] --> send crply to p[j] [] ~conq[j] ^ cancon=0 --> send drply to p[j] [] ~conq[j] ^ cancon>0 --> conq[j], cancon := true, cancon-1 send crply to p[j] fi [] conq[j] --> conq[j], cancon := false, cancon+1 [] rcv data from p[j] --> if conq[j] --> {store data} skip [] ~conq[j] --> {discard data} send drply to p[j] fi [] rcv drqst from p[j] --> if conq[j] --> conq[j], cancon := false, cancon+1 [] ~conq[j] --> skip fi; send drply to p[j] [] rcv error from p[j] --> skip end 2. The block consists of m*1 data bits and one parity bit. Thus, the block has only one column. If r=2 then, each corruption burst of length 2 consists of exactly two consecutive bits and the corruption burst will not be detected by the parity bit.