Can anyone explain to me why we need a router to ping PC's that are in different vlans?
Or better yet, I have doubts in behavior about:
1 - What happens when I ping to PCs that have the same VLAN?
2 - What happens when I ping PCs that have different VLANs?
3 - Why do switches put a tag(dot1Q) in frames?
4 - Where does the router fit into all this?
My question is related to what happens with my frame.
For example, figuring that I have a PC1 that is in vlan 10 and a PC2 that is in vlan 20 that are separated by a switch and this same switch is connected to a router. I'm going to use my PC1 to ping PC2... and what I know is that my frame that is being sent is of type 802.3, but when it arrives at the switch it places a tag on it 802.1Q, there was a transition from 802.3 -> 802.1Q and this same frame will go to my router (which has subinterfaces configured (vlan 10 and vlan 20 => encapsulation dot1Q) which will do an inter routing vlan, I do not know if here the frame undergoes a new transition, but continuing this same frame will again reach my switch that will do the tag removal, that is, there will be a 802.1Q -> 802.3 transition, and this same frame is received by PC2.
My question here is that my knowledge on this is vague, which is why I made those 4 questions to see if anyone can deepen my knowledge.
My question here is that my knowledge on this is vague, which is why I made those 4 questions to see if anyone can deepen my knowledge.My question here is that my knowledge on this is vague, which is why I made those 4 questions to see if anyone can deepen my knowledge.
There are several ways to answer these questions and one of the factors that will influence the answers will depend entirely on your instructor's lesson.
This forum is mostly used by people with real-life networking issues. If we start giving out answers that, based on our real-life experience in fixing things, may not "gel" with your instructor's teaching and chances are your instructor may just turn around and ask, "Where the <EXPLETIVE> did you get this idea from?"
Ok, what normally happens, for the situation you describe is:
PC1 will physically send the ping request to its defined gateway IP (right here this assumes it has a gateway IP defined). It would do this assuming PC2's IP is in a different network than its own.
If the gateway IP is not in PC1's ARP cache, it would ARP for the gateway IP. When PC1 receives the ARP reply, it can construct a frame with the gateway's MAC. The packet, though, would have the PC2 IP.
When the switch receives the frame from PC1, it would forward that frame out its trunk port to the router. (This assumes the switch knows which port that is - and it should having just seen the ARP reply. The ARP request, may have been sent to all the switch's ports, same VLAN, except the ingress port.) Since link to the router would be a trunk, to carry the two VLANs, 10 and 20, frames to the router would have a VLAN tag added to them, unless the VLAN is defined to be "native" (only one can be so defined - by default, its VLAN 1).
The router's port will receive the frame, and depending on how the router port is defined, know which logical subinterace the frame belong to. It will then strip the frame and route the packet. As the packet should be routed to VLAN 20's interface, the router will construct a new frame to encapsulate the packet and send it to the switch (which which will forward it to the PC2 port). How the frame is constructed is much again a repeat of what I've already described, in that router needs the MAC of PC2 and may need to add a VLAN tag to the frame, which will be stripped off by the switch.
When PC2 receives the frame built by the router, and strips that off, it will then have the packet sent by PC1. It will then reverse the process to send a ping reply.
Important to the above, L2 frames don't transit L3 interfaces. L2 VLAN tags are only used when needed to identiy that frames belong to different VLANs on the same "wire". Cisco, though, will permit one VLAN to use untagged frames on such a shared "wire".
BTW, networking books, or other information on the Internet will likely better explain the above. These forums are best used for very specific questions (or as Leo notes - what's actually done in the "real world").