Application layer and transport layer_byseyOrd

Transport layer  

    The origin of the transport layer: the IP of the network layer helps us to partition the molecular network, the mac of the Ethernet layer helps us find the host, and then identifies the application on the host by the port.

  The port is the number associated with the application and the network card.

  Transport layer function: establish port-to-port communication, supplement: port range 0-65535, 0-1023 is the system occupied port

  The transport layer has two protocols, TCP and UDP

 

 

1. The TCP protocol is
  reliably transmitted. There is no limit on the length of TCP data packets. In theory, it can be infinitely long. However, in order to ensure the efficiency of the network, the length of TCP data packets usually does not exceed the length of IP data packets, to ensure that a single TCP data packet does not have to be longer. segmentation. (Streaming protocol, uninterrupted transmission)

  The reason for TCP's reliability: as long as no confirmation is received, the datagram is resent until the other party's confirmation is obtained.

tcp message:

 

 

2. The three-way handshake and four
  -way wave of tcp. The so-called three-way handshake (Three-way Handshake) refers to the establishment of a TCP connection that requires the client and server to send a total of 3 packets.

  First, the Client sends a connection request message, and the Server segment replies with an ACK message after accepting the connection, and allocates resources for this connection. After receiving the ACK message, the Client also generates an ACK message to the Server segment and allocates resources, so that the TCP connection is established.

  The disconnection of the TCP connection requires sending four packets, so it is called four-way handshake. Either the client or the server can initiate a wave motion (interrupt the connection). In socket programming, either side performs a close () operation to generate a wave motion.

  Waving process: Assume that the client initiates a disconnection request, that is, sends a FIN message. After the Server receives the FIN message, it means "I have no data to send to you at the Client", but if you still have data to send, you don't have to rush to close the Socket, you can continue to send data. So you first send an ACK, "Tell the client, I have received your request, but I am not ready yet, please continue to wait for my message." At this time, the Client enters the FIN_WAIT state and continues to wait for the FIN message on the Server. When the server determines that the data has been sent, it sends a FIN message to the client, "Tell the client, okay, my data has been sent here, ready to close the connection." After the client receives the FIN message, "it knows that the connection can be closed, but he still does not believe the network, afraid that the server does not know to close, so after sending the ACK, it enters the TIME_WAIT state. Pass. "After the server receives the ACK," I know I can disconnect. " After the client side waits for 2MSL and still hasn't received a reply, it proves that the server side has been shut down normally. Well, my client side can also close the connection.

  
 

2.
  Unreliable transmission of the UDP protocol . The "header" part has only 8 bytes in total, and the total length does not exceed 65,535 bytes. It just fits into an IP data packet.

  UDP features:

    There is no need to establish a connection before transferring data.
    With the best efforts, delivery cannot guarantee the accurate delivery of data to the target host, nor does it require confirmation of received UDP packets.
    It is packet-oriented and encapsulates the data transmitted by the application layer in UDP packets without splitting or merging.
    No congestion control, transmission rate is not so UDP protocol network congestion Effect
    support one, one-to-many interactive communication
    UDP header of 8 bytes only, occupy less
. 3, summarizes the comparison of TCP and UDP
  TCP Although the protocol is very safe, the network overhead is large, and although the UDP protocol does not provide a security mechanism, the network overhead is small. In the current situation where the network security is relatively high, we generally give priority to ensuring the transmission rate. Consider the UDP protocol!

Application layer  

    The origin of the application layer: users use applications, all work in the application layer, and the Internet is developed. Everyone can develop their own applications. The data is diverse, and the organization of the data must be specified.

  Application layer function: Specifies the data format of the application.

  Example: TCP protocol can transfer data for various programs, such as Email, WWW, FTP, etc. Then, there must be different protocols stipulating the format of e-mail, web pages, and FTP data, and these application protocols constitute the "application layer".

From this blog

 

Guess you like

Origin www.cnblogs.com/seyOrd/p/12692825.html