------------------------------------------------------------------------------ Mohamed G. Gouda Midterm 2 CS 356: Computer Networks Spring 2007 Solution ------------------------------------------------------------------------------ 1. (7 points) (The solution below corresponds to the interpretation where p can connect to multiple q[i]'s, but only one connection per q[i]). process p const n inp m : integer var conp : array[0..n-1] of boolean, {init false} cansnd : array[0..n-1] of 0..m par i : 0..n-1 begin timeout ~conp[i] ^ (#ch.p.q[i]+#ch.q[i].p=0) -> send crqst to q[i] [] rcv crply from q[i] -> conp[i] := true; cansnd[i]:=m; [] conp[i] -> if cansnd[i]>0 -> send data to q[i]; cansnd[i]:=cansnd[i]-1 [] true -> send drqst to q[i]; cansnd[i] := 0 fi [] rcv drply from q[i] -> conp[i] := false end ------------------------------------------------------------------------------ 2. (7 points) Length of shortest burst: n This occurs when exactly n consecutive bits are corrupted, which can be counted as the first n and the last n, with no uncorrupted bits between them. Length of the longest burst: 2n-1 The longest possible n-bracketed error can occur when the first n and the last n bits of the entire block of m*n and the n parity bits is corrupted, however this will cause two bits in every column to be corrupted. For the protocol in section 8.1 to work in this case, there must be at least one column with a single error, which is guaranteed if the length of the burst is less than 2n, and is sufficient to discard the entire block. ------------------------------------------------------------------------------ 3. (6 points) process p const w var na : array[0..1] of integer, {init. 0} ns : array[0..1] of integer, {init. 0} i : integer par j : 0..1 begin (ns[0]-na[0]) + (ns[1]-na[1]) < w -> send data(ns[j]) to q[j]; ns[j] := ns[j] + 1 [] rcv ack(i) from q[j] -> na[j] := max( na[j], i); [] timeout na[j] send data(na[j]) to q[j] [] rcv error from q[j] -> skip end