You are on page 1of 12

CSCI 415 Data Communication Networks

Test 1
Solution
Saad Mneimneh
Visiting Professor
Hunter College of CUNY

NAME:
This test is closed book, closed notes, open minds...
There are 4 Problems (but each problem has multiple parts).
Scratch pages are provided at the end. Scratch pages will not be graded.
Make sure your answer is clear.
Do not leave unanswered questions even if you think you do not have the
complete answer. Partial credit might be given.
Read all questions first. This will help you identify which questions you
can easily answer first.

Problem 1: Pitfalls in bit stuffing (10 points)


Problem 2: Parity check codes (10 points)
Problem 3: Sliding window (10 points)
Problem 4: TCP vs. DLC (10 points)
Total: (40 points)

Problem 1: Pitfalls in bit stuffing (10 points)


(a) (3 points) Bit stuffing must avoid the appearance of 016 within the transmitted frame, so we accept as given that an original string 016 will always be
converted to 015 01, where the second 0 is the stuffed bit. Describe that protocol
at the sender and receiver in your own words.

(b) (4 points) Show that a 0 must always be stuffed after 015 in the string
015 0| .{z
. . 0} 1
k

for any k 1, in order to destuff correctly at the receiver. Hint: show that this
is true for k = 1, then work by induction.
The base case (k = 1): If 0 is not stuffed after 015 in 015 01, then the receiver
cannot distinguish between 015 1 with a stuffed 0, and 015 01 as original data.
Therefore, a 0 must be stuffed after 015 in 015 01.
Inductive step: Assume that a 0 must be stuffed after 015 in 015 |0 .{z
. . 0} 1, lets
k

prove that a 0 must be stuffed after 015 in 015 |0 .{z


. . 0} 1. If 0 is not stuffed after
k+1

. . 0} 1 with
015 in 015 0| .{z
. . 0} 1, then the receiver cannot distinguish between 015 |0 .{z
k+1

a stuffed 0, and 015 0| .{z


. . 0} 1 as original data. Therefore, a 0 must be stuffed after
015 in 015 0| .{z
. . 0} 1.
k+1

k+1

(c) (3 points) A student in CSCI 415 suggests the following alternative for bit
stuffing: pick any flag you want of some length n, say x1 x2 . . . xn , and stuff xn
after the appearance of x1 x2 . . . xn1 within the transmitted frame, where

0 xn = 1
xn =
1 xn = 0
Show by example that this strategy does not work.
Let the flag be 0101, i.e. n = 2. We must stuff a 0 after 010. Consider the
following frame:
. . . 01
Regardless of the stuffing that needs to be done, adding the flag at the end of
the frame will produce the following:
. . . 010101
Now the receiver will interpret the first occurrence of 0101 as the flag, hence
accepting the frame before it actually ends.

Problem 2: Parity check codes (10 points)


Consider the following codeword taken from a code with 4 data bits and 5 parity
bits.
0110
| {z} 11110
| {z }
This is what we know about the parity bits:
one of them is the standard parity computed as the sum modulo 2 of all
the data bits
each of the remaining four parity bits is the sum modulo 2 of exactly two
data bits
(a) (2 points) Find the rules for generating all 5 parity bits.
Let w, x, y, and z be the data bits in order. Then the parity bits are computed
as follows (modulo 2):
w+x
w+y
x+z
y+z
w+x+y+z
(b) (2 points) What is the minimum distance of the code? Justify your answer.
This represents a vertical/horizontal parity code. Therfore, the minimum distance is 4.
(c) (2 points) What is the data sensitivity of this code? Justify your answer.
Since we have 5 parity bits, and data sensitivity is defined as the probability of
accepting a random string as a valid codeword, this probability is (1/2)5 .

(e) (2 points) Construct a pattern of 6 errors (in data and parity) that cannot
be detected by this code.
We have to construct a pattern of errors such that we have exactly 2 errors in
each row and each column. Heres a possibility:
011
101
110
with error:
xx1
1xx
x1x

Problem 3: Slinding window (10 points)


Assume all frames have size F bits, and the propagation delay on the link is
P sec, and the bandwidth is B bps. Assume also that the receiver piggybacks
acknowledgements on frames going to the sender.
(a) (4 points) What should the window size n (in frames) be at the sender in
order to effectively use the bandwidth? Be as exact as you can.
The time it takes to get the first acknowledgement is F/B+P+F/B+P=2F/B+2P.
=
During this time, the number of frames that can be transmitted is 2F/B+2P
F/B
2 + 2P B/F .
(b) (2 points) Repeat part (a) if the size of a frame may vary between Fmin and
Fmax .
Let the window size be n. Let F1 be the size of the first frame in the window.
Then the time to transmit all n frames is at least:
F1 /B + (n 1)Fmin /B

(1)

The time until the acknowledgement comes back is at most:


F1 /B + P + Fmax /B + P

(2)

We need (1) (2); therefore,


F1 /B + (n 1)Fmin /B F1 /B + P + Fmax /B + P
n 1 + Fmax /Fmin + 2P B/Fmin
Note that when Fmax = Fmin = F , we get the previous result.

(c) (4 points) Assume n 1, and a receiver sliding window size of 1 frame.


Illustrate by an example that the sliding window algorithm does not operate
correctly if a modulo n is used on the sequence numbers, even in the presence
of the FIFO property (3 points). What is a safe modulus to use in terms of the
senders window size if the FIFO property holds (1 point)?
Assume the sender sends all the packets in its current window, e.g. 0, 1, 2, . . . n
1. Assume also that the receiver received all these packets error free and acknowledged them. If all the acknowledgements are lost, the sender will not
advance it window. After timing out, the sender can re-send the first packet of
the window, i.e. packet 0. At this point in time, the receiver is expecting packet
n, which is packet 0 modulo n, so this duplicate packet is going to be accepted
as a new packet.
A safe modulus would have been p n + 1.

Problem 4: TCP vs. DLC (10 points)


(a) (3 points) Discuss the implication of loosing the FIFO property when going
from link to network on the sliding window algorithm.
The key point here is the segment life time, which puts a limit on how much
a segment can live inside the network. Hopefully, a segment will be destroyed
before the sequence numbers wrap around. This is how TCP compensates for
the loss of the FIFO property.
(b) (3 points) Discuss the implication of not having to keep the state of the
connection like in DLC after a TCP client disconnects on the TCP initialization/disconnection protocol.
The key point here is that a client must have to wait (for 2 segment life times)
before closing the connection.

(c) (3 points) Discuss the implication of a TCP slow receiver on the sliding
window algorithm.
The key point here is the synchronization through the advertised window.
(d) (1 point) What is your favorite restaurant in New York city?

SCRATCH

SCRATCH

SCRATCH

You might also like