Raspberry Pi Zero W Wireless Projects
上QQ阅读APP看书,第一时间看更新

Local network

Let's assume that a packet has arrived at your router. It's crucial to understand what exactly is going on and how the router decides the destination of the packet. In your local network (your home), there may be 10 devices such as tablets, smartphones, PC, and laptops. The router has to decide in which of them it should send the packet. This is done with the Network Address Translation (NAT) protocol. So somehow it chooses one device and it sends the packet. Every single device in your home has an IP address. It is not the same as your home IP address that we mentioned earlier. When you connect a device in your local network (router), it automatically gets an IP address such as 192.168.1.101.

To sum up, the internet consists of clients (homes) and servers (endpoints). For example, a client is your home and a server is https://www.facebook.com. A client is connected to the server through some nodes (switches) usually with cables and there are plenty of them out there. What we described earlier is the internet. Going further, the local network consists of a switch, which in this case is called router and some devices such as your smartphone or laptop. Your router is responsible for delivering anything that comes to your home to the appropriate device. Your router and every single device has an IP address.

The structure of your local network is a tree. This means that everything starts from the router and expands. You may have another local network in your garage or in your yard. For example, you can see in the following screenshot that my network consists of some devices and another switch which consists of some more devices.

In the following screenshot, we can see a page of my router and it must be crystal clear that apart from the Wi-Fi there are two Ethernet ports enabled of which one is connected to a computer and the other to something called a switch that has two devices. The first one is again a computer and the second is our Raspberry Pi Zero W. You can find the IP of the Raspberry Pi in the following screenshot:

Your Raspberry Pi Zero W will be one device connected to your router and will have an IP address like every other device. This device depends on your router. Usually, the IP addresses in your home will be of the format 192.168.1.X, where X is in the range of 1 to 254, but even if the numbers differ, the idea is the same. Usually, since the router is the first device connected to the internet, it has an IP address 192.168.1.1, the second device may have 192.168.1.2, the third device 192.168.1.3, and so on as you can see in the upcoming image my raspberry, which has the IP 192.168.1.101. All of the preceding information is important because we will connect to our Raspberry Pi using SSH over the network. But of course to connect to it we will have to find it first.