Saturday, December 13, 2014

Packet flow with multiples bridges & Routers


We have seen the packet flow when there are multiple bridges,  Now let us expand it bit more by adding one or more routers in between bridges and analyse the packet flow.

I have taken a basic example of two bridges and a router topology for connecting two nodes .


As we can see from above diagram Node1 is connected to Node2 via switch1-Router1-Switch2 . Both the nodes are in different network and hence we need a router to route packets .

To start with we assume Node1 & Node2 are just powered on and they do not have any information about connecting devices ( arp table is empty ).   Now a ICMP packet is being sent from node1 to node2 ( pinging 20.20.20.30 from node1 ) , let us analyse what happens while packet is being sent and received.

  1. When an icmp packet gets trigger from Node1 , it checks the arp table entry for reaching the Node2. As it does not contain any arp entry for node2 it sends an arp request for finding the layer2 information of Node2 . In our case Node1 and Node 2 are not in the same network (which would be a basic L2 forwarding) and hence the arp packet would be sent on default gateway . ( if default gateway is not configured then Node1 cannot know where it has to send arp packet out).
  2. Switch 1 will receive the arp request packet from Node1 . Now  Switch 1 will learn the mac entry corresponding to Node1 ,and creates /updates a mac entry corresponding to Node1.
  3. Now switch 1 will forward the packet on to all of its interfaces except from which it has received the packet .In our case only one interface which is connected to router 1 .
  4. When Router 1 receives the arp request , it checks in its route table if the destination ip address is part of its route table ( Either statically configured route entry or a dynamically learnt route) .
    •  If Router1 finds the route entry corresponding to Node2 it gives reply to arp packet by providing its own mac address for reaching Node2.
    •  If there is not route entry for Node 2 , the packet would be dropped and arp reply will not be sent .
  5. The Arp reply sent by router 1 will be sent back to switch 1 , which intern will send it back to Node1 as it has learned the Node1 mac address during the arp request phase.
  6. While sending the arp reply , Switch 1 will learn the mac address corresponding to Route 1 and creates/updates its mac address table.
  7. Now since Node 1 has got the destination mac address to reach the Node2 ( strictly speaking it is the Router 1 mac address , how ever it is Router 1's job to take it further other side), it sends a ICMP request packet to Node2.
  8. Since bridge1 has learned mac address of Router 1, it forwards the ICMP packet to the interface associated with Router 1.
  9. When an ICMP packet is received at Router 1 , it checks if the destination ip address is its own ip address . If it is its own ip address it would send back the reply for ICMP packet.  In our case it is Node 2 ip address , it would keep ICMP packet aside and send an arp request for finding the layer2 mac address associated with Node2 ( Since it has got Route entry corresponding to Node2 ip address , it would know to which interface it should send the arp request).
  10. Bridge 2 will learn the mac address of Router 1 and forwards the arp request on all of its interfaces except on the received interface (Similar to step 2 &3 ).
  11. Node 2 would respond for the arp request , by providing its layer 2 information (mac address) to reach .
  12. Bridge 2 would learn and update the arp entry for Node2 .
  13. Now Router 1 will send the arp request which it kept aside by changing the destination mac address to the one it has learnt in step 11 and changing source mac address to Router 1's mac address.
  14. Node 2 will respond to icmp request ( bridge 2 would have learnt the mac addresses of node 2 and router 1 by now as similar to step 2&3).
  15. Once Router 1 gets reply for ICMP packet , it will alter the destination mac address to Node1's mac address ( ICMP echo Reply contains the mac address of Router1 from Node2) and source address as router1's mac address.
  16. Bridge 1 will forward icmp reply to Node1 as it has updated its forwarding table while sending the icmp echo request .
  17. Finally at Node1 , we will be having a reply for the ping request we have sent .

If we have multiple routers instead of Router 1 alone , at each router stage source and destination mac addresses would be changed similar to step 9 and 13 . And each router would send arp request for finding the next hop mac address at every stage and keeps it in its forwarding table.

Let us look into some other topic soon !



No comments:

Post a Comment