Upload
mnshrao
View
241
Download
0
Embed Size (px)
Citation preview
8/12/2019 Chapter 3 - Data Link Layer
1/46
1
3a. Data Link Layer Protocols1. Introduction
2. DLL Design a. Network Layer Services
b. Error Controlc. Flow Control
3. Elementary Data LinkProtocols
a. Stop-and-Wait Protocol
b. Simplex Protocol for NoisyChannel; Time-out
c. Sliding Window Protocols
d. Sliding-window Flow Control
e. A One bit Sliding-Window
f. A Protocol Using Go-Back-N
g. Selective RejectHigh-Level Data Linc Control a. HDLC Operation
b. HDLC Protocol
The Internet Protocol a. PPP-The point-to-point protocol
(T. 183-229; 234-246)
8/12/2019 Chapter 3 - Data Link Layer
2/46
2
1. Data/control exchanged viaprotocols
a human protocol and a computer networkprotocol:
HiHi
Got thetime?
2:00
TCP connectionreq
TCP connectionresponse
Get http://www.awl.com/kurose-ross
time
8/12/2019 Chapter 3 - Data Link Layer
3/46
3
Data Link Layerapplication
transport
network
link
physical
Requirements and Objectives:Maintain and release data LinkFrame synchronizationError controlFlow controlAddressingLink management
DLL functions:
Providing service interface to the network layer.
Data Link Protocols must take circuit errors,
Flow regulating.
Data transfer betweenneighboring network elements
8/12/2019 Chapter 3 - Data Link Layer
4/46
4
Link Layer: Introduction
Some terminology:
Hosts, bridges, switches androutersare nodes
Communication channels that
connect adjacent nodes along
communication path are links wired links
wireless links
LANs
frame,encapsulates datagram
Data link
Data link layerhas responsibility oftransferring datagram from one node
to adjacent node over a data link
8/12/2019 Chapter 3 - Data Link Layer
5/46
5
2. Packet and Frame relationship
Packet
Header Payload fild Trai ler
Sending machine Receiving machine
PacketFrame
Header Payload field Trai ler
Network LayerNetwork Layer
In some cases, functions of error control and flow control areallocated in transport or other upper layer protocols and not in the
DLL, but principles are pretty much the same.
8/12/2019 Chapter 3 - Data Link Layer
6/46
6
Protocol layering and data
Each layer takes data from above
adds header information to create new data
unit
passes new data unit to layer below
applicationtransport
networklinkphysical
applicationtransport
networklinkphysical
source destination
M
M
MM
Ht
HtHnHtHnHl
M
M
M
M
Ht
HtH
n
HtHnHl
message
segment
datagram
frame
8/12/2019 Chapter 3 - Data Link Layer
7/46
7
Data flow-physical communication
applicationtransportnetwork
linkphysical
applicationtransportnetwork
linkphysical
applicationtransportnetwork
linkphysical
applicationtransportnetwork
linkphysical
networklinkphysical
data
data
8/12/2019 Chapter 3 - Data Link Layer
8/46
8
list of the DLL requirements Frame synchronization. Data are sent in blocks
called frames. The beginning and endof each framemust be recognized.
Flow control. The sending station must notsendframes at a ratefaster then the receiving station canabsorb them.
Error control. Any bit errors introduced by thetransmission system must be checked & corrected.
Addressing. On a multipoint line, such as a LAN,the identity of the two stations involved in a
transmission must be specified. Link management. The initiation, maintenance, and
terminationof a data exchange requires a fairamount of coordination and cooperation amongstations.
8/12/2019 Chapter 3 - Data Link Layer
9/46
9
Services to the Network Layer (NL)
DLL processes data transfer using a data link
protocol. The actual services can vary from system to system.
Three reasonable services to the NL are:
1. Unacknowledged connectionless service.2. Acknowledged connectionless service.
3. Acknowledged connection-oriented service.
8/12/2019 Chapter 3 - Data Link Layer
10/46
10
1. Unacknowledged connectionless service The source machine send frames to the destination
machine withouthaving the destination machineacknowledged them.
No logical connectionis established beforehand orreleased afterward.
If a frame is lost due to noise on the line, no attempt
is made to detect the loss or recoverfrom it in theDLL.
This class of service is appropriate when the errorrate is very lowso that recovery task is left for
solution to higher layers. It is also appropriate for real-time traffic, such asvoice, in which late data are worse than bad data.
Most LANs use unacknowledged connectionlessservice in the DLL
8/12/2019 Chapter 3 - Data Link Layer
11/46
11
2. Acknowledged connectionless service Is more reliable.
Still no logical connectionsused, but each frame
sent is individually acknowledged. The sender knowswhether a frame has arrived
correctly.
If it has not arrived within a specific time interval, it
can be sent again. This service is useful over unreliable channels,
such as wireless system. If the large packet is broken up into frames, If
individual frames are acknowledgedorretransmitted, entire packets get through muchfaster than unbrokenframe that is lost, it may takea very long time for the packet to get through..
8/12/2019 Chapter 3 - Data Link Layer
12/46
12
3. ACKed connection-oriented service The service requires established connectionbetween
source/destination machines before data are transferred.
Any framesent over the connection is numbered, and theDLL guarantees that each frame sent, is received, and arereceived in the same order.
With connectionless service, in contrast, it is possible that alost acknowledgement causes a packet to be sent severaltimes and thus received several times.
When connection-oriented service is used, transfers gothrough 3distinct phases:
1. The connection is establishedand counters needed to keep
trackof which frames have been received and which oneshave not.
2. One or more frames are transmitted andacknowledged.
3. Connection is released,freeing up the variables - buffersand
other resources used to maintain the connection.
8/12/2019 Chapter 3 - Data Link Layer
13/46
13
Link Layer JobFraming:
encapsulate datagram into frame, adding header, trailer
Error Detection:
errors caused by signal attenuation, noise.
receiver detects presence of errors:
signals sender for retransmission or drops frame
two types of errors: Lost frame
Damaged frame
Error Correction:
receiver identifies and correctsbit errors without
retransmission
8/12/2019 Chapter 3 - Data Link Layer
14/46
14
Example is a WAN subnet
Consisting of routers connected by point-to-point
leased telephone lines.1. When a frame arrives at a router, the hardwarechecksit for errors, (Passes the frame to the DLLsof twarewhich might be embedded in a chip on the
network interface board).2. The DLL software checks to see if it is the f rame
expected,
3. If so, givesthe packet (contained the payload field)
to the rout ing sof tware.4. The routing software then chooses the appropriate
ou tgoing l ine and passes the packetback down tothe DLL software, which then transmits it.
T h i f l
8/12/2019 Chapter 3 - Data Link Layer
15/46
15
Techniques for error control are: Error detection.
Positive Acknowledgment.
Retransmission after time-out.
Negative acknowledgment and retransmission
These 4mechanisms are all referred to as Automatic
Report reQuest (ARQ);the effect of ARQ is to turnan unreliable data link into a reliable one.
Three standardized versions Of ARQ:
Stop-and-wait ARQ Go-back-N ARQ
Selective-reject ARQ
L k L J b (C )
8/12/2019 Chapter 3 - Data Link Layer
16/46
16
Link Layer Job (Cont)Flow Control:
Two approaches are commonly used:1. Feedback-based flow control,the receiver
sends back information to the sender giving itpermission to send more data or at leasttelling the sender how the receiver is doing.
You may send me nframes now, but afterthey have been sent, do not send any more
until I have told you to continue.2. Rate-based flow control,the protocol has a
built-in mechanism that limits the rateat
which senders may transmit data. Since rate-based schemes are never used in the DLL
8/12/2019 Chapter 3 - Data Link Layer
17/46
17
Elementary Data Link Protocols Assumptions:
1).DLLand Networklayer are independent processes
that communicate by passing messages back and
forth trough the physical layer.
2).a.Machine Awants to send a long stream of data tomachine B, using a reliable, connection-oriented
service.
b. We will consider the case where Balso wants to
send data to Asimultaneously. Ais assumed tohave a data ready to send.
3).Machines do not crash.
P l 1 S d W i P l
8/12/2019 Chapter 3 - Data Link Layer
18/46
18
Prtcl.1. Stop-and Wait Protocol
Protocolin which the sender sends one frameand then waitsfor anACK: stop-and-wait.
t (timeout); Damaged ACK; ACK0, ACK1. bidirectionalinformation transfer.
Half duplexphysical channel.
It is often the case that a source will breakup a large block ofdata into smaller blocksand transmit the data in manyframes, Reason:
1. The buffersize of the receiver may be limited.
2. The larger the transmission, the more error,
With smaller frames, error aredetected sooner, Smaller
amount of data needs retransmission.3. On a shared medium, (LAN), it is usually desirable not topermitone station to occupythe medium for an extendedperiod, as this causes long delay at the other sendingstations.
8/12/2019 Chapter 3 - Data Link Layer
19/46
19
Stop-and-Wait ARQ
Timeout
Timeout
Frame lost A
retransmits
ACK1 lost A
retransmits
A B
B discards
duplicateframe
H t t th s d f
8/12/2019 Chapter 3 - Data Link Layer
20/46
20
How to prevent the sender fromflooding the receiver?
t= from_physical_layer +to_network_layer, Errors
Damaged:
Error detectionAcknowledgment
(Copies are maintained).,
Damaged ACK=Time-out+
Duplicates frame
Frame labeling (0 / 1).Positive ACK0= ready for 1;
ACK1= ready for 0.
Lost:
Timer
Time-out
Frame resend
(Copies are maintained)
8/12/2019 Chapter 3 - Data Link Layer
21/46
21
T T
T T
T T
T T
T T
R
R
R R
R
R
R
R
R
R
t0
t0+
t0+1+2
t0+1+
t0+1+2
t0+1+
t0+1
t0+
t0
t0+1
(a) >1 (b)
8/12/2019 Chapter 3 - Data Link Layer
22/46
22
Prtcl.2. Simplex prtcl for Noisy Channel; Time-out
Data are transmitted in one direction only (simplex
channel),that makes error. Frames may be eitherdamaged or lostcompletely.
Stop-and-wait protocol would work: adding a timer.
a. The sender could send a frame, but the receiver
would only send an ACK frame if the data werecorrectly received.
b. If a damaged frame arrived at the receiver, itwould be discarded.
c.After a while the sender would time out andsends the frame again. This process would berepeated until the frame finally arrives intact.
1-bit sequence number (0 or 1)
8/12/2019 Chapter 3 - Data Link Layer
23/46
23
TCP Round Trip Time and Timeout
Q:how to set TCP
timeout value?
too short: premature
timeout
=unnecessary
retransmissions
too long: slow
reaction =time
wasting
Q:how to estimate RTT?
SampleRTT:measured time
from segment transmission
until ACK receipt
ignore retransmissions
SampleRTTwill vary, want
estimated RTT smoother
average several recent
measurements, not just
current SampleRTT
8/12/2019 Chapter 3 - Data Link Layer
24/46
24
Fast Retransmit Time-out period often
relatively long: long delay beforeresending lost packet
Detect lost frame via
duplicate ACKs. Sender often sends
many frames back-to-
back
If frame is lost, therewill likely be many
duplicate ACKs.
If sender receives 3
ACKs for the samedata, it presumes that
frame after ACKed
data was lost:
fast retransmit: resend
frame immediately,
before timer expires
P t l i
8/12/2019 Chapter 3 - Data Link Layer
25/46
25
Protocol scenario:1. The network layer on Agives packet 1 to its DLL. The
packet is correctly received at Band passed to the
network layer on B.Bsends anACKframe back to A.
2. The ACK frame gets lost completely. It just neverarrives at all.
3. The DLLon Atimes out. Not having received an ACK,it (incorrectly) assumes that its data frame was lost ordamaged and sends the frame containing packet 1again.
4. The duplicate frame also arrives at the DLLonBperfectly and is randomly passed to the network layerthere. If Ais sending a file to B, part of the file will beduplicated (i.e., the copy of the file made by Bwill beincorrect and the error will not have been detected). In
other words, the protocol will fail.
Sliding Window
8/12/2019 Chapter 3 - Data Link Layer
26/46
26
Sliding-Window Better idea is to use the Duplex Channel.
Data frame from Ato Bare intermixed with theacknowledgment frames from Bto A.
By looking at the kind field in the header of an
incoming frame, the receiver can tell whetherthe frame is dataorACK.
Station B,-buffer space for n frames. Thus, B
can accept nframes, and A is allowed to sendnframes withoutwaiting for anyACK.
3-bitfield, the sequence number can range
from 0to 7 0 through , from 0 to12
k
8/12/2019 Chapter 3 - Data Link Layer
27/46
27
Sliding-Window
0 1 2 3 5 6 7 0 14 0765432
0
4321
554321 6 2107 43
Frames already received
Frames already received
Window of frames that
may be transmitted
Window of frames that
may be accepted
321076 4
Frame
Sequence
number
Last frame
transmittedWindow shrinks
from trailing edge
as frames are sent
Window expands from
leading edge as received
acknowledgment
Last frame
acknowledgedWindow shrinks
from trailing edge
as frames are received
Window expands from
leading edge as sent
acknowledgment
(a) Transmitters perspective
(b) Receivers perspective
P
ipeline
P 3 E l Slidi i d t l
8/12/2019 Chapter 3 - Data Link Layer
28/46
28
Pr.3. Example: Sliding-window protocol
0 1 2 3 4 5 6 7 0 1 2 3 0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3
F0F1
F2
RR3
F3
F4
F5
F6
RR7
Source system A Destination system B
Maximum window size=7
(RR
6);(RNR)
P 4 O Bit Slidi Wi d
8/12/2019 Chapter 3 - Data Link Layer
29/46
29
Pr.4 x mple One-Bit Sliding Window(piggybacking)
A sends(0,1,A0)
A gets (0,0,B0)*
A sends(1,0,A1)
A gets (1,1,B1)*
A sends(0,1,A2)
A gets (0,0,B2)*
A sends(1,0,A3)
B gets (0,1,A0)*
B sends(0,0,B0)
B gets (1,0,A1)*
B sends(1,1,B1)
B gets (0,1,A2)*
B sends(0,0,B2)
B gets (1,0,A3)*B sends(1,1,B3)
A sends(0,1,A0)
A gets (0,1,B0)*
A sends(0,0,A0)
A gets (0,0,B0)
A sends(1,0,A1)
A gets (1,0,B1)*
A sends(1,1,A1)
B sends(0,1,B0)B gets (0,1,A0)*
B sends(0,0,B0)
B gets (0,0,A0)
B sends(1,1,B1)
B gets (1,0,A1)*
B sends(1,1,B1)
B gets (1,1,A1)B sends(0,1,B2)
a b
Two scenario: (a) Normal case. (b) Abnormal case. The notation is (seq, ack,
packetnumber).An asterisk indicates where a network layer accepts a packet.
A; T-O short
P t l 5 A P t l U i G B k N
8/12/2019 Chapter 3 - Data Link Layer
30/46
30
Prtcl.5. A Protocol Using Go Back N
For efficiency of the bandwidth utilization:
59 kbpssatellite channel-500-msecround-trip delay.
Sent 1000-bitframe. At t=0msec-the frame has been
Started and t=20 msecsent. Received t=270 msec
frame fully arrived at the receiver; t=520 msec- ACKto
the sender; So, sender was blocked during 500/520or96%of the time. 4 %of the bandwidth was used.
The solution: the sender transmits up to wframes
before blocking, instead of just 1 frame.
The example, wshould be at least 26. The senderbegins sending Fr. 0as before. Finishes sending 26frames, at t=520 msec, the ACK for frame 0will have
just arrived.ACKarrive every 20 msec, (PIPLINING)so the sender always gets permission to continuewhen it needs it.
P 5 A P t l U i G B k N (C t)
8/12/2019 Chapter 3 - Data Link Layer
31/46
31
Pr.5.A Protocol Using Go Back N (Cont)
If the channel capacity is bbits/sec, the frame
size lbits, and the round-trip propagation timeRsec, the time required to transmit a single
frame is l /bsec. After the last bit of data
frame has been sent, there is a delay of R/2before that bit arrives at the receiver and
another delay of at least R/2for ACK to come
back, for a total delay of R.
In stop-and-wait the line is busy for l/band
idle for R, giving:
L ine uti l izat ion = l / (l+bR).=4%
Pr 5 A P t l U i G B k N
8/12/2019 Chapter 3 - Data Link Layer
32/46
32
Pr.5. A Protocol Using Go Back N
0 31 2 4 5 6 7 8
0 1 E
765432
532
D
0 1 2
5432
4
DD D DD
Time interval, Time out
9876 13121110
53E
0 1 24 9876 13121110
Error Frames discarded by DLL Time
Error Frames buffered by DLL
a
b
0 1 NAK2 1 1 5 6 7 8 9 10 11
0 1 2 3 4 5
Data flow ACK flowError recovery, when:
(a) receivers window size is 1 and(b)receivers window size is large; Selective Repeat
Selective
repeat
(NAK)
Go Back N
With size
window 1
Pr 5 Go Back N
8/12/2019 Chapter 3 - Data Link Layer
33/46
33
Pr.5.Go-Back-NSender:
k-bit seq # in packet header
window of up to N, consecutive unACKed pkts allowed
ACK(n): ACKs all pkts up to, including seq # n -
cumulative ACK
may receive duplicate ACKs (see receiver)
timer for each in-flight pkt
timeout(n):retransmit pkt n and all higher seq # pkts in
window
Prtcl 5 S l ti t d
8/12/2019 Chapter 3 - Data Link Layer
34/46
34
Prtcl.5. Selective repeat: sender-receiver windows
8/12/2019 Chapter 3 - Data Link Layer
35/46
35
Prtcl.7.High-Level Data Link Control
High-Level Data Link Control (HDLC)subsets:
(Synchronous Data Link Control (SDLC)
Link Access Procedurefor DChannel (LAPD)
Advanced Data Communication Control
Procedure (ADCCP) Link Access Procedure (LAP).
These protocols are based on the same principles.
P 7 HDLC F m F m t
8/12/2019 Chapter 3 - Data Link Layer
36/46
36
Pr.7.HDLC Frame Format
Flag
8 Bits
Address
8/16 Bits
Control
8/16 Bits
Data
Variable Length
CRC
8/16 Bits
Flag
8 Bits
bit oriented; bit stuffing
Master Slave
Commends
Response
Flag- synchronization.
Address- address of the secondary station.
Control- keep track of transmitted and received frames foracknowledgment and flow control.
CRC- contains a checksum to ensure data integrity.
Flag- used to signal the end of a frame, and possibly the start
of the next frame.
P 7 High Level Data Link Control
8/12/2019 Chapter 3 - Data Link Layer
37/46
37
Pr.7.High-Level Data Link Control Three kinds of control fields:
a. Informationb. Supervisory
c. Unnumbered.
0 Seq P/F Next
1
1
1
0
Bits 1 3 1 3
Type P/F Next
Type P/F Modifier
(a)
(b)
(c)
The protocol uses a slidingwindow, with 3-bit sequence
number. Up to seven
unacknowledged frames may be
outstanding at any instant.
For ACK is used the number of the first frame not
yet received (i.e.., the next frame expected).
P-polling data
F-finished polling.
(a)-nACK (reject)
(b)-RNR
(c)-Selective reject-
retransmit specified
P 7 Hi h L l D t Li k C t l
8/12/2019 Chapter 3 - Data Link Layer
38/46
38
Pr.7.High-Level Data Link Control Different types of frames use different ACKs:
Type
1
REJECT Transmission error
has been detected
Type
2
RECEIVENOT
READY
Acknowledges all
frames, but not
including Next.
Stop sending
Type
3
SELECTIE
REJECT
Retransmission
of only the frame
specified.
ACK Definition UsedFrame with
error
Problems withthe receiver
shortage of
buffer
senders
window size is
half or lessthesequence space
8/12/2019 Chapter 3 - Data Link Layer
39/46
39
A Network Layer in the Internet
Leased
Lines toAsia
A U.S. backbone
Regional
network
IP Ethernet
LAN
IP tokenRing LAN
Regional
network
A European backbone
A1 C
D
B
2
D Li k L i h I
8/12/2019 Chapter 3 - Data Link Layer
40/46
40
Data Link Layer in the Internet
Subnetrouter
Host
ATC
PC
Service
provider
Data Link Layer in the Internet
8/12/2019 Chapter 3 - Data Link Layer
41/46
41
Data Link Layer in the Internet
PC
modemClient process
Using TCP/IP
Users home
Dial-upTelephone
line
TCP/IP
ConnectionUsing PPP
modems
RouterRouting
process
Internet providers office
A home personal computer acting as an Internet host
PPP Situation
Pr 8 PPP-The Point-to-point
8/12/2019 Chapter 3 - Data Link Layer
42/46
42
Pr.8.PPP-The Point-to-pointProtocol
PPP provides three features:
A framing method that clearly determines the:
end of one frame and the start of the next one,
Error detection.
A link control protocol for bringing lines up, testing them,
negotiating options, and bringing them down again when theyare no longer needed, This protocol is calledLCP (LinkControl Protocol).It supports synchronous andasynchronous circuits and byte-oriented and bit-orientedencodings.
A way to negotiate network-layer options in a way that isindependent of the network layer protocol to be used. Themethod chosen is to have a differentNCP (Network ControlProtocol)for each network layer supported.
P PPP
8/12/2019 Chapter 3 - Data Link Layer
43/46
43
Pr.8.PPP- Steps
ATC
Router 1. PC calls the providers router via a modem.
2. The routers modem has answered the
phone and established a physical connection
3. PC sends to the router a series of LCP
packets in the payload field of one or more
PPP frames
These packets and their responses select the PPP
parameters to be used.
Once the parameters have been agreed upon, a series of
Network Control Protocol packets are sent to configure the
network layer.
Typically, the PC wants to run a TCP/IP protocol stack, so it
needs an IP address.
PPP d HDLC
8/12/2019 Chapter 3 - Data Link Layer
44/46
44
Difference betweenPPPandHDLC
Flag
8 Bits01111110
Address
8/16
Bits
Control
8/16
Bits
Data
Variable
Length
CRC
8/16
Bits
Flag
8 Bits01111110
High-Level Data Link Frame; Bit-Oriented
Flag
01111110
Address
11111111
Control
00000011
Protocol Payload Checksum Flag
01111110
1 1 1 1 or 2 variable 2 or 4 1
Bytes
PPP Frame; Byte Oriented
Pr 8 PPP Protocol field
8/12/2019 Chapter 3 - Data Link Layer
45/46
45
Pr.8.PPP-Protocol field The Protocolfields job is to tell what kind of
packet is in the Payloadfield.
Codes are defined for LCP, NCP, IP, and other
protocols.
Protocols starting with a 0 bitare network layer
protocols such as IP, IPX, OSI CLANP. Those starting with a 1 bitare used to negotiate
other protocols. These include LCPand a different
NCPfor each network layer protocol supported.
The default size of the protocol field is 2 bytes, but it
can be negotiated down to 1 byteusing LCP.
PPP
8/12/2019 Chapter 3 - Data Link Layer
46/46
46
PPP-summary PPP is a multiprotocol framing mechanism suitable for use
over:Modems, HDLC,SONET, Other physical layers. It supports:Error detection, Option negotiating, Header
compression.
DLL converts the raw bit stream (from physical layer) into a
stream of frames (for network layer). Various framing methods are used:character count, byte
stuffing, and bit stuffing.
Data link protocols can provide:1. Error control to retransmit
damaged or lost frames. 2.To prevent a fast sender fromoverrunning a slow receiver.
The data link protocol also provide flow control.
The sliding window mechanism is used to integrate error