Vous êtes sur la page 1sur 117

Computer Networks

and Internetworking
Layers
Dippal Israni
Assistant Professor, U and P U Patel Department of Computer
Engineering,
CHARUSAT

E-Mail ID: dippalisrani.ce@charusat.ac.in


Chapter 3

The Data Link Layer


Functions of the Data Link Layer

• Provide service interface to the network layer


• Dealing with transmission errors
• Regulating data flow
• Slow receivers not swamped by fast senders
Functions of the Data Link Layer (2)

Relationship between packets and frames.


Data Link Layer Design Issues
• Services Provided to the Network Layer
• Framing
• Error Control
• Flow Control
Services Provided to Network Layer

(a) Virtual communication.


(b) Actual communication.
Services Provided to Network Layer
(1) Unacknowledged Connectionless Service
• When Error Rate is very low
• For Real time traffic - Voice

(2) Acknowledged Connectionless Service


• Unreliable Communication such as Wifi
• Optimization not requirement
• Optical Fibre Vs Wifi
(3) Acknowledged Connection-Oriented Service
• Disadvantage:
• Lost Acknowledgement will waste
bandwith
Services Provided to Network Layer
(2)

Placement of the data link protocol.


Framing
• Uses Services of Physical Layer
• Problem 1) bits received not equal to bits transmitted
• Problem 2) Bits might change
• Frame <-> Checksum

• Byte Count
• Flag with Byte Stuffing
• Flag Bits with Bit Stuffing
Framing

A character stream. (a) Without errors. (b) With one error.


Framing (2)

(a) A frame delimited by flag bytes.


(b) Four examples of byte sequences before and after stuffing.
Framing (3)

Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receiver’s memory after destuffing.
Error and Flow Control

• Feedback Based Flow Control


• Rate based Flow Control
Error Detection
and Correction
a) Types of Errors
b) Detection
c) Correction
Basic concepts
 Networks must be able to transfer data from one device to
another with complete accuracy.
 Data can be corrupted during transmission.
 For reliable communication, errors must be detected and
corrected.
 Error detection and correction are
implemented either at the data link layer or the
transport layer of the OSI model.
Types of Errors
Single-bit error
Single bit errors are the least likely type of errors in serial
data transmission because the noise must have a very short
duration which is very rare. However this kind of errors
can happen in parallel transmission.
Example:
 If data is sent at 1Mbps then each bit lasts only
1/1,000,000 sec. or 1 μs.
 For a single-bit error to occur, the noise must have a
duration of only 1 μs, which is very rare.
Burst error
The term burst error means that two or more bits in the
data unit have changed from 1 to 0 or from 0 to 1.

Burst errors does not necessarily mean that the errors


occur in consecutive bits, the length of the burst is
measured from the first corrupted bit to the last corrupted
bit. Some bits in between may not have been corrupted.
 Burst error is most likely to happen in serial transmission
since the duration of noise is normally longer than the duration of
a bit.
 The number of bits affected depends on the data rate and duration
of noise.
Example:
If data is sent at rate = 1Kbps then a noise of 1/100 sec
can affect 10 bits.(1/100*1000)

If same data is sent at rate = 1Mbps then a noise of


1/100 sec can affect 10,000 bits.(1/100*106)
Error detection

Error detection means to decide whether the received data is


correct or not without having a copy of the original message.

Error detection uses the concept of redundancy, which means


adding extra bits for detecting errors at the destination.
Redundancy
Four types of redundancy checks are used
in data communications
Vertical Redundancy Check
VRC
Performance

 It can detect single bit error


 It can detect burst errors only if the total number of errors is odd.
Longitudinal Redundancy Check
LRC
LRC
LRC
a) 11100111
b) 11011101
c) 00111001
d) 10101001

• 11100101
• 11010101
• 00111001
• 10101001
LRC
Performance

LCR increases the likelihood of detecting


burst errors.
If two bits in one data units are damaged
and two bits in exactly the same positions
in another data unit are also damaged, the
LRC checker will not detect an error.
VRC and LRC
Checksum
At the sender

 The unit is divided into k sections, each of n bits.


 All sections are added together using one’s complement to get the
sum.
 The sum is complemented and becomes the checksum.
 The checksum is sent with the data
At the receiver

 The unit is divided into k sections, each of n bits.


 All sections are added together using one’s complement to get the
sum.
 The sum is complemented.
 If the result is zero, the data are accepted: otherwise, they are
rejected.
CHECKSUM (Sender)
•Assume the packet header is:
01 00 F2 03 F4 F5 F6 F7 00 00 (00 00 is the checksum to be calculated)
•The first step is to form 16-bit words.
0100 F203 F4F5 F6F7
•The second step is to calculate the sum using 32-bits.
0100 + F203 + F4F5 + F6F7 = 0002 DEEF
•The third step is to add the carries (0002) to the 16-bit sum.
DEEF + 002 = DEF1
•The fourth step is to take the complement. (1s becomes 0s and 0s become 1s)
~DEF1 = 210E
So the checksum is 21 0E.
•The packet header is sent as:
01 00 F2 03 F4 F5 F6 F7 21 0E
CHECKSUM (Receiver)
a) At the receiver, the steps are repeated.
b) The first step is to form 16-bit words.
0100 F203 F4F5 F6F7 210E
c)The second step is to calculate the sum using 32-bits.
0100 + F203 + F4F5 + F6F7 + 210E =
0002 FFFD
d)The third step is to add the carries (0002) to the 16-bit sum. FFFD +
0002 = FFFF which means that no error was detected. (In 1s
complement, zero is 0000 or FFFF.)
Performance
 The checksum detects all errors involving an odd number of
bits.
 It detects most errors involving an even number of bits.
 If one or more bits of a segment are damaged and the
corresponding bit or bits of opposite value in a second
segment are also damaged, the sums of those columns will not
change and the receiver will not detect a problem.
Polynomial
Polynomial and Divisor
Cyclic Redundancy Check
CRC
Cyclic Redundancy Check
a) Given a k-bit frame or message, the transmitter
generates an n-bit sequence, known as a frame
check sequence (FCS), so that the resulting
frame, consisting of (k+n) bits, is exactly divisible by
some predetermined number.
b) The receiver then divides the incoming frame by the
same number and, if there is no remainder, assumes that
there was no error.
Example
Binary Division

101111101
Error-Correcting Codes

• Hamming Codes
• Binary Convolutional Codes
• Reed-Solomon Codes
• Low-Density Parity Check codes
Hamming Codes: Encoding
Localizing error to top or bottom half 1xxx or 0xxx

m15m14m13m12 m11 m10 m9 p8 m7 m6 m5 m3 p0


p8 = m15  m14  m13  m12  m11  m10  m9
10011010
Localizing error to x1xx or x0xx
m15m14m13m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 m2 p0
p4 = m15  m14  m13  m12  m7  m6  m5
Localizing error to xx1x or xx0x
m15m14m13m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 p2 p0
p2 = m15  m14  m11  m10  m7  m6  m3
Localizing error to xxx1 or xxx0
m15m14m13m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 p2 p1 p0
p1 = m15  m13  m11  m9  m7  m5  m3
15-853 Page47
Hamming Codes: Decoding
m15m14m13m12 m11 m10 m9 p8 m7 m6 m5 p4 m3 p2 p1 p0

a) We don’t need p0, so we have a (15,11,?) code.


b) After transmission, we generate
b8 = p8  m15  m14  m13  m12  m11  m10  m9
b4 = p4  m15  m14  m13  m12  m7  m6  m5
b2 = p2  m15  m14  m11  m10  m7  m6  m3
b1 = p1  m15  m13  m11  m9  m7  m5  m3
c) With no errors, these will all be zero
d) With one error b8b4b2b1 gives us the error location.
e) e.g. 0100 would tell us that p4 is wrong, and
1100 would tell us that m12 is wrong
15-853 Page48
Hamming Code
a) 10011010
b) 011100101010 <-> 011100101110
Even Parity Hamming Code , check whether they are corrected
c) 010101100011
d) 111110001100
e) 000010001010
Taxonomy of protocols discussed in this chapter

11.50
Elementary Data Link Protocols

• An Unrestricted Simplex Protocol


• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
Protocol Definitions

Continued 

Some definitions needed in the protocols to follow.


These are located in the file protocol.h.
Figure 11.6 The design of the simplest protocol with no flow or error control

11.53
Protocol
Definitions
(ctd.)

Some definitions
needed in the
protocols to follow.
These are located in
the file protocol.h.
Unrestricted
Simplex
Protocol
Flow diagram for Example of Simplex
Disadvantage
• No Flow Control

• No Error Control
Stop-and-Wait Protocol

11.58
Stop-and-Wait Protocol

Protocols in which the sender


sends one frame and then waits
for acknowledgement before
proceeding is called stop and
wait.

11.59
Simplex
Stop-and-
Wait
Protocol
Simplex Stop and Wait

11.61
Disadvantage
In noisy channels

• A-> B Data

• B->A (ack)-> Lost

• A->B Send frame again

• B unwittingly passes to data link layer


11­5   NOISY CHANNELS

Although the Stop-and-Wait Protocol gives us an idea of


how to add flow control to its predecessor, noiseless
channels are nonexistent. We discuss three protocols in
this section that use error control.

Topics discussed in this section:


Stop-and-Wait Automatic Repeat Request
Go-Back-N Automatic Repeat Request
Selective Repeat Automatic Repeat Request

11.63
Note

Error correction in Stop-and-Wait ARQ is done by


keeping a copy of the sent frame and
retransmitting of the frame when the timer
expires.

11.64
Note

In Stop-and-Wait ARQ, we use sequence


numbers to number the frames.
The sequence numbers are based on modulo-2
arithmetic.

11.65
Note

In Stop-and-Wait ARQ, the


acknowledgment number always
announces in modulo-2 arithmetic the
sequence number of the next frame
expected.

11.66
Figure 11.10 Design of the Stop-and-Wait ARQ Protocol

11.67
Example 11.3

Figure 11.11 shows an example of Stop-and-Wait ARQ.


Frame 0 is sent and acknowledged. Frame 1 is lost and
resent after the time-out. The resent frame 1 is
acknowledged and the timer stops. Frame 0 is sent and
acknowledged, but the acknowledgment is lost. The sender
has no idea if the frame or the acknowledgment is lost, so
after the time-out, it resends frame 0, which is
acknowledged.

11.68
Figure 11.11 Flow diagram for Example 11.3

11.69
Algorithm 11.5 Sender-site algorithm for Stop-and-Wait ARQ

(continued)
11.70
(continued)
Algorithm 11.5 Sender-site algorithm for Stop-and-Wait ARQ

11.71
Algorithm 11.6 Receiver-site algorithm for Stop-and-Wait ARQ Protocol

11.72
Example 11.4

Assume that, in a Stop-and-Wait ARQ system, the


bandwidth of the line is 1 Mbps, and 1 bit takes 20 ms to
make a round trip. What is the bandwidth-delay product? If
the system data frames are 1000 bits in length, what is the
utilization percentage of the link?

Solution
The bandwidth­delay product is

11.73
Example 11.4 (continued)

The system can send 20,000 bits during the time it takes for
the data to go from the sender to the receiver and then back
again. However, the system sends only 1000 bits. We can
say that the link utilization is only 1000/20,000, or 5
percent. For this reason, for a link with a high bandwidth
or long delay, the use of Stop-and-Wait ARQ wastes the
capacity of the link.

11.74
Example 11.5

What is the utilization percentage of the link in Example


11.4 if we have a protocol that can send up to 15 frames
before stopping and worrying about the
acknowledgments?
Solution
The  bandwidth­delay  product  is  still  20,000  bits.  The 
system  can  send  up  to  15  frames  or  15,000  bits  during  a 
round trip. This means the utilization is 15,000/20,000, or 
75  percent.  Of  course,  if  there  are  damaged  frames,  the 
utilization percentage is much less because frames have to 
be resent.
11.75
Note

In the Go-Back-N Protocol, the sequence


numbers are modulo 2m,
where m is the size of the sequence
number field in bits.

11.76
Figure 11.12 Send window for Go-Back-N ARQ

11.77
Note

The send window is an abstract concept defining


an imaginary box of size 2m − 1 with three
variables: Sf, Sn, and Ssize.

11.78
Note

The send window can slide one


or more slots when a valid acknowledgment
arrives.

11.79
Figure 11.13 Receive window for Go-Back-N ARQ

11.80
Note

The receive window is an abstract concept


defining an imaginary box
of size 1 with one single variable Rn.
The window slides
when a correct frame has arrived; sliding occurs
one slot at a time.

11.81
Figure 11.14 Design of Go-Back-N ARQ

11.82
Note

In Go-Back-N ARQ, the size of the send window


must be less than 2m;
the size of the receiver window
is always 1.

11.83
Figure 11.15 Window size for Go-Back-N ARQ

11.84
Note

In Go-Back-N ARQ, the size of the send window


must be less than 2m;
the size of the receiver window
is always 1.

11.85
Example 11.6

Figure 11.16 shows an example of Go-Back-N. This is an


example of a case where the forward channel is reliable,
but the reverse is not. No data frames are lost, but some
ACKs are delayed and one is lost. The example also shows
how cumulative acknowledgments can help if
acknowledgments are delayed or lost. After initialization,
there are seven sender events. Request events are triggered
by data from the network layer; arrival events are triggered
by acknowledgments from the physical layer. There is no
time-out event here because all outstanding frames are
acknowledged before the timer expires. Note that although
ACK 2 is lost, ACK 3 serves as both ACK 2 and ACK 3.
11.86
Figure 11.16 Flow diagram for Example 11.6

11.87
Example 11.7

Figure 11.17 shows what happens when a frame is lost.


Frames 0, 1, 2, and 3 are sent. However, frame 1 is lost.
The receiver receives frames 2 and 3, but they are
discarded because they are received out of order. The
sender receives no acknowledgment about frames 1, 2, or
3. Its timer finally expires. The sender sends all
outstanding frames (1, 2, and 3) because it does not know
what is wrong. Note that the resending of frames 1, 2, and
3 is the response to one single event. When the sender is
responding to this event, it cannot accept the triggering of
other events. This means that when ACK 2 arrives, the
sender is still busy with sending frame 3.
11.88
Example 11.7 (continued)

The physical layer must wait until this event is completed


and the data link layer goes back to its sleeping state. We
have shown a vertical line to indicate the delay. It is the
same story with ACK 3; but when ACK 3 arrives, the
sender is busy responding to ACK 2. It happens again when
ACK 4 arrives. Note that before the second timer expires,
all outstanding frames have been sent and the timer is
stopped.

11.89
Figure 11.17 Flow diagram for Example 11.7

11.90
Algorithm 11.7 Go-Back-N sender algorithm

(continued)
11.91
(continued)
Algorithm 11.7 Go-Back-N sender algorithm

SendFrame(temp);
temp=temp+1;

11.92
Algorithm 11.8 Go-Back-N receiver algorithm

11.93
Figure 11.18 Send window for Selective Repeat ARQ

11.94
Figure 11.19 Receive window for Selective Repeat ARQ

11.95
Figure 11.20 Design of Selective Repeat ARQ

11.96
Figure 11.21 Selective Repeat ARQ, window size

11.97
Note

In Selective Repeat ARQ, the size of the


sender and receiver window
must be at most one-half of 2m.

11.98
Figure 11.22 Delivery of data in Selective Repeat ARQ

11.99
Example 11.8

This example is similar to Example 11.3 in which frame 1 is


lost. We show how Selective Repeat behaves in this case.
Figure 11.23 shows the situation. One main difference is
the number of timers. Here, each frame sent or resent needs
a timer, which means that the timers need to be numbered
(0, 1, 2, and 3). The timer for frame 0 starts at the first
request, but stops when the ACK for this frame arrives. The
timer for frame 1 starts at the second request, restarts when
a NAK arrives, and finally stops when the last ACK arrives.
The other two timers start when the corresponding frames
are sent and stop at the last arrival event.
11.100
Example 11.8 (continued)

At the receiver site we need to distinguish between the


acceptance of a frame and its delivery to the network layer.
At the second arrival, frame 2 arrives and is stored and
marked, but it cannot be delivered because frame 1 is
missing. At the next arrival, frame 3 arrives and is marked
and stored, but still none of the frames can be delivered.
Only at the last arrival, when finally a copy of frame 1
arrives, can frames 1, 2, and 3 be delivered to the network
layer. There are two conditions for the delivery of frames to
the network layer: First, a set of consecutive frames must
have arrived. Second, the set starts from the beginning of
the window.
11.101
Example 11.8 (continued)

Another important point is that a NAK is sent after the


second arrival, but not after the third, although both
situations look the same. The reason is that the protocol
does not want to crowd the network with unnecessary
NAKs and unnecessary resent frames. The second NAK
would still be NAK1 to inform the sender to resend frame 1
again; this has already been done. The first NAK sent is
remembered (using the nakSent variable) and is not sent
again until the frame slides. A NAK is sent once for each
window position and defines the first slot in the window.

11.102
Example 11.8 (continued)

The next point is about the ACKs. Notice that only two ACKs
are sent here. The first one acknowledges only the first
frame; the second one acknowledges three frames. In
Selective Repeat, ACKs are sent when data are delivered to
the network layer. If the data belonging to n frames are
delivered in one shot, only one ACK is sent for all of them.

11.103
Figure 11.23 Flow diagram for Example 11.8

11.104
Figure 11.24 Design of piggybacking in Go-Back-N ARQ

11.105
Algorithm 11.9 Sender-site Selective Repeat algorithm

(continued)

11.106
(continued)
Algorithm 11.9 Sender-site Selective Repeat algorithm

11.107 (continued)
(continued)
Algorithm 11.9 Sender-site Selective Repeat algorithm

11.108
Algorithm 11.10 Receiver-site Selective Repeat algorithm

11.109
Algorithm 11.10 Receiver-site Selective Repeat algorithm

11.110
BASIS FOR COMPARISON GO-BACK-N SELECTIVE REPEAT

Retransmits all the frames that sent after


Retransmits only those frames that are
Basic the frame which suspects to be damaged
suspected to lost or damaged.
or lost.

If error rate is high, it wastes a lot of Comparatively less bandwidth is wasted


Bandwidth Utilization
bandwidth. in retransmitting.

More complex as it require to apply extra


Complexity Less complicated. logic and sorting and storage, at sender
and receiver.

Window size
Window Size is 2m-1 and Sender and receiver Window
receiver window size is 1 Size is 2m-1
Sorting is neither required at sender side Receiver must be able to sort as it has to
Sorting
nor at receiver side. maintain the sequence of the frames.

Receiver do not store the frames received Receiver stores the frames received after
Storing after the damaged frame until the the damaged frame in the buffer until the
damaged frame is retransmitted. damaged frame is replaced.

No searching of frame is required neither The sender must be able to search and
Searching
on sender side nor on receiver select only the requested frame.

NAK number refer to the next expected


ACK Numbers NAK number refer to the frame lost.
frame number.
It is less in practice because of its
Use It more often used.
complexity.
Example Data Link Protocols
• PPP:
1. Framing
2. LCP
3. NCP

IP IP
PPP PPP
SONET SONET

Optical
Fibre
PPP – Point to Point Protocol

0-IPX
1-PPP
configuration
payload

The PPP full frame format for unnumbered mode operation.


The Data Link Layer in the Internet

A home personal computer acting as an internet host.


PPP – Point to Point Protocol (2)

A simplified phase diagram for bring a line up and down.


High-Level Data Link Control (2)

Control field of
(a) An information frame.
(b) A supervisory frame.
(c) An unnumbered frame.

Vous aimerez peut-être aussi