CN100531142C - Method and device for guaranteeing message sequence - Google Patents

Method and device for guaranteeing message sequence Download PDF

Info

Publication number
CN100531142C
CN100531142C CNB2006101722439A CN200610172243A CN100531142C CN 100531142 C CN100531142 C CN 100531142C CN B2006101722439 A CNB2006101722439 A CN B2006101722439A CN 200610172243 A CN200610172243 A CN 200610172243A CN 100531142 C CN100531142 C CN 100531142C
Authority
CN
China
Prior art keywords
sequence number
message
current
data flow
transmitting
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.)
Expired - Fee Related
Application number
CNB2006101722439A
Other languages
Chinese (zh)
Other versions
CN1996958A (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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CNB2006101722439A priority Critical patent/CN100531142C/en
Publication of CN1996958A publication Critical patent/CN1996958A/en
Application granted granted Critical
Publication of CN100531142C publication Critical patent/CN100531142C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

This invention provides one method and device to ensure message order in data communication field, which comprises the following steps: in transferring multiple data flows, aligning each sequence number for each message and aligning the message into parallel lines; setting one current send sequence number for each data flow; in each line transferring, firstly finding current send sequence number for lock in the belonged data flow and updating the current sequence number for unlock when the current send sequence number is same to the transfer message number. This invention provides one device to ensure message order composed of initial module and sequence keep module.

Description

Guarantee the method and apparatus of message sequence
Technical field
The present invention relates to data communication field, particularly a kind of method and apparatus that guarantees message sequence.
Background technology
A basic function of data communications equipment is to transmit IP (Internet Protocol, Internet protocol) message.The order that a lot of business need data communications equipment strict guarantee messages are arranged is such as real time business such as voice, figures.Concerning router, guarantee that the message transfer sequence of same grouping is particularly important, same data flow enters router and answers strict guarantee identical with the order of leaving router.
For the router of distributed architecture, generally finish the IP message forwarding by Hardware Forwarding Engine.The network processing unit of some multithreadings guarantees message sequence by hardware mechanisms, for example, uses Semaphore Mechanism, and when thread was serial and parallel the mixing, the interface in parallel and serial utilized semaphore order-preserving synchronously usually; Perhaps beat label (label) to message, when sending message, guarantee to send message according to the label order by hardware by receiving element hardware.These benefits that rely on hardware mechanisms assurance message sequence are that the performance of system can not be affected substantially, but has the hidden danger that causes cross-thread semaphore transmitting-receiving confusion because of chip failure.
The packet order preserving function can also realize that this mode is mainly used in being finished in the system of message forwarding by the multinuclear multi thread CPU by software scenario.Adopt software scenario to realize that packet order preserving does not rely on hardware cell substantially and realizes that portability is better than the scheme with the hardware mechanisms realization, and is subjected to the influence of chip less.Different software scenarios causes the performance of system also different, this performance difference not only is embodied in the algorithm of packet order preserving itself, the more important thing is to be embodied among the whole system performance, so often need to take all factors into consideration the software scenario that the overall performance situation of system designs packet order preserving.
Fig. 1 finishes the principle schematic that software in the system that the IP message transmits is realized packet order preserving for prior art at the CPU by the multinuclear multithreading.Referring to Fig. 1, RX (Receive, receiving element) message in the data flow is assigned in parallel a plurality of processing threads in the mode of poll, be thread 0, thread 1 ..., thread n, be assigned to parallel processing in a plurality of bag order-preserving threads through processing unit again, promptly wrap order-preserving thread 0, bag order-preserving thread 1 ..., bag order-preserving thread n, give TX (Transmit, transmitting element) then and send.
When receiving element receives message, distribute flow_id (data flow id) and seq_num (sequence of message number) for each message by certain rule.Data flow id is in order to distinguish different data flow, so the message in same data flow all has identical flow_id, but the seq_num of the message in same data flow is all inequality.Set in advance the formation Seqs[x of a regular length in addition], be used for message in the buffer memory current data stream, and and the current sequence number of message Seq_current that can send be kept at together in the data structure, as shown in table 1.Wherein the length x of formation can set according to actual conditions.
Table 1
The current sequence number of message Seq_current that can send The formation seqs[x of buffer memory message] (x is the length of formation)
Referring to Fig. 2, the order-preserving class of algorithms is similar to sliding window mechanism.Suppose that default queue length x is 64, then message queue can 64 messages of buffer memory, regard message queue as the forms that can slide, and number determine the position of forms on current data flows according to the current sequence of message that can send.If the message that receives is in the scope of current cache formation, when promptly satisfying following conditions:
(the ﹠amp of seq_num>=seq_current); ﹠amp; (the) ﹠amp of seq_num<(seq_current+64); ﹠amp; (position of seq_num correspondence does not have message in the window);
Just with the message queue seq[64 of current packet buffer to current data stream] in, carry out the message ordering; If the message that receives not in the scope of current cache formation, dropping packets then.
After the message ordering is finished, read message according to seq_current corresponding position from buffer queue, by the message in the continuous transmit queue of transmitting element, certain position is not also inserted till the message in formation.
Above-mentioned prior art need take independent bag order-preserving sets of threads and finish packet order preserving, takies more system resources; And use with a multinuclear multithreading chip and realize different software order-preserving schemes, though be that multi-threaded parallel is handled, do not improve the performance of system.
Summary of the invention
The software order-preserving takies problems such as more system resources in the prior art in order to solve, and the embodiment of the invention provides a kind of method that guarantees message sequence, specifically may further comprise the steps:
When transmitting the message of many data flow,, and the message that receives is assigned in parallel a plurality of threads in the mode of poll for each message that receives distributes a sequence number;
For every data flow is provided with current transmitting Sequence Number;
When each thread E-Packets, find affiliated the current of data flow of waiting to E-Packet to transmit Sequence Number earlier, and described current transmitting Sequence Number locked, more described current transmit Sequence Number and whether sequence number to be E-Packeted equates, if equate, then transmit described waiting and E-Packet, upgrade described current transmitting Sequence Number, to the described current release that transmits Sequence Number.
A kind of device that guarantees message sequence also is provided in the embodiment of the invention, and described device comprises:
Initialization module is used for when transmitting the message of many data flow, for each message that receives distributes a sequence number, and in the mode of poll the message that receives is assigned in parallel a plurality of threads; Also be used to every data flow that current transmitting Sequence Number is set;
The order-preserving module, be used for when each thread E-Packets, find affiliated the current of data flow of waiting to E-Packet to transmit Sequence Number earlier, and described current transmitting Sequence Number locked, more described current transmit Sequence Number and whether sequence number to be E-Packeted equates if equate, then transmitted described waiting and E-Packeted, upgrade described current transmitting Sequence Number, to the described current release that transmits Sequence Number.
Embodiment of the invention algorithm is simple, does not need independent order-preserving thread, and is little to memory requirements, has entire system performance advantage.
Description of drawings
To be prior art finish the principle schematic that software in the system that the IP message transmits is realized packet order preserving at the CPU by the multinuclear multithreading to Fig. 1;
Fig. 2 is a prior art software order-preserving algorithm principle schematic diagram;
Fig. 3 is the schematic diagram that the embodiment of the invention guarantees the method thread process of message sequence;
Fig. 4 is the flow chart that the embodiment of the invention guarantees the method for message sequence;
Fig. 5 is the structure chart that the embodiment of the invention guarantees the device of message sequence.
Embodiment
The invention will be further described below in conjunction with the drawings and specific embodiments, but the present invention is not limited to the following examples.
The embodiment of the invention adopts the mode of similar spin_lock (spin lock) to realize packet order preserving, and does not need independent order-preserving thread.Referring to Fig. 3, when transmitting the message of many data flow, receiving element RX gives each the message distributing serial numbers that receives, and message assigned in the mode of poll (round robin) (thread 0 is to thread n in the parallel processing threads, n is a natural number), same the interior message of data flow may be distributed to and go in the different threads to handle, in the thread of these parallel processings, by to locking for current the transmitting Sequence Number of every data flow setting in advance, number meet current situation about transmitting Sequence Number at sequence of message and issue the literary composition of delivering newspaper, and send the current mode that transmits Sequence Number of back release and realize packet order preserving.
Referring to Fig. 4, the embodiment of the invention provides a kind of method that guarantees message sequence, specifically may further comprise the steps:
Step 101: when transmitting the message of many data flow, receiving element all distributes a sequence number seq_num for each message that receives, and in the mode of poll message is assigned in parallel a plurality of processing threads.
Many data flow is distinguished according to certain rule of classification, and for example, the port numbers in the message information is the message of port 2, can regard the message in same the data flow as.All inequality for the sequence number that the message in same the data flow distributes, be used to distinguish the different messages in same the data flow.
Step 102: for every data flow is provided with a current seq_current of transmitting Sequence Number, correspondingly, many data flow just have a plurality of current transmitting Sequence Number, and all current seq_current of transmitting Sequence Number are kept in the shared address in the internal memory; All parallel processing threads can be visited this shared address and be read current transmitting Sequence Number.
Step 103: each thread finds earlier the current seq_current of transmitting Sequence Number of data flow under waiting to E-Packet from shared address when E-Packeting, and this sequence number seq_current is locked.
Step 104: relatively whether this sequence number of message seq_num and the current seq_current that transmits Sequence Number equate, if equate that then execution in step 105; Otherwise execution in step 106.
Step 105: send this message, and upgrade seq_current, the value that is about to seq_current adds 1, as the foundation that judges whether to send message next time, to the seq_current release.
Step 106: do not transmit this message, seq_current is carried out release, continue execution in step 103, finish up to whole messages forwardings.
Lock and unlocking process can realize by function PKT_ORDER_LOCK () and PKT_ORDER_UNLOCK () respectively.
Referring to Fig. 5, the embodiment of the invention also provides a kind of device that guarantees message sequence, specifically comprises:
1) initialization module is used for when transmitting the message of many data flow, for each message that receives distributes a sequence number seq_num, and in the mode of poll the message that receives is assigned in parallel a plurality of threads; Also be used to every data flow that a current seq_current of transmitting Sequence Number is set;
2) order-preserving module, be used for when each thread E-Packets, find the current seq_current of transmitting Sequence Number of data flow under waiting to E-Packet earlier, and this current seq_current of transmitting Sequence Number locked, whether the more current seq_current that transmits Sequence Number equates with sequence number seq_num to be E-Packeted, if equate, then transmits this message, upgrade the current seq_current that transmits Sequence Number, and to its release.
Above-mentioned order-preserving module is upgraded the current seq_current of transmitting Sequence Number and specifically is meant the current seq_current of transmitting Sequence Number is added 1, i.e. seq_current=seq_current+1.
Above-mentioned order-preserving module also is used for transmitting Sequence Number and sequence number to be E-Packeted when unequal current, current transmitting Sequence Number is carried out release, and do not transmit and wait to E-Packet.
The device of above-mentioned assurance message sequence also comprises:
Preserve module, be used for after setting up current the transmitting Sequence Number of all data flow, preserve the current of all data flow with the equal energy of above-mentioned all parallel threads access modes and transmit Sequence Number, promptly be kept in the shared address, all parallel threads can both be visited this shared address.
Above-described embodiment, the present invention embodiment several more preferably just, the common variation that those skilled in the art carries out in the technical solution of the present invention scope and replacing all should be included in protection scope of the present invention.

Claims (10)

1. a method that guarantees message sequence is characterized in that, described method comprises:
When transmitting the message of many data flow,, and the message that receives is assigned in parallel a plurality of threads in the mode of poll for each message that receives distributes a sequence number;
For every data flow is provided with current transmitting Sequence Number;
When each thread E-Packets, find affiliated the current of data flow of waiting to E-Packet to transmit Sequence Number earlier, and described current transmitting Sequence Number locked, more described current transmit Sequence Number and whether sequence number to be E-Packeted equates, if equate, then transmit described waiting and E-Packet, upgrade described current transmitting Sequence Number, to the described current release that transmits Sequence Number.
2. the method for assurance message sequence according to claim 1 is characterized in that, described current the transmitting Sequence Number of described renewal comprises:
Described current transmitting Sequence Number added 1.
3. the method for assurance message sequence according to claim 1 is characterized in that, described method also comprises:
Described current transmitting Sequence Number and sequence number to be E-Packeted when unequal, described current transmitting Sequence Number carried out release, and do not transmit described waiting and E-Packet.
4. according to the method for claim 1 or 2 or 3 described assurance message sequences, it is characterized in that described method also comprises:
After setting up current the transmitting Sequence Number of described many data flow, preserve the current of described every data flow with the equal energy of described parallel a plurality of threads access modes and transmit Sequence Number.
5. according to the method for claim 1 or 2 or 3 described assurance message sequences, it is characterized in that described many data flow are distinguished according to the rule of classification of setting.
6. according to the method for claim 1 or 2 or 3 described assurance message sequences, it is characterized in that, when distributing a sequence number, distribute sequence number inequality belonging to same the message in the data flow for each message that receives.
7. a device that guarantees message sequence is characterized in that, described device comprises:
Initialization module is used for when transmitting the message of many data flow, for each message that receives distributes a sequence number, and in the mode of poll the message that receives is assigned in parallel a plurality of threads; Also be used to every data flow that current transmitting Sequence Number is set;
The order-preserving module, be used for when each thread E-Packets, find affiliated the current of data flow of waiting to E-Packet to transmit Sequence Number earlier, and described current transmitting Sequence Number locked, more described current transmit Sequence Number and whether sequence number to be E-Packeted equates if equate, then transmitted described waiting and E-Packeted, upgrade described current transmitting Sequence Number, to the described current release that transmits Sequence Number.
8. the device of assurance message sequence according to claim 7 is characterized in that, described current the transmitting Sequence Number of described renewal comprises:
Described current transmitting Sequence Number added 1.
9. the device of assurance message sequence according to claim 7, it is characterized in that, described order-preserving module also is used for described current transmitting Sequence Number and sequence number to be E-Packeted when unequal described current transmitting Sequence Number being carried out release, and does not transmit described waiting and E-Packet.
10. according to the device of claim 7 or 8 or 9 described assurance message sequences, it is characterized in that described device also comprises:
Preserve module, be used for after setting up current the transmitting Sequence Number of described many data flow, preserve the current of described every data flow with the equal energy of described parallel a plurality of threads access modes and transmit Sequence Number.
CNB2006101722439A 2006-12-30 2006-12-30 Method and device for guaranteeing message sequence Expired - Fee Related CN100531142C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006101722439A CN100531142C (en) 2006-12-30 2006-12-30 Method and device for guaranteeing message sequence

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006101722439A CN100531142C (en) 2006-12-30 2006-12-30 Method and device for guaranteeing message sequence

Publications (2)

Publication Number Publication Date
CN1996958A CN1996958A (en) 2007-07-11
CN100531142C true CN100531142C (en) 2009-08-19

Family

ID=38251898

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006101722439A Expired - Fee Related CN100531142C (en) 2006-12-30 2006-12-30 Method and device for guaranteeing message sequence

Country Status (1)

Country Link
CN (1) CN100531142C (en)

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101175033B (en) * 2007-11-27 2010-06-16 中兴通讯股份有限公司 Message order-preserving method and device thereof
CN101854302B (en) * 2010-05-27 2016-08-24 中兴通讯股份有限公司 Message order-preserving method and system
CN102075427A (en) * 2011-01-18 2011-05-25 中兴通讯股份有限公司 Security association-based IPSec message processing method and device
CN102204183A (en) * 2011-05-09 2011-09-28 华为技术有限公司 Message order-preserving processing method, order-preserving coprocessor and network equipment
EP2834755B1 (en) 2012-04-05 2018-01-24 Microsoft Technology Licensing, LLC Platform for continuous graph update and computation
CN102710524B (en) * 2012-06-15 2015-01-21 大连梯耐德网络技术有限公司 Implementing method for multi-protocol network message transmission order preserving system
CN102868636A (en) * 2012-09-11 2013-01-09 汉柏科技有限公司 Method and system for stream-based order preservation of multi-core network equipment packet
CN103078811B (en) * 2013-01-31 2015-12-09 北京金和软件股份有限公司 A kind of based on multi-thread environment network packet out-of-order control method
CN105323081A (en) * 2014-06-16 2016-02-10 中兴通讯股份有限公司 Parallel processing method, device, and processing method and device of alarm
CN106464605B (en) * 2014-07-14 2019-11-29 华为技术有限公司 The method and relevant device of processing message applied to the network equipment
CN106713144B (en) * 2016-12-27 2020-01-21 锐捷网络股份有限公司 Reading and writing method of message outlet information and forwarding engine
CN110263895B (en) * 2019-06-25 2023-02-17 北京慧眼智行科技有限公司 Code graph generation method and system
CN110830386B (en) * 2019-11-14 2023-06-30 武汉船舶通信研究所(中国船舶重工集团公司第七二二研究所) Message order preserving method, device and system
CN113141235B (en) * 2020-01-20 2022-07-22 华为技术有限公司 Method and related device for processing data
CN114731334B (en) * 2020-02-14 2023-10-20 华为技术有限公司 Message order preserving method and device
CN113630376B (en) * 2021-06-16 2023-04-07 新华三信息安全技术有限公司 Network security device and message processing method thereof
EP4373055A1 (en) * 2021-07-16 2024-05-22 Beijing Xiaomi Mobile Software Co., Ltd. Data transmission method, data transmission apparatus, and storage medium
CN114448573B (en) * 2022-03-02 2024-02-23 新华三半导体技术有限公司 Message processing method and device

Also Published As

Publication number Publication date
CN1996958A (en) 2007-07-11

Similar Documents

Publication Publication Date Title
CN100531142C (en) Method and device for guaranteeing message sequence
US8099521B2 (en) Network interface card for use in parallel computing systems
US6546010B1 (en) Bandwidth efficiency in cascaded scheme
US6744776B1 (en) Servicing priority traffic in multiport network switch
US6466580B1 (en) Method and apparatus for processing high and low priority frame data transmitted in a data communication system
US8385374B1 (en) Multilane communication device
US6618390B1 (en) Method and apparatus for maintaining randomly accessible free buffer information for a network switch
US6608813B1 (en) Method and apparatus for achieving fault tolerance in packet switching systems with inverse multiplexing
US6563818B1 (en) Weighted round robin cell architecture
US6738384B1 (en) Technique for optimizing cut-through for broadcast and multi-cast packets in a multi-port bridge for a local area network
US6442137B1 (en) Apparatus and method in a network switch for swapping memory access slots between gigabit port and expansion port
US6732184B1 (en) Address table overflow management in a network switch
US20030072316A1 (en) Apparatus and method in a network switch port for transferring data between buffer memory and transmit and receive state machines according to a prescribed interface protocol
US7031305B1 (en) Apparatus and method for programmable memory access slot assignment
US6636523B1 (en) Flow control using rules queue monitoring in a network switching system
KR20070007769A (en) Highly parallel switching systems utilizing error correction
JP2002514367A (en) Integrated multiport switch with management information base (MIB) interface primary storage
US6724769B1 (en) Apparatus and method for simultaneously accessing multiple network switch buffers for storage of data units of data frames
US6658015B1 (en) Multiport switch with plurality of logic engines for simultaneously processing different respective data frames
US6501734B1 (en) Apparatus and method in a network switch for dynamically assigning memory interface slots between gigabit port and expansion port
US6895015B1 (en) Dynamic time slot allocation in internal rules checker scheduler
US6574231B1 (en) Method and apparatus for queuing data frames in a network switch port
US8589593B2 (en) Method and apparatus for processing protocol messages for multiple protocol instances
US6335938B1 (en) Multiport communication switch having gigaport and expansion ports sharing the same time slot in internal rules checker
CN105530157B (en) The multiple virtual links of the AFDX network switch share the framework and method of credit

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090819

Termination date: 20191230