Iii Aiml NT Unit-3 Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

UNIT-3

Data Link Layer:


The data link layer 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 swamped 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 Fig. 3-1.

(i) Services Provided to the Network Layer


(ii) Framing
(iii) Error control
(iv) Flow Control
(I ) Services provided to the Network Layer:
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 Fig. 3-2(a). The actual transmission follows the path of Fig. 3-2(b),

Figure 3-2. (a) Virtual communication. (b) Actual communication.

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.

(3) Flag bits with bit stuffing:


In this method the sender DLL encounters five consecutive one’s in the data it automatically stuffes a zero bit into
outgoing stream.

(iii) Error control


 The error control can managed by following method.
 The sender has to provide some feedback about what is happening at the receiver. These will be done by
sending acknowledgements.
 If the sender receives a positive acknowledgement about a frame it knows the frame has arrived safely.
 If a negative acknowledgement means that something has gone wrong and the frame must be transmitted
again.
( iv) Flow Control
Two approaches are commonly used for flow control are
a) Feed back based flow control
b) Rate based flow
Topic 2: Error Detection and correction:
Error: When a data transmitted over network, it may get corrupted due to many factors. One or more bits altered.
Some mechanism required for detecting and correcting these errors.

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

Determining The Position of Redundant Bits


A redundancy bits are placed at positions that correspond to the power of 2. As in the above example:
 The number of data bits = 7
 The number of redundant bits = 4
 The total number of bits = 7+4=>11
 The redundant bits are placed at positions corresponding to power of 2 that is 1, 2, 4, and 8

 Suppose the data to be transmitted is 1011001 from sender to receiver, the bits will be placed as follows:

Determining The Parity Bits According to Even Parity


 R1 bit is calculated using parity check at all the bits positions whose binary representation includes a 1 in
the least significant position. R1: bits 1, 3, 5, 7, 9, 11

 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:

Error Detection and Correction


Suppose in the above example the 6th bit is changed from 0 to 1 during data transmission, then it gives new parity
values in the binary number:

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

(iii) Reed-Solomon codes


Reed-Solomon codes are block-based error correcting codes with a wide range of applications in digital
communications and storage. Reed Solomon codes are a subset of BCH codes and are linear block codes.
Reed-Solomon codes are used to correct errors in many systems including:
 Storage devices (including tape, Compact Disk, DVD, barcodes, etc)
 Wireless or mobile communications (including cellular telephones, microwave links, etc)
 Satellite communications
 Digital television / DVB
 High-speed modems such as ADSL, xDSL, etc.
Example:

(Iv) Low density parity check (LDPC) code:


 Low - density parity check (LDPC) code is a linear error-correcting block code, suitable for error correction in large block
sizes transmitted via very noisy channels.
 LDPC was developed by Robert G. Gallager, in his doctoral dissertation at the Massachusetts Institute of Technology in
1960. So, these codes are also known as Gallager codes.
 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. This corrects errors.

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:

(3) Cyclic Redundancy Check(CRC)


Topic: Multiple Access and Links and Protocols:
There are two types of Network link
(i) Point to point link
(ii) Broadcast link
(i) Point to point link
 A Point to point link consists of a single sender at one end of the link and a single receiver
at the other end of the link.
 Many link-layer protocols have been designed for point-to-point links;
 Point-to-Point Protocol (PPP) and
 high-level data link control (HDLC).
(ii) Broadcast link:
 It can have multiple sending and receiving nodes all connected to the same, single, shared
broadcast channel.
 Ethernet and wireless LANs are examples of broadcast link-layer technologies.
Multiple Access Protocols:
These Protocols are divided into three types:
(a) Channel partitioning protocols,
(b) Random access protocols, and
(c) taking-turns protocols
(a)Channel Partitioning protocols:
There are two techniques used for partitioning a broadcast channel bandwidth among all the nodes
sharting the channel
 time-division multiplexing (TDM) and
 frequency-division multiplexing (FDM)

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.

(c )Carrier Sense Multiple Access with Collision Detection(CSMA/CD)


 In CSMA nodes do not perform collision detection; both B and D continue to transmit their frames
in their entirety even though a collision has occurred. When a node performs collision detection, it
ceases transmission as soon as it detects a collision.
Figure 6.13 shows the same scenario as in Figure 6.12, except that the two nodes each abort their
transmission a short time after detecting a collision.
 Hence, adding collision detection to a multiple access protocol will help protocol performance by
not transmitting a useless, damaged (by interference with a frame from another node) frame in its
entirety.
(iii )Taking Turns Protocols:
(a) Polling Protocol
(b) Token-passing protocol.
(a) polling protocol. The polling protocol requires one of the nodes to be designated as a master node.
The master node polls each of the nodes in a round-robin fashion.Master node first sends a message to
node 1, saying that it (node 1) can transmit up to some maximum number of frames. After node 1
transmits some frames, the master node tells node 2 it (node 2)as so on.
Advantages:
 It eliminates the collisions and empty slots.
 It gives much higher efficiency
Drawback
 a polling delay
 if master node fails, the entire channel becomes inoperative.
(b) token-passing protocol:
 A small, special-purpose frame known as a token is exchanged among the nodes in some fixed
order.
For example, node 1 might always send the token to node 2, node 2 might always send the token
to node 3, as so on.When a node receives a token, it holds onto the token only if it has some frames to
transmit; otherwise, it immediately forwards the token to the next node.
 Token passing is decentralized and highly efficient.

Topic: Switched Local Area Networks(Unit-2)


The above diagram shows a switched local network connecting three departments, two servers and a
router with four switches. Because these switches operate at the link layer, they switch link-layer frames
rather than network-layer.
It uses link layer addresses to forward link-layer frames through networks switches.
(i) Link-Layer Addressing and ARP:
 Hosts and routers has link-layer address.
 Address Resolution Protocol(ARP) which provides mechanism to translate IP address to link-layer
addresses.
NEXT TOPIC
NEXT TOPIC
Topic :
******* END ********

You might also like