Ethernet Hubs vs. Switches
Here's a crash course in your choices for Ethernet connectivity--what are hubs, routers and switches, and when should you use which?
by Phil Hughes
I recently was explaining to a friend some information on Ethernet connections and realized I should share it with TUX readers as well. Although this article is in no way Linux-specific, the information it presents is likely to be useful to anyone who has multiple computers.
If you have anything more than one computer with a dial-up phone connection, you likely have your computer connected to other equipment using Ethernet. Your setup could be as simple as one computer connected to a cable modem or DSL modem using Ethernet. If you have multiple machines, you either have a router with multiple ports (Ethernet connectors), a switch or a hub. If you have a router, it's simply a special case of being either a switch or a hub. So, really, there are only two things to talk about here--switches and hubs.
The first thing you should know is Ethernet allows multiple connections to what you might call a common wire. In early Ethernet implementations, "common wire" wasn't only a descriptive term, it was how connections actually worked. That is, each computer tapped into this single wire.
There were many downsides to this connection method, however, so modern Ethernet consists of discreet cables connecting each piece of equipment to fancy junction boxes. These boxes are called either hubs or switches. Each is a lot more than merely a box where wires connect together, but they function quite differently. The hub is the oldest, so let's look at it first.
The hub comes the closest to being an ordinary junction box. It has electronics to deal with signal levels and collision detection, but it really does no more than pass along what it receives to all the other ports (connections) on the hub.
A switch, on the other hand, is more intelligent. It is selective about where it passes data. That is, it learns (or is told) where certain equipment is located and passes along the data only to the ports that need to receive it. The big advantage here is if you have a busy network where not all of the traffic is destined for a particular connection--a server, for example. In this situation, the switch allows multiple interactions at once. For example, if your Internet connection is on port 1 and your server is on port 5, the traffic from a local machine on another port, say 3, to the Internet appears only on ports 1 and 3. Therefore, this traffic does not interfere with traffic to your server on port 5 from other machines.
You probably are thinking now that a switch is always the best answer. That is, if the slight additional cost of a switch is not an issue, you may be thinking you should just buy a switch. In truth, however, a switch is not always the best answer.
Let's consider an example in which you have a few local machines that use only the Internet connection. That is, there is no communication between the local machines. In this situation, all the traffic would be connecting to port 1, so there would be no advantage to having a switch in this setup. In fact, in this situation, there is an actual disadvantage to having a switch. In order for a switch to be intelligent about where it sends data, it has to receive and understand the data. That means it must wait until a complete routable data block is received. It then must read the header information and decide where to send it. Thus, a switch introduces a delay before forwarding the data.
Many compromises are possible here, such as switches that can be managed. That means you can tell them specifically how to handle the data. This may be an attractive consideration for high-end networks, but it's a topic better left to a more technical forum. For the average TUX reader, you most likely will be choosing among small, low-end switches and hubs that do not offer these fancy features. This also means you don't have to figure out how to use them.
One other topic I would like to discuss is auto-negotiation, which is when a hub or switch senses the speed of the devices. Typically, low-end hubs and switches work with 10Mbit (10 million bits per second) and 100Mbit Ethernet. Auto-negotiation in this aspect means sensing the speed on each port. One consideration here is if you have devices of different speeds connected. If this is your situation, you pretty much are in the realm of needing a switch, as the data must be saved and converted to the new speed.
Another auto-sensing feature is polarity. An Ethernet cable has a transmit pair and a receive pair. In order tor two devices to talk, the transmit pair of one device must be connected to the receive pair of the other device and vice versa. This used to put you in the realm of needing crossover cables, which are cables that reverse the transmit and receive connections.
To get around this confusing situation, most modern hubs and switches sense the signals on each cable and internally connect the right pairs. That is, it all works without human intervention. This feature alone can save you a lot of time and headaches.
That's it in a nutshell. Many books have been written on the topic of Ethernet and networking, and a lot more could be said. This article is not intended to replace one of those books--just to get you on the right track.