EEE 4113: Computer Networks
Specific responsibilities of the data link layer include:
framing, addressing, error control, flow control, and media access control.
The data link layer divides the stream of bits received from the network layer into
manageable data units called frames. The data link layer adds a header to the frame
to define the addresses of the sender and receiver of the frame.
If the rate at which the data are absorbed by the receiver is less than the rate at
which data are produced in the sender, the data link layer imposes a flow control
mechanism to avoid overwhelming the receiver.
The data link layer also adds reliability to the physical layer by adding mechanisms to
detect and retransmit damaged, duplicate, or lost frames.
When two or more devices are connected to the same link, data link layer protocols
are necessary to determine which device has control over the link at any given time.
Behrouz
Farhana B Sufi (PhD), 2023 2
Types of Error
- Single bit
- Burst error
Detection Vs Correction
Redundancy
Forward Error Correction Vs Retransmission
Behrouz
Farhana B Sufi (PhD), 2023 3
Codeword n = k+r ; where r redundant bits are added to k databits.
With k bits, we can create a combination of datawords; with n bits, we can create a combination
of codewords.
Since n > k, the number of possible codewords is larger than the number of possible datawords.
The ratio of redundant bits to data bits (n – k)/k, is called the redundancy of the code, and the ratio
of data bits to total bits, k/n, is called the code rate. (Stallings Ch.6)
If the following two conditions are met, the receiver can detect a change in the original codeword:
1. The receiver has (or can find) a list of valid codewords.
2. The original codeword has changed to an invalid one.
If the received codeword is the same as one of the valid codewords, the word is accepted; the
corresponding dataword is extracted for use, otherwise discarded.
However, if the codeword is corrupted during transmission but the received word still matches a
valid codeword, the error remains undetected.
This type of coding can detect only single errors. Two or more errors may remain undetected.
e.g 10.2 - Behrouz
Farhana B Sufi (PhD), 2023 4
Adding more redundant bits
Example 10.3 of Behrouz
Stallings – Ch. 6:
For a code consisting of the codewords w1 , w2 , … , ws , where s = , the minimum distance of the code dmin
If dmin errors occur, this could change one valid codeword into another. Any number of errors less than can not
result in another valid codeword.
The design of a block code involves a number of considerations:
1. For given values of n and k, we would like the largest possible value of dmin
2. The code should be relatively easy to encode and decode, requiring minimal memory and processing time.
3. We would like the number of extra bits, (n – k), to be small, to reduce bandwidth.
4. We would like the number of extra bits, (n – k), to be large, to reduce error rate.
Farhana B Sufi (PhD), 2023 5
The Hamming distance between two words (of the same size) is the number of differences
between the corresponding bits.
The Hamming distance is found by applying the XOR operation on the two words and count
the number of 1s in the result.
Note that the Hamming distance is a value greater than zero.
Example 10.4 Behrouz
Minimum Hamming Distance
The minimum Hamming distance is the smallest Hamming distance between all possible
pairs in a set of words.
We use dmin to define the minimum Hamming distance in a coding scheme.
Example 10.4 & 10.5 Behrouz
When a codeword is corrupted during transmission, the Hamming distance between the sent
and received codewords is the number of bits that will be affected by the error. For example,
ifthe codeword 00000 is sent and 01101 is received, 3 bits are in error and the Hamming
distance between the two is d(OOOOO, 01101) =3
To guarantee the detection of up to s errors in all cases, the minimum Hamming distance in a
block code must be dmin = s + 1.
E.g 10.7, 10.8, 10.9
Farhana B Sufi (PhD), 2023 6
A k-bit dataword is changed to an n-bit codeword where n = k + 1. The extra bit is called the
parity bit.
If there are even number of 1s, it is an even parity. Typically used for synchronous
transmission.
If there are an odd number of 1s, it is an odd parity. Typically used for asynchronous
transmission.
The minimum Hamming distance for this category is dmin =2, which means that the code is a
single-bit error-detecting code; it cannot correct any error.
Behrouz & Stallings
Farhana B Sufi (PhD), 2023 7
https://www.geeksforgeeks.org/hamming-code-in-computer-network/
This is a forward error correction (FEC), where errors can be automatically fixed when read back
Hamming code uses a block parity mechanism. The data is divided into blocks, and parity is added to the
block.
Standard Hamming code can correct single-bit errors and detect the presence of two-bit errors in a data
block.
https://www.techtarget.com/whatis/definition/Hamming-code
This is a forward error correction (FEC), where errors can be automatically fixed when read back
Hamming code uses a block parity mechanism. The data is divided into blocks, and parity is added to the
block.
Standard Hamming code can correct single-bit errors and detect the presence of two-bit errors in a data
block.
Tanenbaum’s book
8
Farhana B Sufi (PhD), 2023
Also see –
Fig. 10.12 Behrouz - encoder and Decoder
Example 10.13 Behrouz
NOTE:
Hamming code is not used in modern data transmission. Wired data connections are generally not
noisy enough to warrant the overhead of added parity data, and if an error is encountered, it may be faster
to ask the sender to retransmit the faulty packet.
One area where Hamming code is used for data transmission is in satellite and space communication. Because
of the great distances involved, long transmit times and the requirements for accurate data, it is preferred to
use the slower but more precise Hamming code and sacrifice overall transmission rate.
Farhana B Sufi (PhD), 2023 9
Cyclic code is a codeword that is cyclically shifted (rotated) - the result is another codeword.
For example, if 1011000 is a codeword and we cyclically left-shift, then 0110001
We can create cyclic codes to correct errors. Cyclic Redundancy Check (CRC) is used in
networks such as LANs and WANs.
Given a k-bit block of data bits, the transmitter generates an (n – k)-bit sequence, known as a
frame check sequence (FCS), such that the resulting frame, consisting of n bits, is exactly
divisible by some predetermined number. The receiver then divides the incoming frame by
that number and, if there is no remainder, assumes there was no error.
Modulo-2 arithmatic – Stallings
Example 6.6 – Stallings
Polynomials
The CRC process can be represented by, and indeed implemented as, a dividing circuit
consisting of XOR gates and a shift register.
Farhana B Sufi (PhD), 2023 10
Example 10.18, 10.19
One’s Complement:
Inverting all bits (changing 0 to a 1, and 1 to a 0). This is the same as subtracting
the number from - 1.
Farhana B Sufi (PhD), 2023 11
1. Data Communications and Networking By Behrouz A.Forouzan
– Chapter 10
2. Data and Computer Communications – W. Stallings – Chapter 6
3. Hamming Code –
https://www.techtarget.com/whatis/definition/Hamming-code
https://www.geeksforgeeks.org/hamming-code-in-computer-network/
Farhana B Sufi (PhD), 2023 12