Switching

Switching in networking refers to the process of forwarding data packets between devices within a local area network (LAN). It is a fundamental function of network switches, which are devices that connect multiple devices (such as computers, printers, and servers) within a LAN and enable them to communicate efficiently.

Switches operate at Layer 2 (Data Link Layer) of the OSI model, although some advanced switches (called multilayer switches) can also operate at Layer 3 (Network Layer).

Key Concepts of Switching

  1. MAC Addresses:

    • Switches use MAC (Media Access Control) addresses to identify devices on a network.

    • Each network interface card (NIC) has a unique MAC address.

  2. Forwarding Decisions:

    • Switches make forwarding decisions based on the destination MAC address in the Ethernet frame.

    • They maintain a MAC address table (also called a CAM table) that maps MAC addresses to the switch ports.

  3. Unicast, Broadcast, and Multicast:

    • Unicast: Data is sent to a specific device.

    • Broadcast: Data is sent to all devices in the network.

    • Multicast: Data is sent to a group of devices.

How Switching Works

  1. Learning:

    • When a switch receives a frame, it examines the source MAC address and associates it with the port on which the frame arrived.

    • This information is stored in the MAC address table.

  2. Forwarding:

    • When a switch receives a frame, it checks the destination MAC address.

    • If the MAC address is in the table, the switch forwards the frame only to the corresponding port.

    • If the MAC address is not in the table, the switch floods the frame to all ports (except the one it came from).

  3. Filtering:

    • If the destination MAC address is on the same port as the source, the switch drops the frame (this prevents unnecessary traffic).

  4. Loop Prevention:

    • Switches use protocols like Spanning Tree Protocol (STP) to prevent loops in the network, which can cause broadcast storms.

Types of Switching

  1. Store-and-Forward:

    • The switch receives the entire frame, checks it for errors, and then forwards it.

    • This method is reliable but introduces some latency.

  2. Cut-Through:

    • The switch starts forwarding the frame as soon as it reads the destination MAC address.

    • This method is faster but does not check for errors.

  3. Fragment-Free:

    • A compromise between store-and-forward and cut-through.

    • The switch checks the first 64 bytes of the frame (where most errors occur) before forwarding.

Benefits of Switching

  1. Improved Performance:

    • Switches reduce collisions by creating dedicated communication paths between devices.

    • They provide full-duplex communication, allowing simultaneous sending and receiving of data.

  2. Efficient Use of Bandwidth:

    • Switches forward traffic only to the intended recipient, reducing unnecessary traffic.

  3. Scalability:

    • Switches allow networks to grow by connecting multiple devices and segments.

  4. Enhanced Security:

    • Switches isolate traffic between devices, making it harder for unauthorized users to intercept data.

Switching vs. Routing

Feature

Switching

Routing

OSI Layer

Layer 2 (Data Link Layer)

Layer 3 (Network Layer)

Addressing

Uses MAC addresses

Uses IP addresses

Device

Switch

Router

Scope

Within a LAN

Between different networks (WAN)

Forwarding Decision

Based on MAC address table

Based on routing table

Broadcast Handling

Forwards broadcasts within the LAN

Blocks broadcasts by default

Types of Switches

  1. Unmanaged Switches:

    • Basic switches with no configuration options.

    • Plug-and-play devices.

  2. Managed Switches:

    • Advanced switches that can be configured and monitored.

    • Support features like VLANs, QoS, and STP.

  3. Layer 2 Switches:

    • Operate at the Data Link Layer and use MAC addresses for forwarding.

  4. Layer 3 Switches:

    • Combine the functions of a switch and a router.

    • Can perform routing based on IP addresses.

  5. PoE Switches:

    • Provide Power over Ethernet (PoE) to devices like IP cameras and VoIP phones.

Example of Switching in Action

Imagine a small office network with the following devices:

  • Computer A (MAC: 00:1A:2B:3C:4D:5E) connected to Port 1.

  • Computer B (MAC: 00:1A:2B:3C:4D:5F) connected to Port 2.

  • Printer (MAC: 00:1A:2B:3C:4D:60) connected to Port 3.

Step 1: Learning

  • When Computer A sends a frame to the Printer, the switch learns that 00:1A:2B:3C:4D:5E is on Port 1.

  • When the Printer responds, the switch learns that 00:1A:2B:3C:4D:60 is on Port 3.

Step 2: Forwarding

  • If Computer B sends a frame to the Printer, the switch checks its MAC address table and forwards the frame only to Port 3.

Last updated