------------------------------------------------------------------------------ Mohamed G. Gouda CS 356 Spring 2014 Midterm 2 ------------------------------------------------------------------------------ (A Connection Protocol) 1. (10 points) Modify the connection protocol discussed in class such that process p can send any number of data messages to process q once process p's connection to q has been accepted. Specify process p in the modified protocol using the AP notation. 2. (8 points) Modify the connection protocol discussed in class such that process q cannot remove any connection from p (once this connection has been accepted by q), unless process p requests that the connection be removed. Specify process q in the modified protocol using the AP notation. 3. (2 points) Consider the corruption detection protocol discussed in class. Assume that the total number of corrupted bits in a data block sent from p to q is even. Will the corruption detection protocol be able to detect the corruption in this case? Explain your answer. Solutions: 1. process p var conp:boolean {init false} cansnd: 0..1 begin timeout ~conp ^ ((#ch.p.q + #ch.q.p) = 0) --> send crqst to q [] rcv crply from q --> conp, cansnd := true, 1 [] conp --> if cansnd>0 --> send data to q [] true --> send drqst to q; cansnd := 0 fi [] rcv drply from q --> conp := false [] rcv error from q --> skip end 2. process q var conq: boolean {init. false} begin rcv crqst from p --> if true --> conq := true; send crply to p [] true --> conq := false; send drply to p fi [] rcv data from p --> if conq --> {store data} skip [] ~conq --> {discard data} skip fi [] rcv drqst from p --> conq := false; send drply to p [] rcv error from p --> skip end 3. It is possible that the corrupted bits occur in different columns, such that each column has an even number of corrupted bits. In this case, the corruption detection protocol cannot detect the occurrence of corruption. However, if the corrupted bits occur in different columns, such that two or more of these columns have an odd number of corrupted bits, then the corruption detection protocol will detect the occurrence of corruption.