12.3 How are switching decisions made?
In this section you will have a look at how switches make their switching decisions, using the same demonstration network you used in the previous section. You will again be able to see what the frames of data are doing at each stage, with Packet Tracer running in simulation mode.
Watch the video below, which is about 3 minutes long.
Box _unit7.2.3 How are switching decisions made?

Transcript
In this part we are going to look at how a switch works. Switches work at the Network Access layer of the TCP/IP network model, which means that they use MAC addresses to forward frames of data. Although there are more powerful and advanced switches which use IP addresses and operate at the Internet layer as well, most switches know nothing about the Internet layer and only use MAC addresses to make their switching decisions. This means that normal switches do not generate ARP requests or have anything to do with IP addresses.
When a switch is first powered on, its MAC address table will be empty and will contain no addresses. This can also be simulated by issuing the command clear mac-address-table, which we have done in the Packet Tracer network. The MAC address table is currently empty. To populate the MAC table we must generate some traffic between the PCs. In this case we are going to start with a ping from PC2 to Router0. We have set up a table to the left of the diagram which will show you the current entries in the MAC table of Switch1 at the relevant time. PC2 pings Router0. The packet leaves the PC in an Ethernet frame and enters Switch1 on port FastEthernet0/1. When the switch receives the frame, it looks in the Ethernet frame at the source address in that frame. The address is then added to the MAC table and referenced to the port number the frame came in on. The switch looks in its table to see if the destination MAC address is there. Currently it is not, so the switch forwards the frame out of all ports except the one it came in on. This means that both Router0 and PC3 will receive the frame. Only Router0 will get a match to the destination MAC address; PC3 will ignore it completely. When Router0 replies back, the reply frame will contain its own MAC address as the source address and the destination MAC address of PC2. At this point the switch will look at the incoming frame on Gigabit0/2 and read the source MAC address and add it into the MAC table. It will then look at the destination MAC address and see if there is a match. There will now be a match as the MAC address of PC2 was already added to the table previously. The frame will now be sent out only on the port Fa0/1 and on to PC2.
This is the content of Switch1’s MAC address table, just to show you that the table we created to the left of the screen is genuine. In order to complete the network, we need to generate some traffic from PC3 so that its MAC address can be added to the table of the switch too. PC3 pings the router on 172.16.0.1. The frame arrives at the switch and its source address is added to the MAC table. The destination MAC address is checked against the entries in the table. There is a match for port Gigabit0/2, so the switch will send the frame back out on that port to the router. The ping reply frame will leave the router and enter the switch on Gigabit0/2. The switch will record the source MAC address in the table. Because it’s already there, the table will simply be updated with the time-out counter reset; in other words, the entry is refreshed. The switch will then look up the destination MAC address and find that it matches that of PC3 on port Fa0/2. The frame is then sent out of that port where it will be received by PC3, competing the ping. Here we can see the fully populated MAC address table of the switch.
Activity _unit7.2.5 Activity 5 Test yourself
a.
(a) Yes
b.
(b) No
The correct answer is a.
a.
(a) IP addresses
b.
(b) Postal addresses
c.
(c) MAC addresses
d.
(d) Gateway addresses
The correct answer is c.
a.
(a) Yes
b.
(b) No
The correct answer is a.
Next you are going to revisit an earlier activity that involved a simple network comprising a switch and four PCs.
Activity _unit7.2.6 Activity 6 Try it out
10 minutes
1. Open PT Anywhere [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)] in a new tab or window so you can read these instructions. The ‘spare’ switch and the two PCs at the bottom are for use in step 4 of this activity.
Investigate the network and enter the configuration settings into a copy of the table.
Device | Interface | IP address | Subnet mask | Default gateway |
---|---|---|---|---|
Router0 | G0/0 | – | ||
PC0 | – | |||
PC1 | – | |||
PC2 | – | |||
PC3 | – |
2. From the CLI of the switch have a look at the MAC address table. You should find the table is currently empty. (Hint: to view the MAC address table you will need to use the command show mac-address-table from the privileged executive mode.)
3. Generate some network traffic by sending a broadcast ping from one of the PCs and then have another look at the table. You should now find that the table has been populated.
4. Add a second switch to the work area, with a couple of PCs connected to it, to create a second isolated network. (Use the spare switch and PCs provided at the bottom for this.) Configure these new PCs with suitable IP addresses and add the configuration details to the table you created in step 1.
5. Generate some network traffic on the new network and then have a look at the MAC address table of the new switch.
6. Now connect your new network to the router by adding a link between the router interface G0/1 and the switch.
7. Configure the router interface G0/1 with an appropriate IP address and add this address as a default gateway on both of the new PCs. Once again, add the configuration details to the table you created in step 1.
8. Try to ping between networks.
9. Examine the routing table from the CLI of the router. Can you see the connected networks (C)? And the IP addresses of the router interfaces (L)? (Hint: use the command show ip route from the privileged executive mode.)
Answer
1. Your table should look like this.
Device | Interface | IP address | Subnet mask | Default gateway |
---|---|---|---|---|
Router0 | G0/0 | 192.168.2.1 | 255.255.255.0 | – |
PC0 | – | 192.168.2.10 | 255.255.255.0 | 192.168.2.1 |
PC1 | - | 192.168.2.11 | 255.255.255.0 | 192.168.2.1 |
PC2 | - | 192.168.2.12 | 255.255.255.0 | 192.168.2.1 |
PC3 | - | 192.168.2.13 | 255.255.255.0 | 192.168.2.1 |
2. If there were any entries in the MAC address table, you may have accidentally generated some network traffic. You can clear the MAC address table with the command clear mac-address-table.
3. The broadcast address for this network is 192.168.2.255 . You should have seen replies come in from each of the other three PCs and that the MAC address table now has five entries – one for each of its connected interfaces.
4. You could have chosen any private IP addresses for the two new PCs but, of course, they should both belong to the same network. For example, 192.168.8.10 and 192.168.8.11.
5. Again, you need to use the broadcast address for this network. For the example IP addresses given above, this would be 192.168.8.255. Once again, your ping should have populated the switch’s MAC address table.
6. Router interface 0/1 needs to be configured with a suitable IP address which will be the same for the PCs’ default gateways. For the example IP addresses given above, this would be 192.168.8.1. Using these example IP addresses, the complete configuration table would be:
Device | Interface | IP address | Subnet mask | Default gateway |
---|---|---|---|---|
Router0 | G0/0 | 192.168.2.1 | 255.255.255.0 | – |
PC0 | – | 192.168.2.10 | 255.255.255.0 | 192.168.2.1 |
PC1 | – | 192.168.2.11 | 255.255.255.0 | 192.168.2.1 |
PC2 | – | 192.168.2.12 | 255.255.255.0 | 192.168.2.1 |
PC3 | – | 192.168.2.13 | 255.255.255.0 | 192.168.2.1 |
PC4 | – | 192.168.8.10 | 255.255.255.0 | 192.168.8.1 |
PC5 | – | 192.168.8.11 | 255.255.255.0 | 192.168.8.1 |
Router0 | G0/1 | 192.168.8.1 | 255.255.255.0 |
7. If your ping between the two networks was unsuccessful, it may have been because the default gateways on the PCs were not correctly set.