Home  
  Cisco  
  Practice Exams  
  TechNotes  
  - CCNA -  
  - CCSP -  
  - CCIE -  
  TechSims  
  TechLabs  
  Links  
  Forums  
  Blogs  
  Topsites  
  Search the Web  
  Certification Kits
     
  Subnet Calculator  
  Online Degrees  
  Exam Vouchers  
  Free Magazines  

   
   
CCNA TechLab: Layer 2 Switching Basics

In this TechLab, we will go over the essentials of layer 2 switching. Cisco offers a complete line of switches in different series and models, for small LANs to large internetworks. This TechLab pertains to layer 2 switching only.

The Network

The example network we'll be using in this TechLab consists of one layer-2 switch and two PCs. Attach PC1 to the Fa0/1 interface and PC2 to the Fa0/2 interface of the switch. Configure PC1 with the IP address 10.0.0.1 and the default Class A subnet mask (255.0.0.0). Configure PC2 with the IP address 10.0.0.2 and the default Class A subnet mask (255.0.0.0).

Switching

If the two PCs were directly connected to each other they would both be on the same collision domain . This would also be the case if the PCs were connected through a hub. With a switch however, every connection creates an additional collision domain, so in our case, PC1 and PC2 are each in their own collision domain (cd). Both PCs are still in one and the same broadcast domain because they are in the same logical subnet and belong to VLAN1 by default.

Being in their own separate collision domain, the signals, hence the frames, send by one PC cannot collide with signals from the other PC. This also means collision detection can be disabled on the connections between the switch and the PCs, and that they can operate in full-duplex mode.

A hub would simply forward the signal out of all interfaces, except the incoming interface. Unlike a hub, a switch processes the signals it receives up to layer 2 to be able to read the MAC addresses in frame header. Both the source and the destination MAC address play an important role in the switching process. A switch maintains a MAC forwarding table, also known as the CAM (Content Addressable Memory) table. After connecting the switch to at least one other device, the MAC table will be filled with information learned from incoming frames.

When a switch receives a frame, it will consult the MAC table to check whether the source MAC address of the frame is already ‘learned'. If it is not a known address, the switch will add the source MAC to the table and include the interface on which the frame was received. When the switch receives a frame destined for this MAC address, it will know out of which interface it needs to forward the frame based on the entry in the MAC table. If the switch has not learned the destination MAC address of a frame yet, it will forward the frame out of all interfaces, except the incoming interface.

This selective forwarding allows a LAN switch to offer much better network performance than a hub does. In a LAN with a hub, hence a single collision domain, all hosts see all of the traffic send between any hosts. They only process the frames if the destination address is theirs, but it does take up additional space on the media (in this case the cable). In a switched LAN however, given that the addresses are learned, the hosts only receive traffic that is actually destined to them.

As mentioned earlier, the hosts still belong to a single broadcast domain. Hence, broadcasts are sent out of all interfaces.

Note that a switch does not change the contents of the frames it forwards. This means switching is transparent to PCs, they cannot tell whether the frame arrived from another directly connected PC, or through a hub or a switch.

Now let's see how this works in the small switched LAN we created. To do this we are going to use the ping utility on the PCs. This will generate ARP broadcasts and ICMP unicast messages.

> Open the command prompt console for PC1 and enter the command ping 10.0.0.2 (the IP address of PC2).

> Run arp -a in the console for PC1 and notice the entry for the IP to MAC address mapping for PC2. The latter will have an entry for PC1.

The results should be described next:

1. PC1 broadcasts an ARP Request to discover the MAC address for PC2's IP address.
2. PC2 receives the ARP request and adds the entry for PC1 based on the info in the ARP Request
3. PC2 sends an ARP Reply with his own MAC address and IP to PC1
4. PC1 receives the ARP Reply with the requested information (the MAC address of PC2) and now knows what destination address to use for frames destined to PC2, hence can send the ICMP packets (encapsulated in the frames).

Although the results would be the same if the PCs were directly connected (from the PC's perspective), the switch performed several actions the PCs are unaware of.

1. When the switch receives the ARP Request broadcast from PC1, it learns PC1's MAC address from the frame header and stores it together with the interface (in this case FastEthernet0/1) in the MAC forwarding table.
2. The destination address of the ARP Request is the broadcast address ffff.ffff.ffff, so the switch forwards it out of all ports except the incoming port.
3. Even if other devices where connected, only PC2 replies with an ARP Reply. When the switch receives this reply frame, it learns the MAC address from PC2 and stores it together with the interface (in this case FastEthernet0/2) in the MAC forwarding table.
4. The ARP Reply is targeted directly to the MAC address of PC1 (which PC2 learned from the ARP Request sent by PC1) and since the switch learned on which interface the target MAC address can be reached in step 1, it will forward the ARP Reply only out of FastEthernet0/1.
5. The switch now learned the MAC addresses and interfaces for both PCs, so when PC1 sends the frames that contain the ICMP packets to PC2, the switch will switch traffic directly between FastEthernet0/1 and FastEthernet0/2. If any other PC or network device were attached to the switch, they wouldn't even notice the traffic and won't have to waste time on reading the frames' header to check if their own MAC address matches the one in the frames.

> Start a console or telnet session with the switch and use the following command to display the contents of the MAC forwarding table:
Switch# show mac address-table

The output should be similar as follows (may be different depending on your IOS version and switch model):

              Mac Address Table
   -------------------------------------------

   Vlan    Mac Address       Type       Ports
   ----    -----------       --------   -----
   All     0014.6922.5440    STATIC    CPU
   All     0100.0ccc.cccc    STATIC    CPU
   All     0100.0ccc.cccd    STATIC    CPU
   All     0100.0cdd.dddd    STATIC    CPU
   1       0f08.0a01.9b54    DYNAMIC   Fa0/1
   1       0f08.0a02.42f9    DYNAMIC   Fa0/2

Total Mac Addresses for this criterion: 26

In addition to the destination address and destination port, the switch stores the Address Type (Dynamic for learned addresses and Static for manually configured static entries) and the VLAN. The interfaces have to belong to the same VLAN for the attached hosts to be able to communicate with each other without a router or layer 3 switch. As you can see in the output above, all interfaces belong to VLAN 1 by default.

The show mac address-table command supports several keywords and options to filter the output. For example, you can add the count keyword to list the number of addresses per VLAN:
Switch#show mac-address-table count

Mac Entries for Vlan 1:
---------------------------
Dynamic Address Count : 22
Static Address Count  : 0
Total Mac Addresses   : 22
Total Mac Address Space Available: 8168

Or, you can specify the MAC address:
Switch#show mac address-table address 0f08.0a01.9b54

Or, you can specify the Interface:
Switch#show mac address-table interface fastethernet0/1

Another common option is to specify the VLAN id:
Switch#show mac address-table vlan 1

Note both show mac address-table and show mac-address-table (an older variant with a dash between mac and address) are accepted as valid commands.

Cisco CCNA Labs – Are you looking for additional Cisco Labs? We have Cisco CCNA Labs, Cisco CCNP Labs and Cisco Video Training that you will bring your Cisco routing & switching skills to the next level. Click Here for more Cisco Training!



Certificationkits.com – Experience the real thing, build your own lab. Free study labs and documents, command lists, router/switch procedures, lab suggestions, and more.


Discuss this Lab here
Back to the list of CCNA TechNotes & Labs
Author: Johan Hiemstra




 
 
 

All images and text are copyright protected, violations of these rights will be prosecuted to the full extent of the law.
2002-2015 TechExams.Net | Advertise | Disclaimer


IT Showcase