Multiple Hops and Switching – Ciscco Certifed Support Technici
Note
This section describes what the Spanning Tree Protocol accomplishes and why it is important. The operation of SPT is outside the scope of this book.
A single switch might be useful in some situations, but to build a large network, you are going to need more than one. How do hosts communicate when there are multiple switches in a network, as Figure 3-7 illustrates?
Figure 3-7 A Single Network with Multiple Switches
Suppose host A wants to send a packet to G. We’ll simplify the example by assuming A already knows the mapping between G’s physical and interfaces addresses.
1. Host A will build a packet with G’s destination physical and interface addresses and transmit it.
2. When switch C receives this packet, it will learn A is reachable on port C1.
Assume switches D and E have also received traffic in the past, so D knows G is reachable via port D2, and E knows F is connected to port E3.
Which port will C forward the packet through to reach G? What if
• Switch C chooses to forward the packet through port C3?
• When switch E receives the packet, it decides to forward the packet through E2?
• When switch D receives the packet, it decides to forward the packet through D1?
The traffic would travel around in a loop…forever! To prevent this from happening, switches to need to decide which ports they will forward traffic on, and which packets they will not (which ports they will block).
Spanning Tree Protocol ( STP) is used in most switched computer networks to decide which ports to use and block, preventing loops of this kind from forming. To prevent loops, SPT
• Chooses a root bridge.
• Blocks ports not on the shortest path to or from the root bridge.
The shortest path is chosen based on metrics assigned to each link in the network. While metrics are often assigned based on the bandwidth of each link, all links might also be assigned the same metric, or the network operator might assign metrics based on some other method.
Note
Why use the shortest path? Because the shortest path can never be a loop. Loops will always contain some part of a given path twice, so they will always be longer than some alternate path that does not loop. The shortest path test is too strict because it eliminates non-looping paths. In advanced routing techniques, the shortest path test is relaxed, and methods are used to discover loop- free paths that are the shortest path. In traffic steering and engineering, packets are carried past the point where they would otherwise loop in tunnels. These techniques are beyond the scope of this book.
If SPT chooses switch E as the root, for instance:
• Switch C’s shortest path to reach E, the root, is through port C3.
Switch C will leave C3 in a forwarding state and block C2, so no traffic will be forwarded through that port.
• Switch D’s shortest path to reach E, the root, is through port D3. Switch D will leave D3 in a forwarding state and block D1, so no traffic will be forwarded through that port.
• Switch E will leave all its ports in forwarding state.
When A sends a packet to G:
• Switch C will forward the packet destined to G through port C3 because this is the only other port that is in a forwarding state.
• When E receives this packet on port E1, it will learn A is reachable through this point.
• Since E does not yet know which port to use when forwarding traffic to G, it will forward the packet out ports E2 and E3.
• Host F will ignore the packet because the destination does not match F’s physical address.
• When switch D receives the packet on port D1, it learns A is reachable through this port.
• Switch D’s only other port in forwarding mode is D2, so it forwards the packet through this port.
• Host G will receive the packet and process it.
In the opposite direction, when host G sends a response to A:
• Switch D will learn G is reachable through port D2.
• Switch D will have a table entry stating A is reachable through port D3, so it will forward the packet through port D3.
• Switch E will have a table entry stating A is reachable through port E1, so E will forward the packet through E1.
• Switch C will have a table entry stating A is reachable through port C1, so it will forward the packet through C1.
• Host A will receive the packet and process it.
Two key points to remember about STP are
• STP builds a tree of the entire network regardless of where each host is and forwards traffic along the tree. For instance, in
Figure 3-7, the shortest path between A and G is through C and D rather than through C, E, and D. The tree may take some packets along the more optimal path and other packets along less-than-optimal paths to prevent loops from forming.
• Any time the topology of the network—the switches and links
—changes, the switches must relearn how to reach each host connected to the network.
Routing Packets
Switches determine where to forward a packet based on physical interface addresses. Because physical interfaces are often called Layer 2 addresses, switches are often called Layer 2 switches or Layer 2 network devices. Routing, on the other hand, uses interface, or IP, addresses to forward traffic through a network.
Figure 3-8 illustrates routing.
Figure 3-8 Routing
Let’s consider what happens in this network when host A sends a packet to G.
1. Host A determines G will not receive any broadcast addresses it sends. Because of this, A cannot use ARP, ND, or any other mechanism to discover G’s physical address.
2. Because host A has only an interface (IP) address to send the packet to, it will send the packet to the default gateway. The default gateway is learned from DHCP for IPv4, learned from RAs for IPv6, or manually configured. In this case, router C is the default gateway.
3. Host A builds the packet with G’s interface address and C’s physical address. It is important for A to build the packet with C’s physical address because routers—unlike switches—do not operate in promiscuous mode. Routers only accept and process packets destined to one of their physical addresses. It is also important for A to build the packet with G’s interface address since router C knows where the packet is ultimately destined.
4. Router C examines its local routing table to determine the next hop toward G. Let’s assume the shortest path through the network toward G, from C’s perspective, is via router D.
5. Router C strips the outer encapsulation (or physical layer header) off the packet and adds a new physical layer header with D’s physical address. Router C leaves G’s address in place as the final interface address so D can determine where to forward the packet.
6. Router D processes the packet because the destination physical address matches one of its local interfaces. D’s routing table indicates G is directly connected through port D2.
7. Router D strips the outer encapsulation and adds a new one with G’s physical address. The interface address remains G’s. D
then transmits the packet on the segment toward G.
If router C does not know the correct physical address for port D1, or router D does not know G’s physical address, they will use the normal protocols and processes described previously to build this mapping—IPv4 ARP and IPv6 ND.
Key points to remember about routing:
• Routers (unlike switches) do not forward packets transmitted to physical broadcast segments. This means traditional mapping protocols like DHCP will not work through a router (although some protocols can be made to work, as described in a later section).
• Two hosts connected only through a router are not on the same segment or broadcast domain. Breaking networks into multiple segments is important for scaling. Imagine if 10,000
hosts were all connected to the same broadcast domain, and each host sent one broadcast packet each second. Every host on the network would need to process 10,000 broadcast packets per second—a huge amount of traffic for very little (or no) gain.
• Hosts send packets directly to the physical interface address of the router, rather than the physical interface address of the destination host or a broadcast address. A router is more like a host in this regard than a switch.
• Routers decide where to send packets based on the interface, or IP, address, rather than the physical address. The table routers use to determine where to forward packets is called the routing table, or the IP routing table.
This description of how routing works leads to other questions, such as
• How is the routing table used to forward packets?
• How is the routing table built?
• What is the difference between a router and a switch?
• What happens inside a router or switch? How do these devices forward packets?
Each of these questions will be discussed in the following sections.
Note
Breaking networks into multiple segments also reduces the size of the failure domain by reducing the scope of broadcast packets. Controlling failure domains falls under network design, and so is outside the general scope of this book.