The TCP/IP protocol that network programmers must learn-layered

  1. How to realize a single machine million connections;
  2. How to optimize three handshake and four wave hands;
  3. How to optimize the transmission rate of TCP;
  4. Implementation of nginx zero copy technology;
  5. epoll principle analysis and interview questions.

Insert picture description here

Reference textbook: TCP/IP Detailed Explanation Volume 1/2/3

If you still have questions about this?
Click here: https://ke.qq.com/course/2739583?flowToken=1024417 to
Insert picture description here
take you to solve the problem! Start in actual combat and hit the pain points!

Network protocols are usually developed at different levels, and each layer is responsible for different communication functions. A protocol family, such as TCP/IP, is
a combination of multiple protocols at different levels. TCP/IP is generally considered a four-layer protocol system, as shown in Figure 1-1.

  1. The link layer, sometimes called the data link layer or network interface layer, usually includes the device drivers in the operating system and the
    corresponding network interface card in the computer . Together they deal with the details of the physical interface with the cable (or any other transmission medium).

  2. The network layer, sometimes called the Internet layer, handles packet activities in the network, such as packet routing. In the TCP/IP protocol suite, network layer protocols include IP (Internet Protocol), ICMP (Internet Internet Control Message Protocol), and IGMP (I nternet Group Management Protocol).

3) The transport layer mainly provides end-to-end communication for applications on two hosts. In the TCP/IP protocol suite, there are two
different transmission protocols: TCP (Transmission Control Protocol) and UDP (User Datagram Protocol).

TCP provides highly reliable data communication for two hosts. The work it does includes dividing the data handed over by the application
into appropriate small pieces and handing it over to the lower network layer, confirming the received packet, and setting the timeout clock for sending the final confirmation packet
. Since the transport layer provides highly reliable end-to-end communication, the application layer can ignore all these details.
On the other hand, UDP provides a very simple service for the application layer. It just sends a packet called a datagram
from one host to another, but it does not guarantee that the datagram will reach the other end. Any required reliability
must be provided by the application layer.

These two transport layer protocols have different uses in different applications, which will be seen later.

4) The application layer is responsible for handling specific application details. Almost various TCP/IP implementations provide the following
general applications:
• Telnet remote login.
• FTP file transfer protocol.
• SMTP Simple Mail Transfer Protocol.
• SNMP Simple Network Management Protocol.
There are many other applications, some of which will be introduced in later chapters.
Suppose there are two hosts in a local area network (LAN) such as Ethernet, both of which run the FTP protocol. Figure 1-2 lists
all the protocols involved in this process.
Insert picture description here
Here, we have listed an FTP client program and another FTP server program. Most network applications are
designed as a client-server model. The server provides some kind of service to the client, in this case it is to access
the file on the host where the server is located . In the remote login application Telnet, the service provided for customers is to log in to the server host.
On the same layer, both parties have corresponding one or more protocols for communication. For example, one protocol allows the TCP layer
to communicate, while another protocol allows two IP layers to communicate.

On the right side of Figure 1-2, we notice that the application is usually a user process, and the lower three layers are generally
executed in the (operating system) kernel. Although this is not required, it is usually handled in this way, such as the UNIX operating system.
In Figure 1-2, there is another key difference between the top and the bottom three. The application layer is concerned with the
details of the application , not the data transmission activity in the network. The lower three layers know nothing about the application, but they have to deal with all the
communication details.

Figure 1-2 lists four different levels of agreement. FTP is an application layer protocol, TCP is a transport layer
protocol, IP is a network layer protocol, and the Ethernet protocol is used on the link layer. The TCP/IP protocol family is a
protocol family composed of a group of different protocols. Although the protocol suite is usually called TCP/IP, TCP and IP are just two of
the protocols (the other name of the protocol suite is the Internet Protocol Suite (Internet Protocol Suite)).
The purpose of the network interface layer and the application layer is obvious-the former deals with the details of the communication medium (Ethernet, Token
Ring, etc.), while the latter deals with a specific user application (FTP, Telnet, etc.). However, on the surface,
the difference between the network layer and the transport layer is not so obvious. Why divide them into two different levels? In order to understand this
, we must extend the horizon from a single network to a group of networks.

In the 1980s, one of the reasons for the continuous growth of the Internet was that everyone realized that an "
island" composed of only one isolated computer was meaningless, so these isolated systems were grouped together to form a network. With this development, in the
1990s, we gradually realized that this new and larger "island" composed of a single network also didn't make much sense.
Therefore, people connect multiple networks together to form a network, or called the Internet. An
Internet is a group of networks interconnected through the same protocol suite.

The simplest way to construct the Internet is to connect two or more networks through routers. It is a special
hardware box used for network interconnection. The advantage of routers is to provide connections for different types of physical networks: Ethernet, token ring,
point-to-point links, FDDI (Fiber Distributed Data Interface), etc.

These boxes are also called IP routers, but we use the term router (R outer) here.
Historically, these boxes are called gateways, and this term is used in many TCP/IP literature.
Now the term gateway is only used to mean application-level gateway: a process that connects two different protocol families (for example,
TCP/IP and IBM's SNA), which serves a specific application (usually email or file transfer). ). Figure 1-3 is an Internet consisting of two networks: an Ethernet and a token ring network, connected to each other through a router
. Although here two hosts communicate through the router, in fact any host in the Ethernet can communicate with any host in the token
ring network.

In Figure 1-3, we can divide the end system (End system) (two hosts on both sides) and the intermediate system
(Intermediate system) (the router in the middle). The application layer and the transport layer use an end-to-end (En d-to-end) protocol. In the
figure, only the end system needs these two layers of protocols. However, what the network layer provides is the Hop-by-hop protocol, which is used by the two
end systems and each intermediate system.
Insert picture description here
In the TCP/IP protocol suite, the network layer IP provides an unreliable service. In other words, it only
sends packets from the source node to the destination node as quickly as possible , but it does not provide any reliability guarantee. On the other hand, TCP
provides a reliable transport layer on top of the unreliable IP layer. In order to provide this reliable service, TCP uses
mechanisms such as timeout retransmission, sending and receiving end-to-end acknowledgement packets. It can be seen that the transport layer and the network layer are responsible for different functions.
By definition, a router has two or more network interface layers (because it connects two or more networks).
Any system with multiple interfaces is called multihomed in English. A host can also have multiple interfaces,
but it is generally not called a router, unless its function is simply to transmit packets from one interface to another. Similarly, a
router does not necessarily refer to a special hardware box used to forward packets on the Internet. Most TCP/IP implementations also allow
a multi-interface host to act as a router, but the host must be specially configured for this. In this case,
we can call the system the host (when it runs an application, such as FTP or Telnet), or it can be called the path
Router (when it forwards packets from one network to another). Use different terminology in different situations.
One of the purposes of the Internet is to hide all physical details in applications. Although this is
not obvious in the Internet composed of two networks in Figure 1-3 , the application layer cannot care (nor care) that one host is on the Ethernet and the
other host is on the token ring network. , They are interconnected through routers. With the addition of different types of physical networks,
there may be 20 routers, but the application layer is still the same. The hiding of physical details makes the Internet very powerful and
very useful.
Another way to connect to the network is to use a bridge. Bridges interconnect the networks at the link layer, while routers interconnect
the networks at the network layer. The bridge allows multiple local area networks (LANs) to be grouped together so that it
appears to the upper layer as a local area network.
TCP/IP tends to use routers instead of bridges to connect to the network, so we will focus on routers.
Chapter 12 of the literature [Perlman 1992] compares routers and bridges.

Guess you like

Origin blog.csdn.net/lingshengxueyuan/article/details/106932465