Layer 2 and Layer 3 switches
IT Pro Guide: You'll find them tucked away in the corners of offices and racked up in server rooms in most organisations, but there's more to the humble switch than meets the eye. Alan Stevens explains
Network switches are often described as Layer 2 or Layer 3. But what exactly does that mean and what are the advantages and disadvantages of the technologies involved?
Why layers?
Switches are used to built networks, linking network devices together and forwarding (i.e. switching) data from one port to another based on information gleaned from the packets being transmitted. Information is organised to conform to the OSI (Open Systems Interconnection) seven-layer model, which is adhered to by networking vendors to insure interoperability between their products.
Hence terms like Layer 2, Layer 3 and so on, which you'll hear used mostly in relation to switches but other networking devices, too.
How Layer 2 switches work
Layer 1, also referred to as the Physical Layer, describes the electrical interface and isn't of much interest to switch vendors. Rather it's to Layer 2 (the Data Link layer) that most switches look when deciding how to move packets around a network. It's here, for instance, that a switch can find the Media Access Control or MAC address of both sending and receiving devices.
Layer 2 switches learn MAC addresses automatically, building a table which can be used to selectively forward packets. For example, if a switch receives packets from MAC address X on Port 1 it then knows that packets destined for MAC address X can simply be forwarded out of that port rather than having to try each available port in turn.
Get the ITPro. daily newsletter
Receive our latest news, industry updates, featured resources and more. Sign up today to receive our FREE report on AI cyber crime & security - newly updated for 2024.
Because Layer 2 information is easily retrieved, packets can be forwarded (switched) very quickly, typically, at the wire speed of the network. Layer 2 switching, therefore, has little or no impact on network performance or bandwidth. And because they are relatively dumb devices no setup or management is required, making them cheap and easy to deploy.
What Layer 2 switches can't do is apply any intelligence when forwarding packets. They can't route packets based on IP address or prioritise packets sent by particular applications to, for example, guarantee bandwidth to Voice over IP users.
The information required for that only starts to become available at Layer 3 (the Network Layer).
Layer 3 advantages
Intelligent packet forwarding (routing) based on Layer 3 information is traditionally the function of routers. It's here that IP addresses are found, for example, enabling a router to link different subnets together. Specialised routing protocols also use Layer 3, enabling routers to "learn" routes between networks.
In recent years, however, that same functionality has also been built into network switches. Routers are still used to forward packets across (relatively) slow WAN (Wide Area Network) connections but on local networks, high-performance Layer 3 switches - sometimes referred to as "switch routers" or "routing switches" - have largely replaced them.
Other intelligence commonly found in Layer 3 switches, includes the ability to logically segment a network into two or more Virtual LANs (VLANs) plus enhanced security controls to prevent unauthorised setup changes. Facilities to prioritise different types of traffic are also commonplace, to provide guaranteed Quality of Service (QoS) when, for example, building converged voice and data networks.
Layer 3 issues
Extra processing power is required to retrieve and make use of Layer 3 information. As a result, early switches could cause bottlenecks; nowadays, most Layer 3 switches operate at full wire speed just like their Layer 2 counterparts.
Prices are higher than for a Level 2 switch because extra processing power and memory is required for Layer 3 switching. Such switches also require setup and management. Most are configured via a Web based GUI, although support for the Simple Network Management Protocol (SNMP) is another common option.
Layer 3 switches can be complex to manage, especially on large distributed networks, but the concepts aren't that difficult and affordable Layer 3 switches are now available for small business deployment.
Which switch?
Small networks can be built using just Layer 2 devices, but most corporate networks will have a mix of Layer 2 and Layer 3 switches. Dumb Layer 2 products are a cheap and easy way of providing connectivity to workgroups while more intelligent Layer 3 switches enable departmental networks to be segmented and controlled with no loss of bandwidth.
Finally, it's worth noting that some switch vendors claim to support Layer 4 (the Transport Layer) and above. Load balancing switches, for example, use information beyond Layer 3 to distribute packets across large server farms. However, there's blurring of the levels in these more sophisticated products such that it's now more usual to refer to them as multi-level switches. Multi-level switches are more expensive and complicated to deploy and mostly reserved for specialist applications.