What is the difference between a hub and a switch?

Title basically sums it up. I’ve been shopping around and I’ve seen 4-port hubs and 4-port switches. What’s the difference?

Sorry. The title should be “difference between a hub and a switch

If a mod is in the neighborhood, could you change my title pleeeeeease?

Basically a hub works at the network’s physical layer. It has no knowledge of higher protocols. Anytime you send something from one hub user to another, the data will actually go to EVERY user connected to the hub. The computers’ network cards sort out which data belongs to which computer. If an unscrupulous user is connected to the same hub as you, he can easily “sniff” your data by putting his network card in promiscuous mode.

A switch operates one layer higher, at the Data Link Layer. When you send something from one switch user to another, the data only travels to that other user, not every single one. Switches are also more likely to be configurable through a web interface, although not all are. The ones that aren’t are called unmanaged switches. Switches eliminate the threat of easy sniffing and tend to be a little faster than hubs if you have many users connected and trying to access resources at the same time.

A router is yet another layer higher (the Network Layer). It has knowledge of IP, thus it can move packets between networks.

Hubs will get you a “shared” connection - meaning that if you’ve got a 10Mbit hub - that means anything that’s plugged into it shares that 10Mbit - plus anybody who’s plugged into the hub can (theoretically) see what everyone else is doing as far as the network is concerned.

A switch… well… gives you a “switched” connection - pretty much the opposite of a hub. If you’ve got a 10Mbit switch, it means everybody can send 10Mbit through their channel, plus they can’t just ‘sniff’ the network to see what everyone else is doing.

A hub is like a “party line”. Every computer on the hub can hear every other computer on the line. Only one computer at a time can speak on the party line, just like on a telephone party line. (another example would be a CB radio channel) When a computer needs to send something it first listens to see if any other computer is talking at the moment. If not, it begins sending. If 2 computers try to talk at the same time, a “collision” happens, and the computers back off for a random amount of time, then try to re-transmit. This is no big deal when you have a small network composed of computers that don’t transfer tons of data. A congested network will have too many collisions and data transfer speeds and response times will suffer. It would be like trying to carry on a conversation with someone across a crowded cafeteria full of other people trying to carry on conversations.

A switch is like a modern phone system. Each computer connected to it has it’s own private line to speak on, and the switch takes care of connecting the sender to the reciever so that they have a private conversation with no one else trying to barge in or eavesdrop.

Switches cost a bit more than hubs because of the increased sophistication of their electronics. They can speed up overpopulated networks. They provide a small increase in network security because it makes it harder for an attacker to simply plug in another computer and listen to everything.

Since you are looking at only a 4-port hub or switch this isn’t really an issue but you can get a greater density of users on a switch than a hub. Since a hub essentially shares a given pipe to all users it is possible to overload it. As a result sufficiently large networks would have to subnet (essentially break into pieces) their infrastructure. While it is possible to overload a switch it is much harder to do than with a hub. As a result it simplifies your network design and operation considerably while improving overall performance.

As you might imagine a switch costs more than a comparable capacity hub but from my view it is money well spent. I won’t use hubs anymore unless the network is fairly small (say under 48 nodes).

Since the word ‘router’ has been mentioned - is a switch the same as a router, except higher up on the hierarchy?

Nah, it’s the other way: Routers are OSI layer 3 (Network Layer), Switches are basically Layer 2 (Datalink Layer).

A switch is a fancy multiport bridge. It eliminates cross-talk traffic: each NIC gets only traffic that is addressed to it, because each line is exclusive - a separate channel. As already stated, you can get a much higher amount of network traffic on a switched network segment than one connected by a hub, because collisions are eliminated on that segment.

Switches only forward packets between NICs. Routers forward packets between networks. Switches know how to find individual machines on a single network segment. Routers know how to find other networks.