Switch
Definition
It is a network device that connects multiple devices with the same local area network (LAN).
Unlike routers, a switch only works within a single network and it doesn't route data between different networks.
Functions
Layer 2 vs. Layer 3 Switching
Layer 2 Switches operate at the Data Link Layer of the OSI model.
- They use MAC addresses to forward frames between devices.
- They simply forward traffic within same LAN and cannot route traffic between different networks.
Layer 3 Switches operate in the Network Layer.
- Can perform routing functions, forwarding packets based on IP addresses.
- They are used in larger networks for inter-VLAN routing.
MAC Address Table
Switches maintain a MAC Address Table that maps MAC addresses to specific ports.
When a switch receives a frame, it looks up the destination MAC address in its table and forwards the frame to the appropriate port.
The switch learns MAC addresses as devices send traffic through it.
VLAN Support (Virtual LAN)
VLANs are used to segment a single physical network into multiple logical networks. They allow administrators to group devices together even if they are physicall separated.
VLANs enhance security and improve network performance by isolating traffic.
Trunk Ports are used to pass traffic from multiple VLANs across the same physical link.
Spanning Tree Protocol (STP)
Switches use STP to prevent loops in the network. If multiple paths exist between two switches, STP disables some of the paths to prevent a broadcast storm.
STP ensures only a single active path between devices.
Full-Duplex Communication
Modern switch allow data to be sent and received simultaneously on a single connection.
Switching Methods
Store-and-Forward - switch stores entire frame, checks it for errors, then forwards it -> slower but ensures error-free transmission.
Cut-Through Switching - switch forwards frame as soon as it reads destination MAC address -> faster but less reliable, as it doesn't check for errors in frame.
Port Mirroring
Allows traffic from one or more switch ports to be duplicated and sent to another port.
This is useful for monitoring and troubleshooting network traffic (eg. using a packet sniffer).
Link Aggregation (LAG)
Combines multiple physical links into a single logical link to increase bandwidth and provide redundancy.
If one link fails, traffic can still flow over the remaining links.
Power of Ethernet (PoE)
PoE switches can supply power over ethernet cables to devices like IP phones, cameras, and wireless access points. This eliminates the need for separate power supplies for these devices.
Multicast & IGMP Snooping
Multicast traffic is used to send data to multiple devices simultaneously.
IGMP snooping allows switches to learn which devices want to receive multicast traffic and forward traffic only to those devices, reducing unnecessary bandwidth usage.