How switch will learn MAC in these situations?

7

So I know how switch learns MAC address. It sends packet through all(if needed) ports, while it get a answer from destination and marks it to that port.

I have a few questions:

Scenario 1 - 2

Scenario 1: How will it learn the MAC address? Switch1 can reach Switch2 through Switch0 or it can go directly to Switch2? How will it be? What if Switch2 was connected later?

Scenario 2: What about this one? It can go from (lets assume) port 1 to port 1, or it can go from port 2 to port 2. Will it make a loop?

user701115

Posted 2017-02-24T14:40:30.663

Reputation: 71

1In the scenarios you describe do you have a managed switch or an unmanaged switch? – Ramhound – 2017-02-24T15:44:01.827

Answers

14

Switches don't send packets to discover the MAC addresses, they listen to the traffic and in that way they create a table relating the MAC address with the port from where the frame came.

In the cases that you show, Spanning Tree Protocol enters in work blocking one of the links to avoid a closed loop.

In both cases, each switch using Spanning Tree and through a process of discovery and negotiation, blocks the redundant links so each switch learns remote MAC addresses through one link only. How STP chooses the 'best' port to use is described on Wikipedia.

(Note that STP doesn't choose a best path for each individual MAC – it decides on a single topology globally. In contrast, the newer TRILL and 802.1aq "Shortest Path Bridging" technologies do route each MAC individually.)

If STP is disabled, then you just get a loop and the network melts down.

jcbermu

Posted 2017-02-24T14:40:30.663

Reputation: 15 868

5If STP is disabled...or isn't supported by the switch at all, which is entirely possible with some switches. – I say Reinstate Monica – 2017-02-24T16:13:25.033

@twist, all ethernet switches support STP, which was a standard for bridges long before there were switches. Some switches have the ability to disable STP, but they all support it. – Ron Maupin – 2017-02-24T20:20:42.593

6

@RonMaupin I agree it would be hard to find a managed switch that doesn't support STP, but this is a feature often lacking in unmanaged switches. For an example, the Dell rep "DELL-GregG" in this Dell Support Community thread states "None of our unmanaged switches send BPDUs or participate in the Spanning Tree Protocol." Obviously BPDUs sent through the switch will still work, but I don't take that to mean the switch "supports" STP.

– I say Reinstate Monica – 2017-02-24T20:46:33.093

3It wasn't even that common in cheaper managed ones, really. I've got a couple of web-managed rack switches from late 2000's (from D-Link and TP-Link) which don't do any form of STP either. – user1686 – 2017-02-24T21:20:07.030

@Twisty, BPDUs cannot be sent through a switch. The IEEE standard provides for a special multicast OUI for link-local protocols (STP, LLDP, 802.1X, etc.), and any frames with that OUI are not allowed to be forwarded to a different interface, meaning those frames cannot be sent through a switch. I know that even cheap home switches support STP because they get connected to our network, and the interfaces on our company switches disable due to receiving BPDUs on access interfaces, then the cheap switches get confiscated. – Ron Maupin – 2017-02-24T21:36:24.337

Also, Windows bridge mode generates BPDUs. – Ron Maupin – 2017-02-24T21:49:17.207

The BPDUs, have a frame header. That frame header has a destination MAC address, the OUI (01-80-C2) of the MAC address is reserved by the IEEE for link-local layer-2 protocols. – Ron Maupin – 2017-02-24T22:02:39.597