what is the difference between switch,hub,router and gateway?
A device that determines where to send a data packet between at least two networks. Its decision is based on its current understanding of the networks. A router maintains a table of the available routes and their conditions. It uses this table together with distance and cost algorithms to determine the best route for a given data packet. Data packets often travel through a number of networks and routers before arriving at their destination.
A device that directs data packets along a path. It may include the function of a router. In general, a switch is a simpler and faster mechanism than a router as it does not maintain knowledge of the networks. A switch is not always required in a network. Many LANs are organised so that the nodes inspect each data packet
A hub is a central connecting device in a network. Data arrives at the hub from one or more devices and is forwarded out using just one cable. For example, four cables from three computers and a printer are connected to a hub and then a single cable connects the hub to a server. A hub can also include a router. Most hubs were originally passive. The data simply passed through the hub without any change.
A combination of hardware and software to link two different types of networks. This usually involves converting different protocols. For example, a gateway could be used to convert a TCP/IP packet to a NetWare IPX packet.