Error Detection and Correction in Networks
Error Detection and Correction in Networks
Qn-1 : Define what is an error and explain different types with examples.
ANS:Error: In computer networks, when data is transmitted from a sender to a receiver, the
bits may get altered due to noise, interference, or signal [Link] error means the
received data does not match the transmitted data.
Types of Errors
1. Single-bit Error
2. Burst Error
ANS:When we send data over a network, errors can occur. To handle this, the sender adds
some extra bits (called redundant bits) to the original data before transmission.
These bits do not carry information, but they help the receiver detect (and sometimes
correct) errors.
At the receiver side, these redundant bits are checked. If the pattern doesn’t match
what is expected, the receiver knows an error has occurred.
Qn- 4 : Define Hamming distance. How is it used for error detection and correction?
ANS :Definition:The Hamming distance between two binary words of the same length is
thenumber of bit positions in which they differ.
ANS :Inblock coding, the message is divided into blocks of fixed length k bits, called
datawords. To each dataword, we addredundant bits(r) to make a longer block of
n=k+r, bits, called acodeword. If the set of all codewords forms alinear subspace
the code is called aLinear Block Code.
Here, k=4 (data bits), n=7 (codeword length), so r=3 (redundant bits).
Example
Dataword = 1001 → x3+1
Generator = 1011 → g(x)= x3+x+1
If the receiver divides the received codeword by 1011 and remainder ≠ 0 → error
detected.
Advantages
1) Detects single-bit, many double-bit, odd number, and burst errors effectively.
2) Easy to implement in hardware/software.
Qn- 8 :Explain the working of Cyclic Redundancy Check (CRC) with encoder and decoder.
ANS :Cyclic Redundancy Check (CRC)
CRC is an error-detecting technique based on cyclic codes. It uses polynomial division to
generate redundancy bits (called CRC bits).
Example
Dataword = 1001 → M(x)=x3+1
Generator = 1011 → g(x)=x3+x+1, degree r=3
Append 3 zeros → 1001000
Divide by 1011 → remainder = 110
Codeword = 1001 110
Rules:
0+0=01+0=10+1=11+1=0
Example:
(x5+x3+x+1)+(x4+x3+x2+1)
= x5+(x3+x3)+x4+x2+x+(1+1)
= x5+x4+x2+x
Bitwise: 101011 + 110011 = 011010.
Example:
Divide 1001000 (i.e. x6+x3) by generator 1011 (i.e. x3+x+1)
So, (x6+x3)÷(x3+x+1)=quotient+(x+1)
Dividend = 1001000
Quotient: 1001
Divisor: 1011 ) 1001000
1011
-------------
00110
1011
-------------
1010
1011
-------------
011← Remainder
Final Remainder = 011 (3 bits).
For any binary polynomial p(x)=∑aixi, evaluating at x=1gives the parity of its
coefficients:
p(1)=∑ai (mod2).
By step 2, e(1)=1
If e(x) were divisible by g(x), step 3 would force e(1)=0. That contradicts e(1)=1.
Therefore e(x)is not divisible by g(x).
Since the receiver checks divisibility by g(x) (CRC check), the division yields a
nonzero remainder for every odd-weight error polynomial. Hence all odd-number
errors are detected.
Examples
1) Single-bit errors
A single-bit error means only one bit is flipped. The error polynomial is of the
form e(x)=xi.
If the generator polynomial g(x) has more than one term, then no single power
of x is divisible by g(x).
This guarantees that the remainder after division is nonzero, so all single-bit
errors are detected.
2) Double-bit errors
A double-bit error at positions i and j is given by e(x)=xi+xj=xj(xi−j+1).
Such an error will escape detection only if g(x) divides (xi−j+1).
By choosing a generator that does not divide any polynomial of the form (xt+1)
for small t, cyclic codes can detect all double-bit errors separated by up to certain
distances.
Thus, most double-bit errors are detected with a properly chosen generator
polynomial.
4) Burst errors
A burst error of length L means a sequence of consecutive bits is corrupted.
Cyclic codes can detect these very effectively:
If L≤r (where r is the degree of the generator), all burst errors are detected.
If L=r+1, detection is guaranteed with probability 1− (1/2r−1).
If L>r+1, detection probability is 1−(1/2r).
Thus, cyclic codes are highly effective in detecting burst errors, which are the
most common in real communication channels.
2. Double-Bit Errors
A double-bit error at positions i and j has error polynomial:
E(x)=xi+xj
Detection depends on whether G(x) divides 1+xi−j
If G(x) does not divide this polynomial, the error is detected.
4. Burst Errors
1. All burst errors with L <=r will be detected.
2. All burst errors with L = r + 1 will be detected with probability 1 - (1/2)r-1
3. All burst errors with L >r + 1 will be detected with probability 1- (1/2)r
Qn14: Explain the checksum technique with a numerical example
ANS : Checksum Technique:
The checksum is an error detection method used in networking (like TCP/IP).
Sender and receiver agree on a fixed word size.
The sender:
1. Divides the data into equal-sized words.
2. Adds them using 1’s complement arithmetic.
3. Takes the 1’s complement of the sum → this becomes the checksum.
4. Sends data + checksum.
The receiver:
1. Adds all words (including checksum).
2. If the result is all 1’s (no carry left), the data is accepted as error-free.
3. Otherwise, an error is detected.
Example:
Qn15: Explain Internet checksum algorithm with a numerical example
ANS : Internet Checksum Algorithm
The Internet checksum is used in TCP/IP (for IP, TCP, UDP headers) to detect
errors during transmission. It works on the principle of 1’s complement addition.
Example:
Qn16: What are Data Link Layer services? Explain framing, flow control, and error control
ANS : The Data Link Layer (DLL) is the second layer in the OSI model. Its main role is to
ensure reliable communication between directly connected nodes over a physical link.
1. Framing:
The physical layer only sees raw bits. The DLL groups these bits into [Link]
frame has a header and trailer that carry information such as addresses, error-check
bits, etc.
Techniques:
o Character Count
o Character Stuffing
o Bit Stuffing:
By these techniques Receiver can identify where one frame ends and another begins.
2. Flow Control
Ensures that the sender does not transmit faster than the receiver can process.
Techniques:
o Stop-and-Wait Protocol:
o Sliding Window Protocols (Go-Back-N, Selective Repeat
These techniques Prevents data loss due to buffer overflow.
3. Error Control
Transmission errors can occur due to noise. DLL provides mechanisms for error
detection and sometimes error correction.
Techniques:
o Error Detection:
Parity Bit
Checksums
Cyclic Redundancy Check (CRC)
o Error Correction / Recovery:
Automatic Repeat Request (ARQ) methods
Stop-and-Wait ARQ: Retransmit if no ACK received.
Go-Back-N ARQ: Retransmit from the erroneous frame onward.
Selective Repeat ARQ: Retransmit only the erroneous frame.
These techniques Ensures reliable frame delivery across a noisy physical link.
Qn17: Explain fixed-size framing and variable-size framing.
ANS : Framing is the process of dividing a continuous stream of bits into smaller called
frames. There are two types of framing: Fixed-size framing and Variable-size
framing.
1. Fixed-Size Framing:
Each frame has a constant, predefined length. The receiver can easily separate
frames since size is already known. No need for start/stop flags or additional overhead.
Advantages
1. Simple and efficient to implement.
2. No extra bits for markers → less overhead.
Disadvantages
1. Wastes bandwidth if data does not fill the entire frame.
Example: ATM (Asynchronous Transfer Mode) uses fixed 53-byte cells.
2. Variable-Size Framing
Frames can have different lengths depending on the data size. Requires
methods to define start/end of frames:
o Character Count
o Character Stuffing
o Bit Stuffing
Advantages
1. Efficient use of bandwidth
2. Flexible, supports both small and large messages.
Disadvantages
More complex implementation.
Needs extra bits or special patterns to detect frame boundaries.
1. Character-Oriented Framing
2. Bit-Oriented Framing
In this method, data is divided into frames of arbitrary bit patterns, not tied to
characters. A special bit sequence (flag) marks the start and end of the frame.
Standard flag: 01111110 (used in HDLC).To prevent confusion, whenever five
consecutive 1’s occur in data, a 0 is stuffed (inserted). Receiver removes the extra 0 →
called bit stuffing.
Qn19: Explain byte stuffing and bit stuffing with examples.
ANS : In data communication, framing is required so that the receiver can identify the
start and end of a message. Two important techniques used for this are byte stuffing
and bit stuffing.
In byte stuffing, the frame is marked with a special flag byte at the beginning
and end. If this flag byte appears in the actual data, it can confuse the receiver. To
overcome this problem, the sender inserts a special escape byte (ESC) before every
flag byte or escape byte that occurs in the data field. At the receiver’s side, whenever
an ESC is encountered, it is removed, and the following byte is treated as normal data.
For example, if the flag is F and the data contains F or E, the sender adds an ESC
before them. This way, the receiver can clearly separate the data from the frame
boundaries.
In bit stuffing, the technique works at the bit level. Here, a special bit pattern,
usually 01111110, is used as the start and end flag of the frame. If the same pattern
occurs in the data, it may be mistaken for a frame boundary. To avoid this, whenever
the sender finds five consecutive 1’s in the data, it automatically inserts a 0 bit after
them. This ensures that the pattern 01111110 never appears in the middle of the data.
The receiver, on the other hand, removes the extra 0 bits after detecting five
consecutive 1’s. For example, a data sequence 11111 will be transmitted as 111110 to
prevent confusion with the flag.
Thus, byte stuffing is a character-oriented method that uses escape bytes,
while bit stuffing is a bit-oriented method that uses inserted 0’s. Both techniques are
essential to maintain proper frame boundaries and ensure that the data is transmitted
accurately without being mistaken for control information.
Qn20: Explain connectionless and connection-oriented protocols.
ANS : In computer networks, communication between two devices can take place in
two ways: connectionless and connection-oriented protocols.
In a connectionless protocol, data is sent without first establishing a dedicated
connection between the sender and the receiver. Each packet, also called a datagram,
is treated independently and carries full addressing information. Since there is no prior
setup, delivery is not guaranteed, and packets may arrive out of order or get lost. The
Internet Protocol (IP) is the best example of a connectionless protocol. It is fast and
efficient for small messages or real-time applications where speed is more important
than reliability.
In contrast, a connection-oriented protocol requires that a connection be
established between the sender and the receiver before data transfer begins. Once the
connection is set up, data is transmitted in sequence, and the protocol ensures
reliability, error checking, and flow control. The Transmission Control Protocol (TCP)
is a well-known example. In this method, the receiver acknowledges the receipt of
packets, and if packets are lost, they are retransmitted. This makes it more reliable but
slightly slower due to the overhead of connection setup and management.
Thus, connectionless protocols are suitable for applications like video
streaming, online gaming, or voice calls where speed is crucial, while connection-
oriented protocols are used in applications like file transfer, emails, and web browsing
where accuracy and reliability are more important. Together, both approaches serve
different needs of data communication in computer networks.
Qn- 21: Explain the working of Stop-and-Wait ARQ protocol with FSM diagrams.
ANS: The Stop-and-Wait ARQ (Automatic Repeat reQuest) protocol is one of the
simplest error control methods used in computer networks to ensure reliable data
transmission. In this protocol, the sender transmits one frame at a time and then stops
to wait for an acknowledgment (ACK) from the receiver. If the ACK is received
within a fixed time (timeout period), the sender proceeds to transmit the next frame. If
the ACK is not received, or if a negative acknowledgment (NAK) is received, the
sender retransmits the same frame. This ensures that lost or corrupted frames are
correctly delivered.
At the receiver’s side, when a frame arrives, it checks for errors using error
detection methods such as CRC. If the frame is error-free, the receiver sends an ACK
and delivers the frame to the higher layer. If the frame is corrupted, the receiver
discards it and sends a NAK, asking the sender to retransmit. Since only one frame is
“in transit” at any time, the protocol is simple but not very efficient for long-distance
or high-speed networks due to idle waiting time.
ANS: In the Go-Back-N ARQ protocol, the sender can transmit several frames (up to
a window size N) without waiting for an acknowledgment. The receiver, however, is
simple and only accepts frames in order. If a frame is lost or arrives with errors, the
receiver discards it and does not acknowledge it. As a result, when the sender’s timer
for that frame expires, it retransmits the lost frame along with all the subsequent
frames, even if some of them were correctly received earlier. For example, if frame 3
is lost, the sender will retransmit frames 3, 4, 5, and so on. This ensures reliability but
can lead to unnecessary retransmissions.
The Selective Repeat ARQ protocol is a more efficient version. Here, both the
sender and receiver maintain a sliding window. The receiver can accept frames that
arrive out of order and store them in a buffer until the missing frames are correctly
received. The sender only retransmits those frames for which a negative
acknowledgment (NAK) or timeout occurs, instead of retransmitting the entire
sequence. For example, if frame 3 is lost but frames 4 and 5 are received correctly, the
receiver buffers 4 and 5, and the sender retransmits only frame 3. This reduces
redundant retransmissions but requires more complex logic and larger buffer space at
the receiver.
The Flag field is 8 bits long and has the unique bit pattern 01111110. It is
placed at both the beginning and the end of every frame to mark boundaries. To avoid
confusion when the same bit sequence appears in the data, the protocol uses bit
stuffing. The Address field is usually 8 bits and identifies the secondary station
(receiver) in unbalanced configurations or both stations in balanced configurations. In
some cases, the address field may be longer than one byte.
The Control field is also typically 8 bits and defines the type of frame being
sent. HDLC supports three types of frames: Information (I-frames) used to carry user
data, Supervisory (S-frames) used for error and flow control, and Unnumbered (U-
frames) used for control purposes such as link setup and termination. Depending on
the frame type, the control field contains sequence numbers, acknowledgment
numbers, or control commands.
The Information field is of variable length and carries the actual payload (user
data). It is present only in I-frames and certain U-frames. The Frame Check
Sequence (FCS) field is usually 16 bits or 32 bits and contains the result of a Cyclic
Redundancy Check (CRC) applied to the address, control, and information fields. It
allows the receiver to detect errors in transmission. Finally, the closing Flag field
01111110 indicates the end of the frame.
Thus, the HDLC frame structure is highly reliable because it clearly defines
boundaries with flag sequences, identifies communicating stations with the address
field, supports control and sequencing through the control field, transmits user data in
the information field, and ensures error detection using the FCS field.
The Information frame (I-frame) is used to carry user data from the network
layer to the destination. Along with the data, it also carries control information such as
send sequence numbers and receive sequence numbers. These numbers are used for
error detection and flow control by acknowledging which frames have been received
correctly. I-frames form the backbone of HDLC communication since they transport
the actual payload.
The Supervisory frame (S-frame) is used only for control purposes,
particularly for error handling and flow control. It does not carry user data. Instead, it
contains functions like Receive Ready (RR) to indicate readiness to receive more
frames, Receive Not Ready (RNR) to pause the sender, Reject (REJ) to request
retransmission from a specific frame, and Selective Reject (SREJ) to ask for
retransmission of a particular erroneous frame. This helps manage smooth data
transfer and recovery from transmission errors.
The Unnumbered frame (U-frame) is used for link management and control
functions that are not related to data sequencing. These include activities like
establishing a connection, disconnecting a link, or exchanging control commands.
They may also carry system management information.
Qn-25: Explain the Point-to-Point Protocol (PPP) frame format & transition phases.
ANS: The Point-to-Point Protocol (PPP) is a data link layer protocol used to
establish direct communication between two nodes over serial links such as telephone
lines, ISDN, or dedicated connections. PPP provides framing, error detection,
authentication, and supports multiple network layer protocols like IP, IPX, and
AppleTalk.
The PPP frame format is similar to that of HDLC but simplified. Each frame
starts and ends with a Flag field (8 bits, 01111110) which marks boundaries. The
Address field (8 bits) is usually set to 11111111 since PPP is always point-to-point
and does not require unique addressing. The Control field (8 bits) is fixed to
00000011, meaning an unnumbered frame, as PPP does not use sequence numbers.
The Protocol field (16 bits) identifies which network layer protocol is being carried,
such as IP (0x0021) or LCP (0xC021). The Information field contains variable-length
user data, and finally, the Frame Check Sequence (FCS), either 16 or 32 bits,
provides error detection using CRC.
PPP also defines several transition phases in establishing and terminating a
link. The process begins with the Dead phase, where no connection exists. When a
physical connection is detected, it moves to the Establish phase, where the Link
Control Protocol (LCP) is used to configure and test the link. If authentication is
required, the Authenticate phase follows, where methods like PAP or CHAP verify
the identity of the user. Once authentication succeeds, the protocol enters the Network
phase, during which Network Control Protocols (NCPs) are used to configure
different network layer protocols. Finally, data transfer occurs in the Open phase, and
when communication ends, the link is terminated, returning to the Dead phase.
Polling:
In the polling method, a central controller or master station sequentially
contacts each station on the ring to check if it has data to transmit. When a station is
polled, it sends its data if ready; otherwise, the controller moves to the next station.
Polling guarantees collision-free communication and is simple to implement, but it
introduces a small delay because each station must wait for its turn to be polled.