Professional Documents
Culture Documents
Data Link
Data Link
Peer-to-Peer Protocols
and Data Link Layer
PART I: Peer-to-Peer Protocols
Peer-to-Peer Protocols
ARQ Protocols and Reliable Data Transfer
Flow Control
PART II: Data Link Controls
Framing
Point-to-Point Protocol
High-Level Data Link Control
Chapter 5
Peer-to-Peer Protocols
and Data Link Layer
PART I: Peer-to-Peer Protocols
Peer-to-Peer Protocols
ARQ Protocols and Reliable Data Transfer
Flow Control
Peer-to-Peer protocols
Application Application
Communicating End Systems
End-to-End Protocols
Application Application
Layer Layer
Transport Transport
Layer Layer
Network Network Network Network
Layer Layer Layer Layer
Data Link Data Link Data Link Data Link
Layer Layer Layer Layer
Physical Physical Physical Physical
Layer Layer Layer Layer
Messages Messages
Network
l Segments can experience long delays, can be lost, or
arrive out-of-order because packets can follow different
paths across network
l End-to-end error control protocol more difficult
C
1 2 3 2 1
2 2
1 1
End System
α 1 End System
1 2 1
2 2 β
4 3 21 12 3 2 1 1 2 3 2 1 1 2 3 4
Medium
2
A B 1
Network
Simple
End-to-end
ACK/NAK
inside the
network
More scalable,
1 2 3 4 5 complexity at
Data Data Data Data the edge
Chapter 5
Peer-to-Peer Protocols
and Data Link Layer
PART I: Peer-to-Peer Protocols
Peer-to-Peer Protocols
ARQ Protocols and Reliable Data Transfer
Flow Control
Error Control
l Digital transmission systems introduce errors
l Applications require certain reliability level
l Data applications require error-free transfer
l Voice & video applications tolerate some errors
l Error control used when transmission system does not meet
application requirement
l Error control ensures a data stream is transmitted to a certain
level of accuracy despite errors
l Two basic approaches:
l Error detection & retransmission (ARQ)
l Forward error correction (FEC) (not covered in this
course)
Error Detection
x
coding x x = codewords
x x
0 o = noncodewords
0 0
0
Recalculate
check bits
k bits
Channel
Calculate
check bits Compare
Sent Received
Information
check check bits
accepted if
bits check bits
match
n – k bits
How good is the single parity
check code?
l Redundancy: Single parity check code adds 1
redundant bit per k information bits:
overhead = 1/(k + 1)
l Coverage: all error patterns with odd # of errors can
be detected
l An error pattern is a binary (k + 1)-tuple with 1s where
errors occur and 0’s elsewhere
l Of 2k+1 binary (k + 1)-tuples, ½ are odd, so 50% of error
patterns can be detected
l Is it possible to detect more errors if we add more
check bits?
l Yes, with the right codes
What if bit errors are random?
l Many transmission channels introduce bit errors at random,
independently of each other, and with probability p
l Some error patterns are more probable than others:
p
P[10000000] = p(1 – p)7 = (1 – p)8 and
1–p
P[11000000] = p (1 – p) = (1 – p)
2 6 8 p 2
1–p
1 0 0 1 0 0
0 1 0 0 0 1
Last column consists
1 0 0 1 0 0 of check bits for each
1 1 0 1 1 0 row
1 0 0 1 1 1
1 0 0 1 1 1 1 0 0 1 1 1
Source IP Address
Destination IP Address
Options Padding
bL = - x modulo 216-1
Thus, the headers must satisfy the following pattern:
0 = b0 + b1 + b2+ ...+ bL-1 + bL modulo 216-1
l The checksum calculation is carried out in software
using one’s complement arithmetic
Internet Checksum Example
For simplicity, assuming 4-bit words
Use Binary Arithmetic
Use Modulo Arithmetic l Note 16 =1 mod15
l b1=1010 = 10 b0 + b1 = 1100+1010
l b0+b1=12+10=7 mod15 =10110
l b2 = -7 = 8 mod15 =10000+0110
=0001+0110
l Therefore
=0111
l b2=1000 =7
Take 1s complement
b2 = -0111 =1000
Polynomial Codes
l Polynomials instead of vectors for codewords
l Polynomial arithmetic instead of check sums
l Implemented using shift-register circuits
l Also called cyclic redundancy check (CRC)
codes
l Most data communications standards use
polynomial codes for error detection
l Polynomial codes also basis for powerful
error-correction methods
Binary Polynomial Arithmetic
l Binary vectors map to polynomials
(ik-1 , ik-2 ,…, i2 , i1 , i0) à ik-1xk-1 + ik-2xk-2 + … + i2x2 + i1x + i0
Addition:
(x7 + x6 + 1) + (x6 + x5) = x7 + x6 + x6 + x5 + 1
= x7 +(1+1)x6 + x5 + 1
= x7 +x5 + 1 since 1+1=0 mod2
Multiplication:
(x + 1) (x2 + x + 1) = x(x2 + x + 1) + 1(x2 + x + 1)
= (x3 + x2 + x) + (x2 + x + 1)
= x3 + 1
Binary Polynomial Division
l Division with Decimal Numbers
34 quotient dividend = quotient x divisor +remainder
35 ) 1222 dividend
105 1222 = 34 x 35 + 32
divisor 17 2
140
32 remainder
x3 + x2 + x = q(x) quotient
l Polynomial
Division x3 + x + 1 ) x6 + x5
x6 + x4 + x3 dividend
divisor
x5 + x4 + x3
x5 + x3 + x2
Note: Degree of r(x) is less than x4 + x2
degree of divisor
x4 + x2 + x
x = r(x) remainder
Polynomial Coding
l Code has binary generating polynomial of degree n–k
g(x) = xn-k + gn-k-1xn-k-1 + … + g2x2 + g1x + 1
l k information bits define polynomial of degree k – 1
i(x) = ik-1xk-1 + ik-2xk-2 + … + i2x2 + i1x + i0
l Find remainder polynomial of at most degree n – k – 1
q(x)
g(x) ) xn-k i(x) xn-ki(x) = q(x)g(x) + r(x)
r(x)
l Define the codeword polynomial of degree n – 1
x3 + x2 + x
1110
x3 + x + 1 ) x6 + x5 1011 ) 1100000
x6 + x 4 + x3 1011
x5 + x4 + x3 1110
x5 + x 3 + x2 1011
x4 + x2 1010
x4 + x2 + x 1011
x 010
Transmitted codeword:
b(x) = x6 + x5 + x
b = (1,1,0,0,0,1,0)
The Pattern in Polynomial Coding
l CRC-8: ATM
= x8 + x2 + x + 1
l CRC-16: Bisync
= x16 + x15 + x2 + 1
= (x + 1)(x15 + x + 1)
= x16 + x12 + x5 + 1
l CCITT-32:
IEEE 802, DoD, V.42
Header
CRC
Information Header
packet CRC
Information frame Control frame: ACKs
Need for Sequence Numbers
(a) Frame 1 lost Time-out
Time
A Frame Frame Frame Frame
0 1 1 2
ACK ACK
B
l In cases (a) & (b) the transmitting station A acts the same way
l But in case (b) the receiving station B accepts frame 1 twice
l Question: How is the receiver to know the second frame is also frame 1?
l Answer: Add frame sequence number in header
l Slast is sequence number of most recent transmitted frame
Sequence Numbers
(c) Premature Time-out
Time-out
Time
A Frame
0 Frame Frame Frame
ACK 0 1 2
ACK
B
Slast Rnext
Timer
B t
B
frame
tprop tproc tack tprop
tf time
nf na bits/ACK frame
2t prop 2t proc
R R
Transmission efficiency:
Effect of
n f no no
1 frame overhead
Reff t0 nf
0 .
R R na 2(t prop t proc ) R
1
nf nf
Effect of
Effect of Delay-Bandwidth Product
ACK frame
Example: Impact of Delay-
Bandwidth Product
nf=1250 bytes = 10000 bits, na=no=25 bytes = 200 bits
2xDelayxBW 1 ms 10 ms 100 ms 1 sec
Efficiency
200 km 2000 km 20000 km 200000 km
1 Mbps 103 104 105 106
88% 49% 9% 1%
1 Gbps 106 107 108 109
1% 0.1% 0.01% 0.001%
n f no
t0 no
1
Reff 1 Pf nf
SW (1 Pf )
R R na 2(t prop t proc ) R
1
nf nf
Effect of
frame loss
Just-in-time mathematics
l Let X be a random variable assuming the values of
x1, x2,… with corresponding probabilities p1, p2,....
The mean or expected value of X is defined by:
E( X ) pi xi
i
i 1
t0 (i 1)tout Pf (1 Pf )
i 1
tout Pf 1
t0 t0 .
1 Pf 1 Pf
Efficiency:
nf no no
1
E[ttotal ] nf
SW (1 Pf ) (1 Pf ) 0 .
R na 2(t prop t proc ) R
1
nf nf
Example: Impact Bit Error Rate
nf=1250 bytes = 10000 bits, na=no=25 bytes = 200 bits
Find efficiency for random bit errors with p=0, 10-6, 10-5, 10-4
nf nf p
1 Pf (1 p ) e for large n f and small p
fr fr fr fr fr fr fr fr fr fr fr fr fr fr Time
0 1 2 3 4 5 6 3 4 5 6 7 8 9
A
B
A A A out of sequence A A A A A A
C C C frames C C C C C C
K K K K K K K K K
1 2 3 4 5 6 7 8 9
Rnext 0 1 2 3 3 4 5 6 7 8 9
B
Receiver is A
looking for C
K
Rnext=0
1
B
A A A A A A
Receiver is Out-of- C C
C C C C
looking for sequence K K K K K K
Rnext=0 frames 1 2 3 4 5 6
Go-Back-N (with timeout)
l Problem with the primitive Go-Back-N as
presented:
l If frame is lost and source does not have frame to
send, then window will not be exhausted and
recovery will not commence
l Use a timeout with each frame
l When timeout expires, resend all outstanding
frames
Go-Back-N Transmitter & Receiver
Transmitter Receiver
Send Window
... Receive Window
Frames
transmitted S
last Srecent Slast+Ws-1
and ACKed
Frames
Buffers Rnext
received
oldest un-
Timer Slast ACKed frame
Timer
Slast+1 Receiver will only accept
... a frame that is error-free and
that has sequence number Rnext
Timer
Srecent most recent
transmission
When such frame arrives Rnext is
... incremented by one, so the
Slast+Ws-1 max Seq # receive window slides forward by
allowed one
Sliding Window Operation
Transmitter
Frames
transmitted S 0
and ACKed
last Srecent Slast+Ws-1 2m – 1 1
2
Transmitter waits for error-free
ACK frame with sequence
number Slast Slast
send
When such ACK frame arrives,
window i
Slast is incremented by one, and
the send window slides forward i + Ws – 1 i+1
by one
Maximum Allowable Window Size is Ws = 2m-1
M = 22 = 4, Go-Back - 4: Transmitter goes back 4
fr fr fr fr fr fr fr fr Time
A 0 1 2 3 0 1 2 3
A A A A
B C C C C Receiver has Rnext= 0, but it does not
K K K K know whether its ACK for frame 0 was
1 2 3 0
received, so it does not know whether
Rnext 0 1 2 3 0 this is the old frame 0 or a new frame 0
A A A
B C C C
K K K Receiver has Rnext= 3 , so it
1 2 3
rejects the old frame 0
Rnext 0 1 2 3
Another View
Slast
SEND WINDOW
SEND WINDOW
SEND
SEND WINDOW
WINDOW
ACK Piggybacking in Bidirectional GBN
SArecent RA next
Transmitter Receiver
Receiver Transmitter
SBrecent RB next
RA next RB next
“A” Send Window “B” Send Window
... ...
Tprop Tf Tf Tprop
1 ms 1000 bits 1
10 ms 10,000 bits 2
Ws t f Ws t f
tGBN t f (1 Pf ) Pf {t f } tf Pf and
1 Pf 1 Pf
nf no no
1
tGBN nf
GBN (1 Pf )
R 1 (Ws 1) Pf
i 1
tf Ws t f (i 1) Pf (1 Pf )
i 1
Ws t f Pf 1 (Ws 1) Pf
tf tf .
1 Pf 1 Pf
Efficiency:
nf no no
1
E[ttotal ] nf
GBN (1 Pf ) .
R 1 (Ws 1) Pf
Example: Impact Bit Error Rate on
GBN
nf=1250 bytes = 10000 bits, na=no=25 bytes = 200 bits
Compare S&W with GBN efficiency for random bit errors with
p = 0, 10-6, 10-5, 10-4 and R = 1 Mbps & 100 ms
1 Mbps x 100 ms = 100000 bits = 10 frames → Use Ws = 11
Efficiency 0 10-6 10-5 10-4
fr fr fr fr fr fr fr fr fr fr fr fr fr fr Time
0 1 2 3 4 5 6 2 7 8 9 10 11 12
A
B
A A N A A A A A A A A A
C C A C C C C C C C C C
K K K K K K K K K K K K
1 2 2 2 2 2 7 8 9 1 1 1
0 1 2
Selective Repeat ARQ
Transmitter Receiver
Frames Frames
transmitted S received Rnext Rnext + Wr-1
last Srecent Slast+ Ws-1
and ACKed
Buffers Buffers
Timer Slast Rnext+ 1
Timer Slast+ 1 Rnext+ 2
...
Timer
Srecent ...
Rnext+ Wr- 1 max Seq #
... accepted
Slast+ Ws - 1
Send & Receive Windows
Transmitter Receiver
0 0
2m-1 1 2m-1 1
2 2
Rnext
Slast
send receive j
window i window
i
i + Ws – 1 i+1
j + Wr – 1
Moves k forward when ACK Moves forward by 1 or more
arrives with Rnext = Slast + k when frame arrives with
k = 1, …, Ws-1 Seq. # = Rnext
What size Ws and Wr allowed?
l Example: M=22=4, Ws=3, Wr=3
Frame 0 resent
Send
{0,1,2} {1,2} {2} {.}
Window
fr0 fr1 fr2 fr0
A Time
B ACK1 ACK2
Receive
{0,1} {1,2} {2,3}
Window
Old frame 0 rejected because it
falls outside the receive window
Why Ws + Wr = 2m works
l Transmitter sends frames 0 to l Receiver window starts at {0, …, Wr-1}
Ws-1; send window empty
l Window slides forward to
l All arrive at receiver {Ws,…,Ws+Wr-1}
l All ACKs lost
l Receiver rejects frame 0 because it
l Transmitter resends frame 0 is outside receive window
0 0
2m-1 1 2m-1 1
Slast Ws +Wr-1 2
2
receive Rnext Ws
send window
window Ws-1
Applications of Selective Repeat
ARQ
l TCP (Transmission Control Protocol):
transport layer protocol uses variation of
selective repeat to provide reliable stream
service
l Service Specific Connection Oriented
Protocol: error control for signaling
messages in ATM networks
Efficiency of Selective Repeat
l Assume Pf frame loss probability, then number of
transmissions required to deliver a frame is:
l tf / (1-Pf)
nf no
t f /(1 Pf ) no
SR (1 )(1 Pf )
R nf
Example: Impact Bit Error Rate on
Selective Repeat
nf=1250 bytes = 10000 bits, na=no=25 bytes = 200 bits
Compare S&W, GBN & SR efficiency for random bit errors with
p=0, 10-6, 10-5, 10-4 and R= 1 Mbps & 100 ms
Control frame
on off on off
B Time
2Tprop
B
Time
l Sliding Window ARQ method with Ws equal to buffer available
l Transmitter can never send more than Ws frames
l ACKs that slide window forward can be viewed as permits to transmit
more
l Can also pace ACKs as shown above
l Return permits (ACKs) at end of cycle regulates transmission rate
Chapter 5
Peer-to-Peer Protocols
and Data Link Layer
PART II: Data Link Controls
Framing
Point-to-Point Protocol
High-Level Data Link Control
Data Link Protocols
Packets Packets Data Links Services
l Framing
Data link Data link l Error control
layer layer
A Frames l Flow control
Physical Physical B
l Multiplexing
layer layer
l Link Maintenance
l Security: Authentication &
Encryption
Examples
l Directly connected, wire-like
l PPP
l Losses & errors, but no out-of-
l HDLC
sequence frames
l Ethernet LAN
l Applications: Direct Links;
LANs; Connections across l IEEE 802.11 (Wi Fi) LAN
WANs
Framing
transmitted received l Mapping stream of
frames frames physical layer bits into
frames
l Mapping frames into
Framing bit stream
l Frame boundaries can
be determined using:
l Character Counts
0111110101
0110110111
l Control Characters
l Flags
l CRC Checks
Character-Oriented Framing
Data to be sent
A DLE B ETX DLE STX E
After stuffing and framing
DLE STX A DLE DLE B ETX DLE DLE STX E DLE ETX
0110111111111100
After stuffing and framing
0111111001101111101111100001111110
01111110000111011111011111011001111110
After destuffing and deframing
*000111011111-11111-110*
Chapter 5
Peer-to-Peer Protocols
and Data Link Layer
PART II: Data Link Controls
Framing
Point-to-Point Protocol
High-Level Data Link Control
PPP: Point-to-Point Protocol
l Data link protocol for point-to-point lines in Internet
l Router-router; dial-up to router
1. Provides Framing and Error Detection
l Character-oriented HDLC-like frame structure
2. Link Control Protocol
l Bringing up, testing, bringing down lines; negotiating
options
l Authentication: key capability in ISP access
3. A family of Network Control Protocols specific to
different network layer protocols
l IP, OSI network layer, IPX (Novell), Appletalk
PPP Applications
PPP used in many point-to-point applications
l Telephone Modem Links 30 kbps
l Packet over SONET 600 Mbps to 10 Gbps
l IP→PPP→SONET
integer # of bytes
All stations are to Unnumbered Specifies what kind of packet is contained in the
accept the frame frame payload, e.g., LCP, NCP, IP, OSI CLNP, IPX
Data to be sent
41 7D 42 7E 50 70 46
7E 41 7D 5D 42 7D 5E 50 70 46 7E
After stuffing and framing
PPP Phases
Home PC to Internet Service
1. Carrier Provider
Dead detected
7. Carrier 1. PC calls router via modem
dropped 2. PC and router exchange LCP
packets to negotiate PPP
Failed parameters
Terminate Establish
3. Check on identities
2. Options 4. NCP packets exchanged to
negotiated configure the network layer, e.g.
6. Done TCP/IP ( requires IP address
Failed assignment)
5. Open Authenticate 5. Data transport, e.g. send/receive
IP packets
6. NCP used to tear down the
3. Authentication network layer connection (free up
4. NCP IP address); LCP used to shut
completed down data link layer connection
configuration Network
7. Modem hangs up
PPP Authentication
l Password Authentication Protocol
l Initiator must send ID & password
l Authenticator replies with authentication success/fail
l After several attempts, LCP closes link
l Transmitted unencrypted, susceptible to eavesdropping
l Challenge-Handshake Authentication Protocol
(CHAP)
l Initiator & authenticator share a secret key
l Authenticator sends a challenge (random # & ID)
l Initiator computes cryptographic checksum of random # &
ID using the shared secret key
l Authenticator also calculates cryptocgraphic checksum &
compares to response
l Authenticator can reissue challenge during session
Chapter 5
Peer-to-Peer Protocols
and Data Link Layer
PART II: Data Link Controls
Framing
Point-to-Point Protocol
High-Level Data Link Control
High-Level Data Link Control
(HDLC)
l Bit-oriented data link control
l Derived from IBM Synchronous Data Link
Control (SDLC)
l Related to Link Access Procedure Balanced
(LAPB)
l LAPD in ISDN
l LAPM in cellular telephone signaling
HDLC Data Transfer Modes
l Normal Response Mode
l Used in polling multidrop lines
Commands
Primary
Responses
Supervisory Frame
1 0 S S P/F N(R)
Unnumbered Frame
1 1 M M P/F M M M
SABM Data UA
UA
transfer DISC
Example: HDLC using NRM
(polling)Address of secondary
Primary A Secondaries B, C
A polls B B, RR, 0, P N(S) N(R)
B, I, 0, 0
N(R) B sends 3 info
X B, I, 1, 0
frames
B, I, 2, 0,F
A rejects fr1 B, SREJ, 1
A polls C C, RR, 0, P
C, RR, 0, F C nothing to
send
A polls B, B, SREJ, 1,P
requests
selective B, I, 1, 0 B resends fr1
retrans. fr1 B, I, 3, 0 Then fr 3 & 4
B, I, 4, 0, F
A send info fr0 B, I, 0, 5
to B, ACKs up to 4
Time
Frame Exchange using
Asynchronous Balanced Mode
Combined Station A Combined Station B
B, I, 0, 0 A, I, 0, 0
B, I, 1, 0 A, I, 1, 1 B ACKs fr0
X
A sends 5
frames B, I, 2, 1 A, I, 2, 1
B, I, 3, 2 B rejects
B, REJ, 1 fr1
B, I, 4, 3
A, I, 3, 1
A goes B, I, 1, 3
back to 1
B, I, 2, 4 B, RR, 2 B ACKs fr1
B, I, 3, 4
B, RR, 3 B ACKs fr2
Flow Control
l Flow control is required to prevent transmitter from
overrunning receiver buffers
l Receiver can control flow by delaying
acknowledgement messages
l Receiver can also use supervisory frames to
explicitly control transmitter
l Receive Not Ready (RNR) & Receive Ready (RR)
I3 I4 I5 RNR5 RR6 I6