IP Packet Traverse along the Router and Switch

Answered Question
Dec 11th, 2007

I have been wondering for a long time how the IP Packet will traverse from end host to a L2 switch to next hop and another routers and finally to another end of a host. What is the source & destination IP address,MAC address along the traversal of the packet?

I have this problem too.
0 votes
Correct Answer by Jon Marshall about 9 years 1 month ago

Hi Michael

Excellent explanation. The only thing i would add is when it gets to the default-gateway router.

Before the router resorts to it's default route (if indeed it has one) it will consult it's routing table to find the longest match on the destination host.

If it doesn't have an explicit entry for that subnet and assuming normal routing procedures and ip classless is turned on then it will use the default route.

Edit - oops one more thing.

Step 1 with the router. If the router forwards the packet onto another router then the source MAC is the exiting interface, the destination MAC is the interface on the next hop router that receives the packet.

The IP source and destination will always stay the same.

Jon

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Loading.
bvsnarayana03 Tue, 12/11/2007 - 04:47

The L3 header (src & dst IP add) remain unchanged throughout the transit. However, L2 headers (src & dest mac add) change from hop to hop.

Hi There

If the destination host is on the same subnet as the originating host, then the source IP & MAC will be that of the originator and the destination IP & MAC will be that of the destination host. The packet will not go past the layer 2 switch.

If the destination host is on a different subnet to the originator then the packet will leave the originator with the source IP & MAC of the originator but will have the destination IP address of the destination host BUT the destination MAC of the default gateway.

If the default gateway router is also attached to the subnet that the destination host is on then the router will send the packet out towards the destination host with the source IP address of the originating host BUT the source MAC of the interface on which the packets exits. The packet will have the destination IP address & MAC of the destination host.

If the default gateway router does not have an interface on the same subnet as the destination host then it will do one of two things.

1. If a default route is configured on the router, the router will forward the packet to its default router with the source IP address of the originating host, the source MAC address of the exiting interface, the destination IP address of the destination host and the destination MAC of the next hop routers interface.

2. If the default router has no default route configured it will drop the packet.

I hope this is understandable and does not confuse you more amd more importantly I hope this is correct :).

Best Regards,

Michael

Correct Answer
Jon Marshall Tue, 12/11/2007 - 05:05

Hi Michael

Excellent explanation. The only thing i would add is when it gets to the default-gateway router.

Before the router resorts to it's default route (if indeed it has one) it will consult it's routing table to find the longest match on the destination host.

If it doesn't have an explicit entry for that subnet and assuming normal routing procedures and ip classless is turned on then it will use the default route.

Edit - oops one more thing.

Step 1 with the router. If the router forwards the packet onto another router then the source MAC is the exiting interface, the destination MAC is the interface on the next hop router that receives the packet.

The IP source and destination will always stay the same.

Jon

noxkrugger Tue, 12/11/2007 - 08:27

Thanks a lot Michael and John. Right now, you have solved my issue

carl_townshend Sun, 04/06/2008 - 06:16

hi there, am i right in saying that when the packet reaches the interface of the other network, if the layer 2 address is not in the forwarding table of the switch, will the router send an arp request then add to the mac address table ?

Actions

This Discussion