Networking - Switching in Networking

1. What is Switching in Networking?

Switching is the process of forwarding data packets within a local area network (LAN) using a network switch.

  • A switch is a Layer 2 device in the OSI model (Data Link Layer).

  • It connects multiple devices (computers, printers, servers, etc.) within the same network.

  • Uses MAC addresses to forward data to the correct destination.


2. How Switching Works

When Device A wants to send data to Device B:

  1. Device A sends a frame to the switch.

  2. The switch reads the destination MAC address.

  3. It looks up the MAC address table.

  4. It forwards the frame only to the port where Device B is connected.

This process is called intelligent switching because the switch doesn’t broadcast unnecessarily.


3. Example of Switching

Scenario:

  • PC1 → 192.168.1.10 (MAC: AA:11:BB:22:CC:33)

  • PC2 → 192.168.1.20 (MAC: DD:44:EE:55:FF:66)

  • PC3 → 192.168.1.30 (MAC: GG:77:HH:88:II:99)

All are connected to a network switch.

Step-by-Step Process:

  1. PC1 sends data to PC2.

  2. Switch checks its MAC table.

  3. Finds that PC2 (DD:44:EE:55:FF:66) is connected to Port 3.

  4. Forwards the frame only to Port 3 → PC2 gets the data.

  5. PC3 does not receive the data because it's not the intended recipient.


4. Types of Switching

Switching can be divided into three main types based on how frames are forwarded:

A. Circuit Switching

  • A dedicated communication path is established between sender and receiver.

  • Used in traditional telephone networks.

  • Example: Old landline calls.

Feature Circuit Switching
Connection Type Dedicated path
Delay Low
Use Case Telephony

B. Packet Switching

  • Data is divided into packets.

  • Each packet may take a different route to reach the destination.

  • Used in the Internet.

Feature Packet Switching
Connection Type No dedicated path
Delay Variable
Use Case Internet data transfer

C. Message Switching

  • Whole messages are sent from one device to another.

  • Stored temporarily at intermediate nodes.

  • Slower than packet switching.

  • Rarely used today.


5. Types of Switches

Switch Type Layer Function Example Use
Unmanaged Switch Layer 2 Basic plug-and-play Home networks
Managed Switch Layer 2 / 3 VLANs, security, QoS Enterprise networks
Layer 3 Switch Layer 3 Supports routing + switching Large networks
PoE Switch Layer 2 Powers devices via Ethernet IP cameras, VoIP phones

6. Switching Methods

Switches can forward frames using three different techniques:

Method Description Speed Error Handling
Store-and-Forward Reads the entire frame, checks for errors, then forwards. Slower High
Cut-Through Reads only the destination MAC and forwards immediately. Faster Low
Fragment-Free Reads the first 64 bytes to avoid collisions. Medium Medium

7. Example of MAC Address Table

Port MAC Address Device
1 AA:11:BB:22:CC:33 PC1
2 GG:77:HH:88:II:99 PC3
3 DD:44:EE:55:FF:66 PC2

When a frame arrives:

  • If MAC exists → Send frame to correct port.

  • If MAC doesn’t exist → Broadcast frame to all ports.


8. Diagram of Switching

           ┌────────────┐
   PC1 ────│            │──── PC2
192.168.1.10   Switch   192.168.1.20
   MAC: AA     │            │
           └────┬───────┘
                │
              PC3
         192.168.1.30
         MAC: GG
  • PC1 → Sends data to PC2.

  • Switch → Uses MAC table.

  • Data goes only to PC2.


9. Difference Between Switching and Routing

Aspect Switching Routing
OSI Layer Layer 2 (Data Link) Layer 3 (Network)
Uses MAC addresses IP addresses
Scope Inside a LAN Between networks
Device Switch Router
Example Connecting PCs in office Sending data to the internet

10. Real-Life Example

  • At home, your Wi-Fi router also acts as a switch.

  • When you send a file from your laptop to your printer:

    • The router’s switch uses MAC addresses to forward the data directly.

  • But when you open www.google.com, the router routes data outside the LAN using IP addresses.