To clarify...
A
router is a device that seperates two or more networks by IP address (if we're only talking about TCP/IP). Remember that an IP address (or IPX/SPX if we're talking Novell) can be changed, meaning it is a LOGICAL address. Depending on how a router is configured, it can forward requests from one network to another. This brings me to the next description...
A
gateway is basically your last point outside of the internal network to another very different network. In a LAN, this can be a computer from a 192.168.x.x address network trying to access a resource from a 10.x.x.x address network. The router allows for the two different networks to communicate with one another, which causes it to act as a "gateway" for machines on either network to talk to each other even though they have different addresses.
Remember that the Internet is one LARGE network, often referred to as "the cloud" (since we personally don't have information regarding other IP addressed computers on the Internet). Your router can act as a gateway to the Internet cloud, which is why on a 192.168.1.0 private network with a computer having an address of 192.168.1.5 (for example), the gateway would need to be set to whatever the IP address the gateway has internally (192.168.1.1, for example, if that's the internal IP for the router).
The difference between a hub and a switch is the following:
A
hub basically repeats the signal sent from a computer to any other devices connected to the other ports on the hub. This is why a hub is sometimes referred to as a multi-port repeater. Unfortunately, since the connection among all the ports is shared, your bandwidth is reduced by the number of devices you have communicating on each port. So a 100 Mb switch with 2 computers connected to it will be slower than if only 1 computer was connected to it. Those two computers would have an effective 50 Mb of bandwidth if they were sending/receiving data at the same time. You can also experience data collisions which slow down your network even further if a lot of devices are connected to the ports and are constantly communicating.
A
switch is one step up from a hub. A switch also repeats the signal like a hub, but each connection on the port is a point-to-point connection, which means you can fill up all the ports on a switch and still have the optimal bandwidth possible (for example, 100 Mb for each port on a 100 Mb switch if one device is connected to each port). A switch does this by reading what is called a MAC (Media Access Control) address which is physically burned into the hardware of the network card (meaning it can't be changed*). This means that the switch can determine who sent the data and who received it, and send it directly to the receiver without broadcasting the information to other devices that don't need it and causing data collisions on the network. Switches have pretty much replaced hubs today.
* MAC addresses, while not PHYSICALLY changeable, can be spoofed. This means that a device can "lie" about what its MAC address really is. Think of it as an alias for an application....it isn't really the application, but acts as though it is by forwarding the request to launch the application over to the application itself. Similarly, a computer can use software to "lie" about it's MAC address by communicating to others using that fake address while the software forwards any information for that fake address to the real MAC address of the computer.
Hopefully that cleared things up, even though it was a bit extensive...