0% found this document useful (0 votes)
235 views102 pages

EN 5 DataLinkLayer PDF

The document summarizes key aspects of the data link layer: - It provides framing, error control, and flow control between the physical and network layers. Framing methods include byte counting, flag bytes with byte stuffing, and flag bits with bit stuffing. - Error control involves the receiver sending acknowledgements and the sender retransmitting frames if acknowledgements are not received within a timeout period. Sequence numbers are added to frames to avoid duplicate frames. - Flow control manages differences in sender and receiver speeds, using either feedback-based or rate-based approaches.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
235 views102 pages

EN 5 DataLinkLayer PDF

The document summarizes key aspects of the data link layer: - It provides framing, error control, and flow control between the physical and network layers. Framing methods include byte counting, flag bytes with byte stuffing, and flag bits with bit stuffing. - Error control involves the receiver sending acknowledgements and the sender retransmitting frames if acknowledgements are not received within a timeout period. Sequence numbers are added to frames to avoid duplicate frames. - Flow control manages differences in sender and receiver speeds, using either feedback-based or rate-based approaches.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 102

3 TẦNG QUAN TRỌNG

- TẦNG LIÊN KẾT MẠNG


- TẦNG DỮ LIỆU
- TẦNG VẬN CHUYỂN

Data Link Layer


Presented by Hung Ba Ngo – email: [email protected]

Cantho – February, 2016


Objectives
 Services provided by Data link layer
 Framing
 Error control
 Flow control

Hung Ba Ngo – [email protected] 2


Requisites
 Learners have to be able to
• present functions of Data link layer in error control
• introduce principal methods of framing such as Byte
count, Flag bytes with byte stuffing and Flag bits with
bit stuffing.
• differentiate between error detection, error control and
flow control in Data link layer
• implement error detection methods such as Parity
check, Checksum, Cyclic Redundancy Checks
• implement error control protocols such as Stop and
Wait, Sliding windows, Go-Back-N, Selective Repeat
• present basic concept of HDLC protocol

Hung Ba Ngo – [email protected] 3


Functions of Data link layer
 Providing well-defined service interfaces to the
network layer
 Dealing with transmission errors

 Regulating the flow of data so that slow receivers are


not swamped by fast senders

Tầng liên kết dữ liệu chỉ gửi khung đến tầng vật lý

Hung Ba Ngo – [email protected] 4


Functions of Data link layer (cont.)
 Providing services the Network layer
 Takes the packets it gets from the network layer and
encapsulates them into frames for transmission

Tầng mạng gửi


1 GÓI TIN

Mô tả thông tin

Nội dung chính kiểm tra lỗi

CHÚ Ý:
Khi tầng mạng gửi 1 gói tin, thì tầng liên kết dữ liệu chuyển thành từng khung

Hung Ba Ngo – [email protected] 5


Services provided to Network layer
Dịch vụ không nối kết và không báo nhận: cứ gửi, có nhận được hay không thì không quan tâm
 Unacknowledged connectionless service used in LANs
Có tín hiệu hồi báo đã nhận được hay chưa
 Acknowledged connectionless service used in wireless
LANs
Có nối kết và có báo nhận: giống như gọi đt
 Acknowledged connection-oriented service used in
WANs.

Hung Ba Ngo – [email protected] 6


Services provided to Network layer

QUY TRÌNH TRUYỀN

tầng mạng

v
tầng liên kết dl

v ^
tầng vậy lý

Virtual Actual
communication communication
Hung Ba Ngo – [email protected] 7
Framing
Tầng lkdl phải sử dụng dịch vụ từ tầng vật lý

 Data link layer must use the service provided to it by Physical


layer to provide services to the Network layer
 Bit stream received by the data link layer is not guaranteed to
be error free:
– bits may have different values and the number of bits
received may be less than, equal to, or more than the
number of bits transmitted
 Data link layer to break up the bit stream into discrete frames,
compute a short token called a checksum for each frame, and
include the checksum in the frame when it is transmitted tầng lkdl đưa ra cơ
chế để kiểm tra lỗi,
 When a frame arrives at the destination, the checksum is và xử lý lỗi
recomputed bên nhận có thể kiểm tra xem có lỗi hay không

 If the newly computed checksum is different from the one


contained in the frame, the data link layer knows that an error
has occurred and takes steps to deal with it
Hung Ba Ngo – [email protected] 8
Framing methods
PHƯƠNG PHÁP ĐÓNG GÓI


Byte count Đếm byte


Flag bytes with byte stuffing dùng cờ


Flag bits with bit stuffing.

Hung Ba Ngo – [email protected] 9


Byte Count

Có mấy kí tự thì ô đầu tiên là số kí tự, tiếp theo sau là dữ liệu, 1 ô là 1 byte
A byte stream without errors

độ dài khung là 1 nên k có dữ liệu, nên khung này bị lỗi


A byte stream with errors

Hung Ba Ngo – [email protected] 10


Flag byte with byte stuffing

tên dữ liệu cần truyền kiểm tra

TẤT CẢ ĐỀU LÀ QUY ƯỚC A frame delimited by flag bytes


Mỗi lần phất cờ là kết thúc và truyền khung mới

Nếu DL trùng với cờ thì


thêm 1 ESC phía trước

Four examples of byte se-


quences before and after byte stuffing
Hung Ba Ngo – [email protected] 11
Starting and ending flags with bit stuffing

 Using flag pattern 01111110 to delimit the start and


the end of a frame
Cờ: 01111110 dùng dể bđ và kt khung

Quy ước: 5 số 1 thì chèn thêm 1 số 0

Dữ liệu gốc
(a) Original data
Chèn thêm số 0 nếu gặp 5 số 1, để đừng trùng với cờ (b) Data as they
appear on
the line
Bên nhận gặp 5 số 1 và 1 số 0 thì bỏ số 0 để nhận lại chuỗi gốc

(c) Data as they are stored in the


receiver’s memory after destuffing
Bit 0: gọi là bit đệm
Hung Ba Ngo – [email protected] 12
Bài tập 2.1 LÀM BÀI TẬP GỬI MAIL CHO THẦY

Hãy cài đặt bằng ngôn ngữ C/C++/Java các phương


pháp định khung sau: Sử dụng các bytes làm cờ hiệu
và Sử dụng cờ bắt đầu và kết thúc khung với các
ràng buộc sau:
- Nhận đầu vào là 1 file, kích thước của khung, bytes
là cờ hiệu, bytes là ký tự ESC (hoặc bytes chứa
mẫu bits)
- int framing(char* filename, int len, byte flag, byte
esc) để chèn esc
- int framing(char* filename, int len, byte flag) để chèn bit 0
- In ra màn hình các khung được tạo ra để chuyển tải
dữ liệu cho file này
Hung Ba Ngo – [email protected] 13
QUAN TRỌNG
Error Control
 How to make sure all frames are eventually delivered to
the network layer at the destination and in the proper
order ?
– Receiver sending back special control frames bearing
positive or negative acknowledgements about the
incoming frames:
• Using acknowledgement frame
– Avoiding the sender to be hung forever when
acknowledge frame lost
GP2: Nếu k thấy bên

• Using a timer and time-out for each sent frame


nhận gửi hồi báo thì
cho rằng mất khung
dữ liệu và gửi lại

– Avoiding multiple times of receiving a frame Gán số vào khung,


lúc đó bên nhận hồi
báo số khung đã

• Assign each sent frame a sequence number nhận là được

Hung Ba Ngo – [email protected] 14


Flow Control ĐK luồng

Dựa vào hồi báo và dựa vào tốc độ


 Resolving problems occurring when send rate and
receive rate are different
Bên nhận gửi hồi báo ngược lại cho bên nhận thông tin gì đó,
 Two approaches tiếp theo bên gửi mới gửi tiếp

– 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 what the
receiver is doing Hai bên thống nhất giói hạn tốc độ của bên gửi và bên nhận mà k
cần phải hồi báo

– 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

Hung Ba Ngo – [email protected] 15


Error Detection
Error detection and correction
 What is error-detecting codes
 Popular error-detecting codes
– Parity checks
– Check sum
– Cyclic redundancy check

Hung Ba Ngo – [email protected] 17


Transmission errors
 Bit 1 becomes bit 0 and reversely
 Error rate

 = Error bits / Transmitted bits


 : 10 to 10
-5 -8

• 88% : error of one bit


• 10% : error of two adjacent bits rất thấp, lỗi ít

Hung Ba Ngo – [email protected] 18


Error-detecting codes
 Sender: add control data into useful data for sending
 Receiver: decode control data to determine if the useful
data are correct or not

Useful data Useful data Useful data

Sender Encoder Decoder Receiver


+

Cotrol data
Phải kiểm
tra lỗi

Hung Ba Ngo – [email protected] 19


Error-detecting codes
 Error-correcting codes Tự sửa lỗi

• Allow receivers to identify error data and correct error


data
 Error-detecting codes Chỉ phát hiện lỗi và yêu cầu bên gửi gửi lại dữ liệu

• Allow receivers to determine if received data are


correct or not
• If error is detected in received data, request for
resending data
 Computer networks use error-detecting codes rather
than error-correcting codes

Hung Ba Ngo – [email protected] 20


Parity Check
Kiểm tra lỗi


xxxxxxx: Useful data need to be transmitted

One parity bit is appended to useful data

Real transmitted stream of bits: xxxxxxxp

Calculation of p
Nếu tổng số bit 1 là số chẵn thì k có lỗi xảy ra và ngược lại

Event parity: xxxxxxxp consists of an event number of bits 1

Odd parity: xxxxxxxp consists of an odd number of bits 1

Detecting error in a stream of bits xxxxxxxp:

In event parity check:

If there is an even number of bits 1→ data xxxxxxx are error-free

Else data xxxxxxx are error

In odd parity check:

If there is an odd number of bits 1→ data xxxxxxx are error-free

Else data xxxxxxx are error

Hung Ba Ngo – [email protected] 21


Parity Check
 Example: G = 1110001 are useful data
 Using even parity check:

• p=0
Nếu kiểm tra chẵn thì tổng số 1 là chẵn, kiểm
tra chẵn thì thêm sô 0.

• Transmitted data: 11100010


 Different cases of received data:
• 11100010: 4 bits 1=> Error-free data
• 11000010: 3 bits 1=> Error data
• 11000110: 4 bits 1=> Error ???

Hung Ba Ngo – [email protected] 22


Longitudinal Redundancy Check or Checksum

Parity bits

1011011 1

1101011 1 lẻ thêm 1, chẵn thêm 0

bài này kiểm tra hàng dọc và ngang


Data bits 0011101 0
Nếu trong 1 hàng có 2 lỗi xảy ra vẫn kiểm
1111000 0 tra được

1000101 1

0101111 1

LRC bits 0111111 0

Hung Ba Ngo – [email protected] 23


Bài tập 2.2

Bổ sung vào bài tập 2.1: mỗi 1 byte có 7 kí tự, chuỗi thứ 1 là nguồn, chuỗi thứ 2 cứ 7 bit sẽ cộng
dần 1 bit vào

- Thêm vào mỗi byte dữ liệu 1 bit kiểm tra chẵn


- Thêm vào tổng kiểm tra LRC vào cuối mỗi khung
- Xây dựng hàm int error_detect(frame) nhận vào một
khung, kiểm tra trả về có lỗi (-1) hay không có lỗi (0)
- Giới hạn: Mỗi byte dữ liệu là 7 bits
- Đề xuất giải pháp cho trường hợp dữ liệu 8 bits

Hung Ba Ngo – [email protected] 24


Cyclic Redundancy Check
Kiểm tra phần dư tuần hoàn

 Different methods of implementation:


• Modulo 2,
• Polynomial
• Shift register
• Exclusive-or gate

Hung Ba Ngo – [email protected] 25


CRC-Modulo 2
Thông điệp gồm k bit cần truyền đi
 Given: Tính F: lấy M/P được phần dư, phần dư dùng làm kiểm tra chẵn lẻ

• M: Message of k bits need to send


P là số chia có r+1 bits, r là chuỗi
kiểm tra

• F : A frame check sequence of r bits is control data that is


appended to M to help receiver to detect error on M Thứ 1: thêm r bit 0 vào, sau

• T =MF is the transmitted frame of (k + r) bits created by đó đem M/P sẽ ra phần dư,
concatenating M and F, with r < k
 With M (k bits) , P (r+1 bits), F (r bits), T (k+r bits), the algorithm of
calculating F and creating transmitted frame will be as following
• Appending r bits 0 to the end of M, or multiply M with 2 r
• Using binary division to divide M*2r with P.
• Adding the remainder of above division to M*2 r to create transmitted
frame T
• Note: P has to be longer than F one bit and the values of its most
significant bit and the least significant must be 1
 Receiver applies binary division to divide T with P:
– No remainder: Error-free, M extracted from (T – k) high order
bits
– Remainder existed: Transmission of T is error
Hung Ba Ngo – [email protected] 26
Khác = 1
giống = 0

Hung Ba Ngo – [email protected] 27


CRC-Modulo 2
 Given:
• M = 1010001101 (k=10 bits)
• P = 110101 (r+1=6 bits)

Steps to calculate FCS (r=5bits):


• Calculate M*2 = 101000110100000.
5

• Apply binary division to divide M*2 by P → Get


5

remainder F = 01110

Create transmitted frame


 T = M*2r + F = 101000110101110

Hung Ba Ngo – [email protected] 28


Hung Ba Ngo – [email protected] 29
Bài tập 2.3.1

Bên gởi và nhận đã thống nhất chọn P=110101


Cho biết các khung T nhận được sau có lỗi hay
không
– T=101.0001.1010.1110
– T=101.0101.1010.1110

Hung Ba Ngo – [email protected] 30


Bài tập 2.3.2

Viết hàm char * fcs(char* T, char* P) chia chuỗi bits T


cho chuỗi bits P và trả về chuỗi bits số dư F

Hung Ba Ngo – [email protected] 31


Bài tập 2.3.1

Cho dữ liệu đầu vào là:


- 1Chuỗi bị chia gồm các ký tự 0 và 1
- 1 Chuỗi chia gồm các ký tự 0 và 1
Hãy tính phần dư theo phép chia modulo 2 của Chuỗi
bị chia cho Chuỗi chia
char * modulo2(char * cbc, char *cc)

Hung Ba Ngo – [email protected] 32


CRC - Polynomial
 Supposing that M=110011 and P = 11001, then M and
P are represented by two following polynomials :
• M(x) = x + x + x + 1
5 4

• P(x) = x + x + 1
4 3

 Algorithm for computing the CRC is represented as


follows:
r
X M(X) R( X )
=Q ( X )+
P(X ) P( X )
n
T ( X )=X M ( X )+R( X )

Hung Ba Ngo – [email protected] 33


CRC - Polynomial

Popular versions of P

Hung Ba Ngo – [email protected] 34


CRC - Polynomial
Example

Given
Then

Compute

Final transmission frame

Hung Ba Ngo – [email protected] 35


Error Control

36
CRC - Polynomial
Example

Given
Then

Compute

Final transmission frame

Hung Ba Ngo – [email protected] 37


Error Control
 How to make sure all frames are eventually delivered to
the network layer at the destination and in the proper
order ?
– Receiver sending back special control frames bearing
positive or negative acknowledgements about the
incoming frames:
• Using acknowledgement frame
– Avoiding the sender to be hung forever when
acknowledge frame lost
• Using a timer and time-out for each sent frame
– Avoiding multiple times of receiving a frame
• Assigning each sent frame a sequence number
Hung Ba Ngo – [email protected] 38
Error control

Hung Ba Ngo – [email protected] 39


Stop and Wait Diagram
 Sender doesn't know if the frame
was transmitted correctly.
• Solution: Use
acknowledgement frame.
 Acknowledgement frame could be
lost.
• Solutions:
• Timer.
• Time-out
• Resend
 Receiver can't recognize duplicate
frames that are resent from sender
• Solution: Assign a sequence
number for each frame
Hung Ba Ngo – [email protected] 40
Duplex data transmission
 Stop and Wait: Simplex data transmission
 Need to achieve duplex data transmission to explore
maximum channel capacity
 Principle for archiving duplex data transmission:

• Maintain frame transmission


• Define frame types: DATA, ACK, NACK
• Using piggyback technology

Hung Ba Ngo – [email protected] 41


Sliding windows
 Instead of sending a frame and then waiting for an
acknowledgement frame from the receiver, Sliding
window protocol allows a sender to send more frames
before returning of acknowledgement frame
 Sending Windows: used by sender to monitor sent
frames that acknowledgement frames are being
waited for
 Receiving Windows: used by receiver to monitor the
frames that are permitted to receive

Hung Ba Ngo – [email protected] 42


Sliding Windows
 A sliding window has two leaves:
Back Front Front leaf and Back leaf. Both
leaf Leaf
Moving leaves have the same moving
direction direction.
 The size of a sliding window is the
length from back leaf to front leaf
 Size of sliding window is changed
when leafs move:
• When the front leaf moves, the
sliding window becomes larger
• When the back leaf moves, the
sliding windows becomes
narrower and it makes the
windows turn around a center

Hung Ba Ngo – [email protected] 43


Sliding Windows
 The smallest size of a sliding window is
Back Front 0
leaf Leaf  The largest size of a sliding window is
Moving n-1
direction  If k bits is used to represent the
sequence number of frames
[0- (2k-1)], then a sliding window will be
divided in to 2k positions that are
corresponding to 2k frame
 For sending window, potions are
currently inside the window represent
the sequence numbers of frames that
sender has sent and is waiting for
acknowledgements from receiver.
Potions out-site the window represent
the sequence numbers of frames that
the sender can send more. However,
the size of the window mustn't be larger
than the maximum size of the window

Hung Ba Ngo – [email protected] 44


Sliding Windows
Back
leaf
Front
Leaf
 For a receiver, the positions
Moving inside its sliding window represent
direction the sequence numbers of frames
that the receiver is permitted to
receive
 Maximum size of a sliding window
represents the size of buffer for
storing temporarily received
frames before processing them
 Supposing that the receiver has a
buffer of 4 frame sizes, then the
maximum size of the sliding
window will be 4.

Hung Ba Ngo – [email protected] 45


Example with maximum window size of 1

Hung Ba Ngo – [email protected] 46


Bài tập

Vẽ hình minh họa hoạt động của cửa sổ trượt có 8 vị


trí (0-7) với kích thước cửa sổ nhận tối đa là 2
Viết chương trình minh họa

Hung Ba Ngo – [email protected] 47


Example with maximum window size of 1

(a): Sending and receiving frame with normal order


(b): Sending and receiving frame with random order
Hung Ba Ngo – [email protected] 48
Go-Back-N protocol
 When a receiver receives an error frame it discards
the frame.
 Because there is no acknowledgement frame for the
error frame, a time-out event for this error frame will
be sent to the sender. The sender then resends the
error frame and all the frames that were sent after the
error frame.

Hung Ba Ngo – [email protected] 49


Go-Back-N protocol

Hung Ba Ngo – [email protected] 50


Selective Repeat protocol

Hung Ba Ngo – [email protected] 51


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 52


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 53


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 54


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 55


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 56


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 57


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 58


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 59


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 60


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 61


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 62


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 63


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 64


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 65


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 66


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 67


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 68


Giao thức Selective Repeat

Hung Ba Ngo – [email protected] 69


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of window will be 7
Sender

Receiver

Sent and waiting for acknowledgment


for frames 0,1,2,3,4,5,6

Receiving ready for


frames 0,1,2,3,4,5,6

Hung Ba Ngo – [email protected] 70


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of window will be 7
Sender

Receiver

Sent and waiting for acknowledgment


for frames 0,1,2,3,4,5,6

Received frames 0,1,2,3,4,5,6,


Checking for error

Hung Ba Ngo – [email protected] 71


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of window will be 7
Sender

Receiver

Sent and waiting for acknowledgment


for frames 0,1,2,3,4,5,6

Frame 0,1,2,3,4,5,6 error-free


Sent acknowledgement for frames 0,1,2,3,4,5,6
Receiving ready for frames 7,0,1,2,3,4,5
Hung Ba Ngo – [email protected] 72
Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of window will be 7
Sender
Transmission error
Acknowledgement frame doesn't reach sender
X Receiver

Sent and waiting for acknowledgment


for frames 0,1,2,3,4,5,6

Frame 0,1,2,3,4,5,6 error-free


Sent acknowledgement for frames 0,1,2,3,4,5,6
Receiving ready for frames 7,0,1,2,3,4,5
Hung Ba Ngo – [email protected] 73
Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of window will be 7
Sender

Receiver

Time-out for frame 0


Resend frame 0
Waiting acknowledgement for
frames 0,1,2,3,4,5,6
Receiving ready for
frames 7,0,1,2,3,4,5

Hung Ba Ngo – [email protected] 74


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of windows will be 7
Sender

Receiver

Time-out for frame 0


Resend frame 0
Waiting acknowledgement for
frames 0,1,2,3,4,5,6
frame 0 arrives, it is a waiting frame →
receive frame 0 and send it to network layer
→ network layer receives duplicate frame 0
Hung Ba Ngo – [email protected] 75
Calculate the size of a sliding window
 It's required that the new receiving window doesn't
overlap the old one.
 Maximum size of sliding window is just a half of the
number used for frame sequence number
 Examples:

• If 3 bits are used for frame sequence number


(from 0 to 7) then the maximum size of the sliding
window is (7-0+1)/2 =4.
• If 4 bits are used for frame sequence number
(from 0 to 15) then the maximum size of the
sliding window is (15-0+1)/2 =8

Hung Ba Ngo – [email protected] 76


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of windows will be 4
Sender

Receiver

Sent and waiting acknowledgement


for frames 0,1,2,3,

Receive ready for


frames 0,1,2,3

Hung Ba Ngo – [email protected] 77


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of windows will be 4
Sender

Receiver

Sent and waiting acknowledgement


for frames 0,1,2,3,

Received frames 0,1,2,3


Checking for error

Hung Ba Ngo – [email protected] 78


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of windows will be 4
Sender

Receiver

Sent and waiting acknowledgement


for frames 0,1,2,3,

Frame 0,1,2,3 error-free


Sent acknowledgement for frames 0,1,2,3
Receive ready for frames 4,5,6,7
Hung Ba Ngo – [email protected] 79
Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of windows will be 4
Sender
Transmission error
Acknowledgement frame doesn't reach sender
X Receiver

Sent and waiting acknowledgement


for frames 0,1,2,3,

Frame 0,1,2,3 error-free


Sent acknowledgement for frames 0,1,2,3
Receive ready for frames 4,5,6,7
Hung Ba Ngo – [email protected] 80
Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of windows will be 4
Sender

Receiver

Time-out
Resend frame 0
Waiting acknowledgement
for frames 0,1,2,3
Receive ready for
frames 4,5,6,7

Hung Ba Ngo – [email protected] 81


Calculate the size of a sliding window

Given a sliding window using 3 bits for numbering


frame → the size of windows will be 4
Sender

Receiver

Time-out
Resend frame 0
Waiting acknowledgement
for frames 0,1,2,3 Frame 0 arrives, It isn't a waiting frame →
discard it

Hung Ba Ngo – [email protected] 82


Calculate the size of the buffer
 Size of buffer is just equal to the maximum size of
receiving window.
 Example: If 3 bits are used to represent the sequence
number of frames (from 0 to 7) then the maximum
size of receiving window is (7-0+1)/2 =4 and the size
of the buffer is also 4.

Hung Ba Ngo – [email protected] 83


Time to send acknowledgement frames
 Piggy-back: Attach acknowledgement into data frame
sent back by receiver
 In case the receiver has no data to send back to the
sender
• Create a timer for each received frame
• If time-out event occurs and the receiver has no data to
send back to the sender then the receiver will send an
acknowledgement frame for the correspondent
received frame

Hung Ba Ngo – [email protected] 84


HDLC Protocol
(High Level Data Link Control)
HDLC Station Types
 Primary station
• Control connection links
• Send frames as commands
• Maintain many logical links to secondary station
 Secondary station

• Controlled by primary station


• Send frames as responses to correspondent
commands
 Combined station

• Play both roles of Primary station and Secondary


station
• Can send commands or responses

Hung Ba Ngo – [email protected] 86


HDLC Link Configurations
 Unbalanced configuration
• One Primary station and one or many secondary
stations
• Support full duplex and half duplex
 Balanced configuration

• Two combined stations


• Support full duplex and half duplex

Hung Ba Ngo – [email protected] 87


HDLC Transfer Modes
 Normal Response Mode (NRM)
 Asynchronous Balanced Mode (ABM)

 Asynchronous Response Mode (ARM)

Hung Ba Ngo – [email protected] 88


HDLC Transfer Modes (1)
 Normal Response Mode (NRM)
• Use unbalanced configuration
• Primary station initializes a data transmission to a
secondary station
• A secondary station can only transfer data in form of
the responses to reply the requests of primary station
• Used with cables having many wires
• Host plays role of a primary stations
• Terminals play role of secondaries

Hung Ba Ngo – [email protected] 89


HDLC Transfer Modes (2)
 Asynchronous Balanced Mode (ABM)
• Use balanced configuration
• All stations can initialize a data transmission without a
permission from a primary station
• Used popularly

Hung Ba Ngo – [email protected] 90


HDLC Transfer Modes (3)
 Asynchronous Response Mode (ARM)
• Use unbalanced configuration
• Secondary can initialize a data transmission without a
permission from a primary
• Primary maintains connections
• Used rarely

Hung Ba Ngo – [email protected] 91


Frame structure
 Synchronous transmission
 All transmissions use frames

 One frame structure for both data and control

Hung Ba Ngo – [email protected] 92


Frame structure
Flag (8 bit): 01111110 , uses bit stuffing technique
 Address (8 bit): Address of secondary station that is permitted to
transfer or receive frames.
 Control (8bit): Type of frames:

• Information frame
• Supervisory frame
• Unnumbered frame
 Information(128-1024 bytes): Data to transfer
 FCS (Frame Check Sequence- 8 bit)
• CRC-CCITT = X16 + X12 + X5 +1

Hung Ba Ngo – [email protected] 93


Control Field
 Depending on frame type
• Frame of Information :
• contains data need to transfer
• contains also acknowledgement (piggy-back)
• Supervisory: Used as acknowledge frame when there
is no data to send back to the sender
• Unnumbered: Used to establish connections

Hung Ba Ngo – [email protected] 94


Control Field Diagram

Hung Ba Ngo – [email protected] 95


Poll/Final Bit
 Used with different meaning depending on the context
 If the frame is a command

• It means Poll
• Value is set to 1 to demand the other side to send
 If the frame is response
• Its means Final
• Value is set to 1 to tell that it has no data to send any
more

Hung Ba Ngo – [email protected] 96


Supervisory function bits

RR (Receive Ready), being an acknowledge frame, telling that it's


ready to receive data, that it has received well until the frame Next-1
SS=00 and are waiting for the frame numbered Next; used when there is no
data to send back to the sender (figgyback)

REJ (Reject): being a non acknowledgement frame, demanding the


SS=01 sender to resend the errors from Next frame

RNR (Receive Not Ready): telling that it is not ready to receive


SS=10 frames, it has received frame Next-1, however, it hasn't been ready to
receive frame Next

SREJ (Selective Reject): demanding to resend the frame with the


SS=11
sequence number being Next
Hung Ba Ngo – [email protected] 97
Unumbered Function Bits

This command requests to setup connection in Balanced


1111P100
mode (Set Asynchronous Balanced Mode).
This command requests to setup connection in Normal
1100P001
response mode(Set Normal Response Mode).
This command requests to setup connection in
1111P000 Asynchronous response mode (Set Asynchronous
Response Mode).
This command requests to release a connection DISC
1100P010 (Disconnect).
UA (Unumbered Acknowledgment). This response is used
1100F110 by secondary stations to tell the primary station that they
have already received and accepted all above U commands
CMDR/FRMR (Command Reject/Frame Reject). This
1100F001 response is used by a secondary station to tell the primary
station that it doesn't accept a well-received command
Hung Ba Ngo – [email protected] 98
Scenarios

Hung Ba Ngo – [email protected] 99


Scenarios

Hung Ba Ngo – [email protected] 100


PPP- Point-to-Point Protocol)

 Used to transfer information between routers in a


network or used to connect user's home machine to a
network of a Internet Service Provider (ISP)
 LCP ( Link Control Protocol).
 NCP (Network Control Protocol): choose network
protocol used by network layer

Hung Ba Ngo – [email protected] 101


Question and Answer please !

8/2015

You might also like