What is the difference between a Router and a Switch? ...Jim Thompson
-- | James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | San Tan Valley, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at
formatting link
| 1962 | I love to cook with wine. Sometimes I even put it in the food.
A router connects networks based on layer three information.
A switch is a box of of bridges, and bridges connect exactly two network segments ( collision domains ) together based on layer 2 - MAC addresses.
Routers are (mostly) rule-based - "If this is from 192.168.1.* and it's addressed to 192.168.2.*, send it out the other port" And then there are the Big Routers that are much more complex for backbones. The rules become protocols like OSPF and its descendents.
Switches/bridges "learn" - sending to one registers your MAC address and you will receive any unicasts addressed to you after that.
Networks can grow on common media until utilization hits 1/e. At that point, collisions start to rise exponentially. So they made bridges to buy some collision-avoidance. Then multiple IP networks caused a need for routing.
Modern equipment intermingles and mixes these concepts as per the career requirements of the engineering staff.
And then there are hubs, which are just boxes of amplifiers.
A router operates at the network layer (typically IP), a switch at the data link layer (e.g. ethernet).
A router can only handle specific higher-level protocols; e.g. most routers can only handle IP (typically only IPv4 unless support for IPv6 is explicitly advertised). A switch doesn't care about anything above the link layer, so it will also work with e.g. IPX or NetBEUI or proprietary protocols.
A router can route between different link layers, e.g. between ethernet, token ring, ATM, or PPP over a serial cable. A switch uses the same link layer for all ports.
Routers are almost invariably store-and-forward (i.e. they'll wait until they've received a complete packet before starting to transmit it), switches are often cut-through: they'll start transmitting once they've seen the header and know which port should be used, provided that the output port isn't in use and can operate at the same speed as the input.
Switches have replaced hubs for connecting local groups of computers to each other and to the network. Switches allow for full-duplex communication, reduce collision (A can talk to B at the same time as C talks to D without any collisions between the two "circuits") and don't require speed matching (systems using 10Mbps, 100Mbps and 1Gbps can co-exist on the same segment, whereas a hub forces the entire segment to use a single speed).
A point that was not yet posted is that a router - by design - interconnects two or more DIFFERENT L2 networks, while a switch can only connect multiple SAME L2 networks.
So, if you want to connect a WiFi network, an Ethernet network and a ADSL connection, you will use a router. It will use the Internet protocol to enable the hosts on the three networks to talk to each other.
But if you only need to connect four Ethernet networks together, you can use a switch and it will use Ethernet frames (a sort-of, kind-of L2 protocol) to enable hosts on those networks to talk to each other.
To be able to talk to things on the other side of a switch, it is enough to use the L2 protocol - Ethernet frames. To be able to talk to things on the other side of a router, you must use a L3 protocol - Internet.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.