技术领域technical field
本发明涉及通信技术领域,特别涉及一种报文处理方法和装置。The present invention relates to the field of communication technology, in particular to a message processing method and device.
背景技术Background technique
随着社会信息化程度的加深,人们对互联网的依赖性越来越强,连接到网络上的计算机节点也成倍的增长。交换机、网络处理器等网络设备作为计算机和互联网的数据交换节点,其数据处理性能决定了整个网络的性能。随着用户连接数的急剧增长和在线视频等高带宽应用的出现,设置在网络设备中负责处理报文的单核处理器越来越难以满足高速数据处理的性能需求,而多核处理器凭借其并行计算能力强的特性,逐渐在网络通信领域得到广泛应用。所谓多核处理器,是指在一个交换机、网络处理器等网络设备上集成的具有多个处理器核心的处理器,多核处理器中的每个处理器核心一次只能处理一个报文。多核处理器通过相互间独立工作的多个处理器核心,可以并行执行报文的处理操作,满足互联网中高速数据处理的性能需求。With the deepening of social informatization, people rely more and more on the Internet, and the number of computer nodes connected to the network has also increased exponentially. Network devices such as switches and network processors are used as data exchange nodes between computers and the Internet, and their data processing performance determines the performance of the entire network. With the rapid increase in the number of user connections and the emergence of high-bandwidth applications such as online video, it is increasingly difficult for single-core processors set in network devices to process packets to meet the performance requirements of high-speed data processing. Due to its strong parallel computing capability, it has gradually been widely used in the field of network communication. The so-called multi-core processor refers to a processor with multiple processor cores integrated on a network device such as a switch or a network processor, and each processor core in the multi-core processor can only process one packet at a time. A multi-core processor can execute message processing operations in parallel through multiple processor cores that work independently of each other to meet the performance requirements of high-speed data processing in the Internet.
目前存在的通过具有多核处理器的网络设备进行报文处理的实现方案中:网络设备可以根据报文转发的源地址和目的地址的不同,在对报文处理之前就将接收到的报文分为不同的报文流,其中,将记载的源地址和目的地址相同的多个报文按照网络设备接收的顺序放入同一条报文流中。在对报文处理完毕进行转发时,按照网络设备接收报文的顺序对同一条报文流中的报文进行转发。In the currently existing implementation schemes for packet processing by network devices with multi-core processors: the network device can divide the received packets according to the difference between the source address and the destination address of packet forwarding before processing the packets. are different packet streams, wherein multiple packets with the same recorded source address and destination address are put into the same packet stream according to the sequence received by the network device. When the packets are processed and forwarded, the packets in the same packet flow are forwarded according to the order in which the network devices receive the packets.
在实现本发明的过程中,发明人发现现有技术至少存在以下问题:In the process of realizing the present invention, the inventor finds that there are at least the following problems in the prior art:
网络设备在按照接收报文的顺序对报文进行转发的过程中,只能按照对报文处理之前形成的报文流中记录的报文顺序对同一条报文流中的报文进行转发操作。所以对报文的转发方式比较固定,不能根据业务场景的不同对某些业务类型的报文的输出进行优先考虑。In the process of forwarding packets according to the order in which the packets are received, the network device can only forward the packets in the same packet flow according to the sequence of packets recorded in the packet flow formed before the packet processing . Therefore, the packet forwarding method is relatively fixed, and the output of packets of certain service types cannot be prioritized according to different service scenarios.
发明内容Contents of the invention
为了解决现有技术的问题,本发明实施例提供了一种报文处理方法和装置。所述技术方案如下:In order to solve the problems in the prior art, the embodiments of the present invention provide a message processing method and device. Described technical scheme is as follows:
第一方面,本发明实施例提供了一种报文处理方法,所述方法包括:In a first aspect, an embodiment of the present invention provides a message processing method, the method comprising:
分配接收到的报文,根据报文的接收顺序,将接收到的报文注册到队列列表的默认队列中,其中,所述队列列表还包括多个按照不同的业务类型进行分类的业务队列,各所述业务队列具有队列标识;Allocating the received messages, registering the received messages in the default queue of the queue list according to the order in which the messages are received, wherein the queue list also includes a plurality of service queues classified according to different service types, Each of the service queues has a queue identifier;
在对分配到的报文进行处理的过程中,根据报文携带的所述业务类型,将与报文携带的所述业务类型对应的所述业务队列的队列标识记录在与报文标识对应的报文描述符中,其中,所述报文标识是在将报文注册到默认队列的过程中对报文分配的;In the process of processing the allocated message, according to the service type carried by the message, the queue identifier of the service queue corresponding to the service type carried by the message is recorded in the corresponding message identifier In the message descriptor, wherein, the message identifier is assigned to the message during the process of registering the message to the default queue;
在报文处理完成后,根据所述报文的报文描述符中记录的队列标识,将所述报文的报文标识从默认队列移动到与记录的所述队列标识对应的业务队列中;After the message processing is completed, according to the queue identifier recorded in the message descriptor of the message, the message identifier of the message is moved from the default queue to the service queue corresponding to the recorded queue identifier;
根据预定的报文输出策略,按照各所述业务队列中记录的报文标识的顺序输出报文。According to a predetermined message output policy, the messages are output according to the order of the message identifiers recorded in the service queues.
在第一方面的第一种可能的实现方式中,所述在报文处理完成后,根据所述报文的报文描述符中记录的队列标识,将所述报文的报文标识从默认队列中移动到与记录的所述队列标识对应的业务队列中步骤包括:In the first possible implementation of the first aspect, after the message processing is completed, according to the queue identifier recorded in the message descriptor of the message, the message identifier of the message is changed from the default The step of moving in the queue to the business queue corresponding to the recorded queue ID includes:
判断处理完成的所述报文的报文标识是否为所述默认队列中的第一个报文标识;Judging whether the message identifier of the processed message is the first message identifier in the default queue;
若确定处理完成的所述报文的报文标识是所述默认队列中的第一个报文标识,则根据所述报文的报文描述符中记录的队列标识,将所述默认队列中的所述第一个报文标识从默认队列中移动到与记录的所述队列标识对应的业务队列中。If it is determined that the message identifier of the message that has been processed is the first message identifier in the default queue, then according to the queue identifier recorded in the message descriptor of the message, the The first message ID of the message is moved from the default queue to the service queue corresponding to the recorded queue ID.
在第一方面的第二种可能的实现方式中,在所述在报文处理完成后,根据所述报文的报文描述符中记录的队列标识,将所述报文的报文标识从默认队列移动到与记录的所述队列标识对应的业务队列中步骤之后,所述方法还包括:In a second possible implementation of the first aspect, after the processing of the message is completed, the message identifier of the message is changed from the queue identifier recorded in the message descriptor of the message to After the step of moving the default queue to the service queue corresponding to the recorded queue identifier, the method further includes:
对处理完成的报文进行缓存。Cache the processed packets.
结合第一方面以及第一方面的第二种可能的实现方式中,在第一方面的第三种可能的实现方式中,在所述对处理完成的报文进行缓存的步骤中:In combination with the first aspect and the second possible implementation of the first aspect, in the third possible implementation of the first aspect, in the step of caching the processed message:
当有至少两个处理器核心同时处理完报文时,根据同时完成报文处理的所述至少两个处理器核心编号的顺序,通过轮询的方式将同时处理完成的所述报文进行缓存。When at least two processor cores have processed the message at the same time, according to the order of the numbers of the at least two processor cores that have completed the message processing at the same time, the message that has been processed at the same time is cached by polling .
在第一方面的第四种可能的实现方式中,所述根据预定的报文输出策略,按照各所述业务队列中记录的报文标识的顺序输出报文步骤包括:In a fourth possible implementation of the first aspect, the step of outputting messages according to the sequence of message identifiers recorded in each of the service queues according to a predetermined message output strategy includes:
当获取到输出报文的指令时,确定具有优先级的多个所述业务队列;When the instruction to output the message is obtained, determine a plurality of the service queues with priority;
从优先级最高的业务队列开始,按照所述业务队列中记录的报文标识的顺序,输出所述缓存模块中缓存的所述报文。Starting from the service queue with the highest priority, output the messages cached in the cache module according to the sequence of message identifiers recorded in the service queue.
结合第一方面以及第一方面的第四种可能的实现方式中,在第一方面的第五种可能的实现方式中,当有业务队列未设置优先级时,所述方法还包括:In combination with the first aspect and the fourth possible implementation of the first aspect, in the fifth possible implementation of the first aspect, when there is a service queue with no priority set, the method further includes:
按照未设置优先级的业务队列的队列标识的顺序,轮询输出各未设置优先级的所述业务队列中的第一个报文标识对应的报文。According to the order of the queue IDs of the service queues with no priority set, polling and outputting the message corresponding to the first message ID in each of the service queues with no priority set.
第二方面,本发明实施例提供了一种报文处理装置,所述装置包括:In a second aspect, an embodiment of the present invention provides a message processing device, the device comprising:
分配模块,用于分配接收到的报文,根据报文的接收顺序,将接收到的报文注册到队列列表的默认队列中,其中,所述队列列表还包括多个按照不同的业务类型进行分类的业务队列,各所述业务队列具有队列标识;The distribution module is used to distribute the received messages, register the received messages in the default queue of the queue list according to the receiving order of the messages, wherein the queue list also includes multiple Classified service queues, each of which has a queue identifier;
处理模块,用于根据报文携带的所述业务类型,将与报文携带的所述业务类型对应的所述业务队列的队列标识记录在与报文标识对应的报文描述符中,其中,所述报文标识是在将报文注册到默认队列的过程中对报文分配的;A processing module, configured to record the queue identifier of the service queue corresponding to the service type carried in the message in the message descriptor corresponding to the message identifier according to the service type carried in the message, wherein, The message identifier is assigned to the message during the process of registering the message to the default queue;
调序模块,用于根据所述报文的报文描述符中记录的队列标识,将所述报文的报文标识从默认队列移动到与记录的所述队列标识对应的业务队列中;An ordering module, configured to move the message identifier of the message from the default queue to the service queue corresponding to the recorded queue identifier according to the queue identifier recorded in the message descriptor of the message;
输出模块,用于从优先级最高的业务队列开始,按照各所述业务队列中记录的报文标识的顺序输出报文。The output module is configured to start from the service queue with the highest priority and output the messages according to the order of the message identifiers recorded in the service queues.
在第二方面的第一种可能的实现方式中,所述调序模块用于:In a first possible implementation manner of the second aspect, the sequencing module is used for:
判断处理完成的所述报文的报文标识是否为所述默认队列中的第一个报文标识;Judging whether the message identifier of the processed message is the first message identifier in the default queue;
若确定处理完成的所述报文的报文标识是所述默认队列中的第一个报文标识,则根据所述报文的报文描述符中记录的队列标识,将所述默认队列中的所述第一个报文标识从默认队列中移动到与记录的所述队列标识对应的业务队列中。If it is determined that the message identifier of the message that has been processed is the first message identifier in the default queue, then according to the queue identifier recorded in the message descriptor of the message, the The first message ID of the message is moved from the default queue to the service queue corresponding to the recorded queue ID.
在第二方面的第二种可能的实现方式中,所述装置还包括:In a second possible implementation manner of the second aspect, the device further includes:
缓存模块,用于对处理完成的报文进行缓存。The caching module is used for caching the processed packets.
结合第二方面以及第二方面的第二种可能的实现方式中,在第二方面的第三种可能的实现方式中,在所述缓存模块中:In combination with the second aspect and the second possible implementation of the second aspect, in the third possible implementation of the second aspect, in the caching module:
当有至少两个处理器核心同时处理完报文时,根据同时完成报文处理的所述至少两个处理器核心编号的顺序,通过轮询的方式将同时处理完成的所述报文进行缓存。When at least two processor cores have processed the message at the same time, according to the order of the numbers of the at least two processor cores that have completed the message processing at the same time, the message that has been processed at the same time is cached by polling .
在第二方面的第四种可能的实现方式中,当有业务队列未设置优先级时,所述输出模块还用于:In a fourth possible implementation of the second aspect, when there is a service queue with no priority set, the output module is further used for:
按照未设置优先级的业务队列的队列标识的顺序,轮询输出各未设置优先级的所述业务队列中的第一个报文标识对应的报文。According to the order of the queue IDs of the service queues with no priority set, polling and outputting the message corresponding to the first message ID in each of the service queues with no priority set.
本发明实施例提供的技术方案带来的有益效果是:The beneficial effects brought by the technical solution provided by the embodiments of the present invention are:
本发明实施例提供的报文处理方法和装置,通过在对分配到的报文进行处理的过程中,根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,从而在对报文处理完成后,将报文标识分配到具有不同优先权的业务队列中,报文的输出顺序由设定的业务队列的优先级确定,从优先级最高的业务队列开始,按照优先级由高到低的顺序输出各业务队列中记录的报文标识对应的报文;由于是在对报文的处理过程中根据报文的业务类型确定报文所在的业务队列,并对业务队列设置了输出报文的优先权,所以可以根据应用场景的不同,灵活的配置报文的输出顺序,而且,根据业务队列的优先级,可在确定携带某种业务类型的报文优先输出的情况下,就可以直接进行这种业务类型的报文进行输出操作,而避免了现有的需要等待在这种业务类型的报文的第一个报文之前输入的报文在被输出之后才能输出的缺陷。In the message processing method and device provided by the embodiments of the present invention, in the process of processing the allocated message, according to the service type carried by the message, the queue identifier of the service queue corresponding to the service type carried by the message Recorded in the message descriptor corresponding to the message ID, so that after the message processing is completed, the message ID is assigned to the service queue with different priorities, and the output order of the message is determined by the set service queue. Priority determination, starting from the service queue with the highest priority, output the messages corresponding to the message identifiers recorded in each service queue in order of priority from high to low; The service type determines the service queue where the message is located, and sets the priority of the output message for the service queue, so the output order of the message can be flexibly configured according to different application scenarios, and, according to the priority of the service queue, When it is determined that the message carrying a certain service type is output first, the message of this service type can be directly output, and the existing need to wait for the first message of this service type is avoided. A defect in which a message that was input before a message cannot be output until after it has been output.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained based on these drawings without creative effort.
图1是本发明实施例提供的报文处理方法所涉及的一种实施环境的结构示意图;FIG. 1 is a schematic structural diagram of an implementation environment involved in a message processing method provided by an embodiment of the present invention;
图2是本发明实施例一提供的报文处理方法流程图;FIG. 2 is a flowchart of a message processing method provided by Embodiment 1 of the present invention;
图3是本发明实施例二提供的报文处理方法流程图;FIG. 3 is a flowchart of a message processing method provided in Embodiment 2 of the present invention;
图4是本发明实施例二提供的报文处理方法中对业务队列设置优先权的示意图一;FIG. 4 is a first schematic diagram of setting priorities for service queues in the message processing method provided by Embodiment 2 of the present invention;
图5是本发明实施例二提供的报文处理方法中对业务队列设置优先权的示意图二;FIG. 5 is a second schematic diagram of setting priorities for service queues in the message processing method provided by Embodiment 2 of the present invention;
图6是本发明实施例二提供的报文处理方法中对业务队列设置优先权的示意图三;FIG. 6 is a third schematic diagram of setting priorities for service queues in the message processing method provided by Embodiment 2 of the present invention;
图7是本发明实施例三提供的报文处理装置的结构示意图;FIG. 7 is a schematic structural diagram of a message processing device provided in Embodiment 3 of the present invention;
图8是本发明实施例四提供的报文处理装置的结构示意图。FIG. 8 is a schematic structural diagram of a message processing device provided in Embodiment 4 of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments It is a part of embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
除非另作定义,此处使用的技术术语或者科学术语应当为本发明所属领域内具有一般技能的人士所理解的通常意义。本发明专利申请说明书以及权利要求书中使用的“第一”、“第二”以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。同样,“一个”或者“一”等类似词语也不表示数量限制,而是表示存在至少一个。Unless otherwise defined, the technical terms or scientific terms used herein shall have the usual meanings understood by those skilled in the art to which the present invention belongs. "First", "second" and similar words used in the patent application specification and claims of the present invention do not indicate any order, quantity or importance, but are only used to distinguish different components. Likewise, words like "a" or "one" do not denote a limitation in quantity, but indicate that there is at least one.
参见图1,其示出了本发明实施例提供的报文转发方法所涉及的一种具有报文转发和处理功能的装置。该环境包括:多核心处理器100、分发模块101、仲裁模块102、排序模块103和缓存模块104。Referring to FIG. 1 , it shows a device with functions of message forwarding and processing involved in the message forwarding method provided by the embodiment of the present invention. The environment includes: a multi-core processor 100 , a distribution module 101 , an arbitration module 102 , a sorting module 103 and a cache module 104 .
其中,多核处理器100,包括多个具有相同功能的处理器核心1、处理器核心2…处理器核心n;这些处理器核心用于对解析和转发接收到的报文;其中,处理器核心具有空闲和忙两个状态,当处理器核心在对报文进行处理时,则处理器核心处于忙的状态;当处理器核心未处理报文时,则处理器核心处于空闲的状态。分发模块101根据多核处理器100中各个处理器核心的状态,将接收到的报文分配到空闲状态的各处理器核心中,并向排序模块发送注册接收报文的指令。仲裁模块102,用于当有多个处理器核心同时发出命令给排序模块103时,根据处理器核心的标识顺序,通过轮询的方式逐一将这多条命令发送到排序模块103进行处理;通常情况下,只获取到一条多核处理器向排序模块发出的命令时,直接将获取到的命令传输到排序模块。排序模块103,对注册的报文分配报文标识,并存储有记录报文输入顺序和输出顺序的队列列表,其中,队列列表包括一个默认队列和多个业务队列,默认队列通过记录报文的报文标识来记录报文的输入顺序,多个业务队列中分别记录具有相同业务类型的报文的标识来对报文的输出顺序进行记录;在需要输出报文时,向缓存模块104发送报文输出指令,控制缓存模块104根据队列列表中多个业务队列中记录的报文顺序进行报文的输出。缓存模块104,对多核处理器各处理器核心处理完成的报文进行缓存,并在接收到排序模块103发出的报文输出指令时输出报文。Wherein, the multi-core processor 100 includes a plurality of processor cores 1, processor cores 2 ... processor core n with the same function; these processor cores are used for parsing and forwarding received messages; wherein, the processor cores It has two states of idle and busy. When the processor core is processing the message, the processor core is in the busy state; when the processor core is not processing the message, the processor core is in the idle state. The distribution module 101 distributes the received message to each processor core in the idle state according to the state of each processor core in the multi-core processor 100, and sends an instruction to register the received message to the sorting module. The arbitration module 102 is used to send these multiple commands to the sorting module 103 one by one by polling for processing according to the identification order of the processor cores when multiple processor cores send commands to the sorting module 103 at the same time; usually In this case, when only one command sent by the multi-core processor to the sorting module is obtained, the obtained command is directly transmitted to the sorting module. The sorting module 103 assigns a message identifier to the registered message, and stores a queue list recording the input sequence and output sequence of the message, wherein the queue list includes a default queue and a plurality of service queues, and the default queue passes through the record message. The message identifier is used to record the input sequence of the message, and the identifiers of the messages with the same service type are respectively recorded in multiple service queues to record the output sequence of the message; output instruction, and control the cache module 104 to output the messages according to the order of the messages recorded in the multiple service queues in the queue list. The caching module 104 caches the messages processed by each processor core of the multi-core processor, and outputs the messages when receiving the message output instruction sent by the sorting module 103 .
其中,包括多核心处理器100、分发模块101、仲裁模块102、排序模块103和缓存模块104且具有报文转发和处理功能的装置一般是交换机或者是网络处理器。Among them, the device including the multi-core processor 100, the distribution module 101, the arbitration module 102, the sorting module 103 and the cache module 104 and having the functions of packet forwarding and processing is generally a switch or a network processor.
实施例一Embodiment one
本发明实施例提供了一种报文处理方法,参见图2,方法流程包括:The embodiment of the present invention provides a message processing method, referring to Figure 2, the method flow includes:
步骤200、交换机的分发模块分配接收到的报文,排序模块根据报文的接收顺序,将接收到的报文注册到队列列表的默认队列中,其中,队列列表还包括多个按照不同的业务类型进行分类的业务队列,各业务队列具有队列标识。Step 200, the distribution module of the switch distributes the received messages, and the sorting module registers the received messages in the default queue of the queue list according to the order in which the messages are received, wherein the queue list also includes multiple Business queues classified by type, and each business queue has a queue ID.
其中,交换机接收的报文,可以是网络中需要处理并转发的任意报文。Wherein, the message received by the switch may be any message that needs to be processed and forwarded in the network.
其中,交换机的分发模块根据多核处理器中各处理器核心的状态,将报文分配到空闲状态的各处理器核心中进行处理。Wherein, the distribution module of the switch distributes the message to each processor core in an idle state for processing according to the state of each processor core in the multi-core processor.
步骤201、在对分配到的报文进行处理的过程中,交换机的多核处理器中各处理器核心根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,其中,报文标识是在将报文注册到默认队列的过程中对报文分配的。Step 201, in the process of processing the allocated message, each processor core in the multi-core processor of the switch records the queue identifier of the service queue corresponding to the service type carried by the message according to the service type carried by the message In the message descriptor corresponding to the message identifier, the message identifier is allocated to the message during the process of registering the message in the default queue.
步骤202、在报文处理完成后,交换机的排序模块根据报文的报文描述符中记录的队列标识,将报文的报文标识从默认队列移动到与记录的队列标识对应的业务队列中。Step 202, after the message processing is completed, the sorting module of the switch moves the message ID of the message from the default queue to the service queue corresponding to the recorded queue ID according to the queue ID recorded in the message descriptor of the message .
步骤203、从优先级最高的业务队列开始,交换机的缓存模块按照排序模块中各业务队列中记录的报文标识的顺序,输出缓存的报文。Step 203, starting from the service queue with the highest priority, the cache module of the switch outputs the cached messages according to the order of the message identifiers recorded in the service queues in the sorting module.
通过以上描述,通过在对分配到的报文进行处理的过程中,根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,从而在对报文处理完成后,将报文标识分配到具有不同优先权的业务队列中,报文的输出顺序由设定的业务队列的优先级确定,从优先级最高的业务队列开始,按照优先级由高到低的顺序输出各业务队列中记录的报文标识对应的报文;由于是在对报文的处理过程中根据报文的业务类型确定报文所在的业务队列,并对业务队列设置了输出报文的优先权,所以可以根据应用场景的不同,灵活的配置报文的输出顺序。Through the above description, in the process of processing the allocated message, according to the service type carried by the message, the queue identifier of the service queue corresponding to the service type carried by the message is recorded in the message corresponding to the message identifier In the text descriptor, after the message processing is completed, the message identifiers are assigned to service queues with different priorities. The output order of the messages is determined by the priority of the set service queues, starting from the highest priority From the beginning of the service queue, output the messages corresponding to the message identifiers recorded in each service queue in order of priority from high to low; since the service type of the message is determined according to the service type of the message during the processing of the message Queues, and set the priority of output packets for business queues, so the output sequence of packets can be flexibly configured according to different application scenarios.
实施例二Embodiment two
本发明实施例提供了一种报文处理方法,参见图3,方法流程包括:The embodiment of the present invention provides a message processing method, referring to Fig. 3, the method flow includes:
步骤300、交换机的分发模块分配接收到的报文,排序模块根据报文的接收顺序,将接收到的报文注册到队列列表的默认队列中,其中,队列列表还包括多个按照不同的业务类型进行分类的业务队列,各业务队列具有队列标识。Step 300, the distribution module of the switch distributes the received messages, and the sorting module registers the received messages in the default queue of the queue list according to the order in which the messages are received, wherein the queue list also includes multiple Business queues classified by type, and each business queue has a queue ID.
具体地,步骤300的流程由步骤3001-步骤3003具体描述。Specifically, the process of step 300 is specifically described by steps 3001-3003.
步骤3001、交换机的分发模块接收报文。Step 3001, the distribution module of the switch receives the message.
其中,交换机所接收的报文,是等待交换机处理并转发的报文。其中,分发模块是译码器。Wherein, the message received by the switch is a message waiting to be processed and forwarded by the switch. Among them, the distribution module is a decoder.
可选地,分发模块采用的设备不仅可以是译码器,也可以是其他现有的任意可以实现分发模块功能的硬件,这里不再一一赘述。Optionally, the device used by the distribution module may not only be a decoder, but also any other existing hardware capable of realizing the function of the distribution module, which will not be repeated here.
步骤3002、交换机的分发模块对接收到的报文分配处理器核心。Step 3002, the distribution module of the switch allocates processor cores to the received message.
具体地,交换机的分发模块根据当前各处理器核心的状态来将接收到的报文进行分配,其中,处理器核心具有空闲和忙两个状态,当处理器核心在对报文进行处理时,则处理器核心处于忙的状态;当处理器核心未处理报文时,则处理器核心处于空闲的状态。分发模块记录有各处理器核心的状态,在分配报文的过程中根据多核处理器中各个处理器核心的状态,将接收到的报文分配到空闲状态的各处理器核心中。然后分发模块向排序模块发送报文的注册指令,其中,报文的注册指令中包含处理该报文的处理器核心的处理器编号。Specifically, the distribution module of the switch distributes the received messages according to the states of the current processor cores, wherein the processor cores have two states of idle and busy, and when the processor cores are processing the messages, Then the processor core is in a busy state; when the processor core is not processing a packet, the processor core is in an idle state. The distribution module records the state of each processor core, and distributes the received message to each processor core in an idle state according to the state of each processor core in the multi-core processor during the distribution of the message. Then the distribution module sends a registration instruction of the message to the sorting module, wherein the registration instruction of the message includes the processor number of the processor core that processes the message.
其中,各处理器核心一次只能处理一个报文,分发模块只对各处理器核心能够处理数量的报文进行分配。Wherein, each processor core can only process one message at a time, and the distribution module only distributes the number of messages that each processor core can process.
步骤3003、根据报文的接收顺序,交换机的排序模块将接收到的报文注册到队列列表的默认队列中。Step 3003, according to the order in which the packets are received, the sorting module of the switch registers the received packets in the default queue of the queue list.
具体地,排序模块中缓存的队列列表包括一个记录报文接收顺序的默认队列;排序模块根据分发模块发送的报文的注册指令,对报文分配报文标识,然后根据注册指令中携带的处理该报文的处理器核心的处理器编号,建立处理器编号与分配给该报文的报文标识的第一对应关系,然后将报文标识放入默认队列中,完成报文的注册。Specifically, the queue list cached in the sorting module includes a default queue that records the order in which messages are received; the sorting module assigns message identifiers to the messages according to the registration instructions of the messages sent by the distribution module, and then processes the messages according to the processing instructions carried in the registration instructions. The processor number of the processor core of the message, the first corresponding relationship between the processor number and the message identifier assigned to the message is established, and then the message identifier is put into the default queue to complete the registration of the message.
其中,报文标识是一组数字串,用于使交换机的排序模块可以唯一识别报文。在不同的交换机中,报文被分配的报文标识是不同的。Wherein, the message identifier is a group of digital strings, which are used to enable the sorting module of the switch to uniquely identify the message. In different switches, packets are assigned different packet identifiers.
步骤301、在对分配到的报文进行处理的过程中,交换机的多核处理器中各处理器核心根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,其中,报文标识是在将报文注册到默认队列的过程中对报文分配的。Step 301, in the process of processing the allocated message, each processor core in the multi-core processor of the switch records the queue identifier of the service queue corresponding to the service type carried by the message according to the service type carried by the message In the message descriptor corresponding to the message identifier, the message identifier is allocated to the message during the process of registering the message in the default queue.
具体地,多核处理器的各处理器核心在处理报文的过程中,先对报文进行解析,得到报文携带的业务类型,根据报文携带的业务类型对预先存储的第二对应关系进行遍历,从而查找到第二对应关系中记录的与报文携带的业务类型具有相同业务类型的业务队列的队列标识,生成处理器编号和队列标识的对应关系,然后将生成的处理器编号和队列标识的对应关系发送到排序模块,排序模块根据得到的处理器编号和队列标识的对应关系,通过处理器编号找到对应的报文标识,然后将处理器编号和队列标识的对应关系中携带的队列标识记录在与报文标识对应的报文描述符中。Specifically, in the process of processing the message, each processor core of the multi-core processor first parses the message to obtain the service type carried in the message, and performs a pre-stored second corresponding relationship according to the service type carried in the message. Traversing, so as to find the queue identifier of the service queue with the same service type as the service type carried in the message recorded in the second correspondence, generate the corresponding relationship between the processor number and the queue identifier, and then combine the generated processor number and queue The corresponding relationship of the identification is sent to the sorting module, and the sorting module finds the corresponding message identification through the processor number according to the corresponding relationship between the obtained processor number and the queue identification, and then the queue carried in the corresponding relationship between the processor number and the queue identification The ID is recorded in the message descriptor corresponding to the message ID.
其中,多核处理器中预先存储有业务队列的业务类型和队列标识的第二对应关系。Wherein, the second corresponding relationship between the service type of the service queue and the queue identifier is pre-stored in the multi-core processor.
其中,对报文的业务类型的划分可以按照任何网络七层协议中的任何一层的通信协议进行划分。如果交换机是根据网络层的协议对报文进行划分,那么进入该交换机的报文携带的业务类型都是网络层的协议;如果交换机是根据传输层的协议对报文进行划分,那么进入该交换机的报文携带的业务类型都是传输层的协议。比如,可以根据网络层的网络之间互连的协议(英文:Internet Protocol,缩写:IP)和互联网数据包交换协议(英文:Internetwork Packet Exchange protocol,缩写:IPX)对报文进行业务类型的划分。Wherein, the division of the service type of the message may be performed according to any layer of the communication protocol in any seven-layer protocol of the network. If the switch divides the packets according to the protocol of the network layer, then the service types carried by the packets entering the switch are network layer protocols; if the switch divides the packets according to the protocol of the transport layer, then The service types carried in the packets are all transport layer protocols. For example, packets can be divided into service types according to the protocol for interconnecting networks at the network layer (English: Internet Protocol, abbreviated: IP) and the Internet packet exchange protocol (English: Internetwork Packet Exchange protocol, abbreviated: IPX). .
其中,队列列表除了包括默认队列外,还包括多个按照不同的业务类型进行分类的业务队列;各业务队列分别具有队列标识。Wherein, the queue list includes not only the default queue, but also multiple service queues classified according to different service types; each service queue has a queue identifier.
其中,报文描述符与报文标识是一一对应的关系,预先存储在排序模块中,用于记录报文被交换机转发的过程中所使用的报文信息。当交换机接收到的报文被注册并被分配了报文标识后,就会在被分配的报文标识对应的报文描述符中记录被交换机转发的过程中所使用的报文信息。Wherein, there is a one-to-one correspondence relationship between the message descriptor and the message identifier, which are pre-stored in the sorting module and are used to record the message information used in the process of the message being forwarded by the switch. After the message received by the switch is registered and assigned a message ID, it will record the message information used in the process of being forwarded by the switch in the message descriptor corresponding to the allocated message ID.
其中,报文描述符中记录的队列标识用于记录报文被移动到的业务队列的队列标识;队列标识在初始状态下为默认值;在确定了报文应该被移动到某个业务队列中时,就将该报文的报文描述符中记录的队列标识从默认值修改为相应的业务队列的队列标识编号。Among them, the queue identifier recorded in the message descriptor is used to record the queue identifier of the service queue to which the message is moved; the queue identifier is the default value in the initial state; when it is determined that the message should be moved to a certain service queue , modify the queue ID recorded in the message descriptor of the message from the default value to the queue ID number of the corresponding service queue.
其中,若各处理器核心在处理报文的过程中,未找到与报文的业务类型相对应的业务队列,那么就修改该报文的报文描述符中记录的队列标识为保留队列的队列标识。Wherein, if each processor core does not find a service queue corresponding to the service type of the message in the process of processing the message, then modify the queue identified in the message descriptor of the message as the queue of the reserved queue logo.
其中,保留队列是多个业务队列中队列标识编号最大的业务队列。Wherein, the reserved queue is the service queue with the largest queue identification number among the multiple service queues.
其中,多核处理器中的各处理器核心根据预设在各处理器核心中的软件对报文进行处理。Wherein, each processor core in the multi-core processor processes the message according to software preset in each processor core.
其中,各处理器核心对报文的处理所实现的功能由预设的软件决定,如对报文的解析和对报文转发端口的确定等;当然,各处理器核心可以对报文还可以有其他的处理方式,这里不再一一赘述。Among them, the functions realized by each processor core to process the message are determined by the preset software, such as analyzing the message and determining the forwarding port of the message; of course, each processor core can also process the message There are other processing methods, which will not be repeated here.
其中,多核处理器包含的处理器核心的数量可以是2个、4个或者8个。多核处理器包含的处理器核心数量越多,说明该多核处理器对报文的并行处理能力越强。Wherein, the number of processor cores included in the multi-core processor may be 2, 4 or 8. The more processor cores the multi-core processor contains, the stronger the parallel processing capability of the multi-core processor is.
可选地,多核处理器中对报文处理的设备不仅可以是处理器核心,也可以是其他现有的任意可以设置在多核处理器中的硬件加速引擎,这里不再一一赘述。Optionally, the device for processing packets in the multi-core processor may not only be a processor core, but also any other existing hardware acceleration engine that can be set in the multi-core processor, which will not be repeated here.
步骤302、在报文处理完成后,交换机的排序模块根据报文的报文描述符中记录的队列标识,将报文的报文标识从默认队列移动到与记录的队列标识对应的业务队列中。Step 302, after the message processing is completed, the sorting module of the switch moves the message ID of the message from the default queue to the service queue corresponding to the recorded queue ID according to the queue ID recorded in the message descriptor of the message .
具体地,步骤302的流程由步骤3021-步骤3023具体描述。Specifically, the process of step 302 is specifically described by steps 3021-3023.
步骤3021、交换机的排序模块判断处理完成的报文的报文标识是否为默认队列中的第一个报文标识。Step 3021, the sorting module of the switch judges whether the message ID of the processed message is the first message ID in the default queue.
若交换机确定处理完成的报文的报文标识为默认队列中的第一个报文标识,那么进行步骤3022。If the switch determines that the packet identifier of the processed packet is the first packet identifier in the default queue, then proceed to step 3022 .
若交换机确定处理完成的报文的报标识不是默认队列中的第一个报文标识,那么进行步骤3023。If the switch determines that the packet identifier of the processed packet is not the first packet identifier in the default queue, then proceed to step 3023 .
其中,报文描述符还包括完成标识,完成标识用于表示报文是否被多核处理器处理完,在报文未被多核处理器处理时完成标识为0,在报文已被多核处理器处理完成时完成标识为1。Among them, the message descriptor also includes a completion flag, which is used to indicate whether the message has been processed by the multi-core processor. The completion flag is 1 when completed.
具体地,在处理完成某个报文后,交换机的多核处理器会发出携带有处理器编号的报文处理完成命令给排序模块,排序模块根据报文处理完成命令中携带的处理器编号,找出该处理器编号对应的报文标识,然后将该找出的报文标识对应的报文描述符中的完成标识设置为1;然后排序模块会判断默认队列的第一个报文标识对应的报文描述符记录的完成标识是否为1,来对处理完成的报文的报文标识是否为默认队列中的第一个报文标识进行判断。Specifically, after processing a certain message, the multi-core processor of the switch will issue a message processing completion command carrying a processor number to the sorting module, and the sorting module will find Find the message ID corresponding to the processor number, and then set the completion ID in the message descriptor corresponding to the found message ID to 1; then the sorting module will judge the first message ID corresponding to the default queue Whether the completion identifier of the message descriptor record is 1 is used to judge whether the message identifier of the processed message is the first message identifier in the default queue.
步骤3022、若确定处理完成的报文的报文标识为默认队列中的第一个报文标识,则交换机的排序模块根据报文的报文描述符中记录的队列标识,将默认队列中的第一个报文标识从默认队列中移动到与队列标识对应的业务队列中。Step 3022, if it is determined that the message ID of the message that has been processed is the first message ID in the default queue, then the sorting module of the switch will sort the message in the default queue according to the queue ID recorded in the message descriptor of the message. The first message ID is moved from the default queue to the service queue corresponding to the queue ID.
具体地,当排序模块确定默认队列的第一个报文的报文描述符记录的完成标识是为1时,那么排序模块根据报文的报文描述符中记录的队列标识,将默认队列中的第一个报文标识从默认队列中取出,然后放入与报文描述符中记录的队列标识所对应的业务队列中。Specifically, when the sorting module determines that the completion flag of the message descriptor record of the first message in the default queue is 1, then the sorting module will, according to the queue flag recorded in the message descriptor of the message, put The first message ID of the message is taken from the default queue and put into the service queue corresponding to the queue ID recorded in the message descriptor.
步骤3023、若确定处理完成的报文的报文标识与默认队列中的第一个报文标识不一致,则交换机的排序模块暂时不会根据队列标识将该处理完成的报文的报文标识移动到相应的业务队列中。Step 3023, if it is determined that the message ID of the processed message is inconsistent with the first message ID in the default queue, the sorting module of the switch will temporarily not move the message ID of the processed message according to the queue ID to the corresponding service queue.
具体地,若排序模块确定默认队列的第一个报文标识对应的报文描述符记录的完成标识为0时,则交换机的排序模块暂时不会根据队列标识将该处理完成的报文的报文标识移动到相应的业务队列中;而排序模块会周期性判断默认队列的第一个报文描述符记录的完成标识是否为1,只有在确定默认队列的第一个报文标识对应的报文标识符中记录的完成标识为1时,说明此时默认队列中的第一个报文已经处理完成,才会将该报文的报文标识移动到与队列标识对应的业务队列中。Specifically, if the sorting module determines that the completion flag of the packet descriptor record corresponding to the first packet identifier of the default queue is 0, the sorting module of the switch will not temporarily process the completed packet according to the queue identifier. The document identifier is moved to the corresponding service queue; and the sorting module will periodically judge whether the completion identifier of the first message descriptor record of the default queue is 1, and only when the completion identifier of the first message identifier of the default queue is determined When the completion flag recorded in the message identifier is 1, it means that the first message in the default queue has been processed at this time, and the message identifier of the message will be moved to the service queue corresponding to the queue identifier.
其中,排序模块是逻辑电路。Wherein, the sorting module is a logic circuit.
通过步骤3021至步骤3023的描述,可以进一步降低报文拥塞的可能性。通过只将默认队列中的第一个报文描述符移动到对应的业务队列中,保证了业务队列中报文的顺序与报文输入的顺序一致,可以避免报文输出时出现乱序的情况。Through the description of steps 3021 to 3023, the possibility of packet congestion can be further reduced. By only moving the first packet descriptor in the default queue to the corresponding service queue, it is ensured that the order of the packets in the service queue is consistent with the sequence of the packet input, which can avoid disorderly output of packets .
步骤303、交换机的多核处理器的各处理器核心将处理完的报文通过仲裁模块发送到预先设置的缓存模块进行缓存。Step 303 , each processor core of the multi-core processor of the switch sends the processed message to a preset buffer module through the arbitration module for buffering.
其中,报文描述符还包括缓存地址,缓存地址用于记录已被多核处理器处理完成的报文缓存到交换机的缓存模块中的物理地址。Wherein, the message descriptor also includes a cache address, and the cache address is used to record the physical address where the message processed by the multi-core processor is cached in the cache module of the switch.
具体地,在各处理器核心处理完报文后,多核处理器的各处理器核心会向将处理完成的报文通过仲裁模块发送到缓存模块,并向缓存模块发送带有处理完成该待缓存报文的处理器核心的处理器编号的缓存指令;交换机的缓存模块先将接收的报文进行缓存,然后根据缓存指令携带的处理器编号,生成处理该已缓存报文的处理器核心的处理器编号和缓存地址的第三对应关系,然后将生成的第三对应关系发送到排序模块,排序模块根据接收到的第三对应关系中的处理器编号,通过遍历的方式找到默认队列中与第一对应关系中与该处理器编号对应的报文标识,在通过报文标识找到对应的报文标识符,然后将第三对应关系中的缓存地址记录到队列描述符中,然后排序模块根据第三对应关系中记录的处理器编号,通知分发模块将该处理器编号对应的处理器核心的状态由忙修改为空闲,并释放掉该处理器编号与已缓存的报文的报文标识的第一对应关系。Specifically, after each processor core has processed the message, each processor core of the multi-core processor will send the processed message to the cache module through the arbitration module, and send the cached message with the processing completion to the cache module. The cache command of the processor number of the processor core of the message; the cache module of the switch first caches the received message, and then generates the processing of the processor core that processes the cached message according to the processor number carried by the cache command. The third corresponding relationship between the processor number and the cache address, and then send the generated third corresponding relationship to the sorting module. A message identifier corresponding to the processor number in the first correspondence, find the corresponding message identifier through the message identifier, then record the cache address in the third correspondence into the queue descriptor, and then the sorting module according to the first For the processor number recorded in the three-correspondence relationship, notify the distribution module to modify the state of the processor core corresponding to the processor number from busy to idle, and release the first link between the processor number and the message identifier of the cached message. One-to-one correspondence.
其中,缓存模块是缓存器。Wherein, the cache module is a cache.
其中,各处理器核心与报文标识的释放时间不同,各处理器核心在处理完成所分配的报文后就会释放,从而处理下一个被分配的报文;而报文标识只有在报文输出后才能被释放,从而在注册接收到的报文时分配给下一个报文。Among them, the release time of each processor core and message ID is different, and each processor core will release after processing the allocated message, so as to process the next allocated message; It can only be released after output, so that it can be assigned to the next message when registering the received message.
现有的多核处理器中的处理器核心在处理报文时,可能出现多个处理器核心同时处理完报文的情况,缓存模块若要同时接收并缓存这些处理完的报文,那么就需要一个较大的带宽才能对多个同时处理完成的报文进行缓存,若缓存模块设计的带宽达不到对多个同时处理完成的报文进行缓存的需求时,则不能对这些处理完成的报文进行缓存,如果想要缓存模块同时对多个报文进行缓存,那在进行缓存模块的设计中,就应该为缓存模块设计一个较大的带宽,但这会在交换机的电路设计的过程中增大交换机的设计成本。When the processor cores in the existing multi-core processor process messages, multiple processor cores may finish processing the messages at the same time. If the cache module wants to receive and cache these processed messages at the same time, it needs Only a large bandwidth can cache multiple simultaneously processed messages. If the bandwidth designed by the cache module cannot meet the requirements for caching multiple simultaneously processed messages, these processed messages cannot be cached. If you want the cache module to cache multiple messages at the same time, you should design a larger bandwidth for the cache module in the design of the cache module, but this will be difficult in the process of circuit design of the switch. Increase the design cost of the switch.
因此,在步骤303中,当有至少两个处理器核心同时处理完报文时,交换机的仲裁模块根据同时完成报文处理的至少两个处理器核心编号的顺序,通过轮询的方式将同时处理完成的报文缓存到预先设置的缓存模块中。Therefore, in step 303, when at least two processor cores have processed the message at the same time, the arbitration module of the switch will simultaneously The processed message is cached in the preset cache module.
具体地,仲裁模块中设置有多个接收报文的端口,这些接收报文的端口与各处理器核心一一对应,比如:处理器核心1对应端口a、处理器核心2对应端口b等。当有处理器核心处理完成报文后,该处理器核心就会向对应的仲裁模块的端口发送报文,这样仲裁模块就会通过接收报文的端口知道是哪个处理器核心处理完了报文,所以当有至少两个处理器核心同时处理完报文时,仲裁模块先对接收到的报文进行缓存,然后根据同时接收到报文的端口号就可以知道完成处理报文的处理器核心的编号,从而根据处理器编号的顺序,通过轮询的方式将同时处理完成的多个报文依次缓存到预先设置的缓存模块中。Specifically, the arbitration module is provided with a plurality of ports for receiving messages, and these ports for receiving messages are in one-to-one correspondence with each processor core, for example: processor core 1 corresponds to port a, processor core 2 corresponds to port b, and so on. When a processor core finishes processing the message, the processor core will send the message to the port of the corresponding arbitration module, so that the arbitration module will know which processor core has processed the message through the port receiving the message, Therefore, when at least two processor cores finish processing the message at the same time, the arbitration module first caches the received message, and then can know the number of the processor core that has completed processing the message according to the port number of the message received at the same time. number, so that according to the order of the processor numbers, multiple messages that are processed simultaneously are sequentially cached in the preset cache module by polling.
其中,仲裁模块是多路选择器。Wherein, the arbitration module is a multiplexer.
可选地,仲裁模块采用的设备不仅可以是多路选择器,也可以是其他现有的任意可以实现仲裁模块功能的硬件,这里不再一一赘述。Optionally, the device used by the arbitration module may not only be a multiplexer, but may also be any other existing hardware that can realize the function of the arbitration module, which will not be repeated here.
通过步骤303的描述,在缓存多个处理完成的报文时,根据至少两个处理器核心标识的顺序,依次将接收到的多个报文进行缓存,因此缓存模块每次只需缓存一个报文即可,而不会出现一次缓存多个报文的情况,使得在设计交换机的缓存模块的带宽时,设计的带宽只需满足一个报文能够通过并进入缓存模块即可,从而节省了交换机的设计成本。Through the description of step 303, when caching multiple processed messages, the multiple received messages are sequentially cached according to the order of at least two processor core identifications, so the cache module only needs to cache one message each time. Only one message can pass through and enter the cache module, thus saving the switch design cost.
步骤304、从优先级最高的业务队列开始,交换机的缓存模块按照排序模块中各业务队列中记录的报文标识的顺序输出报文。Step 304, starting from the service queue with the highest priority, the cache module of the switch outputs the messages in the order of the message identifiers recorded in the service queues in the sorting module.
具体地,步骤304的流程由步骤3041-步骤3043具体描述。Specifically, the process of step 304 is specifically described by steps 3041-3043.
步骤3041、当获取到输出报文的指令时,交换机的排序模块确定具有优先级的多个业务队列。Step 3041, when the instruction to output the message is obtained, the sorting module of the switch determines multiple service queues with priority.
其中,在不同的应用场景中,交换机都会根据用户使用服务的情况,优先输出提供用户当前使用服务的报文,而报文可以提供哪些服务是通过携带的业务类型来区分的。而交换机的排序模块已经在报文输出之前,根据报文携带的业务类型将报文分配到了不同的业务队列中,所以交换机的排序模块可以根据不同的应用场景下用户使用的服务的不同,预先对多个业务队列中提供用户当前服务的业务队列设置高优先级。如图4至图6所示,为本实施例中对业务队列设置优先权的示意图。Among them, in different application scenarios, the switch will give priority to outputting the message that provides the service currently used by the user according to the user's use of the service, and the services that the message can provide are distinguished by the type of service carried. The sorting module of the switch has already allocated the messages to different service queues according to the service types carried in the messages before the messages are output, so the sorting module of the switch can Set a high priority for the business queue that provides the user's current service among multiple business queues. As shown in FIG. 4 to FIG. 6 , they are schematic diagrams of setting priorities for service queues in this embodiment.
进一步地,交换机还可以对其他任何业务队列设置输出优先级,在某些情况下,更可以对所有的业务队列设置优先级,这里不再一一赘述。Furthermore, the switch can also set the output priority for any other service queues, and in some cases, it can even set the priority for all service queues, which will not be repeated here.
比如:用户在进行网络游戏的同时通过下载软件下载视频文件,那么交换机的排序模块就会根据用户当前使用的服务,确定多个业务队列中提供网络游戏数据报文的业务队列的优先级为最高优先级、确定提供下载视频的数据报文的业务队列的优先级为第二高优先级,其他业务队列不设置优先级。For example, if a user downloads a video file by downloading software while playing an online game, then the sorting module of the switch will determine the priority of the service queue that provides online game data packets among multiple service queues according to the service currently used by the user. Priority, to determine the priority of the service queue that provides data packets for downloading video is the second highest priority, and other service queues do not set priority.
步骤3042、从优先级最高的业务队列开始,交换机的缓存模块按照排序模块的业务队列中记录的报文标识的顺序,输出缓存的报文。Step 3042, starting from the service queue with the highest priority, the cache module of the switch outputs the cached messages according to the order of the message identifiers recorded in the service queue of the sorting module.
具体地,交换机的排序模块根据已确定的优先级最高的业务队列中报文标识的顺序从各报文标识对应的报文描述符中获取报文的缓存地址,然后按照获取缓存地址的顺序将获取到的缓存地址发送到缓存模块,缓存模块从得到的缓存地址中读取报文,并将读取的报文输出;然后排序模块根据优先级第二高的业务队列中报文标识的顺序从各报文标识对应的报文描述符中获取报文的缓存地址,然后按照获取缓存地址的顺序将获取到的缓存地址发送到缓存模块,缓存模块从得到的缓存地址中读取报文,并将读取的报文输出;以此类推,直到输出所有具有优先级的业务队列中的报文。Specifically, the sorting module of the switch obtains the cache addresses of the packets from the packet descriptors corresponding to the packet identifiers according to the determined order of the packet identifiers in the service queue with the highest priority, and then according to the sequence of obtaining the cache addresses The obtained cache address is sent to the cache module, and the cache module reads the message from the obtained cache address, and outputs the read message; then the sorting module according to the order of the message identification in the business queue with the second highest priority Obtain the cache address of the message from the message descriptor corresponding to each message identifier, and then send the obtained cache address to the cache module in the order in which the cache address is obtained, and the cache module reads the message from the obtained cache address, And output the read message; and so on, until all the messages in the business queue with priority are output.
其中,交换机可以使用现有任意的方式进行报文的查找,这里不再一一赘述。Wherein, the switch can use any existing method to search for the message, which will not be repeated here.
步骤3043、当有业务队列未设置优先级时,交换机按照未设置优先级的业务队列的队列标识的顺序,轮询输出各未设置优先级的业务队列中的第一个报文标识对应的报文。Step 3043, when there is a service queue with no priority set, the switch polls and outputs the message corresponding to the first message ID in each service queue with no priority set according to the order of the queue IDs of the service queues with no priority set. arts.
具体地,交换机的缓存模块按照未设置优先级的业务队列的队列标识的顺序轮询获取各未设置优先级的业务队列的第一个报文的报文描述符,在获取到各业务队列的第一个报文的报文描述符后,缓存模块根据报文描述符中记录的报文的缓存地址找到相应的报文,在轮流输出未设置优先级的业务队列的第一个报文。Specifically, the cache module of the switch polls to obtain the message descriptor of the first message of each service queue without priority set according to the order of the queue identifiers of the service queues without priority setting. After the message descriptor of the first message, the cache module finds the corresponding message according to the buffer address of the message recorded in the message descriptor, and outputs the first message of the service queue without priority in turn.
业务队列的第一个报文是指排在业务队列中最前面位置的报文标识对应的报文。The first message in the service queue refers to the message corresponding to the message identifier at the front position in the service queue.
通过步骤3041至步骤3043的描述,在不同的业务场景下,处理的数据的类型是不同的,可以针对数据需求类型不同的业务场景,对多个业务队列设置不同的优先级,满足不同的业务场景下优先处理数据报文不同的需求。Through the description of steps 3041 to 3043, in different business scenarios, the types of data to be processed are different. According to business scenarios with different types of data requirements, different priorities can be set for multiple business queues to meet different business needs Different requirements of data packets are prioritized in the scenario.
本实施例提供的报文处理方法,通过在对分配到的报文进行处理的过程中,根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,从而在对报文处理完成后,将报文标识分配到具有不同优先权的业务队列中,报文的输出顺序由设定的业务队列的优先级确定,从优先级最高的业务队列开始,按照优先级由高到低的顺序输出各业务队列中记录的报文标识对应的报文;由于是在对报文的处理过程中根据报文的业务类型确定报文所在的业务队列,并对业务队列设置了输出报文的优先权,所以可以根据应用场景的不同,灵活的配置报文的输出顺序,而且,根据业务队列的优先级,可在确定携带某种业务类型的报文优先输出的情况下,就可以直接进行这种业务类型的报文进行输出操作,而避免了现有的需要等待在这种业务类型的报文的第一个报文之前输入的报文在被输出之后才能输出的缺陷。In the message processing method provided in this embodiment, during the process of processing the allocated message, according to the service type carried by the message, the queue identifier of the service queue corresponding to the service type carried by the message is recorded in the In the message descriptor corresponding to the message ID, after the message processing is completed, the message ID is assigned to the service queue with different priorities, and the output order of the message is determined by the priority of the set service queue , starting from the service queue with the highest priority, output the message corresponding to the message identifier recorded in each service queue in the order of priority from high to low; because it is based on the service type of the message during the processing of the message Determine the service queue where the message is located, and set the priority of the output message for the service queue, so you can flexibly configure the output order of the message according to different application scenarios, and, according to the priority of the service queue, you can determine the In the case that the message carrying a certain service type is output first, the message of this service type can be directly output, and the existing need to wait for the first message of this service type message is avoided. The defect that the message input before the message can only be output after being output.
实施例三Embodiment three
参见图7,本实施例提供了一种报文处理装置,该装置包括:Referring to FIG. 7, this embodiment provides a message processing device, which includes:
分配模块400,用于分配接收到的报文,根据报文的接收顺序,将接收到的报文注册到队列列表的默认队列中,其中,队列列表还包括多个按照不同的业务类型进行分类的业务队列,各业务队列具有队列标识;The distribution module 400 is configured to distribute the received messages, register the received messages in the default queue of the queue list according to the receiving order of the messages, wherein the queue list also includes multiple business queues, each business queue has a queue ID;
处理模块401,用于根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,其中,报文标识是在将报文注册到默认队列的过程中对报文分配的;The processing module 401 is configured to record the queue identifier of the service queue corresponding to the service type carried by the message in the message descriptor corresponding to the message identifier according to the service type carried by the message, wherein the message identifier is in The message is allocated during the process of registering the message to the default queue;
调序模块402,用于根据报文的报文描述符中记录的队列标识,将报文的报文标识从默认队列移动到与记录的队列标识对应的业务队列中;The ordering module 402 is used to move the message identifier of the message from the default queue to the service queue corresponding to the recorded queue identifier according to the queue identifier recorded in the message descriptor of the message;
输出模块403,用于从优先级最高的业务队列开始,按照各业务队列中记录的报文标识的顺序,输出报文。The output module 403 is configured to output messages starting from the service queue with the highest priority and according to the sequence of message identifiers recorded in each service queue.
本实施例提供的报文处理装置,通过在对分配到的报文进行处理的过程中,根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,从而在对报文处理完成后,将报文标识分配到具有不同优先权的业务队列中,报文的输出顺序由设定的业务队列的优先级确定,从优先级最高的业务队列开始,按照优先级由高到低的顺序输出各业务队列中记录的报文标识对应的报文;由于是在对报文的处理过程中根据报文的业务类型确定报文所在的业务队列,并对业务队列设置了输出报文的优先权,所以可以根据应用场景的不同,灵活的配置报文的输出顺序,而且,根据业务队列的优先级,可在确定携带某种业务类型的报文优先输出的情况下,就可以直接进行这种业务类型的报文进行输出操作,而避免了现有的需要等待在这种业务类型的报文的第一个报文之前输入的报文在被输出之后才能输出的缺陷。The message processing device provided in this embodiment records the queue identifier of the service queue corresponding to the service type carried by the message in the In the message descriptor corresponding to the message ID, after the message processing is completed, the message ID is assigned to the service queue with different priorities, and the output order of the message is determined by the priority of the set service queue , starting from the service queue with the highest priority, output the message corresponding to the message identifier recorded in each service queue in the order of priority from high to low; because it is based on the service type of the message during the processing of the message Determine the service queue where the message is located, and set the priority of the output message for the service queue, so you can flexibly configure the output order of the message according to different application scenarios, and, according to the priority of the service queue, you can determine the In the case that the message carrying a certain service type is output first, the message of this service type can be directly output, and the existing need to wait for the first message of this service type message is avoided. The defect that the message input before the message can only be output after being output.
实施例四Embodiment four
参见图8,本实施例提供了一种报文处理装置,该装置包括:Referring to FIG. 8, this embodiment provides a message processing device, which includes:
分配模块500,用于分配接收到的报文,根据报文的接收顺序,将接收到的报文注册到队列列表的默认队列中,其中,队列列表还包括多个按照不同的业务类型进行分类的业务队列,各业务队列具有队列标识;The distribution module 500 is used to distribute the received messages, and register the received messages in the default queue of the queue list according to the receiving order of the messages, wherein the queue list also includes multiple queues classified according to different service types business queues, each business queue has a queue ID;
处理模块501,用于根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,其中,报文标识是在将报文注册到默认队列的过程中对报文分配的;The processing module 501 is configured to record the queue identifier of the service queue corresponding to the service type carried by the message in the message descriptor corresponding to the message identifier according to the service type carried by the message, wherein the message identifier is in The message is allocated during the process of registering the message to the default queue;
调序模块502,用于根据报文的报文描述符中记录的队列标识,将报文的报文标识从默认队列移动到与记录的队列标识对应的业务队列中;The sequencing module 502 is configured to move the message identifier of the message from the default queue to the service queue corresponding to the recorded queue identifier according to the queue identifier recorded in the message descriptor of the message;
缓存模块503,用于对处理完成的报文进行缓存。The caching module 503 is configured to cache the processed packets.
输出模块504,用于从优先级最高的业务队列开始,按照各业务队列中记录的报文标识的顺序,输出缓存模块503中缓存的报文。The output module 504 is configured to output the messages cached in the cache module 503 starting from the service queue with the highest priority and according to the order of the message identifiers recorded in each service queue.
具体地,调序模块502用于:Specifically, the sequencing module 502 is used for:
判断处理完成的报文的报文标识是否为默认队列中的第一个报文标识;Determine whether the message ID of the processed message is the first message ID in the default queue;
若确定处理完成的报文的报文标识是默认队列中的第一个报文标识,则根据报文的报文描述符中记录的队列标识,将默认队列中的第一个报文标识从默认队列中移动到与记录的队列标识对应的业务队列中。If it is determined that the message ID of the processed message is the first message ID in the default queue, then according to the queue ID recorded in the message descriptor of the message, the first message ID in the default queue is changed from The default queue is moved to the business queue corresponding to the recorded queue ID.
具体地,在缓存模块503中:Specifically, in the caching module 503:
当有至少两个处理器核心同时处理完报文时,根据同时完成报文处理的至少两个处理器核心编号的顺序,通过轮询的方式将同时处理完成的报文进行缓存。When at least two processor cores finish processing the message at the same time, according to the sequence of numbers of the at least two processor cores that simultaneously complete the message processing, the simultaneously processed messages are cached in a polling manner.
具体地,输出模块504用于:Specifically, the output module 504 is used for:
当获取到输出报文的指令时,确定具有优先级的多个业务队列;When the instruction to output the message is obtained, determine multiple service queues with priority;
从优先级最高的业务队列开始,按照业务队列中记录的报文标识的顺序,输出缓存模块中缓存的报文。Starting from the service queue with the highest priority, output the messages cached in the cache module according to the order of the message identifiers recorded in the service queue.
当有业务队列未设置优先级时,输出模块504还用于:When there is a service queue with no priority set, the output module 504 is also used for:
按照未设置优先级的业务队列的队列标识的顺序,轮询输出各未设置优先级的业务队列中的第一个报文标识对应的报文。According to the order of the queue identifiers of the service queues without priority, poll and output the message corresponding to the first message identifier in each service queue without priority.
本实施例提供的报文处理装置,通过在对分配到的报文进行处理的过程中,根据报文携带的业务类型,将与报文携带的业务类型对应的业务队列的队列标识记录在与报文标识对应的报文描述符中,从而在对报文处理完成后,将报文标识分配到具有不同优先权的业务队列中,报文的输出顺序由设定的业务队列的优先级确定,从优先级最高的业务队列开始,按照优先级由高到低的顺序输出各业务队列中记录的报文标识对应的报文;由于是在对报文的处理过程中根据报文的业务类型确定报文所在的业务队列,并对业务队列设置了输出报文的优先权,所以可以根据应用场景的不同,灵活的配置报文的输出顺序,而且,根据业务队列的优先级,可在确定携带某种业务类型的报文优先输出的情况下,就可以直接进行这种业务类型的报文进行输出操作,而避免了现有的需要等待在这种业务类型的报文的第一个报文之前输入的报文在被输出之后才能输出的缺陷。The message processing device provided in this embodiment records the queue identifier of the service queue corresponding to the service type carried by the message in the In the message descriptor corresponding to the message ID, after the message processing is completed, the message ID is assigned to the service queue with different priorities, and the output order of the message is determined by the priority of the set service queue , starting from the service queue with the highest priority, output the message corresponding to the message identifier recorded in each service queue in the order of priority from high to low; because it is based on the service type of the message during the processing of the message Determine the service queue where the message is located, and set the priority of the output message for the service queue, so you can flexibly configure the output order of the message according to different application scenarios, and, according to the priority of the service queue, you can determine the In the case that the message carrying a certain service type is output first, the message of this service type can be directly output, and the existing need to wait for the first message of this service type message is avoided. The defect that the message input before the message can only be output after being output.
需要说明的是:上述实施例提供的报文处理装置在处理报文时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的报文处理装置与报文处理方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that when the message processing device provided in the above-mentioned embodiment processes a message, it only uses the division of the above-mentioned functional modules as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional modules according to needs , that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the packet processing device provided in the above embodiment and the packet processing method embodiment belong to the same idea, and the specific implementation process thereof is detailed in the method embodiment, and will not be repeated here.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present invention are for description only, and do not represent the advantages and disadvantages of the embodiments.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, and can also be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium. The above-mentioned The storage medium mentioned may be a read-only memory, a magnetic disk or an optical disk, and the like.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than limiting them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the various embodiments of the present invention. scope.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410667090.XACN104468401B (en) | 2014-11-20 | 2014-11-20 | A kind of message processing method and device |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201410667090.XACN104468401B (en) | 2014-11-20 | 2014-11-20 | A kind of message processing method and device |
| Publication Number | Publication Date |
|---|---|
| CN104468401A CN104468401A (en) | 2015-03-25 |
| CN104468401Btrue CN104468401B (en) | 2017-11-17 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201410667090.XAActiveCN104468401B (en) | 2014-11-20 | 2014-11-20 | A kind of message processing method and device |
| Country | Link |
|---|---|
| CN (1) | CN104468401B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107426025A (en)* | 2017-07-28 | 2017-12-01 | 江西山水光电科技股份有限公司 | A kind of dispatching method for strengthening webmaster north orientation message response degree |
| CN107682265B (en)* | 2017-09-07 | 2021-04-20 | 银清科技有限公司 | Message routing method and device for payment system |
| CN107656896B (en)* | 2017-09-12 | 2020-07-07 | 新华三信息安全技术有限公司 | Multi-core processor and message processing method |
| CN108768882A (en)* | 2018-04-23 | 2018-11-06 | 烽火通信科技股份有限公司 | A kind of processing method and system of protocol massages |
| CN109062781B (en)* | 2018-06-22 | 2022-04-26 | 北京星网锐捷网络技术有限公司 | Message buffer management method and device |
| CN109150755B (en)* | 2018-09-25 | 2022-03-04 | 西安空间无线电技术研究所 | A space-based data link onboard message scheduling method and device |
| CN109246023A (en)* | 2018-11-16 | 2019-01-18 | 锐捷网络股份有限公司 | Flow control methods, the network equipment and storage medium |
| CN109962760B (en)* | 2019-04-09 | 2022-08-30 | 湖南智领通信科技有限公司 | Service scheduling method suitable for wireless TDMA ad hoc network |
| CN110636071B (en)* | 2019-09-26 | 2020-07-07 | 光大兴陇信托有限责任公司 | Interface docking method |
| CN110830386B (en)* | 2019-11-14 | 2023-06-30 | 武汉船舶通信研究所(中国船舶重工集团公司第七二二研究所) | Method, device and system for message order preservation |
| CN111163018B (en)* | 2019-12-02 | 2022-08-26 | 华为技术有限公司 | Network equipment and method for reducing transmission delay thereof |
| CN113543234B (en)* | 2020-04-13 | 2025-08-12 | 中兴通讯股份有限公司 | Port resource reservation method, electronic equipment and storage medium |
| CN111698175B (en)* | 2020-06-24 | 2023-09-19 | 北京经纬恒润科技股份有限公司 | Message receiving and transmitting method and system for gateway |
| CN112099975B (en)* | 2020-09-25 | 2024-03-26 | Oppo广东移动通信有限公司 | Message processing method and system and storage medium |
| CN116320087A (en)* | 2023-03-07 | 2023-06-23 | 篆芯半导体(南京)有限公司 | Message processing method, message processing device, electronic equipment and storage medium |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1414761A (en)* | 2002-02-27 | 2003-04-30 | 华为技术有限公司 | Multi-priority buffer reliable transmission method in communication system |
| CN101631077A (en)* | 2009-08-24 | 2010-01-20 | 中兴通讯股份有限公司 | Message processing method and device |
| CN102638403A (en)* | 2012-04-01 | 2012-08-15 | 华为技术有限公司 | Method and device for processing messages |
| WO2014039505A1 (en)* | 2012-09-06 | 2014-03-13 | Unisys Corporation | Fast data packet transfer operations |
| CN104158764A (en)* | 2014-08-12 | 2014-11-19 | 杭州华三通信技术有限公司 | Message processing method and device |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8761174B2 (en)* | 2009-03-11 | 2014-06-24 | Sony Corporation | Quality of service traffic recognition and packet classification home mesh network |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1414761A (en)* | 2002-02-27 | 2003-04-30 | 华为技术有限公司 | Multi-priority buffer reliable transmission method in communication system |
| CN101631077A (en)* | 2009-08-24 | 2010-01-20 | 中兴通讯股份有限公司 | Message processing method and device |
| CN102638403A (en)* | 2012-04-01 | 2012-08-15 | 华为技术有限公司 | Method and device for processing messages |
| WO2014039505A1 (en)* | 2012-09-06 | 2014-03-13 | Unisys Corporation | Fast data packet transfer operations |
| CN104158764A (en)* | 2014-08-12 | 2014-11-19 | 杭州华三通信技术有限公司 | Message processing method and device |
| Title |
|---|
| 基于区分服务的拥塞控制算法研究;李寅;《中国优秀硕士学位论文全文数据库信息科技辑(2012)》;20120715(第7期);全文* |
| Publication number | Publication date |
|---|---|
| CN104468401A (en) | 2015-03-25 |
| Publication | Publication Date | Title |
|---|---|---|
| CN104468401B (en) | A kind of message processing method and device | |
| CN107846443B (en) | Distributed processing in a network | |
| US8830829B2 (en) | Parallel processing using multi-core processor | |
| US8811417B2 (en) | Cross-channel network operation offloading for collective operations | |
| CN105511954A (en) | Method and device for message processing | |
| US20120207158A1 (en) | Method and system for classification and management of inter-blade network traffic in a blade server | |
| CN110214436B (en) | Multi-core lock-free rate limiting device and method | |
| CN104753818A (en) | Queue scheduling method and device | |
| US9906443B1 (en) | Forwarding table updates during live packet stream processing | |
| KR102165864B1 (en) | Methods and apparatuses for packet scheduling for software defined networking in edge computing environment | |
| US20110255543A1 (en) | Method and system for processing data | |
| US20180014081A1 (en) | Multiple core software forwarding | |
| CN103329493B (en) | Method and apparatus for avoiding memory bandwidth utilization during packet processing | |
| CN103166845A (en) | Data processing method and device | |
| US12175285B1 (en) | Processing unit selection mechanism | |
| US9401879B1 (en) | Systems and methods for sending and receiving information via a network device | |
| US10616116B1 (en) | Network traffic load balancing using rotating hash | |
| CN105635000A (en) | A message storage and forwarding method, circuit and equipment | |
| US11899969B1 (en) | Re-order buffer for in-order execution of dependent write transactions | |
| US10506044B1 (en) | Statistics collecting architecture | |
| CN116938829A (en) | A data forwarding method and related equipment | |
| CN105337888B (en) | Load-balancing method, device and virtual switch based on multicore forwarding | |
| CN106464605B (en) | The method and relevant device of processing message applied to the network equipment | |
| US9154455B1 (en) | Method and system for determining drop eligibility of network information | |
| US8830854B2 (en) | System and method for managing parallel processing of network packets in a wireless access device |
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| TR01 | Transfer of patent right | ||
| TR01 | Transfer of patent right | Effective date of registration:20220118 Address after:450046 Floor 9, building 1, Zhengshang Boya Plaza, Longzihu wisdom Island, Zhengdong New Area, Zhengzhou City, Henan Province Patentee after:xFusion Digital Technologies Co., Ltd. Address before:518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen Patentee before:HUAWEI TECHNOLOGIES Co.,Ltd. |