当前位置:网站首页>为什么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

边栏推荐
- 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
- (validation file) validatejarfile report errors
- AXI协议基础知识
- Cs0006 C failed to find metadata file "c:\users\... Problem
- vscode保存代码时自动eslint格式化
- Recyclerview cache reuse analysis, source code interpretation
- Real time myth -- real-time RTOS multitask performance analysis
- Connect the server with springboard / fortress through xshell
- Environment configuration and pymysql installation
- 说说集合的面试题
猜你喜欢

Docker安装mysql5.7(开启binlog功能、修改字符)

Message queue push / pull mode Learning & ActiveMQ and JMS learning

vscode保存代碼時自動eslint格式化

一套ThinkPHP微信小程序商城源码带后台管理

vscode配置eslint自动格式化报错“The setting is deprecated. Use editor.codeActionsOnSave instead with a source“

LeetCode——42. Connected to rainwater (double pointer)

From a "trendsetter" to a "wind chaser", can master Kang still lead the market?

Sohu tout le personnel a été escroqué, quels problèmes ont été exposés?

Katalon Studio Enterprise

用实际案例分析PMP与ACP应该考哪个?哪个更有用?
随机推荐
[pytest learning] after the pytest case fails to execute, the others will not be executed
Learning C language from scratch day 039
LeetCode-384. Scramble array
vscode配置eslint自动格式化报错“Auto Fix is enabled by default. Use the single string form“
如何成为一个乐观派组织?
Typescript learning notes (II)
My C の errors
说说集合的面试题
Chip mass production, oppo entering a new era?
Global and China Mobile Network Optimization (MnO) industry development panoramic survey and Investment Strategy Research Report 2022-2028
TypeScript学习笔记(二)
Song of the sea in 5g Era
GUI guess number game, directly open play
Derivation of child numbering formula for nodes numbered I in full k-ary tree
vscode保存代码时自动eslint格式化
Recyclerview cache reuse analysis, source code interpretation
《DAMA数据管理知识体系指南》:章节分值占比
Axi protocol Basics
C language: use H and C. summary of problems encountered in documents
error:指针作为函数参数错误总结