WO2010069179A1 - 一种发送多路数据包的方法及系统 - Google Patents

一种发送多路数据包的方法及系统 Download PDF

Info

Publication number
WO2010069179A1
WO2010069179A1 PCT/CN2009/073606 CN2009073606W WO2010069179A1 WO 2010069179 A1 WO2010069179 A1 WO 2010069179A1 CN 2009073606 W CN2009073606 W CN 2009073606W WO 2010069179 A1 WO2010069179 A1 WO 2010069179A1
Authority
WO
WIPO (PCT)
Prior art keywords
data packet
routing information
routing
array
sent
Prior art date
Application number
PCT/CN2009/073606
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
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Priority to US13/140,101 priority Critical patent/US20110292936A1/en
Publication of WO2010069179A1 publication Critical patent/WO2010069179A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/24Multipath
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/56Routing software
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/741Routing in networks with a plurality of addressing schemes, e.g. with both IPv4 and IPv6
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast
    • H04L12/1886Arrangements for providing special services to substations for broadcast or conference, e.g. multicast with traffic restrictions for efficiency improvement, e.g. involving subnets or subdomains

Definitions

  • the present invention relates to the field of network communication technologies, and in particular, to a method and system for transmitting multiple data packets.
  • UDP for packet transmission
  • the prior art generally includes:
  • Step 1 Call Create (call socket function) The system implementation creates a network socket.
  • Step 2 Call Binding
  • the system implements binding the network socket to the local IP address and UDP port.
  • Step 3 Call the send (sendto/sendmsg) system to send UDP packets to the remote host.
  • Step 4. Call the close (close) system to close the network socket.
  • a network socket is required for each audio stream, and the user process packages the audio file into a real-time transport protocol (RTP) packet, and then calls UDP.
  • RTP real-time transport protocol
  • IP address and port specify the remote IP address and UDP port in the delivery interface to send the packet out. Since the remote IP address of the same audio stream does not change normally, the route caching mechanism implemented in the existing packet interface can only support the remote IP address of one audio stream. Cache, therefore, only need to query the routing table once to obtain the next hop IP address and MAC address corresponding to the remote IP address, and subsequent transmissions will use the routing information of the network socket cache to forward the data packet.
  • the prior art can share multiple data packets by using one socket. If multiple audio streams share the same network socket, you need to use the bind system call to set the local IP address and UDP port before calling the outgoing interface. Then specify the remote IP address and UDP port on the outgoing interface. The packet is sent out.
  • the route caching mechanism implemented in the existing packet sending interface can only support the buffering of the remote IP address of one audio stream when sending network packets.
  • the remote IP address changes, you need to re-query the routing table stored in the kernel data structure corresponding to the socket to obtain the next hop IP address and multimedia access control (MAC) address corresponding to the remote IP address, and frequently query.
  • the routing table will cause a lot of system overhead.
  • the user process each time the user process sends an audio data packet, it needs to use a system call.
  • the system call needs to be switched from the user mode to the kernel state. After the system call returns, the kernel mode is switched to the user mode.
  • the CRBT server is heavily loaded, a large amount of data copying and context switching operations are triggered, which greatly consumes CPU resources of the system and reduces the processing power of the system.
  • the prior art can share multiple data packets in one socket.
  • the destination IP addresses of multiple data packets are different, only the way to create separate network sockets for multiple audios can be used, but the system call, route query overhead, and process/thread switching in this way. The number of times will be relatively large.
  • each time a network socket is used to send a data packet only the destination IP address of one data packet can be cached, so that it is impossible to use the same network socket to send multiple data packets with different destination IP addresses.
  • the prior art cannot use the same network socket to send multiple data packets.
  • the embodiment of the invention provides a method and a system for transmitting a multi-way data packet, which are used for transmitting multi-channel data packets through the same network socket, thereby improving the working efficiency of transmitting multi-channel data packets.
  • routing information of the multiplexed data packet and adding the routing information to the routing buffer array; and acquiring routing information of the multiplexed data packet from the routing cache array when the multiplexed data packet needs to be sent, And sending the multi-path data packet according to the routing information.
  • Creating a socket unit configured to create a network socket containing an array of route caches for caching routing information for the multiplexed data packets
  • a sending processing unit configured to acquire routing information of the multi-path data packet and add the routing information to the routing buffer array; and when the multi-path data packet needs to be sent, obtain the multi-path from the routing buffer array Routing information of the data packet, and sending the multiple data packet according to the routing information.
  • a network socket is created, where a route cache array for buffering routing information of multiple data packets is included; routing information of the multiple data packets is obtained and added to the route cache array;
  • routing information of the multi-path data packet is obtained from the routing buffer array, and the multi-way data packet is sent according to the routing information, thereby realizing that the system is called once.
  • Multiple data packets can be sent, which avoids the cumbersome process of calling a system when sending a data packet, thus reducing the overhead of system calls when sending multiple data packets, and improving the efficiency of sending multiple data packets.
  • FIG. 1 is a schematic flowchart of an overall method for transmitting a multi-path data packet according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a process flow of a network protocol stack system call according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a data structure used by a network protocol stack system call interface core parameter according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of a system for transmitting a multi-path data packet according to an embodiment of the present invention. Preferred embodiment of the invention
  • the embodiment of the invention provides a method and a system for transmitting a multi-channel data packet by using a network protocol stack based on Linux, and transmitting through the same network socket without affecting the original network protocol stack of the Linux system.
  • Multi-path data packets minimize CPU consumption caused by system calls, routing queries, or process/thread switching, improve system processing power, and improve the efficiency of sending multiple data packets.
  • the multiplexed data packet is sent as an example of a multi-channel audio stream.
  • the multiplexed data packet of the present invention refers to multiple data packets with different destination IP addresses.
  • a method for transmitting a multi-path data packet generally includes the following steps:
  • Create a network socket which includes an array of routing buffers for caching routing information of multiple data packets.
  • a network socket is created, and the multi-channel audio stream can be sent, and the routing information of the multi-channel audio stream is cached in the network socket, so that the network socket is in service. Multiple audio streams do not need to be routed repeatedly.
  • the embodiment of the present invention can realize the transmission of multiple audio streams by using one system call, each The secondary system call can send one data packet for each audio stream of the multiple audio streams. It should be noted that a network socket is created, and it may be necessary to send data packets to multiple users multiple times, each time sending a data packet. All need to call the sending system once, but each time the transmitting system is called, the embodiment of the present invention can send data packets to multiple users, that is, send multiple data packets.
  • a route cache unit is allocated to each audio stream in the kernel cache space of the network socket.
  • a simple implementation method is to allocate a route cache array for buffering. Routing information for road packets.
  • the routing table is separately queried for each audio stream to obtain the routing information of the audio stream, and each audio stream is obtained.
  • the routing information is cached into the route cache array to implement the caching function of the routing information corresponding to the multi-channel audio stream.
  • the routing information of each data packet buffered in the routing buffer array corresponds to the index value of the data packet, and according to the index value of each data packet in the multiple data packet, the cable cache array can be obtained from the routing buffer array.
  • the routing information of the data packet corresponding to the bow I value.
  • the routing table After the first call to the transmitting system to send multiple data packets and then call the sending system to send multiple data packets, for each audio stream, it is not necessary to query the routing table again to obtain its routing information, but according to the index value of each audio stream.
  • the routing information is obtained directly from the entry of the route cache array, and the route search function of the data packet is completed, so that the data packet can be quickly sent out.
  • the system call interface for transmitting multiple data packets needs to be able to transmit information of multiple audio data packets, including the payload of the audio data packet and the corresponding remote IP address and UDP port.
  • the routing information is obtained from the routing buffer array, and after the audio data packet is encapsulated, each audio stream is sent according to the routing information.
  • the routing information obtained from the routing cache array includes: an IP address of the next hop of the local end, or an IP address and a MAC address of the next hop of the local end.
  • the IP address of the next hop of the local end can be obtained according to the IP address of the next hop of the local end. However, in order to process faster, the IP address of the next hop of the local end is cached in the route cache array. In addition to the address, the MAC address of the next hop of the local end may be further cached to directly obtain the MAC address of the next hop of the local end.
  • the transmission of multiple audio streams can be realized, so that repeated switching of multiple process/thread spaces due to serving multiple users can be avoided.
  • the network socket programming interface provided by the network protocol stack of the embodiment of the present invention includes: a socket system for creating a network socket, a close system for closing a network socket, and a high performance transmitting multi-way data packet.
  • the sendmsg system The network protocol stack is used to implement a routing information caching function of a multi-way data packet, and is used to implement a system call to send multiple audio streams, which reduces the packaging of audio data packets compared with the network protocol stack of the existing Linux kernel. Route lookup overhead and system call overhead during transmission.
  • the Linux protocol-based network protocol stack implements a high-performance transmission multi-path data packet, and utilizes the original Linux network protocol stack, and the network protocol stack is implemented by using a kernel module mechanism, and the kernel module is loaded and unloaded. Will not affect the original network protocol stack of the Linux kernel.
  • the hardware and software of the CRBT server in the embodiment of the present invention includes user process space, Linux kernel space, and hardware devices (including network cards). Between the hardware device and the user process is a Linux kernel space, and a network protocol stack is disposed on the network card driver in the kernel space, and the network protocol stack provides a network socket programming interface to the user process, the network socket
  • the programming interface mainly includes socket, close, sendmsg and other systems, wherein the socket system is used to create a network socket, the close system is used to close the network socket, and the sendmsg system is used to implement high performance to send multiple data packets.
  • the processing flow of the network protocol stack system call implemented by the embodiment of the present invention is as shown in FIG. 2.
  • the hardware environment of the embodiment of the present invention requires a network card, and the software environment is a Linux kernel with a normal network function.
  • the embodiment of the present invention creates a MUTLI network protocol stack based on the AF-MULTI network socket type based on the Linux kernel.
  • the network protocol stack provides the user process with an AF MUTLI type network socket programming interface.
  • the socket uses the AF-MUTLI network socket created by the socket system call.
  • Msg->msg name Temporarily not used, set to NULL.
  • Msg -> msg - namelen is not used, set to 0.
  • the msg->msg_iov input parameter is a pointer to a struct iovec array.
  • Each struct iovec structure contains the buffer address and length of the audio stream data to be sent.
  • the msg->msg_iovlen input parameter is the length of the struct iovec array pointed to by msg iov.
  • Msg->msg control Input and output parameters, used to store the control information of each audio stream packet, including the IP address and UDP port of the local end and the peer end; the output is used to return the data of the transmission failure or the transmission error.
  • the index value of the packet and the error code can further return the number of successfully transmitted packets and the number of failed packets.
  • Msg->msg_controllen Input parameter for storing the total length of the msg-control information.
  • Msg->msg—flags are not used temporarily, set to 0.
  • msg control return value: If all packets are not successfully transmitted, return -1 via the output parameter msg_control and set the error code errno.
  • the so-called error code includes information such as the cause of the transmission failure. If all packets are sent successfully, then 0 is returned via msg_control. If some packets are not successfully sent, the number of successfully transmitted packets or the number of failed packets is returned by msg_control, and the index of the failed packet and the corresponding error code.
  • the data structure struct msghdr of the core parameter msg is shown in FIG. 3, and includes three audio stream packets to be sent.
  • the information constituting the audio stream data packet is stored in the parameter msg, and the msg_iov field is used to store the payload information of the audio stream data packet to be sent, and includes the address and length information of the user data buffer as the payload of the audio stream data packet;
  • the msg-control field is used to store the header information of the audio stream packet to be sent, including the remote IP address and UDP port number, etc., for generating IP data.
  • the head of the bag is used to store the header information of the audio stream packet to be sent, including the remote IP address and UDP port number, etc., for generating IP data.
  • a kernel buffer structure is allocated for each audio stream data packet to be sent in the kernel space, and the data of the kernel buffer structure is composed of two parts: part is the payload of the audio stream data packet, The payload is obtained from the payload information contained in msg_iov; the other part is the header information of the audio stream packet, including the local IP address, UDP port and MAC address information, and the remote IP obtained from msg_control.
  • the address and UDP port, and the routing information obtained from the route cache array that is, the IP address and MAC address of the next hop of the local end.
  • a system for transmitting a multi-path data packet includes: a socket unit 41 for creating a network socket, where a route for buffering routing information of a multi-path data packet is included. Cache array.
  • the sending processing unit 42 is configured to obtain routing information of the multi-path data packet and add the routing information to the routing buffer array; when the multi-path data packet needs to be sent, obtain routing information of the multi-way data packet from the routing buffer array, and according to The routing information sends out multiple packets.
  • the sending processing unit 42 includes:
  • the routing information unit 421 is configured to obtain routing information of the multi-path data packet and add the routing information to the routing buffer array, where the routing information of each data packet buffered in the routing buffer array corresponds to the index value of the data packet.
  • the sending unit 422 is configured to: when the multi-path data packet needs to be sent, obtain, according to an index value of each data packet in the multi-path data packet, a route of the data packet corresponding to the cable value from the route cache array. Information, and the data packet is sent out according to the routing information.
  • the sending unit 422 includes:
  • the routing information obtaining unit 4221 is configured to: when the multi-path data packet needs to be sent, obtain the data corresponding to the value of the cable from the route cache array according to an index value of each data packet in the multi-path data packet. Packet routing information.
  • the load obtaining unit 4222 is configured to acquire a load of the multi-path data packet.
  • the header information obtaining unit 4223 is configured to obtain header information of the multi-path data packet, where the local IP address of the multi-path data packet, the network socket UDP interface, and the multimedia access control are included. MAC address, remote IP address and UDP interface, and routing information.
  • the encapsulation processing unit 4224 is configured to generate a multi-path data packet by using the payload of each data packet and the header information thereof, and send the multi-channel data packet according to the routing information of each data packet.
  • the payload and header information of the audio stream is generated into an IP data packet of the audio stream, and the IP data packet is transmitted according to the routing information of the audio stream.
  • the sending processing unit 42 further includes:
  • the result feedback unit 423 is configured to output the number of successfully transmitted data packets, and/or the index value and the error code of the data packet that failed to be transmitted.
  • the system further comprises:
  • the method and system provided by the embodiments of the present invention make full use of the single-channel routing query function of the original Linux network protocol stack, and implement the multi-way route caching function, compared with the existing Linux kernel network protocol stack.
  • the embodiment of the invention implements the routing information of using a network socket to buffer multiple data packets, and reduces the route searching operation in the multi-path data packet forwarding process.
  • the embodiment of the present invention utilizes the data structure of the system call in the original Linux kernel network protocol stack, realizes the multi-way data packet forwarding function by one system call, and avoids the cumbersome operation of requiring a system call to send a data packet, reducing The system call overhead during multi-path packet forwarding.
  • the present invention creates a network socket, which includes a route cache array for buffering routing information of multiple data packets; acquires routing information of the multiple data packets and adds the number of routing buffers to the routing buffer
  • the routing information of the multi-path data packet is obtained from the routing buffer array, and the multi-way data packet is sent according to the routing information, thereby realizing By calling the system once, multiple data packets can be sent, which avoids the cumbersomeness of calling the system once a packet is sent, thus reducing the overhead of system calls when sending multiple data packets, and improving the efficiency of sending multiple data packets.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Description

一种发送多路数据包的方法及系统
技术领域
本发明涉及网络通信技术领域, 尤其涉及一种发送多路数据包的方法及 系统。
背景技术
在基于 Linux操作系统的彩铃服务器应用中, 需要将大量的音频文件传 递到 IP网络上。 但是, 如果想通过 IP网络传输音频数据, 就需要将音频文 件转化为 IP数据报, 通过网络套接字 (例如 UDP套接字)进行数据包的发 送。
使用 UDP进行数据包的发送, 现有技术一般包括:
步骤 1、 调用创建(调用 socket函数) 系统实现创建网络套接字。
步骤 2、 调用绑定(bind ) 系统实现将网络套接字与本地 IP地址和 UDP 端口相绑定。
步骤 3、 调用发送( sendto/sendmsg )系统实现发送 UDP数据包到远端主 机。
其中, 发送 UDP数据包时需要指定目标主机的远端 IP地址和 UDP端口 (即 UDP数据包的目的 IP地址和目的 UDP端口) 。
步骤 4、 调用关闭 (close ) 系统实现关闭网络套接字。
在现有技术的这种方式下, 对于每一路音频流, 都需要使用一个网络套 接字, 用户进程将音频文件打包成实时传送协议 ( RTP, Real-time Transport Protocol)数据包后, 调用 UDP数据包发送接口, 将 RTP数据包发送出去。
如果为远端 IP地址(即目的 IP地址)相同的多路音频流各自创建单独 的网络套接字, 则只需要第一次调用发包接口前, 使用 IP地址和 UDP端口 绑定接口设定本地 IP地址和端口 ,然后在发包接口中指定远端 IP地址和 UDP 端口,将数据包发送出去。由于同一路音频流的远端 IP地址通常都不会变化, 现有发包接口中实现的路由緩存机制只能够支持一路音频流的远端 IP地址的 緩存, 因此发包时只需要查询一次路由表获取远端 IP地址对应的下一跳 IP 地址和 MAC地址, 后续的发送都将使用该网络套接字緩存的路由信息进行 数据包的转发。
在多个数据包的目的 IP地址相同的情况下 ,为了减少进程 /线程切换的次 数, 以及减小系统调用开销, 现有技术可以将多个数据包共用一个套接字进 行发送。 如果多路音频流共享同一个网络套接字, 则每次调用发包接口前, 需要使用 bind系统调用设定本地 IP地址和 UDP端口, 然后在发包接口中指 定远端 IP地址和 UDP端口, 将数据包发送出去。
然而, 由于多路音频流的远端 IP地址常常是不一样的, 而现有发包接口 中实现的路由緩存机制在发送网络数据包时只能支持一路音频流的远端 IP地 址的緩存, 当远端 IP地址发生变化的时候, 需要重新查询存储在 socket对应 的内核数据结构中的路由表来获取远端 IP地址对应的下一跳 IP地址和多媒 体接入控制 (MAC )地址, 而频繁查询路由表将会造成很大的系统开销。
因此当多路音频流的目的 IP地址不同时, 只能釆用为多路音频流各自创 建单独的网络套接字进行发送的方式。 然而, 为每一路音频流都创建一个单 独的网络套接字, 对于一个支持几千路甚至上万路的彩铃服务器来说, 将会 占用大量的系统资源, 多路进程 /线程的频繁切换也会对系统的性能产生很大 的影响。
此外, 用户进程每发送一个音频数据包, 就需要使用一次发送系统调用, 每次系统调用需要先从用户态切换到内核态, 系统调用返回后, 再从内核态 切换到用户态。 在彩铃服务器负荷较重的情况下, 会触发大量的数据拷贝和 上下文切换操作, 极大地消耗系统的 CPU资源, 降低系统的处理能力。
由此可见, 在多个数据包的目的 IP地址相同的情况下, 为了减少进程 / 线程切换的次数, 以及减小系统调用开销, 现有技术可以将多个数据包共用 一个套接字发送。 但是, 当多个数据包的目的 IP地址不同时, 只能釆用为多 路音频各自创建单独的网络套接字发送的方式, 但是此种方式的系统调用、 路由查询开销以及进程 /线程切换的次数都会比较大。 现有技术每次釆用网络 套接字发送数据包的时候, 只能緩存一路数据包的目的 IP地址, 因此无法釆 用同一网络套接字发送多个目的 IP地址不同的数据包。 综上所述, 现有技术无法釆用同一网络套接字发送多路数据包。
发明内容
本发明实施例提供了一种发送多路数据包的方法及系统, 用以实现通过 同一网络套接字发送多路数据包, 提高发送多路数据包的工作效率。
本发明实施例提供的一种发送多路数据包的方法包括:
创建网络套接字, 其中包含用于緩存多路数据包的路由信息的路由緩存 数组;
获取所述多路数据包的路由信息并添加到所述路由緩存数组中; 以及 当需要发送所述多路数据包时, 从所述路由緩存数组中获取所述多路数 据包的路由信息, 并根据该路由信息将所述多路数据包发送出去。
本发明实施例提供的一种发送多路数据包的系统包括:
创建套接字单元, 其设置成创建网络套接字, 其中包含用于緩存多路数 据包的路由信息的路由緩存数组;
发送处理单元, 其设置成获取所述多路数据包的路由信息并添加到所述 路由緩存数组中; 当需要发送所述多路数据包时, 从所述路由緩存数组中获 取所述多路数据包的路由信息, 并根据该路由信息将所述多路数据包发送出 去。
本发明实施例, 通过创建网络套接字, 其中包含用于緩存多路数据包的 路由信息的路由緩存数组; 获取所述多路数据包的路由信息并添加到所述路 由緩存数组中; 当需要发送所述多路数据包时, 从所述路由緩存数组中获取 所述多路数据包的路由信息,并根据该路由信息将所述多路数据包发送出去, 从而实现了调用一次系统就可以发送多路数据包, 避免了发送一个数据包就 需要调用一次系统的繁瑣, 因此减少了发送多路数据包时系统调用的开销, 提高了发送多路数据包的工作效率。
附图概述
图 1为本发明实施例提供的一种发送多路数据包的总体方法的流程示意 图;
图 2为本发明实施例提供的网络协议栈系统调用的处理流程示意图; 图 3为本发明实施例提供的网络协议栈系统调用接口核心参数所使用的 数据结构示意图; 以及
图 4为本发明实施例提供的一种发送多路数据包的系统结构示意图。 本发明的较佳实施方式
本发明实施例提供了一种基于 Linux的网络协议栈实现高性能地发送多 路数据包的方法及系统, 在不影响 Linux 系统原有网络协议栈的情况下, 实 现通过同一网络套接字发送多路数据包, 尽量减少系统调用、 路由查询或者 进程 /线程切换引起的 CPU 消耗, 提高系统的处理能力, 并且提高发送多路 数据包的工作效率。
本发明实施例以发送的多路数据包为多路音频流为例进行说明, 当然, 本发明所述的多路数据包是指目的 IP地址不同的多个数据包。
下面结合附图对本发明实施例提供的技术方案进行说明。
参见图 1 , 本发明实施例提供的一种发送多路数据包的方法总体包括步 骤:
5101、 创建网络套接字, 其中包含用于緩存多路数据包的路由信息的路 由緩存数组。
5102、 获取多路数据包的路由信息并添加到路由緩存数组中。
5103、 当需要发送所述多路数据包时, 从路由緩存数组中获取多路数据 包的路由信息, 并根据每一路数据包的路由信息将该路数据包发送出去。
本发明实施例创建了一个网络套接字, 就可以实现多路音频流的发送, 并在该网络套接字内部实现多路音频流的路由信息的緩存机制, 以便该网络 套接字在服务多路音频流时无需反复进行路由查询操作。
本发明实施例使用一次系统调用, 就可以实现多路音频流的发送, 每一 次系统调用都能够为多路音频流的每一路音频流发送一个数据包, 需要说明 的是, 创建了一个网络套接字, 可能需要对多个用户多次发送数据包, 每次 发送数据包都需要调用一次发送系统, 但是本发明实施例每调用一次发送系 统, 可以对多个用户发送数据包, 即发送多路数据包。
本发明实施例在创建网络套接字的时候, 在网络套接字的内核緩存空间 为每一路音频流分配一个路由緩存单元, 一种简单的实现方法是分配一个路 由緩存数组, 用以緩存多路数据包的路由信息。
本发明实施例在创建了网络套接字之后的第一次调用发送系统发送多路 数据包时, 对于每一路音频流分别查询路由表获取该路音频流的路由信息, 并将每一路音频流的路由信息緩存到路由緩存数组中, 实现多路音频流对应 的路由信息的緩存功能。 路由緩存数组中緩存的每一路数据包的路由信息与 该路数据包的索引值相对应, 根据多路数据包中的每一路数据包的索引值, 就可以从该路由緩存数组中获取该索弓 I值所对应的该路数据包的路由信息。
在第一次调用发送系统发送多路数据包之后再次调用发送系统发送多路 数据包时, 对于每一路音频流, 无需再次查询路由表获取其路由信息, 而是 根据每一路音频流的索引值,直接从路由緩存数组的表项中获取其路由信息 , 完成数据包的路由查找功能, 从而可以将数据包快速发送出去。
本发明实施例在发送多路数据包完毕, 关闭该网络套接字的时候, 除了 进行普通的资源回收外, 还需要完成该路由緩存数组的释放。
本发明实施例在发送多路数据包的系统调用接口, 需要能够传入多个音 频数据包的信息, 包括音频数据包的载荷和对应的远端 IP地址和 UDP端口。 在系统调用内部, 对于每一路音频流, 根据其对应的索引值, 从路由緩存数 组中获取路由信息, 对音频数据包载荷封装之后, 按照路由信息将每一路音 频流发送出去。
本发明实施例中, 从路由緩存数组中获取的路由信息包括: 本端的下一 跳的 IP地址, 或者本端的下一跳的 IP地址和 MAC地址。
其中,根据本端的下一跳的 IP地址可以得到本端的下一跳的 MAC地址, 但是, 为了处理速度更快, 在路由緩存数组中除了緩存本端的下一跳的 IP地 址之外, 还可以进一步緩存本端的下一跳的 MAC地址, 以便直接获取本端 的下一跳的 MAC地址。
本发明实施例由于使用一个网络套接字、 进行一次系统调用, 就可以实 现多路音频流的发送, 因此可以避免由于服务多路用户而出现的多个进程 /线 程空间的反复切换。
本发明实施例的网络协议栈提供的网络套接字编程接口包括: 用于创建 网络套接字的 socket系统、用于关闭网络套接字的 close系统、用于实现高性 能发送多路数据包的 sendmsg系统。 所述的网络协议栈用于实现多路数据包 的路由信息緩存功能, 用于实现一次系统调用发送多路音频流, 与现有 Linux 内核的网络协议栈相比, 减少了将音频数据包打包发送过程中的路由查找开 销和系统调用开销。
下面结合附图对本发明实施例进行详细说明。
本发明实施例基于 Linux的网络协议栈实现高性能发送多路数据包的方 案中, 利用了原有的 Linux 网络协议栈, 该网络协议栈利用内核模块机制实 现, 所述内核模块的加载和卸载都不会影响 Linux内核原有的网络协议栈。
本发明实施例所述彩铃服务器的软硬件包括用户进程空间、 Linux内核空 间和硬件设备(包括网卡) 。 在硬件设备与用户进程之间是 Linux内核空间, 在该内核空间内的网卡驱动程序之上设置有网络协议栈, 该网络协议栈给用 户进程提供网络套接字编程接口, 该网络套接字编程接口主要包括 socket, close、 sendmsg等系统, 其中 socket系统用于创建网络套接字, close系统用 于关闭网络套接字, sendmsg系统用于实现高性能发送多路数据包。
本发明实施例实现的网络协议栈系统调用的处理流程如图 2所示, 本发 明实施例的硬件环境要求有网卡, 软件环境为网络功能正常的 Linux 内核。 为了实现高性能发送多路数据包的功能, 本发明实施例在 Linux 内核的基础 上创建了基于 AF— MULTI网络套接字类型的 MUTLI网络协议栈。 该网络协 议栈给用户进程提供 AF MUTLI类型的网络套接字编程接口。
本发明实施例实现的 sendmsg系统的定义及其解释如下:
定义: ssize t sendmsg(int socket, const struct msghdr *msg, int flags)。 功能: 通过网络套接字进行高性能发送多路音频流数据。 在该系统调用 内部实现多路路由信息的路由緩存功能和多路数据包的转发功能。
输入输出参数的说明:
socket 使用 socket系统调用创建的 AF— MUTLI网络套接字。
msg->msg— name 暂时不用, 置为 NULL。
msg -〉 msg— namelen 暂时不用, 置为 0。
msg->msg_iov 输入参数, 是指向 struct iovec数组的指针。 每个 struct iovec结构包含一路待发送音频流数据的緩冲区地址和长度。
msg->msg_iovlen 输入参数, 是用于存放 msg iov所指向的 struct iovec数组的长度。
msg->msg— control 输入输出参数, 输入时用于存放每个音频流数据 包的控制信息, 包括本端及对端的 IP地址和 UDP端口等; 输出时用于返回 发送失败或发送错误的数据包的索引值和错误码, 进一步还可以返回发送成 功的数据包的个数和发送失败的数据包的个数。
msg->msg_controllen 输入参数, 用于存放 msg— control信息的总长度。 msg->msg— flags 暂时不用, 置为 0。
flags 暂时不用, 置为 0。
关于 msg— control返回值的说明: 如果全部数据包都没有发送成功, 则通 过输出参数 msg— control返回 -1 , 并设置错误码 errno。 所谓错误码包括发送失 败的原因等信息。 如果全部数据包均发送成功, 则通过 msg— control返回 0。 如果部分数据包没有发送成功, 则通过 msg— control返回发送成功的数据包的 数目或发送失败的数据包的数目, 以及发送失败的数据包的索引值和相应的 错误码。
核心参数 msg的数据结构 struct msghdr如图 3所示, 包含 3个待发送的 音频流数据包。 构成音频流数据包的信息存放在参数 msg中, msg— iov字段 用于存放待发送音频流数据包的载荷信息, 包含用户数据緩冲区的地址和长 度信息, 作为音频流数据包的载荷; msg— control字段用于存放待发送音频流 数据包的头部信息, 包含远端的 IP地址和 UDP端口号等, 用于生成 IP数据 包的头部。
本发明实施例在调用 sendmsg系统时, 在内核空间为每一个待发送的音 频流数据包分配内核緩冲结构, 该内核緩冲结构的数据由两部分组成: 一部 分是音频流数据包的载荷, 该载荷是从 msg— iov中包含的载荷信息得到的; 另一部分是音频流数据包的头部信息, 包括本端 IP地址、 UDP端口和 MAC 地址信息, 从 msg— control中获取的远端 IP地址和 UDP端口, 以及从路由緩 存数组中得到的路由信息, 即本端的下一跳的 IP地址和 MAC地址。
下面结合附图介绍一下本发明实施例提供的系统。
参见图 4, 本发明实施例提供的一种发送多路数据包的系统包括: 创建套接字单元 41 , 用于创建网络套接字, 其中包含用于緩存多路数据 包的路由信息的路由緩存数组。
发送处理单元 42, 用于获取多路数据包的路由信息并添加到路由緩存数 组中; 当需要发送所述多路数据包时, 从路由緩存数组中获取多路数据包的 路由信息, 并根据该路由信息将多路数据包发送出去。
较佳地, 所述发送处理单元 42包括:
添加路由信息单元 421 , 用于获取多路数据包的路由信息并添加到路由 緩存数组中, 该路由緩存数组中緩存的每一路数据包的路由信息与该路数据 包的索引值相对应。
发送单元 422, 用于当需要发送所述多路数据包时, 根据多路数据包中 的每一路数据包的索引值, 从路由緩存数组中获取该索 1值对应的该路数据 包的路由信息, 并根据该路由信息将该路数据包发送出去。
较佳地, 所述发送单元 422包括:
路由信息获取单元 4221 , 用于当需要发送所述多路数据包时, 根据多路 数据包中的每一路数据包的索引值, 从路由緩存数组中获取该索弓 )值对应的 该路数据包的路由信息。
载荷获取单元 4222, 用于获取多路数据包的载荷。
头部信息获取单元 4223 , 用于获取所述多路数据包的头部信息, 其中包 括所述多路数据包的本地 IP地址、 网络套接字 UDP接口和多媒体接入控制 MAC地址, 远端 IP地址和 UDP接口, 以及路由信息。
封装处理单元 4224, 用于利用各路数据包的载荷及其头部信息生成多路 数据包, 并按照各路数据包的路由信息将该多路数据包发送出去。
例如, 对于多路音频流中的每一音频流, 将该音频流的载荷及头部信息 生成该音频流的 IP数据包, 并按照该音频流的路由信息将该 IP数据包发送 出去。
较佳地, 所述发送处理单元 42还包括:
结果反馈单元 423 , 用于输出发送成功的数据包的个数, 和 /或发送失败 的数据包的索引值及错误码。
较佳地, 该系统还包括:
关闭套接字单元 43 , 用于关闭网络套接字, 并释放路由緩存数组。 综上所述, 本发明实施例提供的方法及系统充分利用了原有 Linux 网络 协议栈的单路路由查询功能, 实现了多路路由緩存功能, 与现有的 Linux 内 核网络协议栈相比, 本发明实施例实现了使用一个网络套接字緩存多路数据 包的路由信息, 减少了多路数据包转发过程中的路由查找操作。 并且, 本发 明实施例利用了原有 Linux 内核网络协议栈中系统调用的数据结构, 通过一 次系统调用实现多路数据包转发功能, 避免了发送一个数据包就需要一次系 统调用的繁瑣操作, 减少了多路数据包转发过程中的系统调用开销。
需要说明的是, 上述网络协议栈的实现是通过软件实现的, 系统调用的 实现也是现有技术软件实现中所熟知的, 因此本发明实施例中不再赘述其具 体实现过程。 发明的精神和范围。 这样, 倘若本发明的这些修改和变型属于本发明权利要 求及其等同技术的范围之内, 则本发明也意图包含这些改动和变型在内。
工业实用性
本发明通过创建网络套接字, 其中包含用于緩存多路数据包的路由信息 的路由緩存数组; 获取所述多路数据包的路由信息并添加到所述路由緩存数 组中; 当需要发送所述多路数据包时, 从所述路由緩存数组中获取所述多路 数据包的路由信息, 并根据该路由信息将所述多路数据包发送出去, 从而实 现了调用一次系统就可以发送多路数据包, 避免了发送一个数据包就需要调 用一次系统的繁瑣, 因此减少了发送多路数据包时系统调用的开销, 提高了 发送多路数据包的工作效率。

Claims

权 利 要 求 书
1、 一种发送多路数据包的方法, 包括:
创建网络套接字, 所述网络套接字中包含用于緩存多路数据包的路由信 息的路由緩存数组;
获取所述多路数据包的路由信息并添加到所述路由緩存数组中; 以及 当需要发送所述多路数据包时, 从所述路由緩存数组中获取所述多路数 据包的路由信息, 并根据该路由信息将所述多路数据包发送出去。
2、根据权利要求 1所述的方法, 其中从所述路由緩存数组中获取所述多 路数据包的路由信息的所述步骤包括:
根据所述多路数据包中的每一路数据包的索引值从所述路由緩存数组中 获取该索弓 )值对应的路由信息, 得到所述多路数据包的路由信息。
3、根据权利要求 1所述的方法, 其中根据所述路由信息将所述多路数据 包发送出去的所述步骤包括:
获取多路数据包的载荷以及头部信息; 以及
利用各路数据包的载荷及其头部信息生成多路数据包, 并按照各路数据 包的路由信息将所述多路数据包发送出去。
4、根据权利要求 1或 2或 3所述的方法, 其中在将所述多路数据包发送 出去之后, 所述方法还包括:
关闭所述网络套接字, 并释放所述路由緩存数组。
5、根据权利要求 4所述的方法,其中在将所述多路数据包发送出去之后, 关闭所述网络套接字之前, 所述方法还包括:
输出发送成功的数据包的个数, 和 /或发送失败的数据包的索引值及错误 码。
6、 一种发送多路数据包的系统, 包括:
创建套接字单元, 其设置成创建网络套接字, 所述网络套接字中包含用 于緩存多路数据包的路由信息的路由緩存数组; 以及
发送处理单元, 其设置成获取所述多路数据包的路由信息并添加到所述 路由緩存数组中; 当需要发送所述多路数据包时, 从所述路由緩存数组中获 取所述多路数据包的路由信息, 并根据该路由信息将所述多路数据包发送出 去。
7、 根据权利要求 6所述的系统, 其中所述发送处理单元包括:
添加路由信息单元, 其设置成获取所述多路数据包的路由信息并添加到 所述路由緩存数组中, 所述路由緩存数组中緩存的每一路数据包的路由信息 与该路数据包的索引值相对应; 以及
发送单元, 其设置成当需要发送所述多路数据包时, 根据所述多路数据 包中的每一路数据包的索引值, 从所述路由緩存数组中获取该索 ^ I值对应的 该路数据包的路由信息, 并根据该路由信息将该路数据包发送出去。
8、 根据权利要求 7所述的系统, 其中所述发送单元包括:
路由信息获取单元, 其设置成当需要发送所述多路数据包时, 根据所述 多路数据包中的每一路数据包的索引值, 从所述路由緩存数组中获取该索弓 ) 值对应的该路数据包的路由信息;
载荷获取单元, 其设置成获取所述多路数据包的载荷;
头部信息获取单元, 其设置成获取所述多路数据包的头部信息; 以及 封装处理单元, 其设置成利用各路数据包的载荷及其头部信息生成多路 数据包, 并按照各路数据包的路由信息将所述多路数据包发送出去。
9、 根据权利要求 7或 8所述的系统, 其中所述发送处理单元还包括: 结果反馈单元, 其设置成输出发送成功的数据包的个数, 和 /或发送失败 的数据包的索引值及错误码。
10、 根据权利要求 6所述的系统, 还包括:
关闭套接字单元, 其设置成关闭所述网络套接字, 并释放所述路由緩存 数组。
PCT/CN2009/073606 2008-12-17 2009-08-28 一种发送多路数据包的方法及系统 WO2010069179A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US13/140,101 US20110292936A1 (en) 2008-12-17 2009-08-28 Method and System for Transmitting Multichannel Data Packets

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CNA2008101861040A CN101447925A (zh) 2008-12-17 2008-12-17 一种发送多路数据包的方法及系统
CN200810186104.0 2008-12-17

Publications (1)

Publication Number Publication Date
WO2010069179A1 true WO2010069179A1 (zh) 2010-06-24

Family

ID=40743337

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2009/073606 WO2010069179A1 (zh) 2008-12-17 2009-08-28 一种发送多路数据包的方法及系统

Country Status (3)

Country Link
US (1) US20110292936A1 (zh)
CN (1) CN101447925A (zh)
WO (1) WO2010069179A1 (zh)

Families Citing this family (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101447925A (zh) * 2008-12-17 2009-06-03 中兴通讯股份有限公司 一种发送多路数据包的方法及系统
CN101692740B (zh) * 2009-09-30 2012-09-05 西安电子科技大学 无线网络多路路由网络传输方法
US8661156B2 (en) * 2010-11-22 2014-02-25 International Business Machines Corporation Transport layer connection
US9137270B2 (en) * 2012-12-03 2015-09-15 International Business Machines Corporation Binding multiple addresses to a socket in a network system
CN103179028B (zh) * 2013-01-10 2018-01-02 上海斐讯数据通信技术有限公司 基于内核进行rtp数据收发的网关设备及其实现方法
CN104717189A (zh) * 2013-12-16 2015-06-17 中兴通讯股份有限公司 网络数据包的发送方法及装置
US9485177B2 (en) * 2014-05-30 2016-11-01 Apple Inc. Client applications communicating via a user tunnel
US9798377B2 (en) 2014-10-08 2017-10-24 Apple Inc. Methods and apparatus for recovering errors with an inter-processor communication link between independently operable processors
US10356754B2 (en) 2015-05-10 2019-07-16 Lg Electronics Inc. Method for supporting sporadic high-capacity packet service and apparatus therefor
KR101835315B1 (ko) * 2016-03-07 2018-03-08 주식회사 윈스 Ips 스위치 장치 및 처리 방법
US11210406B2 (en) * 2016-07-15 2021-12-28 Seagate Technology Llc Encrypting system level data structures
CN106803809B (zh) * 2016-12-29 2021-04-27 杭州迪普科技股份有限公司 一种报文转发的方法和装置
CN107204926B (zh) * 2017-05-16 2021-06-11 上海博达数据通信有限公司 预处理cache的路由快速查找方法
US11792307B2 (en) 2018-03-28 2023-10-17 Apple Inc. Methods and apparatus for single entity buffer pool management
CN108712308B (zh) * 2018-06-06 2021-11-26 郑州云海信息技术有限公司 虚拟网络中检测网络设备的方法和装置
US10846224B2 (en) 2018-08-24 2020-11-24 Apple Inc. Methods and apparatus for control of a jointly shared memory-mapped region
CN114201311A (zh) 2019-03-15 2022-03-18 华为技术有限公司 数据处理方法及装置
US11829303B2 (en) 2019-09-26 2023-11-28 Apple Inc. Methods and apparatus for device driver operation in non-kernel space
US11558348B2 (en) 2019-09-26 2023-01-17 Apple Inc. Methods and apparatus for emerging use case support in user space networking
US11606302B2 (en) 2020-06-12 2023-03-14 Apple Inc. Methods and apparatus for flow-based batching and processing
US11775359B2 (en) 2020-09-11 2023-10-03 Apple Inc. Methods and apparatuses for cross-layer processing
US11954540B2 (en) 2020-09-14 2024-04-09 Apple Inc. Methods and apparatus for thread-level execution in non-kernel space
US11799986B2 (en) 2020-09-22 2023-10-24 Apple Inc. Methods and apparatus for thread level execution in non-kernel space
CN113259339B (zh) * 2021-05-08 2022-09-30 珠海六点智能科技有限公司 一种基于udp的数据传输方法、系统及电子设备
US11882051B2 (en) 2021-07-26 2024-01-23 Apple Inc. Systems and methods for managing transmission control protocol (TCP) acknowledgements
US11876719B2 (en) 2021-07-26 2024-01-16 Apple Inc. Systems and methods for managing transmission control protocol (TCP) acknowledgements

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1431805A (zh) * 2002-01-10 2003-07-23 株式会社Ntt都科摩 数据包交换系统、方法,路由设备,数据包结构和产生方法
CN1540932A (zh) * 2003-04-22 2004-10-27 华为技术有限公司 一种实现从指定端口发送数据报类型报文的方法
CN1770735A (zh) * 2004-11-02 2006-05-10 三星电子株式会社 使用多播发送和接收数据的方法和系统
CN101217464A (zh) * 2007-12-28 2008-07-09 北京大学 一种udp数据包的传输方法
CN101447925A (zh) * 2008-12-17 2009-06-03 中兴通讯股份有限公司 一种发送多路数据包的方法及系统

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6295549B1 (en) * 1996-05-08 2001-09-25 Apple Computer, Inc. Method and apparatus for listening for incoming calls on multiple port/socket combinations
US6188689B1 (en) * 1996-10-04 2001-02-13 Kabushiki Kaisha Toshiba Network node and method of frame transfer
JP3490286B2 (ja) * 1998-03-13 2004-01-26 株式会社東芝 ルータ装置及びフレーム転送方法
US20090216641A1 (en) * 2000-03-30 2009-08-27 Niration Network Group, L.L.C. Methods and Systems for Indexing Content
FI20001630A (fi) * 2000-06-30 2001-12-31 Nokia Mobile Phones Ltd Palvelun laadun määritys datavirroille
KR100735383B1 (ko) * 2001-02-09 2007-07-04 삼성전자주식회사 무선 시스템에서 데이터 서비스 장치 및 방법
US8553572B2 (en) * 2003-09-10 2013-10-08 Hyperdata Technologies, Inc. Internet protocol optimizer
CN1305276C (zh) * 2004-01-15 2007-03-14 中兴通讯股份有限公司 一种快速处理实时媒体流数据包的方法及其系统
JP4550728B2 (ja) * 2005-12-14 2010-09-22 アラクサラネットワークス株式会社 パケット転送装置及びマルチキャスト展開方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1431805A (zh) * 2002-01-10 2003-07-23 株式会社Ntt都科摩 数据包交换系统、方法,路由设备,数据包结构和产生方法
CN1540932A (zh) * 2003-04-22 2004-10-27 华为技术有限公司 一种实现从指定端口发送数据报类型报文的方法
CN1770735A (zh) * 2004-11-02 2006-05-10 三星电子株式会社 使用多播发送和接收数据的方法和系统
CN101217464A (zh) * 2007-12-28 2008-07-09 北京大学 一种udp数据包的传输方法
CN101447925A (zh) * 2008-12-17 2009-06-03 中兴通讯股份有限公司 一种发送多路数据包的方法及系统

Also Published As

Publication number Publication date
CN101447925A (zh) 2009-06-03
US20110292936A1 (en) 2011-12-01

Similar Documents

Publication Publication Date Title
WO2010069179A1 (zh) 一种发送多路数据包的方法及系统
CN101217493B (zh) 一种tcp数据包的传输方法
US10057387B2 (en) Communication traffic processing architectures and methods
CN101217464B (zh) 一种udp数据包的传输方法
US9923826B2 (en) Systems and methods for dynamic adaptation of network accelerators
US9065866B2 (en) Systems and methods for policy based integration to horizontally deployed WAN optimization appliances
US10110493B2 (en) Systems and methods of emulating a NIC for packet transmission on hardware RSS unaware NICS in a multi-core system
US6731652B2 (en) Dynamic packet processor architecture
TWI339055B (en) Apparatus and methods for a high performance hardware network protocol processing engine
US20070208820A1 (en) Apparatus and method for out-of-order placement and in-order completion reporting of remote direct memory access operations
CN110768994B (zh) 一种基于dpdk技术的提高sip网关性能的方法
US20080256271A1 (en) Methods and apparatus for reducing storage usage in devices
US8126015B2 (en) Multi-stream communication processing
JP2009093348A (ja) 情報処理装置、及び情報処理システム
WO2022148363A1 (zh) 数据传输方法及数据传输服务器
WO2017028399A1 (zh) 通信数据传输方法及系统
CA2543246C (en) Using ordered locking mechanisms to maintain sequences of items such as packets
CN112953967A (zh) 网络协议卸载装置和数据传输系统
US20060176893A1 (en) Method of dynamic queue management for stable packet forwarding and network processor element therefor
WO2012083654A1 (zh) Ip报文分片的处理方法和分布式系统
CN109743350B (zh) 一种科学计算应用影像区交换通信模式的卸载实现方法
CN114143382A (zh) 一种双边加速数据传输方法及系统
Zeng et al. Middlenet: A high-performance, lightweight, unified nfv and middlebox framework
CN111901689A (zh) 流媒体数据的传输方法、装置、终端设备和存储介质
WO2014183525A1 (zh) 报文的处理方法和级联芯片

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: 09832861

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: 13140101

Country of ref document: US

122 Ep: pct application non-entry in european phase

Ref document number: 09832861

Country of ref document: EP

Kind code of ref document: A1