Iii Aiml NT Unit-3 Notes
Iii Aiml NT Unit-3 Notes
Iii Aiml NT Unit-3 Notes
The data link layer can be designed to offer various services. Such as:
1. Unacknowledged connectionless service.
2. Acknowledged connectionless service.
3. Acknowledged connection-oriented service.
(ii) Framing
Breaking up the bit stream into frames is more difficult. They are four framing methods:
1. Byte count.
2. Flag bytes with byte stuffing.
3. Flag bits with bit stuffing.
4. Physical layer coding violations.
1. Byte count:
The first framing method uses a field in the header to specify the number of bytes in the frame. When the data link
layer at the destination sees the byte count, it knows how many bytes follow and hence where the end of the frame
is. This technique is shown in Fig. 3-3(a) for four small example frames of sizes 5, 5, 8, and 8 bytes, respectively.
(2) Flag bytes with byte stuffing:
One way to solve this problem is to have the sender’s data link layer insert a special escape byte (ESC) just
before each ‘‘accidental’’ flag byte in the data.
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.
Redundancy:
To detect or correct error, need some extra bits with our data called redundant bits. Redundant bits are added by the
sender and removed by the receiver.
The number of redundant bits can be calculated using the following formula:
2r ≥ m + r + 1
where m(message) is the number of bits in input data,
r is the number of redundant bits.
Suppose the number of data bits is 7, then the number of redundant bits can be calculated using: = 2 4 ≥ 7 + 4 + 1 .
Thus, the number of redundant bits is 4.
Even Parity Bit: In the case of even parity, for a given set of bits, the number of 1’s are counted. If that
count is odd, the parity bit value is set to 1, otherwise already even, the parity bit’s value is 0.
Odd Parity Bit: In the case of odd parity, for a given set of bits, the number of 1’s are counted. If that
count is even, the parity bit value is set to 1, making the total count of occurrences of 1’s an odd number. If
the total number of 1’s in a given set of bits is already odd, the parity bit’s value is 0.
Error detection: here looking (detect) if error’s occurs or not. If error occur request a retransmission. It’s also
called as BEC(Backward Error Correction/retransmission.
Error Correction: correcting error by knowing the number of bits corrupted and the location. Its more difficult
than detection. It’s also called as FEC(Forward Error Correction)
Error-Correcting Codes
There are four different error-correcting codes:
1. Hamming codes.
2. Binary convolutional codes.
3. Reed-Solomon codes.
4. Low-Density Parity Check codes.
(i) Hamming codes:
To determine how many bits differ, just XOR the two code words and count the number of 1 bits in the result.
For example:
Sender message : 10001001
Receiver message: 10110001
Here can identify by using ‘XOR’ 3 bits differ=00111000
The number of bit positions in which two code words differ is called the Hamming distance (Hamming, 1950). Its
significance is that if two code words are a Hamming distance d apart, it will require d single-bit errors to convert
one into the other.
Algorithm of Hamming Code
Hamming Code is simply the use of extra parity bits to allow the identification of an error.
Step 1: Write the bit positions starting from 1 in binary form (1, 10, 11, 100, etc).
Step 2: All the bit positions that are a power of 2 are marked as parity bits (1, 2, 4, 8, etc).
Step 3: All the other bit positions are marked as data bits.
Step 4: Each data bit is included in a unique set of parity bits, as determined its bit position in binary form:
a. Parity bit 1 covers all the bits positions whose binary representation includes a 1 in the least significant
position (1, 3, 5, 7, 9, 11, etc).
b. Parity bit 2 covers all the bits positions whose binary representation includes a 1 in the second position
from the least significant bit (2, 3, 6, 7, 10, 11, etc).
c. Parity bit 4 covers all the bits positions whose binary representation includes a 1 in the third position
from the least significant bit (4–7, 12–15, 20–23, etc).
d. Parity bit 8 covers all the bits positions whose binary representation includes a 1 in the fourth position
from the least significant bit bits (8–15, 24–31, 40–47, etc).
e. In general, each parity bit covers all bits where the bitwise AND of the parity position and the bit
position is non-zero
Since we check for even parity set a parity bit to 1 if the total number of ones in the positions it checks is odd. Set a
parity bit to 0 if the total number of ones in the positions it checks is even
Suppose the data to be transmitted is 1011001 from sender to receiver, the bits will be placed as follows:
To find the redundant bit R1, check for even parity. Since the total number of 1’s in all the bit positions
corresponding to R1 is an even number. So, the value of R1 (parity bit’s value) = 0.
Similarly, R2 bit is calculated. R2: bits 2,3,6,7,10,11. the total number of 1’s in all the bit positions
corresponding to R2 is odd the value of R2(parity bit’s value)=1
R4 bit in third position. Hence R4: bits 4, 5, 6, 7. Since the total number of 1’s in all the bit positions
corresponding to R4 is odd so the value of R4(parity bit’s value) = 1
R8 bit 8,9,10,11. Since the total number of 1’s in all the bit positions corresponding to R8 is an even
number the value of R8(parity bit’s value)=0.
Thus, the data transferred is:
For all the parity bits we will check the number of 1’s in their respective bit positions.
For R1: bits 1, 3, 5, 7, 9, 11. We can see that the number of 1’s in these bit positions are 4 and that’s even
so we get a 0 for this.
For R2: bits 2,3,6,7,10,11 . We can see that the number of 1’s in these bit positions are 5 and that’s odd so
we get a 1 for this.
For R4: bits 4, 5, 6, 7 . We can see that the number of 1’s in these bit positions are 3 and that’s odd so we
get a 1 for this.
For R8: bit 8,9,10,11 . We can see that the number of 1’s in these bit positions are 2 and that’s even so we
get a 0 for this.
The bits give the binary number 0110 whose decimal representation is 6. Thus, bit 6 contains an error. To
correct the error the 6th bit is changed from 1 to 0.
Features of Hamming Code
Error Detection and Correction:
Redundancy:
Efficiency: Use low-power and low-bandwidth communication networks.
Widely Used: Eg: telecommunications, computer networks, and data storage systems.
Single Error Correction:
Limited Multiple Error Correction
(ii) Binary convolutional codes:
Here, an encoder processes an input sequence of bits of arbitrary length and generates a sequence of output bits. 1
input bit produces 2 output bits, the code rate is 1/2.
The output depends on the current and previous input bits. That is, the encoder has memory. The number of
previous bits on which the output depends is called the constraint length of the code. Convolutional codes are
specified in terms of their rate and constraint length
Error Detection :
Eerror detection and retransmission is usually more efficient there for dealing with the occasional error.
There are three different error-detecting codes. They are all linear,systematic block codes:
1. Parity.
2. Checksums.
3. Cyclic Redundancy Checks (CRCs).
1. Parity:
A parity check refers to an error detection method where an extra bit, or a parity bit, is added to each data unit.
Parity check provides a simple and efficient method for detecting errors in data transmission and storage as well as
helping ensure a secure data transmission process.
Eg:
2. checksums:
For example, suppose the channel supports N nodes and that the transmission rate of the channel is R bps.
TDM divides time into time frames and further divides each time frame into N time slots.
A third channel partitioning protocol is code division multiple access (CDMA).
While TDM and FDMassign time slots and frequencies, respectively, to the nodes,
CDMA assigns a different code to each node. Each node then uses its unique code to encode the
data bits it sends.
(b) Random Access Protocols:
In a random access protocol, a transmitting node always transmits at the full rate of the channel, namely,
R bps. When there is a collision, each node involved in the collision repeatedly retransmits its frame (that
is, packet) until its frame gets through without a collision.
There are Three types of Random Access Protocols:
(a) Slotted ALOHA protocols
(b) Carrier sense multiple access (CSMA) protocols.
(c ) Carrier sense multiple access / Collision detection.
(a) Slotted ALOHA
Its simplest random access protocols .Its has following constraints(restriction)
All frames consist of exactly L bits.
Time is divided into slots of size L/R seconds (that is, a slot equals the time to transmit one frame).
Nodes start to transmit frames only at the beginnings of slots.
The nodes are synchronized so that each node knows when the slots begin.
If two or more frames collide in a slot, then all the nodes detect the collision event before the slot
ends.
Slotted ALOHA is also decentralized because each node detects Collisions and independently
decides when to transmit.
It allows a node to transmit continuously at the full rate R, when that node is the only active node.
(b) Carrier Sense multiple access(CSMA) protocols:
In both slotted and pure ALOHA, a node’s decision to transmit is made independently of the activity of
the other nodes attached to the broadcast channel. In particular, a node neither pays attention to
whether another node happens to be transmitting when it begins to transmit, nor stops transmitting if
another node begins to interfere with its transmission.
In order to overcome this collision, The CSMA Protocols was created. To increase the amount of data
and decrease the amount of time following rules are there.
Listen before speaking. If someone else is speaking, wait until they are finished. In the
networking world, this is called carrier sensing—a node listens to the channel before
transmitting. If a frame from another node is currently being transmitted into the channel, a node
then waits until it detects no transmissions for a short amount of time and then begins
transmission.
If someone else begins talking at the same time, stop talking. In the networking world, this is
called collision detection—a transmitting node listens to the channel while it is transmitting. If it
detects that another node is transmitting an interfering frame, it stops transmitting and waits a
random amount of time before repeating the sense-and-transmit-when-idle cycle.