Came across this question in Quora https://www.quora.com/TCP-IP/What-is-the-main-purpose-of-Data-link-layer-in-TCP-IP-or-OSI-layer.
So what DLL layer does when I know the ip and port from ip and tcp layer?
Actually ip layer just specifies the destination ip. Say if I need to route a packet from a network A to C via network B. A ip address of host in network C will be in the destination ip field of IP header.
The ip layer in the host finds the route from the routing table(use route -n to see the available routes) and sends a ARP request to find the mac address of the host matching the route, then send the packet to the host by placing its mac address in segment header. Now the packet reaches the router of network A. Now the router finds the route for the host in network C from its routing table and place that mac address and send the packet to a router in B network which does the same to push the packet to router in network in C and finally to the destination host.
Routes can have ip only within the same subnet becoz only then arp can send broadcast messages within the subnet and find mac address or else it will be a infinite process to find routes to the ip of the routes specified(Try adding routes to different subnets using route add -n)
So in general ip address is used only to find the routes and its the mac address that actually transmits the packet. The destination ip does not change during transit.
So what DLL layer does when I know the ip and port from ip and tcp layer?
Actually ip layer just specifies the destination ip. Say if I need to route a packet from a network A to C via network B. A ip address of host in network C will be in the destination ip field of IP header.
The ip layer in the host finds the route from the routing table(use route -n to see the available routes) and sends a ARP request to find the mac address of the host matching the route, then send the packet to the host by placing its mac address in segment header. Now the packet reaches the router of network A. Now the router finds the route for the host in network C from its routing table and place that mac address and send the packet to a router in B network which does the same to push the packet to router in network in C and finally to the destination host.
Routes can have ip only within the same subnet becoz only then arp can send broadcast messages within the subnet and find mac address or else it will be a infinite process to find routes to the ip of the routes specified(Try adding routes to different subnets using route add -n)
So in general ip address is used only to find the routes and its the mac address that actually transmits the packet. The destination ip does not change during transit.
Comments
Post a Comment