Try   HackMD

802.1D - Overview

目標:把多個 LAN 合併

Bridge 的任務是把不同的 LAN 連接起來,使得位於不同 LAN 的兩個節點在經過連接之後,可以彼此傳輸。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

以上面這個例子來說,LAN A 與 LAN B 以這樣的設備連及起來之後,LAN A 與 LAN A 的節點就能互相傳輸。

任務一:擔任 LAN 之間的「閘門」 - Forwarding

不過,除了單純連接在一起之外,也希望這個 bridge 可以擔任類似「閘門」的角色,不會盲目地讓所有封包廣播到所有節點上。舉例來說,若 7 號節點要傳輸給 6 號節點時,這個 bridge 就不會讓這個封包被廣播到 LAN A 上。這個「依照封包目的地決定是否要讓他通過」的目標,稱為 forwarding

任務二:往哪邊轉送? - Address Learning

在決定「哪個封包可不可以通過」之前,首先要問題的是「怎麼知道哪個目的地在哪?」這個「在哪?」指得是「要往交換機的哪個 port 送」。以上面這個例子來說,Bridge 要想辦法知道 6 與 7 位於同一個 LAN 上,才知道不需要讓 6、7 之間的封包通過。因為 LAN 上的設備可能會動態地增減,所以這個「往哪邊轉送」的資訊也必須要隨時更新。而這個隨時更新的過程稱為 address learning

任務三:避開 LAN 中的環 - Loop Resolving

在比較簡單的拓樸中,所以的 bridge 與 LAN 形成一個樹。因為是樹,所以任二節點之間的路徑是唯一的,也因此兩個節點間轉送風包時,就會走這個唯一的路徑:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

但另外一方面,如果這樣多個由 bridge 與 LAN 形成的網路中有環,那麼封包可能就會在這個環裡面不斷地繞圈圈而送不到目的地。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

在碰到這種時候,這些 bridge 之間也要有辦法應對。而這個問題是用 Spanning Tree Protocol 來解決。

其它任務

因為是作為 LAN 之間的閘門,所以如流量控制、過濾封包、必要時分割封包等等。

Bridge 架構

第一步:Bridge 接收廣播的封包

首先,一個 Bridge 的不同接口會各自連接不同的 LAN。每當與其連接的 LAN 上有裝置廣播時,一個 Bridge 就會把廣播的封包收下來:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

第二步:Bridge 檢查封包並決定是否轉送

當一個 Bridge 收下一個封包之後,它就會看看自己的哪個接口可以通往封包目的地。如果有,那它就會把這個封包往那個接口所連接的 LAN 廣播:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Forwarding Database (FDB)

這個「哪個接口可以通往哪個 MAC address」與「哪個 MAC address 要往哪個接口的 LAN 送」其實是藉由一個 Bridge 上的一個表來查詢的。這個表稱為 forwarding database,或是簡稱 FDB。舉例來說:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

狀況一:直接相連

在這個例子中,第 1 號 Bridge 的 1 號接口連接

E
F
,所以它的 FDB 中的
E
F
就會是 1; 類似地,它 2 號接口連接
A
B
,因此
A
B
對應的條目就會是 2。

狀況二:間接相連

除了「直接相連」的結點之外,「間接相連」的節點也有可能記錄起來。舉例來說,

C
D
雖然沒有與 Bridge 1 直接相連,但是可以藉由 Bridge 2 到達。因此若 Bridge 1 收到一個要往
C
D
送的封包,那麼它應該想辦法日 Bridge 2 收到這個封包。因此這時要把封包藉由自己的接口 2 往 Bridge 2 所在的 LAN 2 送。所以
C
D
在 FDB 對應的欄位為 1。

轉送時動態調整 FDB

這樣的 FDB 並不是事先建立好的,而是會在轉送封包的過程中,動態地調整當中的欄位。除此之外,FDB 的每一個欄位都會有一個有效期限,當這個有效期限到期時,這個條目就會「到期」,需要被移除。

Linux 核心中的 FDB

FDB 相關的程式碼可以在 net/bridge/br_fdb.c 裡面找到。這個檔案裡面還有這些 tracepoint:trace_br_fdb_add, trace_fdb_delete, trace_br_fdb_update, 以及 trace_br_fdb_external_learn_add。他們的定義可以在 include/trace/events/bridge.h 當中找到。

課程影片

Withdrawal of IEEE Std 802.1D-2004

第 4A 講 IEEE 802.1D 交換機的擴張樹演算法 (Spanning Tree Algorithm) L01 1

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

第 4B 講 IEEE 802.1D 交換機的擴張樹演算法 (Spanning Tree Algorithm) L01 2

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →