©1999,CiscoSystems,Inc.—6-1Chapter9交换机原理及配置©1999,CiscoSystems,Inc.—6-2•地址(MAC)学习•转发/筛选•环路避免Switch的三个功能©1999,CiscoSystems,Inc.—6-3Switches地址学习•初始MAC地址表为空•学习源地址MACaddresstable0260.8c01.11110260.8c01.22220260.8c01.33330260.8c01.4444E0E1E2E3ABCD©1999,CiscoSystems,Inc.—6-4Switches地址学习•StationAsendsaframetoStationC•SwitchcachesstationAMACaddresstoportE0bylearningthesourceaddressofdataframes•TheframefromstationAtostationCisfloodedouttoallportsexceptportE0(unknownunicastsareflooded)MACaddresstable0260.8c01.11110260.8c01.22220260.8c01.33330260.8c01.4444E0:0260.8c01.1111E0E1E2E3DCBA©1999,CiscoSystems,Inc.—6-5Switches地址学习•StationDsendsaframetostationC•SwitchcachesstationDMACaddresstoportE3bylearningthesourceAddressofdataframes•TheframefromstationDtostationCisfloodedouttoallportsexceptportE3(unknownunicastsareflooded)MACaddresstable0260.8c01.11110260.8c01.22220260.8c01.33330260.8c01.4444E0:0260.8c01.1111E3:0260.8c01.4444E0E1E2E3DCAB©1999,CiscoSystems,Inc.—6-6Switches转发/过滤•StationAsendsaframetostationC•Destinationisknown,frameisnotfloodedE0:0260.8c01.1111E2:0260.8c01.2222E1:0260.8c01.3333E3:0260.8c01.44440260.8c01.11110260.8c01.22220260.8c01.33330260.8c01.4444E0E1E2E3XXDCABMACaddresstable©1999,CiscoSystems,Inc.—6-7•StationDsendsabroadcastormulticastframe•Broadcastandmulticastframesarefloodedtoallportsotherthantheoriginatingport0260.8c01.11110260.8c01.22220260.8c01.33330260.8c01.4444E0E1E2E3DCABE0:0260.8c01.1111E2:0260.8c01.2222E1:0260.8c01.3333E3:0260.8c01.4444MACaddresstable广播与多播Frame©1999,CiscoSystems,Inc.—6-8冗余路径•冗余路径消除了单故障点•冗余路径的不利后果:•广播风暴,多个Frame副本,MAC地址表不稳定Segment1Segment2Server/hostXRouterY©1999,CiscoSystems,Inc.—6-9Segment1Segment2Server/hostXRouterYBroadcastSwitchASwitchBHostXsendsaBroadcast广播风暴©1999,CiscoSystems,Inc.—6-10Segment1Segment2Server/hostXRouterYBroadcastSwitchASwitchBHostXsendsaBroadcast广播风暴©1999,CiscoSystems,Inc.—6-11Segment1Segment2Server/hostXRouterYBroadcastSwitchescontinuetopropagatebroadcasttrafficoverandoverSwitchASwitchB广播风暴©1999,CiscoSystems,Inc.—6-12多个Frame副本Segment1Segment2Server/hostXRouterYUnicastSwitchASwitchB•HostXsendsanunicastframetorouterY•RouterYMACaddresshasnotbeenlearnedbyeitherswitchyet©1999,CiscoSystems,Inc.—6-13Segment1Segment2Server/hostXRouterYUnicastSwitchASwitchB•HostXsendsanunicastframetoRouterY•RouterYMACAddresshasnotbeenlearnedbyeitherSwitchyet•RouterYwillreceivetwocopiesofthesameframeUnicastUnicast多个Frame副本©1999,CiscoSystems,Inc.—6-14Segment1Segment2Server/hostXRouterYUnicastUnicastSwitchASwitchB•HostXsendsanunicastframetoRouterY•RouterYMACAddresshasnotbeenlearnedbyeitherSwitchyet•SwitchAandBlearnHostXMACaddressonport0Port0Port1Port0Port1多个Frame副本©1999,CiscoSystems,Inc.—6-15Segment1Segment2Server/hostXRouterYUnicastUnicastSwitchASwitchB•HostXsendsanunicastframetoRouterY•RouterYMACAddresshasnotbeenlearnedbyeitherSwitchyet•SwitchAandBlearnHostXMACaddressonport0•FrametoRouterYisflooded•SwitchAandBincorrectlylearnHostXMACaddressonport1Port0Port1Port0Port1多个Frame副本©1999,CiscoSystems,Inc.—6-16•Complextopologycancausemultipleloopstooccur•Layer2hasnomechanismtostoptheloopServer/hostWorkstationsLoopLoopLoop多个环路问题Broadcast©1999,CiscoSystems,Inc.—6-17解决办法:Spanning-TreeProtocol将一些Port置为Block状态,避免环路的产生Blockx©1999,CiscoSystems,Inc.—6-18•Onerootbridgepernetwork•Onerootportpernonrootbridge•OnedesignatedportpersegmentxDesignatedport(F)Rootport(F)Designatedport(F)Nondesignatedport(B)RootbridgeNonrootbridgeSWXSWY100baseT10baseT生成树协议STPSpanning-TreeOperations©1999,CiscoSystems,Inc.—6-19SwitchYDefaultpriority32768(8000hex)MAC0c0022222222SwitchXDefaultpriority32768(8000hex)MAC0c0011111111BPDUBPDU=Bridgeprotocoldataunit桥协议数据单元(2秒)Rootbridge:bridgeID最小的桥NonRootbridge:其它的桥BridgeID=Bridgepriority+bridgeMACaddress生成树协议——根桥选择©1999,CiscoSystems,Inc.—6-20SwitchYDefaultpriority32768MAC0c0022222222SwitchXDefaultpriority32768MAC0c0011111111RootbridgexPort0Port1Port0Port1100baseT10baseTDesignatedport(F)Rootport(F)Nondesignatedport(B)Designatedport(F)生成树协议——端口选择非根桥rootport:非根桥上到根桥cost最小的端口designatedport:每一Segment上到根桥cost最小端口根桥的所有端口都是designatedportnondesignatedport:剩余的所有端口©1999,CiscoSystems,Inc.—6-21生成树协议——端口最终状态最终状态根桥的所有端口:Forwarding非根桥rootport:Forwardingdesignatedport:Forwardingnondesignatedport:Blocking注意:Blocking状态不能转发数据,但可收发BPDU消息©1999,CiscoSystems,Inc.—6-22LinkSpeedCost(reratifyIEEEspec)Cost(previousIEEEspec)----------------------------------------------------------------------------------------------------10Gbps211Gbps41100Mbps191010Mbps100100生成树协议——路径成本©1999,CiscoSystems,Inc.—6-23SwitchYMAC0c0022222222Defaultpriority32768SwitchXMAC0c0011111111Defaultpriority32768Port0Port1Port0Port1SwitchZMac0c0011110000Defaultp