Originally posted by: Mday
router: assigns IP, also takes an IP
hub: allows computers to communicate with each other across a network with no fancy features
switch: allows computers to communicate with each other across a network with built in implementations to increase efficiency
I will not address how each does their thing. the items above are not mutually exclusive. a router must have switching capabilities. a switch is a hub, but a hub is not a switch.
Uh, more or less correct.
A hub connects multiple computers together so they can talk to each other, but does so without any intelligence. You are limited to half-duplex connections with a hub, and there is no protection against packet collision (both of which can severely degrade performance if several busy systems are attached and working simultaneously).
A switch is a 'smart' hub, which provides each computer attached to it with its own private full-duplex connection. This eliminates packet collisions, and means that two computers connected to the switch and talking to each other won't interfere with, say, another computer connected to the switch but talking to a system out on the Internet.
A router is a switch that includes packet routing capabilities (it's feasable to have a router built on top of a hub, but any router you'll buy today is switched). This means that when packets come in from an outside network, instead of just sending them to all the attached hosts, the router is smart enough to only send them where they need to go. This also applies the other way (if you have multiple uplinks); if multiple routers are connected together, they will send your packets to the right place without spamming them all over your network. Routers are assigned an IP address (usually via DHCP, though they can be manually configured) just like any other system attached to a network, unlike a switch or hub. Most consumer routers also include NAT (Network Address Translation), which allows the router to take a single IP address (from your ISP) and attach a virtually unlimited number of systems to it by providing them with dummy addresses and doing on-the-fly packet manipulation to make external hosts think they are talking to the router when in fact the traffic is being passed through to an internal host. This is usually combined with a firewall to provide a high level of network security, as NAT makes it impossible for an external host to establish a connection with an internal host (since the internal host has no specific external IP address assigned to it).