WEEK 4 Data Link Layer
WEEK 4 Data Link Layer
Course Handled By
Femilda Josephin
1
AGENDA
2
DATALINK LAYER
• The primary function of the data link layer is to provide a reliable and error-free
communication link between two adjacent network nodes, such as between two
computers or between a computer and a switch.
3
DATA LINK LAYER - SUBLAYERS
• The upper sublayer is responsible for flow and error control is called Logical Link
Control(LLC) layer.
• The lower sublayer is responsible for multiple access resolution is called the
media access control (MAC) layer.
• When nodes or stations are connected and use a common link called a
multipoint or broadcast link, we need a multiple access protocol to coordinate
access to the link.
4
TAXONOMY OF MULTIPLE-ACCESS PROTOCOLS
5
CONTROLLED ACCESS
• In controlled access, the stations consult one another to find which station has
the right to send.
• A station cannot send unless it has been authorized by other stations.
• Three popular controlled-access methods.
1. Reservation
2. Polling
3. Token Passing
6
RESERVATION
7
POLLING
• It works with topologies in which one device is designated as a primary station
and the other devices are secondary stations.
• The primary device controls the link.
• The secondary devices follow its instructions.
• Primary device is to determine which device is allowed to use the channel at a
given time.(initiator of a session).
• If the primary wants to receive data, it asks the secondaries if they have
anything to send, this is called poll function.(poll)
• If the primary wants to send data, it tells the secondary to get ready to receive,
this is called select function.(SEL)
8
SELECT AND POLL FUNCTIONS IN POLLING ACCESS
METHOD
9
TOKEN PASSING
• The stations in a network are organized in a logical ring.
• For each station, there is a predecessor and a successor.
• A special packet called a token circulates through the ring.
• Token management, the token must be monitored to ensure it has not been lost or
destroyed.
Logical ring and physical topology in token-passing access method
10
RANDOM ACCESS
• In random access or contention methods, no station is superior to another
station and none is assigned the control over another.
• No station permits, or does not permit, another station to send.
• At each instance, a station that has data to send uses a procedure defined by the
protocol to make a decision on whether or not to send.
• Two features
1. There is no schedule time for a station to transmit. Transmission is random
among the stations.
2. No rules specify which station should send next. Stations compete with one
another to access the medium
• If more than one station tries to send, there is an access conflict-Collision and
the frames will be either destroyed or modified.
11
• ALOHA, protocol which use a very simple procedure called multiple access.
• The method was improved with the procedure that forces the station to sense the medium
before transmitting. This was called Carrier Sense Multiple Access (CSMA)
• Carrier Sense Multiple Access with Collision Detection(CSMA/CD)
• Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA)
ALOHA
• It was designed for a radio(wireless) LAN, but it can be used on any shared medium.
Types of ALOHA
1. Pure ALOHA
2. Slotted ALOHA
Pure ALOHA(original ALOHA)
• Each station sends a frame whenever it has a frame to send.
• If one bit of a frame coexists on the channel with one bit from another frame, there is a
collision and both will be destroyed.
Frames in a pure ALOHA network
• Need to resend the frames that have been destroyed during transmission.
• Acknowledgement(time-out period)
Methods to prevent collision:
• Back-off time TB.(random amount of time)
• After a maximum number of retransmission attempts Kmax, a station must give up and try later.
13
Procedure for pure ALOHA protocol
14
SLOTTED ALOHA
• In slotted ALOHA, we divide the time into slots of Tfr and force the station
to send only at the beginning of the time slot.
• If a station misses the moment, it must wait until the beginning of the next
time slot.
• The station which started at the beginning of this slot has already finished
sending its frame.
Collision
• If two stations try to send at the beginning of the same time slot.
• However the vulnerable time is now reduced to one-half, equal to Tfr.
Slotted ALOHA vulnerable time = Tfr
15
Frames in a slotted ALOHA network
16
CARRIER SENSE MULTIPLE ACCESS(CSMA)
• CSMA requires that each station first listen to the medium before sending.( Sense before
transmit)
• It can reduce the possibility of collision, but it cannot eliminate it.
• The possibility of collision still exists because of propagation delay.
• A station may sense the medium and find it idle, only because the first bit sent by another
station has not yet been received.
• At time t1, station B senses the medium and find it idle, so it sends a frame.
• At time t2(t2>t1), station c senses the medium and finds it idle because at this time, the first
bits from station B have not reached station C. station C also sends a frame.
• The two signals collide and both frames are destroyed.
17
PERSISTENCE METHODS
What should a station do if the channel is busy or is idle?
1-Persistent(Probability 1)
• After the station finds the line idle, it sends its frame immediately. This method has the highest chance of
collision.
NonPersistent
• A station that has a frame to send senses the line. If the line is idle, it sends immediately. If the line is not idle, it
waits a random amount of time and then senses the line again.
• It reduces the chance of collision and it reduces the efficiency of the network.
p-Persistent
• This method is used if the channel has time slots with a slot duration equal to or greater than the maximum
propagation time.
• It combines the advantages of the other two methods.
• It reduces the chance of collision and improves efficiency
18
PERSISTENCE METHODS
19
Persistent Methods
20
CSMA/ CD
21
CSMA/CD
22
CSMA/C A
• Flow control refers to a set of procedures used to restrict the amount of data
that the sender can send before waiting for acknowledgment.
• Error control in the data link layer is based on automatic repeat request
(ARQ), which is the retransmission of data.
• ARQ types
1. Stop-and-Wait Automatic Repeat Request
2. Go-Back-N Automatic Repeat Request
3. Selective Repeat Automatic Repeat Request
24
STOP-AND-WAIT AUTOMATIC REPEAT REQUEST
25
Flow diagram
26
GO-BACK-N AUTOMATIC REPEAT REQUEST
• In the Go-Back-N Protocol, the sequence numbers are modulo 2m, where m is
the size of the sequence number field in bits.
• The send window is an abstract concept defining an imaginary box of size 2m − 1
with three variables:
Sf - Send window first outstanding frame
Sn - Send window next frame to send
and Ssize – Send window size
• The send window can slide one or more slots when a valid acknowledgment
arrives.
27
Send window for Go-Back-N ARQ
28
Flow diagram
29
COMPARISON OF GO-BACK-N AND SELECTIVE REPEAT
• Go-Back-N Protocol and “Selective Repeat Protocol” are the sliding window
protocols. The sliding window protocol is primarily an error control protocol
• The basic difference between go-back-n protocol and selective repeat protocol is
that the “go-back-n protocol” retransmits all the frames that lie after the frame
which is damaged or lost.
• The “selective repeat protocol” retransmits only that frame which is damaged or
lost.
30
GO-BACK-N
31
SELECTIVE REPEAT
32
ERROR DETECTION
• Error
• A condition when the receiver’s information does not match with the sender’s information.
• During transmission, digital signals suffer from noise that can introduce errors in the binary bits travelling
from sender to receiver. That means a 0 bit may change to 1 or a 1 bit may change to 0.
• Error Detecting Codes are implemented either at Data link layer or Transport Layer of OSI Model
• Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted.
• To avoid this, we use error-detecting codes which are additional data added to a given digital message to
help us detect if any error has occurred during transmission of the message.
• Some popular techniques for error detection are:
1. Simple Parity check
2. Two-dimensional Parity check
3. Checksum
4. Cyclic redundancy check
33
SIMPLE PARITY CHECK
• Blocks of data from the source are subjected to a check bit or parity bit generator
form, where a parity of :
• 1 is added to the block if it contains odd number of 1’s, and
• 0 is added if it contains even number of 1’s
• This scheme makes the total number of 1’s even, that is why it is called even
parity checking.
34
TWO-DIMENSIONAL PARITY CHECK
• Parity check bits are calculated for each row, which is equivalent to a simple parity check
bit.
• Parity check bits are also calculated for all columns, then both are sent along with the
data.
• At the receiving end these are compared with the parity bits calculated on the received
data.
35
CHECKSUM
• In checksum error detection scheme, the data is divided into k segments each of
m bits.
• In the sender’s end the segments are added using 1’s complement arithmetic to
get the sum. The sum is complemented to get the checksum.
• The checksum segment is sent along with the data segments.
• At the receiver’s end, all received segments are added using 1’s complement
arithmetic to get the sum. The sum is complemented.
• If the result is zero, the received data is accepted; otherwise discarded.
36
CHECKSUM
37
CYCLIC REDUNDANCY CHECK (CRC)
• Unlike checksum scheme, which is based on addition, CRC is based on binary division.
• In CRC, a sequence of redundant bits, called cyclic redundancy check bits, are appended to
the end of data unit so that the resulting data unit becomes exactly divisible by a second,
predetermined binary number.
• At the destination, the incoming data unit is divided by the same number.
• If at this step there is no remainder, the data unit is assumed to be correct and is therefore
accepted.
• A remainder indicates that the data unit has been damaged in transit and therefore must
be rejected.
38
CYCLIC REDUNDANCY CHECK (CRC)
39