当前位置:网站首页>Transport layer TCP protocol and UDP protocol

Transport layer TCP protocol and UDP protocol

2022-06-26 04:56:00 The story of Ula

Transport layer protocol

Transport layer :

The transport layer is OSI The most important of all , The most critical layer , It is the only layer responsible for overall data transmission and data control . The transport layer provides a mechanism for end-to-end data exchange , Check the group number and order . The transport layer has three layers above it, such as the session layer , Provide reliable transmission service , Provide reliable destination site information for the network layer .

Transport layer protocol :

The transport layer protocol has TCP( Transmission control protocol ) ,UDP( User datagram protocol ) ,TLS( Safe transport agreement ), DCCP( Datagram congestion control protocol ) , SCTP( Streaming control transport protocol ) ,RSVP( Resource reservation agreement ) , PPTP( Point to point Tunneling Protocol ).

UDP agreement :

 Insert picture description here

  • UDP(User Datagram Protocol), The Chinese name is User datagram protocol , yes OSI(Open System Interconnection, Open system interconnection ) One of the reference models There is no connection Transport layer protocol , Provide simple and unreliable transaction oriented information transfer services ,IETF RFC 768 yes UDP The formal norms of .UDP stay IP The protocol number of the message is 17.
  • UDP Deal with the TCP The protocol is also used to process packets , stay OSI In the model , Both are located at the transport layer , be in IP The next level of agreement .UDP Packet Grouping is not provided 、 The disadvantages of assembling and not being able to sort packets , in other words , When the message is sent , It's impossible to know whether it arrived safely and completely .UDP Used to support network applications that need to transfer data between computers . Including the network video conference system, many customers / Server mode network applications need to use UDP agreement .UDP The protocol has been used for many years since it came out , Although its original glory has been covered by some similar agreements , But even today UDP It is still a very practical and feasible network transport layer protocol .
  • Many applications only support UDP, Such as : Multimedia data stream , No additional data will be generated , Don't resend even if you know that there are broken packets . When transmission performance is emphasized instead of transmission integrity , Such as : Audio and multimedia applications ,UDP Is the best choice . In data transmission time is very short , So that the previous connection process becomes the main body of the whole traffic ,UDP It's also a good choice .

TCP agreement :

Three handshakes :
 Insert picture description here
Four waves :
 Insert picture description here
TCP( Transmission control protocol ) It's connection based . Before sending and receiving data , You have to connect with each other . It needs to go through ’ Three handshakes ’:
First step . First A The host needs and B Set up data transmission between hosts ,A Need to send a request to ask B:‘ I want to establish a connection ’;
The second step . B After receiving the message , Will give A Send a response :‘ Can be connected ’;
The third step . A received B After ,A towards B Respond again :‘ I'm going to start sending ’, They can establish a connection ;
The conclusion of the first handshake was :A The ability to send 、B The reception capacity of is normal .
The conclusion of the second handshake is :B The ability to send 、A The reception capacity of is normal .
The conclusion of the third handshake is :A Reception 、 Sending capability ,B Reception 、 The ability to send is normal .
'3 The second handshake ’ Is that Both sides can define their own and the other side's income 、 Hair power is normal .

  • TCP(Transmission Control Protocol), The Chinese name is Transmission control protocol , It is a transport protocol specially designed to provide reliable end-to-end byte stream on unreliable Internet .
  • TCP agreement It is a reliable connection oriented transmission protocol , You need to create a connection before sending data .
  • The Internet is very different from a single network , Because different parts of the Internet can have very different topologies 、 bandwidth 、 Delay 、 Packet size and other parameters .TCP The goal of the design is to be able to dynamically adapt to these characteristics of the Internet , And has the robustness in the face of various failures .
  • Reliable is often needed between application layers of different hosts 、 A pipe like connection , however IP Layer does not provide such a flow mechanism , It's about providing unreliable packet exchange .
  • Application layer direction TCP Layer send is used for inter network transmission 、 use 8 Data stream represented by bit bytes , then TCP Partition the data stream into message segments of appropriate length ( The largest transmission unit of the data link layer of the network usually connected by the computer (MTU) The limitation of ). after TCP Pass the result package on to IP layer , It transmits the packet to the receiving entity through the network TCP layer .TCP In order to ensure no packet loss , Just give each package a serial number , At the same time, the serial number also ensures the sequential reception of packets sent to the receiving entity . Then the receiving entity sends a corresponding acknowledgement to the received packet (ACK); If the sender entity has a reasonable round-trip delay (RTT) No confirmation has been received within , Then the corresponding packet is assumed to be lost and retransmitted .TCP Use a checksum function to check for data errors ; When sending and receiving, the check sum should be calculated .
  • Each unit supports TCP All of our machines have one TCP Transmission entity .TCP An entity can be a library process 、 A user process , Or part of the kernel . In all these cases , It manages TCP flow , As well as IP Interface between layers .TCP The transport entity accepts the user data stream of the local process , Divide them into no more than 64KB( Actually get rid of IP and TCP head , Usually no more than 1460 Data bytes ) The segmented , Each segment has a separate IP Send in datagram form . When included TCP When a datagram of data reaches a machine , They are delivered to TCP Transmission entity ,TCP The transport entity reconstructs the original byte stream . For the sake of simplification , Sometimes we just use “TCP” To represent the TCP Transmission entity ( A piece of software ) perhaps TCP agreement ( A set of rules ). You should be able to infer its actual meaning clearly from the context semantics . for example , stay “ The user gives the data to TCP” In this sentence , Obviously, this means TCP Transmission entity .
  • IP Layer does not guarantee that the datagram will be delivered to the receiver correctly , It doesn't indicate how fast the datagram is sent . It is TCP Responsible for sending datagrams fast enough , To use network capacity , But it can't cause network congestion : and ,TCP After a timeout , To retransmit undelivered data . Even if the data report is submitted correctly , There may also be a problem of out of order , This is also TCP The responsibility of the , It must reassemble the received datagrams into the correct order . In short ,TCP Good performance of reliability must be provided , This is what most users expect IP There is no function provided .

UDP The protocol and TCP A comparison of agreements :

  • TCP Receiving and sending data is like pipelining , You can receive more than one at a time , Or receive a small part at a time but can receive multiple times ; however UDP Receive as many as you send , If the received data is less than the sent data , So little data will never be received .
  • Every one of them TCP Connections can only be made one-to-one between dots , and UDP Support one-to-one 、 One to many 、 Many to many interactive communication .
  • TCP There is not only a receive buffer but also a send buffer , and UDP Only receive buffer . because TCP In order to be able to retransmit over time, the data that needs to be retransmitted is still , that TCP You need to cache the previously sent data , Easy to resend later , So you need to send the buffer ; however UDP Reliability is not guaranteed , No overtime retransmission , that UDP You don't have to save the data he sent before , therefore UDP There is no send buffer .
  • UDP( User datagram protocol ) It's oriented towards unconnected , Don't connect with each other .

Applicable scenario :

**TCP:** It's full duplex 、 Connection oriented 、 reliable , And precisely controlled protocols . Mainly used for real-time is not strong , But applications with high transmission requirements . For example : Web browsing 、 File download ( No BT、 Computer download )、 E-mail delivery and other occasions , These scenes need TCP Protocol for transmission . Of course , It's expensive on the Internet .
**UDP:** This is an unreliable transport protocol . Because it does not sort the data segments to be sent , It is not responsible for the order in which these data segments arrive at the target ( It's not reliable to say it ). It costs more on the network than TCP Many small , therefore UDP Suitable for those with strong real-time 、 Where mistakes are allowed . for instance : im (MSN、QQ), video 、 Language, etc .
 Insert picture description here
Thousands of miles of mountains and rivers , May you blow the wind of the Aegean Sea .

原网站

版权声明
本文为[The story of Ula]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180509132864.html