Routers and switches are both computer networking devices
that allow one or more computers to be connected to other computers, networked devices, or to other networks.
The functions of a router, switch and hub and are all different,
even if at times they are integrated into a single device.
Routers connect two or more logical subnets,
which do not necessarily map one-to-one to the physical interfaces of the router.
The term layer 3 switch often is used interchangeably with router,
but switch is really a general term without a rigorous technical definition.
In marketing usage, it is generally optimized for Ethernet LAN interfaces
and may not have other physical interface types.
A router is a networking device that connects computer networks,
for example, connecting a home network with the Internet.
Routers are the workhorses that transfer packets of data between networks
to establish and sustain communication between two nodes in an internetwork.
Routers operate at Layer 3 (network layer) of the OSI model;
a router uses the destination IP address in a data packet
to determine where to forward the packet.
A network switch connects devices together on a single computer network.
A switch is also called switching hub, bridging hub, or MAC bridge.
Switches use MAC addresses to forward data to the correct destination.
A switch is considered a Layer 2 device, operating at the data link layer;
switches use packet switching to receive, process and forward data.
Network hubs — also called repeaters — are even less advanced that switches;
while a hub broadcasts the same data to all its ports,
a network switch forwards data only to those devices that the data is intended for.
Network hubs do not manage any traffic coming through them;
they only broadcast — or repeat — packets from an incoming port to all other ports.
A router is a more sophisticated device than a switch.
Traditional routers are designed to join multiple area networks (LANs and WANs).
Routers serve as intermediate destinations for network traffic.
They receive TCP/IP packets, look inside each packet to identify the source and target IP addresses,
then forward these packets as needed to ensure the data reaches its final destination.
In addition, routers often perform network address translation (NAT),
which allows all devices on a subnetwork (e.g., all devices in a home) to share the same public IP address.
Finally, routers that include built-in firewalls improve the network's security.
A network switch is a small
hardware device that joins multiple computers together within one
local area network (LAN).
Switches are incapable of joining multiple networks or sharing an
Internet connection.
A home network with a switch must designate one computer as the gateway to the
Internet,
and that device must possess two network adapters for sharing,
one for the home LAN and one for the Internet WAN.
With a router, all home computers connect to the router equally,
and it performs the equivalent gateway functions.
The following video compares hubs, switches, and routers.
Routers can connect wired or wireless (WiFi) networks.
A switch is used for wired networking connections.
Routers are more sophisticated devices that can have software
to increase network throughput using techniques such as caching.