- The transport layer is oriented communication function in the highest level, the lowest level is user-oriented functions.
First, the role of the transport layer
AP~n~
Representatives of the various processes (communication between the host and host communication is not, in fact, communication between application processes)IP协议
Communication between the host and the host: the scope端口
: Actually a port identifier marks which process data is sent, or which process should be handed over.运输层协议
TCP and UDP scope: from process to process网络层(IP协议)
It provides a logical communication between the host and运输层(TCP/UDP协议)
the logical end to provide communication between the application process
Transport layer functions and protocols:
- In a host of processes often have multiple applications and multiple applications simultaneously another host in-process communication, indicating that the transport layer there are two very important functions:
复用
and分用
- Depending on the needs of the application, the transport layer requires two different transport protocols, i.e.,
面向连接的TCP
and无连接的UDP。
Based on points with port and reuse
- TCP and UDP face different processes have different communication needs of packets, which will eventually be encapsulated into IP datagrams, the destination subdivided, split to split according to the protocol field in the IP datagram header , separation of TCP and UDP
Shielding effect
transport layer shields the high-level user detail below core network (e.g., network topology, routing protocol is employed), it makes the application process to see if there is a transport layer between the two entities端到端的逻辑通信信道
Second, the two protocols TCP / IP transport layer
- This transport layer logical communications channel performance due to the transport of upper layer protocols use different but very different
用户数据报协议UDP
:- Features: Fast, simple, unreliable
- When the transport layer is employed
无连接的UDP协议
, the logical communication channel such是一条不可靠信道
as with UDP, it is connectionless, it does not matter here is the concept of full-duplex, half-duplex.
传输控制协议TCP
:- reliable
- Provides connection-oriented services: network layer in front of the virtual circuit and stresses datagram, the datagram is connectionless, the concept of which is the network layer, the transport layer is not how the lower layer is achieved. In the transport layer it appears to be a connection, but also one to one connection!
- It does not provide a broadcast and multicast service, although the underlying transport network is not reliable, the bottom is not full duplex, but this corresponds to a logical communication channel
全双工可靠信道
(不用管下层怎么样
additional TCP how to ensure reliable transmission, will later mentioned)
application How to choose what kind of agreement?
Third, the concept of port
- The process uses a computer
进程标识符
to flag. However, each process should not let the computer's operating system to assign its process identifier, because different operating systems can lead to too much identifier format, easy to deal with. Usually it is the port number assigned by the same method - Flag port number with a port 16, it only has local meaning, only to flag
本计算机各个应用进程
, port number of the same name of the computer is no different from a contact (non-computer communicate with each other). So when two computers communicate, you need to know the IP address and port number can.
Port Number two categories:
服务器端使用的端口号
- Well-known port, the value is generally 0-1023 (common)
- Registration port number value of 1024-49151. This range of port numbers must be in the IANA level, in order to prevent duplication. (Future for registering
有可能
a port number is called well-known port number.)
客户端使用的端口号
- Also known as ephemeral port number, the value is 49152-65535, leaving the client process to select a temporary use. (After the communication, the port number is released out)
Fourth, the User Datagram Protocol (UDP)
- Unit called a transport protocol packet or a UDP user datagram
特点
:- Fast, unreliable and simple.
- UDP is a connectionless, i.e. without establishing a connection before sending data, thereby reducing the overhead and time delay before data transmission.
- UDP maximum effort delivery, does not guarantee reliable delivery, and regardless of the amount of data congestion level, made a get away.
UDP是面向报文的
The entire application layer packets to the IP datagram.- Long application layer to the UDP packet, it sends UDP packets long, how long do not cares, not split, no packet, once finished. Therefore, the application itself must select the appropriate size of the packet.
- Long application layer to the UDP packet, it sends UDP packets long, how long do not cares, not split, no packet, once finished. Therefore, the application itself must select the appropriate size of the packet.
- UDP support of many, one to one, many to one, many to many interactive communication
- UDP header overhead small, only 8 bytes.
- UDP only in the IP datagram service-oriented a little extra functionality:
- Multiplexing and demultiplexing functions
- Error detection function
- IP datagram header has a header checksum, only to complete the inspection of the header.
- UDP can also detect errors
优点:
Although UDP only provides unreliable delivery, but UDP has its particular advantages in some respects. Suitable for高实时性
and on安全要求不是很高
occasion, such as live video. ()
UDP header format
- UDP has two fields : a header and data fields. Header field: 8 bytes, divided into four fields, each field in 2 bytes. The following structure:
- Pseudo-header: when calculating the checksum, the temporary connecting together the "pseudo-header" and UDP User Datagram. To calculate the checksum.
Five, TCP protocol
Feature
- TCP to achieve many functions, such as reliable transmission, flow control, congestion control, connection is established, the release connections
- Protocol transfer unit is called
TCP报文段
- Designed for TCP transport layer protocol.
- Each TCP connection can have only two endpoints, each TCP connection only
点对点的
(one to one) - Spectrum transmission to provide reliable, full duplex communication (both ends transceiver buffer ???), the byte stream oriented (UDP packet oriented)
Byte stream oriented concepts
- The procedure shown below, and transmitted to the recipient of the transmission process stream of bytes: 0123456 ...... 21
TCP connection
- Endpoint not host TCP connections, nor is the IP address of the host, nor is the application process, nor is the transport layer protocol port (port and application process lacks distinction), it is called TCP connection endpoints
套接字或插口
. - Sockets actually indicates which application process on which host.
- Each TCP connection has two ends, so there are two connection ports TCP sockets composition:
- TCP is a connection
虚连接
rather than a real physical connection exists. (Both sides acknowledge that there is a connection, but there is actually wood) - TCP applications for long once the message is sent to the TCP cache is not concerned with the application made on how the hair so, as long as the cache memory on the line. However, when the data in the cache when the outbound messages of the TCP is determined by.
- TCP is given according to the other side
端口值和当前网络拥塞的程度
to determine a segment should contain the number of bytes. It may be too short partial data blocks that may be forwarded together with the accumulated first byte is stored for a while. (UDP packets sent is completely determined by the process)
- TCP is given according to the other side