EN 5 DataLinkLayer PDF
EN 5 DataLinkLayer PDF
Tầng liên kết dữ liệu chỉ gửi khung đến tầng vật lý
Mô tả thông tin
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
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ý
Byte count Đếm byte
Flag bytes with byte stuffing dùng cờ
Flag bits with bit stuffing.
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ữ 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
Cotrol data
Phải 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
• 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.
Parity bits
1011011 1
1000101 1
0101111 1
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
• 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
remainder F = 01110
• P(x) = x + x + 1
4 3
Popular versions of P
Given
Then
Compute
36
CRC - Polynomial
Example
Given
Then
Compute
Receiver
Receiver
Receiver
Receiver
Receiver
Receiver
Receiver
Receiver
Receiver
Time-out
Resend frame 0
Waiting acknowledgement
for frames 0,1,2,3
Receive ready for
frames 4,5,6,7
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
• 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
• 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
8/2015