cs4231 local area networks hw3 – spanning tree algrithm

19

Upload: ferris

Post on 11-Jan-2016

76 views

Category:

Documents


0 download

DESCRIPTION

CS4231 Local Area Networks HW3 – Spanning Tree Algrithm. Overview. Overview. 區域網路 1. 埠 1. 埠 1. 橋接器 2. 橋接器 3. 埠 1. 埠 2. 埠 2. 橋接器 1. 區域網路 2. 埠 2. 埠 1. 橋接器 4. 埠 2. 區域網路 3. Spanning Tree Algorithm. Bridges Each bridge is assigned a unique identifier (8 octets): - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm
Page 2: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Overview

Page 3: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Overview

埠 1

橋接器 1

區域網路 1

區域網路 2

區域網路 3

橋接器 2 橋接器 3

橋接器 4

埠 2

埠 2

埠 1

埠 2

埠 2

埠 1 埠 1

Page 4: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Spanning Tree AlgorithmBridges

Each bridge is assigned a unique identifier (8 octets): Priority part (two octets): programmable address part (six octets)

A special group MAC address for all bridges :01-80-C2-00-00-00 (Multicast address)

Each port of a bridge has a unique port identifier.

Page 5: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Spanning Tree AlgorithmRoot Bridge: The bridge with the lowest value of bridge identifier.Path Cost: For each port, the cost of transmitting a frame onto a LAN.Root Port: For each bridge, the port on the minimum-cost path to the root

bridge.Root Path Cost: For each bridge, the cost of the path to the root bridge

with minimum cost.Designated Bridge: For each LAN, the bridge that provides the minimum

cost path to the root bridge. The only bridge allowed to forward frames to and from the LAN.

Designated Port: The port of the designated bridge that attaches the bridge to the LAN. All internet traffic to and from the LAN pass through the designated port.

Page 6: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Spanning Tree AlgorithmThree Steps:

1. Determine the root bridge.2. Determine the root port on all other bridges.3. Determine the designated port on each LAN.

The port with the minimum root path cost. In the case of two or more bridges with the same root path cost,

the highest-priority bridge is selected. If the designated bridge has two or more ports attached to this

LAN, then the port with the lowest value of identifier is selected.

Page 7: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Determine Root Bridge1.每個橋接器送出 BPDU 至所有與其相連之區網

將 ’根橋接器 ID’ 設為自己的 ID; RPC 設為 0

2.當橋接器自埠 i 收到 BPDU若收到 BPDU 上之 ’根橋接器 ID’ 比較小

認定 BPDU 上之 ‘根橋接器 ID’ 方為正確 設定 i 為根埠 更新 RPC 值 (=RPC(BPDU) + TC(i)) 送出新的 BPDU 至除 i 外的所有埠 帶有更新後之 ‘根橋接器 ID’ 與 RPC 值

否則,捨棄此 BPDU

3.在兩個 “轉送延遲時間” 內可確定是否為根橋接器

Page 8: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Determine Designated Port1.橋接器 X 設定埠 i 為根埠後,將其 RPC 值送至除 i

外之所有埠,測試是否可為代理埠2.當 Y 由埠 k 收到 BPDU :

若 RPC(X)<RPC(Y) 則放棄競爭 . 埠 k 不為代理埠 若 RPC(X)>RPC(Y) 則將 RPC(Y) 送入埠 k 若 RPC(X)=RPC(Y) 則以 ID 小的擁有代理權

Page 9: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Spanning Tree Algorithm Example

區域網路 W

RPC = 35 7

D(W): 區域網路 W 的代理埠

橋接器 XTC=15

埠 i

TC=10 埠 j

RPC = 38 1

RPC = 40, 根埠 = m

RPC = 48, 根埠 = n, D(W) = m

RPC = 48 3

RPC = 20 5

RPC = 35, 根埠 = i,D(W) = j

橋接器 ZTC=10

埠 m

TC=10 埠 n

橋接器 YTC=5

埠 l

TC=5 埠 k

RPC = 53, 根埠 = kRPC = 58, 根埠 = j

RPC = 45, 根埠 = m

RPC = 40, 根埠 = k

RPC = 30, 根埠 = l,D(W) = k

RPC = 30

RPC = 35, 根埠 = i

RPC = 25 9

11

48

10

46

12

Page 10: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

區域網路 W

R R

R

D

D: 代理埠R: 根埠

Spanning Tree Algorithm Example

橋接器 X

TC=15 埠 i

TC=10 埠 j

橋接器 Z

TC=15 埠 m

TC=10 埠 n

橋接器 Y

TC=5 埠 l

TC=5 埠 k

Page 11: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Bridge Port State Diagram停滯狀態

經過一個轉送延遲時間

傾聽狀態 學習狀態 轉送狀態

經過一個轉送延遲時間

被取消為代理埠或根埠 被取消為

代理埠或根埠 被取消為代理埠或根埠

被選為代理埠或根埠

Page 12: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Bridge Protocol Data Unit

802.3: Ethernet802.2: LLC

Page 13: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Bridge Protocol Data Unithttp://www.banalyzer.de/ban/HTML/P_LAYER2/Eng/

P_lay120.html

Page 14: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Use libnet to send a BPDU libnet_ptag_t libnet_build_stp_conf (u_int16_t id, u_int8_t version,

u_int8_t bpdu_type, u_int8_t flags, u_int8_t * root_id, u_int32_t root_pc, u_int8_t * bridge_id, u_int16_t port_id, u_int16_t message_age, u_int16_t max_age, u_int16_t hello_time, u_int16_t f_delay, u_int8_t * payload, u_int32_t payload_s, libnet_t * l, libnet_ptag_t ptag)

libnet_ptag_t libnet_build_802_3 (u_int8_t * dst, u_int8_t * src, u_int16_t len, u_int8_t * payload, u_int32_t payload_s, libnet_t * l, libnet_ptag_t ptag)

libnet_ptag_t libnet_build_802_2 (u_int8_t dsap, u_int8_t ssap, u_int8_t control, u_int8_t * payload, u_int32_t payload_s, libnet_t * l, libnet_ptag_t ptag)

Page 15: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Use libnet to send a BPDUu_int8_t root_id[8] = {0x80, 0x00, 0x00, 0x10, 0x14, 0x23, 0xA4, 0x08},

bridge_id[8] = {0x80, 0x00, 0x00, 0x10, 0x14, 0x23, 0xA4, 0x08};u_int8_t payload[1] = {0x00};

libnet_build_stp_conf (0, 0, 0, 0, root_id, 0, bridge_id, 2, 0, 20, 2, 15, NULL, 0, l, 0);

libnet_build_802_2 (0x42, 0x42, 0, NULL, 0, l, 0);

libnet_build_802_3 (BPDU_MC, my_mac, 38, NULL, 0, l, 0);

Page 16: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

A BPDU Packet

Page 17: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Requirement封包依建立的 Spanning Tree 傳送 frame想一個可以驗證建立的 Spanning Tree 是正確的方法

例如 show 出每一個 bridge 的收 / 送封包的狀況

Page 18: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

GradingCorrectness (60%)Report (30%)

How to run your program.What you’ve learned?What are you suffer from this HW?Any feedback?

Coding Style (10%)

Page 19: CS4231 Local Area Networks HW3 – Spanning Tree Algrithm

Hand in your programDeadline: 2010/6/18 PM 23:59:59Demo: 2010/6/18 AM 10:00~12:00 at 資電 326Write a simple report in text file.Please tar/zip/rar your files (including code and

report) named as 組別 .tar (ex: group_1.tar) and login to ftp:// 140.114.71.48:4231, cs4231/cs4231s10 Change directory to “Final Project” and create a directory

named your 組別 , then upload your file in this directory.