In order to understand what is the difference between Collision Domain and Broadcast Domain and how having more number of Collision Domain and Broadcast Domain makes a network more efficient we must go through some history lessons.
our first stop will be at HUB,
A hub is a network equipment with several interfaces (also called ports, not to be confused with TCP or UDP ports since these are physical ports where you can connect cables).
All a hub will ever do is to copy electrical signals that are entering one port to all other ports. So whatever a computer sends into the hub will be copied by the hub to all other devices on every other port. This means that a hub is completely unintelligent. It doesn’t care about network traffic or addresses at all. All it does is to copy electrical signals.
Now that we know what a HUB is let us discuss the problems and why we don't use hub now a days. Consider two device in network connected using HUB transmit at the same time.
Here H3 will get a corrupted signal and ask for re-transmission. As number of devices to hub increases the chance of getting collision increases as well which essentially reduces the efficiency of the network. Inorder to deal with the loss of signal the end systems have to come up with schemes to reduces the chance of collision since hub is unintelligent device(all it do is repeat the electrical signal). One of scheme is CSMA/CD.
I will give a simplified idea of what CSMA/CD is.
CSMA/CD is a simple protocol. All computers to the network will listen to see if someone is transmitting. When we want to send something and nobody is transmitting, we can transmit a frame. By doing this also there are chances of collision when CSMA/CD detect collision it will re-transmit the data after a random time delay thus reduces the chances of collision.
A collision domain the part of a network where packet collisions can occur. A collision occurs when two devices send a packet at the same time on the shared network segment. The packets collide and both devices must send the packets again.
What i meant by same collision domain will be clear after reading about Bridge.
Bridge devices work at the data link layer of the Open System Interconnect (OSI) model, connecting two different networks together and providing communication between them. Bridges are similar to repeaters and hubs in that they broadcast data to every node. However, bridges maintain the media access control (MAC) address table as soon as they discover new segments meaning that it uses the MAC address information to make decisions regarding forwarding data packets. Only the data that needs to be sent across the bridge to the adjacent network segment is forwarded. This makes it possible to isolate or segment the network data traffic.
Here is an example of two network connected using bridge.
we can see that our bridge was successfully able to split our network into two collision domain where H1 and H2 belong to same collision domain and H3 and H4 belongs to same collision domain.
Bridges and Switches are pretty similar, both operate at the Data Link layer (Layer 2) and both can filter data so that only the appropriate segment or host receives a transmission.some of the difference between them are
Packet forwarding in Switches are performed using ASICS (Application Specific Integrated Circuits) thus a switch is hardware-based.Packet forwarding in Bridges is performed using the software. Thus bridges are software-based.A Bridge has only 2 ports while a switch can handle many ports.
Up until this point we have only discussed about collision domain its time to introduce broadcast domain and why we need that.
In computer networking, broadcasting refers to transmitting a packet that will be received by every device on the network.Broadcast helps to attain efficiency when a common data stream needs to be delivered to all, by minimizing the communication and processing overhead.
For example, consider ARP protocol.
The Address Resolution Protocol (ARP) is a communication protocol used for discovering the link layer address, such as a MAC address.When a IP packet comes a (layer 3) switch checks whether the destination IP address is in the routing table if it could not find an entry mapping the MAC address with the IP it sends (broadcast) an ARP message to all the connected device asking " Does anyone have this IP " if a node have the particular IP it reply else it ignore. Important point that must be carried from above example is that at most only node will have a matching IP address all other nodes receiving the packet just ignore the message which waste the valuable time for sending and processing the ARP packet.
All the devices we discussed so far has only one broadcast domain that means packets like ARP will be transmitted across all interface.
A router is a device like a switch that routes data packets based on their IP addresses rather than MAC address. Router is mainly a Network Layer device.When a data packet comes in on one of the lines, the router reads the network address information in the packet header to determine the ultimate destination. Then, using information in its routing table or routing policy (is a data table stored in a router or a network host that lists the routes to particular network destination), it directs the packet to the next network on its journey.
A router receives packets from each interface via a network interface. Received packets have all link protocol headers removed. The router uses the information in the IP header to decide whether and where to forward each received packet, and which network interface to use to send the packet. Most packets are forwarded based on the packet's IP destination address , along with routing information held within the router in a routing table. A router does not by default forward a packet with an IP broadcast address.
Let me elaborate on that consider a broadcast frame (we usually call packets at link layer a frame) reaches a switch the frame, being determined as a broadcast, would be forwarded out all interfaces except the one it originated from.
The destination MAC address of broadcast frame will be FF:FF:FF:FF:FF:FF.
what happens when a broadcast frame enters a router ?
the frame gets decapsulated from link layer and passed up to the network layer and destination IP would be 255.255.255.255 (referring to the current network). The router does not forward such packets hence it split the broadcast area (domain).