09 · Exploring the TCP_IP Link Layer探索 TCP/IP 鏈結層

Frame Switching框架交換

The switch builds and maintains a table called the MAC address table, which matches the destination MAC address with the port that is used to connect to a node. The MAC address table is stored in the content-addressable memory (CAM), enabling very fast lookups. Therefore, you might see a switch's MAC address table referred to as a CAM table.

交換器會建立並維護一個稱為 MAC 位址表的表格,用來將目的 MAC 位址與連接該節點所使用的連接埠對應起來。MAC 位址表儲存在內容定址記憶體(CAM)中,能達到非常快速的查詢。因此,交換器的 MAC 位址表有時也被稱為 CAM 表。

For each incoming frame, the destination MAC address in the frame header is compared to the list of addresses in the MAC address table. Switches then use MAC addresses as they decide whether to filter, forward, or flood frames. When the destination MAC address of a received unicast frame resides on the same switch port as the source, the switch drops the frame, which is a behavior known as filtering. Flooding means that the switch sends the incoming frame to all active ports, except the port on which it received the frame.

對於每個進入的框架,交換器會將框架標頭中的目的 MAC 位址與 MAC 位址表中的位址清單進行比對。交換器接著會依據 MAC 位址決定要過濾、轉送或泛洪框架。當收到的單播框架的目的 MAC 位址與來源位於同一個交換器連接埠時,交換器會丟棄該框架,這種行為稱為過濾。泛洪則是指交換器將進入的框架送往所有作用中的連接埠,但不包括接收該框架的連接埠。

The switch creates and maintains the MAC address table by using the source MAC addresses of incoming frames and the port number through which the frame entered the switch. In other words, a switch learns the network topology by analyzing the source address of incoming frames from all attached networks.

交換器會利用進入框架的來源 MAC 位址,以及框架進入交換器的連接埠編號,來建立並維護 MAC 位址表。換句話說,交換器是透過分析來自所有連接網路的進入框架的來源位址,來學習網路拓樸。

The procedure below describes a specific example when PC A sends a frame to PC B, and the switch starts with an empty MAC address table.

以下程序描述一個具體範例:PC A 傳送框架給 PC B,而交換器一開始的 MAC 位址表是空的。

Switching Frames Procedure

框架交換程序

Step
步驟
Action
動作
1
1
The switch receives a frame from PC A on port 1.
交換器在連接埠 1 上收到來自 PC A 的框架。
2
2
The switch enters the source MAC address (of PC A) and the switch port that received the frame into the MAC table.
交換器將來源 MAC 位址(PC A 的位址)與收到該框架的連接埠輸入 MAC 表。
3
3
The switch checks the table for the destination MAC address (of PC B). Because the destination address is not known, the switch floods the frame to all the ports except the port on which it received the frame. In this example, both PC B and PC C will receive the frame.
交換器在表中查詢目的 MAC 位址(PC B 的位址)。由於目的位址未知,交換器會將框架泛洪至除了接收該框架連接埠以外的所有連接埠。在此範例中,PC B 與 PC C 都會收到該框架。
4
4
The destination device with the matching MAC address (PC B) replies with a unicast frame addressed to PC A.
MAC 位址相符的目的裝置(PC B)會以定址給 PC A 的單播框架回覆。
5
5
The switch enters the source MAC address of PC B and the port number of the switch port that received the frame into the MAC table. The destination address of the frame (PC A) and its associated port are found in the MAC table.
交換器將 PC B 的來源 MAC 位址以及收到該框架的連接埠編號輸入 MAC 表。此時,框架的目的位址(PC A)及其對應的連接埠已存在於 MAC 表中。
6
6
The switch can now forward frames between the source and destination devices (PC A and PC B) without flooding because it has entries in the MAC table that identify the associated ports.
由於 MAC 表中已有識別對應連接埠的項目,交換器現在可以在來源與目的裝置(PC A 與 PC B)之間轉送框架,而不需要泛洪。
Interactive content from the online course (not available offline)線上課程的互動內容(離線版未收錄)

The switch performs learning and forwarding actions (including in situations that differ from the example explained above), such as:

交換器會執行學習與轉送動作(包括與上述範例不同的情況),例如:

  • Learning: When the switch receives the frame, it examines the source MAC address and incoming port number. It performs one of the following actions depending on whether the MAC address is present in the MAC address table:學習:當交換器收到框架時,會檢查來源 MAC 位址與進入的連接埠編號。依據該 MAC 位址是否已存在於 MAC 位址表中,執行下列其中一項動作:
    • No: Adds the source MAC address and port number to the MAC address table and starts the default 300 seconds aging timer for this MAC address.:將來源 MAC 位址與連接埠編號加入 MAC 位址表,並為此 MAC 位址啟動預設 300 秒的老化計時器。
    • Yes: Resets the default 300 seconds aging timer.:重設預設 300 秒的老化計時器。
  • Unicast frames forwarding: The switch examines the destination MAC address and, if it is unicast, performs one of the following actions depending on whether the MAC address is present in the MAC address table:單播框架轉送:交換器檢查目的 MAC 位址,若為單播位址,則依據該 MAC 位址是否已存在於 MAC 位址表中,執行下列其中一項動作:
    • No: Forwards the frame out all ports except the incoming port (referred to as unknown unicast).:將框架送往除了進入連接埠以外的所有連接埠(稱為未知單播)。
    • Yes: Forwards the frame out of the port from which that MAC address was learned previously.:將框架從先前學習到該 MAC 位址的連接埠送出。
  • Broadcast or multicast frames forwarding: The switch examines the destination MAC address and if it is broadcast or multicast, forwards the frame out all ports except the incoming port (unless using Internet Group Management Protocol (IGMP) with multicast, in which case it will only send the frame to specific ports).廣播或群播框架轉送:交換器檢查目的 MAC 位址,若為廣播或群播位址,則將框架送往除了進入連接埠以外的所有連接埠(除非搭配群播使用網際網路群組管理通訊協定(IGMP),此時只會將框架送到特定連接埠)。

Regardless of the action of the switch, or the communication type, the switch never changes the content of the frame. A switch’s function is very basic, it just forwards frames according to the destination MAC address and the MAC Address-Table lookup.

無論交換器的動作或通訊類型為何,交換器都不會更改框架的內容。交換器的功能非常單純,它只是依據目的 MAC 位址與 MAC 位址表查詢結果來轉送框架。

Where is the MAC table stored in a Cisco switch?在 Cisco 交換器中,MAC 表儲存在哪裡?