A hub is typically the least expensive, least intelligent, and least complicated of the three. Its job is very, very simple: anything that comes in one port is sent out to the others. That's it. Every computer connected to the hub "sees" everything that every other computer on the hub sees. The hub itself is blissfully ignorant of the data being transmitted. For years, simple hubs have been quick and easy ways to connect computers in small networks.
A switch does essentially what a hub does, but more efficiently. By paying attention to the traffic that comes across it, it can "learn" where particular addresses are. For example, if it sees traffic from machine A coming in on port 2, it now knows that machine A is connected to that port, and that traffic to machine A needs to only be sent to that port and not any of the others. The net result of using a switch over a hub is that most of the network traffic only goes where it needs to, rather than to every port. On busy networks, this can make the network significantly faster.
A router is the smartest, and most complicated of the bunch. Routers come in all shapes and sizes, from the small four-port broadband routers that are very popular right now, to the large industrial strength devices that drive the internet itself. A simple way to think of a router is as a computer that can be programmed to understand, possibly manipulate, and route the data its being asked to handle. For example, broadband routers include the ability to "hide" computers behind a type of firewall, which involves slightly modifying the packets of network traffic as they traverse the device. All routers include some kind of user interface for configuring how the router will treat traffic. The really large routers include the equivalent of a full-blown programming language to describe how they should operate, as well as the ability to communicate with other routers to describe or determine the best way to get network traffic from point A to point B.
OR
HUB When Ethernet was originally designed it used a single fat coax called a backbone. Individual hosts were physically connected to the backbone. This created a party line. Each host has to listen for the backbone to be idle before it started talking. It is possible more then one host will start talking at the same time, in that case the messages collide making them unintelligible. This condition is detected each transmitter stops talking and waits a variable interval before attempting to talk again. The Ethernet network is called a collision domain, since all devices must wait until the line is clear, and may inadvertently interfere with one another.
When Ethernet was modified to run over Unshielded Twisted Pair (UTP) Category rated wiring the original coax backbone was shrunk within the hub, called a collapsed backbone. Functionally a hub operates exactly as the old coax backbone. The ports on the hub provide a point-to-point connection to the Ethernet interface in each computer. With a hub each node must wait for the network to be idle and detect collisions between multiple nodes.
SWITCH As Ethernet networks grew in speed and size the party line nature was recognized as a performance limitation. Switches eliminate the collision domain and work much like the telephone switching system.
When an Ethernet packet arrives at the switch the destination MAC address is examined and the packet is switched to the proper port. Each Ethernet interface has a Media Access Controller (MAC) 48-bit address assigned by the hardware vendor. The switch remembers which MAC addresses are connected to each port. If the Switch does not know which port to use it floods the packet to all ports. When it gets a response it updates its internal MAC address table.
This means Port A can talk to C at the same time F is taking to B. This greatly increases overall performance even though it does not change the speed of individual connections. Because the collision domain is eliminated connections are able to use full duplex, hosts can transmit and receive at the same time improving performance even more.
ROUTER A router is used to interconnect multiple networks. The Internet is literally Internetwork -- a network of networks. Internet router’s work on IP addresses to determine how best to interconnect the sender to the destination. Because router’s work at the IP layer different physical networks can be interconnected, Ethernet, Token Ring, Sonet, even RS232 serial used for dialup can carry IP packets.
Routers intended for home use include Network Address Translation (NAT). This allows a single address assigned by the ISP to be shared by multiple hosts connected to the local network.