1
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Tầng liên kếtdữ liệu
• Chứcnăng củatầng liêt kếtdữ liệu(DLL)
• Địachỉ MAC và tính chất
• Phương pháp framing
• Điềukhiểnluồng
• Kiểmsoátlỗi
• Các giao thứccủatầng liên kếtdữ liêu: HDLC và PPP
• Bridge: transparent và sourouting
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
• Chứcnăng củatầng liên kếtdữ liệu
9 Khả năng truyềnkhungtin cậytrênđường liên kếtvật lý không tin cậy
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
Source node
Network
Layer
Data Link
Layer
Physical
Layer
Application
Layer
Presentation
Layer
Session
Layer
Transport
Layer
Network
Layer
Data Link
Layer
Physical
Layer
Destination node
Intermediate node
Packets
Frames
Bits
2
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o Destination address
Single
Group
Broadcast: 11…11
o Addresses
Local or global
o Global addresses (2
46
possible)
First 24 bits assigned to vendors (OUI)
Next 24 bits assigned by vendors
CISCO: 00-00-0C
3COM: 02-60-8C
9 Địachỉ MAC và tính chất: IEEE 802.3 MAC Frame
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
• Phương pháp Framing
9 DLL tổ chức bit stream thành các frame
9 Bắt đầuvàkết thúc của frame đượcxácđịnh: Character count, control
character, flag, …
9 Character count
oSố ký tự đượcchỉ ra trong vị trí xác định của header
o Bên nhận đếmsố ký tựđểxác định nơikết thúc frame
oVídụ: DDCMP (Digital data comm. message protocol)
3
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Control character
oMỗi frame bắt đầuvàkết thúc vớichuỗikýtựđặcbiệt
Ví dụ: bắt đầuvới DLE STX (data link escape start of text) và
kết thúc với DLE ETX (end of text)
oPhầndữ liệuphảilàsố nguyên lần các ký tự
o Character stuffing: chèn DLE trướcmỗikýtự DLE trong dữ liệu,
ngănchặnkhả năng xuấthiện các ký tự bắt đầuvàk
ết thúc xuất
hiện bên trong frame
Ví dụ: BISYNC
STX: 0x02, ETX: 0x03
DLE: 0x01 (non-printable)
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Flagging
oMỗi frame bắt đầuvàkết thúc bằng chuỗikýtựđặcbiệt–flag
o Flag byte: 01111110 (0x7E)
oPhầndữ liệucủa frame có thể chứasố bit bấtkỳ
o Bit stuffing: chèn bit 0 vào sau mỗichuỗi 5 bit 1 liên tiếp
oVídụ: SDLC, HDLC, LAPB
01111110111101011111011110111110001111110
Flag
FlagFrame
4
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
• Điềukhiểnluồng (flow control)
9 Khái niệm điềukhiểnluồng
oKíchthướcbộđệm đêlưugiữ các frame nhận đượcbi giớihạn
oTrànbộđệmcóthể xảyranếutốc độ xử lý tại phía thu chậmhơn
tốc độ truyền frame
o Điềukhiểnluồng ngănchặ
ntrànbộđệmbằng cách điềukhiểntốc
độ truyềndẫntừ phía phát (Tx) đến phía thu (Rx)
o Các phương pháp phổ biến:
X-ON/X-OFF
Stop and wait
Sliding window
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Transmitter
Receiver
X-OFF
9 X-ON/X-OFF
oRx truyền X-OFF (DC3) nếubộđệm đầy
oTxdừng truyền khi nhận đượcX-OFF
oRx truyền X-ON (DC1) khi bộđệm đượcgiải phóng
oTxbắt đầutruyềnlạikhinhận đượcX-ON
oCóthể sử dụng các frame RR (Receive Ready) và RNR (Receive
not Ready)
oNếusố bit trong bộđệmvượt quá ngưỡng 2t
prop
·R, X-OFF được
gửitớiTx
oPhương pháp: Stop-and-wait, sliding window
X-ON
Threshold
5
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o Stop-and-wait
Tx ngừng truyền frame tiếp theo cho đến khi nhận đượcACK
từ Rx
Rx truyền frame ACK khi đãsẵn sàng nhận frame tiếp theo
Đơngiản, nhưng không hiệuquả khi trễđáp ứng đường
truyềnlớn
Data
Data
ACK
ACK
Tx Rx
t
frame
t
prop
T
12a
1
t2t
t
U
frameprop
frame
+
=
+
=
Utilization:
R / L
v / d
t
t
a
frame
prop
==,
Satellite link: t
prop
= 270 ms, L = 500 byte
R = 56 kbps Î t
frame
= 4/56 = 71 ms,
Î a = t
prop
/ t
frame
= 270/71 = 3.8,
Î U = 0.12 = 12% của 56 kbps
Short link: t
prop
= 5 µs, L = 500 byte
R = 10 Mbps Î t
frame
= 4k/10 M = 400 µs,
Î a = t
prop
/ t
frame
= 5/400 =0.012
Î U = 0,98 = 98% của 10 Mbps
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o Sliding window
Window W
S
bằng kích thướcbộđệmcủa bên nhậncóthể sử
dụng để nhận các frame liên tiếptừ Tx không cầnACK
Có thể tránh hiệntượng tràn bộđệmcủaRx
PhảichọnW
S
lớnhơn a (delay of bandwidth)
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
F0
F1
F2
ACK3
ACK6
F3
F4
F5
F6
System A
System B
6
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
⎪
⎩
⎪
⎨
⎧
+<
+
+≥
=
+
=
2a1 N
2a1
N
2a1N 1
t2t
Nt
U
frameprop
frame
Utilization:
R / L
v / d
t
t
a
frame
prop
==,
Data
Tx Rx
t
frame
t
prop
T
ACK
N frames
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
• Kiểmsoátlỗi (error control)
9 Khái niệm
oLỗi do môi trường truyềndẫn
o Quá trình kiểm soát lỗicó2 chứcnăng: phát hiệnvàsửalỗi
o2 loạilỗiphổ biến: mất frame và lỗi frame
9 Các phương pháp kiểmsoátlỗi
o Forward error control: sửalỗitại phía Rx (Forward Error Correction)
o Backward error control: truyềnlại frame (Automatic Repeat Request)
Î cần backward channel
7
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Automatic Repeat reQuest (ARQ)
oCơ chế
Phát hiệnlỗi
Positive acknowledgement (ACK): frame nhậnOK tạiRx
Truyềnlại sau timeout
Negative acknowledgement (NACK): truyềnlại frame
o Các phương pháp ARQ
Stop and Wait ARQ
Continuous ARQ
Go-back-N ARQ
Selective-reject (or repeat) ARQ
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o Stop and wait ARQ
Tx gửi 1 frame và đợiACK từ Rx trướckhitruyền next frame
Tx phảigiữ bảncopy của frame đãgửi đến khi nhận đươcACK
Sử dụng timeout cho các frame hoặcACK bị mất
Đánh số các frame gửivànhận để nhậnbiếtkhilặp frame
Ví dụ: sử dụng 1 bit để đánh số frame
A
B
F
r
a
m
e
0
F
r
a
m
e
1
F
r
a
m
e
0
F
r
a
m
e
0
F
r
a
m
e
1
F
r
a
m
e
1
A
C
K
1
A
C
K
0
F
r
a
m
e
0
A
C
K
1
A
C
K
0
A
C
K
0
Frame lost
A retransmits
ACK 0 lost
A retransmits
Timeout
Timeout
*
*
B discards
duplicated frame
8
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o Go-back-N ARQ
Tx có thể truyền liên tiếp các frame
Rx gửi negative acknowledgement (REJ) khi phát hiệnlỗi
Tx phảitruyềnlạitấtcả các frame từ frame bi lỗi
Tx phảigiữ bảncopy củatấtcả các frame đãgửi
Tx
Rx
F
r
a
m
e
0
F
r
a
m
e
1
F
r
a
m
e
2
F
r
a
m
e
5
F
r
a
m
e
3
F
r
a
m
e
4
A
C
K
1
N
A
C
K
2
A
C
K
3
Frame 2, 3, 4
retransmitted
F
r
a
m
e
2
F
r
a
m
e
3
A
C
K
2
*
F
r
a
m
e
4
A
C
K
4
A
C
K
5
Discarded by Rx
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o Selective-repeat ARQ
Tx có thể truyền liên tiếp các frame
Rx gửi negative acknowledge (SREJ) khi phát hiệnlỗi
Rx lưulạitấtcả các frame OK sau frame bị lỗi
Tx chỉ gửilại duy nhất frame bị lỗi
Rx phảisắpxếplại các frame đãlưusaukhinhận được frame
truyềnlại
Tx
Rx
F
r
a
m
e
0
F
r
a
m
e
1
F
r
a
m
e
2
F
r
a
m
e
7
F
r
a
m
e
5
F
r
a
m
e
6
A
C
K
1
N
A
C
K
2
A
C
K
5
Frame 2
retransmitted
F
r
a
m
e
2
F
r
a
m
e
3
A
C
K
2
*
F
r
a
m
e
4
A
C
K
6
A
C
K
7
Frame 2, 3, 4
released
F
r
a
m
e
0
A
C
K
0
Error Buffered
by Rx
9
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Performance: Stop-and-wait ARQ
P: xác suấtlỗi khung
N
f
= số lầntruyền khung trung bình
freeerror
r
U
N
1
U
−
=
∑
−
=−⋅=
−
P1
1
P)(1PiN
1i
r
Î
2a1
P1
2a1
1
N
1
U
r
+
−
=
+
⋅=
Tx Rx
t
frame
t
prop
NACK
NACK
ACK
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Performance: Go-back-N ARQ
P: xác suấtlỗi khung
N
f
= số lầntruyền khung trung bình
P1
1)P(K1
P)(1P2K)(1P)(1PK)(1P)(11N
2
r
−
−+
=
++−⋅⋅++−⋅⋅++−⋅≈ L
Î
NK:2a1N
2a1K:2a1N
=+<•
+
=
+
≥
•
⎪
⎪
⎩
⎪
⎪
⎨
⎧
+<
+−+
−
=
+
⋅
−+
−
+≥
+
−
=
−+
−
=
2a1N,
NP)P2a)(1(1
P)N(1
2a1
N
1)P(K1
P1
2a1N,
2aP1
P1
1)P(K1
P1
U
Tx Rx
t
f
t
p
NACK
0
1
2
3
0
1
2
3
4
10
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
P: xác suấtlỗi khung
N
f
= số lầntruyền khung trung bình
Performance: Selective-repeat ARQ
⎪
⎩
⎪
⎨
⎧
+<
+
−
+≥
=
2a1N,
2a1
P)N(1
2a1NP,-
U
1
∑
−
=−⋅=
−
P1
1
P)(1PiN
1i
r
Tx Rx
t
f
t
p
NACK
0
1
2
3
0
4
5
6
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
• Các giao thứccủatầng liên kếtdữ liệu
9 High Level Data Link Control (HDLC)
o ISO phát triểntừ IBM sychronous DLC (SDLC)
oCơ chế chèn bit (bit-stuffing), data transparency
oHỗ trợ truyền đồng bộ, HDX, FDX, point-to-point
o Flow control: X-ON / X-OFF
o Error control: Go-back-N, Selective-repeat ARQ
9 Point to point protocol (PPP)
oTạokếtnối điểm-điểm
Router-router leased line (PPP), dial-up host-router (PPP, SLIP)
oChuẩnchínhthứccủa Internet, làm việc ở tầng liên kếtdữ liệu
o Làm việ
c trên dial-up tel line, SONET, ADSL, X25, ISDN, …
oChứcnăng: error detection, IP address negotiation, authentication
11
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 HDLC
oHọ giao thức HDLC
SDLC: IBM
HDLC: ISO
Link Access Procedure Balanced (LAPB): X25
Link Access Procedure for D-channel (LAPD): ISDN
PPP: Internet
Logical Link Control (LCC): IEEE
Frame relay
oChếđộhoạt động củaHDLC
Configurations: Balanced, unbalanced link
Mode: Normal Response Mode (NRM) – unbalanced multipoint
Asynchronous Response Mode (ARM) – unbalanced PPP
Asynchronous Balanced Mode (ABM) – balanced PPP
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
NRM: polling multidrop lines
Primary
Secondary Secondary Secondary
Commands
Response
Primary
Secondary
Commands
Secondary
Primary
Responses
Responses
Commands
ABM: Asynchronous Balanced Mode
Mode đượcchọnkhithiếtlập liên kết
12
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o HDLC frame format
Flag (01111110): Bắt đầuvàkết thúc frame, sử dụng trong
đồng bộ
Address (có thể mở rộng): xác định secondary trong multidrop
link
Control: Xác định dạng frame
FCS: CRC-16 hoặc32
Flag Address Control Information FCS Flag
8
8
Extendable
8/16
Variable
16/32 8
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o HDLC frame types: I-frame, U-frame, S-frame
0 N(S) P/F N(R)
1 0 S S 0 0 0 0 P/F N(R)
0 N(S) P/F N(R)
1 0 S S P/F N(R)
1 1 M M P/F M
I frame
S frame
U frame
16-bit control field format
8-bit control field format
I frame
S frame
N(S): send sequence #
N(R): receive sequence #
S: super functions bits
M: Unnumbered functions bits
P/F: Poll / Final bits
13
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
I-frame: User data
Mỗi frame có số thứ tự N(S)
Cơ chế ACK:
+ N(S) = số thứ tự của frame đang gửi
+ N(R) = số thứ tự củaframe đợinhậntiếp theo, xác nhận
đãnhận OK các frame có số thứ tựđếnN(R)-1
Sử dụng 3 hoặc7 đánh số thứ tự các frame: Kích thước
cửas
ổ cực đạilà7 hoặc127
P/F: Trong NRM, chếđộhỏi vòng của primary (P=1),
secondary thiếtlậpF=1 khigửi đáp ứng với khung I cuối
cùng
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
S-frame: error control + flow control
Receive Ready (RR), Receive Not Ready (RNR), Reject
(REJ): Go-back-N ARQ, Selective Reject (SREJ):
Selective-repeat ARQ
RR: SS = 00, ACK đãnhận OK N(R)-1 frame
REJ: SS = 01, NACK frame N(R) đầutiêncólỗi, Tx phải
gửilại frame N(R) và các frame sau đó
RNR: SS = 10, ACK đãnhận OK frame N(R)-1, không
nhậntiếp các I frame
SREJ: SS = 11, NACK cho frame N(R) và yêu cầutruyền
lại frame này
14
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
U-frame: Link initialization, maintenance, disconnection
Cung cấp commands + response: mode settings, recovery
Mode settings: thiếtlậpchếđộliên kết
+ SABM: Set Asynchronous Balanced Mode
+ UA: ACK đãchấpnhậncáclệnh thiếtlậpchếđộ
+ DISC: Hủybỏ liên kếtlogic đãthiếtlập
Truyềntin giữacáctrạmsử dụng unnumbered info (UI)
Recovery: khi error/flow control không thựchiện được
+ FRMR: frame có FCS đúng, nhưng sai cú pháp
+ RSET: Tx khởitạolạisố thứ t
ự các frame đượcgửi
SABM DISC UAUA
Data
transfer
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Ví dụ: HDLC sử dụng NRM (polling)
Primary A Secondary B, C
*
B, I, 0, 0
B, I, 1, 0
B, I, 2, 0, F
B truyền3 I-frame
N(S)
N(R)
C, RR, 0, F C không truyềngì
B, I, 1, 0
B, I, 3, 0
B, I, 4, 0, F
B truyềnlại
frame 1, 3, 4
A hỏi vòng B B, RR, 0, P
N(R)
B, SREJ, 1
C, RR, 0, P
A từ chốiframe 1
A hỏi vòng C
B, SREJ, 1, PA hỏi vòng B
yêu cầutruyền
lạiframe 1
A truyềnframe 0
tớiB, ACK đã
nhậnOK đến
frame 4
B, I, 0, 5
15
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Ví dụ: HDLC sử dụng ABM
Station A Station B
*
A, I, 0, 0
A, I, 2, 1
B, REJ, 1
A ACK đãnhận
OK frame 0
B, RR, 2
A ACK frame 1
B truyền5 frame B, I, 0, 0
B, I, 1, 0
A, I, 1, 1
B, I, 2, 1
B, I, 3, 2
B, I, 4, 3
A, I, 3, 1
B, I, 1, 3
B, RR, 3
B, I, 2, 4
B, I, 3, 4
B gửilạiframe 1
A ACK frame 2
A từ chốiframe 1
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 PPP
Flag
01111110
Address
11111111
Control
00000011
Information CRC
Flag
01111110
Integer # of bytes
Protocol
oGiống HDLC, nhưng là giao thứchướng byte
Flag 01111110 được coi như là ký tự 0x7E
Chèn byte (byte stuffing) sử dụng ký tựđặcbiệt: 0x7D
o Address: luôn luôn là 11111111 Î các trạm đềunhận được frame
o Control: U-frame (không có thứ tự các frame đượctruyền)
o Protocol: cho biếtloại packet chứa trong information (IP, IPX, LCP,
NCP …)
User’s home
Modem
ISP’s office
TCP/IP
connection
using PPP
or SLIP
Dial-up
tel. line
16
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
o Link Control Protocol (LCP): Quảnlýkếtnối, hỗ trợ multilink (kết
hợp nhiềukếtnốivậtlývào1 đường kếtnối logic), authentication
(sử dụng ID và password: Password Authentication Protocol -
PAP)
o Network Control Protocol (NCP): hỗ trợ IP, IPX, Decnet, Apple
Talk), dynamic IP address assigment
o Byte stuffing in PPP
Control escape: 0x7D
Khi xuấthiện flag hoặc control escape bên trong frame, chèn
vào 0x7D (01111101) và dữ liệutương ứng đươc XOR với
0x20 (00100000)
41 7D 42 7E 50 70 46
Dữ liệucầntruyền
7E 41 7D 5D 42 5E7E 50 70 46 7E
Sau khi stuffing và framing
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Dead
EstablishTerminate
Open Authentication
Network
1. Carrier
detect
2. Options
negotiated
3. Authentication
completed
4. NCP
configuration
6. Done
5.
7. Carrier
dropped
Failed
Failed
o PPP phase
Home PC kếtnốivớiISP
1. PC calls router via modem
2. PC and router exchange LCP
packets to negotiate PPP
3. Check on identities
4. NCP packets exchanged to
configure the network layer
TCP/IP (require IP address
assignment)
5. Data transport: send/receive
IP packets
6. NCP used to tear down the
network layer connection (free
up IP address); LCP used to
shut down data link layer
connection
7. Modem hangs up
17
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
• Bridge: transparent và source routing
9 Repeater, bridge: làm việc ở tầng liên kếtdữ liệu để liên kết nhiều
phân lớpmạng với MAC format khác nhau, data rate khác nhau, kích
thước frame khác nhau
9 Tổng quát về bridge
802.3
802.3
802.3
802.3
802.5
802.5
802.5
802.5
802.3 802.5
Network
LLC
MAC
PHY
Network
LLC
MAC
PHY
CSMA/CD Token Ring
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Transparent bridge
oKếtnối IEEE LAN đảmbảo data transparency
oSử dụng bảng tham chiếu (table lookup)
oSử dụng phương pháp họcsauđể xây dựng bảng tham chiếu
Theo dõi địachỉ nguồncủamạng LAN gửi đến
Theo dõi sự thay đổicấutrúcmạng để cậpnhậtbảng tham
chiếu
Bridge
LAN 1
LAN 2
S1 S2 S3
S4 S5 S6
18
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
B1
LAN 1 LAN 2
S1 S2 S3
S4 S5
B2
Port 1 Port 2
Port 1 Port 2
Address Port Address Port
oVídụ
LAN 3
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
LAN 1 LAN 2
S1 S2 S3
S4 S5
Port 1 Port 2
Port 1 Port 2
Address Port
S1 1
Address Port
S1 1
S1 Î S5
S1 Î S5
S1 Î S5
S1 Î S5
B1 B2
LAN 3
19
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
S3 Î S2
S3 Î S2
LAN 1 LAN 2
S1 S2 S3
S4 S5
Port 1 Port 2
Port 1 Port 2
Address Port
S1 1
S3 2
Address Port
S1 1
S3 1
S3 Î S2
B1 B2
S3 Î S2
LAN 3
S3 Î S2
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
S4 Î S3
S4 Î S3
LAN 1 LAN 2
S1 S2 S3
S4 S5
Port 1 Port 2
Port 1 Port 2
Address Port
S1 1
S3 2
S4 2
Address Port
S1 1
S3 1
S4 2
S4 Î S3
B1 B2
S4 Î S3
S4 Î S3S4 Î S3
LAN 3
S4 Î S3
20
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
S2 Î S1
LAN 1 LAN 2
S1 S2 S3
S4 S5
Port 1 Port 2
Port 1 Port 2
S2 Î S1
Address Port
S1 1
S3 2
S4 2
S2 1
Address Port
S1 1
S3 1
S4 2
B1 B2
LAN 3
S2 Î S1
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Ngănchặnvònglặpsử dụng spanning tree algorithm
oChọn bridge có root ID thấpnhấtlàmroot bridge (RB)
oXácđịnh root port (R) cho từng bridge, trừ RB: port có
đường đingắnnhất(least-cost) tới RB
oChọn designated bridge (D) cho từng mạng LAN:
+ bridge có đường đingắnnhấttừ mạng LAN tới RB
+ Designated port
: nốimạng LAN với D
oTấtcả các root port R và designated port D đượcthiếtlập
trạng thái chuyểntiếp(forwarding). Chỉ các port này được
phép chuyểntiếp frame. Các port còn lại đượcthiếtlậptrạng
thái khóa (blocking)
21
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
B1 B2
B3
B4
B5
LAN4
LAN3
LAN1
LAN2
11
2
1
2
1
2
1
2
2
3
B1 B2
B3
B4
B5
LAN4
LAN3
LAN1
LAN2
11
2
1
2
1
2
1
2
2
3
RB
ID = 1
o Ví dụ: Giả sử cost cho mỗiLAN đềubằng nhau
1. B1 đượcchọnlàmroot bridge
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
D
B1 B2
B3
B4
B5
LAN4
LAN3
LAN1
LAN2
11
2
1
2
1
2
1
2
2
3
RB
ID = 1
R
R
R
R
B1 B2
B3
B4
B5
LAN4
LAN3
LAN1
LAN2
11
2
1
2
1
2
1
2
2
3
RB
ID = 1
R
R
R
R
D
2. Root port đượcchọnchotừng bridge trừ RB
3. Chọn designated bridge cho mỗiLAN
D
D
4. Thiếtlập root port và designated port
22
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Network analyzer: Ethereal
o Do Gerald Combs
, www.ethereal.com
o Ethereal có thể bắt, hiểnthị và phân tích các frame qua Ethernet
NIC
oChuỗi các frame và nội dung của frame có thể được phân tích chi
tiết ở mứcbyte
oRấthữuhiệu khi phân tích lỗimạng, đồng thờilàphầnmềmdạy
học
oChọn website www.vnexpress.net
làm ví dụ
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Ethereal window
Top pane
Frame/packet
sequence
Middle pane
Encapsulation for
a given frame
Bottom pane
Giá trị Hexa & text tương ứng
23
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Top pane: Frame sequence
DNS query
TCP Connection
Setup
HTTP request &
response
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
9 Middle pane: Encapsulation
Protocol type
Ethernet destination
and source addresses
24
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Protocol type
IP packet
Ethernet destination
and source addresses
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
TCP segment
Source and destination
port numbers
GET
HTTP
request
25
Hanoi University of Technology Faculty of Electronics and Telecommunications
2008 Chương 3
Chương 3. Kếtnốimạng ở lớp2 -tầng liên kếtdữ liệu
Tổng kết
• Tầng liêt kếtdữ liệu(DLL)
9 Framing
9 Flow control: Stop-and-wait control, sliding window
9 Error control: Stop-and-wait ARQ, Go-back-N ARQ, selective-repeat ARQ
• Giao thứccủatầng liên kếtdữ liệu
9 HDLC: HDLC frame format, operation mode
9 PPP: PPP frame format
• Kêt nốivàmở rộng mạng ở tầng liên kếtdữ liệu
9 Transparent bridge: self-learning củabảng tham chiếu
9 Spanning tree algorithm: ngănchặnvònglặp trong kếtnốimạng