How PING work through Multiple Switches and Routers.

How PING work through Multiple Switches and Routers.

When having PCs all connected to the same switch, then if PC1 want to contact PC2 , the process will be:

PC1: will send a broadcast, My MAC address is  MMMMM, My IP address is : 192.168.12.10  and want to reach the Hostname 192.168.12.12 ,
Switch : will register the MAC  address and the Port it has received the request on, and send the broadcast on all other Ports out (except from the port it was received). The broadcast will contain and ARP message that has the MAC address of PC1 and it IP address.

all other PCs will receive the Broadcast frame  and check if it is destined to them.

Let's say PC2 will read the frame and will see that it is destined to it. it will reply back to the Switch with it is IP address and MAC address.
Switch: will register PC2 MAC address and the port it was received, and will send unicast reply to PC1 with the ARP message content that has MAC address and IP address of PC2

***Please correct me If I was wrong in my guessing above.


**Now I would like to take it to another Level, PC1 and PC 2 are apart away, separated by switches and routers. Then how does the process work to get  PC1 able to reach PC2.


Thank you
jskfanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlanConsultantCommented:
Hi jskfan,

Same as above, except that when the packet is being sent outside of the local subnet, it will instead be sent to the gateway of the local subnet which then handles the packet exactly the same, including, for example, sending on to its own gateway if the packet is not for an IP within its own subnet.

Once a packet is going outside of its local subnet, the MAC address is not in use - it will use IP.

Hope that helps,

Alan.
0
JustInCaseCommented:
Local host operations when ping x.x.x.x is issued:

- do binary "and" operation against my address, subnet mask and ping destination to decide is IP address x.x.x.x is my subnet
 
  • if IP address IS a part of the host subnet
          --> if MAC address was not already known - issue ARP request with IP address x.x.x.x inside of ARP packet
                  >> if ARP is resolved send ICMP packets to host x.x.x.x with MAC address of host x.x.x.x in L2 header
                  >> if ARP is not resolved (L2 header can't be created) -->> quit operation
  • if IP address IS NOT a part of host subnet --> check if default gateway IP address is configured
          --> if IP address of default gateway is present check if ARP for default gateway IP address was resolved
                 >> if MAC address of default gateway was not already known - issue ARP request with of default gateway inside of ARP packet      
                 >> if ARP for default gateway is resolved send ICMP packets with IP address of host x.x.x.x, but with MAC address of default gateway in L2
       --> if IP address of default gateway is NOT present ARP can't be resolved (L2 header can't be created) --> quit operation
2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jskfanAuthor Commented:
The PING request will include : the Source IP address, the Source MAC Address and the Destination IP address ?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

JustInCaseCommented:
L2 encapsulation can't be built without source and destination MAC address (encapsulates L3 and higher level protocols). The above is procedure how host decide which MAC address should be placed as destination MAC address (how host decide is destination MAC address supposed to be from destination host itself or MAC address of default gateway).

ICMP ping request (IPv4)
L2 header --> Destination MAC Address - Source MAC address
L3 header --> Source IP address - Destination IP address
ICMP header --> Type 8 code 0  (The rest of  ICMP header are checksum, identifier, sequence number)
ICMP payload

ICMP echo reply (IPv4)
L2 header --> Destination MAC Address - Source MAC address
L3 header --> Source IP address - Destination IP address
ICMP header --> Type 0 code 0 (The rest of  ICMP header are checksum, identifier, sequence number)
ICMP payload

ping (networking utility)
0
jskfanAuthor Commented:
The First PING, the PC does not not know anything about the Destination PC other than the IP address.

So the PING Request Packet will include  Source and Destination IP address and only Source MAC address ?
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
The MAC address is not part of the ping itself. ARP cares about MAC, ping does not. Which MAC addresses are contained in the packet used to transport ping request and reply does not bear any information.
1
jskfanAuthor Commented:
I guess Source MAC Address should have already been known by the Switch when the PC boots up.

regarding The Source IP, I believe it travels  with the request packet all the way to the destination PC.

The Reply will have the IP address of the Destination PC. The MAC address will be the MAC of the Default Gateway if tehre is L3 between both PCs otherwise, if there is a Switch between the PCs, the Reply will also have the MAC address of the Destination PC.

Now in Case both PCs are connected to the same switch or to 2 separate switches( that are trunked), then I wonder if during the Reply whether the MAC address of the Destination PC will be communicated to the Source PC or it got just added to the Switch MAC table.
0
AlanConsultantCommented:
Hi,

I'm not sure that the source IP travels all the way to the destination endpoint - it will go to the gateway, and then be held in that device's routing table until the response comes back, at which point the packet is then routed back to the origin.  That assumes TCP/IP, rather than, say, UDP/IP.

The source IP is likely non-routable (say, 192.168.1.100) so it would be of neither use nor interest outside the original subnet.



Alan.
1
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
It depends. When NAT is applied, IP addresses are changed. If only routing done, no change.
0
AlanConsultantCommented:
Hi Qlemo,

Yes - with a change of subnet, I was implicitly assuming NAT.

Alan.
0
JustInCaseCommented:
Source IP address goes all the way but can be natted at some point (device that performed nat will keep nat translations in its natting table and "nat icmp back to original ip address" just as it would do for TCP traffic), otherwise where ping echo reply would be sent to (find its way back)?
:)
ICMP has source and destination IP addresses as any other L3 packet, but has no ports, so natting is, instead of port, taking icmp identifier field into account during natting.

MAC addresses are not relevant from perspective of ICMP, but are important from perspective of creating L2 encapsulation, which was mentioned in original question (that's why MAC addresses are included above). MAC addresses are only locally significant, that means MAC addresses are irrelevant outside local broadcast domain.
0
JustInCaseCommented:
Additionally, if we are looking ICMP strictly IP addresses are not part of ICMP header or ICMP payload.
But without IP addresses in L3 header ICMP would not be functional out of local subnet, similarly without creating proper L2 encapsulation frame would not be forwarded properly inside broadcast domain etc...

As a sidenote, Cisco created traceroute on L2 which can use MAC addresses and does not have to rely on IP addresses. Tracerote mac is actually using cdp not icmp, so it is generally irrelevant for this discussion.
0
jskfanAuthor Commented:
Thank you Guys for the Explanation
0
JustInCaseCommented:
You're welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Routers

From novice to tech pro — start learning today.