CN Numericals Data Link Layer
CN Numericals Data Link Layer
So distance =3
Error Control
Q. Discuss the relationship between the Hamming distance and errors
occurring during transmission.
Ans. When a codeword is corrupted during transmission, the Hamming
distance between the sent and received codewords is the number of
bits affected by the error. In other words,the Hamming distance
between the received codeword and the sent codeword is the number
of bits that are corrupted during transmission.
For example, if the codeword 00000 is sent and 01101 is received, 3
bits
Are in error and the Hamming distance between the two is
d(00000,01101)=3.
Error Control
Q. What minimum distance between codes is required for error
detection?
Ans. If s errors occur during transmission, the Hamming distance
between the sent codeword and received codeword is s. If our code
is to detect upto s errors, the minimum distance between the valid
codes must be s+1, so that the received codeword does not match a
valid codeword.
7 6 5 4 3 2 1
D D D P D P P 7-BIT CODEWORD
D - D - D - P (EVEN PARITY)
D D - - D P - (EVEN PARITY)
D D D P - - - (EVEN PARITY)
The Hamming Code
• For example, the message 1101 would be sent as
1100110, since:
7 6 5 4 3 2 1
1 1 0 0 1 1 0 7-BIT CODEWORD
1 - 0 - 1 - 0 (EVEN PARITY)
1 1 - - 1 1 - (EVEN PARITY)
1 1 0 0 - - - (EVEN PARITY)
The Hamming Code
• It may now be observed that if an error occurs in any of the seven bits, that error will affect
different combinations of the three parity bits depending on the bit position.
• For example, suppose the above message 1100110 is sent and a single bit error occurs such
that the codeword 1110110 is received:
transmitted message received message
1100110 ------------> 1110110
BIT: 7 6 5 4 3 2 1 BIT: 7 6 5 4 3 2 1
The above error (in bit 5) can be corrected by examining which of the three parity bits was
affected by the bad bit:
The Hamming Code
7 6 5 4 3 2 1
1 1 1 0 1 1 0 7-BIT CODEWORD
1 - 1 - 1 - 0 (EVEN PARITY) NOT! 1
1 1 - - 1 1 - (EVEN PARITY) OK! 0
1 1 1 0 - - - (EVEN PARITY) NOT! 1
Framing
Q. The following data fragment occurs in the middle of
a data stream for which the byte-stuffing algorithm
described in the text is used: A B ESC C ESC FLAG
FLAG D. What is the output after stuffing?
Ans.
After stuffing, we get
A B ESC ESC C ESC ESC ESC FLAG ESC FLAG D
• Complete frame with delimiter
FLAG A B ESC ESC C ESC ESC ESC FLAG ESC
FLAG D FLAG
Framing
Q. A bit string, 0111101111101111110, needs to be
transmitted at the data link layer. What is the string
actually transmitted after bit stuffing?
Ans.
The output is 011110111110011111010
Framing
Q. When bit stuffing is used, is it possible for the loss, insertion, or modification of a
single bit to cause an error not detected by the checksum? If not, why not? If so, how?
Does the checksum length play a role here?
Ans.
It is possible.
Suppose that the original text contains the bit sequence 01111110 as data. After bit
stuffing, this sequence will be rendered as 011111010. If the second 0 is lost due to a
transmission error, what is received is 01111110, which the receiver sees as end of
frame. It then looks just before the end of the frame for the checksum and verifies it. If
the checksum is 16 bits, there is 1 chance in 216 that it will accidentally be correct,
leading to an incorrect frame being accepted. The longer the checksum, the lower the
probability of an error getting through undetected, but the probability is never zero.
Equations
• R = Transmission rate
• S = Signal Speed
• D = Distance between sender and receiver
• T = Time to create one frame
• F = Number of bits in a frame
• N = Number of data bits in a frame
• A = Number of bits in an acknowledgement
Ø Time needed to transmit one frame = F/R
Ø The receiver receives the last bit of the first frame at time = T + F/R + D/S
Ø The time required for the sender to receive the ack is = T + A/R + D/S
Ø Time elapses between sending two data frames = [2*(T + D/S)] + [(F+A)/R]
Ø Amount of time a frame is actually in transit is = F/R + D/S
Stop-N-Wait Protocol
A system uses the Stop-N-Wait protocol. If each packet carries 1000 bits of data, how long does
it take to send 1 million bits of data if the distance between the sender and receiver is 5000km
and propagation speed is 2*108 m. Ignore transmission, waiting and processing delays. We
assume no data or control frame is damaged or lost.
Ans
Ans.
Ans.
• 4,5,6,7,0,1,2.