WO2010015142A1 - 一种实现零拷贝发送流媒体数据的方法及系统 - Google Patents

一种实现零拷贝发送流媒体数据的方法及系统 Download PDF

Info

Publication number
WO2010015142A1
WO2010015142A1 PCT/CN2009/000852 CN2009000852W WO2010015142A1 WO 2010015142 A1 WO2010015142 A1 WO 2010015142A1 CN 2009000852 W CN2009000852 W CN 2009000852W WO 2010015142 A1 WO2010015142 A1 WO 2010015142A1
Authority
WO
WIPO (PCT)
Prior art keywords
streaming media
data
media data
user
real
Prior art date
Application number
PCT/CN2009/000852
Other languages
English (en)
French (fr)
Inventor
王魏强
朱红军
程剑
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Priority claimed from CN 200810142292 external-priority patent/CN101340574B/zh
Priority claimed from CN 200810241596 external-priority patent/CN101465854B/zh
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Priority to RU2011107517/08A priority Critical patent/RU2477930C2/ru
Priority to EP09804442.3A priority patent/EP2312807B1/en
Priority to US13/057,625 priority patent/US20110258337A1/en
Priority to PL09804442T priority patent/PL2312807T3/pl
Publication of WO2010015142A1 publication Critical patent/WO2010015142A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/232Content retrieval operation locally within server, e.g. reading video streams from disk arrays
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/61Network streaming of media packets for supporting one-way streaming services, e.g. Internet radio
    • H04L65/612Network streaming of media packets for supporting one-way streaming services, e.g. Internet radio for unicast
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/65Network streaming protocols, e.g. real-time transport protocol [RTP] or real-time control protocol [RTCP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/60Network streaming of media packets
    • H04L65/70Media network packetisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/20Servers specifically adapted for the distribution of content, e.g. VOD servers; Operations thereof
    • H04N21/23Processing of content or additional data; Elementary server operations; Server middleware
    • H04N21/238Interfacing the downstream path of the transmission network, e.g. adapting the transmission rate of a video stream to network bandwidth; Processing of multiplex streams
    • H04N21/2381Adapting the multiplex stream to a specific network, e.g. an Internet Protocol [IP] network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/643Communication protocols
    • H04N21/6437Real-time Transport Protocol [RTP]

Definitions

  • the invention relates to a network communication method and system in the field of computer application, and particularly relates to a method and system for implementing zero-copy transmission of streaming media data by a Linux-based network protocol stack.
  • the process of delivery mainly includes the following three parts: (1) reading the streaming media data from the disk space into the user data cache; (2) packaging the streaming media data stored in the user data cache into RTP (Real-time Transport Protocol, The real-time transport protocol) data packet is stored in the user send buffer; (3) the RTP data packet stored in the user send buffer is sent out through a UDP (User Datagram Protocol) network socket.
  • RTP Real-time Transport Protocol
  • UDP User Datagram Protocol
  • the user process can read the disk data through the direct input and output interface system call, and the system call directly writes the disk data to the user cache through the DMA (Direct Memory Access) mechanism;
  • the network socket related system call interface can send an RTP data packet, and the system call copies the RTP data packet from the user space to the kernel space, performs corresponding encapsulation, and maps to the transmission buffer of the network card through the DMA mechanism, and the network card will RTP packets are sent out.
  • the user process can read the streaming media data from the disk to achieve zero copy, but the streaming media data is packaged into the RTP data packet, and the data is copied.
  • the RTP data packet needs to be User space is copied to the kernel space.
  • the object of the present invention is to provide a method and system for implementing zero-copy transmission of streaming media data.
  • the method and system are based on a Linux network protocol stack, and minimize data copy without affecting the original network protocol stack of the Linux system. And CPU consumption caused by system calls, improve the processing power of the system.
  • the technical solution of the present invention includes:
  • a method for implementing zero-copy transmission of streaming media data, a Linux-based network protocol stack comprising the following steps:
  • the streaming media server when the streaming media server receives the data request of the user equipment, performs a system call for sending data, and reads the streaming media data from the disk space into the user data cache;
  • the streaming media data stored in the user data cache is packaged into a real-time transport protocol data packet, and the real-time transport protocol data packet is sent in the form of a stream media packet separated by a header and a payload.
  • step B further includes:
  • a kernel buffer structure is allocated in the kernel space for each real-time transport protocol data packet to be sent, and the structure is composed of two parts: a part is a temporarily allocated kernel buffer, and includes a header of the real-time transport protocol data packet. The other part is a temporarily mapped user buffer containing the payload of the real-time transport protocol packet;
  • one streaming media data packet is sent to each user by one system call.
  • the network protocol stack provides the following socket programming interface: a socket for creating a socket, used to close the close of the socket, and used to implement a zero copy sending stream.
  • a system for implementing zero-copy transmission of streaming media data comprising a streaming media server, the streaming media server being configured to implement a zero-copy transmission of streaming media data based on a Linux-based network protocol stack.
  • the streaming media server sets a kernel space between the hardware device and the user process, and a network protocol stack is set on the network card driver in the kernel space; the kernel space is formed by packaging the streaming media data to be sent.
  • Real-time transport protocol packet allocation :
  • the network protocol stack provides a socket programming interface to a user process, and the socket programming interface includes: a socket, a close for closing a socket, a sendmsg for implementing zero-copy transmission of streaming media data; the network protocol stack is configured to implement streaming media packets separated by a header and a payload for real-time transport protocol data packets The form is sent.
  • the streaming media server uses a batch sending technology to send multiple data packets in one sendmsg system call.
  • the invention provides a method and a system for realizing zero-copy transmission of streaming media data, which fully utilizes the DMA function of the network card and the SG (Scatter/Gather) function to realize zero-copy transmission of streaming media data, and Compared with the existing network protocol stack of the Linux kernel, the streaming media data packet with header and load separation is implemented, and the data copy operation required for the RTP packaging process of the streaming media data is reduced.
  • FIG. 1 is a schematic diagram of a zero-copy transmission of streaming media data by a network protocol stack implemented by the present invention
  • Figure 2 is a schematic view showing the structure of the system of the present invention.
  • the original Linux network protocol stack is utilized, and the network protocol stack is implemented by using a kernel module mechanism, and the loading and unloading of the kernel module does not affect the original network protocol stack of the Linux kernel.
  • the system for implementing zero-copy transmission of streaming media data includes a streaming media server. As shown in FIG. 2, the streaming media server is provided with a network card and a communication connection with the user equipment. The network card supports DMA function and SG (Scatter/Gather) function.
  • the hardware device of the streaming media server includes a network card and a hard disk.
  • a network card between the hardware device and the user process is a Linux kernel space, and the network card driver in the kernel space.
  • a network protocol stack is disposed on the network protocol stack, and the network protocol stack provides a socket programming interface to the user process.
  • the socket programming interface mainly includes system calls such as socket, close, sendmsg, etc., wherein the socket is used to create a socket. Close is used to close the socket, sendmsg is used to implement zero-copy send streaming data.
  • the hardware environment of the method and system of the present invention requires the network card to have a DMA function and an SG function, and the software environment is a Linux kernel with a normal network function.
  • the method and system of the present invention creates a DATALINK network protocol stack based on the AF-DATALINK socket type based on the original Linux kernel.
  • the protocol stack provides the user process with an AF DATALINK type socket programming interface, including socket, close, sendmsg and other system calls.
  • the socket system call is used to create the socket
  • the close system call is used to close the socket
  • the sendmsg system call is used to send the streaming media data in RTP packet encapsulation in a zero-copy manner.
  • the streaming media data is sent through a zero copy of the socket.
  • Socket uses the AF-DATALINK socket created by the socket system call
  • Msg->msg_namelen is not used for the time being.
  • Msg->msg_iov Input parameters Pointer to the struct iovec array.
  • Each struct The iovec structure contains the buffer address and length of the data to be sent.
  • Msg->msg_iovlen Input parameters Used to store the length of the struct iovec array pointed to by msg iov.
  • Msg->msg control Input and output parameters.
  • Input control information for each streaming media packet including IP address, UDP port, RTP payload type, etc.; used to return the index and error code of the sent error packet.
  • Msg->msg_controllen Input parameters The total length used to store msg-control information. Msg -> msg - flags are not used temporarily.
  • the number of successfully transmitted data packets is returned, and the index of the data packet that has not been successfully transmitted and the corresponding error code are returned through the output parameters.
  • the information constituting the RTP data packet is stored in the parameter msg, and the msg_iov field stores the payload information of the RTP data packet to be transmitted, including the address and length information of the user data buffer, as the payload of the RTP data packet; msg_control field storage
  • the header information of the RTP packet to be sent includes an IP address, a port number, an RTP payload type, and the like, and is used to generate a header of the RTP packet.
  • the method of the present invention allocates a kernel buffer structure sk_buff for each RTP data packet to be sent in the kernel space when the sendmsg system is invoked, and the data of the structure is composed of two parts: a part is temporarily allocated.
  • the kernel buffer which contains the header of the streaming RTP packet, is generated based on the header information contained in the msg-control; the other is the temporarily mapped user buffer, which contains the payload of the RTP packet, based on msg—
  • the load information contained in iov is obtained.
  • the two buffers are respectively mapped to the transmission buffer of the network card, and the transmission function of the network card driver module is called to complete zero-copy transmission of the streaming media data.
  • the above mapping process is well known in the prior art and will not be described here.
  • the streaming server of the method and system of the present invention can achieve zero copy transmission of streaming media data by using an AF DATALINK socket and a sendmsg system call when processing a single user request.
  • the streaming server When the streaming server needs to process multiple user requests, it can send streaming media data with zero copy, similar to a single user request, and can be further optimized by reducing the number of system calls.
  • System performance This is mainly due to the semantic redefinition of the parameter msg of the sendmsg system call. Its member msg->msg_iov points to a batch of packet buffers, and the member msg->msg_iovlen represents the packet buffer. The number, such a system call can send a batch of streaming media packets. In practical applications, a streaming media packet can be sent to each user in a sendmsg system call to reduce the number of sendmsg system calls and optimize system performance.
  • the method and system of the invention fully utilizes the DMA function and the SG function of the network card, and realizes zero-copy transmission of streaming media data.
  • the method and system of the present invention utilize the SG function of the network card to implement The transmission of the streaming media packets separated by the header and the payload reduces the data copying operation required for the RTP packaging process of the streaming media data.
  • the network card driver module directly uses the user buffer area to transmit data packets, and reduces the data copy operation required to copy the streaming media data from the user space to the kernel space.
  • the method and system of the invention also adopts the batch sending technology, realizes the function of sending a batch of data packets by one system call, avoids the situation that a system call is needed to send one data packet, and reduces the system when sending streaming media data to multiple users.
  • the cost of the call is also known to those skilled in the art, and therefore will not be described again.
  • the method and system of the invention fully utilizes the DMA function and the SG function of the network card, and realizes zero-copy transmission of streaming media data.
  • the method and system of the present invention utilize the SG function of the network card to implement The transmission of the streaming media packets separated by the header and the payload reduces the data copying operation required for the RTP packaging process of the streaming media data.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Databases & Information Systems (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Communication Control (AREA)
  • Computer And Data Communications (AREA)

Description

一种实现零拷贝发送流媒体数据的方法及系统 技术领域
本发明涉及计算机应用领域的一种网络通信方法及系统, 具体涉及的是 一种基于 Linux的网络协议栈实现零拷贝发送流媒体数据的方法及系统。
背景技术
现有技术中, 在基于 Linux操作系统的流媒体服务器应用中, 需要将大 量的流媒体数据从磁盘上传递到网络上。 当流媒体数据从磁盘上到网络上传 输时, 要在不同的系统空间中进行多次传递。
传递的流程主要包括如下 3个部分: ( 1 )将流媒体数据从磁盘空间读入 用户数据緩存中; ( 2 ) 将用户数据緩存中存放的流媒体数据打包成 RTP ( Real-time Transport Protocol , 实时传输协议 )数据包存入用户发送緩存中; ( 3 )将用户发送緩存中存放的 RTP数据包通过 UDP( User Datagram Protocol, 用户数据报协议) 网络套接字发送出去。
在 Linux操作系统中, 用户进程通过直接输入输出接口系统调用, 可以 读取磁盘数据, 该系统调用将磁盘数据通过 DMA ( Direct Memory Access , 直接内存访问 )机制直接写入到用户緩存中; 通过 UDP网络套接字相关系统 调用接口,可以发送 RTP数据包,该系统调用将 RTP数据包从用户空间复制 到内核空间, 进行相应的封装, 通过 DMA机制映射到网卡的发送緩冲区, 网卡将该 RTP数据包发送出去。
在现有技术的这种方式下, 用户进程从磁盘读入流媒体数据可以实现零 拷贝, 但将流媒体数据打包成 RTP数据包需要进行数据的拷贝, 发送 RTP 数据包时也需要将其从用户空间拷贝到内核空间。
此外, 用户进程每发送一个数据包, 就需要使用一次系统调用, 每次系 统调用需要先从用户态切换到内核态, 系统调用返回后, 再从内核态切换到 用户态。 在流媒体服务器负荷较重的情况下, 会触发大量的数据拷贝和上下 文切换操作, 极大地消耗系统的 CPU资源, 降低系统的处理能力。
由此可见, 流媒体数据包发送过程中的开销主要产生在用户进程、 操作 系统、 网卡驱动等不同层次的数据组织、 数据拷贝和数据传输上。 如何有效 地减少数据拷贝和系统调用的次数,降低 CPU的消耗,提高系统的处理能力, 对于提升流媒体服务器的性能, 具有非常重要的影响。
现有技术还有待于改进和发展。
发明内容
本发明的目的在于提出一种实现零拷贝发送流媒体数据的方法及系统, 所述方法和系统基于 Linux的网络协议栈,在不影响 Linux系统原有网络协议 栈的情况下, 尽量减少数据拷贝和系统调用引起的 CPU消耗, 提高系统的处 理能力。
为实现上述目的, 本发明的技术方案包括:
一种实现零拷贝发送流媒体数据的方法, 基于 Linux的网络协议栈, 其 包括以下步骤:
A、 在流媒体服务器接收到用户设备的数据请求时, 进行发送数据的系 统调用, 将流媒体数据从磁盘空间读入用户数据緩存中;
B、将用户数据緩存中存放的流媒体数据打包成实时传输协议数据包,对 该实时传输协议数据包釆用头部和载荷分离的流媒体数据包的形式发送。
进一步的, 所述方法中, 所述步骤 B还包括:
B 1、 在内核空间为每一个待发送的实时传输协议数据包分配内核緩冲结 构, 该结构由两部分组成: 一部分是临时分配的内核緩冲区, 包含所述实时 传输协议数据包的头部; 另一部分是临时映射的用户緩冲区, 包含所述实时 传输协议数据包的载荷;
B2、 利用网卡的分 汇聚功能和直接内存访问功能, 分别将所述内核緩 冲结构的两部分緩冲区映射到网卡的发送緩冲区, 调用网卡驱动模块的发送 函数完成流媒体数据的零拷贝发送。
进一步的, 所述的方法中, 当流媒体服务器需要处理多个用户请求时, 通过一次系统调用给每个用户发送一个流媒体数据包。
进一步的, 所述的方法中, 所述网络协议栈提供以下套接字编程接口: 用于创建套接字的 socket, 用于关闭套接字的 close, 用于实现零拷贝发送流 媒体数据的 sendmsg系统调用。
一种实现零拷贝发送流媒体数据的系统, 包括流媒体服务器, 所述流媒 体服务器设置为基于 Linux的网络协议栈来实现零拷贝发送流媒体数据。 其 中, 所述流媒体服务器在硬件设备与用户进程之间设置内核空间, 在该内核 空间内的网卡驱动程序之上设置有网络协议栈; 所述内核空间为待发送的流 媒体数据打包形成的实时传输协议数据包分配:
临时分配的内核緩冲区, 以包含所述实时传输协议数据包的头部, 以及
临时映射的用户緩冲区, 以包含所述实时传输协议数据包的载荷; 所述网络协议栈给用户进程提供套接字编程接口, 所述套接字编程接口 包括: 用于创建套接字的 socket, 用于关闭套接字的 close, 用于实现零拷贝 发送流媒体数据的 sendmsg;所述网络协议栈用于实现对实时传输协议数据包 釆用头部和载荷分离的流媒体数据包的形式发送。
进一步的, 所述的系统中, 所述流媒体服务器釆用批量发送技术, 用于 在一次 sendmsg系统调用中发送多个数据包。
本发明所提供的一种实现零拷贝发送流媒体数据的方法及系统, 由于充 分利用了网卡的 DMA功能和 SG ( Scatter/Gather, 分 汇聚)功能, 实现零 拷贝发送流媒体数据的方式, 与 Linux 内核现有的网络协议栈相比, 实现了 头部和载荷分离的流媒体数据包的发送, 减少了将流媒体数据进行 RTP打包 过程中所需的一次数据拷贝操作。
附图概述
图 1是通过本发明实现的网络协议栈进行零拷贝发送流媒体数据的示意 图;
图 2所示是本发明系统的结构示意图。
本发明的较佳实施方式
以下结合附图, 将对本发明各较佳实施例进行更为详细的说明。
本发明基于 Linux的网络协议栈实现零拷贝发送流媒体数据的方法中, 利用了原有的 Linux 网络协议栈, 该网络协议栈利用内核模块机制实现, 所 述内核模块的加载和卸载都不会影响 Linux 内核原有的网络协议栈。 本发明 所述实现零拷贝发送流媒体数据的系统, 包括流媒体服务器, 如图 2所示, 所述流媒体服务器设置有网卡与所述用户设备通讯连接。所述网卡支持 DMA 功能和 SG ( Scatter/Gather, 分 汇聚)功能。
本发明所述方法及系统中, 所述流媒体服务器的硬件设备包括网卡和硬 盘, 如图 1所示, 在硬件设备与用户进程之间是 Linux内核空间, 在该内核 空间内的网卡驱动程序之上设置有网络协议栈, 所述网络协议栈给用户进程 提供套接字编程接口, 所述套接字编程接口主要包括 socket, close、 sendmsg 等系统调用, 其中 socket用于创建套接字, close用于关闭套接字, sendmsg 用于实现零拷贝发送流媒体数据。
本发明方法及系统的硬件环境要求网卡具有 DMA功能和 SG功能,软件 环境为网络功能正常的 Linux内核。 为了实现零拷贝发送流媒体数据的功能, 本发明方法及系统在原有 Linux内核的基础上创建了基于 AF— DATALINK套 接字类型的 DATALINK 网络协议栈。 该协议栈给用户进程提供 AF DATALINK类型的套接字编程接口, 包括 socket、 close、 sendmsg等系统 调用。其中 socket系统调用用于创建套接字, close系统调用用于关闭套接字, sendmsg系统调用用于以零拷贝的方式把流媒体数据以 RTP数据包封装方式 发送出去。
现有技术的 sendmsg 系统调用的原有标准语义不能够实现本发明的功 能, 必须对其进行重新定义, 下面给出了本发明方法及系统 sendmsg系统调 用的定义及其解释:
ssize t sendmsg(int socket, const struct msghdr *msg, int flags);
功能:
通过套接字进行零拷贝发送流媒体数据。
输入输出参数:
socket 使用 socket系统调用创建的 AF— DATALINK套接字;
msg -〉 msg— name 暂时不用。
msg->msg_namelen 暂时不用。
msg->msg_iov 输入参数。 指向 struct iovec数组的指针。 每个 struct iovec结构包含待发送数据的緩冲区地址和长度。
msg->msg_iovlen 输入参数。 用于存放 msg iov所指 struct iovec数组 的长度。
msg->msg— control 输入输出参数。 输入时用于存放每个流媒体数据包 的控制信息, 包括 IP地址、 UDP端口、 RTP负载类型等; 输出时用于返回发 送错误数据包的索引和错误码。
msg->msg_controllen 输入参数。 用于存放 msg— control信息的总长度。 msg -〉 msg— flags 暂时不用。
flags 暂时不用。
返回值:
如果数据包都没有发送成功, 则返回 -1 , 并设置错误码 errno。
如果数据包部分或者全部发送成功, 则返回成功发送的数据包的数目, 没有发送成功的数据包的索引和相应的错误码通过输出参数返回。
构成 RTP数据包的信息存放在参数 msg中, msg— iov字段存放待发送 RTP 数据包的载荷信息, 包含用户数据緩冲区的地址和长度信息, 作为 RTP数据 包的载荷; msg— control 字段存放待发送 RTP数据包的头部信息, 包含 IP地 址、 端口号、 RTP负载类型等, 用于生成 RTP数据包的头部。
如图 1所示, 本发明方法在 sendmsg系统调用时, 在内核空间为每一个 待发送的 RTP数据包分配内核緩冲结构 sk— buff,该结构的数据由两部分组成: 一部分是临时分配的内核緩冲区, 包含流媒体 RTP数据包的头部, 是根据 msg— control中包含的头部信息生成; 另一部分是临时映射的用户緩冲区, 包 含 RTP数据包的载荷, 是根据 msg— iov中包含的载荷信息得到。 利用网卡的 SG功能和 DMA功能, 分别将这两块緩冲区映射到网卡的发送緩冲区, 调用 网卡驱动模块的发送函数完成流媒体数据的零拷贝发送。 上述映射过程为现 有技术所熟知, 在此不再赘述。
本发明方法及系统的流媒体服务器在处理单个用户请求时, 通过使用 AF DATALINK套接字和一次 sendmsg系统调用, 就可以实现零拷贝发送流 媒体数据。
当流媒体服务器需要处理多个用户请求时, 除了可以类似单个用户请求 时使用零拷贝发送流媒体数据, 还可以通过减少系统调用的次数进一步优化 系统性能: 这主要归功于对 sendmsg系统调用的参数 msg的语义重定义, 其 成员 msg->msg— iov指向一批数据包緩冲区, 成员 msg->msg— iovlen表示数据 包緩冲区的个数, 这样一次系统调用就可以发送一批流媒体数据包。 在实际 的应用中, 可以在一次 sendmsg系统调用中给每个用户发送一个流媒体数据 包, 以此来减少 sendmsg系统调用的次数, 从而优化系统性能。
本发明方法及系统充分利用了网卡的 DMA功能和 SG功能,实现了零拷 贝发送流媒体数据, 与 Linux 内核现有的网络协议栈相比, 本发明方法及系 统利用网卡的 SG功能, 实现了头部和载荷分离的流媒体数据包的发送, 减 少了将流媒体数据进行 RTP打包过程中所需的一次数据拷贝操作。
同时, 利用网卡的 DMA功能, 实现了网卡驱动模块直接使用用户緩冲 区进行数据包的发送, 减少将流媒体数据从用户空间拷贝到内核空间所需的 一次数据拷贝操作。
本发明方法及系统还釆用批量发送技术, 实现了一次系统调用发送一批 数据包的功能, 避免了发送一个数据包就需要一次系统调用的情况, 减少了 向多用户发送流媒体数据时系统调用的开销。 所述批量发送技术的具体实现 也是现有技术本领域技术人员所了解的, 因此不再赘述。
需要说明的是, 上述网络协议栈的实现是通过软件实现的, 系统调用的 实现也是现有技术软件实现中所熟知的, 因此不再赘述其具体实现过程, 为 本领域技术人员所熟知。
同时, 需要指出的是, 上述针对本发明各较佳实施例的描述较为详细和 具体, 并不能因此而认为是对本发明专利保护范围的限制, 本发明的专利保 护范围应以所附权利要求为准。
工业实用性
本发明方法及系统充分利用了网卡的 DMA功能和 SG功能,实现了零拷 贝发送流媒体数据, 与 Linux 内核现有的网络协议栈相比, 本发明方法及系 统利用网卡的 SG功能, 实现了头部和载荷分离的流媒体数据包的发送, 减 少了将流媒体数据进行 RTP打包过程中所需的一次数据拷贝操作。

Claims

权 利 要 求 书
1、 一种实现零拷贝发送流媒体数据的方法, 所述方法基于 Linux的网络 协议栈来实现, 包括以下步骤:
A、 在流媒体服务器接收到用户设备的数据请求时, 进行发送数据的系 统调用, 将流媒体数据从磁盘空间读入用户数据緩存中;
B、 将用户数据緩存中存放的所述流媒体数据打包成实时传输协议数据 包, 对所述实时传输协议数据包釆用头部和载荷分离的流媒体数据包的形式 发送。
2、 根据权利要求 1所述的方法, 其中, 所述步骤 B还包括:
Bl、 在内核空间为每一个待发送的实时传输协议数据包分配内核緩冲结 构, 所述内核緩冲结构包括:
临时分配的内核緩冲区, 其包含所述待发送的实时传输协议数据包 的头部; 以及
临时映射的用户緩冲区, 其包含所述待发送的实时传输协议数据包 的载荷;
B2、 利用网卡的分 汇聚功能和直接内存访问功能, 将所述内核緩冲结 构的临时分配的内核緩冲区及临时映射的用户緩冲区分别映射到网卡的发送 緩冲区, 调用网卡驱动模块的发送函数完成流媒体数据的零拷贝发送。
3、 根据权利要求 2所述的方法, 其中, 当流媒体服务器需要处理多个用 户请求时,通过一次系统调用给每个发出请求的用户发送一个流媒体数据包。
4、 根据权利要求 3所述的方法, 其中, 所述网络协议栈提供以下套接字 编程接口:
用于创建套接字的 socket, 用于关闭套接字的 close、 以及用于实现零拷 贝发送流媒体数据的 sendmsg系统调用。
5、一种用于实现零拷贝发送流媒体数据的系统, 所述系统包括流媒体服 务器, 所述流媒体服务器设置为基于 Linux的网络协议栈来实现零拷贝发送 流媒体数据, 其中,
所述流媒体服务器在自身的硬件设备与用户进程之间设置内核空间, 在 所述内核空间内的网卡驱动程序之上设置有所述网络协议栈, 所述内核空间 为待发送的流媒体数据打包形成的实时传输协议数据包分配:
临时分配的内核緩冲区, 以包含所述实时传输协议数据包的头部, 以及
临时映射的用户緩冲区, 以包含所述实时传输协议数据包的载荷; 所述网络协议栈给用户进程提供套接字编程接口, 所述套接字编程接口 包括: 用于创建套接字的 socket, 用于关闭套接字的 close、 以及用于实现零 拷贝发送流媒体数据的 sendmsg;所述网络协议栈用于实现对所述实时传输协 议数据包釆用头部和载荷分离的流媒体数据包的形式发送。
6、 根据权利要求 5所述的系统, 其中, 所述流媒体服务器釆用批量发送 技术, 所述批量发送技术用于在一次 sendmsg系统调用中发送多个数据包。
PCT/CN2009/000852 2008-08-04 2009-07-30 一种实现零拷贝发送流媒体数据的方法及系统 WO2010015142A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
RU2011107517/08A RU2477930C2 (ru) 2008-08-04 2009-07-30 Способ и система для передачи потоковых мультимедийных данных с нулевым копированием
EP09804442.3A EP2312807B1 (en) 2008-08-04 2009-07-30 Method and system for enabling zero-copy transmission of streaming media data
US13/057,625 US20110258337A1 (en) 2008-08-04 2009-07-30 Method and system for enabling zero-copy transmission of streaming media data
PL09804442T PL2312807T3 (pl) 2008-08-04 2009-07-30 Sposób i system umożliwiający transmisję danych mediów strumieniowych bez kopiowania

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN 200810142292 CN101340574B (zh) 2008-08-04 2008-08-04 一种实现零拷贝发送流媒体数据的方法及系统
CN200810142292.7 2008-08-04
CN200810241596.9 2008-12-26
CN 200810241596 CN101465854B (zh) 2008-12-26 2008-12-26 一种媒体服务器及实现准实时发送媒体数据的方法

Publications (1)

Publication Number Publication Date
WO2010015142A1 true WO2010015142A1 (zh) 2010-02-11

Family

ID=41663289

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2009/000852 WO2010015142A1 (zh) 2008-08-04 2009-07-30 一种实现零拷贝发送流媒体数据的方法及系统

Country Status (5)

Country Link
US (1) US20110258337A1 (zh)
EP (1) EP2312807B1 (zh)
PL (1) PL2312807T3 (zh)
RU (1) RU2477930C2 (zh)
WO (1) WO2010015142A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112511848A (zh) * 2020-11-09 2021-03-16 网宿科技股份有限公司 直播方法、服务端及计算机可读存储介质

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130262693A1 (en) * 2012-04-02 2013-10-03 Chris Phillips Methods and apparatus for segmenting, distributing, and resegmenting adaptive rate content streams
CN103617125A (zh) * 2013-11-27 2014-03-05 曙光信息产业(北京)有限公司 内存空间的管理方法和装置
CN103942097B (zh) * 2014-04-10 2017-11-24 华为技术有限公司 一种数据处理方法、装置及具备相应装置的计算机
CN105791884A (zh) * 2016-03-07 2016-07-20 读者出版传媒股份有限公司 一种流媒体直播方法及系统
US11855898B1 (en) * 2018-03-14 2023-12-26 F5, Inc. Methods for traffic dependent direct memory access optimization and devices thereof
CN108712308B (zh) * 2018-06-06 2021-11-26 郑州云海信息技术有限公司 虚拟网络中检测网络设备的方法和装置
CN110012343A (zh) * 2019-02-21 2019-07-12 生迪智慧科技有限公司 网络报文的生成方法及装置
CN114201311A (zh) * 2019-03-15 2022-03-18 华为技术有限公司 数据处理方法及装置
CN110086571A (zh) * 2019-04-10 2019-08-02 广州华多网络科技有限公司 一种数据发送及接收的方法、装置及数据处理系统
CN110048963B (zh) * 2019-04-19 2023-06-06 杭州朗和科技有限公司 虚拟网络中的报文传输方法、介质、装置和计算设备
US11403247B2 (en) * 2019-09-10 2022-08-02 GigaIO Networks, Inc. Methods and apparatus for network interface fabric send/receive operations
CN111083072A (zh) * 2019-11-29 2020-04-28 天津市滨海新区信息技术创新中心 交换机报文传输装置及方法
CN112995753B (zh) * 2019-12-16 2024-03-22 中兴通讯股份有限公司 一种媒体流分发方法、cdn节点服务器、cdn系统和可读存储介质
CN111181736B (zh) * 2019-12-31 2022-04-05 奇安信科技集团股份有限公司 数据传输方法、装置、系统及介质
CN113127139B (zh) * 2019-12-31 2023-12-26 阿里巴巴集团控股有限公司 一种基于数据面开发套件dpdk的内存分配方法和装置
CN113163443A (zh) * 2020-01-22 2021-07-23 普天信息技术有限公司 核心网数据传输方法及系统
CN113973091A (zh) * 2020-07-23 2022-01-25 华为技术有限公司 一种报文处理方法、网络设备以及相关设备
CN112114748B (zh) * 2020-09-02 2022-10-25 厦门安胜网络科技有限公司 一种用于冷热数据的分离方法和系统
CN116455612B (zh) * 2023-03-23 2023-11-28 京信数据科技有限公司 一种隐私计算中间数据流零拷贝装置及方法
CN116915860B (zh) * 2023-09-07 2023-11-28 深圳市升立德科技有限公司 基于udp的指令传输方法、装置、设备以及介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040199650A1 (en) * 2002-11-14 2004-10-07 Howe John E. System and methods for accelerating data delivery
CN101063963A (zh) * 2006-04-26 2007-10-31 韩国电子通信研究院 数据零拷贝文件的移动方法
CN101135980A (zh) * 2006-08-29 2008-03-05 飞塔信息科技(北京)有限公司 一种基于Linux操作系统实现零拷贝的装置和方法
CN101340574A (zh) * 2008-08-04 2009-01-07 中兴通讯股份有限公司 一种实现零拷贝发送流媒体数据的方法及系统
CN101465854A (zh) * 2008-12-26 2009-06-24 中兴通讯股份有限公司 一种媒体服务器及实现准实时发送媒体数据的方法

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7159030B1 (en) * 1999-07-30 2007-01-02 Intel Corporation Associating a packet with a flow
US7403974B1 (en) * 2001-06-25 2008-07-22 Emc Corporation True zero-copy system and method
US7181531B2 (en) * 2002-04-30 2007-02-20 Microsoft Corporation Method to synchronize and upload an offloaded network stack connection with a network stack
US7512128B2 (en) * 2002-06-12 2009-03-31 Sun Microsystems, Inc. System and method for a multi-packet data link layer data transmission
US7142540B2 (en) * 2002-07-18 2006-11-28 Sun Microsystems, Inc. Method and apparatus for zero-copy receive buffer management
JP4942375B2 (ja) * 2006-03-27 2012-05-30 株式会社ソニー・コンピュータエンタテインメント ネットワーク処理装置
US8929372B2 (en) * 2007-10-30 2015-01-06 Contextream Ltd. Grid router

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040199650A1 (en) * 2002-11-14 2004-10-07 Howe John E. System and methods for accelerating data delivery
CN101063963A (zh) * 2006-04-26 2007-10-31 韩国电子通信研究院 数据零拷贝文件的移动方法
CN101135980A (zh) * 2006-08-29 2008-03-05 飞塔信息科技(北京)有限公司 一种基于Linux操作系统实现零拷贝的装置和方法
CN101340574A (zh) * 2008-08-04 2009-01-07 中兴通讯股份有限公司 一种实现零拷贝发送流媒体数据的方法及系统
CN101465854A (zh) * 2008-12-26 2009-06-24 中兴通讯股份有限公司 一种媒体服务器及实现准实时发送媒体数据的方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
KURMANN, CHRISTIAN ET AL.: "Speculative Defragmentation - A Technique to Improve the Communication Software Efficiency for Gigabit Ethernet.", 9TH IEEE INTERNATIONAL SYMPOSIUM ON HIGH PERFORMANCE DISTRIBUTED COMPUTING., 4 August 2000 (2000-08-04), XP010511542, Retrieved from the Internet <URL:http://www2.computer.org/portal/web/csdl/doi/10.1109/HPDC.2000.868643> [retrieved on 20090915] *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112511848A (zh) * 2020-11-09 2021-03-16 网宿科技股份有限公司 直播方法、服务端及计算机可读存储介质
CN112511848B (zh) * 2020-11-09 2023-06-20 网宿科技股份有限公司 直播方法、服务端及计算机可读存储介质

Also Published As

Publication number Publication date
EP2312807A1 (en) 2011-04-20
EP2312807B1 (en) 2018-11-14
EP2312807A4 (en) 2016-12-14
RU2477930C2 (ru) 2013-03-20
PL2312807T3 (pl) 2019-04-30
US20110258337A1 (en) 2011-10-20
RU2011107517A (ru) 2012-09-10

Similar Documents

Publication Publication Date Title
WO2010015142A1 (zh) 一种实现零拷贝发送流媒体数据的方法及系统
CN101340574B (zh) 一种实现零拷贝发送流媒体数据的方法及系统
US11899596B2 (en) System and method for facilitating dynamic command management in a network interface controller (NIC)
US8392565B2 (en) Network memory pools for packet destinations and virtual machines
US7320041B2 (en) Controlling flow of data between data processing systems via a memory
US7076569B1 (en) Embedded channel adapter having transport layer configured for prioritizing selection of work descriptors based on respective virtual lane priorities
US7870268B2 (en) Method, system, and program for managing data transmission through a network
CN101304373B (zh) 一种实现局域网内高效传输大块数据的方法及系统
US7409468B2 (en) Controlling flow of data between data processing systems via a memory
EP0889623A2 (en) System and method for efficient remote disk I/O
US20070011358A1 (en) Mechanisms to implement memory management to enable protocol-aware asynchronous, zero-copy transmits
US7283549B2 (en) Method for increasing the transmit and receive efficiency of an embedded ethernet controller
KR100640515B1 (ko) 주변장치로부터 호스트 컴퓨터 시스템에 인터럽트를전달하기 위한 방법 및 장치
US20040213243A1 (en) Transmission components for processing VLAN tag and priority packets supported by using single chip&#39;s buffer structure
CN113067849B (zh) 基于Glusterfs的网络通信优化方法及装置
US7788437B2 (en) Computer system with network interface retransmit
US20060004904A1 (en) Method, system, and program for managing transmit throughput for a network controller
TW200302413A (en) Netbufs: communication protocol packet buffering using paged memory management
Recio Rdma enabled nic (rnic) verbs overview
US20020049875A1 (en) Data communications interfaces
US7532644B1 (en) Method and system for associating multiple payload buffers with multidata message
US20050141434A1 (en) Method, system, and program for managing buffers
US20020049878A1 (en) Data communications interfaces
CN100428670C (zh) 流媒体服务器用户层通信方法
KR100645454B1 (ko) 서버의 디스크와 네트워크 간에 데이터 전송 효율을높이기 위한 서버 성능 가속기 장치

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 09804442

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2009804442

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2011107517

Country of ref document: RU

Ref document number: A20110280

Country of ref document: BY

WWE Wipo information: entry into national phase

Ref document number: 13057625

Country of ref document: US