Unit 3 Networking 1 (GZRSC)
Unit 3 Networking 1 (GZRSC)
What is an Error?
The data can be corrupted during transmission (from source to receiver). A condition when
the receiver’s information does not match with the sender’s information It may be affected by
external noise or some other physical imperfections. In this case, the input data is not same as the
received output data. That means a 0 bit may change to 1 or a 1 bit may change to 0. This mismatched
data is called “Error”.
Types of Errors
Errors can be of three types, namely single
bit errors, multiple bit errors, and burst
errors.
Single bit error − In the received
frame, only one bit has been
corrupted, i.e. either changed from 0
to 1 or from 1 to 0.
BCA Page 1
Networking 1 GZRSC 2021
3.Hamming Code
1.Single Parity Check
A parity bit is a check bit, which is added to a block of data for error detection purposes.
Before adding the parity bit, number of 1’s or zeros is calculated in the data. Based on this calculation
of data an extra bit is added to the actual information / data. The addition of parity bit to the data will
result in the change of data string size. Parity is count the number of 1’s.
There is two types of parity bits in error detection.
1.Even Parity − Here the total number of bits in the message is made even. If number of 1s is
even, parity bit value is 0. If number of 1s is odd, parity bit value is 1.
2. Odd Parity − Here the total number of bits in the message is made odd. If number of 1s is
odd, parity bit value is 0. If number of 1s is even, parity bit value is 1.
Drawbacks Of Single Parity Checking
1. It can only detect single-bit errors which are very rare.
2. If two bits are interchanged, then it cannot detect the errors
Example:
For Even Parity Checking
In even parity checking, our target is to make even number of 1’s in code word generate.
Data 1’s in Data P Total 1’s Code word
1010110 4 0 4 10101100
0101111 5 1 6 01011111
0000000 0 0 0 00000000
1001100 3 1 4 10011001
1111111 7 1 8 11111111
For Odd Parity Checking
Our target is to make odd number of 1’s in code word generated in odd parity checking.
Data 1’s in Data P Total 1’s Code word
0110101 4 1 5 01101011
0101111 5 0 5 01011110
0000000 0 1 1 00000001
1011000 3 0 3 10110000
1111111 7 0 7 11111110
BCA Page 2
Networking 1 GZRSC 2021
2. Cyclic Redundancy Check (CRC)
Cyclic Redundancy Check (CRC) is an error detection method. It is based on binary division.
Cyclic Redundancy Check (CRC) is a block code invented by W. Wesley Peterson in 1961. It is
commonly used to detect accidental changes to data transmitted via telecommunications networks
and storage devices.
CRC involves
lves binary division of the data bits being sent by a predetermined divisor agreed
upon by the communicating system. The divisor is generated using polynomials. So, CRC is also
called polynomial code checksum.
Sender Receiver
Data : Data + CRC
Division : XOR CRC Generator
CRC Generator : n bits
CRC bits : (n-1) er is all zero, the data is
If remainder iscorrect
CRC bits=Data + (n-1)0s
CRC Generator.
Remainder is CRC
Data + CRC send to receiver
Example :
Sender : Receiver :
Data = 101101 Data=10110010
CRC Generator:=1101 (n) 4 bits Data crc
CRC bits =3 (n-1) 4
1) 4-1=3 CRC Generator=1101
Division = XOR
Thus, for the given CRC generator, the corresponding binary pattern is 11011011.
BCA Page 3
Networking 1 GZRSC 2021
3. Hamming Code
Hamming code is used to detect and correct the error in the transmitted data. So, it is an
error detection and correction code. It was originally invented by Richard W. Hamming in the year
1950. Hamming codes detect 1-bit and 2-bit errors.
While transmitting the message, it is encoded with the redundant bits. The redundant bits are the
extra bits that are placed at certain locations of the data bits to detect the error. At the receiver end,
the code is decoded to detect errors and the original message is received.
So before transmitting, the sender has to encode the message with the redundant bits. It involves
three steps.
Encoding the message with hamming code
1.Selecting the number of redundant bits
The hamming code uses the number of redundant bits depending on the number of
information bits in the message.
Let n be the number of information or data bits, then the number of redundant bits P is
determined from the following formula.
2r ≥ m+r+1
For example, if 4-bit information is to be transmitted, then n=4. The number of redundant bits
is determined by the trial and error method.
2r ≥ m+r+1
Let r=1, we get, Let r=2, we get, Let r=3, we get,
21 ≥ 4 + 1 + 1 22 ≥ 4 + 2 + 1 23 ≥ 4 + 3 + 1
2=6 x 4=7 x 8=8
In this way, the number of redundant bits is selected for the number of
information bits to be transmitted
2. Choosing the location of redundant bits
For the above example, the number of data bits n=4, and the number of redundant bits P=3. So
the message consists of 7 bits in total that are to be coded. Let the rightmost bit be designated as bit
1, the next successive bit as bit 2 and so on.
The seven bits are bit 7654321
3. Assigning the values to redundant bits
Now it is time to assign bit value to the redundant bits in the formed hamming code group.
The assigned bits are called a parity bit.
BCA Page 4
Networking 1 GZRSC 2021
Example
Data (m)= 1001 4bit
(r )= 3 [ p4 p2 p1 ] position
Length of data= 7 7 6 5 4 3 2 1
1 0 0 p4 1 p2 p1
( p4 p2 p1)
1 0 0 1 p1= 1,3,5,7= Where the first (p1) position having one(1)
2 0 1 0 p2=2,3,6,7= Where the Second (p2) position having one (1)
3 0 1 1 P3=4,5,6,7= Where the third (p3) position having one (1)
4 1 0 0 Then,
5 1 0 1 p1=1,3,5,7= p1101
6 1 1 0 p2=2,3,6,7= p2 101
7 1 1 1 P3=4,5,6,7= p4 001
Let us consider even parity bit
Two one=even=0
p1=1,3,5,7= p1101 =0 0101 p1=0
p2=2,3,6,7= p2 101 =0 0101 p2=0
P3=4,5,6,7= p4 001 =1 1001 p4=1
Single one=odd=1
Replace the value of data 7 6 5 4 3 2 1
1 0 0 p4 1 p2 p1
The data is send to receiver 1 0 0 1 1 0 0
Length of data= 7 7 6 5 4 3 2 1
1 0 0 1 1 0 0 (receive data from sender)
p1=1,3,5,7 0101 p1=0 if we get, the parity bit is all zero, the data is correct
p2=2,3,6,7 0101 p2=0
P3=4,5,6,7 1001 p4=0
If the formed binary word has 0 bits, then there is no error in the message.
Length of data= 7 7 6 5 4 3 2 1
1 1 0 1 1 0 0 (receive data from sender)
p1=1,3,5,7 0101 p1=0 The data is corrupt or error.
p2=2,3,6,7 0111 p2=1 Convert binary data to decimal value. So, 2+4=6, the data
P3=4,5,6,7 1011 p4=1 corrupt or error at 6 position.
BCA Page 5
Networking 1 GZRSC 2021
BCA Page 6
Networking 1 GZRSC 2021
Sender waits for an infinite amount of time for an acknowledgment.
Receiver waits for an infinite amount of time for a data.
BCA Page 7
Networking 1 GZRSC 2021
BCA Page 8
Networking 1 GZRSC 2021
In this
is technique, each frame has sent from the sequence number. The sequence numbers are
used to find the missing data in the receiver end. The
purpose of the sliding window technique is to avoid
duplicate data, so it uses the sequence number.
Go-Back-N ARQ
Step 2:The
The sender will then send the next frame, i.e.,
4, and the window slides containing four frames
(1,2,3,4).
BCA Page 9
Networking 1 GZRSC 2021
The receiver is not acknowledging the frame no 2, either the frame is lost, or the acknowledgment is
lost. Instead of sending the frame no 6, the sender Go-Back to 2, which is the first frame of the
current window, retransmits all the frames in the current window, i.e., 2,3,4,5.
In Go back N,
Sender window size = N. Example in Go back 10, sender window size will be 10.
Receiver window size is always 1 for any value of N.
In SR protocol,
Sender window size = Receiver window
size
The size is of course greater than 1
otherwise the protocol will become Stop
and Wait ARQ.
If n bits are available for sequence
numbers, then-
Sender window size = Receiver window
size = 2n/2 = 2n-1
Receiver acknowledges each frame
independently.
As receiver receives a new frame from the sender, it sends its acknowledgement.
If receiver receives a frame that is corrupted, then it does not silently discard that frame.
BCA Page 10
Networking 1 GZRSC 2021
Receiver handles the situation efficiently by sending a negative acknowledgement (NACK).
Negative acknowledgement allows early retransmission of the corrupted frame.
It also avoids waiting for the time out timer to expire at the sender side to retransmit the frame.
1. Flag field: Flag field marks the beginning and end of the PPP frame. Flag byte is
01111110. (1 byte).
2. Address field: This field is of 1 byte and is always 11111111. This address is the
broadcast address i.e. all the stations accept this frame.
3. Control field: This field is also of 1 byte. This field uses the format of the U-frame
(unnumbered) in HDLC. The value is always 00000011 to show that the frame does
not contain any sequence numbers and there is no flow control or error control.
4. Protocol field: This field specifies the kind of packet in the data field i.e. what is
being carried in data field.
5. Data field: Its length is variable. If the length is not negotiated using LCP during line
set up, a default length of 1500 bytes is used. It carries user data or other information.
6. FCS field: The frame checks sequence. It is either of 2 bytes or 4 bytes. It contains the
checksum.
BCA Page 11
Networking 1 GZRSC 2021
2.Establish: Connection goes into this phase when one of the nodes start
communication. In this phase, two parties negotiate the options. If negotiation is
successful, the system goes into authentication phase or directly to networking phase.
LCP packets are used for this purpose.
3. Authenticate: This phase is optional. The two nodes may decide during the
establishment phase, not to skip this phase. However if they decide to proceed with
authentication, they send several authentication packets. If the result is successful, the
connection goes to the networking phase; otherwise, it goes to the termination phase.
4. Network: In network phase, negotiation for the network layer protocols takes place.
PPP specifies that two nodes establish a network layer agreement before data at the
network layer can be exchanged. This is because PPP supports several protocols at
network layer. If a node is running multiple protocols simultaneously at the network
layer, the receiving node needs to know which protocol will receive the data.
5. Open: In this phase, data transfer takes place. The connection remains in this phase
until one of the endpoints wants to end the connection.
BCA Page 12