Share

If you were to line up a hub, a switch and a router next to one another, at first glance you might think they look pretty much the same. While they do have some basic functionality in common, they are in fact very different beasts. If you can't tell your routers from your hubs, please read on -- this column is for you.

Let's start at the bottom of the networking food chain - the hub. This basic device joins network computers together to form a single network segment. They're called hubs because they sit at the centre of a network, connecting to PCs via cables that radiate out, similar to wheel spokes. All the computers on a network segment are able to 'see' and communicate with one another.

To get techie, hubs are Layer 1 devices in the OSI (Open System Interconnection) networking model.

A hub simply receives incoming network data (known as frames) and broadcasts them back out to all the attached devices on the network, which includes, somewhat redundantly, the one that originally sent the frame. Because the hub lacks any sort of intelligence, it doesn't know which specific port a frame ought to be sent to.

Broadcasting the frame to every single port will at least guarantee that each frame will reach its intended destination. So it's fair to say that hubs are fairly dumb.

Because hubs are easy on the pocket and simple to set up, they remain an entry-level device for connecting a few PCs. Note that if you run out of network ports on a hub, you can daisy-chain a second hub by connecting via the 'uplink' port.

Modern hubs are 'auto-sensing' and you can use any port for this task. But hubs are on the way out, increasingly replaced by switches, which are much more efficient when it comes to using network bandwidth.

Make the switch
If you're looking for a more efficient networking solution then you need a switch, which operates one level higher than the hub, at the Data Link layer, or Layer 2. Switches are similar to hubs, but they do have an ounce of intelligence. They are a little bit dearer and a heck of a lot faster.

Unlike hubs, switches inspect each data packet as it's received, working out the source and destination of that packet and then forwarding it on correctly. Switches use the MAC (Media Access Control) addresses of each network device attached to it to help find the destination. The MAC address is a unique 16-character ID that is hard-wired into every card.

In effect a switch creates a temporary dedicated link between the sender and the recipient, similar to a switched telephone circuit.

By delivering each packet of data to the specific device it was intended for, a switch makes more efficient use of network bandwidth and thus offers superior performance to a hub.

Another advantage: data collisions. These occur when network PCs try to broadcast at the same time, and these 'data crashes' slow down network performance dramatically. The good news is, with the switch now in charge of controlling the traffic, collisions are eliminated. And no collisions means there's no need to detect collisions as hubs have to. So the switch can eliminate the CSMA/CD (carrier-sense multiple-access with collision detection) media access method, which in turn speeds throughput.

Another benefit of using switches stems from the fact that they support full-duplex or two-way simultaneous communication. The networking default is the slower half-duplex, where you can either send or receive data, but not do both simultaneously.

In effect using full-duplex doubles your network bandwidth.

You'll benefit from a switch over a hub if your network has four or more PCs, or if you want to use your network for applications that generate significant amounts of network traffic, such as multiplayer games or heavy multimedia file sharing.

The best route
With hubs using Layer 1 and switches using Layer 2, you might surmise that routers use Layer 3, the network layer of the OSI model. And you'd be right. A router works similarly to a switch, but can go one step further and send packets to their destination across an 'internetwork' -- other networks or the Internet -- a process known as routing.

To route packets to other networks, the router communicates with other routers using routing protocols. It uses this information to create and maintain a routing table.

The routing table consists of a list of optimal predefined routes to certain network destinations, plus data known as 'routing metrics' associated with those routes. Last but not least, the routing table contains the path to the next router 'upstream.'

The router examines incoming data and is able to determine its destination address. It then refers to its 'routing table' to work out how it is to get there. Routers don't rely on MAC addresses to determine the destination of data, they use the software-configured network address to make routing choices. This approach makes routers more functional than switches, but at the same time it makes them more complex. They need to have a greater intelligence.

One benefit of routing is that it enables network traffic, either incoming or outgoing, to be filtered based on the IP addresses of senders and receivers. A router will analyse each packet to see what type it is. So a router will then send SMTP or POP3 packets to a specific port, such as 25 or 110. Or you can have HTTP packets sent to another port, such as port 80. And so on.

Most home or small office routers are multifunction devices, combining a switch, firewall, DHCP (dynamic host configuration protocol) server and Network Address Translator. Many incorporate a Wi-Fi access point, too. Most general-purpose routers have a separate Ethernet port for the WAN (wide area network) connection, be that a cable set-top box or a WiMax wireless connection.

A common router variant is the ADSL router, which combines a router with an ADSL modem which greatly simplifies connecting to a WAN. Instead of a WAN port, it has a phone socket for the ADSL line. As a result, the ADSL router is strictly a one-trick pony - you couldn't, for example, use it to connect to a cable modem.