Читать книгу Networking All-in-One For Dummies - Lowe Doug, Doug Lowe - Страница 50
Learning
ОглавлениеFor a switch to do its job, it needs to know what devices are connected to each of its ports. More specifically, the switch needs to know what MAC addresses are reachable via each of its ports. It does this in an ingeniously simple way: It simply learns. Whenever a packet is received on any of the switch’s ports, the switch examines the sending MAC address in the packet. The switch rightly assumes that if it received a packet from a given MAC address on a given port, the switch can reach that MAC address via that port. For example, if a switch receives a packet from Computer C on port 3, the switch has learned that Computer C is reachable on port 3. The switch adds this information to the MAC address table. This table is sometimes referred to as a forwarding database, because it keeps track of which port packets intended for a given destination should be forwarded to. The MAC address table simply keeps a tally of which MAC addresses are reachable on each port of the switch. Suppose the MAC address for Computer C is 21-76-3D-7A-F6-1E. If the switch receives a packet from port 3 with that MAC address, it would add the following entry to the MAC address table:
Port | MAC Address |
---|---|
3 | 21-76-3D-7A-F6-1E |
In this way, the switch has learned that Computer C is reachable via port 3.
After a short time, the switch will likely receive packets from all its ports and will associate the sender’s MAC address with each port:
Port | MAC Address |
---|---|
1 | 40-20-08-78-84-52 |
2 | 2F-B6-E0-F6-EA-05 |
3 | 21-76-3D-7A-F6-1E |
4 | 63-44-E4-A7-4F-E0 |
5 | 76-2F-F9-C8-B6-08 |
6 | FC-78-B6-07-52-EA |
7 | CD-34-E4-B3-2C-76 |
8 | 1C-FD-E0-63-21-C0 |
It’s important to keep in mind that a switch port might actually connect to more than one device. For example, suppose port 5 isn’t connected to a computer but to another switch, which in turn has three other computers connected to it. In that case, the first switch can receive packets from three different computers on port 5. Then, the switch records each distinct MAC address in its MAC address table, something like this:
Port | MAC Address |
---|---|
1 | 40-20-08-78-84-52 |
2 | 2F-B6-E0-F6-EA-05 |
3 | 21-76-3D-7A-F6-1E |
4 | 63-44-E4-A7-4F-E0 |
5 | 76-2F-F9-C8-B6-08 |
5 | D6-4E-69-86-E9-F7 |
5 | 06-C1-15-A2-BA-60 |
6 | FC-78-B6-07-52-EA |
7 | CD-34-E4-B3-2C-76 |
8 | 1C-FD-E0-63-21-C0 |
The process of building the MAC address table is called learning, and is one of the three basic functions of a switch. The other two are forwarding and flooding, as described in the next two sections.