1

How to get switch MAC address while implementing spanning tree protocol?

skaffman
  • 398,947
  • 96
  • 818
  • 769
  • What kind of switch? What language are you working in? More specifics would be nice. – Tim Jun 16 '09 at 05:10
  • any switch....generally while implementing spanning tree protocol each switch must have its bridge identifier?where i have to get this data and fill it while implementing protocol –  Jun 16 '09 at 05:48
  • Did I answer your question or not? If I did mark it answered, by clicking the check. If I didn't explain why not? – Ethan Heilman Jun 16 '09 at 21:56

3 Answers3

2

ARP packets are the way to go. Find the ip address of the switch you want, then send an ARP request to that ipaddress. You will receive a packet back mapping the ip address requested to the MAC address which owns that ip address.

The answer above is more of a how to translate an ip address to a MAC address, as that sounds like the gist of your question. STP generally is implemented using BPDU or bridge protocol data unit. If you haven't already you might want to check out:

http://computer.howstuffworks.com/lan-switch14.htm

http://en.wikipedia.org/wiki/Spanning_tree_protocol

http://wiki.wireshark.org/STP

http://en.wikipedia.org/wiki/Logical_Link_Control

BRIDGE ID: Each bridge is assigned an ID, called the bridge ID, that is defined as an 8-byte value split into two components. THe lowest six bytes are assigned the Ethernet MAC address of the bridge ports, and the highest two bytes are a configurable priority, call the bridge priority. -Understanding Linux network internals By Christian Benvenuti

See also

Troubleshooting campus networks By Priscilla Oppenheimer, Joseph Bardwell

Ethan Heilman
  • 16,347
  • 11
  • 61
  • 88
  • thank you ..but what i want to know is what is the mac address of the bridge used in bridge identifier field of BPDU.? –  Jun 16 '09 at 05:43
  • The BPDU packet should contain the MAC Address of the sender. – Ethan Heilman Jun 16 '09 at 06:00
  • Oh! The MAC address is contained in the bridge ID. =) – Ethan Heilman Jun 16 '09 at 06:07
  • A pure bridge doesn't have an IP address. An IP address is only used by a bridge if it is a managed bridge, then it is only for management, and it doesn't play any part in forwarding the frames. The MAC address associated with the management IP address is only for the management interface, not the access or trunk interfaces. – Ron Maupin Mar 01 '18 at 16:56
1

You should first know that most Cisco switches will assign a unique bridge ID per VLAN based on a mac-address assigned to the switch. You can figure out what the bridge ID will be for a VLAN once you have determined what the assigned mac-address is. It is also good to remember that newer switches can use an extended system ID which is more than just the mac-address (as the other poster noted).

You can determine the base mac address and then calculate what the bridgeID will be for a particular VLAN based on the concept that the bridge ID for a particular VLAN will be the base Bridge ID + the vlan number. Example:

Base VLAN = 000.0001.0800

Bridge ID for VLAN 1 = 0000.0001.0801

Bridge ID for VLAN 300 = 0000.0001.092c

yes, it is in Hex format..

You could do this on a Cisco switch as follows:

1: show int | i line | address

This will give you your "base" mac address. You will notice all of the SVIs have the same mac address.

Vlan1 is up, line protocol is up 
  Hardware is EtherSVI, address is 000.0001.0800 (bia 000.0001.0800)

2: You could also just check spanning tree for the calculation directly:

Show span vlan 1 | b Bridge ID



Bridge ID  Priority    8192 
             Address     **000.0001.0801**
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

The mac address under the Bridge ID is the one used for spanning tree calculation.

XL.
  • 1,390
  • 4
  • 11
  • 13
0

for Cisco switches

sh spanning-tree

Switch>sh sp

VLAN0001 Spanning tree enabled protocol ieee Root ID Priority 32769 Address 0010.1167.1B9C Cost 19 Port 17(FastEthernet0/17) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 32769 (priority 32768 sys-id-ext 1) Address 00E0.8F81.C638**** Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 20

Interface Role Sts Cost Prio.Nbr Type


Fa0/17 Root LSN 19 128.17 P2p

Switch>

for Huawei switches

display stp

-------[CIST Global Info][Mode MSTP]-------

CIST Bridge :32768.4c1f-ccfe-181f

Config Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

Active Times :Hello 2s MaxAge 20s FwDly 15s MaxHop 20

CIST Root/ERPC :32768.4c1f-cc7e-7e4d / 20000

CIST RegRoot/IRPC :32768.4c1f-ccfe-181f / 0

CIST RootPortId :128.10

BPDU-Protection :Disabled

TC or TCN received :2

TC count per hello :0

STP Converge Mode :Normal

Time since last TC :0 days 0h:0m:44s

Number of TC :2

Last TC occurred :GigabitEthernet0/0/10

----[Port1(GigabitEthernet0/0/1)][DOWN]----

Cisco Mmu
  • 117
  • 3