directory

  • An overview of the
  • The physical layer
  • Data link layer
  • Network layer (1) Basic knowledge
  • Network layer (2) IP address design and exhaustion
  • Network layer (3) Network layer packet transmission process
  • Network layer (4) Network layer multicast and other applications
  • Transport layer (1) Reliable transport and TCP/UDP
  • Transport layer (2) congestion control and handshake waving
  • Application layer (1) HTTP and the World Wide Web

Responsibilities of the transport layer

Logic network layer provides end-to-end communication, but how do we use the Internet in the computer, we are through our application as a window to use network, visible layer using neural network alone can’t do all the work, lack of application support to the export of computer network, this is also the function of the transport layer provides. An application is a process in a computer, so the transport layer provides communication between processes. It provides communication services to its upper application layer. It is the highest layer for communication and the lowest layer for user functions. The IP protocol of the network layer can send the packet sent by the host to the destination host, and then it will be delivered to the required process (application program) through the transport layer. The starting point and end point of communication is not the host, but the process in the host. The mailroom, which is like a unit, all mail goes to the mailroom, and the mailroom goes to a single person, and the same goes for mailing. So what functions are needed?

Transport layer function

  • The first one is reuse and distribution. There’s only one mail room. Reuse means that all mail is sent through the same mailroom. Sharing means that mail sent to the mailroom needs to be delivered to the intended person. How do you mark the person who sent it, maybe an employee number in a company, maybe an employee number in a computerport.
  • The second is error detection in the data part. There is a checksum field in the IP datagram of the network layer, but it only checks whether the first part of the IP is correct, not the following part of the data.
  • Reliable transmission. As mentioned in the previous section on IP datagrams at the network layer, the network layer only provides services that are delivered as best as possible. Is the network we use unreliable? At the transport layer, TCP is used for reliable transport and UDP is used for unreliable transport. The application layer can choose to use it as required. Let’s talk about each point in detail

Reuse/reuse and ports

Since want to realize reuse and cent use, be about to mark this process, in the computer is how to mark the process, we can use the operating system to allocate to the process number, obviously not, different operating system process number form format is not the same, and allocation is also dynamic. At this time, we need to think about the network layer IP address and hardware address MAC, why not use the MAC address, because we rely on abstraction, not multiple MAC addresses. We just care about our IP address, no matter how MAC addresses change. The same is true here. On the Internet, we use port numbers to mark processes that transfer two endpoints. The transport layer takes this port number and hands it to the appropriate application process. A port number is a 16-bit number. A port number has only local meaning, that is, it is ok to have two same port numbers in the network, just like people with the same id in different units. Ports fall into two categories:

  • The ports used by the server are classified as familiar ports. Between 0 and 1023, these ports are assigned to important TCP/IP applications such as FTP (21), DNS (53), HTTP (80), and HTTPS (443). The other is to register a port number for use by a new application. Registration with IANA is required to prevent duplication.
  • The client port number ranges from 49152-65535. The locally assigned port number of the computer.

How to achieve reliable transmission

What is required for reliable transmission. Transmission is divided into transmission process and receiving process, if there is no problem, then the data in transmission can certainly reach the end point, that is, reliable transmission. If there are no errors in the transmission, the receiving process can be received indefinitely, and the received cache is infinite, which is reliable. But the reality is far from ideal. In reality, the transmission may be due to poor network conditions and super network congestion, resulting in router discarding data, resulting in errors in the transmission process. The receiving cache is less likely to be invalid. Therefore, we can only choose the way that the sender resends the data when there is an error in any of the intermediate steps, and dynamically adjust the sending speed according to the receiving capacity to achieve reliable transmission.

Stop waiting protocol

You can tell by the name how this works. The sender sends the next data only after receiving an acknowledgement from the receiver. If no acknowledgement is received and the local timeout timer is exceeded, the sender resends the data. In this process, the sender needs to cache the unacknowledged data and number the data. The timeout timer should be longer than the average round trip time of transmission. However, a disadvantage of this method is that it requires waiting, and in the process of waiting, a lot of resources are wasted. So how not to wait?

Continuous ARQ protocol

Send n consecutive packets, waiting time to send other data, when the acknowledgement is received, then send the next data. You can think of it as a window, first send all the data in the window, when the data in front of the window received confirmation, move back to the sliding window, send new data in the window. The TCP protocol is called the sliding window protocol. The receiver generally adopts the method of cumulative confirmation. It is not necessary to send confirmation to all the received data, but to confirm the packet that arrives last in the sequence. Indicates that all groups prior to this group are received. The downside is that if the middle one is lost, subsequent data will be re-sent by the sender even if it arrives successfully. In this way, reliable transmission over unreliable networks can be accomplished.

Transport layer agreement

UDP

The user datagram protocol does not need to establish a connection before transmission, and the destination host does not need to confirm receiving a UDP packet. Therefore, it is an unreliable transmission mode. The application layer DNS, DHCP, SNMP, NFS all use this protocol, what function did he add to the IP protocol? Reuse and sharing must have some function, error detection should also have some function. But it does not provide reliable transmission, that is, if the data is wrong, it is discarded. Retransmission was not confirmed. Features are as follows:

  1. Connectionless: No connection is required before transmission
  2. Use best effort delivery: reliability is not guaranteed
  3. Packet-oriented: Packets delivered to the application layer are directly transmitted after the UDP header is added. Do not split and merge.
  4. There is no congestion control: therefore, when the network is congested, it still sends out at the original rate and the speed will not decrease. This is great for applications that require real time, where data loss is fine. But the lack of congestion control can make the network worse.
  5. Support one-to-one, one-to-many, and many-to-many
  6. The first

Port number, destination port number, data part length, check and (check for errors in datagram transmission and lose data after calculation if errors are found), a total of only 8 bytes.

TCP

Transmission control protocol (TCP), which establishes a connection before transmission and releases the connection after transmission. After receiving the packet, the destination host confirms that the packet is correct and sends an acknowledgement. Compared to UDP really a lot more overhead. Application layer HTTP, FTP and so on all use this protocol transmission. Main features:

  1. Connection-oriented: A connection must be established before transmission and released after transmission, just like a phone call.
  2. Only one to one support
  3. Provide reliable delivery service to ensure that the delivered data is not wrong, not lost, not repeated, on demand.
  4. Provides full duplex communication services. Both the sending and receiving sides have caches for temporary storage of data.
  5. Byte stream oriented: A stream is a sequence of itself flowing into or out of a process, treating the data delivered by the application layer as a series of unstructured byte streams.
  6. The start end is a socket with an IP address and port
  7. Header: TCP provides reliable transport services required data are in the header, let’s see how it looks.

“Sending port and destination port” : consistent with UDP “serial number” : To achieve reliable transmission as described above, if you want to achieve confirmation, you need to mark the data by serial number. Since TCP is byte stream oriented, its value is the number of bytes at the beginning of the whole data. 4 bytes Confirmation Number: indicates the number of the first data expected to receive the next packet from the peer party. It takes 4 bytes. In an acknowledgement message, if 400 is acknowledged, all data up to 400 bytes has been received. Data Offset: Indicates how far the data part of the TCP packet is from the start of the TCP. This is how long the TCP header is “urgent URG” : when this value is 1, it indicates that this data is urgent and should be delivered as soon as possible. Confirm: The ACK number is valid only when it is 1. The ACK number is invalid when it is 0. “Push” : If PSH is 1, when such data is received, it is immediately delivered to the upper application layer, rather than waiting until the cache of received data is full. Reset: RsT 1 indicates that a serious error occurs in the TCP connection and the connection must be released. Sync: The SYN is in sync sequence when the connection is established. A value of 1 indicates that this is a connection request or a connection receive message. Terminate: The FIN releases a connection on. A value of 1 indicates that data from the sender has been sent. Need to release connection “window” : 2 bytes. This data dynamically adjusts the sender’s send window. If the receiver’s receive cache is nearly full and the receiving speed cannot catch up with the sending speed, if the receiver still sends data at the original speed, it will definitely cause the receiver to lose data because the receive cache will be full. If you want to send slowly, make the window value smaller. This value is typically the remaining bytes of data received from the cache. Check and: contains 2 bytes. The check includes the header and data, similar to UDP.

Compare the header of TCP and UDP with the principle of reliable transport. How does TCP achieve reliable transport? The next section covers the TCP part in more detail, including connection establishment and reliable transport.

This article is formatted using MDNICE