Computer Network The Data Link Layer
Computer Network The Data Link Layer
Computer Network The Data Link Layer
Chapter 3
Data Link Layer Design Issues
• Network layer does not know frame size of the packets and other
restriction of the data link layer. Hence it becomes necessary for
data link layer to have some mechanism to optimize the
transmission.
Acknowledged Connection
Oriented Service
• Source and Destination establish a connection first.
• Each frame sent is numbered
– Data link layer guarantees that each frame sent is indeed received.
– It guarantees that each frame is received only once and that all frames
are received in the correct order.
• Examples:
– Satellite channel communication,
– Long-distance telephone communication, etc.
Acknowledged Connection
Oriented Service
• Three distinct phases:
1. Connection is established by having both side initialize variables and
counters needed to keep track of which frames have been received
and which ones have not.
2. One or more frames are transmitted.
3. Finally, the connection is released – freeing up the variables, buffers,
and other resources used to maintain the connection.
Framing
• To provide service to the network layer the data link layer must use
the service provided to it by physical layer.
• Stream of data bits provided to data link layer is not guaranteed to
be without errors.
• Errors could be:
– Number of received bits does not match number of transmitted bits
(deletion or insertion)
– Bit Value
• It is up to data link layer to correct the errors if necessary.
Framing
• Transmission of the data link layer starts with breaking up the bit
stream
– into discrete frames
– Computation of a checksum for each frame, and
– Include the checksum into the frame before it is transmitted.
• Receiver computes its checksum error for a receiving frame and if it
is different from the checksum that is being transmitted will have to
deal with the error.
1.Byte count.
2.Flag bytes with byte stuffing.
3.Flag bits with bit stuffing.
4.Physical layer coding violations.
Byte Count Framing Method
• It uses a field in the header to specify the number of bytes in the
frame.
• Once the header information is being received it will be used to
determine end of the frame.
• See figure in the next slide:
• Trouble with this algorithm is that when the count is incorrectly
received the destination will get out of synch with transmission.
– Destination may be able to detect that the frame is in error but it does
not have a means (in this algorithm) how to correct it.
Framing (1)
A byte stream. (a) Without errors. (b) With
one error.
Flag Bytes with Byte Staffing
Framing Method
• This methods gets around the boundary detection of the frame by
having each appended by the frame start and frame end special
bytes.
• If they are the same (beginning and ending byte in the frame) they
are called flag byte.
• In the next slide figure this byte is shown as FLAG.
• If the actual data contains a byte that is identical to the FLAG byte
(e.g., picture, data stream, etc.) the convention that can be used is
to have escape character inserted just before the “FLAG” character.
Framing (2)
Bit stuffing. (a) The original data. (b) The data as they appear on
the line. (c) The data as they are stored in the receiver’s memory after destuffing.
Framing
• Many data link protocols use a combination of presented methods
for safety. For example in Ethernet and 802.11 each frame begin
with a well-defined pattern called a preamble.
• Preamble is typically 72 bits long.
• It is then followed by a length fileld.
Error Control
• After solving the marking of the frame with start and end the
data link layer has to handle eventual errors in transmission or
detection.
– Ensuring that all frames are delivered to the network layer at
the destination and in proper order.
• Unacknowledged connectionless service: it is OK for the
sender to output frames regardless of its reception.
• Reliable connection-oriented service: it is NOT OK.
Error Control
1.Hamming codes.
2.Binary convolutional codes.
3.Reed-Solomon codes.
4.Low-Density Parity Check codes.
Error Detection & Correction Code
• All the codes presented in previous slide add redundancy to the
information that is being sent.
• A frame consists of
– m data bits (message) and
– r redundant bits (check).
• Block code - the r check bits are computed solely as function of the m data
bits with which they are associated.
• Systemic code – the m data bits are send directly along with the check
bits.
• Linear code – the r check bits are computed as a linear function of the m
data bits.
Error Detection & Correction Code
Example
• Transmitted: 10001001
• Received: 10110001
XOR operation gives number of bits that are different.
• XOR: 00111000
Consider a message having four data bits (D) which is to be transmitted as a 7-bit
codeword by adding three error control bits. This would be called a (7,4) code. The
three bits to be added are three EVEN Parity bits (P), where the parity of each is
computed on different subsets of the message bits as shown below.
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)
Hamming Code
• Why Those Bits? - The three parity bits (1,2,4) are related to the
data bits (3,5,6,7) as shown at right. In this diagram, each
overlapping circle corresponds to one parity bit and defines the four
bits contributing to that parity computation. For example, data bit 3
contributes to parity bits 1 and 2. Each circle (parity bit)
encompasses a total of four bits, and each circle must have EVEN
parity. Given four data bits, the three parity bits can easily be chosen
to ensure this condition.
• It can be observed that changing any one bit numbered 1..7
uniquely affects the three parity bits. Changing bit 7 affects all three
parity bits, while an error in bit 6 affects only parity bits 2 and 4, and
an error in a parity bit affects only that bit. The location of any single
bit error is determined directly upon checking the three parity circles.
Hamming Code
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)
Hamming Codes
• When these seven bits are entered into
the parity circles, it can be confirmed that
the choice of these three parity bits
ensures that the parity within each circle is
EVEN, as shown here.
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:
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
Hamming Code
• In fact, the bad parity bits labeled 101 point directly to the bad bit since
101 binary equals 5. Examination of the 'parity circles' confirms that any
single bit error could be corrected in this way.
• The value of the Hamming code can be summarized:
1. Detection of 2 bit errors (assuming no correction is attempted);
2. Correction of single bit errors;
3. Cost of 3 bits added to a 4-bit message.
• The ability to correct single bit errors comes at a cost which is less than
sending the entire message twice. (Recall that simply sending a message
twice accomplishes no error correction.)
Error Detection Codes (2)
Chapter 3