8.2 Explanation transport layer TCP / UDP
As a software program ape, we can only decide what the application layer protocol. Other layers are fixed
TCP
- Stream protocol known as TCP protocol (streaming protocol): pass like water, like, we need a two-way pipeline
- Establish a connection (dig the pipeline) :( 3-way handshake)
- 1 Handshake: A client sent a request to the server (SYN = 1, Seq = x): I'm going to connect you, okay? →
- Two handshakes: the server replies to the client request (ACK = 1, Seq = x): can. At the same time, the server to the client sends a request (SYN = 1, Seq = y): I have to connect you, okay?
3-way handshake: a client server's reply to the request (ACK = 1, Seq = y): can.
This establishes a two-way connection
- Disconnect: As the server does not necessarily pass through after the client's data, it requires four steps (four break)
- 1: The client sends a request to the server end (FIN = 1)
2: the server's reply to the requesting client (ACK = 1)
Here the server will transmit the data to the client transmits a disconnection request End Chuancai
- 3: the server sends a request to the client (FIN = 1)
4: The client requests the server to reply (ACK = 1)
- Establish a connection (dig the pipeline) :( 3-way handshake)
SYN = 1 indicates that this is a request
ACK = 1 indicates that this is an acknowledgment
seq = x indicates the serial number is x, the service side is used to confirm the end of the service responses sent just I
TCP is a reliable protocol, what is reliable agreement? Reliable is specified: When the sender sends the data to the receiving end when the other end will reply with a message telling the sender that I received. If the sender did not receive a reply, it is re-issued.
- TCP Features:
- Transmission efficiency is low
Reliable data transmission
TCP protocol, also known as streaming protocol (STREAM), because the data flow is sent, so stick pack phenomenon occurs
- Streaming protocols:
- Stick pack phenomenon occurs
- Not send dummy data
- Send and receive can be many to many
UDP
- UDP does not require digging pipe (no connection exists), as long as know the target, direct contracting will not be confirmed if it was received.
- UDP transmission speed quickly: without establishing a connection, do not need to confirm if it was received
Unreliable protocol (if the network and other problems, most likely packet loss)
UDP protocol, also known as Datagram Protocol (DataGRAM), will not stick pack phenomenon
- Datagram Protocol:
- Stick pack phenomenon does not occur
- Null data can be sent (comes header, so the data is not actually empty)
- sendto and recvfrom is one relationship