CN106330741B - Message transmission method and device - Google Patents

Message transmission method and device Download PDF

Info

Publication number
CN106330741B
CN106330741B CN201510331181.0A CN201510331181A CN106330741B CN 106330741 B CN106330741 B CN 106330741B CN 201510331181 A CN201510331181 A CN 201510331181A CN 106330741 B CN106330741 B CN 106330741B
Authority
CN
China
Prior art keywords
message
chunk
linked list
slices
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510331181.0A
Other languages
Chinese (zh)
Other versions
CN106330741A (en
Inventor
王斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sanechips Technology Co Ltd
Original Assignee
Sanechips Technology Co Ltd
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 Sanechips Technology Co Ltd filed Critical Sanechips Technology Co Ltd
Priority to CN201510331181.0A priority Critical patent/CN106330741B/en
Priority to PCT/CN2016/083569 priority patent/WO2016202158A1/en
Publication of CN106330741A publication Critical patent/CN106330741A/en
Application granted granted Critical
Publication of CN106330741B publication Critical patent/CN106330741B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Landscapes

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

Abstract

The invention discloses a message transmission method, which comprises the following steps: when a message queue outputs a message, acquiring a linked list which is established when the message is input into the message queue and corresponds to the message queue, wherein the linked list comprises one or more chunks, each chunk comprises one or more slices, and the slices correspond to addresses of the message slices in the message queue one by one; sequentially acquiring slices from an ith chunk according to the address of the ith chunk pointed by the linked list pointer, wherein i is a positive integer; and outputting the message slices from the message queue according to the addresses of the message slices corresponding to the slices, and pointing the linked list pointer to the address of the (i + 1) th chunk. The invention also discloses a message transmission device.

Description

Message transmission method and device
Technical Field
The present invention relates to a management technology of packet forwarding devices, and in particular, to a method and an apparatus for packet transmission.
Background
With the rapid development of the internet, the network bandwidth increases rapidly, and the interface speed and queue number of the packet forwarding device, especially the high-end router, also increases rapidly. In order to adapt to the speed of interface and the speed of increasing the number of queues, a network processor chip of a general router is internally provided with a special flow management system to manage high-speed data flow, and then a message cache is processed and output.
In the prior art, a storage chip is hung outside a chip to store data, a chain table structure is adopted inside the chip to manage, the head and tail nodes of the chain table are recorded in advance by using each node of the chain table to correspond to the storage space of each message slice, the inherent read delay of intermediate nodes and hardware except the head and tail nodes is delayed, the current chain table node is used as an address to read the next node, and a plurality of clock cycles are needed until the data content stored in the address is really read, and the chain table cannot be effectively used in the period of time. Therefore, the prior art cannot solve the problem of uniform dequeuing in the case of adopting a singly linked list structure.
Disclosure of Invention
In order to solve the existing technical problem, embodiments of the present invention mainly provide a method and an apparatus for packet transmission, which can solve the problem of uniform dequeuing under the condition of adopting a single linked list structure.
The technical scheme of the embodiment of the invention is realized as follows:
in a first aspect, an embodiment of the present invention provides a packet transmission method, where the method includes:
when a message queue outputs a message, acquiring a linked list which is established when the message is input into the message queue and corresponds to the message queue, wherein the linked list comprises one or more chunks, each chunk comprises one or more slices, and the slices correspond to addresses of the message slices in the message queue one by one;
sequentially acquiring slices from an ith chunk according to the address of the ith chunk pointed by the linked list pointer, wherein i is a positive integer;
and outputting the message slices from the message queue according to the addresses of the message slices corresponding to the slices, and pointing the linked list pointer to the address of the (i + 1) th chunk.
With reference to the first aspect, in a first implementation manner, the sequentially obtaining slices from an ith chunk according to an address of the ith chunk pointed by the linked list pointer includes:
obtaining a base address, wherein the base address is an offset address of each chunk;
sequentially using each slice in the ith chunk according to the base address, wherein the offset address of the jth slice in the ith chunk is equal to the base address plus the product of j, which is a positive integer, and a specified value.
In combination with the first implementable manner, in the second implementable manner, the number of slices of each chunk is the same in the same linked list.
With reference to the first aspect, any one of the first and second implementable manners, in a third implementable manner, when a packet is input into the packet queue before the packet queue outputs the packet, the method further includes:
establishing a linked list corresponding to the message queue;
and saving the number of slices in each chunk of the linked list and the number of slices occupied in the last chunk.
With reference to the third implementable manner, in a fourth implementable manner, the establishing of one linked list corresponding to the packet queue includes:
if the message queue does not store messages, generating a linked list, wherein the linked list comprises a chunk; storing the address of the first node of the first cache region distributed to the message queue as the address of the first chunk and the address of the last chunk of the linked list; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the message queue stores messages, judging whether the linked list has a slice without corresponding information;
if the linked list has the slice without the corresponding information, the addresses of the message slices stored in the message queue are sequentially corresponding to the slice without the corresponding information;
if the linked list does not have a slice without corresponding information, judging whether the linked list only comprises one chunk;
if the linked list only comprises one chunk, generating a new last chunk, and storing the first node address of a second idle buffer distributed to the message queue as the address of the second chunk and the address of the new last chunk; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the linked list comprises a plurality of chunks, generating a new last chunk, and storing the address of the head node of a third idle buffer allocated to the message queue as the address of the new last chunk; and sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list.
With reference to the first aspect, in a fifth implementation manner, when a plurality of packet queues output packets, the method further includes:
obtaining linked lists corresponding to the plurality of message queues one by one;
and outputting the messages from the message queues in sequence according to the output sequence of the message queues.
In a second aspect, an apparatus for packet transmission according to an embodiment of the present invention includes:
the link list acquisition unit is used for acquiring a link list which is established when a message is input into the message queue and corresponds to the message queue when the message is output from the message queue, wherein the link list comprises one or more chunks, each chunk comprises one or more slices, and the slices correspond to addresses of the message slices in the message queue one by one;
an address obtaining unit, configured to sequentially obtain slices from an ith chunk according to an address of the ith chunk pointed by the linked list pointer, where i is a positive integer;
and the message acquisition unit is used for outputting the message slices from the message queue according to the addresses of the message slices corresponding to the slices, and pointing the linked list pointer to the address of the (i + 1) th chunk.
With reference to the second aspect, in a first implementable manner, the obtaining slicing unit is specifically configured to:
obtaining a base address, wherein the base address is an offset address of each chunk;
sequentially using each slice in the ith chunk according to the base address, wherein the offset address of the jth slice in the ith chunk is equal to the base address plus the product of j and a specified value, wherein j is a positive integer.
In combination with the first implementable manner, in the second implementable manner, the number of slices of each chunk is the same in the same linked list.
With reference to the second aspect, any one of the first and second realizations, the apparatus further includes:
the establishing unit is used for establishing the linked list corresponding to the message queue;
and the storage unit is used for storing the number of the slices in each chunk of the linked list and the number of the occupied slices in the last chunk.
With reference to the third implementable manner, in a fourth implementable manner, the establishing unit is specifically configured to:
if the message queue does not store messages, generating a linked list, wherein the linked list comprises a chunk; storing the address of the first node of the first cache region distributed to the message queue as the address of the first chunk and the address of the last chunk of the linked list; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the message queue stores messages, judging whether the linked list has a slice without corresponding information;
if the linked list has the slice without the corresponding information, the addresses of the message slices stored in the message queue are sequentially corresponding to the slice without the corresponding information;
if the linked list does not have a slice without corresponding information, judging whether the linked list only comprises one chunk;
if the linked list only comprises one chunk, generating a new last chunk, and storing the first node address of a second idle buffer distributed to the message queue as the address of the second chunk and the address of the new last chunk; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the linked list comprises a plurality of chunks, generating a new last chunk, and storing the address of the head node of a third idle buffer allocated to the message queue as the address of the new last chunk; and sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list.
In a fifth implementable manner, in combination with the second aspect, when multiple message queues output messages,
the link list acquiring unit is further configured to acquire link lists corresponding to the plurality of message queues one to one;
the message obtaining unit is further configured to sequentially output messages from the plurality of message queues according to the output order of the plurality of message queues.
When a message is output from a message queue, a linked list corresponding to the message queue, which is established when the message is input into the message queue, is obtained, wherein the linked list comprises one or more chunks, each chunk comprises one or more slices, and the slices correspond to addresses of the message slices in the message queue one by one; sequentially acquiring each slice of the chunk from the ith chunk according to the address of the ith chunk pointed by the linked list pointer; and outputting the message slices from the message queue according to the addresses of the message slices corresponding to the slices, and pointing the linked list pointer to the address of the (i + 1) th chunk. Therefore, after the slice in the current chunk is used, the linked list pointer already points to the address of the next chunk, and the slice in the next chunk can be used immediately without wasting a plurality of clock cycles to wait for the pointer to point to the address of the next chunk; therefore, the time wasted by message queue output is reduced, the continuity of using the slices in each chunk is ensured, and the problem of uniform output queue is solved.
Drawings
Fig. 1 is a flowchart of a message transmission method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a linked list provided by an embodiment of the present invention;
fig. 3 is a flowchart of another message transmission method according to an embodiment of the present invention;
fig. 4 is a flowchart of another message transmission method according to an embodiment of the present invention;
fig. 5 is a flowchart of another message transmission method according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating a process performed by a 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 another message transmission apparatus according to an embodiment of the present invention.
Detailed Description
Example one
An embodiment of the present invention provides a packet transmission method, and as shown in fig. 1, the method may include:
step 101, when a message queue outputs a message, acquiring a linked list corresponding to the message queue, which is established when the message is input into the message queue, wherein the linked list comprises one or more chunks, each chunk comprises one or more slices, and the slices correspond to addresses of the message slices in the message queue one by one.
Here, the linked list stores the arrangement order and position of the messages of the input message queue, each chunk corresponds to a segment of message slice, for example, the message input message queue has a linked list corresponding to one linked list, the linked list is as shown in fig. 2, it is assumed that the message is divided into 16 message slices, the linked list includes three chunks, each chunk includes six slices, wherein, a slice with a slash indicates that the addresses with message slices correspond, and a slice without a slash indicates that the addresses without message slices correspond. The 6 slices of the chunk 1 correspond to the addresses of the first 6 message slices in sequence, the slices of the chunk 2 correspond to the addresses of the 7 th to 12 th message slices in sequence, and the slices of the chunk 3 correspond to the addresses of the 13 th to 16 th message slices in sequence. Here, the chunks described in the present embodiment are the same as the nodes of the linked list in the related art.
And step 102, sequentially acquiring each slice of the chunk from the ith chunk according to the address of the ith chunk pointed by the linked list pointer.
Here, i is a positive integer.
Specifically, a base address is obtained, where the base address is an offset address of each chunk; sequentially using each slice in the ith chunk according to the base address, wherein the offset address of the jth slice in the ith chunk is equal to the base address plus the product of j, which is a positive integer, and a specified value. Here, the linked list may include three pointers, a head pointer, a tail pointer, and a linked list pointer. The head 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 to be used.
Preferably, the number of slices per chunk is the same in the same linked list. The preferred specified value of the embodiment of the present invention is 1 and the base address is 0. For example, the offset address of the 6 th slice of chunk 2 in fig. 2 is 0+6 × 1, i.e., 6.
And 103, outputting the message slices in the message queue according to the addresses of the message slices corresponding to the slices, and pointing the linked list pointer to the address of the (i + 1) th chunk.
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 message slice corresponding to the chunk 1 is outputting, the linked list pointer points to the 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 invention can obtain the slice of the current chunk and simultaneously point the linked list pointer to the address of the next chunk, so that after the slice in the current chunk is used, the linked list pointer already points to the address of the next chunk, the slice in the next chunk can be used immediately without wasting a plurality of clock cycles to wait for the pointer to point to the address of the next chunk, thus reducing the time wasted by message queue output, ensuring the continuity of using the slices in each chunk, and further solving the problem of uniform output queue.
Further, as shown in fig. 3, the method further includes:
step 100a, establishing a linked list corresponding to the message queue.
Specifically, if no message is stored in the message queue, a linked list is established, wherein the linked list comprises a chunk, the address of the first node of the first cache region allocated to the message queue is stored as the address of the first chunk and the address of the last chunk of the linked list, and the addresses of message slices stored in the message queue sequentially correspond to the slices of the linked list; if the message queue stores the messages, judging whether the linked list has a slice without corresponding information; if the linked list has the slice without the corresponding information, the addresses of the message slices stored in the message queue are sequentially corresponding to the slice without the corresponding information; if the linked list does not have the slice without the corresponding information, judging whether the linked list only comprises one chunk; if the linked list only comprises one chunk, generating a new last chunk, storing the first node address of a second idle buffer distributed to the message queue as the address of the second chunk and the address of the new last chunk, and sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list; if the linked list comprises a plurality of chunks, generating a new last chunk, saving the first node address of a third idle buffer allocated to the message queue as the address of the new last chunk, and sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list. Here, the first buffer area, the second buffer area, and the third buffer area are not particularly different, but are not necessarily the same buffer area to distinguish the three buffer areas.
And step 100b, saving the number of slices in each chunk of the linked list and the number of slices occupied in the last chunk.
Correspondingly, when the message is output to the 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, the number of slices occupied in the last chunk and the queue mark need to be obtained, when the queue is output initially, 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 1 st slice of the first chunk, the base address is obtained, the offset address of the 1 st slice is obtained through calculation, the 1 st slice of the first chunk is obtained, the address of the message slice corresponding to the 1 st slice is determined according to the 1 st slice, the message slice is input, the analogy is carried out in sequence until the last slice of the first chunk is obtained, meanwhile, the linked list pointer points to the address of the next chunk using the chunk, and the process of inputting the message slice is repeated, and stopping until the chunk corresponding to the message slice in the last chunk is obtained and the corresponding message is output.
Further, when the plurality of packet queues output packets, the method further includes: obtaining a linked list corresponding to a plurality of message queues one by one; and outputting the messages from the message queues in sequence according to the output sequence of the message queues. Therefore, the method provided by the embodiment of the invention can simultaneously acquire the linked list of each message queue and sequentially output the messages according to the sequence of the message queues, so that after one message queue outputs the message slices, the linked list of the next message queue does not need to be acquired, and the next message queue can directly output the message slices, thereby saving the time for acquiring the linked list, ensuring the output continuity of a plurality of message queues and meeting the requirement of uniform output.
Example two
The embodiment of the invention provides a message transmission method, which is applied to a message input message queue. The offset address of the ith slice of the chunk in 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 for recording the number of slices occupied in the chunk, that is, the number of sequence numbers of currently used slices when a message is input into a message queue. As shown in fig. 4, the method may include:
step 201, obtaining a queue identifier.
Here, the queue flag indicates whether the packet queue corresponding to the linked list stores a packet. Here, the queue identifier in the embodiment of the present invention is an empty flag, which indicates that no message is stored in the message queue or that a message has been output from the queue when the empty flag is 1, and indicates that a message is stored in the queue message when the empty flag is 0.
Step 202, judging whether the null flag is 1, if so, executing step 203; if not, go to step 204.
Step 203, if the empty flag is 1, generating a linked list, where the linked list includes a chunk, storing the address of the first node of the first cache region allocated to the packet queue as the address of the first chunk and the address of the last chunk of the linked list, setting count-i to 0, and setting the queue empty flag to non-empty.
Here, the linked list may include a plurality of chunks (chunk), each chunk includes the same number of slices (block), and each node of the linked list corresponds to a storage space of a slice in which the packet is stored. 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 empty flag is 0, determining whether count-i is equal to 0, if yes, executing step 205; if not, go to step 208.
When count-i is equal to 0, it indicates that no slice without corresponding information exists in the linked list. When the count-i is not equal to 0, the slice in one or more blocks in the linked list has no corresponding information.
Step 205, if count-i is equal to 0, determining whether the address of the first chunk of the linked list is equal to the address of the last chunk, if yes, executing step 206; if not, go to step 207.
Here, when the address of the first chunk of the linked list is equal to the address of the last chunk, it is indicated that the linked list includes only one chunk, and when the address of the first chunk of the linked list is not equal to the address of the last chunk, it is indicated that 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, a new last chunk is generated, the address of the first node of the second idle buffer allocated to the packet queue is stored as the address of the second chunk and the address of the new last chunk, and step 208 is executed.
Step 207, if the address of the first chunk of the linked list is not equal to the address of the last chunk, a new last chunk is generated, and the address of the first node of the third idle buffer allocated to the packet queue is stored as the address of the new last chunk.
And step 208, taking count-i as the offset address of each chunk, and sequentially corresponding the slice of the current chunk to the address of the message slice of the input message queue.
Step 209, judging whether a next message slice is input into the message queue, if so, executing step 204; if not, go to step 210.
Step 210, if no message slice is input into the message queue, storing the queue mark and the last chunk corresponding to the message slice.
Here, the no message slice input message queue indicates that the message input is complete.
It should be noted that, when each count-i is equal to the number of slices of each chunk, and further slices need to be used continuously, indicating that the slice of the current chunk is already occupied and the slice of the next slice needs to be occupied, at this time, count-i will be set to 0, and counting is started from the beginning.
EXAMPLE III
The embodiment of the present invention provides a message transmission method, which is used for implementing a plurality of message queues storing messages to output messages after a message in a message queue in the second embodiment is inputted, and assuming that after three message queues (a message queue 1, a message queue 2, and a message queue 3) request to output messages are received at the same time in the embodiment of the present invention, as shown in fig. 5, the method includes:
step 301, the message transmission device allocates a process to each of the three message queues, and the process is used for executing the message queues to output messages.
Step 302, the three processes enter a preparation stage, and the message transmission device obtains a linked list corresponding to the message queue 1, a queue mark, a count-i of the last chunk, an address of the first chunk, an address of the second chunk, and an address of the last chunk, and obtains a message slice corresponding to a slice in the linked list.
Here, the linked list corresponding to each message queue, the queue tag, 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 stored when the message is input into the message queue.
Step 303, the process of the message queue 1 enters an execution stage, the processes of the message queue 2 and the message queue 3 enter a waiting stage, and the message transmission device acquires the message slice corresponding to the slice in the linked list according to the linked list corresponding to the message queue 1, the queue mark, 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.
Specifically, the linked list pointer points to the address of the first chunk, all slices of the linked list first chunk where the message is located in the process are sequentially used, and meanwhile, the linked list pointer points to the address of the second chunk; all the slices of the second chunk are used in sequence, and meanwhile, 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.
Here, the slice using any one of the chunks may specifically include: assuming that count-i is used for recording the number of slices corresponding to message slices in a chunk when a message is input into a message queue, for convenience of understanding, count-o is correspondingly set and used for recording the number of used slices in the chunk when the message is output from the message queue. And after the linked list pointer points to the address of the chunk, calculating the offset address of the next slice according to the base address, the count-o and the specified value, wherein the offset address is equal to the sum-o multiplied by 1, acquiring the next slice according to the offset address, thereby acquiring the address of the message slice corresponding to the slice and outputting the message slice. For the last chunk, when the count-o of the last chunk is equal to the pre-stored count-i of the last chunk, the message slice taken out from the message queue is the last message slice, and the message queue finishes message output, where the count-o is the number of slices corresponding to the message slice in the chunk, that is, the number of sequence numbers of the currently used slices, when the message outputs the message queue.
It should be noted that the algorithm of the offset address provided by the embodiment of the present invention is not limited to this, and the offset address of each slice may also be the offset address of the previous slice plus a specified value. Here, determining that the output of the packet queue is completed in this embodiment may further include: the queue identification is empty; or count-o for each chunk in the linked list is 0.
Step 304, the process of the message queue 2 enters an execution stage, the message queue 3 enters a waiting stage, and the message transmission device acquires the message slice corresponding to the slice in the linked list according to the linked list, the queue mark, 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 corresponding to the acquired message queue 2.
Step 305, the process of the message queue 3 enters an execution stage, and the message transmission device obtains a message slice corresponding to the slice in the linked list according to the linked list, the queue mark, 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 corresponding to the obtained message queue 3.
The specific execution sequence of the processes provided by the embodiment of the present invention is shown in fig. 6. It should be noted that the method used in the message output in steps 303 to 305 is the same, so that the detailed description is only provided in step 303, and step 304 and step 305 are not repeated; generally, after the message output message queue is completed, the corresponding process is released, but when the following situations occur, the corresponding process will be arranged behind all the queues before, and waits for the next call: the queue is not empty, i.e., the queue depth is not 0; or the port where the queue is located is not in a flow control state; or the process is not full.
Example four
An embodiment of the present invention provides a message transmission apparatus 40, as shown in fig. 7, where the apparatus 40 may include:
the link list obtaining unit 401 is configured to obtain, when a packet queue outputs a packet, a link list corresponding to the packet queue, where the link list is established when the packet is input to the packet queue, where the link list includes one or more chunks, each chunk includes one or more slices, and the slices correspond to addresses of the packet slices in the packet queue one to one.
An address obtaining unit 402, configured to sequentially obtain slices from an ith chunk according to an address of the ith chunk pointed by the linked list pointer, where i is a positive integer.
A message obtaining unit 403, 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 + 1) th chunk.
Compared with the prior art, the embodiment of the invention can obtain the slice of the current chunk and simultaneously point the linked list pointer to the address of the next chunk, so that after the slice in the current chunk is used, the linked list pointer already points to the address of the next chunk, the slice in the next chunk can be used immediately without wasting a plurality of clock cycles to wait for the pointer to point to the address of the next chunk, thus reducing the time wasted by message queue output, ensuring the continuity of using the slices in each chunk, and further solving the problem of uniform output queue.
Further, the slice acquiring unit 403 is specifically configured to:
obtaining a base address, wherein the base address is an offset address of each chunk;
sequentially using each slice in the ith chunk according to the base address, wherein the offset address of the jth slice in the ith chunk is equal to the base address plus the product of j and a specified value, wherein j is a positive integer.
Preferably, the number of slices per chunk is the same in the same linked list.
Further, as shown in fig. 8, the apparatus 40 further includes:
an establishing unit 404, configured to establish one linked list corresponding to the packet queue.
A storing unit 405, configured to store the number of slices in each chunk of the linked list, the number of slices occupied in the last chunk, and the queue flag, where the queue flag indicates whether the packet queue stores packets in a column.
Further, the establishing unit 404 is specifically configured to:
if the message queue does not store messages, generating a linked list, wherein the linked list comprises a chunk; storing the address of the first node of the first cache region distributed to the message queue as the address of the first chunk and the address of the last chunk of the linked list; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the message queue stores messages, judging whether the linked list has a slice without corresponding information;
if the linked list has the slice without the corresponding information, the addresses of the message slices stored in the message queue are sequentially corresponding to the slice without the corresponding information;
if the linked list does not have a slice without corresponding information, judging whether the linked list only comprises one chunk;
if the linked list only comprises one chunk, generating a new last chunk, and storing the first node address of a second idle buffer distributed to the message queue as the address of the second chunk and the address of the new last chunk; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the linked list comprises a plurality of chunks, generating a new last chunk, and storing the address of the head node of a third idle buffer allocated to the message queue as the address of the new last chunk; and sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list.
Further, when a plurality of message queues output messages,
the obtaining linked list unit 401 is further configured to obtain linked lists corresponding to the plurality of message queues one to one;
the message obtaining unit 402 is further configured to sequentially output messages from the plurality of message queues according to the output order of the plurality of message queues.
In practical applications, the chain table obtaining Unit 401, the address obtaining Unit 402, the message obtaining Unit 403, the establishing Unit 404, and the storing Unit 405 may be implemented by a Central Processing Unit (CPU), a microprocessor Unit (MPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), or the like in the terminal.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention.

Claims (12)

1. A method for packet transmission, the method comprising:
when a message queue outputs a message, acquiring a linked list which is established when the message is input into the message queue and corresponds to the message queue, wherein the linked list comprises one or more chunks, each chunk comprises one or more slices, and the slices correspond to addresses of the message slices in the message queue one by one;
sequentially acquiring slices from an ith chunk according to the address of the ith chunk pointed by the linked list pointer, wherein i is a positive integer;
and outputting the message slices from the message queue according to the addresses of the message slices corresponding to the slices, and pointing the linked list pointer to the address of the (i + 1) th chunk while outputting the message slices.
2. The method of claim 1, wherein the sequentially obtaining the slices from the ith chunk according to the address of the ith chunk pointed to by the linked list pointer comprises:
obtaining a base address, wherein the base address is an offset address of each chunk;
sequentially using each slice in the ith chunk according to the base address, wherein the offset address of the jth slice in the ith chunk is equal to the base address plus the product of j, which is a positive integer, and a specified value.
3. The method of claim 2, wherein the number of slices per chunk is the same in the same linked list.
4. The method according to any one of claims 1 to 3, wherein when a message is input into the message queue before the message queue outputs the message, the method further comprises:
establishing a linked list corresponding to the message queue;
and saving the number of slices in each chunk of the linked list and the number of slices occupied in the last chunk.
5. The method of claim 4, wherein the establishing the one linked list corresponding to the packet queue comprises:
if the message queue does not store messages, generating a linked list, wherein the linked list comprises a chunk; storing the address of the first node of the first cache region distributed to the message queue as the address of the first chunk and the address of the last chunk of the linked list; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the message queue stores messages, judging whether the linked list has a slice without corresponding information;
if the linked list has the slice without the corresponding information, the addresses of the message slices stored in the message queue are sequentially corresponding to the slice without the corresponding information;
if the linked list does not have a slice without corresponding information, judging whether the linked list only comprises one chunk;
if the linked list only comprises one chunk, generating a new last chunk, and storing the first node address of a second idle buffer distributed to the message queue as the address of the second chunk and the address of the new last chunk; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list; wherein the second chunk is the new last chunk;
if the linked list comprises a plurality of chunks, generating a new last chunk, and storing the address of the head node of a third idle buffer allocated to the message queue as the address of the new last chunk; and sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list.
6. The method of claim 1, wherein when multiple packet queues output packets, the method further comprises:
obtaining linked lists corresponding to the plurality of message queues one by one;
and outputting the messages from the message queues in sequence according to the output sequence of the message queues.
7. A message transmission apparatus, the apparatus comprising:
the link list acquisition unit is used for acquiring a link list which is established when a message is input into the message queue and corresponds to the message queue when the message is output from the message queue, wherein the link list comprises one or more chunks, each chunk comprises one or more slices, and the slices correspond to addresses of the message slices in the message queue one by one;
an address obtaining unit, configured to sequentially obtain slices from an ith chunk according to an address of the ith chunk pointed by the linked list pointer, where i is a positive integer;
and the message acquisition unit is used for outputting the message slices from the message queue according to the addresses of the message slices corresponding to the slices, and pointing the linked list pointer to the address of the (i + 1) th chunk while outputting the message slices.
8. The apparatus of claim 7, wherein the acquisition slicing unit is specifically configured to:
obtaining a base address, wherein the base address is an offset address of each chunk;
sequentially using each slice in the ith chunk according to the base address, wherein the offset address of the jth slice in the ith chunk is equal to the base address plus the product of j and a specified value, wherein j is a positive integer.
9. The apparatus of claim 8, wherein the number of slices per chunk is the same in the same linked list.
10. The apparatus of any one of claims 7 to 9, further comprising:
the establishing unit is used for establishing the linked list corresponding to the message queue;
and the storage unit is used for storing the number of the slices in each chunk of the linked list and the number of the occupied slices in the last chunk.
11. The apparatus according to claim 10, wherein the establishing unit is specifically configured to:
if the message queue does not store messages, generating a linked list, wherein the linked list comprises a chunk; storing the address of the first node of the first cache region distributed to the message queue as the address of the first chunk and the address of the last chunk of the linked list; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list;
if the message queue stores messages, judging whether the linked list has a slice without corresponding information;
if the linked list has the slice without the corresponding information, the addresses of the message slices stored in the message queue are sequentially corresponding to the slice without the corresponding information;
if the linked list does not have a slice without corresponding information, judging whether the linked list only comprises one chunk;
if the linked list only comprises one chunk, generating a new last chunk, and storing the first node address of a second idle buffer distributed to the message queue as the address of the second chunk and the address of the new last chunk; sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list; wherein the second chunk is the new last chunk;
if the linked list comprises a plurality of chunks, generating a new last chunk, and storing the address of the head node of a third idle buffer allocated to the message queue as the address of the new last chunk; and sequentially corresponding the addresses of the message slices stored in the message queue to the slices of the linked list.
12. The apparatus of claim 7, wherein when a plurality of message queues output a message,
the link list acquiring unit is further configured to acquire link lists corresponding to the plurality of message queues one to one;
the message obtaining unit is further configured to sequentially output messages from the plurality of message queues according to the output order of the plurality of message queues.
CN201510331181.0A 2015-06-15 2015-06-15 Message transmission method and device Active CN106330741B (en)

Priority Applications (2)

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

Applications Claiming Priority (1)

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

Publications (2)

Publication Number Publication Date
CN106330741A CN106330741A (en) 2017-01-11
CN106330741B true CN106330741B (en) 2020-04-24

Family

ID=57544945

Family Applications (1)

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

Country Status (2)

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

Families Citing this family (6)

* 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
CN114189569B (en) * 2020-08-31 2024-03-26 华为技术有限公司 Data transmission method, device and system
CN113595932B (en) * 2021-08-06 2024-05-14 上海金仕达软件科技股份有限公司 Processing method of data disorder message and application specific integrated circuit
CN115756296A (en) * 2021-09-02 2023-03-07 深圳市中兴微电子技术有限公司 Cache management method and device, control program and controller
CN118509399A (en) * 2024-07-22 2024-08-16 格创通信(浙江)有限公司 Message processing method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200305076A (en) * 2001-12-21 2003-10-16 Agere Systems Inc Methods and apparatus for forming linked list queue using chunk-based structure
CN101635682A (en) * 2009-08-05 2010-01-27 中兴通讯股份有限公司 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

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7301954B1 (en) * 1999-09-24 2007-11-27 United States Of America As Represented By The Secretary Of The Navy Multiple-buffer queueing of data packets with high throughput rate
US7346067B2 (en) * 2001-11-16 2008-03-18 Force 10 Networks, Inc. High efficiency data buffering in a computer network device
CN100521655C (en) * 2006-12-22 2009-07-29 清华大学 Dynamic sharing device of physical queue based on the stream queue

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW200305076A (en) * 2001-12-21 2003-10-16 Agere Systems Inc Methods and apparatus for forming linked list queue using chunk-based structure
CN101635682A (en) * 2009-08-05 2010-01-27 中兴通讯股份有限公司 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

Also Published As

Publication number Publication date
WO2016202158A1 (en) 2016-12-22
CN106330741A (en) 2017-01-11

Similar Documents

Publication Publication Date Title
CN106330741B (en) Message transmission method and device
CN105511954B (en) Message processing method and device
CN102480430B (en) Method and device for realizing message order preservation
CN113485822A (en) Memory management method, system, client, server and storage medium
US10341264B2 (en) Technologies for scalable packet reception and transmission
CN106411778B (en) The method and device of data forwarding
CN104394096A (en) Multi-core processor based message processing method and multi-core processor
CN110995595A (en) Message sending method, device, storage medium and node equipment
CN112579515B (en) Thread message processing method and related product
CN106254270A (en) A kind of queue management method and device
CN104270287A (en) Message disorder detecting method and device
US20170366477A1 (en) Technologies for coordinating access to data packets in a memory
CN108429703B (en) DHCP client-side online method and device
US9894012B2 (en) Method and system to improve network connection locality on multicore systems
CN105357148A (en) Method and system for preventing output message of network exchange chip from being disordered
CN113157465A (en) Message sending method and device based on pointer linked list
Suen et al. Affordable avionic networks with Gigabit Ethernet assessing the suitability of commercial components for airborne use
CN116582387A (en) Message sending method, device and equipment
EP3185611A1 (en) Method, terminal and system for acquiring mail
CN115835333A (en) Signal scanning method and device, electronic equipment and storage medium
CN115225586A (en) Data packet transmitting method, device, equipment and computer readable storage medium
CN109862044B (en) Conversion device, network equipment and data transmission method
CN113132240A (en) Data packet processing and forwarding method, device, integrated chip, switch and system
CN114428684A (en) Message pushing method, device and system based on distribution
CN111130968A (en) Method and terminal for solving Modbus bus communication packet sticking

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant