CN106302372A - Network media stream packet receiving method, Apparatus and system - Google Patents
Network media stream packet receiving method, Apparatus and system Download PDFInfo
- Publication number
- CN106302372A CN106302372A CN201510325987.9A CN201510325987A CN106302372A CN 106302372 A CN106302372 A CN 106302372A CN 201510325987 A CN201510325987 A CN 201510325987A CN 106302372 A CN106302372 A CN 106302372A
- Authority
- CN
- China
- Prior art keywords
- kernel
- packet receiving
- relief area
- user
- user side
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/60—Network streaming of media packets
- H04L65/75—Media network packet handling
- H04L65/764—Media network packet handling at the destination
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/40—Network security protocols
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Multimedia (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明提供了一种网络媒体流收包方法、装置及系统,其中,该方法接收用户侧取数据包的指令,其中,该指令包括预设收包数量,从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将该预设收包数量个数据包发送给该用户侧的用户接收缓冲区,解决了系统频繁调用网络数据包,严重降低流媒体服务器性能的问题,提高了流媒体服务器对外服务能力。
The present invention provides a network media stream packet receiving method, device and system, wherein the method receives an instruction for fetching data packets from the user side, wherein the instruction includes a preset number of packets to be received, and is obtained from the kernel receiving buffer of the kernel space After the preset number of data packets received, send the preset number of data packets to the user receiving buffer on the user side, which solves the problem that the system frequently calls network data packets and seriously reduces the performance of the streaming media server, and improves the performance of the streaming media server. The external service capability of the streaming media server is improved.
Description
技术领域technical field
本发明涉及通信领域,具体而言,涉及一种网络媒体流收包方法、装置及系统。The present invention relates to the communication field, in particular, to a method, device and system for receiving network media stream packets.
背景技术Background technique
在Unix/Linux等操作系统中,一般通过网络套接字使用系统调用接收网络数据包。在数据包的接收过程中,需要通过相关系统调用陷入内核态,将网卡接收的数据包从内核接收缓存拷贝到用户缓冲区。对用户数据协议(User Date Protocol,简称为UDP)码流,收包的系统调用recvfrom每次只能返回一个包。In operating systems such as Unix/Linux, network packets are generally received through network sockets using system calls. In the process of receiving data packets, it is necessary to fall into the kernel state through relevant system calls, and copy the data packets received by the network card from the kernel receiving buffer to the user buffer. For the User Data Protocol (UDP) code stream, the system call recvfrom for receiving packets can only return one packet at a time.
在相关技术中,对网络协定电视(Internet Protocol Television,简称为IPTV)流媒体服务器来说可能需要接收来自编码器的两百个以上频道的直播码流。以200个频道,每个频道码率8Mbps来计算,需要接收的流量达到1.6Gbps;如果是4K分辨率超高清频道,按平均20Mbps计算,流量将达到4Gbps。假设编码器发出来的UDP包每个大小为1500字节,在4K分辨率的情况下,每秒的系统调用将达到33万次以上。系统调用的开销严重影响流媒体服务器性能和其对外服务的能力。In related technologies, an Internet Protocol Television (IPTV for short) streaming server may need to receive live code streams of more than two hundred channels from an encoder. Calculated on the basis of 200 channels with a code rate of 8Mbps for each channel, the traffic to be received will reach 1.6Gbps; if it is a 4K resolution ultra-high-definition channel, calculated at an average of 20Mbps, the traffic will reach 4Gbps. Assuming that the size of each UDP packet sent by the encoder is 1500 bytes, in the case of 4K resolution, the system calls per second will reach more than 330,000 times. The overhead of system calls seriously affects the performance of the streaming media server and its external service capabilities.
针对相关技术中,系统频繁调用网络数据包,严重降低流媒体服务器性能的问题,目前尚未提出有效的解决方案。Aiming at the problem in the related technology that the system frequently invokes network data packets and seriously reduces the performance of the streaming media server, no effective solution has been proposed yet.
发明内容Contents of the invention
本发明提供了一种网络媒体流收包方法、装置及系统,以至少解决相关技术中系统频繁调用网络数据包的问题。The present invention provides a network media stream packet receiving method, device and system to at least solve the problem in the related art that the system frequently invokes network data packets.
根据本发明的一个方面,提供了一种网络媒体流收包方法,包括:According to one aspect of the present invention, a method for receiving network media stream packets is provided, including:
接收用户侧取数据包的指令,其中,所述指令包括预设收包数量;receiving an instruction from the user side to fetch data packets, wherein the instruction includes a preset number of received packets;
从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将所述预设收包数量个数据包发送给所述用户侧的用户接收缓冲区。After acquiring the preset received data packets from the kernel receiving buffer in the kernel space, sending the preset received data packets to the user receiving buffer on the user side.
进一步地,所述从内核空间的内核接收缓冲区获取预设收包数量个数据包包括:Further, said obtaining a preset number of received packets from the kernel receiving buffer of the kernel space includes:
在内核空间中注册探测函数,所述探测函数从内核空间的内核接收缓冲区获取所述预设收包数量个数据包。A detection function is registered in the kernel space, and the detection function obtains the preset number of received packets from the kernel receiving buffer of the kernel space.
进一步地,所述指令包括标识参数,所述从内核空间的内核接收缓冲区获取预设收包数量个数据包包括:Further, the instruction includes an identification parameter, and the acquisition of a preset number of received packets from the kernel receive buffer in the kernel space includes:
在内核空间中识别与所述标识参数对应的探测函数,所述探测函数从内核空间的内核接收缓冲区获取所述预设收包数量个数据包。A detection function corresponding to the identification parameter is identified in the kernel space, and the detection function obtains the preset number of received packets from a kernel receiving buffer in the kernel space.
进一步地,所述接收用户侧取数据包的指令之后包括:Further, after receiving the instruction for fetching data packets from the user side, it includes:
在所述内核空间的内核接收缓冲区内的数据包数量小于所述预设收包数量的情况下,将当前所述内核空间的内核接收缓冲区内的数据包发送给所述用户侧的用户接收缓冲区。In the case that the number of data packets in the kernel receiving buffer of the kernel space is less than the preset number of received packets, the current data packets in the kernel receiving buffer of the kernel space are sent to the user on the user side Receive buffer.
进一步地,在将所述预设收包数量个数据包发送给所述用户侧的用户接收缓冲区的同时,还将所述数据包的辅助信息发送给所述用户侧的用户接收缓冲区,其中,所述辅助信息包括以下至少之一:数据包长度、接收时间、源IP地址、端口号。Further, while sending the data packets of the preset number of received packets to the user receiving buffer of the user side, the auxiliary information of the data packets is also sent to the user receiving buffer of the user side, Wherein, the auxiliary information includes at least one of the following: data packet length, receiving time, source IP address, and port number.
根据本发明的另一个方面,还提供了一种网络媒体流收包方法,包括:According to another aspect of the present invention, a method for receiving network media stream packets is also provided, including:
用户侧发送取数据包的指令,其中,所述指令包括预设收包数量;The user side sends an instruction to fetch data packets, wherein the instruction includes a preset number of received packets;
所述用户侧的用户接收缓冲区接收从内核空间发送的所述预设收包数量个数据包,所述预设收包数量个数据包是从所述内核空间的内核接收缓冲区获取的。The user receiving buffer on the user side receives the preset number of data packets sent from the kernel space, and the preset number of data packets are obtained from the kernel receiving buffer of the kernel space.
进一步地,所述预设收包数量的计算因子包括以下至少之一:Further, the calculation factor of the preset number of received packets includes at least one of the following:
码率,收包间隔。Code rate, packet receiving interval.
根据本发明的另一个方面,还提供了一种网络媒体流收包装置,包括:According to another aspect of the present invention, a network media stream packet receiving device is also provided, including:
第一接收模块,用于接收用户侧取数据包的指令,其中,所述指令包括预设收包数量;The first receiving module is configured to receive an instruction for fetching data packets from the user side, wherein the instruction includes a preset number of received packets;
获取模块,用于从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将所述预设收包数量个数据包发送给所述用户侧的用户接收缓冲区。The acquisition module is configured to acquire the preset received data packets from the kernel receiving buffer in the kernel space, and then send the preset received data packets to the user receiving buffer on the user side.
进一步地,所述获取模块包括:Further, the acquisition module includes:
第一获取单元,用于在内核空间中注册探测函数,所述探测函数从内核空间的内核接收缓冲区获取所述预设收包数量个数据包。The first obtaining unit is configured to register a detection function in the kernel space, and the detection function obtains the preset number of received packets from the kernel receiving buffer of the kernel space.
进一步地,所述指令包括标识参数,所述获取模块包括:Further, the instruction includes an identification parameter, and the acquisition module includes:
第二获取单元,用于在内核空间中识别与所述标识参数对应的探测函数,所述探测函数从内核空间的内核接收缓冲区获取所述预设收包数量个数据包。The second obtaining unit is configured to identify a detection function corresponding to the identification parameter in the kernel space, and the detection function obtains the preset number of received packets from the kernel receiving buffer of the kernel space.
进一步地,所述获取模块包括:Further, the acquisition module includes:
第三获取单元,用于在所述内核空间的内核接收缓冲区内的数据包数量小于所述预设收包数量的情况下,将当前所述内核空间的内核接收缓冲区内的数据包发送给所述用户侧的用户接收缓冲区。The third acquisition unit is used to send the data packets currently in the kernel receiving buffer of the kernel space when the number of data packets in the kernel receiving buffer of the kernel space is less than the preset number of received packets Give the user receive buffer on the user side.
进一步地,所述装置还包括:Further, the device also includes:
第一发送模块,用于将所述数据包的辅助信息发送给所述用户侧的用户接收缓冲区,其中,所述辅助信息包括以下至少之一:数据包长度、接收时间、源IP地址、端口号。The first sending module is configured to send the auxiliary information of the data packet to the user receiving buffer of the user side, wherein the auxiliary information includes at least one of the following: data packet length, receiving time, source IP address, The port number.
根据本发明的另一个方面,还提供了一种网络媒体流收包装置,包括:According to another aspect of the present invention, a network media stream packet receiving device is also provided, including:
第二发送模块,用于用户侧发送取数据包的指令,其中,所述指令包括预设收包数量;The second sending module is used for the user side to send an instruction for fetching data packets, wherein the instruction includes a preset number of received packets;
第二接收模块,用于所述用户侧的用户接收缓冲区接收从内核空间发送的所述预设收包数量个数据包,所述预设收包数量个数据包是从所述内核空间的内核接收缓冲区获取的。The second receiving module is used for the user receiving buffer on the user side to receive the preset number of data packets sent from the kernel space, the preset number of data packets received from the kernel space Acquired by the kernel receive buffer.
进一步地,所述预设收包数量的计算因子包括以下至少之一:Further, the calculation factor of the preset number of received packets includes at least one of the following:
码率,收包间隔。Code rate, packet receiving interval.
根据本发明的另一个方面,还提供了一种网络媒体流收包系统,其特征在于,包括:用户侧设备,内核设备;According to another aspect of the present invention, there is also provided a network media stream packet receiving system, which is characterized in that it includes: a user side device, a kernel device;
所述内核设备接收用户侧设备取数据包的指令,其中,所述指令包括预设收包数量;The kernel device receives an instruction from the user-side device to fetch data packets, wherein the instruction includes a preset number of received packets;
从所述内核设备的内核接收缓冲区获取预设收包数量个数据包后,将所述预设收包数量个数据包发送给所述用户侧设备的用户接收缓冲区。After acquiring the preset received data packets from the kernel receiving buffer of the kernel device, sending the preset received data packets to the user receiving buffer of the user-side device.
通过本发明,采用接收用户侧取数据包的指令,其中,该指令包括预设收包数量,从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将该预设收包数量个数据包发送给该用户侧的用户接收缓冲区,解决了系统频繁调用网络数据包,严重降低流媒体服务器性能的问题,提高了流媒体服务器对外服务能力。According to the present invention, an instruction for receiving data packets from the user side is adopted, wherein the instruction includes a preset number of received packets, and after obtaining the preset number of data packets from the kernel receiving buffer in the kernel space, the preset received packets A number of data packets are sent to the user receiving buffer on the user side, which solves the problem that the system frequently calls network data packets and seriously reduces the performance of the streaming media server, and improves the external service capability of the streaming media server.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings described here are used to provide a further understanding of the present invention and constitute a part of the application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations to the present invention. In the attached picture:
图1是根据本发明实施例的一种网络媒体流收包方法的流程图一;Fig. 1 is a flow chart one of a method for receiving packets of a network media stream according to an embodiment of the present invention;
图2是根据本发明实施例的一种网络媒体流收包方法的流程图二;Fig. 2 is a flow chart two of a method for receiving packets of a network media stream according to an embodiment of the present invention;
图3是根据本发明实施例的一种网络媒体流收包装置的结构框图一;Fig. 3 is a structural block diagram 1 of a network media stream packet receiving device according to an embodiment of the present invention;
图4是根据本发明实施例的一种网络媒体流收包装置的结构框图二;Fig. 4 is a structural block diagram 2 of a network media stream packet receiving device according to an embodiment of the present invention;
图5是根据本发明优选实施例的网络收包系统示意图。Fig. 5 is a schematic diagram of a network packet receiving system according to a preferred embodiment of the present invention.
具体实施方式detailed description
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。Hereinafter, the present invention will be described in detail with reference to the drawings and examples. It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that the terms "first" and "second" in the description and claims of the present invention and the above drawings are used to distinguish similar objects, but not necessarily used to describe a specific sequence or sequence.
在本实施例中提供了一种网络媒体流收包方法,图1是根据本发明实施例的一种网络媒体流收包方法的流程图一,如图1所示,该流程包括如下步骤:A method for receiving packets of network media streams is provided in the present embodiment. FIG. 1 is a flowchart one of a method for receiving packets of network media streams according to an embodiment of the present invention. As shown in FIG. 1 , the process includes the following steps:
步骤S102,接收用户侧取数据包的指令,其中,该指令包括预设收包数量;Step S102, receiving an instruction from the user side to fetch data packets, wherein the instruction includes a preset number of received packets;
步骤S104,从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将该预设收包数量个数据包发送给该用户侧的用户接收缓冲区。Step S104, after obtaining the preset number of received data packets from the kernel receiving buffer in the kernel space, sending the preset received number of data packets to the user receiving buffer on the user side.
通过上述步骤,接收用户侧取数据包的指令,从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将该预设收包数量个数据包发送给该用户侧的用户接收缓冲区,实现了可以按照用户侧的指令取一定数量的数据包,而不是每次只取一个数据包,解决了系统频繁调用网络数据包,严重降低流媒体服务器性能的问题,提高了流媒体服务器对外服务能力。Through the above steps, the command to fetch data packets from the user side is received, and after obtaining the preset number of packets received from the kernel receiving buffer in the kernel space, the preset number of packets received is sent to the user on the user side for reception. Buffer, which realizes that a certain number of data packets can be fetched according to the instructions of the user side, instead of only fetching one data packet each time, which solves the problem that the system frequently calls network data packets and seriously reduces the performance of the streaming media server, and improves the performance of the streaming media. Server external service capability.
在本实施例中,可以在内核空间中注册探测函数,该探测函数从内核空间的内核接收缓冲区获取该预设收包数量个数据包。也可以在该指令包括标识参数的情况下,在内核空间中识别与该标识参数对应的探测函数,该探测函数从内核空间的内核接收缓冲区获取该预设收包数量个数据包。In this embodiment, a detection function may be registered in the kernel space, and the detection function obtains the preset received number of data packets from the kernel receiving buffer of the kernel space. In the case that the instruction includes an identification parameter, a detection function corresponding to the identification parameter may be identified in the kernel space, and the detection function obtains the preset number of received packets from the kernel receiving buffer in the kernel space.
在本实施例中,在该内核空间的内核接收缓冲区内的数据包数量小于该预设收包数量的情况下,将当前该内核空间的内核接收缓冲区内的数据包发送给该用户侧的用户接收缓冲区。In this embodiment, when the number of data packets in the kernel receiving buffer of the kernel space is less than the preset number of received packets, the current data packets in the kernel receiving buffer of the kernel space are sent to the user side The user receive buffer.
在本实施例中,在将该预设收包数量个数据包发送给该用户侧的用户接收缓冲区的同时,还将该数据包的辅助信息发送给该用户侧的用户接收缓冲区,其中,该辅助信息包括以下至少之一:数据包长度、接收时间、源IP地址、端口号。In this embodiment, while sending the data packets of the preset number of received packets to the user receiving buffer of the user side, the auxiliary information of the data packets is also sent to the user receiving buffer of the user side, wherein , the auxiliary information includes at least one of the following: packet length, receiving time, source IP address, port number.
在本实施例中提供了一种网络媒体流收包方法,图2是根据本发明实施例的一种网络媒体流收包方法的流程图二,如图2所示,该流程包括如下步骤:A method for receiving packets of network media streams is provided in this embodiment. FIG. 2 is a flow chart 2 of a method for receiving packets of network media streams according to an embodiment of the present invention. As shown in FIG. 2 , the process includes the following steps:
步骤S202,用户侧发送取数据包的指令,其中,该指令包括预设收包数量;Step S202, the user side sends an instruction to fetch data packets, wherein the instruction includes a preset number of received packets;
步骤S204,该用户侧的用户接收缓冲区接收从内核空间发送的该预设收包数量个数据包,该预设收包数量个数据包是从该内核空间的内核接收缓冲区获取的。Step S204, the user receiving buffer on the user side receives the preset number of data packets sent from the kernel space, and the preset number of data packets are obtained from the kernel receiving buffer of the kernel space.
通过上述步骤,用户侧发送取数据包的指令,其中,该指令包括预设收包数量,该用户侧的用户接收缓冲区接收从内核空间发送的该预设收包数量个数据包,该预设收包数量个数据包是从该内核空间的内核接收缓冲区获取的,实现了可以按照用户侧的指令取一定数量的数据包,而不是每次只取一个数据包,解决了系统频繁调用网络数据包,严重降低流媒体服务器性能的问题,提高了流媒体服务器对外服务能力。Through the above steps, the user side sends an instruction to fetch data packets, wherein the instruction includes a preset number of received packets, and the user receiving buffer on the user side receives the data packets of the preset number of received packets sent from the kernel space, and the preset number of packets received Set the number of received packets and the data packets are obtained from the kernel receiving buffer of the kernel space, which realizes that a certain number of data packets can be fetched according to the instructions of the user side, instead of only fetching one data packet at a time, which solves the problem of frequent system calls Network data packets seriously reduce the performance of the streaming media server and improve the external service capability of the streaming media server.
在本实施例中,该预设收包数量的计算因子可以包括以下至少之一:码率,收包间隔。In this embodiment, the calculation factor of the preset number of received packets may include at least one of the following: a code rate, and an interval for receiving packets.
在本实施例中还提供了一种网络媒体流收包装置,该装置用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。In this embodiment, a device for receiving packets of network media streams is also provided, which is used to implement the above embodiments and preferred implementation modes, and what has already been described will not be repeated. As used below, the term "module" may be a combination of software and/or hardware that realizes a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementations in hardware, or a combination of software and hardware are also possible and contemplated.
图3是根据本发明实施例的一种网络媒体流收包装置的结构框图一,如图3所示,该装置包括Fig. 3 is a structural block diagram 1 of a network media stream packet receiving device according to an embodiment of the present invention. As shown in Fig. 3, the device includes
第一接收模块32,用于接收用户侧取数据包的指令,其中,该指令包括预设收包数量;The first receiving module 32 is configured to receive an instruction for fetching data packets from the user side, wherein the instruction includes a preset number of received packets;
获取模块34,用于从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将该预设收包数量个数据包发送给该用户侧的用户接收缓冲区。The obtaining module 34 is configured to obtain the preset received data packets from the kernel receiving buffer in the kernel space, and then send the preset received data packets to the user receiving buffer on the user side.
通过上述装置,接收用户侧取数据包的指令,从内核空间的内核接收缓冲区获取预设收包数量个数据包后,将该预设收包数量个数据包发送给该用户侧的用户接收缓冲区,实现了可以按照用户侧的指令取一定数量的数据包,而不是每次只取一个数据包,解决了系统频繁调用网络数据包,严重降低流媒体服务器性能的问题,提高了流媒体服务器对外服务能力。Through the above-mentioned device, an instruction to fetch data packets from the user side is received, and after obtaining a preset number of data packets from the kernel receiving buffer in the kernel space, the preset number of data packets to be received is sent to the user on the user side for receiving Buffer, which realizes that a certain number of data packets can be fetched according to the instructions of the user side, instead of only fetching one data packet each time, which solves the problem that the system frequently calls network data packets and seriously reduces the performance of the streaming media server, and improves the performance of the streaming media. Server external service capability.
在本实施例中,该获取模块34包括:In this embodiment, the acquisition module 34 includes:
第一获取单元,用于在内核空间中注册探测函数,该探测函数从内核空间的内核接收缓冲区获取该预设收包数量个数据包。The first obtaining unit is configured to register a detection function in the kernel space, and the detection function obtains the preset number of received packets from the kernel receiving buffer of the kernel space.
在该指令包括标识参数的情况下,该获取模块34包括:In the case that the instruction includes an identification parameter, the obtaining module 34 includes:
第二获取单元,用于在内核空间中识别与该标识参数对应的探测函数,该探测函数从内核空间的内核接收缓冲区获取该预设收包数量个数据包。The second obtaining unit is used to identify a detection function corresponding to the identification parameter in the kernel space, and the detection function obtains the preset number of data packets received from the kernel receiving buffer of the kernel space.
第三获取单元,用于在该内核空间的内核接收缓冲区内的数据包数量小于该预设收包数量的情况下,将当前该内核空间的内核接收缓冲区内的数据包发送给该用户侧的用户接收缓冲区。The third acquisition unit is used to send the current data packets in the kernel receiving buffer of the kernel space to the user when the number of data packets in the kernel receiving buffer of the kernel space is less than the preset number of receiving packets side of the user receive buffer.
在本实施例中,该装置还包括:In this embodiment, the device also includes:
第一发送模块,用于将该数据包的辅助信息发送给该用户侧的用户接收缓冲区,其中,该辅助信息包括以下至少之一:数据包长度、接收时间、源IP地址、端口号。The first sending module is configured to send the auxiliary information of the data packet to the user receiving buffer of the user side, wherein the auxiliary information includes at least one of the following: data packet length, receiving time, source IP address, port number.
图4是根据本发明实施例的一种网络媒体流收包装置的结构框图二,如图4所示,该装置包括Fig. 4 is a structural block diagram II of a network media stream packet receiving device according to an embodiment of the present invention. As shown in Fig. 4, the device includes
第二发送模块42,用于用户侧发送取数据包的指令,其中,该指令包括预设收包数量;The second sending module 42 is used for the user side to send an instruction for fetching data packets, wherein the instruction includes a preset number of received packets;
第二接收模块44,用于该用户侧的用户接收缓冲区接收从内核空间发送的该预设收包数量个数据包,该预设收包数量个数据包是从该内核空间的内核接收缓冲区获取的。The second receiving module 44 is used for the user receiving buffer on the user side to receive the preset number of data packets sent from the kernel space, and the preset number of data packets are received from the kernel space of the kernel space obtained from the area.
通过上述装置,用户侧发送取数据包的指令,其中,该指令包括预设收包数量,该用户侧的用户接收缓冲区接收从内核空间发送的该预设收包数量个数据包,该预设收包数量个数据包是从该内核空间的内核接收缓冲区获取的,实现了可以按照用户侧的指令取一定数量的数据包,而不是每次只取一个数据包,解决了系统频繁调用网络数据包,严重降低流媒体服务器性能的问题,提高了流媒体服务器对外服务能力。Through the above device, the user side sends an instruction to fetch data packets, wherein the instruction includes a preset number of received packets, and the user receiving buffer on the user side receives the preset number of data packets sent from the kernel space, and the preset number of packets received Set the number of received packets and the data packets are obtained from the kernel receiving buffer of the kernel space, which realizes that a certain number of data packets can be fetched according to the instructions of the user side, instead of only fetching one data packet at a time, which solves the problem of frequent system calls Network data packets seriously reduce the performance of the streaming media server and improve the external service capability of the streaming media server.
在另一个实施例中,还提供了一种网络媒体流收包系统,包括:用户侧设备,内核设备;In another embodiment, a system for receiving packets of network media streams is also provided, including: a user side device and a kernel device;
该内核设备接收用户侧设备取数据包的指令,其中,该指令包括预设收包数量;The kernel device receives an instruction from the user-side device to fetch data packets, wherein the instruction includes a preset number of received packets;
从该内核设备的内核接收缓冲区获取预设收包数量个数据包后,将该预设收包数量个数据包发送给该用户侧设备的用户接收缓冲区。After acquiring the preset received data packets from the kernel receiving buffer of the kernel device, the preset received data packets are sent to the user receiving buffer of the user-side device.
下面结合优选实施例和实施方式对本发明进行详细说明。The present invention will be described in detail below in combination with preferred embodiments and implementation modes.
本优选实施例提供一种网络收包方法、装置及系统,降低系统调用的开销,解决流媒体服务器的性能瓶颈问题,从而提高其对外服务能力。This preferred embodiment provides a network packet receiving method, device and system, which reduces the overhead of system calls and solves the performance bottleneck problem of the streaming media server, thereby improving its external service capability.
本优选实施例的装置/系统包括以下模块:The device/system of this preferred embodiment includes the following modules:
用户收包模块,调用系统调用收取网络包进行处理。The user packet receiving module calls the system call to collect network packets for processing.
内核收包模块,运行在内核空间,一次返回用户指定数量的数据包。The kernel packet receiving module runs in the kernel space and returns the number of packets specified by the user at a time.
本优选实施例的方法包括以下步骤:The method of this preferred embodiment comprises the following steps:
步骤1.利用内核的jprobe(Jumper probe)调试工具注册一个探测函数,该函数实现批量收包功能。编译成一个内核模块(可命名为receivepacketdriver.ko)。Step 1. Use the jprobe (Jumper probe) debugging tool of the kernel to register a detection function, which realizes the function of receiving packets in batches. Compile it into a kernel module (named receivepacketdriver.ko).
步骤2.利用insmod命令安装该内核收包模块到Linux等操作系统Kernel。Step 2. Use the insmod command to install the kernel packet receiving module to the Kernel of an operating system such as Linux.
步骤3.用户收包模块根据码率和收包间隔等计算一次要收多少个包,通过系统接口recvmsg收包,同时指定收包个数并携带特殊的标记参数。Step 3. The user packet receiving module calculates how many packets to receive at a time according to the code rate and packet receiving interval, etc., and receives packets through the system interface recvmsg, and at the same time specifies the number of packets to receive and carries special marking parameters.
步骤4.携带特殊标记参数的系统调用recvmsg会执行内核收包模块receivepacketdriver.ko中的函数。该函数会从内核接收缓存区取用户指定数量的包返回给用户,同时返回每个包的辅助信息(如包的长度、接收时间、源IP地址和端口等)。如果内核接收缓存区的包数量少于用户指定的数量,则只返回现有的数量。Step 4. The system call recvmsg with special flag parameters will execute the function in the kernel packet receiving module receivepacketdriver.ko. This function will take the user-specified number of packets from the kernel receiving buffer and return them to the user, and return the auxiliary information of each packet (such as the length of the packet, receiving time, source IP address and port, etc.). If the number of packets in the kernel's receive buffer is less than the number specified by the user, only the existing number is returned.
步骤5.用户收包模块得到多个包后进行后续处理。Step 5. The user packet receiving module performs subsequent processing after obtaining multiple packets.
图5是根据本发明优选实施例的网络收包系统示意图,如图5所示,利用内核的接口register_jprobe注册一个探测函数到内核函数udp_recvmsg上,该探测函数实现批量收包功能。将此内核收包模块编译成receivepacketdriver.ko,并通过insmod命令安装到内核中运行。Fig. 5 is a schematic diagram of a network packet receiving system according to a preferred embodiment of the present invention. As shown in Fig. 5, a detection function is registered to the kernel function udp_recvmsg by using the interface register_jprobe of the kernel, and the detection function realizes a batch packet collection function. Compile this kernel packet receiving module into receivepacketdriver.ko, and install it into the kernel to run through the insmod command.
用户收包模块调用系统接口recvmsg(int sockfd,struct msghdr*msg,int flags)进行收包,flags为特殊值如MSG_BATCH。通过结构体msg的msg_iovlen指定收包个数,msg_control用于回传每个包的辅助信息。The user packet receiving module calls the system interface recvmsg(int sockfd, struct msghdr*msg, int flags) to receive packets, and the flags are special values such as MSG_BATCH. The number of received packets is specified by the msg_iovlen of the structure msg, and the msg_control is used to return the auxiliary information of each packet.
recvmsg会调用udp_recvmsg,从而执行之前注册的探测函数,如果flags为MSG_BATCH则探测函数会从内核接收队列取出msg_iovlen个包返回给用户。如果内核接收队列中包的个数少于msg_iovlen个,则返回队列中现有的所有包。本次收包流程结束。recvmsg will call udp_recvmsg to execute the previously registered detection function. If flags is MSG_BATCH, the detection function will take msg_iovlen packets from the kernel receive queue and return them to the user. If the number of packets in the kernel receive queue is less than msg_iovlen, all existing packets in the queue are returned. The receiving process is over.
用户收包模块周期调用recvmsg接收码流做后续处理。The user packet receiving module periodically calls recvmsg to receive the code stream for subsequent processing.
本发明的实施例还提供了一种存储介质。可选地,在本实施例中,上述存储介质可以被设置为存储用于执行上述实施例的方法步骤的程序代码:The embodiment of the invention also provides a storage medium. Optionally, in this embodiment, the foregoing storage medium may be configured to store program codes for executing the method steps of the foregoing embodiments:
可选地,在本实施例中,上述存储介质可以包括但不限于:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。Optionally, in this embodiment, the above-mentioned storage medium may include but not limited to: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk Various media that can store program codes such as discs or optical discs.
可选地,在本实施例中,处理器根据存储介质中已存储的程序代码执行上述实施例的方法。Optionally, in this embodiment, the processor executes the methods in the foregoing embodiments according to the program code stored in the storage medium.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that each module or each step of the above-mentioned present invention can be realized by a general-purpose computing device, and they can be concentrated on a single computing device, or distributed in a network formed by multiple computing devices Alternatively, they may be implemented in program code executable by a computing device so that they may be stored in a storage device to be executed by a computing device, and in some cases, in an order different from that shown here The steps shown or described are carried out, or they are separately fabricated into individual integrated circuit modules, or multiple modules or steps among them are fabricated into a single integrated circuit module for implementation. As such, the present invention is not limited to any specific combination of hardware and software.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention, and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims (15)
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510325987.9A CN106302372A (en) | 2015-06-12 | 2015-06-12 | Network media stream packet receiving method, Apparatus and system |
PCT/CN2016/077124 WO2016197659A1 (en) | 2015-06-12 | 2016-03-23 | Packet reception method, device and system for network media stream |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510325987.9A CN106302372A (en) | 2015-06-12 | 2015-06-12 | Network media stream packet receiving method, Apparatus and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106302372A true CN106302372A (en) | 2017-01-04 |
Family
ID=57503085
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510325987.9A Pending CN106302372A (en) | 2015-06-12 | 2015-06-12 | Network media stream packet receiving method, Apparatus and system |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN106302372A (en) |
WO (1) | WO2016197659A1 (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107040581A (en) * | 2017-01-25 | 2017-08-11 | 腾讯科技(深圳)有限公司 | A kind of network packet transmission method, device, server and system |
CN116668415A (en) * | 2022-06-01 | 2023-08-29 | 中兴通讯股份有限公司 | Streaming media data processing method and system |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113824777B (en) * | 2021-09-06 | 2023-12-19 | 武汉中科通达高新技术股份有限公司 | Data management method and data management device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101132355A (en) * | 2006-08-21 | 2008-02-27 | 北京锐科天智科技有限责任公司 | Network accelerating method, software and hardware device |
CN101304373A (en) * | 2008-06-25 | 2008-11-12 | 中兴通讯股份有限公司 | Method and system for implementing high-efficiency transmission chunk data in LAN |
CN101494579A (en) * | 2008-01-22 | 2009-07-29 | 中兴通讯股份有限公司 | Bus scheduling device and method |
CN101841476A (en) * | 2010-04-22 | 2010-09-22 | 北京星网锐捷网络技术有限公司 | Message processing method, device and network equipment |
US20130198538A1 (en) * | 2012-01-31 | 2013-08-01 | Broadcom Corporation | Enhanced Buffer-Batch management for Energy Efficient Networking |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100464304C (en) * | 2006-08-29 | 2009-02-25 | 飞塔信息科技(北京)有限公司 | A device and method for realizing zero-copy based on Linux operating system |
CN104426866B (en) * | 2013-08-28 | 2018-12-14 | 华为技术有限公司 | A kind of data transmission method and device |
-
2015
- 2015-06-12 CN CN201510325987.9A patent/CN106302372A/en active Pending
-
2016
- 2016-03-23 WO PCT/CN2016/077124 patent/WO2016197659A1/en active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101132355A (en) * | 2006-08-21 | 2008-02-27 | 北京锐科天智科技有限责任公司 | Network accelerating method, software and hardware device |
CN101494579A (en) * | 2008-01-22 | 2009-07-29 | 中兴通讯股份有限公司 | Bus scheduling device and method |
CN101304373A (en) * | 2008-06-25 | 2008-11-12 | 中兴通讯股份有限公司 | Method and system for implementing high-efficiency transmission chunk data in LAN |
CN101841476A (en) * | 2010-04-22 | 2010-09-22 | 北京星网锐捷网络技术有限公司 | Message processing method, device and network equipment |
US20130198538A1 (en) * | 2012-01-31 | 2013-08-01 | Broadcom Corporation | Enhanced Buffer-Batch management for Energy Efficient Networking |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107040581A (en) * | 2017-01-25 | 2017-08-11 | 腾讯科技(深圳)有限公司 | A kind of network packet transmission method, device, server and system |
CN116668415A (en) * | 2022-06-01 | 2023-08-29 | 中兴通讯股份有限公司 | Streaming media data processing method and system |
WO2023231723A1 (en) * | 2022-06-01 | 2023-12-07 | 中兴通讯股份有限公司 | Streaming media data processing method and system |
CN116668415B (en) * | 2022-06-01 | 2025-01-24 | 中兴通讯股份有限公司 | Streaming media data processing method and system |
Also Published As
Publication number | Publication date |
---|---|
WO2016197659A1 (en) | 2016-12-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102402487B (en) | Zero copy message reception method and system | |
CN102739473B (en) | Network detecting method using intelligent network card | |
US10044802B2 (en) | System for detection of content servers and caching popular content therein | |
CN104488231B (en) | Method, apparatus and system for selectively monitoring flow | |
CN113285931B (en) | Streaming media transmission method, streaming media server and streaming media system | |
CN113835902B (en) | Data processing method, device, computer equipment and storage medium | |
CN105657000A (en) | Message transmission method and device | |
CN106302372A (en) | Network media stream packet receiving method, Apparatus and system | |
CN104219230A (en) | Method and device for identifying malicious websites | |
CN108462590B (en) | Network flow monitoring method and device and computer terminal | |
US20180255325A1 (en) | Fault recovery of video bitstream in remote sessions | |
CN115202969A (en) | Interface calling timeout processing method, device, equipment and storage medium | |
CN109766347B (en) | Data updating method, device, system, computer equipment and storage medium | |
CN107105004B (en) | Cross-platform service calling method and device | |
US20150326661A1 (en) | Apparatus and method for performing infiniband communication between user programs in different apparatuses | |
CN110213399A (en) | Dynamic Host Configuration Protocol server detection method, storage medium and terminal based on NETFILTER mechanism | |
US11032583B2 (en) | Method and system for improving high availability for live content | |
US10812837B2 (en) | System and method for live service content handling with content storing servers caching popular content therein | |
CN115942000A (en) | Video stream transcoding method, device, equipment and medium based on H.264 format | |
KR101270743B1 (en) | Apparatus and Method for hybrid BD for hardware load balancing of network security system | |
CN112671670A (en) | VR video service identification method and device, intelligent terminal and storage medium | |
CN105281976A (en) | Method and apparatus for monitoring transmission of proxy service data | |
CN108632339A (en) | A kind of method and system of dynamic select server | |
US9112766B2 (en) | Method and apparatus having improved line rate IP packet communication | |
CN104243436A (en) | Service processing method, device and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20170104 |