0
In this post we are going to see how the switches learns MAC address and Forwards,Filters the frames in Layer 2.

Create a topology like this,

How the Switch Learns MAC Address Forwards Filters Frames
Configure ip addresses for all host like i have given in topology,

Click on PC0-->Config-->Fastethernet 0 and Enter IP address and Subnetmask

PC-0
IP-10.0.0.10
Subnetmask-255.0.0.0

PC-1
IP-10.0.0.20
Subnetmask-255.0.0.0

PC-2
IP-10.0.0.30
Subnetmask-255.0.0.0

PC-3
IP-10.0.0.40
Subnetmask-255.0.0.0


we can also see the MAC address of the host's on that window.Now go to Switch Check the MAC address table in Swith by giving this command,


Switch#show mac-address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----




MAC address table is empty,now go to the host 10.0.0.10 and ping host 10.0.0.30

Click on PC0-->Desktop-->Command Prompt ,give this command 'ping 10.0.0.10' and hit enter.


PC>ping 10.0.0.30

Pinging 10.0.0.30 with 32 bytes of data:

Reply from 10.0.0.30: bytes=32 time=1ms TTL=128
Reply from 10.0.0.30: bytes=32 time=0ms TTL=128
Reply from 10.0.0.30: bytes=32 time=0ms TTL=128
Reply from 10.0.0.30: bytes=32 time=0ms TTL=128

Ping statistics for 10.0.0.30:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms




Switch#show mac-address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0001.4232.090a    DYNAMIC     Fa0/3
   1    0040.0bb9.a7cc    DYNAMIC     Fa0/1


Let me explain how switch learned this MAC address,

Once we press enter to ping the ip address, PC will send the packets to switch,switch receives the packets through the interface fastethernet0/1 and it will read the Source MAC address from the frame.Now switch will check the MAC address table whether this MAC address already present or not,If this is MAC address not present in the MAC address table then it will add this physial address to the table with appropriate port address.Then it will check the Destination MAC address it will be like this '0000.0000.0000' (because this the first time we ping so PC doesn't know the destination MAC address,so the address will be zero next time mac address will be added from arp table).Now switch will send this frame out on all ports because it is unknown unicast address.

Now,all host will receive this packet and every host will check the destination MAC address if it is it's address it will reply to the host otherwise it will drop it,this is unknown unicast frames right, the MAC address will be all Zero's.Now, the host will check the destination IP address,if the destination IP address is matched host's IP address it will reply to the host otherwise it will drop it.

Now,the host 10.0.0.20 and 10.0.0.40 will drop this frames and host 10.0.0.30 will reply to 10.0.0.10 with source MAc address '0001.4232.090a' and the destination address '0040.0bb9.a7cc' of host 10.0.0.10.In the meantime switch waiting for the reply from any host.Now the host 10.0.0.30 sends packets to the switch,now switch get packets from interface fastethernet0/3 learns the MAC address of host 10.0.0.30 and it will check the destination address.It was already present in the table so it will not broadcast the frames out in all ports it will  forward the packet through interface fastethernet 0/1 to host 10.0.0.10.

How the Switch Learns MAC Address Forwards Filters Frames





Now ping from the host 10.0.0.20 to 10.0.0.40 and check the mac address table of switch.

PC>ping 10.0.0.40

Pinging 10.0.0.40 with 32 bytes of data:

Reply from 10.0.0.40: bytes=32 time=2ms TTL=128
Reply from 10.0.0.40: bytes=32 time=0ms TTL=128
Reply from 10.0.0.40: bytes=32 time=1ms TTL=128
Reply from 10.0.0.40: bytes=32 time=0ms TTL=128

Ping statistics for 10.0.0.40:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 2ms, Average = 0ms


Switch#show mac-address-table 
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----

   1    0001.4232.090a    DYNAMIC     Fa0/3
   1    0010.1102.3684    DYNAMIC     Fa0/2
   1    0040.0bb9.a7cc    DYNAMIC     Fa0/1
   1    00e0.f97d.1941    DYNAMIC     Fa0/4



That's it!!!....

Post a Comment

 
Top