当前位置:网站首页>TCP and UDP
TCP and UDP
2022-06-25 08:07:00 【Shrek】
List of articles
TCP and UDP It's all transport layer protocols , They all belong to TCP/IP Protocol family
One 、UDP
UDP The full name is User datagram protocol , In the Internet, it's connected with TCP The protocol is also used to process packets , It's a connectionless protocol . stay OSI In the model On the transport layer , be in IP The next level of agreement .UDP Packet Grouping is not provided 、 Disadvantages of assembly and sequencing ; namely , When the message is sent , It is impossible to know whether it arrived safely and completely .
1) Facing connectionless
UDP You don't need to be with TCP Before sending data Three handshakes Connected , Data can be sent at any time . And it's just a data message carrier , There will be no splitting and splicing operation for data message .
- At the sending end , The application layer transfers data to the transport layer ,
UDP Only one... Will be added to the data UDP Head sign, And then it goes to the network layer - At the receiving end , The network layer passes the data to the transport layer ,
UDP Will only remove IP The message header will not have any splicing operation, Then it is passed to the application layer
2)UDP Provides unicast , multicast , The function of broadcasting .
3) Message oriented
The sender's UDP Message delivered to the application , After adding the header, it will be delivered down to IP layer .UDP For the messages handed in by the application layer , Neither merge , It doesn't break up , But keep the boundaries of these messages . therefore , The application must choose the appropriate size of the message .
4) Unreliability
- First of all, unreliability is reflected in
On no connection, There is no need to establish a connection when communicating . - also
The data received will be transmitted, alsoNo backup data, Sending data is alsoIt doesn't care whether the other party has received the data correctly. - Moreover, the network environment is good or bad , however
UDP Because there's no congestion control , Always send data at a constant speed. Even if the network conditions are not good , It will not adjust the transmission rate . In this wayThe disadvantage is that packet loss may occur when the network conditions are not good, howeverThe advantage is that in some real-time scenarios( For example, conference call ) You need to use UDP instead of TCP.
5) Small overhead , Very efficient when transmitting data messages
UDP The cost of the head is small , Only 8 byte , comparison TCP At least 20 There are far fewer bytes , It's very efficient to transmit data messages .
Two 、TCP
TCP The full name is Transmission control protocol It's a connection oriented 、 reliable 、 Transport layer communication protocol based on byte stream .TCP It's connection-oriented 、 Reliable Streaming Protocol ( Flow is a continuous data structure ).
1) Connection oriented
Connection oriented , It means that a connection must be established at both ends before sending data . The method of establishing the connection is Three handshakes To establish a connection , Lay a foundation for reliable data transmission .
2) Only unicast transmission is supported
Every one of them TCP A transport connection can only have two endpoints , Only point-to-point data transmission ; Multicast is not supported 、 Broadcast transmission mode .
3) Byte stream oriented
TCP Unlike UDP Just like that, messages are transmitted independently , It is transmitted in byte stream mode without retaining the message boundary .
4) Reliable transmission
Judge packet loss 、 The error code depends on TCP Of Segment number as well as Confirmation no. .TCP In order to ensure the reliability of message transmission , 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 bytes that have been successfully received (ACK); If the sender entity has a reasonable round-trip delay (RTT) No confirmation has been received within , So the corresponding data ( Suppose we lost ) Will be retransmitted .
5) Provide congestion control
When the network appears congestion When ,TCP It can reduce the cost of injecting data into the network rate and Number , Ease congestion .
6) Provide full duplex communication
TCP Allow applications on both sides of the communication to send data at any time , because TCP There are buffers at both ends of the connection , Used to temporarily store data for two-way communication . Of course ,TCP You can send a segment of data immediately , You can also cache a period of time to send more data segments at a time ( The maximum segment size depends on MSS)
3、 ... and 、TCP and UDP The difference between
| UDP | TCP | |
|---|---|---|
| Is it connected | There is no connection | Connection oriented |
| reliable | Unreliable transmission , No flow control and congestion control | Reliable transmission ( Data order and correctness ), Using flow control and congestion control |
| Number of connected objects | Support one-to-one , One to many , Many to one and many to many interactive communication | It can only be one-to-one communication |
| transport | Message oriented | Byte stream oriented |
| First cost | Small overhead of the first part , only 8 byte | The first is the smallest 20 byte , Maximum 60 byte |
| Applicable scenario | For real-time applications , For example, video conference 、 live broadcast | For applications requiring reliable transmission , For example, file transfer |
Four 、TCP and UDP Usage scenarios of
TCP Application scenarios :
Efficiency requirements are relatively low , But the scenes with relatively high requirements for accuracy . Because the data needs to be confirmed in the transmission 、 retransmission 、 Sorting and other operations , By contrast, efficiency is not UDP high . for example : File transfer ( High accuracy and high requirements 、 But the speed can be relatively slow )、 Take mail 、 Remote login .
UDP Application scenarios :
Efficiency requirements are relatively high , Scenes with relatively low accuracy requirements . for example :QQ Chat 、 Online video 、 Voice over the Internet ( im , High speed requirement , But it's not a big problem to have occasional interruptions , And the resend mechanism can't be used here at all )、 Broadcast communications ( radio broadcast 、 multicast ).
5、 ... and 、 Data flow diagram

边栏推荐
- FM信号、调制信号和载波
- 什么是SKU和SPU,SKU,SPU的区别是什么
- Luogu p6822 [pa2012]tax (shortest circuit + edge change point)
- DNS协议及其DNS完整的查询过程
- 电子学:第008课——实验 6:非常简单的开关
- What are the problems with traditional IO? Why is zero copy introduced?
- RMQ interval maximum subscript query, interval maximum
- Analysis and utilization of Microsoft Office Word remote command execution vulnerability (cve-2022-30190)
- Luogu p2839 [national training team]middle (two points + chairman tree + interval merging)
- Drawing of clock dial
猜你喜欢

Ubuntu18下登录mysql 5.7设置root密码

420-二叉树的层序遍历2(429. N 叉树的层序遍历、515.在每个树行中找最大值、116.填充每个节点的下一个右侧节点指针、104.二叉树的最大深度、111.二叉树的最小深度)

50 pieces of professional knowledge of Product Manager (IV) - from problem to ability improvement: amdgf model tool

Looking for b-end product manager after years? I almost ruined myself

电子学:第012课——实验 11:光和声

共话云原生数据库的未来

Mining microbial dark matter -- a new idea

剑指offer刷题(中等等级)

417-二叉树的层序遍历1(102. 二叉树的层序遍历、107.二叉树的层次遍历 II、199.二叉树的右视图、637.二叉树的层平均值)

Modeling and fault simulation of aircraft bleed system
随机推荐
唐老师讲运算放大器(第七讲)——运放的应用
洛谷P2839 [国家集训队]middle(二分 + 主席树 + 区间合并)
c#中设置lable控件的TextAlign属性控制文字居中的方法
函数尽量不要通过变量指定操作类型
CAN总线工作状况和信号质量“体检”
PHP array function Encyclopedia
自制坡道,可是真的很香
Electronics: Lesson 014 - Experiment 15: intrusion alarm (Part I)
现在通过开户经理发的开户链接股票开户安全吗?
Electronics: Lesson 010 - Experiment 9: time and capacitors
Electronics: Lesson 013 - Experiment 14: Wearable pulsed luminaries
Linux上oracle和mysql的启动,关闭,重启
Authority design of SaaS system based on RBAC
Electronics: Lesson 009 - Experiment 7: study relays
FM signal, modulated signal and carrier
Socket problem record
Pycharm的奇葩设定:取消注释后立马复制会带上#
电子学:第010课——实验 9:时间与电容器
Logu P2486 [sdoi2011] coloring (tree chain + segment tree + merging of intervals on the tree)
Application of can optical transceiver of ring network redundant can/ optical fiber converter in fire alarm system