CS 487 Solution for Homework # 2 By: Gabriela Barrantes 9/16/00 ============================================================================================== 2.1 (i) The monitor thing was a typical small research question. (ii) Let R be the bit rate of the radiologists' link, and let's use the 24 bit grayscale. R = (1000 x 1000 x 24 b) / (10 s) = 2,400,000 bps = 2.4 Mbps (iii) Let T be the rate if a 10 min. delay is acceptable. T = (1000 x 1000 x 24 b) / (10 x 60 s) = 40,000 bps = 0.04 Mbps Let S be the storage space we will need to store the X ray: S = 1000 x 1000 x 24 b = 24 Mbits Difference in rates between the two schemes: B = T - R = 2.4 Mbps - 0.04 Mbps = 2.36 Mbps Let Bc be te COST to increase the bit rate by 1 Mbps Let Sc be the COST of 1 Mbit of storage space The total data rate increase will be B = 2.36 Mbps The cost of this increase will be B x Bc = 2.36 x Bc The storage space that will be needed if we won't increase the data rate is S = 24 Mbits The cost of this space will be S x Sc = 24 x Sc We are told that r = Bc / Sc ( ==> Bc = r x Sc) So, in short, what we are to find out are the conditions on r so 24 x Sc > 2.36 x Bc So we solve the inequality: 24 x Sc > 2.36 x r x Sc ==> 24 / 2.36 > r ==> r > 10.17 For any r > 10.17 the cost of storage is such that the decrease in bit rate will be advantageous. For the 16 bit grayscale the results will be (ii) 1.6 Mbps (iii) r > 10.2 ========================================================================== 2.5 (a) n(n-1) if links are unidirectional (n-1) + (n-2) + ... + 1 = n(n-1)/2 if links are bidirectional (b) We will assume that the arrangement is linear, so the first and last hubs are NOT connected to each other directly. All hubs except those two will have available only 4 ports for computers, because 2 will be used for the hub-to-hub connection. The number of hubs we need is: 1 if n <= 2 trunc(n/4) + if (n % 4) <= 2 (the remaining machines can go on the first and last hubs) ceiling(n/4) if (n % 4) > 2 This is for a linear model of interconnecting the hubs If we were to use a tree-like structure of hubs, where there would be computers only on the leafs, we will need 1 hub if n<=6, and ceiling(n/5) + ceiling(ceiling(n/5)/5) + ... hubs if n>6. For example if n=100, we'll need 20 hubs to connect 5 nodes each. Those 20 are connected by 4 hubs of 5 hubs each. And these are connected among them for yet another hub. ========================================================================== 2.6 (a) Notice that if no link fails, or one link fails, all nodes can still communicate. However, no matter what two links we remove, the graph will lose connectivity. Note: as a simple text convention I am using (A B) to denote "Choose B out of A". (A B) = A!/(A-B)!B! p(all connected) = p(0 links failing) + p(1 link failing) = (1-p)^6 + (6 1) x p x (1-p)^5 = (1-p)^6 + 6 x p x (1-p)^5 (b) For any N, the conditions still don't change: we can afford to lose only 0 or 1 links in order to remain connected. p(all connected) = p(0 links failing) + p(1 link failing) =(1-p)^N +(N 1) x p x (1-p)^(N-1) = (1-p)^N + N x px(1-p)^(N-1) (c) Notice that this is a conditional probability. Also the answer is for the EXACT configuration of the figure. I am also assuming that EXACTLY TWO links failed. If you suppose that two or more links failed, the answer will be different. Number of cases whe exactly two links fail: (6 2) = 15 p(exactly two links fail) = 15 p^2 (1-p)^4 p(A & B can communicate/two links have failed) = p(the two upper links failed/two links failed) + p(two of the lower links failed/two links failed) = [( p^2(1-p)^4 + (4 2)p^2(1-p)^4 ) ] / [15 x (p^2 (1-p)^4) ] = 7/15 Another interpretation: = 1 - p(A & B can't communicate/two links have failed) A & B cant' communicate in the following case: if one of the upper links failed and one of the lower links failed: (2 1) x (4 1) = 2 x 4 = 8 So, = 1 - p(A & B can't communicate/two links have failed) = 1 - p^2 x (1-p)^4 x 8/ 15 (p^2 (1-p)^4) = 7/15 (d) There where two ways of interpreting this exercise. One was to assume a static graph, with no disconnecting links, and the objective of the exercis e being to discover the minimum path length between any two nodes. In this case, we have 5 possible path lengths: 1,2,3,4 and 5 The distribution was: 2/5 if d = 1 p(D=d) = 2/5 if d = 2 1/5 if d = 3 0 otherwise The other possibility was to continue with the general mood of the exercise and to assume we were working with the specific case of A & B, and work with conditional probabilities. =============================================================================== 2.7 (a) We can loose 1, or 2 links and still be connected. However, we can find cases where the loss of three links disconnect a node. So, the answer is 3. (b) p(losing connectivity) = p(losing connectivity with 1 failed link) + p(losing connectivity with 2 failed links) +... + p(losing connectivity with 9 failed links) = 0 + 0 + p(losing connectivity with 3 failed links) + ... + p(losing connectivity with 9 failed links) So: 3 failed links -------------- We loose connectivity with 3 failed links only if the three links that are lost are the three around a node, so p(losing connectivity at 3 failed links) = (6 1) p^3 (1-p)^6 4 failed links -------------- Now, in order to loose connectivity with 4 links, we are confronted with several non overlapping cases: isolating one node: if three are around a node and the fourth is lost elsewhere (one out of 6 nodes to be isolated)(one out of the remaining 6 links) = (6 1)(6 1) cases isolating a group of 2 nodes: the only way to isolate them is if they are directly connected and we should disconnect, on each node, the two links that are NOT connecting them (a total of four). If the two nodes are not directly connected, the required number of disconnexions to isolate them is 5. (pick a group of two directly connected nodes) x (the only way to disconnect then) = (Number of links 1) = (9 1) = 9 cases isolating a group of 3 nodes: there is no way to isolate a group of 3 nodes from the other 3 given that the number of links connecting the group to the rest of the graph is higher than 4. so, p(losing connectivity at 4 links failing) = (6 1)(6 1) p^4 (1-p)^5 + (9 1) p^4 (1-p)^5 = 45 p^4 (1-p)^5 five to nine failing links -------------------------- From 5 failing links on, the number of links remaining on the graph drops to 4 and less, so there is no way for it to stay connected, no matter which links we pick to elliminate. This simplifies a lot the case calculation: p(losing connectivity at 5, 6, 7, 8 or 9 links failing) = = (9 5) p^5 (1-p)^4 + (9 6) p^6 (1-p)^3 + (9 7) p^7 (1-p)^3 + (9 8) p^8 (1-p)^2 + (9 9) p^9 (1-p)^0 Finally: ------- p(losing connectivity) = (6 1) p^3 (1-p)^6 + 45 p^4 (1-p)^5 + (9 5) p^5 (1-p)^4 + (9 6) p^6 (1-p)^3 + (9 7) p^7 (1-p)^3 + (9 8) p^8 (1-p)^1 + (9 9) p^9 (1-p)^0 (c) There is no way to extend the formula it to other topologies. You can easily think of a counterexample. =============================================================================== 5. (a) This is a "caracter stuffing" problem. As with any other stuffing scheme, what we need to devise is a way to assure that the start and end of frame characters won't appear in the middle of the frame, without restricting higher level layers' use of characters. You could pick any scheme you like as long it uses ONE character for SOF and another ONE for the EOF (not a sequence of 2 or 3), and specify a stuffing/destuffing policy at the sender and the reciver. Of course, your policy must WORK, i.e. the original string must be always recoverable, and any arbitrary string must be encodable without ambiguity. It is NOT a valida ssumption to say that you will use characters that will never appear in a random string. What I'll provide here is an example: Let's say we use "A" and "B" SOF and EOF markers. Rule for stuffing: Each time an "A" appears in the string, substitute it by an "X". If an "X" appears on the original string, add another "X". Same for "B", only with the character "Y". Rule for transmission: The stuffed string will be transmitted starting with an "A" and ending with a "B". Rule for reception: I will assume that the destuffing will be done after the reception is complete, but it could also be done in line. In fact my solution is incredibly inefficient. When we receive an "A" it is the start of a frame, so we copy the incoming characters to a buffer until we receive a "B", which marks the end of frame. We then pass control to the destuffing engine for the buffer destuffing. Rule for destuffing: We read a character. If it is neither "X" nor "Y" we write it to the result buffer. Each time we find an "X" we don't immediately substitute it with an "A" as it could be a "real" "X". We analyze the next character. If it is another "X" we throw out the previous "X" and write this "X" to the result. We continue the analysis from the next caracter in the original buffer. If it is any other character, we write an "A" in the result and continue the analyssis FROM THE CHARACTER WE ARE JUST HOLDING. We must do this because it could be an "Y", which has an analogous analysis, so we can't copy it directly to the result string. The same rules applies for "Y" and "B". (b) Here, you could have explained any bit stuffing scheme, such as the 01111110 classical example. ============================================================================== 6. We have k/n data columns and n data rows. We have an extra parity column and row. If the original data was arranged as b1,b2,b3,...,bk it will be arranged as: b1 b2 b3 ... b(k/n) rp1 n rows b(k/n+1) b(k/n+2) ... rp2 ... cp1 cp2 ... undef and it will be transmitted as: b1,b(k/n+1),b(2k/n +1),...,cp1,b2,...,rp1,...,undef First of all, independently from the rest of the exercise, it should be clear that the distance of this code is 4, so we can catch 1, 2 or 3 inverted bits with a 100% probability. Also, we can cathc any odd number of changes with a 100% probability, and some of the even ones, depending on their pattern on the matrix. When bursts of errors occur, we don't know the bit pattern the burst will create (for all we know, we may end up with the original string!). What we know is its extension: r. So we can pick n such that it is at least one bit bigger than the burst. That will allow the row parity to catch any error in the burst: If x are the original bits, and b are the burst bits: x x b x ... rp1 x x b x ... rp2 x x x x ... rp3 x b x ... x b x ... x b x . . . . . . . . . x b x cp1 b cp3 ... You can see that independently of where the burst starts, the row parities should be able to capture the bits that differ from the original ones. Advantages & disadvantages: good error detection capabilitues, and even 1 bit error correction capability, however, the overhead is huge. =========================================================================== 7. (a) For any arbitrary transmission attempt, p(success) = p(success in packet transmission) x p(success in ACK transm.) = (1 - p)(1 - q) = 1 - q - p +pq (b) We need the probability of failure p(failure) = 1 - p(success) = 1 - (1 - p)(1 - q) = q + p -pq or we can also interpret is as: p(failure) = p(packet transmission succeds) x p(ACK transmission fails) + p(packet transmission fails) = (1-p)q +p = q -pq +p p(succeding in 2nd trials) = p(failing at first trial) x p(succeeding at second trial) = p(failure)p(success) = (q + p -pq)(1 -q - p +pq) (c) We should now calculate the expectation of the number of trials. I hope that by this time everybody has noticed the pattern: p(success in n trials) = (p(failure))^(n-1) x p(success) which makes it a nice, well known, geometric distribution, whose expectation we already know: E(Number of trials) = 1 x p(success) + 2 x p(success) x p(failure) + 3 x p(success) x (p(failure))^2 + ... + n x p(success) x (p(failure))^(n-1) + ... = 1 / p(success) = 1 / ((1-p) x (1-q)) (d) Well, if we assume no processing nor propagation delays, we can map fairly the number of bits sent to the total time. However, if this is not true (as in any real system), we should account for these delays in the efficiency calculation. So, we either transform these delays to bits, or transform the data bits to time (all of this requieres, of course, the data rate). The efficiency of such a system can be defined as the percentage of time the system is doing useful work. What is useful? It is only the time it takes us to send one instance of the data part of the packet. The rest of the time (ACKs, retransmissions, propagation delay, etc, is simply bureacuracy. If we consider that the timeout will take exactly n+r bits, the efficiency is: k / ( (n+r) x 1/p(success) ) = k x p(success) / (n+r) = k (1-p)(1-q) / (n+r) ================================================================================ 8. "A" is 41 Hex or 65 Dec = 01000001 Bin To calculate the CRC we had to multiply the "A" polinomial by x^4 given the degree of the generator plynomial. In binary terms, we should shif left 4 positions. So, the polinomial we are going to divide is 010000010000 After the division, the CRC turns out to be 0011, so the complete polinomial we are going to send is 010000010011 With the first bit incorrect (110000010011), the CRC yields 1101 <> 0 With the 1st and last bits incorrect (110000010010), the CRC yields 1100 <> 0 With the first 4 bits incorrect (101100010011), the CRC yields 1100 <> 0 ==================================================================================== 9. Virtual circuit would be better for applications that require lots of security in the data path, and that are sensitive to packet loss and need to receive packets in order. Also for applications that require certain bandwidth requirements. For example, most real-time applications run better over virtual circuits than over datagram links. So do any multimedia applications. Datagram, on the other hand, provides more robustness, and speed, but packets will get to the destination out-of-order, with replications and unpredictable losses. However, most regular data applications can recover from that with a well designed ARQ operating on higher levels. What datagram has no way of guaranteeing is a given bandwidth, which is why telephony over IP has so many difficulties.