3 Datalink

Download as pdf or txt
Download as pdf or txt
You are on page 1of 148

3 The Data Link Layer

1
Highlights
 Framing
 Error-Control
 Error-correction
 Error-detection
 ARQ (Automatic Repeat reQuest)
 Flow control
 Stop-Wait
 Slide Window
 Performance
 ADSL、HDLC、SLIP和PPP
2
3.1 Data Link Layer
Design Issues

3
Data Link Layer Design Issues
 Goals
 Study the algorithms for achieving reliable,
efficient communication between two adjacent
machines
 Adjacent: two machines are connected by a
communication channel that acts conceptually
like a wire, bits are delivered in exactly the
same order in which they are sent.
 Data Link Layer Design Issues
 Services Provided to the Network Layer
 Framing
 Error Control
 Flow Control

4
Services Provided to the
Network Layer

5
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

6
Functions of the Data Link Layer (2)
Relationship between packets and frames.

7
Services Provided to Network Layer
(a) Virtual communication.
(b) Actual communication.

8
Services Provided to Network Layer(2)
 Unacknowledged connectionless service.
Most LANs use unacknowledged connectionless service
 Acknowledged connectionless service.
This service is useful over unreliable channels, such
as wireless systems
 Acknowledged connection-oriented service
10 frames, of which 2 are lost on average. It would then take a
very long time for the packet to get through.
 Connection establishment
 Timer
 Sequence number
9
Framing

10
Framing

 A sequence of bits is sent from node A to


node B over a point-to-point link. Node B must
recognize exactly what set of bits constitutes a
frame, that is, it must determine where the
frame begins and ends.

11
Character Count
 Character count(字符计数):
Uses a field in the header to specify the number of
characters in the frame (DEC:DDCMP)

A character stream.
(a) Without errors. (b) With one error.
12
Byte Stuffing
 Flag bytes with byte stuffing (字符添充):Having each
frame start and end with special bytes (IBM:BISYNC)

(a) A frame delimited by flag bytes.


(b) Four examples of byte sequences before and after stuffing.
13
Bit Stuffing
 Starting and ending flags, with bit stuffing (⽐特添
充):Each frame begins and ends with a special bit
pattern, 01111110 . Whenever the sender's data link
layer encounters five consecutive 1s in the data, it
automatically stuffs a 0 bit into the outgoing bit
stream (Example: HDLC)

(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.
14
Example with Possible Errors (Bit Stuffing)

15
⽐特填充
 从信道上收到⽐特序列: 1101 0111 1110
0111 1110 1101 1011 1110 0010 1100
0101 1111 0101 1001 1111 1001,该⽐特序
列中包含⼀个完整的帧,⽤⼗六进制写出该帧的内
容(不包含帧的⾸尾标志)。
 HDLC使⽤⽐特填充法成帧,帧定界符为
01111110,在帧的内容中若出现连续的5个1,则
⽴即插⼊1个0,应该去掉加⼊的0,完整的帧内容:

16
Physical Layer Coding Violations
 Physical layer coding violations:物理层编码违例法
(IEEE:802.3)

17
Error Control & Flow Control

18
Error Control
 Make sure all frames are eventually
delivered to the network layer at the
destination and in the proper order
 Provide the sender with some feedback about
what is happening at the other end of the line
 Hardware troubles may cause a frame to vanish
completely
 If either the frame or the ACK is lost, the
timer will go off, alerting the sender to a
potential problem
 Managing the timers and sequence numbers
so as to ensure that each frame is ultimately
passed to the network layer at the destination
exactly once, no more and no less
19
Flow Control
 What to do with a sender that wants to
transmit frames faster than the receiver can
accept them
 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
 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.

20
Flow Control

21
3.2 Error Detection and
Correction

22
Error Control
 Classification of Errors
 Lost frames: a frame failed to arrive to the other
side
 Owing to noise burst or dropped from a queue
 Damaged frames: some bits are in error
 Error detection
 Parity check: able to detect single bit errors
 Cyclic Redundancy Check (CRC): detecting some
burst errors
 Automatic Repeat reQuest (ARQ)
 Error correction
 Forward Error Correction (FEC)
23
Single-bit Error & Burst Error
 Single-bit error, only one bit has changed

 A burst error means that 2 or more bits


have changed.

24
Error Correcting Code

25
Hamming Distance
 Hamming distance: The number of bit
positions in which two codewords differ
 (10001001 and 10110001, Hamming distance = 3)
 To detect d errors, need a distance d+1 code
 To correct d errors, need a distance 2d+1 code

26
Example of an Error-Correcting Code
 Consider a code with only four valid codewords:
0000000000, 0000011111
1111100000, 1111111111
 This code has a distance 5, which means that it can
correct 2 errors.
 If the codeword 0000000111 arrives, the
receiver knows that the original must have been
0000011111
 If a triple error changes 0000000000 into
0000000111, the error will not be corrected
properly

27
Hamming code
 The number of check bits needed to correct
single errors:
 m+r+1≤ 2r m: message bits, r:check bits
 m message bits and r check bits, 2m legal
messages, n = m + r
 Each legal message has n illegal codewords at
a distance 1 from it
(n + 1)2m ≤ 2n
(m + r + 1) ≤ 2r.
Example: m=7,r≥4

28
Hamming code
 The bits of the codeword are numbered, start with 1
at left end, bit 2 to its immediate right, and so on.
 The bits that are powers of 2 (1, 2, 4, 8, 16, etc.)
are check bits. Each check bit forces the parity of
some collection of bits, including itself, to be even
(or odd).
 The rest (3, 5, 6, 7, 9, etc.) are filled up with the m
data bits
even parity ‘H’ 100,1000

3=1+2, 5=1+4, 6=2+4, 7=1+2+4 , 9=1+8,


10=2+8, 11=1+2+8 so bit1 (3,5,7,9,11) 29
Error Crrection

30
Hamming code: Correct burst errors

Use of a Hamming code to correct burst errors.


31
Other error-correcting codes
 Binary convolutional codes.
 Reed-Solomon codes.
 Low-Density Parity Check codes.

32
Error Detecting Code

33
Detection code

1、Parity
2、Checksums
3、Cyclic Redundancy Checks (CRCs)

34
Error Correcting & Detecting
 On channels that are reliable, such as fiber, it is
cheaper to use an error detecting code and just
retransmit the occasional block found to be faulty
 On channels such as wireless links that make many
errors, it is better to add enough redundancy to
each block for the receiver to be able to figure out
what the original block was
 Example (single-bit error)
 Bit Error Rate BER=10-6, 1Block=1000bits,
Data=1M bits
 The overhead
 Error detection + retransmission: 2001 bits
 Hamming code : 10,000 bits
(m + r + 1) ≤ 2r 35
Error Detecting Codes

36
Odd & Even Parity
 Odd & Even parity

37
Odd & Even Parity
 Coding n
 Each block to be sent is regarded as a 10010001
matrix 01010011
10100001
 A parity bit is computed separately for 01010110
each column and affixed to the matrix as 11001100
the last row 11101101
10001000
 The matrix is then transmitted one row 10011110
at a time.
 Performance
 Can detect a single burst of length n
 A burst of length n + 1 will pass
undetected if the first bit is inverted, the
last bit is inverted, and all the other bits
are correct
38
Checksums
Word Cksum(Word *Buf, Word Num_Words)
{
Dword Sum;
for ( Sum=0; Num_Words>0; Num_Words--)
Sum+=*Buf++;
Sum = ( Sum >> 16 ) + ( Sum & 0xffff );
Sum += Sum >> 16;
return ~Sum;
}

39
Polynomial Code
Also known as CRC (Cyclic Redundancy Check)
 Treating bit strings as representations of
polynomials with coefficients of 0 and 1
 A k-bit frame is regarded as the coefficient list for
a polynomial with k terms, ranging from xk-1 to x0:
110001=> x5 + x4 + x0
 Polynomial arithmetic is done modulo 2,
addition and subtraction are identical to XOR
 The algorithm for computing the checksum:
 The degree of generator polynomial G(x), is r
 Append r zero bits to the low-order end of the frame(xr
M(x) )
 Divide the bit string corresponding to G(x), using modulo 2
division
 Subtract the remainder from the bit string using modulo 2
subtraction (T(x)) 40
Calculation of the
polynomial code
checksum.

41
CRC code

42
The Power of CRC (1)
 Imagine that a transmission error occurs,
so that instead of the bit string for T(x)
arriving, T(x) + E(x) arrives.
 Upon receiving the checksummed frame,
the receiver computes [T(x) + E(x)]/G(x).
T(x)/G(x) is 0, so the result is E(x)/G(x).
Those errors that happen to correspond to
polynomials containing G(x) as a factor will
slip by; all other errors will be caught.

43
The Power of CRC (2)
 A polynomial code with r check bits will
detect all burst errors of length ≤ r
 By making x+1 a factor of G(x), we can catch
all errors consisting of an odd number of
inverted bits
 Burst length is r + 1 ,an incorrect frame
being accepted as valid is ½r – 1.
 The probability of a bad frame(Burst length
is longer than r + 1 ) getting through
unnoticed is ½r, assuming that all bit
patterns are equally likely

44
Generator Polynomial
 Certain polynomials have become
international standards
 CRC-16
 x16+x15+x2+1
 CRC-CCITT (HDLC)
 x16+x12+x5+1
 CRC-32 (IEEE802)
 x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x1+1

45
The Calculation of CRC
 Hardware
 A simple shift register circuit can be constructed
to compute and verify the checksums
 Software
static u16 fcstab[256] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536,
0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5,
……
0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7,
0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
};

u16 fcs16(u16 fcs, unsigned char *cp, int len)


{
while (len--)
fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
return (fcs);
}
46
3.3 Elementary Data Link
Protocols

47
Elementary Data Link Protocols

 An Unrestricted Simplex Protocol


 A Simplex Stop-and-Wait Protocol
 A Simplex Protocol for a Noisy Channel

48
Protocol Definitions

49
Elementary Data Link Protocols
 Some of the assumptions
 Physical layer, data link layer, and network
layer are independent processes
 Machine A wants to send a long stream of data to
machine B, using a reliable, connection-
oriented service
 Machines do not crash
 There exist suitable library procedures
to_physical_layer to send a frame and
from_physical_layer to receive a frame

50
Protocol Definitions

Some definitions needed in the protocols to follow.


These are located in the file protocol.h.

51
52
Protocol 1: Utopia

53
54
Protocol 2:
Stop-and-Wait Protocol for a
Error-free Channel

55
56
Protocol 3:
A Simplex Protocol for a
Noisy Channel

57
Stop-And-Wait
A B A B A B A B

DATA DATA Err DATA Lost DATA



tout tout Lost CK
ACK NAK A

DATA DATA DATA DATA

Time ACK ACK ACK ACK

(a) Normal (b) Data Error (c) Data Lost (d) ACK Lost

58
Problems
 Case 1: Protocol failed on receiver
 The network layer on A gives packet 1 to its data
link layer. The packet is correctly received at B and
passed to the network layer on B. B sends an ACK
frame back to A.
 The ACK gets lost completely
 The data link layer on A eventually times out. Not
having received an acknowledgement, it sends the
frame containing packet 1 again
 The duplicate frame also arrives B and is passed to
the network layer
 Case 2: Protocol failed on Sender
 A delayed ACK
59
Sequence Number
 Distinguish a frame that it is seeing for the
first time from a retransmission
 Put a sequence number in the header of each
frame
 What is the minimum number of bits needed
for the sequence number?
 链路层:1⽐特,编号空间⼤⼩为2
 传输层:1⽐特编号空间太⼩,需要较⼤的编号空间使得在
编号回卷时,保证同编号的旧帧不可能被缓冲在⽹络中,如:
TFTP

60
从⽹络层获取⼀个分组放⼊buffer
发送buffer中的数据,新启动定时器
label1:
wait_for_event()
switch (event) {
case 收到了坏帧(校验和错):
重发缓冲在buffer⾥的数据,重新启动定时器
case 定时器超时:
重发缓冲在buffer⾥的数据,新启动定时器
case 收到校验和正确的帧:
if(ack序号正确) {
关闭旧定时器
从⽹络层获取下⼀个分组放⼊buffer
发送buffer中的数据,新启动定时器
} else
重发缓冲在buffer⾥的数据,重新启动定时器
}
goto label1

Sender 61
从⽹络层获取⼀个分组放⼊buffer
发送buffer中的数据,新启动定时器
label1:
wait_for_event()
switch (event) {
case 收到了坏帧(校验和错):
重发缓冲在buffer⾥的数据,重新启动定时器
case 定时器超时:
重发缓冲在buffer⾥的数据,新启动定时器
case 收到校验和正确的帧:
if(ack序号正确) {
关闭旧定时器
从⽹络层获取下⼀个分组放⼊buffer
发送buffer中的数据,新启动定时器
} else
重发缓冲在buffer⾥的数据,重新启动定时器
}
goto label1

Sender 62
从⽹络层获取⼀个分组放⼊buffer
发送buffer中的数据,启动定时器
while(true) {
wait_for_event()
if (收到校验和正确的帧) {
if(ack序号正确) {
关闭旧定时器
从⽹络层获取下⼀个分组放⼊buffer
}
}
发送buffer中的数据,启动定时器
}

Sender 63
从⽹络层获取⼀个分组放⼊buffer
while(true) {
发送buffer中的数据,启动定时器
wait_for_event()
if (收到校验和正确的帧) {
if(ack序号正确) {
关闭旧定时器
从⽹络层获取下⼀个分组放⼊buffer
}
}
}

Sender 64
从⽹络层获取⼀个分组放⼊buffer
next_frame_to_send = 0;

while(true) {
发送buffer中的数据,启动定时器
帧序号填写为next_frame_to_send
wait_for_event()
if (收到校验和正确的帧) {
if(ack序号正确) {
关闭旧定时器
从⽹络层获取下⼀个分组放⼊buffer
inc(next_frame_to_send)
}
}
}
(next_frame_to_send 记录⽬前缓冲在buffer中的数据的编号。
buffer中装⼊下⼀个数据, next_frame_to_send 加1)

Sender 65
Sender 66
frame_expected=0
while(true) {
wait_for_event()
switch(event) {
case 坏帧:
do_nothing
case 收到校验和正确的数据帧:
if(序号==frame_expected) {
向⽹络层上交分组
回ACK(序号为frame_expected)
inc(frame_expected)
} else {
回ACK(序号为frame_expected-1)
}
}
}

Receiver 67
frame_expected=0
while(true) {
wait_for_event()
if (event==收到校验和正确的数据帧) {
if(序号==frame_expected) {
向⽹络层上交分组
inc(frame_expected)
回ACK(序号为frame_expected-1)
} else {
回ACK(序号为frame_expected-1)
}
}
}

Receiver 68
frame_expected=0
while(true) {
wait_for_event()
if (event==收到校验和正确的数据帧) {
if(序号==frame_expected) {
向⽹络层上交分组
inc(frame_expected)
}
回ACK(序号为frame_expected-1)
}
}

Receiver 69
A positive acknowledgement with retransmission protocol.

Receiver 70
Timer
 Timeout
 If the timeout interval is set too short, the
sender will transmit unnecessary frames. While
these extra frames will not affect the correctness
of the protocol, they will hurt performance

71
3.4 Sliding Window
Protocols

72
Piggybacking
 For full-duplex data transmission:
 Use two separate communication channels and use
each one for simplex data traffic
 Use the same circuit for data in both directions
 Piggybacking
 When a data frame arrives, instead of immediately
sending a separate control frame, the receiver
restrains itself and waits until the network layer
passes it the next packet
 ACK is attached to the outgoing data frame (using
the ack field in the frame header).

73
Sending window & Receiving window
 Sending window
 At any instant of time, the sender maintains a
set of sequence numbers corresponding to
frames it is permitted to send. These frames are
said to fall within the sending window
 Receiving window
 Receiver also maintains a receiving window
corresponding to the set of frames it is permitted
to accept

74
Sliding Window Protocols
 A One-Bit Sliding Window Protocol
 A Protocol Using Go Back N
 A Protocol Using Selective Repeat

75
One-Bit Sliding Window
Protocol

76
Sliding Window of Size 1

A sliding window of size 1, with a 3-bit sequence


number.
(a) Initially.
(b) After the first frame has been sent.
(c) After the first frame has been received.
(d) After the first acknowledgement has been received.
77
One-Bit Sliding Window Protocol (1)

78
One-Bit Sliding Window Protocol (2)

79
Two Scenarios for Protocol 4

Two scenarios for protocol 4.


The notation is (seq, ack, packet)
An asterisk indicates where a network layer accepts a packet
(a) Normal case. (b) Abnormal case.
80
Problem
 Consider a 50-kbps satellite channel with a
500-msec round-trip propagation delay,
send 1000-bit frames(1000/50k=20ms)
 t=0: sender starts sending
 t=20 msec: the frame has been completely sent
 t=270 msec: frame fully arrived at the receiver
 t=520 msec: ACK arrived back at the sender,
under the best of circumstances (no waiting in
the receiver and a short acknowledgement
frame).
 Conclusion
 Sender was blocked during 500/520 or 96% of
the time. only 4% of the available bandwidth
was used
81
Line Utilization
 Channel capacity is B bits/sec
 Frame size l bits
 propagation time R sec
 Line Utilization
 (l/B)/(l/B+2R)=l/(l+2BR)=1/(1+2BR/l)
 If l < 2BR, the efficiency will be less than 50
percent
 1/(1+2*50*250/1000)=1/26=4%

82
Protocol Using Go Back N

83
Pipelining & Error Recovery

Pipelining and error recovery. Effect on an error when


(a) Receiver’s window size is 1.
(b) Receiver’s window size is large.
84
Go Back N(GBN)
Based on sliding window
 Use window to control number of
outstanding frames
 If Receiver detects error, discard that frame
and all future frames until error frame
received correctly
 Transmitter must go back and retransmit
that frame and all subsequent frames

85
Damaged Frame
 If Data Frame is Damaged
 Receiver detects error in frame i
 Receiver discard that frame i and all subsequent
 When timeout transmitter retransmits frame i
and all subsequent
 If ACK Frame is Damaged
 Receiver gets frame i and send
acknowledgement ACK (i) which is lost
 Ack are cumulative, so next ACK(i+n) may
arrive before transmitter times out on frame i
 If transmitter times out, retransmits frame i and
all subsequent

86
About ACK
A B A
0 0 B

ACK0
1 1

ACK1
2 2

ACK2 ACK2

87
Maximum of Sending Window Size
 The sender sends frames 0 through 7.
 A piggybacked acknowledgement for frame 7
eventually comes back to the sender.
 The sender sends another eight frames, again
with sequence numbers 0 through 7.
 Now another piggybacked acknowledgement
for frame 7 comes in
 原则
 当发送⽅发送完发送窗⼝内所有帧,在未收到ACK之前,接
收⽅正确接收到所有发送来的帧,接收窗⼝向前推移,此时,
必须
必须保证发送窗⼝与接收窗⼝在序号上不能重叠

88
Go-Back-N Protocol
发送窗⼝最⼤值7

89
90
91
92
93
Protocol5改进和效率
 设置ACK定时器
 发送数据并⾮⼀个源源不断的分组流,⽆法及时搭载ACK
时,发送ACK帧
 ⽤于回送ACK的定时器start_ack_timer与
stop_ack_timer
 与数据重传所⽤定时器start_timer与stop_timer的区别
 ACK定时器时限的设计
 协议参数与线路利⽤率
 超时定时器时限的设计(考虑线路往返时间延迟,ACK定
时器时限等)
 滑动窗⼝即MAX_SEQ的⼤⼩

94
Timer Queue in Software
Simulation of multiple timers in software.

95
Using Selective Repeat

96
Selective Repeat
 Also called Selective Reject(SR)
 Only Rejected frames are retransmitted
 Subsequent frames are accepted by the
receiver and buffered
 Minimizes retransmission
 Receiver must maintain large enough
buffer
 More complex

97
Window Size of Selective Repeat

(a) Initial situation with a window size seven.


(b) After seven frames sent and received, but not
acknowledged.
(c) Initial situation with a window size of four.
(d) After four frames sent and received, but not
acknowledged.

98
Sequence Number, Buffers
 The maximum window size should be at
most half the range of the sequence
numbers
 How many buffers must the receiver have?
 The number of buffers needed is equal to the
window size, not to the range of sequence
numbers

99
Send Window & Receive Windows

Ws+Wr <=2n
Ws>=Wr
Ws,Wr<= 2n -1

100
ACK Timer
 ACK timer
 After an in-sequence data frame arrives, an
auxiliary timer is started by start_ack_timer. If
no reverse traffic has presented before this
timer expires, a separate ACK frame is sent
 The timeout associated with the auxiliary
timer be appreciably shorter than the timer
used for timing out data frames

101
NAK
 Whenever the receiver has reason to suspect
that an error has occurred, it sends NAK frame
back to the sender
 NAK frame is a request for retransmission
 There are two cases when the receiver should
be suspicious
 A damaged frame has arrived
 A frame other than the expected one arrived
 To avoid making multiple requests for
retransmission of the same frame, the receiver
should keep track of whether a NAK has already
been sent for a given frame

102
Continued  103
Continued  104
Continued  105
106
3.5 Performance of
Sliding Window Protocols

107
Performance(1)
Stop-and-wait without
error(transmission time=1,propagation=a)

a=tp/tf
108
Performance(2)

Slide window without error


109
Performance(3)
 Stop-and-wait without error

110
Performance(4)
 Stop-and-wait without error

111
Performance(5)
 Stop-and-wait with error

112
Performance(6)
 Slide window without error

113
Performance(7)
 Piggybacking: U=N/(2+2a)

114
Example
 数据链路层采⽤GBN协议,发送⽅已经发送了编号
为0-7的帧,当计时器超时时,若发送⽅只收到0,2,3
号帧的确认,则发送⽅需要重发的帧数是?
 数据链路层采⽤SR协议,发送⽅已经发送了编号为
0-7的帧,当计时器超时时,若发送⽅只收到0,2,3号
帧的确认,则发送⽅需要重发的帧数是?

115
Example2
 Consider a 50-kbps satellite channel with a
500-msec round-trip propagation delay,
send 1000-bit frames
使⽤GBN协议,若使效率达到50%,序号的⽐特数⾄
少是多少?

0.5=N/(1+2a)
a=250/(1000/50)=12.5

116
3.6 Example Data Link
Protocols

117
Example Data Link Protocols
 HDLC – High-Level Data Link Control
 The Data Link Layer in the Internet
 SLIP (Serial Line IP)
 PPP (Point-to-Point Protocol)
 PACKET over SONET
 ADSL

118
HDLC
(High-Level Data Link Control)

119
History
 IBM SDLC ,1974
 Synchronous Data Link Control
 ANSI ADCCP
 Advanced Data Communication Control
Procedure
 ISO HDLC
 High-level Data Link Control
 CCITT(ITU-T) LAPB
 LAP (Link Access Procedure)
 LAPB (Link Access Procedure – Balanced mode)

120
HDLC Frame format
Frame format for bit-oriented protocols.

121
HDLC Frames

Control field of
(a) An information frame. (I)
(b) A supervisory frame. (RR/RNR/REJ/SREJ)
(c) An unnumbered frame.(SABM,UA,DISC,FRMR)
First one or two bits of control filed identify frame
type

122
I-frame
 If the first bit of the control field is 0, this
means the frame is an I-frame.
3-bit N(S)
1-bit P/F
3-bit N(R)

123
S-frame Control Field
 If the first 2 bits of the control field are 10,
this means the frame is an S-frame.
 Code
 RR, RNR, REJ, SREJ (3-bit N(R))

124
U-frame

125
P/F Bit
Use depends on context
 Unbalanced configuration
 Poll: Invite the terminal to send data
 Final: All the frames sent by the terminal, except the final
one, have the P/F bit set to 0. The final one is 1
 Balanced configuration
 Command (P bit): P=1 to solicit (poll) response from peer
 Response (F bit): F=1 indicates response to soliciting
command
 Force the other machine to send a Supervisory frame
immediately rather than waiting for reverse traffic onto
which to piggyback the window information

126
ACK Frame: RR & RNR
 RR: Reveiver Ready
 ACK frame used to indicate the N(R) frame
expected
 This frame is used when there is no reverse
traffic to use for piggybacking
 RNR: Reveiver Not Ready
 It acknowledges all frames up to but not
including N(R) , just as RR does, but it tells the
sender to stop sending (Flow control)

127
NAK Frame: REJ & SREJ
 REJ: Reject
 Indicate that a transmission error has been
detected
 The N(R) field indicates the first frame in
sequence not received correctly (i.e., the frame
to be retransmitted)
 The sender is required to retransmit all
outstanding frames starting at N(R)
 SREJ: Selective Reject
 Calls for retransmission of only the frame
specified by N(R)
 If a receiver wishes to buffer out-of-sequence
frames for potential future use, it can force the
retransmission of any specific frame using SREJ
128
HDLC Station Types
 Primary station
 Controls operation of link
 Frames issued are called commands
 Maintains separate logical link to each secondary
station
 Secondary station
 Under control of primary station
 Frames issued called responses
 Combined station
 May issue commands and responses

129
HDLC Link Configurations
 Unbalanced
 One primary and one or more secondary stations
 Supports full-duplex and half-duplex
 Balanced
 Two combined stations
 Supports full-duplex and half-duplex

130
HDLC Operation
 Exchange of information, supervisory and
unnumbered frames
 Information - data to be transmitted to user
(next layer up)
 Flow and error control piggybacked on
information frames
 Supervisory - ARQ when piggyback not used
 Unnumbered - supplementary link control
 Three phrases
 Initialization
 Data transfer
 Disconnect
131
Example of HDLC Operation

132
Example of HDLC Operation

133
SLIP
(Serial Line IP)

134
SLIP – Serial Line Internet Protocol
 RFC1055
 Framing: Character Stuffing
 Use 0xC0 as a flag char
 Use 0xDB 0xDC to replace 0xC0
 Use 0xDB 0xDB to replace 0xDB
 Problems
 No error control
 Only support IP
 Don’t assign IP address dynamically
 No authentication
 Different version exist

135
PPP
(Point to Point Protocol )

136
The Data Link Layer in the Internet
A home personal computer acting as an
internet host.

137
PPP Protocol Sub-layers

IP IPX Third Layer

IPCP IPXCP Others


NCP
PPP

LCP

PHYSICAL

138
Multiple protocols

TCP/IP PPP encapsulation


Novell IPX
…...

139
PPP - Point to Point Protocol
 Protocol specifications:
 RFC1661,1662,1663
Features:
 Layer 1
 Synchronous circuits (bit-oriented encodings)
 Asynchronous circuits (byte-oriented encodings)
 PPPoE (PPP over Ethernet, ADSL)
 LCP: Link Control Protocol
 Error detection (CRC)
 Permits authentication
 Allows IP addresses to be negotiated at
connection time
 Multiple protocols: NCP(IP, IPX, …)
140
PPP Frame Format
The PPP full frame format for unnumbered
mode operation.

141
PPP Phase Diagram

A simplified phase diagram for bring a line up and


down. 142
LCP Frame Types
The LCP frame types.

143
LCP Negotiates Protocol Options(1)
 Max payload size for data frames(1500)
 Authentication and choosing a protocol to use
 PAP:Password Authentication Protocol
 CHAP: Challenge Handshake Authentication
Protocol
 Line-quality monitoring during normal
operation
 Compression: Header and Data compression
scheme
 Stacker
 Predictor
 Zlib
144
LCP Negotiates Protocol Options(2)
 CRC options
 异步⽅式,字节填充法,指定转义字符集ACCM
(Async-Control-Character-Map, 32 bits,⽤
bitmap指定需转义的ASCII 码的控制字符集合)
 0x7E==>0x7D, 0x5E (0x7E为FLAG)
 0x7D==>0x7D, 0x5D
 控制字符C==> 0x7D,C xor 0x20 (C < 0x20)
 Multilink Protocol (MP)
 ISDN (2B+D)

145
CHAP Example

CHAP_REQUEST (Challenge-ID, server-name) 12618764(4-bytes Random), routerA

CHAP_RESPONSE (response, client-name) , Ty7ic#oM9@S...(16-bytes MD5), zhang

CHAP_SUCCESS/CHAP_FAILURE

146
Packet over SONET
 SONET
 the physical layer protocol that is used over the wide-
area optical fiber links that make up the backbone of
communications networks, including the telephone
system.
 provides a bitstream that runs at a well-defined rate, for
example 2.4 Gbps for an OC-48 link, some framing
mechanism is needed.

147
ADSL Protocol stacks
 AAL5(ATM Adaptation Level 5)
 Framing and CRC
 ATM
 ATM fixed-size cell (5-byte head and 48-byte payload)
 ADSL physical layer
 Reed-Solomon code for error correction
 1-byte CRC, error detection
 DMT (Discrete MultiTone), QAM modulation

148

You might also like