Programming Xiaobai must understand the network principle

Time:2021-9-23

How is the network composed? Why can we easily surf the Internet now?
Whether you are a computer major or not, you may always have such questions in your heart!
And today we will solve this matter and tell you the real answer!
Programming Xiaobai must understand the network principle

Basic composition of network

First, let’s look at this sentence

Connect all computers together to form a network, but there are many forms of connection, such as

Yes, the so-called network, in fact, is to connect computers with network cables. When connected more, it forms a network. Generally, we can divide it into the following ways according to the connection mode

Direct network

Every computer on the earth must join the network if it wants to surf the Internet. The purpose of joining is to find each other. So what method is used to connect? The simplest way is to use a network cable to connect directly.
The two computers can transmit data to each other. It’s like I visit my neighbor’s house without any redundant steps.
Programming Xiaobai must understand the network principle
⚠️ Note: Here you can imagine the network cable as the way to your neighbor’s house.
But this kind of network is useless. It’s just for your own entertainment!

LAN

You can think of the LAN as a village. There are many families living in this village. If you want to go to any family, you must know their address. How can you remember the addresses of so many people? Therefore, it needs to be managed by the village committee or the police station. Note that this organization is called a router in the network.
Programming Xiaobai must understand the network principle
So if you want multiple devices to surf the Internet at home, you know why you must buy a router!
Connection mode of router

  1. Wired – > network cable – > 100M / Gigabit / 10g
  2. Wireless – > Radio – > WiFi

Wide area network

In fact, there are many concepts of Wan. The network of a community can be called Wan, the network of a district or county can also be called Wan, and even the network of a city can be called Wan.
Whether the police station manages the household registration is managed by the superior department. This level is the same as our network level.
Therefore, the unlimited development of LAN to the superior organization forms all kinds of Wan.
Programming Xiaobai must understand the network principle
Note that each layer of organization has at least one larger router to support it! Or switch!

internet

The Internet is not a technical term, but a concept, but now it usually refers to the global network. You can think that there are many Internet devices in the world connected with the outside world through their own LAN, forming the current Internet.
Programming Xiaobai must understand the network principle

Mobile / 5G network

Now is the era of mobile Internet. Our Internet devices have changed from computers to mobile phones, tablets and so on. However, in any case, the composition of the network has not changed, but the transmission medium has changed.
The media used to be connected with a network cable, but now it has become a wireless connection!
This is like, I used to walk to your house, but now I can fly directly!
Programming Xiaobai must understand the network principle
Therefore, 5g is the abbreviation of the fifth generation mobile communication technology!
Programming Xiaobai must understand the network principle

Thinking: why does the Internet speed slow down?
Tip: there is no road in the world. More people have a road! Later, there were more and more people, and the road was difficult to walk!

After understanding the basic composition of the network, the problem comes again. How do we surf the Internet? Why can you open a website to see the news and open a software to watch the video?

Composition of network services

In fact, this problem is also very simple. In reality, some people open a supermarket, a steamed bread shop and a barber shop, and then we can line up to buy things.
Programming Xiaobai must understand the network principle
In fact, the same is true in the network. You can open what kind of server you need to provide.
So the server is also a computer, which is the same reason that we can open a shop at home or in the front room.
Programming Xiaobai must understand the network principle
The server can also be an ordinary computer or the kind that looks awesome (such as blade server)!
Basic composition of a computer / server

  • CPU: responsible for computing
  • Graphics card: responsible for display and graphics rendering
  • Memory (flash): responsible for caching data
  • Hard disk (flash): storing data
  • Motherboard: the carrier responsible for connecting all devices
  • Power supply: responsible for power on

Classification of network software

There are two kinds of software on the computer, one is stand-alone software (you can use it without networking), and the other is network software (you need Networking).
The software that needs to be connected to the network is in the following two forms

B / S architecture

Browser / server
At the beginning, the most Internet demand we contacted was the website. Enter a website address in the browser address and press enter to open a web page.
The actual process is to find the content stored in the server with the website service on according to the address of the website.
Programming Xiaobai must understand the network principle
Programming Xiaobai must understand the network principle
Because this form is very extensive, we call this type of software B / S architecture, that is, browser server architecture.
This page is composed ofFront end development engineerFor development, small partners who want to know can leave a message in the private letter or comment area and receive itComplete collection of the latest front-end development courses in 2021
Programming Xiaobai must understand the network principle
The software providing this service includes nginx, Apache, IIS, etc., which are installed on the server through commands.

C / S architecture

Ordinary web pages have limited functions, and when we need more complex functions, we need to install a client software, such as QQ, 360, games and so on. These software also need to be networked to use more functions, so this software service mode is called C / s, that is, client server software.
The above software architecture is the same in the mobile phone. For example, you have installed a buffeting or fast hand.

For this process, please see my other article “how is app installed on your mobile phone?”

In fact, we found that no matter what kind of architecture the network software is, they all need to communicate with the server in order to work!
Through the above content, I believe you can roughly understand the Internet!
However, as a technician, it is not enough to understand these, so the next content is really dry! The small bench is not enough. Buy a suite and live in it. Take your time!

To truly become an Internet expert, you have to be familiar with the following concepts

What is the IP address?

Even if you are a computer Xiaobai who doesn’t understand anything, you should have heard of IP address!
The question is, what is an IP address?

Let’s look at the more official explanation

Internet protocol address refers to the internet protocol address, which is also translated into internet protocol address.

In fact, this address is essentially no different from our own home address concept!
For example, my family lives at No. 1 Chang’an Street, Dongcheng District, Beijing. As long as I tell others this address, others can find my family along Chang’an Street.
Programming Xiaobai must understand the network principle
But the question is, can the computer recognize such an address?
The answer, definitely not!
Computers are made up of a pile of hardware. What if they don’t understand the Chinese language? Their communication method, I said before, is composed of 0 and 1. So computers are very sensitive to numbers, so we just use numbers to represent the address!
Programming Xiaobai must understand the network principle
Of course, why don’t you say it’s not a mobile phone number? Isn’t that more convenient? In theory, this is no problem, but everything has established rules. After all, we didn’t participate in the formulation of this set of standards, so we can only follow other people’s standards.

How to get the IP address?
At the beginning of the article, we talked about the concept of LAN and Internet. The actual IP address is a set of specifications
They basically look like this!
10.0.0.1
192.168.0.1
114.114.114.114
Don’t be afraid, they are still very regular
It consists of four digits 0-255
Note that the 4 bits here are very important, so this standard is called IPv4

The question is, how many IP addresses do we have?

The range of IP addresses is 0.0.0.0 – 255.255.255.255, which is theoretically 255255255 * 255, about 4228 million
You’ll find~
The world’s 67 billion people and countless electronic devices are obviously not enough~
Therefore, the IPv6 standard was released many years ago, but it has not been popularized on a large scale, because the whole scope has changed and can not be updated so quickly.
But it doesn’t matter. In fact, everyone doesn’t need to have an IP address (of course, it’s best)
Smart Internet people divide the network into internal network and external network, referred to as internal network and external network for short

  1. Intranet – > LAN in home, kilometer and community. They must connect to the external network through router to use it
  2. Extranet – > the only real available IP address in the world, that is, the real Internet address
    In fact, you can think so
    The earth is the home of mankind, China is the home of Chinese people, Shandong is the home of Shandong people, and our home is the home of our family.
    Well, that seems to mean it~

In fact, there is more knowledge about IP addresses to understand, such as DNS server, routing assignment, subnet mask, etc. we need a special class to explain this. Welcome to continue to pay attention~

What is the port number?

A computer needs network services for different software, so it needs to be distinguished by port number!
With an IP address, the two computers can access each other
But the problem is, there are many software on each computer, such as QQ, wechat, 360, world of Warcraft, etc. How do I know what you want to do when you visit?
Therefore, there must be a port number to distinguish
For example, when we surf the Internet through the browser, you may sometimes find that some addresses are like this
http://www.baidu.com:80
perhaps
223.224.234.235:80
This thing is used to distinguish what you want to do. In fact, many international software have fixed port numbers, such as

  1. Email: 25
  2. Transmission document: 21
  3. Website visit: 80 and 443
  4. Remote connection: 3389
  5. Database: 3306
  6. wait

If you need network communication to develop your own software, you can also apply to the operating system for a port number that has not been used in the system.

OSI seven layer model of network

OSI is the abbreviation of open system interconnection, which is translated as “open system interconnection”.
The OSI model divides the work of network communication into seven layers, from bottom to top: physical layer, data link layer, network layer, transport layer, session layer, presentation layer and application layer.
Many network Xiaobai and even computer majors will be confused by this OSI seven layer model when learning network principles. Why?
Because you don’t want to understand one thing, the computer is actually composed of a pile of stones!
How to make a stone have vitality, we need to build it well!
You may have seen this picture in many places on the Internet
Programming Xiaobai must understand the network principle
The description is very good, but it is difficult for novices to understand. Why?
Because this is the cornerstone of the whole network architecture. Every layer of it involves all aspects of the computer. A little Bai hasn’t even learned the basic grammar of programming. How can he understand these things!
But don’t be afraid!
BOGO’s best thing is to explain difficult things to you!
The actual OSI seven layer model is too complex. Some people began to integrate and put forward the concept of TCP / IP five layer model!
Of course, Xiaobai still can’t understand!
It’s okay. Let’s look at the correspondence first!
Programming Xiaobai must understand the network principle
Some people have also proposed a four layer model based on TCP / IP. Let’s see which one you like~
Programming Xiaobai must understand the network principle
The above are all concepts. The real process should be like this. Data transmission between two computers has actually gone through many steps!
We can see the picture below
Programming Xiaobai must understand the network principle
Each floor has an industry or industry. They are all working hard on it and changing the world!

Well, little partner, the above is about the simple network principles that Xiaobai needs to know about programming. In fact, we still need to know a lot about the development of network technology. Pay attention to me and talk slowly in the future~

Network protocol

There are many protocols, and each layer has different protocols
Programming Xiaobai must understand the network principle
There are so many concepts in the network seven layer model. In fact, for ordinary programmers, they mainly work on the application layer
The following are common application layer protocols. Web related developers must understand these protocols!
Programming Xiaobai must understand the network principle
So the question is, what is a network protocol?
Network protocol is simply understood as the language spoken between people. If two computers want to understand what each other says, they must use the same protocol.
You can understand it as: a family can’t speak two words!

The agreement stipulates a special format, which can be recognized by both sides!

  1. HTTP application layer
  2. TCP belongs to the transport layer

    HTTP is a protocol based on TCP

    Application layer protocols such as HTTP / ftp
    Here we take the HTTP protocol that web related developers must use as an example!
    In short, this is a protocol specially designed for browsers
    Programming Xiaobai must understand the network principle
    It is mainly aimed at the browser, so you need to see the embodiment of this protocol in the browser
    This is the case when requesting data
    Programming Xiaobai must understand the network principle
    The data returned by the server is like this
    Programming Xiaobai must understand the network principle
    HTTP protocol is characterized by one-way. The client sends a request to the server, the server returns data, and then it is over!

    Socket socket

    It seems that some students say that the browser also supports socket protocol, and other software also supports socket protocol
    Let me correct it here
    Strictly speaking, socket is not a protocol, but an abstraction of common protocols!
    Programming Xiaobai must understand the network principle
    Socket is actually a two-way, equal relationship between the two sides, and the roles can be exchanged!

    TCP / IP and UDP protocols

    This is a transport layer protocol. It is the cornerstone of the application layer protocol, including sockets
    In fact, he only specifies the way of data transmission
    In short, it specifies the IP address, port number and data transmission method

    TCP

    The full name of TCP protocol is transmission control protocol. It is a connection oriented, reliable and byte stream based transport layer communication protocol, which is defined by RFC 793 of IETF. TCP is a connection oriented and reliable streaming protocol. Flow is an uninterrupted data structure. You can think of it as a flow in a drain.

It is suitable for dedicated connection (data communication) between two computers
Three handshakes explain how data is transferred between them
Programming Xiaobai must understand the network principle
Wave four times to explain how they broke the link
Programming Xiaobai must understand the network principle

UDP

The full name of UDP protocol is user datagram protocol. In the network, it is used to process packets like TCP protocol. It is a connectionless protocol. In the OSI model, the transport layer, the fourth layer, is the upper layer of the IP protocol. UDP does not provide packet Grouping, assembly and sorting. In other words, after the message is sent, it is impossible to know whether it arrives safely and completely.
Programming Xiaobai must understand the network principle
It is applicable to 1-to-1, 1-to-many and many to many complex network scenarios
Programming Xiaobai must understand the network principle

summary

This article is mainly aimed at popularizing some common concepts of computer network.
The content of the article does not deeply discuss their specific rules and some so-called indicators, because I think it is enough for many people to roughly understand their concepts first
The knowledge behind each concept is what we will study slowly in the future!
After all, the content of this article also needs a book and a semester’s knowledge in college ~ (although many students gave feedback and didn’t understand it at that time)
Later, I will continue to update the article in the form of a single knowledge, and give you a good chat on the details of each concept~
Finally, your support is the driving force for my continuous renewal~
https://www.bilibili.com/vide…

Recommended Today

Seven Python code review tools recommended

althoughPythonLanguage is one of the most flexible development languages at present, but developers often abuse its flexibility and even violate relevant standards. So PythoncodeThe following common quality problems often occur: Some unused modules have been imported Function is missing arguments in various calls The appropriate format indentation is missing Missing appropriate spaces before and after […]