Transcript for:
Understanding Host Communication in Networking

Hello. Welcome to another lesson from my new course on networking fundamentals. The first module of this course will teach you everything you need to understand how data flows through the internet. In this lesson, we'll be taking a look at the internet from the host's perspective. We're going to look at everything a host does to speak on the internet. Before watching this video, it is recommended to have watched the prior lessons in this module. In lesson one, we unpacked the concepts of a host, IP address, network, switches, and routers. And in lesson two, we took a practical look at the OSI model and showed you how each layer contributes to the overall goal of networking, which is moving data between hosts. There will be links to each of these lessons in the description. In this lesson, we're going to illustrate everything hosts do to speak on the internet. And we're going to do this across two scenarios. The first scenario will outline everything that occurs for two hosts, which are directly connected to one another, to communicate. And the second scenario will outline everything that occurs for two hosts to communicate on opposite sides of a router. And regarding this first scenario, hosts don't actually know what they are connected to. So whether host A is directly connected to host B, or whether there is one switch or multiple switches in between, either way host A is going to follow the same steps. So this first scenario is actually showing you everything that hosts do when communicating with other hosts on the same network, regardless of how they are connected. And regarding that second scenario, hosts also don't know whether what they are trying to speak to is on the other side of one router, or multiple routers, or on opposite sides of the internet. So again, we'll remove all the extra variables to keep it simple, which will tell us exactly what a host does to speak to any other host on a foreign network. These two scenarios will illustrate 100% of the communication that occurs on the internet from the perspective of each host. And we're going to be doing this in two parts. In part one, in this video, we'll show you all the steps hosts take to communicate to other hosts on the same network. And in part two, in the next video, we'll show you how it changes if you add a router to the mix. That being said... let's jump right into it with our first illustration. So here we have two hosts, and these two hosts are directly connected to each other. Now they don't know that, so what they're going to be doing is identical if there were hubs or switches in the mix. Both of these hosts have a NIC, which this wire is physically connected to, which means both these hosts have a MAC address. I'm providing only the first four digits of each host's MAC address to conserve screen real estate. Moreover, both of these hosts have IP addresses and subnet masks. We defined earlier in this module that IP addresses serves as the identity of each host. We didn't yet give you a definition for a subnet mask, but a subnet mask essentially tells you the size of a particular network. This is all done through a process known as subnetting, and we're not going to be covering subnetting in this module. If you're interested in learning subnetting, go and check out the free videos we've created at subnetipv4.com. Host A has some data it needs to send to host B. Now from the network perspective, we don't know or care what that data is. It's just a bunch of ones and zeros that needs to go from host A to host B. Host A also knows the IP address that it's trying to speak to. It knows the IP address of host B. Now how it knows that is somewhat outside the scope of this video, but the simplest explanation is maybe the user of host A jumped on the command prompt and typed ping 10.1.1.33. This provided the IP address to host A that needs to receive this data. Alternatively, Maybe host A acquired the IP address of host B through DNS. DNS is a protocol which converts a domain name into an IP address. For example, when you jump on your web browser and type in practicalnetworking.net, DNS is what's going to turn this domain name into an IP address that your computer can send a web request to. One way or another, host A is going to use something like this in order to know the IP address that it's trying to send the data to. Moreover, host A also knows that the IP address that it's trying to speak to is on host A's own IP network. Host A will do this by looking at its own IP address and comparing it to its own subnet mask to determine how many other IP addresses are on the same network. Now, all this, again, is done through subnetting, which we won't be covering in this module. For now, just take my word for it that host A knows that 10.1.33 is on the same IP network of host A. If you want to learn more about subnetting, however, feel free to check out the free videos at subnetipv4.com. Either way, since host A knows the IP address of who it's trying to speak to, it's able to create the Layer 3 header to attach to this data. This Layer 3 header is going to serve the function of end-to-end delivery. Therefore, it's going to include a source IP address of whoever is sending the data, in this case host A, and a destination IP address of whoever's meant to receive the data. Now, of course, Layer 3 cannot interact with a wire. For that, we need Layer 2. So host A next needs to add a layer2 header to this packet. The problem is that host A does not know host B's MAC address. If we look back at our example of how host A knew host B's IP address, many of you have used the ping command. And I imagine all of you have typed in ping and then an IP address. But notice you never typed in ping, an IP address, and a MAC address. You only provided the IP address to the computer. The computer figured out the MAC address on its own. And that's exactly what host A is going to have to do. Host A is going to have to use the address resolution protocol, or ARP, to resolve host B's MAC address. This, in fact, is exactly the purpose of ARP. ARP is meant to link a layer 3 address to a particular layer 2 address. So let me show you how that works. Host A needs to use ARP to resolve the target IP address's MAC address, meaning that MAC address right there. What it's going to do is shoot out an ARP request. This ARP request is going to ask for the MAC address which is associated with a particular target IP address. In this case, the IP address we are trying to resolve, 10.1.1.33. Moreover, this ARP request is going to include the sender's MAC address. Host A is going to include its own IP address and MAC address in the request itself. This will be useful so that host B can respond directly to host A later on. Now notice that the ARP request included a layer 2 header. This layer 2 header is meant to take the ARP payload and get it delivered to host B. But that Layer 2 header does not have a destination MAC address of B's MAC address. If host A knew host B's MAC address, it wouldn't have to do ARP to begin with and could just populate the MAC address in this Layer 2 header from the very beginning. Instead, this Layer 2 header is sent as a broadcast, meaning it's sent to everybody on the network. What that means is that it has a destination MAC address of all Fs. The all Fs MAC address is a specially reserved MAC address which is meant to be used whenever you want to deliver a packet to everybody on the local network. That is by definition a broadcast. Now if you're interested in learning more about broadcasts, I created another video which discusses local broadcasts and directed broadcasts. There'll be a link for that video in the description. As for us, we're going to continue. ARP mappings are stored in what's called an ARP cache. Every device which has an IP address has an ARP cache. Host A has an IP address and host B has an IP address. Therefore, they both have ARP caches. At the moment, host A's ARP cache simply states that we're trying to resolve the 10.1.1.33 IP address to a particular MAC address. Host B's ARP cache is currently empty. When this request, however, makes it across the wire, you'll see something happens to host B's ARP cache. Notice, host B was able to populate an entry in its ARP cache for host A. It was able to identify that the IP address 10.1.1.22 maps to the MAC address A2A2. That occurred because in the original ARP request, host A provided its own MAC address. So by simply receiving an ARP request, host B was able to learn an ARP entry. Host B will now respond to that ARP request by sending what's known as an ARP response. That ARP response will include the mapping that host A was trying to resolve, specifically the IP address 10.1.1.33 and the MAC address that owns it. This Its ARP response is sent unicast, meaning directly back to host A. Since host B knows host A's MAC address, it can create the layer 2 header which will take the ARP response directly to host A and not have to interrupt everybody on the wire by using a broadcast. Either way, when that ARP response arrives on host A, host A is able to create the ARP mapping that was listed in the ARP response. Now host A has everything it needs to complete the layer 2 header. for the data it was initially trying to send to host B. The layer 2 header is going to include a source MAC address of host A's MAC address and a destination MAC address of host B's MAC address. This layer 2 header will accomplish the goal of hop to hop delivery, which finally lets this data be sent to host B. Upon arriving to host B, host B will discard the layer 2 header. Again, the whole purpose of that header was to get the packet from this NIC to this NIC. It did so successfully and can now happily retire in header heaven. Next, host B will discard the layer three header. Again, the only purpose of that header was to get this data from host A to host B, and it did that successfully and can therefore also retire in header heaven. And finally, the application on host B can process the data that it just received. So that is what is required to get some data. from host a to host b now presumably host b is going to have a response meaning it's going to have some ones and zeros it's going to have to send to host A. But the good news is host B has all the necessary information in order to respond much quicker than it initially took. Host B knows who it's trying to communicate, so it's able to create the layer 3 header with a source IP address of host B and a destination IP address of host A. And since host B's ARP cache is already populated, it's able to create a layer 2 header that includes its own MAC address as the source, and host A's MAC address as the destination, which it knows because it's stored in its ARP cache. In fact, any further data exchange between these two hosts now happens very easily because both hosts have everything they need in order to create the layer 3 and layer 2 headers successfully. And that wraps up our lesson on everything hosts do to speak to another host on the same network. The key takeaways of this lesson... is understanding all the steps a host takes when speaking to another host on the same network, understanding that those steps are the same regardless on whether there are switches or hubs in between the two hosts, and finally understanding ARP and how it works and how it links a layer 3 address to a layer 2 address. In the next video, we're going to add a router between these two hosts to show you how these steps change. This will illustrate everything a host does to speak to another host on a foreign network. But that wraps up this video. I hope you enjoyed this video. I want to thank you for watching, and I'll see you in the next video as we unpack how hosts communicate through a router. Hey, YouTube. I hope you enjoyed that free lesson from my new course on networking fundamentals. I'll be releasing the entire first module for free here on YouTube. I want this course to be the ultimate networking fundamentals course. And since I'm still scoping out the outline, you could have a say in what topics will be covered. Let me know in the comments below what subjects you want included in this course. Otherwise. remember to like and subscribe. And of course, if you learned something from this video, the best way to thank me is to share this video. It's a small act of gratitude, but one I appreciate greatly. I hope you enjoyed this lesson. I want to thank you for watching, and I'll see you in the next one.