WO2016202158A1 - Message transmission method and device, and computer-readable storage medium - Google Patents

Message transmission method and device, and computer-readable storage medium Download PDF

Info

Publication number
WO2016202158A1
WO2016202158A1 PCT/CN2016/083569 CN2016083569W WO2016202158A1 WO 2016202158 A1 WO2016202158 A1 WO 2016202158A1 CN 2016083569 W CN2016083569 W CN 2016083569W WO 2016202158 A1 WO2016202158 A1 WO 2016202158A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
address
linked list
chunk
slice
Prior art date
Application number
PCT/CN2016/083569
Other languages
French (fr)
Chinese (zh)
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 深圳市中兴微电子技术有限公司
Publication of WO2016202158A1 publication Critical patent/WO2016202158A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/33Flow control; Congestion control using forward notification

Definitions

  • the present invention relates to a packet forwarding device management technology, and in particular, to a message transmission method and apparatus, and a computer readable storage medium.
  • the network processor chip of the general router will have a dedicated traffic management system to complete the management of the high-speed data stream, and then the message buffer is processed and output.
  • the embodiment of the present invention mainly provides a message transmission method and device, and a computer readable storage medium, which can solve the problem of uniform dequeue in the case of adopting a single linked list structure.
  • an embodiment of the present invention provides a packet transmission method, where the method includes:
  • a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;
  • the obtaining, according to the address of the i-th chunk pointed by the linked list pointer, sequentially acquiring the slice from the i-th chunk includes:
  • the base address being an offset address of each chunk
  • each of the i-th chunks is sequentially used according to the base address, wherein an offset address of the j-th slice in the i-th chunk is equal to a base address plus the j and a specified value Product, the j is a positive integer.
  • the number of slices per block is the same in the same linked list.
  • the method further includes:
  • the number of slices in each chunk of the linked list and the number of slices occupied in the last chunk are saved.
  • the establishing, by the linked list, the linked list includes:
  • the linked list includes a chunk; and save the address of the first node of the first cache area allocated to the packet queue as Addressing the address of the first chunk of the linked list and the address of the last chunk; and sequentially storing the address of the packet slice stored in the packet queue with the slice of the linked list;
  • the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
  • the address of the packet slice stored in the message queue is sequentially corresponding to the slice without the corresponding information
  • the linked list includes only one chunk, a new last chunk is generated, and the address of the head node of the second free cache allocated to the message queue is saved as the address and location of the second chunk. Addressing the address of the new last chunk; the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list;
  • the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk;
  • the addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
  • the method further includes:
  • a second aspect of the present invention provides a message transmission apparatus, where the apparatus includes:
  • Obtaining a linked list unit configured to output a message in the message queue, obtain a linked list corresponding to the message queue established when the message is input into the message queue, and the linked list includes one or more chunks, each The chunk includes one or more slices, and the slice has a one-to-one correspondence with an address of a message slice in the message queue;
  • an address unit configured to sequentially acquire a slice from the i-th chunk according to an address of the i-th chunk pointed to by the linked list pointer, where i is a positive integer;
  • Obtaining a message unit configured to output the message slice from the message queue according to an address of a message slice corresponding to each slice, and point the linked list pointer to an address of the i+1th block.
  • the acquiring a slice unit is configured to:
  • the base address being an offset address of each chunk
  • the number of slices per block is the same in the same linked list.
  • the apparatus further includes:
  • a saving unit configured to save the number of slices in each chunk of the linked list and the number of slices occupied in the last chunk.
  • the establishing unit is configured to:
  • the linked list includes a chunk; and save an address of a first node of the first cache area allocated to the packet queue as the linked list
  • the address of the first chunk and the address of the last chunk; the address of the packet slice stored in the message queue is sequentially corresponding to the slice of the linked list;
  • the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
  • the report to the message queue is stored The address of the slice corresponds to the slice without the corresponding information
  • the linked list includes only one chunk, a new last chunk is generated, and the address of the head node of the second free cache allocated to the message queue is saved as the address and location of the second chunk. Addressing the address of the new last chunk; the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list;
  • the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk;
  • the addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
  • the acquiring a linked list unit is configured to obtain a linked list that is in one-to-one correspondence with the plurality of message queues;
  • the acquiring the message unit is configured to output the message from the plurality of message queues in sequence according to the output order of the plurality of message queues.
  • the embodiment of the present invention further provides a computer readable storage medium, the storage medium comprising a set of instructions, when executed, causing at least one processor to perform operations including:
  • a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;
  • the message transmission method and device, and the computer readable storage medium provided by the embodiment of the present invention when the message queue outputs a message, first acquires the report established when the message is input into the message queue.
  • a linked list corresponding to the text queue the linked list includes one or more chunks, each chunk includes one or more slices, and the slice corresponds to the address of the packet slice in the message queue;
  • the address of the i-th chunk pointed to by the pointer, and the respective slices of the chunk are sequentially obtained from the i-th chunk; and the packet slice is output from the packet queue according to the address of the packet slice corresponding to each slice.
  • point the linked list pointer to the address of the i+1th chunk.
  • the linked list pointer has already pointed to the address of the next chunk, and the slice in the next chunk can be used immediately without wasting several clock cycles to wait for the pointer to point to the next group.
  • the address of the block therefore, the time wasted by the output of the message queue is reduced, and the continuity of the slice in each block is ensured, thereby solving the problem of the uniform output queue.
  • FIG. 1 is a flowchart of a method for transmitting a message according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a linked list according to an embodiment of the present invention.
  • FIG. 3 is a flowchart of another method for transmitting a message according to an embodiment of the present invention.
  • FIG. 4 is a flowchart of still another method for transmitting a message according to an embodiment of the present invention.
  • FIG. 5 is a flowchart of still another method for transmitting a message according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of a process execution process according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a message transmission apparatus according to an embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of still another message transmission apparatus according to an embodiment of the present invention.
  • the embodiment of the invention provides a packet transmission method. As shown in FIG. 1 , the method may include:
  • Step 101 When the message queue outputs a message, obtain a linked list corresponding to the message queue established when the message is input into the message queue, where the linked list includes one or more chunks, and each chunk includes one or A plurality of slices corresponding to the address of the message slice in the message queue.
  • the linked list stores the order and location of the messages of the input message queue, and each block corresponds to a segment of the message.
  • the message is input into the message queue, and the message queue has a linked list corresponding to the linked list.
  • the linked list includes three chunks, each chunk consisting of six slices, wherein the slice of the slash represents a slice of the message.
  • the unslashed slice indicates that there is no address corresponding to the packet slice.
  • the six slices of the block 1 correspond to the addresses of the first six message slices in turn, the slices of the block 2 correspond to the addresses of the seventh to twelfth message slices, and the slices of the block 3 correspond to the thirteenth to the The address of 16 message slices.
  • the chunks described in this embodiment are the same as the nodes of the linked list in the prior art.
  • Step 102 Acquire each slice of the chunk from the i-th chunk according to the address of the i-th chunk pointed to by the linked list pointer.
  • i is a positive integer.
  • the base address is obtained, where the base address is an offset address of each chunk; each slice in the i-th chunk is sequentially used according to the base address, wherein the j-th slice in the i-th chunk
  • the offset address is equal to the base address plus the product of j and the specified value, which is a positive integer.
  • the linked list can include three pointers, a head pointer, a tail pointer, and a linked list pointer. The first pointer points to the address of the first chunk, the tail pointer points to the address of the last chunk, and the linked list pointer points to the next chunk used.
  • the number of slices per block is the same.
  • the specified value of the embodiment of the present invention is 1, and the base address is 0.
  • the offset address of the sixth slice of chunk 2 in FIG. 2 is 0+6*1, which is 6.
  • Step 103 Output a message slice in the message queue according to the address of the packet slice corresponding to each slice, and point the linked list pointer to the address of the i+1th block.
  • the head pointer in the linked list points to the address of chunk 1, and the tail pointer points to the address of chunk 3.
  • the linked list pointer points to chunk 2; when the packet slice corresponding to chunk 2 is being output, the linked list pointer points to chunk 3.
  • the embodiment of the present invention can obtain the slice of the current chunk, and the linked list pointer points to the address of the next chunk. Therefore, after the slice is used in the current chunk, the linked list pointer has already pointed to the next group.
  • the address of the block, the slice in the next block can be used immediately, without wasting a few clock cycles to wait for the pointer to point to the address of the next block, thus reducing the wasted time of the message queue output, ensuring the use
  • the continuity of the slices in each chunk solves the problem of uniform output queues.
  • the method further includes:
  • Step 100a Establish a linked list corresponding to the message queue.
  • a linked list is created, and the linked list includes a chunk, and the address of the first node of the first cache area allocated to the packet queue is saved as the address of the first chunk of the linked list. And the address of the last chunk, the address of the packet slice stored in the packet queue is corresponding to the slice of the linked list; if the packet queue stores the packet, it is determined whether there is no corresponding information in the linked list.
  • the address of the packet slice stored in the message queue corresponds to the slice without the corresponding information; if there is no slice without the corresponding information in the linked list, it is determined whether the linked list is Include only one chunk; if the linked list includes only one chunk, generate a new last chunk, and save the first node address of the second free cache allocated to the message queue as the second The address of the chunk and the address of the new last chunk, and the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list; if the linked list includes multiple chunks, Generating a new last chunk, storing the first node address of the third free buffer allocated to the message queue as the address of the new last chunk, and storing the packet to the packet queue
  • the addresses of the slices correspond in turn to the slices of the linked list.
  • the first cache area, the second cache area, and the third cache area are not particularly different, except that the three cache areas are not necessarily the same cache area.
  • Step 100b Save the number of slices in each chunk of the linked list and the number of slices that have been occupied in the last chunk.
  • the address of the first chunk of the linked list, the address of the second chunk, the address of the last chunk, the number of slices in each chunk, and the last chunk are obtained.
  • the head pointer of the linked list points to the address of the first chunk
  • the tail pointer points to the address of the last chunk
  • the linked list pointer points to the second chunk, for the first
  • the first slice of the chunk acquires the base address, calculates the offset address of the first slice, obtains the first slice of the first chunk, and determines the address of the corresponding packet slice according to the first slice. Enter the packet slice, and so on until the last slice of the first chunk is obtained.
  • the linked list pointer points to the address of the next chunk of the used chunk, and repeats the process of inputting the input packet. Until the chunk corresponding to the message slice in the last chunk is obtained, and the corresponding message is stopped.
  • the method further includes: obtaining a linked list that is in one-to-one correspondence with the plurality of message queues; and sequentially selecting the plurality of message queues according to the output order of the plurality of message queues Output message.
  • the method provided by the embodiment of the present invention can obtain the linked list of each packet queue at the same time, and then output the packets in sequence according to the sequence of the message queue. Therefore, after the packet queue is outputted, the next report does not need to be acquired.
  • the next message queue can directly output the message slice, thereby saving the time for obtaining the linked list and ensuring the continuity of the output of the plurality of message queues, thereby achieving the requirement of uniform output.
  • the embodiment of the invention provides a message transmission method, which is applied to a message input message queue.
  • the offset address of the i-th slice of the chunk of the embodiment of the present invention is equal to the base address 0 plus the sequence number of the slice multiplied by the specified value 1, and count-i is used to record the chunk when the packet is input into the message queue.
  • the method may include:
  • Step 201 Obtain a queue identifier.
  • the queue tag indicates whether a message queue corresponding to the linked list stores a message.
  • the queue identifier is an empty flag. When the null flag is 1, it indicates that no packet is stored in the packet queue or the packet has been output. If the null flag is 0, the packet is stored in the queue message.
  • Step 202 Determine whether the empty flag is 1, if yes, execute step 203; if no, execute step 204.
  • Step 203 If the null flag is 1, generate a linked list, where the linked list includes a chunk, and save the address of the first node of the first cache area allocated to the message queue as the address and the last of the first chunk of the linked list. The address of the chunk, set count-i to 0, and set the queue empty flag to non-empty.
  • the linked list may include a plurality of chunks, each of which includes the same number of blocks, and each node of the linked list corresponds to a storage space of the slice of the stored message.
  • the address of the first chunk of the linked list corresponds to the address of the first node of the message queue, and the address of the last chunk of the linked list corresponds to the address of the last node of the message queue.
  • Step 204 If the null flag is 0, it is determined whether count-i is equal to 0. If yes, step 205 is performed; if not, step 208 is performed.
  • count-i When count-i is equal to 0, it indicates that there is no slice with no corresponding information in the linked list. When count-i is not equal to 0, it means that the slice in one or several chunks in the linked list has no corresponding information.
  • Step 205 If count-i is equal to 0, it is determined whether the address of the first chunk of the linked list is equal to the address of the last chunk, and if yes, step 206 is performed; if not, step 207 is performed.
  • the address of the first chunk of the linked list when the address of the first chunk of the linked list is equal to the address of the last chunk, it indicates that the linked list includes only one chunk.
  • the address of the first chunk of the linked list is not equal to the address of the last chunk, the linked list includes At least two chunks.
  • Step 206 If the address of the first chunk of the linked list is equal to the address of the last chunk, generate a new last chunk, and save the first node address of the second free cache allocated to the packet queue as the second Step 208 is performed by the address of the chunk and the address of the new last chunk.
  • Step 207 If the address of the first chunk of the linked list is not equal to the address of the last chunk, generate one The new last chunk saves the first node address of the third free cache assigned to the message queue as the address of the new last chunk.
  • Step 208 Count-i is the offset address of each chunk, and sequentially compares the slice of the current chunk with the address of the packet slice of the input message queue.
  • Step 209 Determine whether there is a next message slice input message queue, if yes, execute step 204; if not, execute step 210.
  • Step 210 If no message slice is input into the message queue, the queue tag and the count-i of the last chunk are saved.
  • no message slice input message queue indicates that the message input is completed.
  • count-i is equal to the number of slices per block, and the slice needs to continue to be used, indicating that the slice of the current block is already occupied, and the slice of the next slice needs to be occupied.
  • Count-i will be set to 0 and counted from the beginning.
  • the embodiment of the present invention provides a message transmission method, which is used to implement a message queue output message of a plurality of stored messages after the message is input into the message queue of the second embodiment, and is assumed to be in the embodiment of the present invention.
  • the method After receiving three message queues (message queue 1, message queue 2, and message queue 3) to request output of the message, as shown in FIG. 5, the method includes:
  • Step 301 The message transmission device allocates a process for each of the three message queues, and the process is used to execute the message queue output message.
  • Step 302 The three processes enter the preparation phase, and the packet transmission device acquires the linked list corresponding to the queue 1 of the message, the queue-mark and the count-i of the last chunk, the address of the first chunk, the address of the second chunk, and The address of the last chunk is obtained, and the packet slice corresponding to the slice in the linked list is obtained.
  • the linked list corresponding to the respective message queue, the queue-mark and the count-i of the last chunk, the address of the first chunk, the address of the second chunk, and the address of the last chunk are all in the message input report.
  • the text queue is stored well.
  • Step 303 The process of the message queue 1 enters the execution phase, and the processes of the message queue 2 and the message queue 3 enter a waiting phase, and the message transmission device obtains the linked list, the queue mark, and the last block corresponding to the queue 1 of the message. Count-i, the address of the first chunk, the address of the second chunk, and the address of the last chunk, and obtain the packet slice corresponding to the slice in the linked list.
  • the linked list pointer points to the address of the first chunk, and sequentially uses all the slices of the first chunk of the linked list in the process, and the linked list pointer points to the address of the second chunk; the second group is used in sequence. All slices of the block, at the same time, the linked list pointer points to the address of the third chunk; all slices of the third chunk are used, and so on, until the slice of the last chunk.
  • the use of the slice of any one of the chunks may specifically include: assuming that count-i is used to record the number of slices corresponding to the packet slice in the chunk when the packet is input into the packet queue, for the purpose of understanding, the corresponding setting count -o,count-o is used to record the number of used slices in the chunk when the message is output.
  • the offset address of the next slice is calculated according to the base address and the count-o, the specified value, and the offset address is equal to count-o multiplied by 1, according to the offset address,
  • the next slice is obtained, so that the address of the packet slice corresponding to the slice is obtained, and the message slice is output.
  • count-o refers to the number of slices corresponding to the packet slice in the block when the message is output, that is, the number of the slice currently being used.
  • determining that the message queue output is completed may further include: the queue identifier is empty; or the count-o of each chunk in the linked list is 0.
  • Step 304 The process of the message queue 2 enters the execution phase, and the message queue 3 enters the waiting phase.
  • the message transmission device obtains the linked list corresponding to the queue 2 of the message queue, the queue mark, and the count-i and the first group of the last block.
  • the address of the block, the address of the second chunk, and the address of the last chunk, get the linked list The slice corresponding to the middle slice.
  • Step 305 The process of the message queue 3 enters an execution phase, and the message transmission device obtains the link table corresponding to the message queue 3, the queue mark, the count-i of the last chunk, the address of the first chunk, and the second group. The address of the block and the address of the last chunk are obtained, and the packet slice corresponding to the slice in the linked list is obtained.
  • the specific execution sequence of the process provided by the embodiment of the present invention is shown in FIG. 6. It should be noted that the methods used in the output of the message are the same in steps 303 to 305. Therefore, the embodiment is only described in detail in step 303, and is not repeated in steps 304 and 305. In general, the message is output. After the queue is completed, the corresponding process is released, but when the following situations occur, the corresponding process will be queued behind all previous queues, waiting for the next call: the queue is not empty, that is, the queue depth is not 0; or the queue The port is not in the flow control state; or the process is not full.
  • the embodiment of the present invention provides a message transmission device 40.
  • the device 40 may include:
  • the obtaining linked list unit 401 is configured to: when the message queue outputs the message, obtain a linked list corresponding to the message queue established when the message is input into the message queue, where the linked list includes one or more chunks. Each chunk includes one or more slices that correspond one-to-one with the address of the message slice in the message queue.
  • the obtaining address unit 402 is configured to sequentially acquire a slice from the i-th chunk according to an address of the i-th chunk pointed to by the linked list pointer, where i is a positive integer.
  • the obtaining message unit 403 is configured to output the message slice from the message queue according to the address of the message slice corresponding to each slice, and point the linked list pointer to the address of the i+1th block.
  • the embodiment of the present invention can obtain the slice of the current chunk, and the linked list pointer points to the address of the next chunk. Therefore, after the slice is used in the current chunk, the linked list pointer has already pointed to the next group.
  • the address of the block, the slice in the next block can be used immediately, without wasting several clock cycles waiting for the pointer to point to the address of the next block, thus, The time wasted by the message queue output is reduced, and the continuity of the slices in each block is ensured, thereby solving the problem of uniform output queue.
  • the acquiring slice unit 403 is specifically configured to:
  • the base address being an offset address of each chunk
  • the number of slices per block is the same.
  • the device 40 further includes:
  • the establishing unit 404 is configured to establish one of the linked lists corresponding to the message queue.
  • a saving unit 405 configured to save the number of slices in each chunk of the linked list, the number of occupied slices in the last chunk, and the queue tag, where the queue tag indicates the message queue Whether to store the message.
  • the establishing unit 404 is specifically configured to:
  • the linked list includes a chunk; and save an address of a first node of the first cache area allocated to the packet queue as the linked list
  • the address of the first chunk and the address of the last chunk; the address of the packet slice stored in the message queue is sequentially corresponding to the slice of the linked list;
  • the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
  • the address of the packet slice stored in the message queue is sequentially corresponding to the slice without the corresponding information
  • the linked list includes only one chunk, a new last chunk is generated and will be assigned to the
  • the first node address of the second free buffer of the message queue is saved as the address of the second chunk and the address of the new last chunk; the address of the packet slice to be stored in the message queue Corresponding to the slice of the linked list in turn;
  • the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk;
  • the addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
  • the obtaining linked list unit 401 is further configured to acquire a linked list that is in one-to-one correspondence with the plurality of message queues;
  • the acquiring message unit 403 is further configured to sequentially output the message from the plurality of message queues according to the output order of the plurality of message queues.
  • the acquiring linked list unit 401, the obtaining address unit 402, the obtaining message unit 403, the establishing unit 404, and the saving unit 405 may each be a central processing unit (CPU) and a microprocessor located in the terminal.
  • CPU central processing unit
  • MPU Micro Processor Unit
  • DSP Digital Signal Processor
  • FPGA Field Programmable Gate Array
  • the embodiment of the present invention can further provide a computer readable storage medium, where the storage medium includes a set of instructions, when executed, causing at least one processor to execute the following operating:
  • a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;

Landscapes

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

Abstract

Disclosed is a message transmission method, comprising: when a message is output from a message queue, acquiring a linked list corresponding to the message queue which is created when the message is input into the message queue, the linked list comprising one or more blocks, each of the blocks comprising one or more slices, and the slices being in one-to-one correspondence to the addresses of message slices in the message queue; sequentially acquiring the slices from the ith block according to the address of the ith block pointed by a linked list pointer, where i is a positive integer; and outputting the message slices from the message queue according to the addresses of the message slices corresponding to various slices, and pointing the linked list pointer to the address of the (i+1)th block. Also disclosed at the same time are a message transmission device and a computer-readable storage medium.

Description

一种报文传输方法、装置及计算机可读存储介质Message transmission method, device and computer readable storage medium 技术领域Technical field
本发明涉及分组转发设备的管理技术,特别涉及一种报文传输方法、装置及计算机可读存储介质。The present invention relates to a packet forwarding device management technology, and in particular, to a message transmission method and apparatus, and a computer readable storage medium.
背景技术Background technique
随着互联网的迅猛发展,网络带宽迅速增加,分组转发设备尤其是高端路由器的接口速度和队列数也随之迅速增加。为了适应接口速度和队列数增加的速度,一般路由器的网络处理器芯片都会内置专门的流量管理系统来完成对高速数据流的管理,再将报文缓存经过处理后输出。With the rapid development of the Internet, network bandwidth has increased rapidly, and the interface speed and number of queues of packet forwarding devices, especially high-end routers, have also increased rapidly. In order to adapt to the speed of the interface and the increase of the number of queues, the network processor chip of the general router will have a dedicated traffic management system to complete the management of the high-speed data stream, and then the message buffer is processed and output.
现有技术大多采用在芯片外部挂存储芯片来存储数据,在芯片内部采用链表结构进行管理,以链表的每个节点对应每个报文切片的存储空间,预先记录链表的首尾节点,对于除首尾节点外的中间节点和硬件的固有读延迟,从当前链表节点作为地址读取下一节点,到真正读取到该地址里存储的数据内容,需要若干个时钟周期,这一段时间内链表也是无法有效使用的。因此,在采用单链表结构的情况下,现有技术无法解决均匀出队的问题。Most of the prior art uses a memory chip external to the chip to store data, and is managed by a linked list structure inside the chip. Each node of the linked list corresponds to the storage space of each packet slice, and the first and last nodes of the linked list are recorded in advance, except for the head and tail. The inherent read latency of the intermediate nodes and hardware outside the node, from the current linked list node as the address to read the next node, to the actual reading of the data content stored in the address, requires several clock cycles, this time the linked list is not Effective use. Therefore, in the case of employing a single linked list structure, the prior art cannot solve the problem of uniform dequeue.
发明内容Summary of the invention
为解决现有存在的技术问题,本发明实施例主要提供一种报文传输方法、装置及计算机可读存储介质,能够在采用单链表结构的情况下,解决均匀出队的问题。In order to solve the existing technical problems, the embodiment of the present invention mainly provides a message transmission method and device, and a computer readable storage medium, which can solve the problem of uniform dequeue in the case of adopting a single linked list structure.
本发明实施例的技术方案是这样实现的:The technical solution of the embodiment of the present invention is implemented as follows:
第一方面,本发明实施例提供一种报文传输方法,所述方法包括: In a first aspect, an embodiment of the present invention provides a packet transmission method, where the method includes:
报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应;When the message queue outputs a message, a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;
根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数;Obtaining a slice sequentially from the i-th chunk according to an address of the i-th chunk pointed by the linked list pointer, wherein the i is a positive integer;
根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文切片,并将所述链表指针指向第i+1个组块的地址。And outputting the message slice from the message queue according to an address of a message slice corresponding to each slice, and pointing the linked list pointer to an address of the i+1th block.
结合第一方面,在第一种可实现方式中,所述根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片包括:With reference to the first aspect, in a first implementation manner, the obtaining, according to the address of the i-th chunk pointed by the linked list pointer, sequentially acquiring the slice from the i-th chunk includes:
获取基地址,所述基地址是每个组块的偏移地址;Obtaining a base address, the base address being an offset address of each chunk;
根据所述基地址依次使用所述第i个组块中的每个切片,其中,所述第i个组块中第j个切片的偏移地址等于基地址加上所述j与指定值的积,所述j是正整数。And each of the i-th chunks is sequentially used according to the base address, wherein an offset address of the j-th slice in the i-th chunk is equal to a base address plus the j and a specified value Product, the j is a positive integer.
结合第一种可实现方式,在第二种可实现方式中,在同一链表中,每个组块的切片个数相同。In combination with the first achievable manner, in the second achievable manner, the number of slices per block is the same in the same linked list.
结合第一方面、第一种和第二种可实现方式中任一种可实现方式,在第三种可实现方式中,在所述报文队列输出报文之前,报文输入所述报文队列之时,所述方法还包括:In combination with the implementation of any one of the first aspect, the first type, and the second implementation manner, in the third implementation manner, before the packet queue outputting the packet, the packet is input into the packet. At the time of the queue, the method further includes:
建立与所述报文队列对应的一条所述链表;Establishing one of the linked lists corresponding to the message queue;
保存所述链表的每个组块中的切片个数和所述末个组块中已占用的切片个数。The number of slices in each chunk of the linked list and the number of slices occupied in the last chunk are saved.
结合第三种可实现方式,在第四种可实现方式中,所述建立与所述报文队列对应的一条所述链表包括:In conjunction with the third implementation manner, in the fourth implementation manner, the establishing, by the linked list, the linked list includes:
若所述报文队列未存储报文,则生成一条所述链表,所述链表包括一个组块;将分配给所述报文队列的第一缓存区域的首节点的地址保存为所 述链表的首个组块的地址和末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the message queue does not store a message, generate one of the linked list, the linked list includes a chunk; and save the address of the first node of the first cache area allocated to the packet queue as Addressing the address of the first chunk of the linked list and the address of the last chunk; and sequentially storing the address of the packet slice stored in the packet queue with the slice of the linked list;
若所述报文队列存储有报文,则判断所述链表中是否存在无对应信息的切片;If the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
若所述链表中存在无对应信息的切片,则将存储至所述报文队列的报文切片的地址依次与所述无对应信息的切片相对应;If there is a slice with no corresponding information in the linked list, the address of the packet slice stored in the message queue is sequentially corresponding to the slice without the corresponding information;
若所述链表中不存在无对应信息的切片,则判断所述链表是否只包括一个组块;If there is no slice in the linked list without corresponding information, it is determined whether the linked list includes only one chunk;
若所述链表只包括一个组块,则生成一个新的末个组块,将分配给所述报文队列的第二空闲缓存的首节点地址保存为所述第二个组块的地址和所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the linked list includes only one chunk, a new last chunk is generated, and the address of the head node of the second free cache allocated to the message queue is saved as the address and location of the second chunk. Addressing the address of the new last chunk; the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list;
若所述链表包括多个组块,则生成一个新的末个组块,将分配给所述报文队列的第三空闲缓存的首节点地址保存为所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应。If the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk; The addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
结合第一方面,在第五种可实现方式中,当多个报文队列输出报文时,所述方法还包括:With reference to the first aspect, in a fifth implementation manner, when a plurality of message queues output a message, the method further includes:
获取与所述多个报文队列一一对应的链表;Obtaining a linked list that is in one-to-one correspondence with the plurality of message queues;
按照所述多个报文队列的输出顺序,依次从所述多个报文队列输出报文。And outputting the packets from the plurality of message queues in sequence according to the output order of the plurality of message queues.
第二方面,本发明实施例一种报文传输装置,所述装置包括:A second aspect of the present invention provides a message transmission apparatus, where the apparatus includes:
获取链表单元,配置为报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应; Obtaining a linked list unit, configured to output a message in the message queue, obtain a linked list corresponding to the message queue established when the message is input into the message queue, and the linked list includes one or more chunks, each The chunk includes one or more slices, and the slice has a one-to-one correspondence with an address of a message slice in the message queue;
获取地址单元,配置为根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数;Obtaining an address unit, configured to sequentially acquire a slice from the i-th chunk according to an address of the i-th chunk pointed to by the linked list pointer, where i is a positive integer;
获取报文单元,配置为根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文切片,并将所述链表指针指向第i+1个组块的地址。Obtaining a message unit, configured to output the message slice from the message queue according to an address of a message slice corresponding to each slice, and point the linked list pointer to an address of the i+1th block.
结合第二方面,在第一种可实现方式中,所述获取切片单元配置为:With reference to the second aspect, in a first implementation manner, the acquiring a slice unit is configured to:
获取基地址,所述基地址是每个组块的偏移地址;Obtaining a base address, the base address being an offset address of each chunk;
根据所述基地址,依次使用所述第i个组块中的每个切片,其中,所述第i个组块中第j个切片的偏移地址等于基地址加上所述j与指定值的积,所述j是正整数。Determining, according to the base address, each slice in the i-th chunk, wherein an offset address of the j-th slice in the i-th chunk is equal to a base address plus the j and a specified value Product, the j is a positive integer.
结合第一种可实现方式,在第二种可实现方式中,在同一链表中,每个组块的切片个数相同。In combination with the first achievable manner, in the second achievable manner, the number of slices per block is the same in the same linked list.
结合第二方面、第一种和第二种可实现方式中任一种可实现方式,所述装置还包括:In combination with any of the second aspect, the first and the second implementable manner, the apparatus further includes:
建立单元,配置为建立与所述报文队列对应的一条所述链表;Establishing a unit, configured to establish one of the linked lists corresponding to the message queue;
保存单元,配置为保存所述链表的每个组块中的切片个数和所述末个组块中已占用的切片个数。And a saving unit configured to save the number of slices in each chunk of the linked list and the number of slices occupied in the last chunk.
结合第三种可实现方式,在第四种可实现方式中,所述建立单元配置为:In combination with the third achievable manner, in a fourth implementable manner, the establishing unit is configured to:
若所述报文队列未存储报文,则生成一条所述链表,所述链表包括一个组块;将分配给所述报文队列的第一缓存区域的首节点的地址保存为所述链表的首个组块的地址和末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the message queue does not store a message, generate a linked list, the linked list includes a chunk; and save an address of a first node of the first cache area allocated to the packet queue as the linked list The address of the first chunk and the address of the last chunk; the address of the packet slice stored in the message queue is sequentially corresponding to the slice of the linked list;
若所述报文队列存储有报文,则判断所述链表中是否存在无对应信息的切片;If the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
若所述链表中存在无对应信息的切片,则将存储至所述报文队列的报 文切片的地址依次与所述无对应信息的切片相对应;If there is a slice in the linked list without corresponding information, the report to the message queue is stored The address of the slice corresponds to the slice without the corresponding information;
若所述链表中不存在无对应信息的切片,则判断所述链表是否只包括一个组块;If there is no slice in the linked list without corresponding information, it is determined whether the linked list includes only one chunk;
若所述链表只包括一个组块,则生成一个新的末个组块,将分配给所述报文队列的第二空闲缓存的首节点地址保存为所述第二个组块的地址和所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the linked list includes only one chunk, a new last chunk is generated, and the address of the head node of the second free cache allocated to the message queue is saved as the address and location of the second chunk. Addressing the address of the new last chunk; the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list;
若所述链表包括多个组块,则生成一个新的末个组块,将分配给所述报文队列的第三空闲缓存的首节点地址保存为所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应。If the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk; The addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
结合第二方面,在第五种可实现方式中,当多个报文队列输出报文时,With reference to the second aspect, in the fifth implementation manner, when multiple message queues output a message,
所述获取链表单元,配置为获取与所述多个报文队列一一对应的链表;The acquiring a linked list unit is configured to obtain a linked list that is in one-to-one correspondence with the plurality of message queues;
所述获取报文单元,配置为按照所述多个报文队列的输出顺序,依次从所述多个报文队列输出报文。The acquiring the message unit is configured to output the message from the plurality of message queues in sequence according to the output order of the plurality of message queues.
本发明实施例还提供了一种计算机可读存储介质,该存储介质包括一组指令,当执行所述指令时,引起至少一个处理器执行包括以下的操作:The embodiment of the present invention further provides a computer readable storage medium, the storage medium comprising a set of instructions, when executed, causing at least one processor to perform operations including:
报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应;When the message queue outputs a message, a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;
根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数;Obtaining a slice sequentially from the i-th chunk according to an address of the i-th chunk pointed by the linked list pointer, wherein the i is a positive integer;
根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文切片,并将所述链表指针指向第i+1个组块的地址。And outputting the message slice from the message queue according to an address of a message slice corresponding to each slice, and pointing the linked list pointer to an address of the i+1th block.
本发明实施例提供的报文传输方法、装置及计算机可读存储介质,在报文队列输出报文时,先获取在报文输入所述报文队列时建立的与所述报 文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,该切片与所述报文队列中的报文切片的地址一一对应;再根据链表指针指向的第i个组块的地址,从第i个组块中依次获取该组块的各个切片;根据各切片对应的报文切片的地址,从报文队列中输出所述报文切片,并将链表指针指向第i+1个组块的地址。这样一来,当前组块中切片使用完成之后,链表指针已经指向下一个组块的地址,下一个组块中的切片就可以立刻被使用,无需浪费几个时钟周期来等待指针指向下一个组块的地址;因此,减少了报文队列输出所浪费的时间,保证了使用各个组块中切片的连续性,从而解决了均匀输出队列的问题。The message transmission method and device, and the computer readable storage medium provided by the embodiment of the present invention, when the message queue outputs a message, first acquires the report established when the message is input into the message queue. a linked list corresponding to the text queue, the linked list includes one or more chunks, each chunk includes one or more slices, and the slice corresponds to the address of the packet slice in the message queue; The address of the i-th chunk pointed to by the pointer, and the respective slices of the chunk are sequentially obtained from the i-th chunk; and the packet slice is output from the packet queue according to the address of the packet slice corresponding to each slice. And point the linked list pointer to the address of the i+1th chunk. In this way, after the use of the slice in the current chunk is completed, the linked list pointer has already pointed to the address of the next chunk, and the slice in the next chunk can be used immediately without wasting several clock cycles to wait for the pointer to point to the next group. The address of the block; therefore, the time wasted by the output of the message queue is reduced, and the continuity of the slice in each block is ensured, thereby solving the problem of the uniform output queue.
附图说明DRAWINGS
图1为本发明实施例提供一种报文传输方法的流程图;FIG. 1 is a flowchart of a method for transmitting a message according to an embodiment of the present invention;
图2为本发明实施例提供的链表的示意图;2 is a schematic diagram of a linked list according to an embodiment of the present invention;
图3为本发明实施例提供另一种报文传输方法的流程图;FIG. 3 is a flowchart of another method for transmitting a message according to an embodiment of the present invention;
图4为本发明实施例提供再一种报文传输方法的流程图;FIG. 4 is a flowchart of still another method for transmitting a message according to an embodiment of the present invention;
图5为本发明实施例提供又一种报文传输方法的流程图;FIG. 5 is a flowchart of still another method for transmitting a message according to an embodiment of the present invention;
图6为本发明实施例提供的进程执行过程的示意图;FIG. 6 is a schematic diagram of a process execution process according to an embodiment of the present invention;
图7为本发明实施例提供一种报文传输装置的结构示意图;FIG. 7 is a schematic structural diagram of a message transmission apparatus according to an embodiment of the present invention;
图8为本发明实施例提供又一种报文传输装置的结构示意图。FIG. 8 is a schematic structural diagram of still another message transmission apparatus according to an embodiment of the present invention.
具体实施方式detailed description
实施例一Embodiment 1
本发明实施例提供一种报文传输方法,如图1所示,该方法可以包括:The embodiment of the invention provides a packet transmission method. As shown in FIG. 1 , the method may include:
步骤101、报文队列输出报文时,获取在报文输入该报文队列时建立的一条与该报文队列对应的链表,该链表包括一个或多个组块,每个组块包括一个或多个切片,该切片与该报文队列中的报文切片的地址一一对应。 Step 101: When the message queue outputs a message, obtain a linked list corresponding to the message queue established when the message is input into the message queue, where the linked list includes one or more chunks, and each chunk includes one or A plurality of slices corresponding to the address of the message slice in the message queue.
这里,该链表保存着输入报文队列的报文的排列顺序和位置,各个组块对应着一段报文切片,示例的,报文输入报文队列,该报文队列有一个链表相对应,链表如图2所示,假设该报文被分为16个报文切片,该链表中包括三个组块,每个组块包括六个切片,其中,划斜杠的切片表示有报文切片的地址对应,未划斜杠的切片表示没有报文切片的地址对应。组块1的6个切片依次对应着前6个报文切片的地址,组块2的切片依次对应着第7至第12个报文切片的地址,组块3的切片依次对应着第13至16个报文切片的地址。这里,本实施例中所述的组块和现有技术中的链表的节点是相同的。Here, the linked list stores the order and location of the messages of the input message queue, and each block corresponds to a segment of the message. For example, the message is input into the message queue, and the message queue has a linked list corresponding to the linked list. As shown in FIG. 2, it is assumed that the message is divided into 16 message slices, and the linked list includes three chunks, each chunk consisting of six slices, wherein the slice of the slash represents a slice of the message. Corresponding to the address, the unslashed slice indicates that there is no address corresponding to the packet slice. The six slices of the block 1 correspond to the addresses of the first six message slices in turn, the slices of the block 2 correspond to the addresses of the seventh to twelfth message slices, and the slices of the block 3 correspond to the thirteenth to the The address of 16 message slices. Here, the chunks described in this embodiment are the same as the nodes of the linked list in the prior art.
步骤102、根据链表指针指向的第i个组块的地址,从第i个组块中依次获取该组块的各个切片。Step 102: Acquire each slice of the chunk from the i-th chunk according to the address of the i-th chunk pointed to by the linked list pointer.
这里,i是正整数。Here, i is a positive integer.
具体的,获取基地址,该基地址是每个组块的偏移地址;根据基地址依次使用所述第i个组块中的每个切片,其中,第i个组块中第j个切片的偏移地址等于基地址加上j与指定值的积,该j是正整数。这里,该链表可以包括三个指针,头指针、尾指针和链表指针。首指针指着首个组块的地址,尾指针指着末个组块的地址,链表指针则指着下一个被使用的组块。Specifically, the base address is obtained, where the base address is an offset address of each chunk; each slice in the i-th chunk is sequentially used according to the base address, wherein the j-th slice in the i-th chunk The offset address is equal to the base address plus the product of j and the specified value, which is a positive integer. Here, the linked list can include three pointers, a head pointer, a tail pointer, and a linked list pointer. The first pointer points to the address of the first chunk, the tail pointer points to the address of the last chunk, and the linked list pointer points to the next chunk used.
优选的,在同一链表中,每个组块的切片个数相同。本发明实施例优选的指定值是1,基地址是0。例如,图2中组块2的第6个切片的偏移地址是0+6*1,即为6。Preferably, in the same linked list, the number of slices per block is the same. Preferably, the specified value of the embodiment of the present invention is 1, and the base address is 0. For example, the offset address of the sixth slice of chunk 2 in FIG. 2 is 0+6*1, which is 6.
步骤103、根据各切片对应的报文切片的地址,报文队列中输出报文切片,并将链表指针指向第i+1个组块的地址。Step 103: Output a message slice in the message queue according to the address of the packet slice corresponding to each slice, and point the linked list pointer to the address of the i+1th block.
如图2所示,该链表中头指针指向组块1的地址,尾指针指向组块3的地址。当组块1对应的报文切片正在输出,链表指针指向组块2;当组块2对应的报文切片正在输出,链表指针指向组块3。 As shown in FIG. 2, the head pointer in the linked list points to the address of chunk 1, and the tail pointer points to the address of chunk 3. When the packet slice corresponding to chunk 1 is being output, the linked list pointer points to chunk 2; when the packet slice corresponding to chunk 2 is being output, the linked list pointer points to chunk 3.
相较于现有技术,本发明实施例可以在获取当前组块的切片的同时,链表指针指向下一个组块的地址,因此,当前组块中切片使用完成之后,链表指针已经指向下一个组块的地址,下一个组块中的切片就可以立刻被使用,无需浪费几个时钟周期来等待指针指向下一个组块的地址,这样,减少了报文队列输出所浪费的时间,保证了使用各个组块中切片的连续性,从而解决了均匀输出队列的问题。Compared with the prior art, the embodiment of the present invention can obtain the slice of the current chunk, and the linked list pointer points to the address of the next chunk. Therefore, after the slice is used in the current chunk, the linked list pointer has already pointed to the next group. The address of the block, the slice in the next block can be used immediately, without wasting a few clock cycles to wait for the pointer to point to the address of the next block, thus reducing the wasted time of the message queue output, ensuring the use The continuity of the slices in each chunk solves the problem of uniform output queues.
进一步的,如图3所示,所述方法还包括:Further, as shown in FIG. 3, the method further includes:
步骤100a、建立报文队列对应的一条链表。 Step 100a: Establish a linked list corresponding to the message queue.
具体的,若报文队列未存储报文,则建立一条链表,链表包括一个组块,将分配给报文队列的第一缓存区域的首节点的地址,保存为链表的首个组块的地址和末个组块的地址,将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;若报文队列存储有报文,则判断链表中是否存在无对应信息的切片;若链表中存在无对应信息的切片,则将存储至报文队列的报文切片的地址依次与无对应信息的切片相对应;若链表中不存在无对应信息的切片,则判断链表是否只包括一个组块;若所述链表只包括一个组块,则生成一个新的末个组块,将分配给所述报文队列的第二空闲缓存的首节点地址保存为所述第二个组块的地址和所述新的末个组块的地址,将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;若所述链表包括多个组块,则生成一个新的末个组块,将分配给所述报文队列的第三空闲缓存的首节点地址保存为所述新的末个组块的地址,将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应。这里,第一缓存区域、第二缓存区域和第三缓存区域并无特殊不同,只是为了区分三个缓存区域并不一定是同一个缓存区域。Specifically, if the packet queue does not store the packet, a linked list is created, and the linked list includes a chunk, and the address of the first node of the first cache area allocated to the packet queue is saved as the address of the first chunk of the linked list. And the address of the last chunk, the address of the packet slice stored in the packet queue is corresponding to the slice of the linked list; if the packet queue stores the packet, it is determined whether there is no corresponding information in the linked list. If there is a slice with no corresponding information in the linked list, the address of the packet slice stored in the message queue corresponds to the slice without the corresponding information; if there is no slice without the corresponding information in the linked list, it is determined whether the linked list is Include only one chunk; if the linked list includes only one chunk, generate a new last chunk, and save the first node address of the second free cache allocated to the message queue as the second The address of the chunk and the address of the new last chunk, and the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list; if the linked list includes multiple chunks, Generating a new last chunk, storing the first node address of the third free buffer allocated to the message queue as the address of the new last chunk, and storing the packet to the packet queue The addresses of the slices correspond in turn to the slices of the linked list. Here, the first cache area, the second cache area, and the third cache area are not particularly different, except that the three cache areas are not necessarily the same cache area.
步骤100b、保存链表的每个组块中的切片个数和末个组块中已占用的切片个数。 Step 100b: Save the number of slices in each chunk of the linked list and the number of slices that have been occupied in the last chunk.
相应的,报文输出队列时,需要获取链表的首个组块的地址、第二个组块的地址、末个组块的地址、每个组块中的切片个数、末个组块中已占用的切片个数和队列标记,在队列输出初始时,链表的头指针指向首个组块的地址,尾指针指向末个组块的地址,链表指针指向第二个组块,对于首个组块的第1个切片,获取基地址,计算得到第1个切片的偏移地址,获取首个组块的第1个切片,根据第1个切片确定出与只对应的报文切片的地址,输入该报文切片,依次类推,直到获取到首个组块的最后一个切片为止,与此同时,链表指针指向使用完组块的下一个组块的地址,重复上述输入报文切片的过程,直到获取最后一个组块中与报文切片对应的组块,并输出相应的报文停止。Correspondingly, when the message output queue, the address of the first chunk of the linked list, the address of the second chunk, the address of the last chunk, the number of slices in each chunk, and the last chunk are obtained. The number of occupied slices and the queue tag. At the beginning of the queue output, the head pointer of the linked list points to the address of the first chunk, the tail pointer points to the address of the last chunk, and the linked list pointer points to the second chunk, for the first The first slice of the chunk acquires the base address, calculates the offset address of the first slice, obtains the first slice of the first chunk, and determines the address of the corresponding packet slice according to the first slice. Enter the packet slice, and so on until the last slice of the first chunk is obtained. At the same time, the linked list pointer points to the address of the next chunk of the used chunk, and repeats the process of inputting the input packet. Until the chunk corresponding to the message slice in the last chunk is obtained, and the corresponding message is stopped.
进一步的,当多个报文队列输出报文时,所述方法还包括:获取与多个报文队列一一对应的链表;按照多个报文队列的输出顺序,依次从多个报文队列输出报文。这样,本发明实施例提供的方法可以同时获取各个报文队列的链表,再按照报文队列的顺序,依次输出报文,因此,一个报文队列输出报文切片之后,无需再获取下一个报文队列的链表,下一个报文队列可以直接输出报文切片,从而将获取链表的时间节省下来,保证了多个报文队列输出的连续性,从而达到了均匀输出的要求。Further, when a plurality of message queues output a message, the method further includes: obtaining a linked list that is in one-to-one correspondence with the plurality of message queues; and sequentially selecting the plurality of message queues according to the output order of the plurality of message queues Output message. In this way, the method provided by the embodiment of the present invention can obtain the linked list of each packet queue at the same time, and then output the packets in sequence according to the sequence of the message queue. Therefore, after the packet queue is outputted, the next report does not need to be acquired. In the linked list of the text queue, the next message queue can directly output the message slice, thereby saving the time for obtaining the linked list and ensuring the continuity of the output of the plurality of message queues, thereby achieving the requirement of uniform output.
实施例二Embodiment 2
本发明实施例提供一种报文传输方法,该方法应用于报文输入报文队列。其中,本发明实施例的组块第i个切片的偏移地址等于基地址0加上切片的顺序号乘以指定值1,count-i用于在报文输入报文队列时,记录组块中已占用的切片个数,也就是当前使的切片的序号数。如图4所示,该方法可以包括:The embodiment of the invention provides a message transmission method, which is applied to a message input message queue. The offset address of the i-th slice of the chunk of the embodiment of the present invention is equal to the base address 0 plus the sequence number of the slice multiplied by the specified value 1, and count-i is used to record the chunk when the packet is input into the message queue. The number of slices that have been occupied, that is, the number of the current slice. As shown in FIG. 4, the method may include:
步骤201、获取队列标识。Step 201: Obtain a queue identifier.
这里,队列标记表示链表对应的报文队列是否存储有报文。这里,本 发明实施例中队列标识是空标记,当空标记为1时,说明报文队列中未存储报文或者报文已经输出队列了,当空标记为0,则说明队列报文中存储着有报文。Here, the queue tag indicates whether a message queue corresponding to the linked list stores a message. Here, this In the embodiment of the present invention, the queue identifier is an empty flag. When the null flag is 1, it indicates that no packet is stored in the packet queue or the packet has been output. If the null flag is 0, the packet is stored in the queue message.
步骤202、判断空标记是否为1,若是,则执行步骤203;若否,则执行步骤204。Step 202: Determine whether the empty flag is 1, if yes, execute step 203; if no, execute step 204.
步骤203、若空标记为1,则生成一条链表,该链表包括一个组块,将分配给报文队列的第一缓存区域的首节点的地址保存为链表的首个组块的地址和末个组块的地址,将count-i置为0,将队列空标记置为非空。Step 203: If the null flag is 1, generate a linked list, where the linked list includes a chunk, and save the address of the first node of the first cache area allocated to the message queue as the address and the last of the first chunk of the linked list. The address of the chunk, set count-i to 0, and set the queue empty flag to non-empty.
这里,该链表可以包括若干个组块(chunk),每个组块中又包括相同个数的切片(block),链表的每个节点都对应着存储着的报文的切片的存储空间。链表的首个组块的地址对应着报文队列的首个节点的地址,链表的末个组块的地址对应着报文队列的末个节点的地址。Here, the linked list may include a plurality of chunks, each of which includes the same number of blocks, and each node of the linked list corresponds to a storage space of the slice of the stored message. The address of the first chunk of the linked list corresponds to the address of the first node of the message queue, and the address of the last chunk of the linked list corresponds to the address of the last node of the message queue.
步骤204、若空标记为0,则判断count-i是否等于0,若是,则执行步骤205;若否,则执行步骤208。Step 204: If the null flag is 0, it is determined whether count-i is equal to 0. If yes, step 205 is performed; if not, step 208 is performed.
当count-i等于0时,说明链表不存在无对应信息的切片。当count-i不等于0时,说明链表中某一个或几个组块中的切片没有对应的信息。When count-i is equal to 0, it indicates that there is no slice with no corresponding information in the linked list. When count-i is not equal to 0, it means that the slice in one or several chunks in the linked list has no corresponding information.
步骤205、若count-i等于0,则判断链表的首个组块的地址是否等于末个组块的地址,若是,则执行步骤206;若否,则执行步骤207。Step 205: If count-i is equal to 0, it is determined whether the address of the first chunk of the linked list is equal to the address of the last chunk, and if yes, step 206 is performed; if not, step 207 is performed.
这里,当链表的首个组块的地址等于末个组块的地址,则说明链表只包括一个组块,当链表的首个组块的地址不等于末个组块的地址,则说明链表包括至少两个组块。Here, when the address of the first chunk of the linked list is equal to the address of the last chunk, it indicates that the linked list includes only one chunk. When the address of the first chunk of the linked list is not equal to the address of the last chunk, the linked list includes At least two chunks.
步骤206、若链表的首个组块的地址等于末个组块的地址,则生成一个新的末个组块,将分配给报文队列的第二空闲缓存的首节点地址保存为第二个组块的地址和新的末个组块的地址,执行步骤208。Step 206: If the address of the first chunk of the linked list is equal to the address of the last chunk, generate a new last chunk, and save the first node address of the second free cache allocated to the packet queue as the second Step 208 is performed by the address of the chunk and the address of the new last chunk.
步骤207、若链表的首个组块的地址不等于末个组块的地址,则生成一 个新的末个组块,将分配给报文队列的第三空闲缓存的首节点地址保存为新的末个组块的地址。Step 207: If the address of the first chunk of the linked list is not equal to the address of the last chunk, generate one The new last chunk saves the first node address of the third free cache assigned to the message queue as the address of the new last chunk.
步骤208、以count-i为每个组块的偏移地址,依次按将当前组块的切片与输入报文队列的报文切片的地址相对应。Step 208: Count-i is the offset address of each chunk, and sequentially compares the slice of the current chunk with the address of the packet slice of the input message queue.
步骤209、判断是否有下一个报文切片输入报文队列,若是,则执行步骤204;若否,则执行步骤210。Step 209: Determine whether there is a next message slice input message queue, if yes, execute step 204; if not, execute step 210.
步骤210、若无报文切片输入报文队列,则保存队列标记和末个组块的count-i。Step 210: If no message slice is input into the message queue, the queue tag and the count-i of the last chunk are saved.
这里,无报文切片输入报文队列说明报文输入完成。Here, no message slice input message queue indicates that the message input is completed.
值得说明的是,当每次count-i等于每个组块的切片个数,且还需要继续使用切片,表明当前组块的切片已经被占用了,需要占用下一个切片的切片,此时,count-i将置为0,从新开始计数。It is worth noting that each time count-i is equal to the number of slices per block, and the slice needs to continue to be used, indicating that the slice of the current block is already occupied, and the slice of the next slice needs to be occupied. Count-i will be set to 0 and counted from the beginning.
实施例三Embodiment 3
本发明实施例提供一种报文传输方法,该方法用于在实施例二的报文输入报文队列之后,实施多个已存储报文的报文队列输出报文,假设本发明实施例在同时接收到三个报文队列(报文队列1、报文队列2和报文队列3)请求输出报文之后,如图5所示,该方法包括:The embodiment of the present invention provides a message transmission method, which is used to implement a message queue output message of a plurality of stored messages after the message is input into the message queue of the second embodiment, and is assumed to be in the embodiment of the present invention. After receiving three message queues (message queue 1, message queue 2, and message queue 3) to request output of the message, as shown in FIG. 5, the method includes:
步骤301、报文传输装置为三个报文队列各分配一个进程,该进程用于执行报文队列输出报文。Step 301: The message transmission device allocates a process for each of the three message queues, and the process is used to execute the message queue output message.
步骤302、三个进程进入准备阶段,报文传输装置获取报文队列1对应的链表、队列标记和末个组块的count-i、首个组块的地址、第二个组块的地址和末个组块的地址,获取链表中切片对应的报文切片。Step 302: The three processes enter the preparation phase, and the packet transmission device acquires the linked list corresponding to the queue 1 of the message, the queue-mark and the count-i of the last chunk, the address of the first chunk, the address of the second chunk, and The address of the last chunk is obtained, and the packet slice corresponding to the slice in the linked list is obtained.
这里,各自报文队列对应的链表、队列标记和末个组块的count-i、首个组块的地址、第二个组块的地址和末个组块的地址都是在报文输入报文队列时存储好的。 Here, the linked list corresponding to the respective message queue, the queue-mark and the count-i of the last chunk, the address of the first chunk, the address of the second chunk, and the address of the last chunk are all in the message input report. The text queue is stored well.
步骤303、报文队列1的进程进入执行阶段,报文队列2和报文队列3的进程进入等待阶段,报文传输装置根据获取报文队列1对应的链表、队列标记和末个组块的count-i、首个组块的地址、第二个组块的地址和末个组块的地址,获取链表中切片对应的报文切片。Step 303: The process of the message queue 1 enters the execution phase, and the processes of the message queue 2 and the message queue 3 enter a waiting phase, and the message transmission device obtains the linked list, the queue mark, and the last block corresponding to the queue 1 of the message. Count-i, the address of the first chunk, the address of the second chunk, and the address of the last chunk, and obtain the packet slice corresponding to the slice in the linked list.
具体的,链表指针指向首个组块的地址,依次使用该进程中报文所在的链表首个组块的所有切片,同时,链表指针指向第二个组块的地址;依次使用第二个组块的所有切片,同时,链表指针指向第三个组块的地址;使用第三个组块的所有切片,依次类推,直到末个组块的切片。Specifically, the linked list pointer points to the address of the first chunk, and sequentially uses all the slices of the first chunk of the linked list in the process, and the linked list pointer points to the address of the second chunk; the second group is used in sequence. All slices of the block, at the same time, the linked list pointer points to the address of the third chunk; all slices of the third chunk are used, and so on, until the slice of the last chunk.
这里,使用任一个组块的切片可以具体包括:假设count-i用于在报文输入报文队列时,记录组块中与报文切片对应的切片个数,为了便于理解,相应的设置count-o,count-o用于在报文输出报文队列时,记录组块中已使用切片的个数。链表指针指向该组块的地址之后,根据基地址和count-o、指定值,计算出下一个切片的偏移地址,该偏移地址等于count-o乘以1,根据该偏移地址,获取出下一个切片,从而获取切片对应的报文切片的地址,输出报文切片。对于末个组块,当末个组块的count-o等于预先保存的末个组块的count-i时,报文队列中取出的报文切片就是最后的报文切片,此报文队列输出报文完毕,这里,count-o是指当报文输出报文队列时,记录组块中与报文切片对应的切片个数,也就是当前使的切片的序号数。Here, the use of the slice of any one of the chunks may specifically include: assuming that count-i is used to record the number of slices corresponding to the packet slice in the chunk when the packet is input into the packet queue, for the purpose of understanding, the corresponding setting count -o,count-o is used to record the number of used slices in the chunk when the message is output. After the linked list pointer points to the address of the chunk, the offset address of the next slice is calculated according to the base address and the count-o, the specified value, and the offset address is equal to count-o multiplied by 1, according to the offset address, The next slice is obtained, so that the address of the packet slice corresponding to the slice is obtained, and the message slice is output. For the last chunk, when the count-o of the last chunk is equal to the count-i of the last chunk saved in advance, the packet slice taken in the message queue is the last packet slice, and the packet queue output is After the message is completed, here, count-o refers to the number of slices corresponding to the packet slice in the block when the message is output, that is, the number of the slice currently being used.
值得说明的是,本发明实施例提供的偏移地址的算法不限于此,每个切片的偏移地址同样可以为上一个切片的偏移地址加上指定值。这里,本实施例中确定报文队列输出完成,还可以包括:队列标识为空;或链表中每个组块的count-o都为0。It should be noted that the algorithm for the offset address provided by the embodiment of the present invention is not limited thereto, and the offset address of each slice may also be the offset address of the previous slice plus a specified value. Here, in this embodiment, determining that the message queue output is completed may further include: the queue identifier is empty; or the count-o of each chunk in the linked list is 0.
步骤304、报文队列2的进程进入执行阶段,报文队列3进入等待阶段,报文传输装置根据获取报文队列2对应的链表、队列标记和末个组块的count-i、首个组块的地址、第二个组块的地址和末个组块的地址,获取链表 中切片对应的报文切片。Step 304: The process of the message queue 2 enters the execution phase, and the message queue 3 enters the waiting phase. The message transmission device obtains the linked list corresponding to the queue 2 of the message queue, the queue mark, and the count-i and the first group of the last block. The address of the block, the address of the second chunk, and the address of the last chunk, get the linked list The slice corresponding to the middle slice.
步骤305、报文队列3的进程进入执行阶段,报文传输装置根据获取报文队列3对应的链表、队列标记和末个组块的count-i、首个组块的地址、第二个组块的地址和末个组块的地址,获取链表中切片对应的报文切片。Step 305: The process of the message queue 3 enters an execution phase, and the message transmission device obtains the link table corresponding to the message queue 3, the queue mark, the count-i of the last chunk, the address of the first chunk, and the second group. The address of the block and the address of the last chunk are obtained, and the packet slice corresponding to the slice in the linked list is obtained.
本发明实施例提供的进程的具体执行顺序如图6所示。值得说明的是,步骤303至305在报文输出所使用的方法相同,因此,本实施例只在步骤303中详述,步骤304和步骤305中就不在复述;一般情况下,报文输出报文队列完毕,相应的进程就被释放,但是当如下几种情况发生,相应的进程将会排在之前所有队列的后面,等待下次调用:队列非空,即队列深度不为0;或队列所在端口不处于流控状态;或进程没有占用满。The specific execution sequence of the process provided by the embodiment of the present invention is shown in FIG. 6. It should be noted that the methods used in the output of the message are the same in steps 303 to 305. Therefore, the embodiment is only described in detail in step 303, and is not repeated in steps 304 and 305. In general, the message is output. After the queue is completed, the corresponding process is released, but when the following situations occur, the corresponding process will be queued behind all previous queues, waiting for the next call: the queue is not empty, that is, the queue depth is not 0; or the queue The port is not in the flow control state; or the process is not full.
实施例四Embodiment 4
本发明实施例提供一种报文传输装置40,如图7所示,该装置40可以包括:The embodiment of the present invention provides a message transmission device 40. As shown in FIG. 7, the device 40 may include:
获取链表单元401,用于报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应。The obtaining linked list unit 401 is configured to: when the message queue outputs the message, obtain a linked list corresponding to the message queue established when the message is input into the message queue, where the linked list includes one or more chunks. Each chunk includes one or more slices that correspond one-to-one with the address of the message slice in the message queue.
获取地址单元402,用于根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数。The obtaining address unit 402 is configured to sequentially acquire a slice from the i-th chunk according to an address of the i-th chunk pointed to by the linked list pointer, where i is a positive integer.
获取报文单元403,用于根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文切片,并将所述链表指针指向第i+1个组块的地址。The obtaining message unit 403 is configured to output the message slice from the message queue according to the address of the message slice corresponding to each slice, and point the linked list pointer to the address of the i+1th block.
相较于现有技术,本发明实施例可以在获取当前组块的切片的同时,链表指针指向下一个组块的地址,因此,当前组块中切片使用完成之后,链表指针已经指向下一个组块的地址,下一个组块中的切片就可以立刻被使用,无需浪费几个时钟周期来等待指针指向下一个组块的地址,这样, 减少了报文队列输出所浪费的时间,保证了使用各个组块中切片的连续性,从而解决了均匀输出队列的问题。Compared with the prior art, the embodiment of the present invention can obtain the slice of the current chunk, and the linked list pointer points to the address of the next chunk. Therefore, after the slice is used in the current chunk, the linked list pointer has already pointed to the next group. The address of the block, the slice in the next block can be used immediately, without wasting several clock cycles waiting for the pointer to point to the address of the next block, thus, The time wasted by the message queue output is reduced, and the continuity of the slices in each block is ensured, thereby solving the problem of uniform output queue.
进一步的,所述获取切片单元403具体用于:Further, the acquiring slice unit 403 is specifically configured to:
获取基地址,所述基地址是每个组块的偏移地址;Obtaining a base address, the base address being an offset address of each chunk;
根据所述基地址,依次使用所述第i个组块中的每个切片,其中,所述第i个组块中第j个切片的偏移地址等于基地址加上所述j与指定值的积,所述j是正整数。Determining, according to the base address, each slice in the i-th chunk, wherein an offset address of the j-th slice in the i-th chunk is equal to a base address plus the j and a specified value Product, the j is a positive integer.
优选的,在同一链表中,每个组块的切片个数相同。Preferably, in the same linked list, the number of slices per block is the same.
进一步的,如图8所示,所述装置40还包括:Further, as shown in FIG. 8, the device 40 further includes:
建立单元404,用于建立与所述报文队列对应的一条所述链表。The establishing unit 404 is configured to establish one of the linked lists corresponding to the message queue.
保存单元405,用于保存所述链表的每个组块中的切片个数、所述末个组块中已占用的切片个数和所述队列标记,所述队列标记表示所述报文队列是否列存储报文。a saving unit 405, configured to save the number of slices in each chunk of the linked list, the number of occupied slices in the last chunk, and the queue tag, where the queue tag indicates the message queue Whether to store the message.
进一步的,所述建立单元404具体用于:Further, the establishing unit 404 is specifically configured to:
若所述报文队列未存储报文,则生成一条所述链表,所述链表包括一个组块;将分配给所述报文队列的第一缓存区域的首节点的地址保存为所述链表的首个组块的地址和末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the message queue does not store a message, generate a linked list, the linked list includes a chunk; and save an address of a first node of the first cache area allocated to the packet queue as the linked list The address of the first chunk and the address of the last chunk; the address of the packet slice stored in the message queue is sequentially corresponding to the slice of the linked list;
若所述报文队列存储有报文,则判断所述链表中是否存在无对应信息的切片;If the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
若所述链表中存在无对应信息的切片,则将存储至所述报文队列的报文切片的地址依次与所述无对应信息的切片相对应;If there is a slice with no corresponding information in the linked list, the address of the packet slice stored in the message queue is sequentially corresponding to the slice without the corresponding information;
若所述链表中不存在无对应信息的切片,则判断所述链表是否只包括一个组块;If there is no slice in the linked list without corresponding information, it is determined whether the linked list includes only one chunk;
若所述链表只包括一个组块,则生成一个新的末个组块,将分配给所 述报文队列的第二空闲缓存的首节点地址保存为所述第二个组块的地址和所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the linked list includes only one chunk, a new last chunk is generated and will be assigned to the The first node address of the second free buffer of the message queue is saved as the address of the second chunk and the address of the new last chunk; the address of the packet slice to be stored in the message queue Corresponding to the slice of the linked list in turn;
若所述链表包括多个组块,则生成一个新的末个组块,将分配给所述报文队列的第三空闲缓存的首节点地址保存为所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应。If the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk; The addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
进一步的,当多个报文队列输出报文时,Further, when multiple message queues output messages,
所述获取链表单元401,还用于获取与所述多个报文队列一一对应的链表;The obtaining linked list unit 401 is further configured to acquire a linked list that is in one-to-one correspondence with the plurality of message queues;
所述获取报文单元403,还用于按照所述多个报文队列的输出顺序,依次从所述多个报文队列输出报文。The acquiring message unit 403 is further configured to sequentially output the message from the plurality of message queues according to the output order of the plurality of message queues.
在实际应用中,所述获取链表单元401、获取地址单元402、获取报文单元403、建立单元404和保存单元405均可由位于终端中的中央处理器(Central Processing Unit,CPU)、微处理器(Micro Processor Unit,MPU)、数字信号处理器(Digital Signal Processor,DSP)、或现场可编程门阵列(Field Programmable Gate Array,FPGA)等实现。In an actual application, the acquiring linked list unit 401, the obtaining address unit 402, the obtaining message unit 403, the establishing unit 404, and the saving unit 405 may each be a central processing unit (CPU) and a microprocessor located in the terminal. (Micro Processor Unit, MPU), Digital Signal Processor (DSP), or Field Programmable Gate Array (FPGA).
基于上述多个实施例提供的场景下,本发明实施例还能够提供一种计算机可读存储介质,该存储介质包括一组指令,当执行所述指令时,引起至少一个处理器执行包括以下的操作:Based on the scenario provided by the foregoing multiple embodiments, the embodiment of the present invention can further provide a computer readable storage medium, where the storage medium includes a set of instructions, when executed, causing at least one processor to execute the following operating:
报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应;When the message queue outputs a message, a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;
根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数;Obtaining a slice sequentially from the i-th chunk according to an address of the i-th chunk pointed by the linked list pointer, wherein the i is a positive integer;
根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文 切片,并将所述链表指针指向第i+1个组块的地址。Outputting the message from the message queue according to an address of a packet slice corresponding to each slice Slice and point the linked list pointer to the address of the i+1th chunk.
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。 The above is only the preferred embodiment of the present invention and is not intended to limit the scope of the present invention.

Claims (13)

  1. 一种报文传输方法,所述方法包括:A message transmission method, the method comprising:
    报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应;When the message queue outputs a message, a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;
    根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数;Obtaining a slice sequentially from the i-th chunk according to an address of the i-th chunk pointed by the linked list pointer, wherein the i is a positive integer;
    根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文切片,并将所述链表指针指向第i+1个组块的地址。And outputting the message slice from the message queue according to an address of a message slice corresponding to each slice, and pointing the linked list pointer to an address of the i+1th block.
  2. 根据权利要求1所述的方法,其中,所述根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片包括:The method according to claim 1, wherein the sequentially acquiring the slices from the i-th chunk according to the address of the i-th chunk pointed to by the linked list pointer comprises:
    获取基地址,所述基地址是每个组块的偏移地址;Obtaining a base address, the base address being an offset address of each chunk;
    根据所述基地址依次使用所述第i个组块中的每个切片,其中,所述第i个组块中第j个切片的偏移地址等于基地址加上所述j与指定值的积,所述j是正整数。And each of the i-th chunks is sequentially used according to the base address, wherein an offset address of the j-th slice in the i-th chunk is equal to a base address plus the j and a specified value Product, the j is a positive integer.
  3. 根据权利要求2所述的方法,其中,在同一链表中,每个组块的切片个数相同。The method of claim 2, wherein the number of slices per block is the same in the same linked list.
  4. 根据权利要求1至3任一项所述的方法,其中,在所述报文队列输出报文之前,报文输入所述报文队列之时,所述方法还包括:The method according to any one of claims 1 to 3, wherein, when the message is input into the message queue before the message queue outputs the message, the method further includes:
    建立与所述报文队列对应的一条所述链表;Establishing one of the linked lists corresponding to the message queue;
    保存所述链表的每个组块中的切片个数和所述末个组块中已占用的切片个数。The number of slices in each chunk of the linked list and the number of slices occupied in the last chunk are saved.
  5. 根据权利要求4所述的方法,其中,所述建立与所述报文队列对应的一条所述链表包括: The method according to claim 4, wherein said establishing said one linked list corresponding to said message queue comprises:
    若所述报文队列未存储报文,则生成一条所述链表,所述链表包括一个组块;将分配给所述报文队列的第一缓存区域的首节点的地址保存为所述链表的首个组块的地址和末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the message queue does not store a message, generate a linked list, the linked list includes a chunk; and save an address of a first node of the first cache area allocated to the packet queue as the linked list The address of the first chunk and the address of the last chunk; the address of the packet slice stored in the message queue is sequentially corresponding to the slice of the linked list;
    若所述报文队列存储有报文,则判断所述链表中是否存在无对应信息的切片;If the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
    若所述链表中存在无对应信息的切片,则将存储至所述报文队列的报文切片的地址依次与所述无对应信息的切片相对应;If there is a slice with no corresponding information in the linked list, the address of the packet slice stored in the message queue is sequentially corresponding to the slice without the corresponding information;
    若所述链表中不存在无对应信息的切片,则判断所述链表是否只包括一个组块;If there is no slice in the linked list without corresponding information, it is determined whether the linked list includes only one chunk;
    若所述链表只包括一个组块,则生成一个新的末个组块,将分配给所述报文队列的第二空闲缓存的首节点地址保存为所述第二个组块的地址和所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the linked list includes only one chunk, a new last chunk is generated, and the address of the head node of the second free cache allocated to the message queue is saved as the address and location of the second chunk. Addressing the address of the new last chunk; the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list;
    若所述链表包括多个组块,则生成一个新的末个组块,将分配给所述报文队列的第三空闲缓存的首节点地址保存为所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应。If the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk; The addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
  6. 根据权利要求1所述的方法,其中,当多个报文队列输出报文时,所述方法还包括:The method of claim 1, wherein when the plurality of message queues output the message, the method further comprises:
    获取与所述多个报文队列一一对应的链表;Obtaining a linked list that is in one-to-one correspondence with the plurality of message queues;
    按照所述多个报文队列的输出顺序,依次从所述多个报文队列输出报文。And outputting the packets from the plurality of message queues in sequence according to the output order of the plurality of message queues.
  7. 一种报文传输装置,所述装置包括:A message transmission device, the device comprising:
    获取链表单元,配置为报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多 个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应;Acquiring a linked list unit, configured to output a message in the message queue, obtain a linked list corresponding to the message queue established when the message is input into the message queue, and the linked list includes one or more Blocks, each chunk comprising one or more slices, the slices being in one-to-one correspondence with addresses of message slices in the message queue;
    获取地址单元,配置为根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数;Obtaining an address unit, configured to sequentially acquire a slice from the i-th chunk according to an address of the i-th chunk pointed to by the linked list pointer, where i is a positive integer;
    获取报文单元,配置为根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文切片,并将所述链表指针指向第i+1个组块的地址。Obtaining a message unit, configured to output the message slice from the message queue according to an address of a message slice corresponding to each slice, and point the linked list pointer to an address of the i+1th block.
  8. 根据权利要求7所述的装置,其中,所述获取切片单元,配置为:The apparatus according to claim 7, wherein the acquisition slice unit is configured to:
    获取基地址,所述基地址是每个组块的偏移地址;Obtaining a base address, the base address being an offset address of each chunk;
    根据所述基地址,依次使用所述第i个组块中的每个切片,其中,所述第i个组块中第j个切片的偏移地址等于基地址加上所述j与指定值的积,所述j是正整数。Determining, according to the base address, each slice in the i-th chunk, wherein an offset address of the j-th slice in the i-th chunk is equal to a base address plus the j and a specified value Product, the j is a positive integer.
  9. 根据权利要求8所述的装置,其中,在同一链表中,每个组块的切片个数相同。The apparatus according to claim 8, wherein the number of slices per block is the same in the same linked list.
  10. 根据权利要求7至9任一项所述的装置,其中,所述装置还包括:The device according to any one of claims 7 to 9, wherein the device further comprises:
    建立单元,配置为建立与所述报文队列对应的一条所述链表;Establishing a unit, configured to establish one of the linked lists corresponding to the message queue;
    保存单元,配置为保存所述链表的每个组块中的切片个数和所述末个组块中已占用的切片个数。And a saving unit configured to save the number of slices in each chunk of the linked list and the number of slices occupied in the last chunk.
  11. 根据权利要求10所述的装置,其中,所述建立单元,配置为,The apparatus according to claim 10, wherein said establishing unit is configured to
    若所述报文队列未存储报文,则生成一条所述链表,所述链表包括一个组块;将分配给所述报文队列的第一缓存区域的首节点的地址保存为所述链表的首个组块的地址和末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the message queue does not store a message, generate a linked list, the linked list includes a chunk; and save an address of a first node of the first cache area allocated to the packet queue as the linked list The address of the first chunk and the address of the last chunk; the address of the packet slice stored in the message queue is sequentially corresponding to the slice of the linked list;
    若所述报文队列存储有报文,则判断所述链表中是否存在无对应信息的切片;If the message queue stores a message, it is determined whether there is a slice in the linked list that has no corresponding information;
    若所述链表中存在无对应信息的切片,则将存储至所述报文队列的报 文切片的地址依次与所述无对应信息的切片相对应;If there is a slice in the linked list without corresponding information, the report to the message queue is stored The address of the slice corresponds to the slice without the corresponding information;
    若所述链表中不存在无对应信息的切片,则判断所述链表是否只包括一个组块;If there is no slice in the linked list without corresponding information, it is determined whether the linked list includes only one chunk;
    若所述链表只包括一个组块,则生成一个新的末个组块,将分配给所述报文队列的第二空闲缓存的首节点地址保存为所述第二个组块的地址和所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应;If the linked list includes only one chunk, a new last chunk is generated, and the address of the head node of the second free cache allocated to the message queue is saved as the address and location of the second chunk. Addressing the address of the new last chunk; the address of the packet slice stored in the packet queue is sequentially corresponding to the slice of the linked list;
    若所述链表包括多个组块,则生成一个新的末个组块,将分配给所述报文队列的第三空闲缓存的首节点地址保存为所述新的末个组块的地址;将存储至所述报文队列的报文切片的地址依次与所述链表的切片对应。If the linked list includes multiple chunks, generate a new last chunk, and save the first node address of the third free cache allocated to the message queue as the address of the new last chunk; The addresses of the message slices stored in the message queue are sequentially corresponding to the slices of the linked list.
  12. 根据权利要求7所述的装置,其中,当多个报文队列输出报文时,所述获取链表单元,配置为获取与所述多个报文队列一一对应的链表;The device according to claim 7, wherein, when a plurality of message queues output a message, the acquiring linked list unit is configured to acquire a linked list that is in one-to-one correspondence with the plurality of message queues;
    所述获取报文单元,配置为按照所述多个报文队列的输出顺序,依次从所述多个报文队列输出报文。The acquiring the message unit is configured to output the message from the plurality of message queues in sequence according to the output order of the plurality of message queues.
  13. 一种计算机可读存储介质,该存储介质包括一组指令,当执行所述指令时,引起至少一个处理器执行包括以下的操作:A computer readable storage medium comprising a set of instructions that, when executed, cause at least one processor to perform operations comprising:
    报文队列输出报文时,获取在报文输入所述报文队列时建立的一条与所述报文队列对应的链表,所述链表包括一个或多个组块,每个组块包括一个或多个切片,所述切片与所述报文队列中的报文切片的地址一一对应;When the message queue outputs a message, a linked list corresponding to the message queue established when the message is input into the message queue is obtained, and the linked list includes one or more chunks, and each chunk includes one or a plurality of slices, the slices being in one-to-one correspondence with addresses of the message slices in the message queue;
    根据所述链表指针指向的第i个组块的地址,从所述第i个组块中依次获取切片,所述i是正整数;Obtaining a slice sequentially from the i-th chunk according to an address of the i-th chunk pointed by the linked list pointer, wherein the i is a positive integer;
    根据各切片对应的报文切片的地址,从所述报文队列中输出所述报文切片,并将所述链表指针指向第i+1个组块的地址。 And outputting the message slice from the message queue according to an address of a message slice corresponding to each slice, and pointing the linked list pointer to an address of the i+1th block.
PCT/CN2016/083569 2015-06-15 2016-05-26 Message transmission method and device, and computer-readable storage medium WO2016202158A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510331181.0A CN106330741B (en) 2015-06-15 2015-06-15 Message transmission method and device
CN201510331181.0 2015-06-15

Publications (1)

Publication Number Publication Date
WO2016202158A1 true WO2016202158A1 (en) 2016-12-22

Family

ID=57544945

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/083569 WO2016202158A1 (en) 2015-06-15 2016-05-26 Message transmission method and device, and computer-readable storage medium

Country Status (2)

Country Link
CN (1) CN106330741B (en)
WO (1) WO2016202158A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113595932A (en) * 2021-08-06 2021-11-02 上海金仕达软件科技有限公司 Method for processing data out-of-order message and special integrated circuit
CN118509399A (en) * 2024-07-22 2024-08-16 格创通信(浙江)有限公司 Message processing method and device, electronic equipment and storage medium

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107644054B (en) * 2017-07-26 2019-02-19 北京海泰方圆科技股份有限公司 Information display method and device
WO2019061270A1 (en) * 2017-09-29 2019-04-04 深圳市大疆创新科技有限公司 Data caching device and control method therefor, data processing chip, and data processing system
CN114244917B (en) * 2020-08-31 2023-06-02 华为技术有限公司 Data transmission method, device and system
CN115756296A (en) * 2021-09-02 2023-03-07 深圳市中兴微电子技术有限公司 Cache management method and device, control program and controller

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030095558A1 (en) * 2001-11-16 2003-05-22 Force 10 Networks, Inc. High efficiency data buffering in a computer network device
TW200305076A (en) * 2001-12-21 2003-10-16 Agere Systems Inc Methods and apparatus for forming linked list queue using chunk-based structure
CN101009646A (en) * 2006-12-22 2007-08-01 清华大学 Dynamic sharing device of physical queue based on the stream queue
US20080104313A1 (en) * 1999-09-24 2008-05-01 Tam-Anh Chu Multiple-Buffer Queueing of Data Packets with High Throughput Rate

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101635682B (en) * 2009-08-05 2011-12-07 中兴通讯股份有限公司 Storage management method and storage management system
CN102130833A (en) * 2011-03-11 2011-07-20 中兴通讯股份有限公司 Memory management method and system of traffic management chip chain tables of high-speed router

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080104313A1 (en) * 1999-09-24 2008-05-01 Tam-Anh Chu Multiple-Buffer Queueing of Data Packets with High Throughput Rate
US20030095558A1 (en) * 2001-11-16 2003-05-22 Force 10 Networks, Inc. High efficiency data buffering in a computer network device
TW200305076A (en) * 2001-12-21 2003-10-16 Agere Systems Inc Methods and apparatus for forming linked list queue using chunk-based structure
CN101009646A (en) * 2006-12-22 2007-08-01 清华大学 Dynamic sharing device of physical queue based on the stream queue

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113595932A (en) * 2021-08-06 2021-11-02 上海金仕达软件科技有限公司 Method for processing data out-of-order message and special integrated circuit
CN113595932B (en) * 2021-08-06 2024-05-14 上海金仕达软件科技股份有限公司 Processing method of data disorder message and application specific integrated circuit
CN118509399A (en) * 2024-07-22 2024-08-16 格创通信(浙江)有限公司 Message processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN106330741A (en) 2017-01-11
CN106330741B (en) 2020-04-24

Similar Documents

Publication Publication Date Title
WO2016202158A1 (en) Message transmission method and device, and computer-readable storage medium
US11876701B2 (en) System and method for facilitating operation management in a network interface controller (NIC) for accelerators
JP6881861B2 (en) Packet processing method and equipment
CN105511954B (en) Message processing method and device
WO2016179968A1 (en) Queue management method and device, and storage medium
US10193831B2 (en) Device and method for packet processing with memories having different latencies
JP5795592B2 (en) Apparatus and method for receiving and storing data packets controlled by a central controller
US10742555B1 (en) Network congestion detection and resolution
US10331613B2 (en) Methods for enabling direct memory access (DMA) capable devices for remote DMA (RDMA) usage and devices therof
US9639403B2 (en) Receive-side scaling in a computer system using sub-queues assigned to processing cores
US10701002B1 (en) System and method for memory deallocation
CN108028781B (en) Techniques for network round-trip time estimation
CN102480430A (en) Method and device for realizing message order preservation
US9401879B1 (en) Systems and methods for sending and receiving information via a network device
CN111026324B (en) Updating method and device of forwarding table entry
WO2019024763A1 (en) Message processing
CN108702370A (en) Multithread for network technology interweaves
WO2020108568A1 (en) Information processing method and device and computer storage medium
US11671382B2 (en) Technologies for coordinating access to data packets in a memory
US9268621B2 (en) Reducing latency in multicast traffic reception
CN113986969A (en) Data processing method and device, electronic equipment and storage medium
WO2024021801A1 (en) Packet forwarding apparatus and method, communication chip, and network device
Suen et al. Affordable avionic networks with Gigabit Ethernet assessing the suitability of commercial components for airborne use
US20220217098A1 (en) Streaming communication between devices
WO2016095340A1 (en) Method and device for determining that data is sent successfully

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16810899

Country of ref document: EP

Kind code of ref document: A1