[Computer Network] Network Basics (Part 1)

1. Network Development

It is impossible for a single scientist to do computing work. It is destined to be a group of scientists working together. If
each scientist is equipped with a computer, then the computers among the scientists also work together.

As long as people use computers, computers must cooperate

In ancient wars, each soldier had his own weapon (knife, gun, sword, etc.), but the soldiers were not isolated from each other, but cooperated with each other with knives and guns, and guns and swords.


Each computer is independent.
Copy the data calculated by Komatsu to a floppy disk and hand it to Xiaozhu.
Copy the data calculated by Xiaozhu to a floppy disk and hand it to Xiaomei
. But the work with human participation will be very inefficient.


So in order to improve efficiency, simply connect all the machines
so that you can see everyone's data on your computer


awareness agreement

agreement is an agreement

In the past, it cost money to make a call, but it didn’t cost money to answer the phone
. Suppose you only have 20 to 30 bills in your mobile phone. Because the cost is very small, you avoid making calls yourself.
So when you call home,
if it rings, hang up , indicating to report to the family that it is safe.
If it rings twice before hanging up, it means that you have no money and it is time to transfer money
. If it rings three times before hanging up, it means something special

Making the agreement well, separated by hundreds of miles, quickly forming a consensus and making the agreed action through the things that have been agreed upon, is called an agreement. The
essence of the agreement is to improve the efficiency of collaboration


Two computers are the expression of human will. Because of the introduction of the network, the distance between the computers is doomed to be relatively long,
so the two computers use a specific method at the technical level to complete the agreement when the two parties communicate.

2. Basic understanding of network protocols

When communicating over the network, what needs need to be solved, what problems will arise, and why?
1. During long-distance transmission, the signal will attenuate, so the data may be abnormal (data loss)


The machine to be sent is at the remote end. There are many machines on the network.
How to accurately find one of the machines in the network after sending the machine data
2. The problem of locating a host


Because the network is too long, going through intermediate nodes
will lead to
3. How to forward data and choose the path


Only by locating a host can you start to transmit data and choose a path.
For example, if you know that you want to take the postgraduate entrance examination, you will study hard.
Therefore, when designing, design different functional modules into different modules.
You can design the solution as a layered structure ( Each layer solves the same problem, there is no direct relationship between layers)

protocol layering

Suppose you and your friend are in two different buildings, and you use the desktop computer in your dormitory to make a call to the desktop computer in your friend’s dormitory. In the process of making a call, you think that
you and your friend are communicating directly
In fact, you gave the words to your desktop computer, and passed the information to another desktop computer through the telephone protocol. At this time, your friend's desktop computer analyzes the received data and plays the sound to your friend's ear. side

Therefore, it is divided into the language layer and the communication device layer. Logically, it is considered that they are communicating with the other layer. The layer and the
layer call each other through the interface . When making a call, it doesn't care what frequency the call uses


In the process of communicating with mobile phones, although the bottom layer is completely replaced, the upper layer still uses Chinese to communicate.


Replacement of the language layer
In the process of communicating with the desktop computer,
two people change the language from Chinese to English, and the desktop computer does not care so much. The desktop computer still transmits the data of one person to the other desktop computer.


After the software is layered, each layer only pays attention to the functions of its own layer, and only uses the interface of the next layer. If there is a problem in any layer, it will not directly affect the other layer. Reduce the cost of
later developers

OSI seven-layer model | TCP/IP

OSI (Open System Interconnection) Open System Interconnection
seven-layer network model is called the Open System Interconnection Reference Model, which
is a logical definition and specification


Divided into seven layers
from bottom to top: physical layer data link layer network layer transport layer session layer presentation layer application layer


In fact, when the project is implemented, it will be compressed into the physical layer, the data link layer, the network layer, the transport layer, the application layer (the session layer, the presentation layer, and the application layer are regarded as the application layer). Generally, when studying the
network protocol stack, the focus is on software, and the physical layer is about Network communication hardware, so the physical layer does not consider


The network protocol stack adopted is the TCP/IP five-layer (or four-layer) model. TCP/IP is born out of the OSI seven-layer model, and the session layer presentation layer application layer is regarded as the application layer
five layers: physical layer data link layer network layer Transport layer Application layer
Four layers: Data link layer Network layer Transport layer Application layer


Physical layer: Responsible for the transmission of optical/electrical signals. For example, the network cable (twisted pair) commonly used in Ethernet, the coaxial cable used in early Ethernet
(now mainly used in cable TV), optical fiber, and the current wifi wireless network The use of electromagnetic waves, etc. all belong to the concept of the physical layer. The ability of the physical layer determines
the maximum transmission rate, transmission distance, anti-interference, etc. The hub (Hub) works on the physical layer.


Data link layer: Responsible for the transmission and identification of data frames between devices. For example, the driver of the network card device, frame synchronization (that is , what signal is detected from the network line is counted as the beginning of a new frame), conflict detection (if a conflict is detected
Automatic retransmission), data error checking, etc. There are standards such as Ethernet, Token Ring, and wireless LAN. The switch (Switch) works at the data link layer. (For example: there is a child who can
say simple Field, to pass the information to his father or mother
The standards of the data link layer are different, because the specific implementation of the data link layer is implemented in the network card driver The
most common standard is Ethernet)


Network layer: responsible for address management and routing selection. For example, in the IP protocol, a host is identified by the IP address, and the data transmission line (route) between the two hosts
is planned Router) works at the network layer.

The red box is the internal network private IP address of the host


Transport layer: Responsible for data transmission between two hosts. For example, Transmission Control Protocol (TCP), which can ensure that data is reliably sent from the source host to the target
host.

Reliably send data from A to B.
For example: Your teacher praised you for being able to score 100 points in mathematics, but it does not mean that you can definitely score 100 in the test. There is a high probability of 100 in the test, and it is also possible to test 99. Therefore, reliable data transmission is
required


Application layer: Responsible for communication between applications, such as Simple Email Transfer (SMTP), File Transfer Protocol (FTP), Network Remote Access
Protocol (Telnet), etc. Our network programming is mainly for the application layer

Basic process of network transmission

Case 1: Same LAN (subnet)

Two machines in the same LAN can communicate directly.
For example: Suppose one day the network card is stuck, and the roommates in the same dormitory want to play games, so they play CS to build a LAN room, and then they can enter the room to play games together. Two
hosts The essence of communication is that the operating systems of the two hosts communicate with the network protocol stack

How data flows between two communicating machines

Each layer of the same layer is a protocol, and each layer must have its own protocol
protocol expression: the protocol header reflects

Understanding of protocol headers

Online shopping: I bought a keyboard in an online store, and the seller delivered the goods after payment. After receiving the goods, it was not just the keyboard, but a package with a piece of paper on it, with name, location, and zip code of delivery
. Wait,
what you want is a keyboard, in fact, besides the keyboard, there is an extra piece of paper for you

This piece of paper is not necessary for you, but it is necessary for the courier. The extra piece of paper is called the header.
The header works on the courier's layer. In your opinion, you remove the header.
The keyboard itself is also the packaging Get up, the keyboard should be accompanied by an instruction manual, and the instruction manual will tell you what type of keyboard is, how to use the keyboard, etc.
The instructions can also be used as headers


In the logistics system, not only logistics goods, but also express orders + goods are the main body of logistics

When you want to send it, it is equivalent to a product. If this product wants to be forwarded normally in the network, it works at different levels. Each layer must have a corresponding protocol (expressed as a header)

Each layer of protocol must have its own protocol header, plus the payload.
For example, when a package is received, the paper on the package is called the header, and the contents of the package are called the payload.


When you want to send a message, instead of sending the message directly to the other party, first add the header of your own application layer, and then deliver the header and payload to the next layer
. As the payload of this layer, add the header again

All data must be received by the hardware first, because the von Neumann system stipulates that for the sender, when it is called output and input, the
hardware of the host must receive it first, which determines the data received from the bottom up.


After receiving it, separate its own header from its own payload
After separation, hand over the payload to the upper layer
For example: after receiving the express delivery, dismantle the package and take out the contents


Penetrating the header from top to bottom is called encapsulation
Delivering the header from bottom to top is called unpacking and adding points Unpacking
: separating the header from the payload Decomposing
: delivering the payload to the upper layer


The protocol must support two basic functions:
1. The header must be able to be separated from the payload
2. The header must be supported, and the payload is delivered to the upper layer, which is called datagram demultiplexing (distributed to the upper layer for use)

Principles of LAN Communication (Story Version)
general principles

Every classmate has his own name. The teacher asked loudly in the classroom why Zhang San didn’t write the homework assigned by Zhang San. All the students in the classroom heard it and analyzed the data first
. The payload is the homework. Why didn’t you do it
first? Separate the header from the payload. The header is Zhang San. Everyone knows that they are not Zhang San, so everyone discards the message at the data link layer.

A classmate found that he was Zhang San when he compared the data link layer.
When Zhang San replied to the teacher, teacher, the homework has been finished.
Zhang San sent a data packet to the teacher, and other students present could hear
the header as teacher, payload Because the homework has been finished,
other students discarded the message at the data link layer. When the teacher compared the data link layer, he found that this student was called him. The
payload homework has been completed and delivered to the teacher.

In this process, Zhang San thinks that he communicates directly with the teacher, and the teacher also thinks that he communicates directly with Zhang San to complete an information exchange.
This communication principle is called the communication principle of Ethernet LAN.

data collision

In the classroom, when a classmate is in class, there is a classmate who keeps talking and disturbs the order of the classroom. Usually, the teacher will let this classmate go out at this time
because when this classmate speaks, it will interfere with the teacher or other students, causing others to hear clearly
This situation is called LAN data collision

in conclusion

In the local area network, only one person is allowed to send messages to the local area network at any time.
Anyone who wants to communicate needs to have a unique identifier. The same is true for machines. For computers, each computer is equipped with a network
card. Write the sn number of the network card inside the network card (commonly known as MAC address, globally unique)
(identifier: in the classroom, everyone has a unique name)

Guess you like

Origin blog.csdn.net/qq_62939852/article/details/132052429