Understanding How Data Travels
Let’s look at a really cool example here. I actually love this and if I had this information at this kind of explanation a long time ago, my mind would have been blown because it would have made it all so clear to me. What we’re going to do is we’re going to see what happens to data as it travels through the network from the host on the left to the host on the right. Before we do that we need to identify what’s going on with two different networks. We have one network on the left with an IP address 192.168.100.0 and we have another network on the right with an private IP address 10.10.10.0. Two different private networks that we’re connecting together over this router. Each one of our hosts on these networks have specific IP addresses and specific MAC addresses.
Remember every node on a network has an IP address and a MAC address. So, both of your hosts have both of these. The host on the left is 192.168.100.0 and a MAC address with all A’s and the host on the right has an IP of 10.10.10.2 with a MAC address with all B’s. We do have to understand what the IP address and MAC address is of the router as well. Normally, we only think of routers in terms of IP, but they do have MAC addresses.
The router is called the default gateway for a network whenever a computer needs to go to another network. For example, the computer on the left needs to communicate with the network on the right and to do so it is going to talk to it’s default gateway to get over to that network.
Routers
The router will get you out to other networks like the internet. In your IP configuration you have one and that's basically your routers. We do have additional IP addresses and MAC addresses assigned to each individual interface of the router. The router specializes in routing traffic from one network to another, and again each IP address will also have a MAC address associated with it for those particular interfaces. We’re going to see how this relates as the traffic travels through.
Host Creates A Packet
At this point we have identified that we have two different local area networks. The host on the left is going to send a message to the host on the right so it says I want to send this data to the host on the right. Okay, so let’s see what happens. It’s going to take this data and before it can send it out it first needs to create an IP packet. This IP packet is going to have the destination address, it already knows that the host it wants to send it to is 10.10.10.2 and it puts that on the IP packet destination address. It also includes its own IP address in the IP packet as well as the source. In the header we have the source which is 192.168.100.0 and the destination which is 10.10.10.2, the packet is created and the data stuffed into it. Now what does it need to do with this packet before it can send it out onto the Ethernet LAN? It needs to create a frame.
Packet Creates A Frame
So, a packet creates a frame and it’s going to put the destination MAC address information into it. However, It doesn’t know the MAC address of this computer 10.10.10.2 because it’s on a different network. It only knows the MAC addresses of computers on its local network. But what it does have is a default gateway and this computer knows the MAC address of its default gateway. The G0/0 interface has a MAC address so it is going to put a destination MAC address on the MAC header of this frame. The frame will get to the default gateway and it knows to do this because it knows its default gateway is the 192.168.100.1 address and it knows its MAC. The next step is to stuff the packet into the frame.
Again to summarize: Now we have a frame and take the data, put the data into the packet then we take the packet and put it into the frame. We are going to exclude the TCP part for simplicity purposes and say that it already happened. Since we now have a destination MAC address, we’re going to see how it actually gets there. The computer sends it out onto the LAN and it goes to the switch.
Switch
The switch takes the frame and looks at it and it opens up the header and it see’s CC-CC-CC-CC-CC-CC as the destination MAC address. What it does next is sends it out of the port that is connected to that MAC address because remember, it has a table and knows exactly where this router is connected.
It then sends it out the port that’s connected to that router. Boom, it makes it to the router. The router takes the frame and analyzes the frames MAC header. It sees that the MAC header is CC-CC-CC-CC-CC-CC and it knows that the frame is for the router and opens up the frame. It then discovers the IP packet and looks at the packet header information and sees the destination IP of 10.10.10.2. The router knows where the destination is and creates a brand new frame and changes the MAC address header to all B’s so that it can be repackaged and sent off to the host.
The router sends the frame to the switch, the switch then looks at the frame and looks at the frame header of all B’s and knows that it is connected to port G0/1 and then sends it out that port and directly to the host. The host receives it and opens it up and looks at the frame header, and MAC address header and see that it’s all B’s and now knows the frame has made it to the right place and opens up the frame completely getting to the IP packet. It checks out the IP packet destination and says “Oh cool, this is for me.” and it came from 192.168.100.0. So then it takes the data out of the packet and now can analyze it.
Now what does it do with the packet and frame now? Well, it destroys those things and is just left with the data. We can go ahead and take this data and figure out what it means. It’ll run through its applications or whatever the data was meant to go through.
Conclusion
That’s how the process works. Packets go to frames which go to packets again which go to frames again, which sometimes go to packets again, and then go to frames again and then get decapsulated by the host eventually where it can pull the data out. That is how the communication works.