当前位置:网站首页>为什么udp流设置1316字节
为什么udp流设置1316字节
2022-06-11 17:16:00 【、、、、南山小雨、、、、】
当我们在用udp推流时经常会看到pkt_size=1316,如下:
ffmpeg -re -i westLife.mp4 -f mpegts udp://127.0.0.1:5000?pkt_size=1316
上述命令中pkt_size=1316是什么意思,它是指udp发送音视频流时,每个udp包所含有的有效负载的大小。
在代码中设置如下:
AVDictionary*dic = NULL;
av_dict_set(&dic, “pkt_size”, “1316”, 0); //Maximum UDP packet size
那么大小为什么是1316呢,以太网的MTU(Maximum Transmission Unit)通常是1500 bytes,因此,最好控制发送报文长度在1500 bytes以下,以TS over UDP场景为例,通常每个TS包大小为188 bytes,因此,每个UDP包中最大可包含TS包的数目为floor((1500 – 8 -20 )/ 188) = 7,即有效数据为188 * 7 = 1316bytes,8和20分别为UDP包头和IP包头的长度。
补充:
MTU(Maximum Transmission Unit)网络上传送的最大数据包大小。
MTU的单位是字节byte,主流网络是以太网(Ethernet)MTU是1500,以太网的相关网络设备MTU是1500。
MTU其实属于OSI参考模型第2层(数据链路层),目的是限定【MAC帧中数据部分(payload)的大小】的值,会影响到【第3层的整个IP封包的大小】,此大小包括IP数据包的包头;而最终IP数据包是要放进MAC帧。
28字节的大小,是 【IP包头的20字节】+ 【ICMP的包头8字节】。
1500 bytes (Ethernet mtu) – 20 byte (IP header) – 8 byte (ICMP header) = 1472 byte
ping -s 1472 -M do 192.168.100.79
如下:
PING 192.168.100.79 (192.168.100.79) 1472(1500) bytes of data.
1480 bytes from 192.168.100.79: icmp_seq=1 ttl=64 time=0.196 ms
1480 bytes from 192.168.100.79: icmp_seq=2 ttl=64 time=0.208 ms
^C
--- 192.168.100.79 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1032ms
rtt min/avg/max/mdev = 0.196/0.202/0.208/0.006 ms
ping -s 1473 -M do 192.168.100.79
PING 192.168.100.79 (192.168.100.79) 1473(1501) bytes of data.
ping: local error: Message too long, mtu=1500
ping: local error: Message too long, mtu=1500
ping: local error: Message too long, mtu=1500
ping: local error: Message too long, mtu=1500
ping: local error: Message too long, mtu=1500
^C
--- 192.168.100.79 ping statistics ---
5 packets transmitted, 0 received, +5 errors, 100% packet loss, time 4099ms

边栏推荐
- Tornado environment construction and basic framework construction -- familiar Hello World
- 启牛商学院给的证券账户是安全的吗?开户收费吗
- LeetCode-859. Intimate string
- 10 times faster than 5g. Are you ready for 10 Gigabit communication?
- sql server中关于FORCESCAN的使用以及注意项
- Oracle database merge row records, wmsys WM_ Use of the concat function and group in MySQL_ Use and comparison of concat (ID).
- leetcode--数组
- Set object mapping + scene 6-face mapping + create space in threejs
- Environment configuration and pymysql installation
- Oracle generates non duplicate string sys_ Guid() and MySQL generate unique values
猜你喜欢

Biden ordered to enforce the zero trust structure
![[pytest learning] after the pytest case fails to execute, the others will not be executed](/img/c7/52ae88cde65bdd12ae8b86df5c477f.png)
[pytest learning] after the pytest case fails to execute, the others will not be executed

Docker installs mysql5.7 (enable binlog function and modify characters)

Authoring share | understanding saml2 protocol

Authing Share|理解 SAML2 协议

DFS和BFS笔记(一)基于C语言的广度优先搜索

Don't you understand the design and principle of thread pool? Break it up and crush it. I'll teach you how to design the thread pool

What problems are exposed when all Sohu employees are cheated?

拜登下令强制推行零信任架构

Global and China Mobile Network Optimization (MnO) industry development panoramic survey and Investment Strategy Research Report 2022-2028
随机推荐
Katalon Studio Enterprise
Create database instance
Connection and difference of network streaming media protocol (RTP RTCP RTMP HLS)
Association relationship
ASP.NET教育OA系统源码 教育行业OA系统源码带文档
AXI协议基础知识
LeetCode-384. Scramble array
定制 or 订阅?未来中国 SaaS 行业发展趋势是什么?
vscode保存代码时自动eslint格式化
Cs0006 C failed to find metadata file "c:\users\... Problem
TypeScript学习笔记(二)
which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod
Vscode configures eslint to automatically format with an error "the setting is deprecated. use editor.codeactionsonsave instead with a source“
Redis - learn five types of NoSQL
DFS and BFS notes (I) breadth first search based on C language
Go get downloaded package path
How does Sister Feng change to ice?
Talk about the interview questions of the collection
Read and understand the development plan for software and information technology service industry during the "14th five year plan"
Analyze which should be tested in PMP and ACP with actual cases? Which is more useful?