Friday, 26 May 2017

Broadcasting

  No comments

In my earlier post, I explained about the limited broadcast address and directed broadcast address. Now let's see how they are implemented.

Before we go further there is one important thing we should understand i.e no matter what kind of casting we are doing it is always implemented at data link layer. Had it been implemented at network layer than all the advertisers would have directly advertised onto our computers while no one stopping them.

Implementation of Limited Broadcasting:

Limited broadcasting is used in situations where a host wants to send some data to all the hosts in his/her local network. To do that it creates a broadcast packet at its end. The structure of the packet looks something like this.



Data
Src_port
Dest_port
Src_IP
Dest_IP
Src_MAC
Dest_MAC




“Hello”
8000
8080
178.113.89.20
255.255.255.255
E4:78:A8:9D:34:67
FF:FF:FF:FF:FF:FF


This is the actual content that is transmitted inside the packet when we use LBA. But the question arises how do the nodes on the way realise that the packet is LBA or DBA? 


Whenever the packet reaches the NIC of the node, it immediately looks into the destination IP and finds out that it is 255.255.255.255 which is LBA and accepts the packet, read its content and then forwards it. When the packet reaches the default router (beyond which the internet starts), the router looks into the destination IP and it too finds out that the packet is limited broadcasted packet and is not to be forwarded. It reads the content of the packet and then destroys the packet. 


Since routers and gateways are layer 3 and layer 5 devices so they can look into the packet till network layer and find out the IP addresses but how does a switch come to know that the packet is limited broadcasting packet?


This is where the MAC addresses come into the picture. Since the switch is a layer 2 device (that means it can look only till data link layer) it can only look at the MAC address in the packet. So when a switch encounters a limited broadcasting packet it looks at the MAC address if the MAC is all F's then it understand that the packet is to be forwarded to all the ports or else it forwards it to a dedicated port.

Implementation of Directed broadcasting:


Limited broadcasting is a simple task since it involves forwarding of a packet in the same network but Directed broadcasting involves some overhead. Directed broadcasting is used when a host wants to deliver some data to all the hosts of some other network. The structure of a directed broadcasting packet is as follows:


Data
Src_port
Dest_port
Src_IP
Dest_IP
Src_MAC
MAC of default router



“Hello”
8000
8080
178.113.89.20
134.23.255.255
E4:78:A8:9D:34:67
F4:78:A8:4D:39:60


When the message is created at source the destination IP is set as DBA (All host id bits are set as 1). And destination MAC is set as the MAC address of the default router or the nearest router. If we had set the destination MAC as all 1's it would have been discarded by the router. 

So when the packet travels through the local network, all the nodes have a look at the packet. After looking at the destination IP they decide that the packet is not for them and forwards it. When the packet reaches the default router it looks at the destination MAC address and finds out that it is his address. Now there could be two possibilities 

  • The packet is actually for him and need not be forwarded.
  • The packet is a directed broadcast packet and needs to be forwarded in the network.

To overcome this dilemma it looks at the destination IP and finds out that it is a Directed broadcast address and so the packet needs to be forwarded. Now router destroys the current packet keeping safe all the essential data and creates one new packet. In this packet, it keeps everything same but the source IP, source MAC and the destination MAC changes.


In the above diagram when the packet reaches router R1, the new packet content is:

“Hello”
8000
8080
188.103.89.90
134.23.255.255
F4:78:A8:4D:39:60
A4:78:A8:4D:40:66

The source IP changes to IP address of the router(R1), source MAC changes to MAC address of the router and destination MAC changes to MAC address of the next router(R2). Destination IP remains same till it reaches the default router of the network to which the message is to be delivered.

Now when the packet reaches the router R2 it finds out that the packet is for the network of which it is the default router so the router now changes the content of the packet as if the packet is a Limited broadcasting packet. 

“Hello”
8000
8080
168.213.99.80
255.255.255.255
A4:78:A8:4D:40:66
FF:FF:FF:FF:FF:FF

So finally when the packet goes inside the targeted network it is considered as the Limited broadcasting packet and it is delivered to all the hosts in the targeted network. And since it is Limited broadcasting packet it is not forwarded by other routers.

Hope this was helpful. Leave your questions, answers & suggestions in the comment section below. And make sure to like us on Facebook and follow on Google+.

No comments :

Post a Comment