Router:
works on third layer i.e Network Layer.
Does path selection, routing etc.
Creates multiple collision domail and multiple broadcast
domain.
Switch:
works on second layer i.e datalynik Layer.
Does framinng.Error Detection etc.
Each port on the switch has a seperate collision domain.
It has single broadcast doamin and multiple collision
domain.
Hub:
It works on physical layer.
It simply forwards the data to each port of it.
Its a non intelligent device.
Has Single collision Domain and single broadcast domain.
Hub
A common connection point for devices in a network. Hubs are commonly used to connect segments of a LAN. A hub contains multiple ports. When a packet arrives at one port, it is copied to the other ports so that all segments of the LAN can see all packets.
Switch
In networks, a device that filters and forwards packets between LAN segments. Switches operate at the data link layer (layer 2) and sometimes the network layer (layer 3) of the OSI Reference Model and therefore support any packet protocol. LANs that use switches to join segments are called switched LANs or, in the case of Ethernet networks, switched Ethernet LANs.
Router
A device that forwards data packets along networks. A router is connected to at least two networks, commonly two LANs or WANs or a LAN and its ISP.s network. Routers are located at gateways, the places where two or more networks connect. Routers use headers and forwarding tables to determine the best path for forwarding the packets, and they use protocols such as ICMP to communicate with each other and configure the best route between any two hosts.