Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

How packet reach destination

Folks,

a question to clear my understanding.

When a host send a packet to a destination host, then what it writes in its packet as destination address. It is the gateway or the destination host's IP/MAC address?

If it is gateway address of the host as destination address of the packet, then how the packet arrives to the destination host?

If the host writes destination host's address in the packet, then every hop rewrites MAC/IP during routing & switching. So how the packet arrives to the destination?

9 ACCEPTED SOLUTIONS

Accepted Solutions
Cisco Employee

How packet reach destination

Hi Sugata,

If a host wants to send a packet to a host that is not on the local subnet, the destination IP address is the IP address of the destination host and the MAC address is set to the gateway MAC address.

Regards

Harold Ritter
Sr. Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México
Super Bronze

Re: How packet reach destination

Disclaimer

The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.

Liability Disclaimer

In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.

Posting

ok..so destination IP will be always the final destination hop's IP correct?

Normally yes, except for when the destination IP is "hidden", e.g. NAT.  Even then, sender belives it has the destination's IP.

My another question here is how host know the destination IP? The application of the hop knows that?

The sending host does need to "know" the recipient for unicast (doesn't need to know the recipient for mulitcast or broadcast).

The sending host might have a destination IP or it might have a destination logical name, e.g. FQDN.  If a logical name, it would need to be resolved to an IP address, e.g. DNS.

Purple

How packet reach destination

Hi,

The host does a a binary AND between its IP and mask and between the dest IP and its mask to know if the dst IP is on same subnet or not.

The dest IP is given by the application  on the host and usually derived from a name by DNS.

Regards

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.
Purple

How packet reach destination

Hi,

The destination IP is not set to L3 next hop when the host sends its frame, it sends the frame to the dst MAC of the next-hop corresponding to next-hop IP( default gateway). The destination IP stays the same before and after traversing the router.

Regards

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.
Super Bronze

Re: How packet reach destination

Disclaimer

The   Author of this posting offers the information contained within this   posting without consideration and with the reader's understanding that   there's no implied or expressed suitability or fitness for any purpose.   Information provided is for informational purposes only and should not   be construed as rendering professional advice of any kind. Usage of  this  posting's information is solely at reader's own risk.

Liability Disclaimer

In   no event shall Author be liable for any damages whatsoever (including,   without limitation, damages for loss of use, data or profit) arising  out  of the use or inability to use the posting's information even if  Author  has been advised of the possibility of such damage.

Posting

Hi Joseph,

I need little more clarification here. When a packet travers L3 hops then the IP header is rewritten and destination IP is set as the next hop IP. So how the final destination IP is retained in the packet?

Answered by Alain.  As he noted, the packet's destination IP isn't changed.

Transit devices do use the destination IP to select their next hop (or final destination host).  Again, though, the packet's destination IP is untouched.

Think of a snail mail envelope address.  Destination address doesn't change on envelope as it transits different offices, but each office uses that address to select where to send the envelope next.  The outer transit container (the bag/vehicle) the envelope is within, does change per hop.  (The latter is the purpose of the L2 frame.)

Super Bronze

Re: How packet reach destination

Disclaimer

The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.

Liability Disclaimer

In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.

Posting

as Joseph said, I wonder what will be the destination IP in the packet if both the host are behind NAT Router?

Source or destination IPs will be changed by NAT.  Packet will contain what appears to be "correct" IP based on what side of NAT the packet is currently on.

Super Bronze

Re: How packet reach destination

Disclaimer

The   Author of this posting offers the information contained within this   posting without consideration and with the reader's understanding that   there's no implied or expressed suitability or fitness for any purpose.   Information provided is for informational purposes only and should not   be construed as rendering professional advice of any kind. Usage of  this  posting's information is solely at reader's own risk.

Liability Disclaimer

In   no event shall Author be liable for any damages whatsoever (including,   without limitation, damages for loss of use, data or profit) arising  out  of the use or inability to use the posting's information even if  Author  has been advised of the possibility of such damage.

Posting

NAT will rewrite IP source and/or destination IP.  Normally this isn't "visible" to hosts.

e.g.

host A : 10.1.1.1

Nat A: 1.1.1.1

Nat B: 2.1.1.1

host B: 192.168.1.1

Host A sends packet to host B as source IP 10.1.1.1 dest IP 2.1.1.1

NAT A changes to: source IP 1.1.1.1 dest IP 2.1.1.1

NAT B change to: source IP 1.1.1.1 dest IP 192.168.1.1

i.e. Host A thinks host B's IP is 2.1.1.1 while host B thinks host A's IP is 1.1.1.1

Super Bronze

Re: How packet reach destination

Disclaimer

The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.

Liability Disclaimer

In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.

Posting

Hi My last question is how the host application will know what is the destination IP? I think the application will generate the packet with IP destination address?

See my 2nd posting.

Super Bronze

Re: How packet reach destination

Disclaimer

The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.

Liability Disclaimer

In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.

Posting

ok.. so if the host application doesn't know the IP then it will know FQDN and resolve it to IP. So in this scenario a DNS help shall be required or NATing device also can work as a DNS?

Correct, the sending device has to somehow "know" the address of the recipient.  It might be its IP or it might be by logical name (e.g. supportforums.cisco.com).

If NAT is involved, it may need to also NAT the DNS query and response, but that doesn't mean the NAT device, itself, is doing DNS.

17 REPLIES
Cisco Employee

How packet reach destination

Hi Sugata,

If a host wants to send a packet to a host that is not on the local subnet, the destination IP address is the IP address of the destination host and the MAC address is set to the gateway MAC address.

Regards

Harold Ritter
Sr. Technical Leader
CCIE 4168 (R&S, SP)
harold@cisco.com
México móvil: +52 1 55 8312 4915
Cisco México
Paseo de la Reforma 222
Piso 19
Cuauhtémoc, Juárez
Ciudad de México, 06600
México
Super Bronze

Re: How packet reach destination

Disclaimer

The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.

Liability Disclaimer

In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.

Posting

If the sender and recipient host are on the same subnet, the MAC would be the recipient host's.  If it's a transient L3 hop, the MAC would be for the next hop IP's (whose IP is not in the packet).

Destination IP is doesn't change.  Destination MAC is either next (L3) hop's or final host MAC.

New Member

How packet reach destination

ok..so destination IP will be always the final destination hop's IP correct?

My another question here is how host know the destination IP? The application of the hop knows that?

Super Bronze

Re: How packet reach destination

Disclaimer

The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.

Liability Disclaimer

In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.

Posting

ok..so destination IP will be always the final destination hop's IP correct?

Normally yes, except for when the destination IP is "hidden", e.g. NAT.  Even then, sender belives it has the destination's IP.

My another question here is how host know the destination IP? The application of the hop knows that?

The sending host does need to "know" the recipient for unicast (doesn't need to know the recipient for mulitcast or broadcast).

The sending host might have a destination IP or it might have a destination logical name, e.g. FQDN.  If a logical name, it would need to be resolved to an IP address, e.g. DNS.

New Member

How packet reach destination

Hi Joseph,

I need little more clarification here. When a packet travers L3 hops then the IP header is rewritten and destination IP is set as the next hop IP. So how the final destination IP is retained in the packet?

Purple

How packet reach destination

Hi,

The destination IP is not set to L3 next hop when the host sends its frame, it sends the frame to the dst MAC of the next-hop corresponding to next-hop IP( default gateway). The destination IP stays the same before and after traversing the router.

Regards

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.
Super Bronze

Re: How packet reach destination

Disclaimer

The   Author of this posting offers the information contained within this   posting without consideration and with the reader's understanding that   there's no implied or expressed suitability or fitness for any purpose.   Information provided is for informational purposes only and should not   be construed as rendering professional advice of any kind. Usage of  this  posting's information is solely at reader's own risk.

Liability Disclaimer

In   no event shall Author be liable for any damages whatsoever (including,   without limitation, damages for loss of use, data or profit) arising  out  of the use or inability to use the posting's information even if  Author  has been advised of the possibility of such damage.

Posting

Hi Joseph,

I need little more clarification here. When a packet travers L3 hops then the IP header is rewritten and destination IP is set as the next hop IP. So how the final destination IP is retained in the packet?

Answered by Alain.  As he noted, the packet's destination IP isn't changed.

Transit devices do use the destination IP to select their next hop (or final destination host).  Again, though, the packet's destination IP is untouched.

Think of a snail mail envelope address.  Destination address doesn't change on envelope as it transits different offices, but each office uses that address to select where to send the envelope next.  The outer transit container (the bag/vehicle) the envelope is within, does change per hop.  (The latter is the purpose of the L2 frame.)

New Member

How packet reach destination

Hi,

as Joseph said, I wonder what will be the destination IP in the packet if both the host are behind NAT Router?

Super Bronze

Re: How packet reach destination

Disclaimer

The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.

Liability Disclaimer

In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.

Posting

as Joseph said, I wonder what will be the destination IP in the packet if both the host are behind NAT Router?

Source or destination IPs will be changed by NAT.  Packet will contain what appears to be "correct" IP based on what side of NAT the packet is currently on.

New Member

How packet reach destination

ok..so you mean in this case also destination IP in the packet will be the actual destination host IP. When the packet reach the NAT router, it will rewrite the IP header?

Super Bronze

Re: How packet reach destination

Disclaimer

The   Author of this posting offers the information contained within this   posting without consideration and with the reader's understanding that   there's no implied or expressed suitability or fitness for any purpose.   Information provided is for informational purposes only and should not   be construed as rendering professional advice of any kind. Usage of  this  posting's information is solely at reader's own risk.

Liability Disclaimer

In   no event shall Author be liable for any damages whatsoever (including,   without limitation, damages for loss of use, data or profit) arising  out  of the use or inability to use the posting's information even if  Author  has been advised of the possibility of such damage.

Posting

NAT will rewrite IP source and/or destination IP.  Normally this isn't "visible" to hosts.

e.g.

host A : 10.1.1.1

Nat A: 1.1.1.1

Nat B: 2.1.1.1

host B: 192.168.1.1

Host A sends packet to host B as source IP 10.1.1.1 dest IP 2.1.1.1

NAT A changes to: source IP 1.1.1.1 dest IP 2.1.1.1

NAT B change to: source IP 1.1.1.1 dest IP 192.168.1.1

i.e. Host A thinks host B's IP is 2.1.1.1 while host B thinks host A's IP is 1.1.1.1

New Member

How packet reach destination

Hi My last question is how the host application will know what is the destination IP? I think the application will generate the packet with IP destination address?

Super Bronze

Re: How packet reach destination

Disclaimer

The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.

Liability Disclaimer

In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.

Posting

Hi My last question is how the host application will know what is the destination IP? I think the application will generate the packet with IP destination address?

See my 2nd posting.

New Member

How packet reach destination

ok.. so if the host application doesn't know the IP then it will know FQDN and resolve it to IP. So in this scenario a DNS help shall be required or NATing device also can work as a DNS?

Super Bronze

Re: How packet reach destination

Disclaimer

The  Author of this posting offers the information contained within this  posting without consideration and with the reader's understanding that  there's no implied or expressed suitability or fitness for any purpose.  Information provided is for informational purposes only and should not  be construed as rendering professional advice of any kind. Usage of this  posting's information is solely at reader's own risk.

Liability Disclaimer

In  no event shall Author be liable for any damages whatsoever (including,  without limitation, damages for loss of use, data or profit) arising out  of the use or inability to use the posting's information even if Author  has been advised of the possibility of such damage.

Posting

ok.. so if the host application doesn't know the IP then it will know FQDN and resolve it to IP. So in this scenario a DNS help shall be required or NATing device also can work as a DNS?

Correct, the sending device has to somehow "know" the address of the recipient.  It might be its IP or it might be by logical name (e.g. supportforums.cisco.com).

If NAT is involved, it may need to also NAT the DNS query and response, but that doesn't mean the NAT device, itself, is doing DNS.

New Member

How packet reach destination

Got it Joseph! thank you so much!!

Purple

How packet reach destination

Hi,

The host does a a binary AND between its IP and mask and between the dest IP and its mask to know if the dst IP is on same subnet or not.

The dest IP is given by the application  on the host and usually derived from a name by DNS.

Regards

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.
876
Views
0
Helpful
17
Replies
CreatePlease to create content