Networking All-in-One For Dummies. Doug Lowe

Чтение книги онлайн.

Читать онлайн книгу Networking All-in-One For Dummies - Doug Lowe страница 32

Networking All-in-One For Dummies - Doug Lowe

Скачать книгу

that comes its way. Even though devices are supposed to ignore packets that aren’t meant for them, there is no way to ensure that they do so.

      Switches to the rescue!

      A switch is essentially an intelligent hub that has the ability to actually look at the contents of the packets it processes and make intelligent decisions about what to do with them. A hub is a layer-1 device, which means that it can do nothing but receive and amplify electrical signals. In contrast, switches are layer-2 devices, which means they can actually inspect the layer-2 packets and act intelligently based on the content of each packet.

      A switch examines the destination MAC address of every packet it receives and forwards the packet only to the port that leads to the packet’s intended destination. Thus, packets aren’t repeated on ports that don’t contain the packets’ destination.

Schematic illustration of a switch knows where to send its data.

      FIGURE 3-2: Unlike a hub, a switch knows where to send its data.

      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.

      Forwarding

      Now that you know about the MAC address table, you should have a good idea of how a switch knows which ports to forward incoming packets to: The switch simply looks up the destination MAC address in the table and sends the packet out through the corresponding port.

      For example, if the switch receives a packet on port 1 intended for MAC address CD-34-E4-B3-2C-76, the switch looks up that MAC address in the table, finds that the MAC address can be reached on port 7, and forwards the packet out to port 7. This process, called forwarding, is the second basic function of a switch.

      It’s important to understand that the switch does not modify the packet in any way prior to sending it. What gets sent out to the destination port is an exact replica of what was received on the incoming port. When the destination device receives the packet, the device has no idea that the packet passed through the switch. In other

Скачать книгу