The Link Layer
Has 2 main Components
The Data Link Layer
Medium Access Control (MAC)
Examples:SLIP, PPP, Ethernet.
CSC 3352 Computer Communications Chapter 3&4 1
Logical Link Layer Function
Provides service to the network layer
Has two Components
1. Data link layer
Framing
Error Handling
Flow control
2. Medium access control
In the case of a shared medium, this function provides
means for sharing optimally the medium
CSC 3352 Computer Communications Chapter 3&4 2
Framing
What is it? breaking up the bits into discrete
frames and checking the total number of
received bits (the checksum)…
Why? to ensure that the number and the
value of the sent and the received bits are
exact…
How? character count, Start/Stop characters,
Start/stop flags
CSC 3352 Computer Communications Chapter 3&4 3
Character Count
Character count Character count Character count
5 1 2 3 4 5 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3
Frame 1 with 5 char Frame 4 with 8 char
The problem with this method is:
Transmission Error New Character counts
5 1 2 3 4 7 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3
Frame 1 with 5 char
CSC 3352 Computer Communications Chapter 3&4 4
Start/Stop characters
Stuffed DLE
A DLE B
STX DLE A DLE DLE B DLE ETX
A DLE B
• STX is Start of TeXt
• DLE is Data Link Escape
• ETX End of TeXt
CSC 3352 Computer Communications Chapter 3&4 5
Start/stop flags
CSC 3352 Computer Communications Chapter 3&4 6
Error Handling…
What is it? A mechanism to make sure all frames are
delivered to the right destination and in the right order
and only once…
Why? The sent data may be corrupted or vanish in the
network…
How? Give feedback to the source machine by
acknowledging the reception and using temporal flags
(i.e. a timer)… Then after correcting the errors…
CSC 3352 Computer Communications Chapter 3&4 7
Error Handling
Error detection
1. Parity bit
2D/Crossed parity
Hamming code
Error correction
Hamming Code
CSC 3352 Computer Communications Chapter 3&4 8
Parity bit
The sender adds a parity bit to the end of the
word such that the total number of bits
(including the parity bit) is even (Even parity)
01110110 becomes 011101101
Detects only odd number of corrupted bits…
Why?
CSC 3352 Computer Communications Chapter 3&4 9
2D/Crossed Parity
CSC 3352 Computer Communications Chapter 3&4 10
Hamming code (Detecting + Correcting)
Hamming distance of two WORDS is the number of bits
that differ (exclusive OR between the 2 words)
Example: 10001001 and 10110001, the Hamming
distance is 3…
The Hamming distance of a list of codewords is
the smallest distance between any pair of
codewords on this list
CSC 3352 Computer Communications Chapter 3&4 11
Hamming code (Detecting + Correcting)
Assume the following list of valid codewords:
0000000000
0000011111
1111100000
1111111111
What is the hamming distance of this list?
It is 5 since the smallest distance between
any two codewords of this list is 5
CSC 3352 Computer Communications Chapter 3&4 12
How can we use hamming codes in errors
detection/correction
Codeword= Data + Checkbits
N bits = M bits + R bits
Given the structure codewords, we can build a
complete list of valid codewords…
A Hamming distance of d will allow to detect up to
(n-1) corrupted bits… Why?
A Hamming distance of d will allow to correct up to
(n/2) or ((n-1)/2) corrupted bits… Why?
CSC 3352 Computer Communications Chapter 3&4 13
Hamming code (Detecting + Correcting)
Hence:
we need a distance of d+1 to detect d errors…
we need a distance of 2d+1 to correct d errors…
A hamming distance of 5bits can:
detect errors of 4bits
correct errors of 2bits
See the example in page 185
Generally, Checkbits bits are put at power of 2 positions
(1, 2, 4, 8, etc.) and Data elsewhere...
CSC 3352 Computer Communications Chapter 3&4 14
Building a Hamming Code of
Distance 3
CSC 3352 Computer Communications Chapter 3&4 15
Family of Hamming Codes…
CSC 3352 Computer Communications Chapter 3&4 16
Flow Control (FC)
What is it? Synchronization mechanism to allow faster machines
and slow machines to coexist on the net…
Why? The flow of faster machines is higher than the one of slow
machines…
How? Throttling the sender into sending no more than the
receiver’s capacity
The basic principle: Send n frames now but, after they have
been sent, don’t send any more until getting an OK to
continue… The protocol contains well defined rules about when
a sender may transmit the next frame…
CSC 3352 Computer Communications Chapter 3&4 17
Elementary FC protocols: fundamentals
Read carefully pages 191..193 for the basic
definitions of the standard variables and
functions that are used…
CSC 3352 Computer Communications Chapter 3&4 18
Elementary FC protocols: example 1
The unrestricted Simplex Protocol… The Utopia
Protocol (fig. 3-9, page 196)
CSC 3352 Computer Communications Chapter 3&4 19
Elementary FC protocols: Example 2
A simplex protocol for noisy channels… The
stop and wait Protocol (fig. 3-10, page 198)
CSC 3352 Computer Communications Chapter 3&4 20
Elementary FC protocols: Example 3
A positive acknowledgement with
retransmission protocol
CSC 3352 Computer Communications Chapter 3&4 21
Elementary FC protocols: Example 4
See fig. 3-13 page 205
CSC 3352 Computer Communications Chapter 3&4 22