--------------------------------------------------------------------------- Mohamed G. Gouda CS 356 Spring 2018 Homework 2 --------------------------------------------------------------------------- 1. (5 points) A client-server application is deployed on top of UDP in two hosts ch and sh. The client is deployed on top of UDP in ch and the server is deployed on top of UDP in sh. Execution of this application proceeds as follows. First the client sends an application msg m to UDP in ch. Then, UDP in ch adds a UDP header to msg m forming a UDP segment s and sends s. Eventually, segment s arrives at UDP in sh which removes the UDP header from s and forwards the the resuting application msg m to the application server in sh. The application server in sh prepares a reply m' to msg m and forwards m' to UDP in sh. UDP in sh adds a UDP header to m' forming a UDP segment s'. Eventually, segment s' arrives at UDP in ch which removes the UDP header from s' and forwards the resulting reply m' to the application client in ch. The transfer of segments between UDP in ch and UDP in sh is "best effort". Thus, segment s can be lost (or corrupted and later discarded) after it is sent by UDP in ch and before it is received by UDP in sh. Similarly, segment s' can be lost (or corrupted and later discarded) after it is sent by UDP in sh and before it is received by UDP in ch. (a) Explain how does the loss of s or s' lead the communication between the client and server to a "deadlock state". (b) Show that the client in this application can be modified such that the loss of s or s' does not lead the communication between the client and server to a "deadlock state". ------------------------------------------------------------------------ 2. (5 points) Consider a TCP connection between two sides src and dst. Side src sends data segments to dst and side dst sends ack segments to src. Each data segment Di sent from src to dst has 64 data bytes. Consecutive data bytes in the data byte stream from src to dst have consecutive sequence numbers that start with the sequence number 32. Each data segment Di has a seq# which is the sequence number of the first data byte in Di. Each ack segment Ai has an ack# which is the sequence number of the next data byte expected to be received by dst when Ai is sent (from dst to src). Consider the following five-step scenario of this connection, where two data segments D1 and D2 are sent from src to dst, and where two ack segments A1 and A2 are sent from dst to src: 1. src sends D1 to dst but D1 is lost 2. src sends D2 to dst 3. dst sends A1 to src 4. src times out and resends D1 to dst 5. dst sends A2 to src (a) What are the values of seq#'s in D1 and in D2 (b) What are the values of ack#'s in A1 and in A2 ------------------------------------------------------------------------- Solutions ------------------------------------------------------------------------- 1. (a) The loss of s or s' causes the client to wait indefinitely to receive the reply msg m' which will never arrive. In other words, the communication between the client and server reaches a deadlock state. (b) Consider the value (T1 + T2) where T1 is an upper bound on the time needed to compute msg m and to transfer it from the client to the server, and T2 is an upper bound on the time needed to compute msg m' and to transfer it from the server to the client. Now, modify the client to wait at most (T1 + T2) time units after it sends msg m and before it receives the reply m'. If the time period (T1 + T2) expires before the client rcvs m', then the client is sure that either s or s'is lost and so it resends msg m (one more time). THerefore, the communication between the client and server never reaches a deadlock state. -------------------------------------------------------------------------- 2. (a) The value of seq# in D1 is 32 The value of seq# in D2 is 96 (b) The value of ack# in A1 is 32 The value of ack# in A2 is 160 -------------------------------------------------------------------------- '.