0% found this document useful (0 votes)
2 views92 pages

21CS52 CN Module 2

The document covers the Data Link Layer of computer networks, detailing its design issues, functions, and protocols including error detection and correction. It discusses the sub-layers of the Data Link Layer, such as Logical Link Control (LLC) and Media Access Control (MAC), and various framing methods for data transmission. Additionally, it addresses flow control mechanisms and error-correcting codes, emphasizing the importance of ensuring reliable communication between directly connected hosts.

Uploaded by

Antheesh R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views92 pages

21CS52 CN Module 2

The document covers the Data Link Layer of computer networks, detailing its design issues, functions, and protocols including error detection and correction. It discusses the sub-layers of the Data Link Layer, such as Logical Link Control (LLC) and Media Access Control (MAC), and various framing methods for data transmission. Additionally, it addresses flow control mechanisms and error-correcting codes, emphasizing the importance of ensuring reliable communication between directly connected hosts.

Uploaded by

Antheesh R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 92

1

COMPUTER NETWORKS
Subject Code: 21CS52
2

MODULE- 2
• The Data link layer: Design issues of DLL,
Error detection and correction, Elementary
data link protocols, Sliding window protocols.
• The medium access control sublayer: The
channel allocation problem, Multiple access
protocols.
Laboratory Component :
1. Implement simple ESS and with transmitting nodes in
wire-less LAN by simulation and determine the
throughput with respect to transmission of packets
2. Write a program for error detecting code using CRC-
CCITT (16- bits).
DATA LINK LAYER
• This layer is one of the most complicated layers.
• Data link layer works between two hosts which are
directly connected:
 Point to point
 Broadcast
• The work of data link layer tends to get more
complex when it is dealing with multiple hosts on
single collision domain.
DATA LINK LAYER
• Data link layer has two sub-layers:

• Logical Link Control (LLC):


Protocols, Flow control, Error control

• Media Access Control (MAC):


Actual control of media
DATA LINK LAYER DESIGN ISSUES
• 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:


 Providing a well-defined service interface to
the network layer.
 Dealing with transmission errors.
 Regulating the flow of data.
DATA LINK LAYER DESIGN ISSUES

Frame management forms the heart of what the


data link layer does.
DATA LINK LAYER DESIGN ISSUES
1. Services Provided to the Network Layer
• The function of the data link layer is to provide
services to the network layer.

• On the source machine is an entity, call it a process,


in the network layer that hands some bits to the data
link layer for transmission to the destination.

• 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
DATA LINK LAYER DESIGN ISSUES

(a) Virtual communication. (b) Actual communication.


DATA LINK LAYER DESIGN ISSUES

Placement of the data link protocol.


DATA LINK LAYER DESIGN ISSUES
• The data link layer can be designed to offer various
services. The actual services that are offered vary from
protocol to protocol. Three reasonable possibilities:
1) Unacknowledged connectionless service.
 The source sends, the destination does not acknowledge
them.
 No logical connection.
 If some frames are lost due to noise, recovery is up to the
higher layers.
 This service is suitable for voice transmission, links using
highly reliable.
DATA LINK LAYER DESIGN ISSUES

2) Acknowledged connectionless service.


• Each frame sent by the source Data Link Layer is
individually acknowledged by the destination Data Link
Layer.

• If a frame has not reached the destination safely, it can be


sent again.

• No logical connection is made before or released after the


exchange of data
DATA LINK LAYER DESIGN ISSUES

3) Acknowledged connection-oriented service.


 The source and destination machines establish a
connection before any data are transferred.

 Each frame sent over the connection is number.


 Guarantees that each frame sent is indeed received.
 Guarantees that each frame is received exactly once.
 All frames are received in the right order.
 It is appropriate over long, unreliable links
DATA LINK LAYER DESIGN ISSUES
2. Framing
• Data-link layer takes packets from Network Layer and
encapsulates them into Frames.
• Then, it sends each frame bit-by-bit on the hardware. At
receiver end, data link layer picks up signals from hardware
and assembles them into frames.
• A good design must make it easy for a receiver to find the start
of new frames while using little of the channel bandwidth.
• There are four methods:
1. Byte count.
2. Flag bytes with byte stuffing.
3. Flag bits with bit stuffing.
4. Physical layer coding violations.
DATA LINK LAYER DESIGN ISSUES
a) 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.

A byte stream. (a) Without errors.


DATA LINK LAYER DESIGN ISSUES
Byte count
• The trouble with this algorithm is that the count can be garbled by
a transmission error.
• For example, if the byte count of 5 in the second frame of Fig. 3-
3(b) becomes a 7 due to a single bit flip, the destination will get
out of synchronization.
• It will then be unable to locate the correct start of the next frame

A byte stream. (b) With errors.


DATA LINK LAYER DESIGN ISSUES
b) Flag bytes with byte stuffing
• The second framing method gets around the problem of
resynchronization after an error by having each frame start and
end with special bytes.
• Each frame starts with special start and end bytes. Often the
same byte, called a flag byte
• Two consecutive flag bytes indicate the end of one frame and
the start of the next.

(a) A frame delimited by flag bytes.


DATA LINK LAYER DESIGN ISSUES
b) Flag bytes with byte stuffing
• However, there is a still a problem we have to solve. It may
happen that the flag byte occurs in the data.
• 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
• Thus, 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.
DATA LINK LAYER DESIGN ISSUES
b) Flag bytes with byte stuffing
What happens if an escape byte occurs in the middle of the
data?
• The answer is that it, too, is stuffed with an escape byte.
• At the receiver, the first escape byte is removed, leaving the data
byte that follows it (which might be another escape byte or the
flag byte).
• Some examples are shown in Fig. 3-4(b).
• In all cases, the byte sequence delivered after destuffing is
exactly the same as the original byte sequence.
• We can still search for a frame boundary by looking for two flag
bytes in a row, without bothering to undo escapes.
DATA LINK LAYER DESIGN ISSUES
b) Flag bytes with byte stuffing
Figure shown is a slight simplification of the one used in PPP (Point-
to-Point Protocol), which is used to carry packets over
communications links

Four examples of byte sequences before and after byte stuffing.


DATA LINK LAYER DESIGN ISSUES
c) Flag bits with bit stuffing
• It was developed for the once very popular HDLC (Highlevel
• Data Link Control) protocol.
• Each frame begins and ends with a special bit pattern, 01111110
or 0x7E in hexadecimal. This pattern is a flag byte.
• Whenever the sender’s data link layer encounters five
consecutive 1’s in the data, it automatically stuffs a 0 bit into the
outgoing bit stream.
• This bit stuffing is analogous to byte stuffing, in which an escape
byte is stuffed into the outgoing character stream before a flag
byte in the data.
• It also ensures a minimum density of transitions that help the
physical layer maintain synchronization. USB (Universal Serial
Bus) uses bit stuffing for this reason.
DATA LINK LAYER DESIGN ISSUES
c) Flag bits with bit stuffing
DATA LINK LAYER DESIGN ISSUES
c) Flag bits with bit stuffing
• When the receiver sees five consecutive incoming 1 bits,
followed by a 0 bit, it automatically destuffs (i.e., deletes)
the 0 bit.
• Just as byte stuffing is completely transparent to the
network layer in both computers, so is bit stuffing.
• With bit stuffing, the boundary between two frames can be
unambiguously recognized by the flag pattern.
• Thus, if the receiver loses track of where it is, all it has to do
is scan the input for flag sequences, since they can only
occur at frame boundaries and never within the data.
DATA LINK LAYER DESIGN ISSUES
c) Flag bits with bit stuffing
DATA LINK LAYER DESIGN ISSUES
d) Physical layer coding violations :
• With both bit and byte stuffing, a side effect is that the
length of a frame now depends on the contents of the data it
carries.
• With bit stuffing, the increase would be roughly 12.5% as 1
bit is added to every byte.
• We can use some reserved signals to indicate the start and
end of frames.
• In effect, we are using ‘‘coding violations’’ to delimit
frames.
• The beauty of this scheme is that, because they are reserved
signals, it is easy to find the start and end of frames and
there is no need to stuff the data.
DATA LINK LAYER DESIGN ISSUES
d) Physical layer coding violations :
• Many data link protocols use a combination of these
methods for safety.
• A common pattern used for Ethernet and 802.11 is to have a
frame begin with a well-defined pattern called a preamble.
This pattern might be quite long (72 bits is typical for
802.11) to allow the receiver to prepare for an incoming
packet.
The preamble is then followed by a length (i.e., count) field
in the header
DATA LINK LAYER DESIGN ISSUES
3. Error Control
• How to make sure all frames are eventually delivered to the
network layer at the destination and in the proper order.
• For the connection oriented service, the data link layer must
guarantee that all the frames sent arrive at the receiver in the
proper order, and only one correct copy of each frame is
expected at the receiver.
• The receiver usually sends an acknowledgement (ACK) or a
negative acknowledgement (NACK) back to the transmitter.
• These ACKs and NACKs are typically very short in length
and do not consume the channel capacity.
DATA LINK LAYER DESIGN ISSUES
3. Error Control
• To stop the loss of a frame or an ACK/NACK due to
channel errors causing the transmitter to wait forever to
transmit the next frame, a time out procedure is used. If
after certain time, an ACK or NACK is not reached the
transmitter, the frame is sent again.
• However, if only the ACK is lost, the sender transmits a
copy of the same frame causing duplication and waste of
channel capacity.
• By introducing sequence numbers to all frames, passing of a
duplicate frame to the network layer can be prevented.
DATA LINK LAYER DESIGN ISSUES
4. Flow Control
• Another important design issue that occurs in the data link
layer (and higher layers as well) is what to do with a sender
that systematically wants to transmit frames faster than the
receiver can accept them.
• This situation can occur when the sender is running on a
fast, powerful computer and the receiver is running on a
slow, low-end machine.
• A common situation is when a smart phone requests a Web
page from a far more powerful server.
DATA LINK LAYER DESIGN ISSUES
4. Flow Control
• Clearly, something has to be done to prevent this situation.
Two approaches are commonly used:
 Feedback-based flow control, the receiver sends back
information to the sender giving it permission to send
more data, or at least telling the sender how the receiver
is doing. (The link layer and higher layers)
 Rate-based flow control, the protocol has a built-in
mechanism that limits the rate at which senders may
transmit data, without using feedback from the receiver.
(Transport layer)
ERROR DETECTION AND CORRECTION
• Network designers have developed two basic strategies for
dealing with errors.
• Both add redundant information to the data that is sent.
• One strategy is to include enough redundant information to
enable the receiver to deduce what the transmitted data
must have been.
• The other is to include only enough redundancy to allow the
receiver to deduce that an error has occurred (but not which
error) and have it request a retransmission.
• The former strategy uses error-correcting codes and the
latter uses error-detecting codes.
• The use of error-correcting codes is often referred to as
FEC (Forward Error Correction).
ERROR DETECTION AND CORRECTION
• On channels that are highly reliable, such as fiber, it is cheaper
to use an error-detecting code and just retransmit the occasional
block found to be faulty.
• However, on channels such as wireless links that make many
errors, it is better to add redundancy to each block so that the
receiver is able to figure out what the originally transmitted
block was.
• FEC is used on noisy channels because retransmissions are just
as likely to be in error as the first transmission.
1. Cover these error-correcting codes and error-detecting
codes in the data link layer because this is the first place
that we have run up against the problem of reliably
transmitting groups of bits.
2. Error codes are applied mathematics
ERROR DETECTION AND 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.
ERROR DETECTION AND CORRECTION
Error-Correcting Codes:
• All of these codes add redundancy to the
information that is sent.
• A frame consists of m data (i.e., message) bits
and r redundant (i.e. check) bits.
• In a block code, the r check bits are computed
solely as a function of the m data bits with
which they are associated, as though the m bits
were looked up in a large table to find their
corresponding r check bits.
ERROR DETECTION AND CORRECTION
Error-Correcting Codes:
• In a systematic code, the m data bits are sent directly,
along with the check bits, rather than being encoded
themselves before they are sent.
• In a linear code, the r check bits are computed as a
linear function of the m data bits.
• Exclusive OR (XOR) or modulo 2 addition is a
popular choice.
• This means that encoding can be done with operations
such as matrix multiplications or simple logic circuits.
• The codes we will look at in this section are linear,
systematic block codes unless otherwise noted.
ERROR DETECTION AND CORRECTION
Error-Correcting Codes:
• Let the total length of a block be n (i.e., n = m + r). We
will describe this as an (n , m) code.
• An n-bit unit containing data and check bits is referred to
as an n bit codeword.
• The code rate, or simply rate, is the fraction of the
codeword that carries information that is not redundant, or
m/n.
• The rates used in practice vary widely.
• They might be 1/2 for a noisy channel, in which case half
of the received information is redundant, or close to 1 for a
high-quality channel, with only a small number of check
ERROR DETECTION AND CORRECTION
Error-Correcting Codes:
• To understand how errors can be handled, it is necessary
to first look closely at what an error really is.
• Given any two code words that may be transmitted or
received—say, 10001001 and 10110001—it is possible
to determine how many corresponding bits differ.
• In this case, 3 bits differ.
• To determine how many bits
differ, just XOR the two code
words and count the number of 1
bits in the result.
ERROR DETECTION AND CORRECTION
Error-Correcting Codes:
• The number of bit positions in which two codewords
differ is called the Hamming distance (Hamming,
1950).
• Its significance is that if two codewords are a Hamming
distance d apart, it will require d single-bit errors to
convert one into the other.
38

Module – 2(b)
The medium access control sub
layer: The channel allocation problem,
Multiple access protocols.
39

Introduction
• Broadcast networks
• Key issue: who gets to use the channel when there is competition
• Referred to as
• Multiaccess channels
• Random access channels
• MAC (Medium Access Control) sublayer
• LANs
• Wireless networks
• Satellite networks
The MAC Sublayer
40

Channel Allocation Problem


• Channel Allocation
• Static
• Dynamic
• Performance factors
• Medium access delay
• Time between a frame is ready and the frame can be
transmitted
• Throughput
• #frames can be transmitted in unit time interval
• For fixed channel and traffic from N users
• Divide up bandwidth using FTM (Flow Transfer Mode), TDM (Time-
division multiplexing), CDMA(Code Division Multiple Access), etc.
• This is a static allocation, e.g., FM radio
• This static allocation performs poorly for bursty traffic
• Allocation to a user will sometimes go unused
41

Static Channel Allocation


• FDM
• Bandwidth divided into N equal sized portions for N users
• Problems
• #senders large
• #senders continuously varies
• bursty traffic
• N times worse than all frames queued in one big queue

TDM:
• Each user is statically allocated every Nth time slot
• Same problems as FDM
42

Static Channel Allocation


• The poor performance of static FDM can easily be seen with a simple queueing
theory calculation. Let us start by finding the mean time delay, T, to send a frame
onto a channel of capacity C bps. We assume that the frames arrive randomly with
an average arrival rate of λ frames/sec, and that the frames vary in length with an
average length of 1/μ bits. With these parameters, the service rate of the channel is
μC frames/sec. A standard queueing theory result is

• Example, if C is 100 Mbps, the mean frame length, 1/μ, is 10,000 bits, and the
frame arrival rate, λ, is 5000 frames/sec, then T = 200 μsec. Note that if we ignored
the queueing delay and just asked how long it takes to send a 10,000- bit frame on
a 100-Mbps network, we would get the (incorrect) answer of 100 μsec. That result
only holds when there is no contention for the channel.
43

Dynamic Channel Allocation


Assumptions for Dynamic Channel Allocation
• There are five key assumptions:
1. Independent Traffic: The model consists of N
independent stations (e.g., computers, telephones), each
with a program or user that generates frames for
transmission. The expected number of frames generated
in an interval of length Δt is λΔt, where λ is a constant
(the arrival rate of new frames). Once a frame has been
generated, the station is blocked and does nothing until
the frame has been successfully transmitted.
44

Dynamic Channel Allocation


Assumptions for Dynamic Channel Allocation
2. Single Channel. A single channel is available for all
communication. All stations can transmit on it and all can
receive from it. The stations are assumed to be equally
capable, though protocols may assign them different roles
(e.g., priorities).
3. Observable Collisions: If two frames are transmitted
simultaneously, they overlap in time and the resulting
signal is garbled. This event is called a collision. All
stations can detect that a collision has occurred. A collided
frame must be transmitted again later. No errors other
than those generated by collisions occur.
45

Dynamic Channel Allocation


Assumptions for Dynamic Channel Allocation
4. Continuous or Slotted Time: Time may be assumed
continuous, in which case frame transmission can begin at any
instant. Alternatively, time may be slotted or divided into
discrete intervals (called slots). Frame transmissions must then
begin at the start of a slot. A slot may contain 0, 1, or more
frames, corresponding to an idle slot, a successful transmission,
or a collision, respectively.
5. Carrier Sense or No Carrier Sense: With the carrier sense
assumption, stations can tell if the channel is in use before
trying to use it. No station will attempt to use the channel while
it is sensed as busy. If there is no carrier sense, stations cannot
sense the channel before trying to use it. They just go ahead and
transmit. Only later can they determine whether the
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

Textbooks
1. Computer-Networks- Andrew S. Tanenbaum
and David J. Wetherall, Pearson Education,
5th Edition.
(www.pearsonhighered.com/tanenbaum)

Reference Books
2. Behrouz A Forouzan, Data and Communications and
Networking, Fifth Edition, McGraw Hill, Indian Edition
3. Larry L Peterson and Brusce S Davie, Computer
Networks, fifth edition, ELSEVIER
92

Thank you

You might also like