Title: Computer Networks - 21CS52 - VTU Notes / Study Materials - Module 2
1Department ofInformation Science Engineering
Computer Networks Module 2
Dr Loganathan D Professor
www.cambridge.edu.in
221CS32 - Computer Networks - Syllabus
Module 1 Introduction to networks Network
hardware, Network software, Reference models.
Physical Layer Guided transmission media,
Wireless transmission. Module 2 The Data link
layer Design issues of DLL, Error detection and
correction, Elementary data link protocols,
Sliding window protocols. The medium access
control sub layer The channel allocation
problem, Multiple access protocols.
www.cambridge.edu.in
Department of Information Science Engineering
321CS32 - Computer Networks - Syllabus
Module 3 The Network Layer Network Layer Design
Issues, Routing Algorithms, Congestion Control
Algorithms, QoS. Module 4 The Transport Layer
The Transport Service, Elements of transport
protocols, Congestion control, The internet
transport protocols. Module 5 Application
Layer Principles of Network Applications, The
Web and HTTP, Electronic Mail in the Internet,
DNSThe Internets Directory Service.
www.cambridge.edu.in
Department of Information Science Engineering
421CS32 - Computer Networks - Syllabus
- Module 2
- The Data Link Layer
- Design issues of DLL,
- Error detection and correction,
- Elementary data link protocols, Sliding window
protocols. - The medium access control sub layer
- The channel allocation problem,
- Multiple access protocols.
www.cambridge.edu.in
Department of Information Science Engineering
5Module 2 - The Data link layer
Design issues of DLL
- The Data Link Layer (DLL) uses the services of
the physical layer to send and receive bits over
communication channels. - It has a number of functions, including
- 1. Providing a well-defined service interface to
the network layer. - 2. Dealing with transmission errors.
- 3. Regulating the flow of data so that slow
receivers are not flooded by fast senders. - To accomplish these goals, the data link layer
takes the packets it gets from the network layer
and encapsulates them into frames for
transmission. - Each frame contains a frame header, a payload
field for holding the packet, and a frame
trailer, as illustrated in Figure.
www.cambridge.edu.in
Department of Information Science Engineering
6Module 2 - The Data link layer
Design issues of DLL
- Frame Header It contains the source and the
destination addresses of the frame and the
control bytes. - Payload field It contains the message to be
delivered. - Trailer It contains the error detection and
error correction bits.
www.cambridge.edu.in
Department of Information Science Engineering
7Module 2 - The Data link layer
Design issues of DLL
- Although this chapter is explicitly about the
data link layer and its protocols, many of the
principles we will study here, such as error
control and flow control, are found in transport
and other protocols as well. - Services Provided to the Network Layer
- The function of the data link layer is to provide
services to the network layer. - The principal service is transferring data from
the network layer on the source machine to the
network layer on the destination machine. - The network layer that hands some bits to the
data link layer for transmission to the
destination. - The job of the data link layer is to transmit the
bits to the destination machine so they can be
handed over to the network layer there, as shown
in Figure.
www.cambridge.edu.in
Department of Information Science Engineering
8Module 2 - The Data link layer
Design issues of DLL
www.cambridge.edu.in
Department of Information Science Engineering
9Module 2 - The Data link layer
Design issues of DLL
Placement of the data link protocol.
www.cambridge.edu.in
Department of Information Science Engineering
10Module 2 - The Data link layer
Design issues of DLL
- The data link layer can be designed to offer
various services. The actual services that are
offered vary from protocol to protocol. Three
reasonable possibilities that we will consider in
turn are - 1. Unacknowledged connectionless service.
- 2. Acknowledged connectionless service.
- 3. Acknowledged connection-oriented service.
- Getting back to the services, the most
sophisticated service the data link layer can
provide to the network layer is
connection-oriented service. - With this service, the source and destination
machines establish a connection before any data
are transferred. - Each frame sent over the connection is numbered,
and the data link layer guarantees that each
frame sent is indeed received.
Connection-oriented service Connection less
Service
www.cambridge.edu.in
Department of Information Science Engineering
11Module 2 - The Data link layer
Design issues of DLL
Connection-oriented service Connection less
Service
- When connection-oriented service is used,
transfers go through three distinct phases. - In the first phase, the connection is established
by having both sides initialize variables and
counters needed to keep track of which frames
have been received and which ones have not. - In the second phase, one or more frames are
actually transmitted. - In the third and final phase, the connection is
released, freeing up the variables, buffers, and
other resources used to maintain the connection.
www.cambridge.edu.in
Department of Information Science Engineering
12Module 2 - The Data link layer
Design issues of DLL
- Data Link Layer Design Issues
- Framing
- Error Control
- Flow Control
www.cambridge.edu.in
Department of Information Science Engineering
13Module 2 - The Data link layer
Design issues of DLL
- Framing
- To provide service to the network layer, the data
link layer must use the service provided to it by
the physical layer. - What the physical layer does is accept a raw bit
stream and attempt to deliver it to the
destination. - However, the bit stream received by the data link
layer is not guaranteed to be error free. - Some bits may have different values and the
number of bits received may be less than, equal
to, or more than the number of bits transmitted. - It is up to the data link layer to detect and, if
necessary, correct errors.
www.cambridge.edu.in
Department of Information Science Engineering
14Module 2 - The Data link layer
Design issues of DLL
- Framing
- Breaking up the bit stream into frames is more
difficult than it at first appears. - A good design must make it easy for a receiver to
find the start of new frames while using little
of the channel bandwidth. - We will look at four methods to implement
framing, - 1. Byte count.
- 2. Flag bytes with byte stuffing.
- 3. Flag bits with bit stuffing.
- 4. Physical layer coding violations.
www.cambridge.edu.in
Department of Information Science Engineering
15Module 2 - The Data link layer
Design issues of DLL
- Framing involves,
- Detecting start of the frame
- How does the station detect a frame?
- Detecting end of frame
- Handling errors
- Framing overhead (bandwidth)
- Framing synchronization
- Two types of Framing -
- 1. Fixed-size and 2. Variable size - frame counts
www.cambridge.edu.in
Department of Information Science Engineering
16Module 2 - The Data link layer
Design issues of DLL
Framing - 1. Byte count method
Byte counting is a technique used in framing at
the data link layer. In this method, the length
of the frame (number of bytes) is explicitly
specified in the frame itself.
www.cambridge.edu.in
Department of Information Science Engineering
17Module 2 - The Data link layer
Design issues of DLL
Framing 2. Flag bytes with byte stuffing Method
- Byte stuffing is a method used to avoid confusion
between data and control characters in a data
stream. The second framing method gets around the
problem of resynchronization after an error by
having each frame start and end with special
bytes. - Often the same byte, called a flag byte, is used
as both the starting and ending delimiter. This
byte is shown in Figure as FLAG. - However, there is a still a problem we have to
solve. It may happen that the flag byte occurs in
the data, especially when binary data such as
photographs or songs are being transmitted.
www.cambridge.edu.in
Department of Information Science Engineering
18Module 2 - The Data link layer
Design issues of DLL
Framing 2. Flag bytes with byte stuffing Method
- One way to solve this problem is to have the
senders data link layer insert a special escape
byte (ESC) just before each accidental flag
byte in the data. Thus, a framing flag byte can
be distinguished from one in the data by the
absence or presence of an escape byte before it. - The data link layer on the receiving end removes
the escape bytes before giving the data to the
network layer. This technique is called byte
stuffing.
www.cambridge.edu.in
Department of Information Science Engineering
19Module 2 - The Data link layer
Design issues of DLL
Framing 2. Flag bytes with byte stuffing Method
insert a special escape byte (ESC) just before
each accidental flag byte in the data.
Used in PPP (Point-to-Point Protocol), which is
used to carry packets over communications
links. The second framing method gets around the
problem of synchronization after an error by
having each frame start and end with special
bytes. Often the same byte, called a flag byte,
is used as both the starting and ending delimiter.
www.cambridge.edu.in
Department of Information Science Engineering
20Module 2 - The Data link layer
Design issues of DLL
Framing 3. Flag bits with bit stuffing.
- It was developed for the very popular HDLC (High
level Data Link Control) protocol. - Each frame begins and ends with a special bit
pattern, 01111110 or 0x7E in hexadecimal. This
pattern is a flag byte. When the receiver sees
five consecutive incoming 1 bits, followed by a 0
bit, it automatically deletes the 0 bit. Just as
byte stuffing is completely transparent to the
network layer in both computers, so is bit
stuffing. If the user data contain the flag
pattern, 01111110, this flag is transmitted as
011111010 but stored in the receivers memory as
01111110.
www.cambridge.edu.in
Department of Information Science Engineering
21Module 2 - The Data link layer
Design issues of DLL
Framing 3. Flag bits with bit stuffing.
0 added every after five consecutive ones -111110
111110
www.cambridge.edu.in
Department of Information Science Engineering
22Module 2 - The Data link layer
Design issues of DLL
Framing 4. Physical layer coding violations
- In networking, especially in the context of
Ethernet, physical layer coding violations refer
to situations where the normal coding rules are
intentionally violated to create a unique signal
pattern. - In 100BASE-TX Ethernet, the normal Manchester
encoding might be violated for certain control or
special-purpose signals. - The encoding of bits as signals often includes
redundancy to help the receiver. - This redundancy means that some signals will not
occur in regular data. - This can be detected by devices interpreting the
signal. - Used for special signaling or synchronization
purposes in the physical layer.
www.cambridge.edu.in
Department of Information Science Engineering
23Module 2 - The Data link layer
Connection oriented or Connectionless Oriented
Services
- Connection oriented Services
- Requires the establishment of a connection before
data transfer. - TCP (Transmission Control Protocol) is a
prominent example of a connection-oriented
protocol. - Implements flow control mechanisms to manage the
rate of data transmission. - Offers a reliable communication channel with
error checking and correction mechanisms. - Connectionless Oriented Services
- Does not require a pre-established connection
before data transmission. - UDP (User Datagram Protocol) is a common
connectionless protocol. - Provides no guarantee of reliable data delivery.
- Error checking may be minimal or absent.
www.cambridge.edu.in
Department of Information Science Engineering
24Module 2 - The Data link layer
Modem, Multiplexing, and error detection,
- Data Communication
- Understanding the fundamentals of data
communication, including concepts like modem
(Modulation and Demodulation), multiplexing, and
error detection, provides a solid foundation for
networking. - Modulation is the process of encoding information
in a transmitted signal, while demodulation is
the process of extracting information from the
transmitted signal. - Multiplexing is a technique used to combine and
send the multiple data streams over a single
medium. The process of combining the data streams
is known as multiplexing and hardware used for
multiplexing is known as a multiplexer. - Error is a condition when the receivers
information does not match the senders
information.
www.cambridge.edu.in
Department of Information Science Engineering
25Module 2 - The Data link layer
RJ 45 8 pin Connector - Ethernet Cable Color
Coding Diagram
www.cambridge.edu.in
Department of Information Science Engineering
26Module 2 - The Data link layer
Modes of Transmission Medium
- Modes of Transmission Medium
- Simplex mode In this mode, out of two devices,
only one device can transmit the data, and the
other device can only receive the data. Example-
Input from keyboards, monitors, TV broadcasting,
Radio broadcasting, etc. - Half Duplex mode In this mode, out of two
devices, both devices can send and receive the
data but only one at a time not simultaneously.
Examples- Walkie-Talkie, Railway Track, etc. - Full-Duplex mode In this mode, both devices can
send and receive the data simultaneously.
Examples- Telephone Systems, Chatting
applications, etc.
www.cambridge.edu.in
Department of Information Science Engineering
27Module 2 - The Data link layer
- Virtual Communication
- Virtual communication relies on digital
platforms, such as email, video calls, instant
messaging, and social media using digital medium. - Participants may face more distractions in a
virtual environment, affecting focus and
attention. - Face-to-face communication
- Face-to-face communication involves direct,
in-person interaction between individuals - Face-to-face conversations are typically not
documented, relying on participants' memory for
recall.
www.cambridge.edu.in
Department of Information Science Engineering
28Module 2 - The Data link layer
Design issues of DLL
- Frame how support in DLL?
- Error Control?
- Flow Control?
- Error Detection and Correction?
- Error Correcting Codes?
www.cambridge.edu.in
Department of Information Science Engineering
29Module 2 - The Data link layer
Design issues of DLL
- Error Control
- 1. If Sender receives a negative acknowledgement
or positive acknowledgement about a frame - 2. In case of malfunctioning hardware or a
faulty communication channel. Timer will be used
and to assign sequence numbers for outgoing
frames - The whole issue of managing the timers and
sequence numbers so as to ensure that each frame
is ultimately passed to the network layer at the
destination exactly once, no more and no less, is
an important part of the duties of the data link
layer
www.cambridge.edu.in
Department of Information Science Engineering
30Module 2 - The Data link layer
Design issues of DLL
- Error Control
- Marking the start and end of each frame, we come
to the next problem - How to make sure all frames are eventually
delivered to the network layer at the destination
and in the proper order. - Not bothering about unacknowledged connectionless
service it might be fine if the sender just kept
outputting frames without regard to whether they
were arriving properly. - But for reliable, connection-oriented service it
would not be fine at all.
www.cambridge.edu.in
Department of Information Science Engineering
31Module 2 - The Data link layer
Design issues of DLL
- Error Control
- Typically, the protocol calls for the receiver to
send back special control frames bearing Positive
Acknowledgement or negative acknowledgement. - If the sender receives a positive acknowledgement
about a frame, it knows the frame has arrived
safely. - On the other hand, a negative acknowledgement
means that something has gone wrong and the frame
must be transmitted again.
www.cambridge.edu.in
Department of Information Science Engineering
32Module 2 - The Data link layer
Design issues of DLL
- Error Control
- In case of malfunctioning hardware or a faulty
communication channel. - Timer will be used and to assign sequence numbers
for outgoing frames. - This possibility is dealt with by introducing
timers into the data link layer. When the sender
transmits a frame, it generally also starts a
timer. - The timer is set to expire after an interval long
enough for the frame to reach the destination, be
processed there, and have the acknowledgement
propagate back to the sender. - Even if repeat to re transmit To prevent this
from happening, it is generally necessary to
assign sequence numbers to outgoing frames, so
that the receiver can distinguish retransmissions
from originals.
www.cambridge.edu.in
Department of Information Science Engineering
33Module 2 - The Data link layer
Design issues of DLL
- Flow Control
- Another important design issue that occurs in the
data link layer is what to do with a sender that
systematically wants to transmit frames faster
than the receiver can accept them. - Clearly, something has to be done to prevent this
situation. - NICs (Network Interface Cards) are sometimes
- said to run at wire speed, meaning that
they can - handle frames as fast as they can arrive on
the link.
www.cambridge.edu.in
Department of Information Science Engineering
34Module 2 - The Data link layer
Design issues of DLL
- Flow Control
- Two approaches are commonly used to prevent the
overflow control. - Feedback-based flow control
- Rate-based flow control
- In the first one, feedback-based flow control,
the receiver sends back information to the sender
giving it permission to send more data, or at
least telling the sender how the receiver is
doing. - In the second one, rate-based flow control, the
protocol has a built-in mechanism that limits the
rate at which senders may transmit data, without
using feedback from the receiver.
www.cambridge.edu.in
Department of Information Science Engineering
35Module 2 - The Data link layer
Design issues of DLL
Error Detection and Correction
www.cambridge.edu.in
Department of Information Science Engineering
36Module 2 - The Data link layer
Design issues of DLL
- Error Detection and Correction
- Parity is commonly used in the design of
error-checking codes. - There are two main types of parity Odd Parity
and Even Parity - Although this chapter is explicitly about the
data link layer and its protocols, many of the
principles we will study here, such as error
control and flow control, are found in transport
and other protocols as well. - The former strategy uses error-correcting codes
and the latter uses error-detecting codes - The use of error-correcting codes is often
referred to as FEC (Forward Error Correction).
www.cambridge.edu.in
Department of Information Science Engineering
37Module 2 - The Data link layer
Design issues of DLL
Single-bit error
www.cambridge.edu.in
Department of Information Science Engineering
38Module 2 - The Data link layer
Design issues of DLL
- Erasure channel Other types of errors also
exist. Sometimes, the location of an error will
be known, perhaps because the physical layer
received an analog signal that was far from the
expected value for a 0 or 1 and declared the bit
to be lost. This situation is called an erasure
channel. - We will examine both error-correcting codes and
error-detecting codes next. - Error-correcting codes are also seen in the
physical layer, particularly for noisy channels,
and in higher layers, particularly for real-time
media and content distribution. - Error-detecting codes are commonly used in data
link, network, and transport layers.
www.cambridge.edu.in
Department of Information Science Engineering
39Module 2 - The Data link layer
Error-Correcting Codes
www.cambridge.edu.in
Department of Information Science Engineering
40Module 2 - The Data link layer
Error-Correcting Codes
- Errors and Error Correcting Codes (EEC)
- We will examine four different error-correcting
codes/models - 1. Hamming codes.
- 2. Binary convolutional codes.
- 3. Reed-Solomon codes.
- 4. Low-Density Parity Check (LDPC) codes.
- All of these codes add redundancy to the
information that is sent. - A frame consists of m data (i.e., message) bits
and r redundant (i.e. check bits) bits.
www.cambridge.edu.in
Department of Information Science Engineering
41Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes add redundancy to
- Block code
- Systematic code
- linear code
- Convolutional codes
Types 1. Hamming codes. 2. Binary convolutional
codes. 3. Reed-Solomon codes. 4. Low-Density
Parity Check (LDPC) codes.
In general, block codes, systematic codes, linear
codes and binary conventional codes are all types
of error-correcting codes used in various types
of error correcting models in digital
communication systems.
www.cambridge.edu.in
Department of Information Science Engineering
42Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes add redundancy in
- In a block code, the r check bits are computed
solely as a function of the m data bits with
which they are associated, as though the m bits
were looked up in a large table to find their
corresponding r check bits. - In a systematic code, the m data bits are sent
directly, along with the check bits, rather than
being encoded themselves before they are sent. - In a linear code, the r check bits are computed
as a linear function of the m data bits. - Convolutional codes use shift registers and
modulo-2 addition (XOR) to encode input data.
www.cambridge.edu.in
Department of Information Science Engineering
43Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Hamming code
- The Hamming distance is a metric used to measure
the difference between two strings of equal
length. - For example, consider the two strings 101010
and 111000. The Hamming distance between these
two strings is 3, since there are three positions
where the corresponding symbols are different
the first, fourth, and sixth positions - Hamming code is a type of linear block code that
is used to detect and correct errors in digital
communication systems. - It is also a systematic code that adds redundant
bits to the message to detect and correct errors.
www.cambridge.edu.in
Department of Information Science Engineering
44Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Hamming code
- In Hamming codes the bits of the codeword are
numbered consecutively, starting with bit 1 at
the left end, bit 2 to its immediate right, and
so on. - Basic Hamming code above corrects 1-bit errors
only. - Trick to use it to correct burst errors (A burst
error is a type of error when two or more bits in
the data unit have changed from 0 to 1 or vice
versa ) - The bits that are powers of 2 (1, 2, 4, 8, 16,
etc.) are check bits. - The rest (3, 5, 6, 7, 9, etc.) are filled up with
the m data bits. This pattern is shown for an
(11,7) Hamming code with 7 data bits and 4 check
bits in figure. - Let the total length of a block be n (i.e., n m
r). We will describe this as an (n,m) code. An
n-bit unit containing data and check bits is
referred to as an nbit codeword.
www.cambridge.edu.in
Department of Information Science Engineering
45Module 2 - The Data link layer
Error-Correcting Codes
Error-Correcting Codes - Hamming code
www.cambridge.edu.in
Department of Information Science Engineering
46Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Hamming code
- How it works?
- Example 1
- 21 (as sum of powers of 2) 1 4 16
- Bit 21 is checked by check bits 1, 4 and 16.
- No other bit is checked by exactly these 3 check
bits. - Assume one-bit error
- If any data bit bad, then multiple check bits
will be bad. - Example 2
- 23 (as sum of powers of 2) 1 2 4 16
- Bit 21 is checked by check bits 1,2, 4 and 16.
- If nbit codeword will check and compare, all data
bit are goodit might a good frame.
www.cambridge.edu.in
Department of Information Science Engineering
47Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Binary Convolutional
code - The second code we will look at is a
convolutional code. This code is the only one we
will cover that is not a block code. - In a convolutional code, an encoder processes a
sequence of input bits and generates a sequence
of output bits. - The output depends on the current and previous
input bits. - That is, the encoder has memory.
- Convolutional codes are specified in terms of
their Code rate and constraint length.
www.cambridge.edu.in
Department of Information Science Engineering
48Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Binary Convolutional
code - Basically, there are mainly two parameters that
define the convolutional coding which are as
follows - Constraint length
- The number of previous bits on which the output
depends is called the constraint length of the
code - Code rate
- It is the ratio of a number of bits shifted at
once within the shift register (denoted by k) to
the total number of bits in an encoded
(generated) bit stream (denoted by n).
www.cambridge.edu.in
Department of Information Science Engineering
49Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Binary Convolutional
code - A convolutional code can be represented as (n,k,
K) where - k is the number of bits shifted into the encoder
at one time. - Generally, k 1.
- n is the number of encoder output bits
corresponding to k information bits. - The code-rate, Rc k/n .
- The encoder memory, a shift register of size k,
is the constraint length. - n is a function of the present input bits and the
contents of K. - The state of the encoder is given by the value of
(K - 1) bits.
www.cambridge.edu.in
Department of Information Science Engineering
50Module 2 - The Data link layer
Error-Correcting Codes
Error-Correcting Codes - Binary Convolutional
code
www.cambridge.edu.in
Department of Information Science Engineering
51Module 2 - The Data link layer
Error-Correcting Codes
For example, if 111 is input and the initial
state is all zeros, the internal state, written
left to right, will become 100000, 110000, and
111000 after the first, second, and third bits
have been input. The output bits will be 11,
followed by 10, and then 01. It takes seven
shifts to flush an input completely so that it
does not affect the output. The constraint length
of this code is thus k 7.
Error-Correcting Codes - Binary Convolutional
code
www.cambridge.edu.in
Department of Information Science Engineering
52Module 2 - The Data link layer
Error-Correcting Codes
- Convolutional codes have been popular in practice
because it is easy to factor - the uncertainty of a bit being a 0 or a 1
into the decoding. - For example, suppose -1V is the logical 0 level
and 1V is the logical 1 level, we might receive
0.9V and -0.1V for 2 bits. - Instead of mapping these signals to 1 and 0 right
away, we would like to treat 0.9V as very
likely a 1 and -0.1V as maybe a 0 and
correct the sequence as a whole. - This approach of working with the uncertainty of
a bit is called soft-decision decoding.
Conversely, deciding whether each bit is a 0 or a
1 before subsequent error correction is called
hard-decision decoding.
www.cambridge.edu.in
Department of Information Science Engineering
53Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Reed-Solomon code.
- Reed-Solomon codes are the code that was
introduced by Irving S. Reed and Gustave Solomon.
- The encoder of Reed-Solomon codes differs from a
binary encoder in that it operates on multiple
bits rather than individual bits. - So basically, Reed-Solomon codes help in
recovering corrupted messages that are being
transferred over a network. - In Reed-Solomon codes, we have
- Binary Encoder and
- Binary Decoder
www.cambridge.edu.in
Department of Information Science Engineering
54Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Reed-Solomon code.
- Parameters of Reed-Solomon code
- (n, k) code is used to encode m-bit symbols.
- Block length(n) is given by 2m-1 symbols.
- In Reed-Solomon codes, message size is given by
(n-2t) where t number of errors corrected. - Parity check size is given by (n-k) or 2t
symbols. - Minimum distance(a) is given by (2t1).
- Message size is of k bits.
www.cambridge.edu.in
Department of Information Science Engineering
55Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - Reed-Solomon code.
- Decoding
- At the receiver end we perform the following
methods - The receiver receives r(x) at the receiver end.
- If s(x) r(x) then r(x)/g(x) has no remainder.
- If it has remainder, then r(x) p(x) g(x)
e(x) where e(x) is an error polynomial
www.cambridge.edu.in
Department of Information Science Engineering
56Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - LDPC (Low-Density Parity
Check) code - The final error-correcting code we will cover is
the LDPC (Low-Density Parity Check) code. This
corrects errors. - LDPC codes are linear block codes that were
invented by Robert Gallagher. In an LDPC code,
each output bit is formed from only a fraction of
the input bits. - This leads to a matrix representation of the code
that has a low density of 1s, hence the name for
the code. The received codewords are decoded with
an approximation algorithm that iteratively
improves on a best fit of the received data to a
legal codeword.
www.cambridge.edu.in
Department of Information Science Engineering
57Module 2 - The Data link layer
Error-Correcting Codes
- Error-Correcting Codes - LDPC (Low-Density Parity
Check) code - Representations for LDPC codes Basically there
are two different possibilities to represent LDPC
codes. - Like all linear block codes they can be described
via matrices. - The second possibility is a graphical
representation. - A LDPC code is represented by , where is the
block length, is the number of 1s in each column
and is the number of 1s in each row, holding the
following properties - - j is the small fixed number of 1s in each
column, where j gt 3 - k is the small fixed number of 1s in each row,
where k gt j.
www.cambridge.edu.in
Department of Information Science Engineering
58Module 2 - The Data link layer
Error-Correcting Codes
Low - Density Parity Check Matrix This examples
illustrates an (12, 3, 4) LDPC matrix, i.e. n
12, j 3 and k 4. This implies that each
equation operates on 4 code symbols and each code
symbol appears in 3 equations. Unlike parity
check matrix of the Hamming code, this code does
not have any diagonal 1s in parity bits.
www.cambridge.edu.in
Department of Information Science Engineering
59Module 2 - The Data link layer
Error-Detecting Codes
www.cambridge.edu.in
Department of Information Science Engineering
60Module 2 - The Data link layer
Error-Detecting Codes
- Data can be corrupted during transmission. Some
applications require that errors be detected and
corrected.
In a single-bit error, only 1 bit in the data
unit has changed.
www.cambridge.edu.in
Department of Information Science Engineering
61Module 2 - The Data link layer
Error-Detecting Codes
A burst error means that 2 or more bits in the
data unit have changed.
www.cambridge.edu.in
Department of Information Science Engineering
62Module 2 - The Data link layer
Error-Detecting Codes
- To detect or correct errors, we need to send
extra (redundant) bits with data. - we can divide our message into blocks(frames),
each of k bits, called datawords (message). We
can add r redundant bits to each block to make
the length n k r. - The resulting n-bit blocks are called codewords
- An error-detecting code can detect only the types
of errors for which it is designed other types
of errors may remain undetected.
www.cambridge.edu.in
Department of Information Science Engineering
63Module 2 - The Data link layer
Error-Detecting Codes
- We will examine three different error-detecting
codes. - They are all linear, systematic block codes
- 1. Parity.
- 2. Checksums.
- 3. Cyclic Redundancy Checks (CRCs).
www.cambridge.edu.in
Department of Information Science Engineering
64Module 2 - The Data link layer
Error-Detecting Codes
- Parity Error detecting Code
- Parity Bit Method
- A parity bit is an extra bit included in binary
message to make total number of 1s either odd or
even. - Parity word denotes number of 1s in a binary
string. - Always transmit according to the rule
- On receipt, if rule is violated, word is invalid
- There are two parity system even and odd parity
checks.
www.cambridge.edu.in
Department of Information Science Engineering
65Module 2 - The Data link layer
Error-Detecting Codes
- Parity Error detecting Code
- Almost all block codes used today belong to a
subset called linear block codes. A linear block
code is a code in which the XOR (addition
modulo-2) of two valid codewords creates another
valid codeword. - Even Parity Bit
- Doing this is equivalent to computing the (even)
parity bit as the modulo 2 sum or XOR of the data
bits.
www.cambridge.edu.in
Department of Information Science Engineering
66Module 2 - The Data link layer
Error-Detecting Codes
Parity Error detecting Code Even Parity Bit
www.cambridge.edu.in
Department of Information Science Engineering
67Module 2 - The Data link layer
Error-Detecting Codes
- Parity Error detecting Code
- Disadvantage
- One difficulty with this scheme is that a single
parity bit (either even or odd parity check) can
only reliably detect a single-bit error in the
block. - If the block is badly garbled by a long burst
error, the probability that the error will be
detected is only 0.5, which is hardly acceptable. - However, there is something else we can do that
provides better protection against burst errors
we can compute the parity bits over the data in a
different order than the order in which the data
bits are transmitted. - Doing so is called interleaving.
www.cambridge.edu.in
Department of Information Science Engineering
68Module 2 - The Data link layer
Error-Detecting Codes
Parity Error detecting Code Interleaving
procedure Suppose that a certain error detection
code has generated the four codewords 10011101,
00101100, 10100101 and 11110000. The next
diagrams illustrates an interleaving procedure
www.cambridge.edu.in
Department of Information Science Engineering
69Module 2 - The Data link layer
Error-Detecting Codes
Parity Error detecting Code
www.cambridge.edu.in
Department of Information Science Engineering
70Module 2 - The Data link layer
Parity Error detecting Code
Periodic interleaving The sequential blocks of
code may be written to a matrix in a row-wise
manner and then read out from the matrix in a
column-wise manner
www.cambridge.edu.in
Department of Information Science Engineering
71Module 2 - The Data link layer
Error-Detecting Codes
- Checksums Error detecting Code
- The second kind of error-detecting code, the
checksum, is closely related to groups of parity
bits. - The word checksum is often used to mean a
group of check bits associated with a message,
regardless of how are calculated. - A group of parity bits is one example of a
checksum. - However, there are other, stronger checksums
based on a running sum of the data bits of the
message. - The checksum is usually placed at the end of the
message, as the complement of the sum function. - This way, errors may be detected by summing the
entire received codeword, both data bits and
checksum. If the result comes out to be zero, no
error has been detected.
www.cambridge.edu.in
Department of Information Science Engineering
72Module 2 - The Data link layer
Error-Detecting Codes
- Checksums Error detecting Code
- One example of a checksum is the 16-bit Internet
checksum used on all Internet packets as part of
the IP protocol
www.cambridge.edu.in
Department of Information Science Engineering
73Module 2 - The Data link layer
Error-Detecting Codes
- Checksums Error detecting Code
- The Receiver after receiving data checksum
passes it to checksum checker. - Checksum checker divides this data unit into
various subunits of equal length and adds all
these subunits. - These subunits also contain checksum as one of
the subunits. - The resultant bit is then complemented.
- If the complemented result is zero, it means the
data is error-free. - If the result is non-zero it means the data
contains an error and Receiver rejects it.
www.cambridge.edu.in
Department of Information Science Engineering
74Module 2 - The Data link layer
Error-Detecting Codes
- Checksums Error detecting Code
- Ones or Twos complement arithmetic process
- Modern computers run twos complement arithmetic,
in which a negative number is the ones
complement plus one. - On a twos complement computer, the ones
complement sum is equivalent to taking the sum
modulo and adding any overflow of the high
order bits back into the low-order bits. - This algorithm gives a more uniform coverage of
the data by the checksum bits. - There is another benefit, too. Ones complement
has two representations of zero, all 0s and all
1s. This allows one value (e.g., all 0s) to
indicate that there is no checksum, without the
need for another field.
www.cambridge.edu.in
Department of Information Science Engineering
75Module 2 - The Data link layer
Error-Detecting Codes
- Checksums Error detecting Code
- The Internet checksum in particular is efficient
and simple but provides weak protection in some
cases precisely because it is a simple sum. - It does not detect the deletion or addition of
zero data, nor swapping parts of the message, and
it provides weak protection against message
splices in which parts of two packets are put
together. - These errors may seem very unlikely to occur by
random processes, but they are just the sort of
errors that can occur with buggy hardware. - A better choice is Fletchers checksum (Fletcher,
1982). It includes a positional component, adding
the product of the data and its position to the
running sum. - This provides stronger detection of changes in
the position of data.
www.cambridge.edu.in
Department of Information Science Engineering
76Module 2 - The Data link layer
Error-Detecting Codes
- CRC (Cyclic Redundancy Check) Error detecting
Code - Although the two Parity check and Checksum
schemes may sometimes be adequate at higher
layers, in practice, a third and stronger kind of
error-detecting code is in widespread use at the
link layer is the CRC (Cyclic Redundancy Check),
also known as a polynomial code. - Data
- CRC Generator
- CRC Bits reminder bits not Quotient bits
- CRC Generator -gt n bits
- CRC Bits -gt (n-1) bits
Data (n-1) 0s CRC Generator -gt n bits
www.cambridge.edu.in
Department of Information Science Engineering
77Module 2 - The Data link layer
Error-Detecting Codes
- CRC enables the transmit end to append an R-bit
check code to the K-bit data to be sent, generate
a new frame, and send the frame to the receive
end. - When receiving the new frame, the receive end
checks whether the received data is correct based
on the received data and check code.
CRC Code
Data
www.cambridge.edu.in
Department of Information Science Engineering
78Module 2 - The Data link layer
Error-Detecting Codes
- CRC (Cyclic Redundancy Check) Error detecting
Code - CRC Cyclic Redundancy Check or polynomial code
- Consider bits of a message to be coefficients of
a polynomial - M(x) 11000 1x4 1x3 0x2
0x1 0x0 - Of course real messages will be
much longer and hence of higher degree - Agree on a small-degree generator polynomial G(x)
of degree r - Note G(x) has r digits to the right of
the leading 1, hence r1 total - Divide xrM(x) by G(x) using modulo 2 division
(algebraic field theory does not have carries for
addition or borrows for subtraction. Both
addition and subtraction are identical to
exclusive OR.) getting the remainder polynomial
R(x) - Transmit T(x) xrM(x) - R(x) note that this has
remainder 0 when divided by G(x) - Receiver rejects frame if the remainder it
computers is not 0
www.cambridge.edu.in
Department of Information Science Engineering
79Module 2 - The Data link layer
Error-Detecting Codes
CRC (Cyclic Redundancy Check) Error detecting
Code The algorithm for computing the CRC is as
follows 1. Let r be the degree of G(x). Append r
zero bits to the low-order end of the frame so it
now contains m r bits and corresponds to the
polynomial x rM(x). 2. Divide the bit string
corresponding to G(x) into the bit string
corresponding to x rM(x), using modulo 2
division. 3. Subtract the remainder (which is
always r or fewer bits) from the bit string
corresponding to x rM(x) using modulo 2
subtraction. The result is the check summed frame
to be transmitted. Call its polynomial T(x).
www.cambridge.edu.in
Department of Information Science Engineering
80Module 2 - The Data link layer
Error-Detecting Codes
An R-bit check code is appended to the K-bit
data, and the entire code length becomes N bits.
This type of code is also referred to as (N,K)
code. For a given (N,K) code, it can be proved
that there is a polynomial g(x) whose highest
power is NKR, and an R-bit check code can be
generated based on g(x). The algorithm is based
on the GF(2) polynomial arithmetic, as shown in
the figure.
www.cambridge.edu.in
Department of Information Science Engineering
81Figure illustrates the calculation for a frame
1101011111 using the generator G(x) x 4 x 1.
www.cambridge.edu.in
Department of Information Science Engineering
82Module 2 - The Data link layer
Error-Detecting Codes
- Certain polynomials have become international
standards. - The one used in IEEE 802 followed the example of
Ethernet and is - Although the calculation required to compute the
CRC may seem complicated, it is easy to compute
and verify CRCs in hardware with simple shift
register Circuits.
www.cambridge.edu.in
Department of Information Science Engineering
83Module 2 - The Data link layer
Error-Detecting Codes
- Easily computed with feedback shift register
hardware - Detects any single-bit error
- Proper choice of G(x) gives detection of any two
bit errors - Proper choice of G(x) gives detection of any odd
number of bit errors - Detects any burst error of length lt r
- Received message is T(x)E(x) for some error
polynomial E(x) - If E(x) represents a burst of length lt r then
it can be written as xi(F(x)) where the degree of
F(x) is lt r - If G(x) has an x0 term it cant divide xi and no
degree r polynomial divides a polynomial of
degree lt r
www.cambridge.edu.in
Department of Information Science Engineering
84Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- To start with, we assume that the physical layer,
data link layer, and network layer are
independent processes that communicate by passing
messages back and forth. - A common implementation is shown in Figure.
- The physical layer process and some of the data
link layer process run on dedicate hardware
called a NIC (Network Interface Card). - The link layer process often taking the form of a
device driver (OS). - Three processes (physical layer, data link layer,
and network layer ) offloaded to dedicated
hardware called a network accelerator, or three
processes running on the main CPU. - In any event, treating the three layers as
separate processes makes the discussion
conceptually cleaner and also serves to emphasize
the independence of the layers.
www.cambridge.edu.in
Department of Information Science Engineering
85Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
www.cambridge.edu.in
Department of Information Science Engineering
86Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- Another key assumption is that machine A wants to
send a long stream of data to machine B, using a
reliable, connection-oriented service. - Later, we will consider the case where B also
wants to send data to A simultaneously. - A is assumed to have an infinite supply of data
ready to send and never has to wait for data to
be produced. - Instead, when As data link layer asks for data,
the network layer is always able to comply
immediately. - We also assume that machines do not crash.
- That is, these protocols deal with communication
errors, but not the problems caused by computers
crashing and rebooting
www.cambridge.edu.in
Department of Information Science Engineering
87Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- Utopia
- Data are transmitted in one direction only.
- Both the transmitting and receiving network
layers are always ready. - Processing time can be ignored.
- Infinite buffer space is available.
- And best of all, the communication channel
between the data link layers never damages or
loses frames. - This thoroughly unrealistic protocol, which we
will nickname Utopia, is simply to show the
basic structure on which we will build.
www.cambridge.edu.in
Department of Information Science Engineering
88Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- Assumptions
- Each layer (physical, data link and network) are
independent of each other. - Machine A wants to send a long data stream to
machine B using a reliable connection-oriented
service. - The data link layer encapsulates the packet in a
frame by adding a data link header and trailer. - The software (and hardware) is dedicated full
time to handling just one channel. - Checksums are computed and used to manage
erroneous frames. - A frame header and tail will never be given to
the network layer.
www.cambridge.edu.in
Department of Information Science Engineering
89Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- Five data structures that describe a frame
boolean, integer, packet, frame kind and frame. - A frame is composed of four fields (frame,
header) kind, seq, ack, and info - Frame sequence numbers are always in the range of
0 and a predefined maximum constant and are
incremented in a circular manner. Timers are used
to manage lost or missing frames or
acknowledgements Network layer can be disabled to
control the number of packets to prevent the
network layerfrom swamping it with packets for
which it has no buffer space
www.cambridge.edu.in
Department of Information Science Engineering
90Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- An Unrestricted Simplex Protocol UTOPIA
- Data transmitted in one direction only
- Transmitting and receiving layers are always
ready - Processing time is ignored
- Infinite buffer space
- Ideal communication channel - no loss, no errors
-
www.cambridge.edu.in
Department of Information Science Engineering
91Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- A Simplex Stop-and-Wait Protocol
- Consider a slow receiver, No buffer space and
Slow Processor but channel is still error free
and traffic is still simplex - Possible solutions
- Introduction of delays
- Send information very slowly
- Stop and wait
- Sender only sends out the succeeding packet
afterreceiving an acknowledgement, - Data traffic is simplex,
- Communication channel needs to be bidirectional
- Communication channel can be half-duplex
www.cambridge.edu.in
Department of Information Science Engineering
92Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- A Simplex Protocol for a Noisy Channel
- Lost or damaged frames
- Damage must be detectable through checksums
- Possible solution
- Receiver only acknowledges when there is an
undamaged frame received. - What happens if the acknowledgement frame gets
lost? The protocol would keep passing wrong
information up to the network protocol. - The proper solution requires the receiver to
distinguish a frame that it is seeing for
thefirst time from a retransmission. - Use sequence numbers
www.cambridge.edu.in
Department of Information Science Engineering
93Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- A Simplex Protocol for a Noisy Channel
- What is the minimum number of bits needed for the
sequence number? - To ensure that the frame header is also small
1-bit sequence number is sufficient - Protocols in which the sender waits for a
positive acknowledgement before advancing to
thenext data item - PAR (Positive Acknowledgement with
Retransmission) - ARQ (Automatic Repeat request)
- Timeout interval must be long enough to prevent
premature timeouts - It cannot be set too short allow time for the
frame to reach the receiver, to get processed and
to receive an acknowledgement
www.cambridge.edu.in
Department of Information Science Engineering
94Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- A Simplex Protocol for a Noisy Channel
- Sender can wait for three things
- an acknowledgement frame arrives undamaged
- an acknowledgement frame arrives damaged timer
goes off - Valid frames are passed on to the network layer
- Duplicate frames and damaged frames are not
passed on to the network layer.
www.cambridge.edu.in
Department of Information Science Engineering
95Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
DLL Protocols
www.cambridge.edu.in
Department of Information Science Engineering
96Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
DLL Protocols
www.cambridge.edu.in
Department of Information Science Engineering
97Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
DLL Protocols Flow Control
ARQ (Automatic Repeat request) Or PAR
(Positive Acknowledgement with Retransmission).
www.cambridge.edu.in
Department of Information Science Engineering
98Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
A utopian simplex Protocol Sender Side
www.cambridge.edu.in
Department of Information Science Engineering
99Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
A utopian simplex Protocol Receiver Side
www.cambridge.edu.in
Department of Information Science Engineering
100Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
A Simplex Stop-and-Wait Protocol for an
Error-Free Channel Sender Side
www.cambridge.edu.in
Department of Information Science Engineering
101Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
A Simplex Stop-and-Wait Protocol for an
Error-Free Channel Receiver Side
www.cambridge.edu.in
Department of Information Science Engineering
102Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- Sendand-Wait Vs Sliding Window Protocols
- Sendand-Wait - Only one frame can send at a
time - Where as Sliding Window Protocols allows to send
multiple frames at a time - The sliding window is a technique for sending
multiple frames at a time. - It controls the data packets between the two
devices where reliable and gradual delivery of
data frames is needed. - It is also used in TCP (Transmission Control
Protocol).
www.cambridge.edu.in
Department of Information Science Engineering
103Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- Sliding Window Protocols
- There are three protocols, which are
bidirectional protocols that belong to a class
called sliding window protocols. - A One-Bit Sliding Window Protocol
- A Protocol Using Go-Back-N ARQ
- A Protocol Using Selective Repeat
- The three differ among themselves in terms of
efficiency, complexity, and buffer requirement. - In these, as in all sliding window protocols,
each outbound frame contains a sequence number,
ranging from 0 up to some maximum.
www.cambridge.edu.in
Department of Information Science Engineering
104Module 2 - The Data link layer
ELEMENTARY DATA LINK PROTOCOLS
- Sliding Window Protocols
- The maximum is usually 2n - 1 so the sequence
number fits exactly in an n-bit field. - The stop-and-wait sliding window protocol uses n
1, restricting the sequence numbers to 0 and 1,
but more sophisticated versions can use an
arbitrary n. - The essence of all sliding window protocols is
that at any instant of time, the sender maintains
a set of sequence numbers corresponding to frames
it is permitted to send. - These frames are said to fall within the s