WO2015120699A1 - 一种报文转发方法、装置及网络转发设备 - Google Patents

一种报文转发方法、装置及网络转发设备 Download PDF

Info

Publication number
WO2015120699A1
WO2015120699A1 PCT/CN2014/083728 CN2014083728W WO2015120699A1 WO 2015120699 A1 WO2015120699 A1 WO 2015120699A1 CN 2014083728 W CN2014083728 W CN 2014083728W WO 2015120699 A1 WO2015120699 A1 WO 2015120699A1
Authority
WO
WIPO (PCT)
Prior art keywords
value
sent
cbs value
updating
cbs
Prior art date
Application number
PCT/CN2014/083728
Other languages
English (en)
French (fr)
Inventor
朱寅
魏立军
姬晓阳
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2015120699A1 publication Critical patent/WO2015120699A1/zh

Links

Classifications

    • 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/215Flow control; Congestion control using token-bucket

Definitions

  • the present invention relates to the field of communications, and in particular, to a packet forwarding method, apparatus, and network forwarding device. Background technique
  • Routers and switches are indispensable important devices in the field of data communication. Due to geographical restrictions, devices generally gather farther. In order to ensure the reliability of long-distance signal transmission, transmission equipment is required for signal relay. This type of transmission equipment is costly and generally configured as needed. Because the operator considers the cost, its bandwidth is often lower than the actual nominal interface bandwidth of the router and switch. The bandwidth of the auto-negotiation of the interface between the two routers and the switch cannot reflect the actual bandwidth capacity of the transmission device. As a result, the bandwidth of the actual egress of the communication device such as the router and the switch is much larger than the maximum capacity of the link, resulting in a large number of data packets. Lost, affecting the normal operation of various businesses.
  • the network operator usually upgrades the transmission equipment on some key interfaces. These interfaces often have a low traffic state for most of the time, and occasionally traffic bursts occur. Therefore, upgrading the transmission device not only causes waste of resources, The cost of the network operator is also greatly increased. Therefore, a link bandwidth setting method is needed. Under the condition that the transmission device is not upgraded, the traffic burst condition should be dealt with, and the link bandwidth should be fully utilized to ensure that the service is not affected.
  • the embodiments of the present invention provide a packet forwarding method, a device, and a network forwarding device.
  • An embodiment of the present invention provides a packet forwarding method for saving a committed burst size.
  • the packet forwarding method includes:
  • the first determining step is: when the to-be-sent message arrives, determining whether the first lock can be obtained, and obtaining the first determination result;
  • a first execution step when the first determination result indicates that the first lock can be obtained, acquiring the first lock, selecting the CBS value, and reaching a TICK value to determine whether to send the sending message to be sent Processing, and updating the CBS value and reaching the TICK value and unlocking after sending the to-be-sent message;
  • a second execution step when the first determination result indicates that the first lock cannot be obtained, only the CBS value is selected from the CBS value and the arrival TICK value to perform transmission determination processing of whether to send the to-be-sent document And updating the CBS value after sending the to-be-sent document.
  • the method for updating the CBS value specifically includes:
  • a second determining step determining whether another thread is updating the CBS value to obtain a second judgment result
  • a first updating step updating, when the second determination result indicates that no other thread is updating the CBS value, updating the CBS value;
  • the second update step when the second determination result indicates that another thread is updating the CBS value, performing a wait operation until the CBS value is updated after no other thread updates the CBS value.
  • the method for updating the CBS value specifically includes: a third determining step: determining whether the second lock can be obtained, obtaining a third determining result; and a third updating step: when the third determining result indicates that the second lock can be obtained, determining that no other thread is updating the The conclusion of the CBS value, obtaining the second lock, updating the CBS value and unlocking;
  • a fourth updating step when the third determining result indicates that the second lock cannot be obtained, it is concluded that another thread is updating the CBS value, performing a waiting operation until after acquiring the second lock, updating The CBS value is unlocked.
  • the method for updating the CBS value includes:
  • a fourth determining step determining whether another thread occupies the resource of the CBS value, and obtaining a fourth determination result
  • a fifth update step when the fourth determination result indicates that no other thread occupies the resource of the CBS value, it is concluded that no other thread is updating the CBS value, and the resource occupying the CBS value is updated. CBS value and release;
  • a sixth updating step when the fourth determining result indicates that another thread occupies the resource of the CBS value, it is determined that another thread is in the process of updating the CBS value, and performs a waiting operation until the CBS value is occupied. After the resource, the CBS value is updated and released.
  • the first performing step of selecting the CBS value and the arriving TICK value into a first obtaining step acquiring, according to the arriving TICK value, the number of newly added tokens when the to-be-sent packet arrives;
  • a second obtaining step obtaining, according to the number of newly added tokens and the CBS value, the number of available tokens when the to-be-sent packet arrives;
  • a third obtaining step obtaining a required number of tokens for sending the to-be-sent packet
  • a fifth determining step determining whether the number of available tokens is greater than or equal to the number of required tokens for sending the to-be-sent packet, and obtaining a fifth determination result; a first execution sub-step: when the fifth determination result indicates that the number of available tokens is greater than or equal to the number of required tokens for sending the to-be-sent packet, the network forwarding device sends the to-be-sent The judgment process of the message is processed, otherwise the conclusion that the network forwarding device does not send the message to be sent is obtained.
  • the sending by the second execution step, only the CBS value is selected to send the to-be-sent message.
  • a fourth obtaining step obtaining a required number of tokens for sending the to-be-sent packet
  • a sixth determining step determining, according to the CBS value, whether the CBS value is greater than or equal to the number of required tokens for sending the to-be-sent packet, and obtaining a sixth determination result;
  • a second execution sub-step when the sixth determination result indicates that the CBS value is greater than or equal to the number of required tokens for sending the to-be-sent packet, the network forwarding device sends the to-be-transmitted message Judge the conclusion of the process.
  • the method further includes:
  • the packet obtaining step is as follows: The packet to be sent is obtained according to the priority of the packet.
  • the step of acquiring the packet specifically includes:
  • Queue formation step According to the queue allocation strategy, the "3 ⁇ 4 text" is divided into a PQ queue, a WFQ queue, a protocol queue, and a default queue.
  • Queue selection step selecting a queue to be sent according to the priority of each queue
  • the embodiment of the present invention further provides a packet forwarding device, configured to store a CBS value and a network forwarding device that reaches a TICK value, where the network forwarding device performs packet forwarding according to the multi-thread token bucket technology, and the packet forwarding is performed.
  • the device is used by any one of the multiple threads, and the message forwarding device includes:
  • the first judging module is configured to determine whether the first lock can be obtained when the to-be-sent packet arrives, and obtain the first judging result;
  • the first execution module is configured to: when the first determination result indicates that the first lock can be obtained, acquire the first lock, select the CBS value, and reach a TICK value to send whether to send the to-be-sent packet Sending a judgment process, and updating the CBS value and reaching the TICK value and unlocking after transmitting the to-be-sent message;
  • the second execution module is configured to: when the first determination result indicates that the first lock cannot be obtained, select only the CBS value from the CBS value and the arrival TICK value to send whether to send the to-be-sent document The processing is judged, and after the text to be transmitted is sent, the CBS value is updated.
  • the first execution module and the second execution module include:
  • a second determining unit configured to determine whether another thread is updating the CBS value, and obtaining a second determining result
  • a first update unit configured to update the CBS value when the second determination result indicates that no other thread is updating the CBS value
  • the second update unit is configured to perform a wait operation when the second judgment result indicates that another thread is updating the CBS value, until the CBS value is not updated after the other thread updates the CBS value.
  • the first execution module and the second execution module further include:
  • a third determining unit configured to determine whether the second lock can be obtained, and obtain a third determining result; the third updating unit: configured to: when the third determining result indicates that the second lock is available, At the conclusion of updating the CBS value, acquiring the second lock, updating the CBS value and unlocking;
  • a fourth updating unit configured to: when the third determination result indicates that the second lock cannot be obtained, conclude that another thread is updating the CBS value, performing a waiting operation until obtaining After the second lock, the CBS value is updated and unlocked.
  • the first execution module and the second execution module further include:
  • a fourth determining unit configured to determine whether another thread occupies the resource of the CBS value, and obtains a fourth determining result
  • a fifth updating unit configured to: when the fourth determining result indicates that no other thread occupies the resource of the CBS value, it is concluded that no other thread is updating the CBS value, and the resource occupying the CBS value is updated. The CBS value is released;
  • a sixth updating unit configured to: when the fourth determining result indicates that another thread occupies the resource of the CBS value, conclude that another thread is updating the CBS value, performing a waiting operation until occupying the CBS After the value of the resource, the CBS value is updated and released.
  • the first execution module further includes:
  • a first acquiring unit configured to acquire, according to the arriving TICK value, a number of newly added tokens when the to-be-sent packet arrives;
  • a second acquiring unit configured to acquire, according to the number of newly added tokens and the CBS value, the number of available tokens when the to-be-sent packet arrives;
  • the third obtaining unit is configured to obtain the required number of tokens for sending the to-be-sent packet;
  • the fifth determining unit is configured to determine whether the number of available tokens is greater than or equal to that required to send the to-be-sent packet The number of tokens, the fifth judgment result is obtained;
  • a first execution subunit configured to: when the fifth determination result indicates that the number of available tokens is greater than or equal to the number of required tokens for sending the to-be-sent packet, the network forwarding device sends the The judgment processing result of the to-be-sent packet is sent, otherwise the judgment result of the network forwarding device not transmitting the to-be-sent packet is obtained.
  • the second execution module further includes:
  • a fourth acquiring unit configured to obtain a required number of tokens for sending the to-be-sent packet; a sixth determining unit: configured to determine, according to the CBS value, whether the CBS value is greater than or The second execution subunit is configured to: in the sixth determination result, the CBS value is greater than or equal to the sending the to-be-sent
  • the network forwarding device sends a judgment process for transmitting the to-be-sent packet, and the conclusion that the network forwarding device does not send the to-be-sent packet is obtained.
  • the device further includes:
  • the packet obtaining module is configured to obtain the to-be-sent packet according to the priority of the packet.
  • the embodiment of the present invention further provides a network forwarding device, which stores a CBS value and a TICK value, and the network forwarding device performs packet forwarding based on the multi-thread token bucket technology, including:
  • Memory configured to store a bandwidth tuning configuration table having a CBS value and a TICK value, and process data when the token bucket is calculated; buffering or storing the message;
  • Coprocessor configured to translate configuration commands from the network and configuration files into a bandwidth setting configuration table; and read process data of the token bucket calculation and display;
  • the network processor is configured to send and receive a message, and store the received message into the memory; select a message to be sent; and perform a judgment processing operation of whether to send the to-be-sent message.
  • the message forwarding method and device when the message is forwarded by using the token bucket technology, the calculation method of each thread and the time point of updating the shared data are reasonably arranged, and the multi-threading is effectively solved.
  • FIG. 1 is a schematic flowchart of a packet forwarding method according to an embodiment of the present invention
  • FIG. 2 is a schematic structural diagram of a packet forwarding apparatus according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a packet forwarding method according to another embodiment of the present invention.
  • 4 is a schematic diagram of a first lock application process of a packet forwarding method according to an embodiment of the present invention;
  • FIG. 5 is a schematic diagram of a problem generated by calculating a time increment of each thread;
  • FIG. 6 is a schematic diagram of a second lock application process of a packet forwarding method according to an embodiment of the present invention
  • FIG. 7 is a schematic structural diagram of a packet forwarding apparatus according to another embodiment of the present invention. detailed description
  • FIG. 1 is a schematic flowchart of a text forwarding method according to an embodiment of the present invention.
  • an embodiment of the present invention provides a packet forwarding method, which is configured to perform packet forwarding based on a multi-thread token bucket technology, and is used for saving The CBS value and the network forwarding device that reaches the TICK value, the packet forwarding method is used in any one of the multiple threads, and the packet forwarding method includes:
  • the first determining step 101 is: when the to-be-sent message arrives, determining whether the first lock can be obtained, and obtaining the first determination result;
  • First executing step 102 when the first determination result indicates that the first lock can be obtained, acquiring the first lock, selecting the CBS value, and reaching a TICK value to send whether to send the to-be-sent packet Determining processing, and after transmitting the to-be-sent message, updating the CBS value and reaching the TICK value and unlocking;
  • a second execution step 103 when the first determination result indicates that the first lock cannot be obtained, only the CBS value is selected from the CBS value and the arrival TICK value, and whether to send the to-be-sent packet is sent. Determining processing, and after transmitting the to-be-sent message, updating the CBS value.
  • the time increment calculation can be performed only by the thread that obtains the first lock at the same time.
  • the first lock is unique, so that the token filling value is not caused by the simultaneous accumulation of multiple threads at the same time, that is, the number of newly added tokens is repeatedly calculated, and the number of available tokens is too large, and the speed limit is not allowed. , the problem of message loss.
  • the calculation of the transmission capability is also performed, and the packet is forwarded within the traffic range restricted by the network forwarding device, and the multi-threading improves the forwarding efficiency and fully utilizes the bandwidth.
  • the second determination step 201 determine whether there is The other thread updates the CBS value to obtain a second determination result
  • a first updating step 202 updating, when the second determination result indicates that no other thread is updating the CBS value, updating the CBS value;
  • a second update step 203 indicating, in the second determination result, that another thread is updating the
  • a wait operation is performed until the CBS value is updated after no other thread updates the CBS value.
  • the third determining step 2011 determining whether the second lock can be obtained, obtaining the third determining result; the third updating step 2021: when the third determining result indicates that the second lock can be obtained, it is determined that no other thread is updating The conclusion of the CBS value, obtaining the second lock, updating the
  • a fourth updating step 2031 when the third determination result indicates that the second lock cannot be obtained, it is determined that another thread is updating the CBS value, and performing a waiting operation until after acquiring the second lock, Update the CBS value and unlock it.
  • the thread that obtains the second lock can update the CBS value, and the second lock is unique, it is ensured that only one thread can be used for the CBS at the same time.
  • the value is modified to solve the multi-thread simultaneous read and write coverage, forming a dirty The problem with the data.
  • Fourth determining step 2012 determining whether another thread occupies the resource of the CBS value, and obtaining a fourth judgment result
  • a fifth update step 2022 when the fourth determination result indicates that no other thread occupies the resource of the CBS value, it is concluded that no other thread is updating the CBS value, and the resource occupying the CBS value is updated. Describe the CBS value and release it;
  • the sixth update step 2032 when the fourth determination result indicates that another thread occupies the resource of the CBS value, it is concluded that another thread is updating the CBS value, and performs a waiting operation until the CBS value is occupied. After the resources are updated, the CBS value is updated and released.
  • the CBS value can be updated only by the thread that limits the resources that occupy the CBS value, thereby ensuring that only one thread can modify the CBS value at the same time. , also solves the problem of multi-threaded read and write coverage, forming dirty data.
  • the thread that acquires the first lock, selects the CBS value, and the arrival TICK value to send the to-be-sent transmission determination processing step specifically includes:
  • a first obtaining step 1021 acquiring, according to the arriving TICK value, a number of newly added tokens when the to-be-sent message arrives;
  • a second obtaining step 1022 acquiring, according to the number of newly added tokens and the CBS value, the number of available tokens when the to-be-sent packet arrives;
  • a third obtaining step 1023 obtaining a required number of tokens for sending the to-be-sent packet; and a fifth determining step 1024: determining whether the number of available tokens is greater than or equal to a required token for sending the to-be-sent packet Number, obtain the fifth judgment result;
  • a first execution sub-step 1025 indicating, in the fifth determination result, that the number of available tokens is greater than Or, when the number of the required tokens to be sent is sent, the network forwarding device sends the judgment result of the to-be-sent packet, otherwise the network forwarding device does not send the to-be-sent The conclusion of the judgment of the message.
  • the thread of the first lock is obtained, and the token bucket algorithm is used for traffic shaping, limiting the average transmission rate of the data while allowing a certain degree of burst transmission, and failing to send The packets to be sent, as time accumulates, wait until the network forwarding device has the forwarding capability, and then transmits, maximizing the bandwidth utilization.
  • the thread of the first lock is not obtained, and only the fourth obtaining step 1031 is selected: obtaining the required number of tokens for sending the to-be-sent packet; the sixth determining step 1032 And determining, according to the CBS value, whether the CBS value is greater than or equal to the number of required tokens for sending the to-be-sent packet, and obtaining a sixth determination result;
  • a second execution sub-step 1033 when the sixth determination result indicates that the CBS value is greater than or equal to the number of required tokens for sending the to-be-sent packet, the network forwarding device sends the to-be-sent report. The judgment of the text is processed, otherwise the judgment result of the network forwarding device not transmitting the to-be-sent packet is obtained.
  • the method further includes the step of selecting a packet, which is specifically:
  • the packet obtaining step 100 is: acquiring the to-be-sent packet according to the priority of the packet.
  • the step of selecting a packet to be sent according to the priority of the packet is increased, so that the network forwarding device makes full use of the bandwidth, and in the case that the service does not lose packets,
  • the packets with the highest priority are sent preferentially, and the packets that cannot be sent in time after the initial calculation can be re-arranged according to the priority, so that the packets with the highest priority are sent first.
  • the packet obtaining step 100 specifically includes:
  • Queue forming step 1001 According to the queue allocation policy, the packet is divided into a PQ queue, a WFQ queue, a protocol queue, and a default queue in a linked list format;
  • Queue selection step 1002 Select a queue to be sent according to the priority of each queue; send a message.
  • the technical solution of obtaining the high priority packet is reduced, the computing burden of the network forwarding device is reduced, and the device crash and delay are avoided. happened.
  • FIG. 2 is a schematic structural diagram of a packet forwarding apparatus according to an embodiment of the present invention. As shown in FIG. 2, an embodiment of the present invention further provides a packet forwarding apparatus, which performs packet forwarding based on a multi-thread token bucket technology. And the packet forwarding device is used in any one of the multiple threads, where the packet forwarding device includes:
  • the first judging module 201 is configured to determine whether the first lock can be obtained when the to-be-sent packet arrives, and obtain the first judgment result;
  • the first execution module 202 is configured to: when the first determination result indicates that the first lock can be obtained, acquire the first lock, select the CBS value, and reach a TICK value to perform sending Determining a transmission judgment process of the sent message, and updating the CBS value and reaching the TICK value and unlocking after transmitting the to-be-sent message;
  • the second execution module 203 is configured to: when the first determination result indicates that the first lock cannot be obtained, select only the CBS value from the CBS value and the arrival TICK value to send the to-be-sent packet. The sending judgment process, and after transmitting the to-be-sent message, updating the CBS value.
  • the first execution module 202 and the second execution module 203 include:
  • a second determining unit configured to determine whether another thread is updating the CBS value, and obtaining a second determining result
  • a first update unit configured to update the CBS value when the second determination result indicates that no other thread is updating the CBS value
  • the second update unit is configured to perform a wait operation when the second judgment result indicates that another thread is updating the CBS value, until the CBS value is not updated after the other thread updates the CBS value.
  • the first execution module 202 and the second execution module 203 further include: a third determining unit: configured to determine whether the second lock can be obtained, and obtain a third determination result;
  • a third update unit configured to: when the third determination result indicates that the second lock can be obtained, obtain a conclusion that no other thread is updating the CBS value, and acquire the second lock, and update the CBS value And unlocked;
  • a fourth updating unit configured to: when the third determining result indicates that the second lock cannot be obtained, obtaining a conclusion that another thread is updating the CBS value, performing a waiting operation until after acquiring the second lock, Update the CBS value and unlock it.
  • the first execution module 202 and the second execution module 203 further include: a fourth determining unit: configured to determine whether the resource of the CBS value can be occupied, and obtain the first Four judgment results;
  • a fifth updating unit configured to: when the fourth determining result indicates that no other thread occupies the resource of the CBS value, obtain a conclusion that no other thread is updating the CBS value, occupying the CBS value, and updating the Describe the CBS value and release it;
  • a sixth updating unit configured to: when the fourth determining result indicates that another thread occupies the resource of the CBS value, obtain a conclusion that another thread is updating the CBS value, and perform a waiting operation until the CBS value is occupied. After the resources are updated, the CBS value is updated and released.
  • the first execution module 202 further includes:
  • a first acquiring unit configured to acquire, according to the arriving TICK value, a number of newly added tokens when the to-be-sent packet arrives;
  • a second acquiring unit configured to acquire, according to the number of newly added tokens and the CBS value, the number of available tokens when the to-be-sent packet arrives;
  • a third acquiring unit configured to obtain a required number of tokens for sending the to-be-sent packet; and a fifth determining unit: configured to wait when the second determining result indicates that the resource that cannot occupy the CBS value is used, Obtaining a fifth judgment result;
  • a first execution subunit configured to: when the fifth determination result indicates that the number of available tokens is greater than or equal to the number of required tokens for sending the to-be-sent packet, the network forwarding device sends the to-be-sent The judgment processing result of the packet is sent, otherwise the judgment result of the network forwarding device not transmitting the to-be-sent packet is obtained.
  • the second execution module 203 further includes:
  • the fourth obtaining unit is configured to obtain the number of required tokens for sending the to-be-sent packet;
  • the sixth determining unit is configured to determine, according to the CBS value, whether the CBS value is greater than or equal to sending the to-be-sent packet The number of required tokens, the sixth judgment result;
  • a second execution subunit configured to obtain the network forwarding device when the sixth determination result indicates that the number of available tokens is greater than or equal to the number of required tokens for sending the to-be-sent packet Sending a judgment processing result of the to-be-sent packet, otherwise obtaining a judgment processing conclusion that the network forwarding device does not send the to-be-sent packet.
  • the device further includes:
  • the packet obtaining module is configured to obtain the to-be-sent packet according to the priority of the packet. Specifically, when the packet forwarding device uses the token bucket technology to forward the packet, the computing method of each thread and the time point of updating the shared data are reasonably arranged, thereby effectively solving the inaccurate sharing data in the multi-threading. The problem of the packet forwarding loss is caused by the packet forwarding module, so that the packet forwarding device can ensure that the network forwarding device makes full use of the bandwidth in the service. If no packet is lost, the packet with the highest priority is sent preferentially.
  • FIG. 3 is a schematic flowchart of another method for forwarding a 3 ⁇ 4 text according to an embodiment of the present invention.
  • a packet forwarding method is used in a network forwarding device, and includes:
  • Step 301 According to the priority of the packet, the two threads respectively obtain respective to-be-sent "3 ⁇ 4 texts; specifically, the following steps are included:
  • Step 3011 According to the queue allocation policy, the packet is divided into a PQ queue, a WFQ queue, a protocol queue, and a default queue by using a linked list.
  • the number of queues supported by one of the interfaces should be set as follows:
  • Qnum is the total number of queues supported by the interface
  • Qpqnum is the number of PQ queues supported by the port
  • Qwfqnum is the number of WFQ queues supported by the interface
  • Qprotol is the protocol queue supported by the interface
  • Qdef is supported by the interface The default number of queues.
  • Step 3012 Select a queue to be sent according to the priority of each queue.
  • the optimal to-be-sent message is selected.
  • FIG. 4 is a schematic diagram of a first lock application process of a message forwarding method according to an embodiment of the present invention.
  • the first lock may be a try lock, and when the thread acquires the lock, the ability to perform some operation is obtained.
  • Step 303 The thread that obtains the first lock selects the CBS value and reaches the TICK value to perform a transmission determination process of whether to send the to-be-sent message. Specifically, the following steps are included:
  • Step 3031 Obtain a new number of cards when the to-be-sent message arrives according to the arrival TICK value; the arrival TICK value refers to a TICK count when the previous message arrives.
  • Step 3032 Obtain, according to the number of newly added tokens and the CBS value, the number of available tokens when the to-be-sent packet arrives;
  • Step 3033 Obtain a required number of tokens for sending the to-be-sent packet.
  • Step 3034 Determine whether the number of available tokens is greater than or equal to the number of required tokens for sending the to-be-sent packet, and obtain a determination result.
  • Step 3035 The network forwarding device sends the to-be-sent packet when the number of available tokens is greater than or equal to the number of required tokens to send the to-be-sent packet; The network forwarding device does not send the to-be-sent message.
  • the network forwarding device stores a bandwidth setting configuration table, which is as follows:
  • Tremain(n-1)+T newly added > Tpkt is established, and the to-be-sent is sent.
  • Tremain(n) MIN(Tburst,( Tremain(n-1)+ TNew - Tpkt))
  • Trate - interface tuning rate configuration value Tpkt - the number of tokens required to send the message to be sent; Lpkt - the length of the message to be sent; L compensation - the extra bandwidth overhead of the physical link (eg Preamble field, CC field, frame interval, etc.; T new - new token number; Tn - tick count when the message to be sent arrives; Tn-1 - tick count when the previous message arrives; Tremain(n) - the number of remaining tokens after the message to be sent is sent; Tremain(nl) - the number of remaining tokens after the last message is sent; Tburst - the maximum number of tokens that the token bucket can hold.
  • Tpkt the number of tokens required to send the message to be sent
  • Lpkt the length of the message to be sent
  • L compensation - the extra bandwidth overhead of the physical link eg Preamble field, CC field, frame interval, etc.
  • T new - new token number Tn - tick count when the message to
  • Step 304 Send the to-be-sent message according to the judgment result, update the arrival TICK value, and unlock.
  • Step 305 The thread that does not obtain the first lock selects only the CBS value to perform the sending and determining process of sending the to-be-sent message.
  • the specific steps include the following steps:
  • Step 3051 Obtain a required number of tokens for sending the to-be-sent packet.
  • Step 3052 Determine, according to the CBS value, whether the CBS value is greater than or equal to the number of required tokens for sending the to-be-sent packet, and obtain a determination result;
  • Step 3053 When the judgment result indicates that the CBS value is greater than or equal to the number of required tokens for sending the to-be-sent packet, the network forwarding device sends the to-be-sent packet, otherwise the network forwarding device The to-be-sent message is not sent.
  • the length of the packet to be sent of the thread that does not obtain the first lock is 300 bytes
  • the length of the physical layer prefix of the Ethernet packet is 26 bytes
  • the number of remaining tokens cbs is 400 (byte).
  • Tremain(n-l) > Tpkt is established, and the 4th message to be sent is sent.
  • Step 306 Send the to-be-sent packet according to the judgment result.
  • FIG. 5 is a schematic diagram of a problem caused by calculation of time increments for each thread.
  • tick 200t
  • thread 1 starts at 500t
  • thread 2 starts at 700t.
  • the tick is 200t (the arrival time of the previous message)
  • the common time increment of two threads is 800t. Obviously, from 200t when the previous message arrives to when thread 2 arrives.
  • the actual experience time is 500t. Therefore, the two threads repeatedly calculate the time increment of 300t. Adding a token of 300t time to the token bucket will increase the sending capacity of the token bucket, and the speed limit is not allowed. , The message was lost.
  • the embodiment of the present invention uses the try lock technique to ensure that only one thread performs the calculation and update of the time increment at the same time.
  • FIG. 6 is a schematic diagram of a second lock application process of a message forwarding method according to an embodiment of the present invention.
  • the second lock may be a spin lock, which proposes a lock mechanism for realizing protection of shared resources. If the spin lock is already held by another execution unit, the caller always loops there. See if the holder of the spin lock has released the lock.
  • Step 308 Obtain the thread of the second lock, update the CBS value, and unlock.
  • the thread of the spin lock is obtained, which may be any one of the two threads, so the update result of the CBS value may be the calculation result of the thread that obtains the first lock:
  • Tremain(n) MIN(Tburst,( Tremain(n-1)+ TNew - Tpkt)
  • Step 309 The thread that does not obtain the second lock determines whether the second lock can be obtained while waiting.
  • the thread that does not obtain the spin lock continues to loop, and it is determined whether the holder of the spin lock has released the lock.
  • the thread that does not obtain the spin lock continues to loop, and it is determined whether the holder of the spin lock has released the lock.
  • only two threads are taken as an example to illustrate. In an actual situation, it may be that multiple threads jointly preempt the spin lock.
  • Step 310 When the second lock is available, acquire the second lock, update the CBS value, and unlock.
  • the spin lock technology is used to ensure that only the spin lock is obtained at the same time.
  • the thread can update the CBS value, avoiding the technical problem that multiple threads simultaneously update the CBS value to form dirty data.
  • FIG. 7 is another schematic structural diagram of a packet forwarding apparatus according to an embodiment of the present invention. As shown in FIG. 7, the packet forwarding apparatus is used for a network forwarding device, including a coprocessor 1, a network processor 2, and a memory 3. , Specifically:
  • the coprocessor 1 is configured to translate a configuration command from a network and a configuration file into a bandwidth tuning configuration table; and read process data of the token bucket calculation and display the same.
  • the coprocessor 1 specifically includes:
  • Translation unit 11 configured to translate configuration commands from the network, configuration files into a bandwidth tuning configuration table
  • Display unit 12 configured to display process data when the token bucket is calculated
  • Communication unit 13 is configured to interact with data in the memory.
  • the network processor 2 is configured to send and receive a message, and store the received message into the memory; select a message to be sent; and perform a determination process of whether to send the to-be-sent message.
  • the network processor 2 specifically includes:
  • Transceiver unit 21 configured to receive traffic on the link and convert it into a message, or convert the message into traffic on the link and send it.
  • the packet processing unit 22 is configured to queue the packets and select the packets to be sent according to the priority of the queue.
  • the judging processing unit 23 is configured to perform multi-threaded token bucket calculation, and determine whether to send the parsing of the to-be-sent packet, and return the judging processing result to the transceiver unit.
  • the memory 3 is configured to store a bandwidth tuning configuration table having a CBS value and a TICK value, process data when the token bucket is calculated, and buffering or storing the message.
  • the memory 3 specifically includes:
  • a configuration table storage unit 31 configured to store the bandwidth tuning configuration table
  • a message storage unit 32 configured to cache or store a message
  • Process data storage unit 33 configured to store process data when the token bucket is calculated.
  • the above modules cooperate with each other, and the specific working process is as follows: First, the translation module 11 translates the configuration commands from the network and the configuration file into a bandwidth setting configuration table, and stores them in the configuration table through the communication unit 13 Unit 31.
  • the transceiver unit 21 receives the traffic on the link and converts it into a message.
  • the message processing unit 22 stores the message in the form of a queue into the message storage unit 32. Then, the message processing unit 22 polls the message storage.
  • the packet queue in the unit 32 selects the packet of the link header of the queue with the highest priority as the packet to be sent.
  • the judgment processing unit 23 reads the related information including the length information of the message to be transmitted, and reads the bandwidth setting configuration table from the configuration table storage unit 31, according to the message information and the bandwidth setting configuration table, according to the embodiment of the present invention.
  • the process data at the time of card bucket calculation is stored in the process data storage unit 33.
  • the display unit 12 reads the process data of the token bucket calculation from the process data storage unit 33 through the communication unit 13 and displays it, thereby displaying to the user the bandwidth setting process using the multi-thread token bucket technology, which facilitates function debugging and parameters. set up.
  • the translation unit 11, the text processing unit 22, the determination processing unit 23, the process data storage unit 33, and the configuration table storage unit 31 may also be assembled into a bandwidth tuning scheduling subsystem.
  • traffic shaping is required, the translation unit is enabled.
  • the bandwidth setting scheduling subsystem the packet enters the system, and is sent according to the priority of the packet and the configured bandwidth limit, otherwise the normal packet forwarding is performed.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can be embodied in the form of one or more computer program products embodied on a computer usable storage medium (including but not limited to disk storage and optical storage, etc.) in which computer usable program code is embodied.
  • a computer usable storage medium including but not limited to disk storage and optical storage, etc.
  • These computer program instructions can be provided to a general purpose computer, a special purpose computer, an embedded processor or other programmable data processing device processor to produce a machine such that a flow or a block diagram of a flow or a block diagram or A device that has multiple functions specified in the box.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

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

Abstract

本发明提供一种报文转发方法、装置及网络转发设备,基于多线程令牌桶技术进行报文转发,用于保存有CBS值和到达TICK值的网络转发设备的多线程中的任一线程,该方法包括:待发送报文到达时,判断是否能够获得第一锁,获取第一判断结果;在所述第一判断结果指示能够获得所述第一锁时,获取所述第一锁,选择CBS值和到达TICK值进行是否发送所述待发送报文的发送判断处理,并在发送所述待发送报文后更新CBS值和到达TICK值并解锁;在所述第一判断结果指示不能获得所述第一锁时,从CBS值和到达TICK值中只选择CBS值进行是否发送所述待发送报文的发送判断处理,并在发送所述待发送报文后,更新CBS值。

Description

一种报文转发方法、 装置及网络转发设备 技术领域
本发明涉及通信领域, 尤其涉及一种报文转发方法、 装置及网络转发 设备。 背景技术
路由器、 交换机是数据通信领域不可缺少的重要设备, 由于地域的限 制, 各设备一般相聚较远, 为了保证长距离信号传输的可靠性, 需要传输 设备进行信号中继。 这种传输设备成本较高, 一般会根据需要进行配置, 由于运营方考虑成本, 其带宽往往低于路由器、 交换机实际标称的接口带 宽。 而两台路由器、 交换机之间接口自协商的带宽, 无法反应传输设备的 实际带宽能力, 就会导致路由器、 交换机等通信设备实际出口的带宽, 远 大于链路最大能力, 使得大量的数据报文丟失, 影响各种业务的正常运行。
目前, 网络运营方为了不影响业务, 通常在一些关键接口升级传输设 备, 这些接口往往存在大部分时间处于低流量状态, 偶尔出现流量突发的 情况, 因此, 升级传输设备不但造成资源的浪费, 也使网络运营方的成本 大大增加, 因此亟需一种链路带宽整定方法, 在不升级传输设备的条件下, 应对流量突发状况, 充分使用链路带宽, 保证业务不受影响。
常见的流量整形通常使用緩冲区和令牌桶来完成, 当报文的发送速度 过快时, 首先在緩冲区进行緩存, 在令牌桶的控制下再均勾地发送这些被 緩冲的报文。 可现有技术的令牌桶算法只是一种针对单线程的算法, 对于 多线程共同使用令牌桶算法进行流量整形就会出现共享数据更新不准确、 令牌重复添加等导致计算错误、 报文丟失的现象, 所以现急需一种多线程 下的令牌桶整形方法。 发明内容
为解决现有存在的技术问题, 本发明实施例提供了一种报文转发方法、 装置及网络转发设备。
本发明实施例提供了一种报文转发方法, 用于保存有承诺突发尺寸
( CBS )值和到达嘀嗒(TICK )值的网络转发设备, 所述网络转发设备基 于多线程令牌桶技术进行报文转发, 所述报文转发方法用于所述多线程中 的任一线程, 所述报文转发方法包括:
第一判断步骤: 待发送报文到达时, 判断是否能够获得第一锁, 获取 第一判断结果;
第一执行步骤: 在所述第一判断结果指示能够获得所述第一锁时, 获 取所述第一锁, 选择所述 CBS值和到达 TICK值进行是否发送所述待发送 报文的发送判断处理, 并在发送所述待发送报文后更新所述 CBS值和到达 TICK值并解锁;
第二执行步骤: 在所述第一判断结果指示不能获得所述第一锁时, 从 所述 CBS值和到达 TICK值中只选择所述 CBS值进行是否发送所述待发送 文的发送判断处理, 并在发送所述待发送 文后, 更新所述 CBS值。 优选地, 所述更新所述 CBS值的方法具体包括:
第二判断步骤: 判断是否有其他线程在更新所述 CBS值, 获取第二判 断结果;
第一更新步骤: 在所述第二判断结果指示没有其他线程在更新所述 CBS值时, 更新所述 CBS值;
第二更新步骤: 在所述第二判断结果指示有其他线程在更新所述 CBS 值时, 执行等待操作, 直至没有其他线程更新所述 CBS值后更新所述 CBS 值。
优选地, 所述更新所述 CBS值的方法具体包括: 第三判断步骤: 判断是否能够获得第二锁, 获取第三判断结果; 第三更新步骤: 在所述第三判断结果指示能够获得所述第二锁时, 得 出没有其他线程在更新所述 CBS值的结论,获取所述第二锁,更新所述 CBS 值并解锁;
第四更新步骤: 在所述第三判断结果指示不能获得所述第二锁时, 得 出有其他线程在更新所述 CBS值的结论, 执行等待操作, 直到获取所述第 二锁后, 更新所述 CBS值并解锁。
优选地, 所述更新所述 CBS值的方法包括:
第四判断步骤: 判断是否有其他线程占用所述 CBS值的资源, 获取第 四判断结果;
第五更新步骤: 在所述第四判断结果指示没有其他线程占用所述 CBS 值的资源时, 得出没有其他线程在更新所述 CBS值的结论, 占用所述 CBS 值的资源, 更新所述 CBS值并释放;
第六更新步骤: 在所述第四判断结果指示有其他线程占用所述 CBS值 的资源时, 得出有其他线程在更新所述 CBS值的结论, 执行等待操作, 直 到占用所述 CBS值的资源后, 更新所述 CBS值并释放。
优选地, 所述第一执行步骤中选择所述 CBS值和所述到达 TICK值进 第一获取步骤:根据所述到达 TICK值,获取所述待发送报文到达时的 新增令牌数;
第二获取步骤: 根据所述新增令牌数及所述 CBS值, 获取所述待发送 报文到达时的可用令牌数;
第三获取步骤: 获取发送所述待发送报文的所需令牌数;
第五判断步骤: 判断所述可用令牌数是否大于或者等于发送所述待发 送报文的所需令牌数, 获取第五判断结果; 第一执行子步骤: 在所述第五判断结果指示所述可用令牌数大于或者 等于发送所述待发送报文的所需令牌数时, 得出所述网络转发设备发送所 述待发送报文的判断处理结论, 否则得出所述网络转发设备不发送所述待 发送报文的判断处理结论。
优选地, 所述第二执行步骤中只选择所述 CBS值进行是否发送所述待 发送 "^文的发送判断处理具体包括:
第四获取步骤: 获取发送所述待发送报文的所需令牌数;
第六判断步骤: 根据所述 CBS值, 判断所述 CBS值是否大于或者等于 发送所述待发送报文的所需令牌数, 获取第六判断结果;
第二执行子步骤: 在所述第六判断结果指示所述 CBS值大于或者等于 发送所述待发送报文的所需令牌数时, 得出所述网络转发设备发送所述待 报文的判断处理结论。
优选地, 所述方法还包括:
报文获取步骤: 根据所述报文的优先级, 获取所述待发送报文。
优选地, 所述报文获取步骤具体包括:
队列形成步骤: 根据队列分配策略, 釆用链表形式, 将"¾文分成 PQ队 列、 WFQ队列、 协议队列及默认队列;
队列选择步骤: 根据所述各队列的优先级, 选出待发送的队列; 文。
本发明实施例还提供一种报文转发装置, 用于保存有 CBS 值和到达 TICK值的网络转发设备, 所述网络转发设备基于多线程令牌桶技术进行报 文转发, 所述报文转发装置用于所述多线程中的任一线程, 所述报文转发 装置包括: 第一判断模块: 配置为待发送报文到达时, 判断是否能够获得第一锁, 获取第一判断结果;
第一执行模块: 配置为在所述第一判断结果指示能够获得所述第一锁 时, 获取所述第一锁, 选择所述 CBS值和到达 TICK值进行是否发送所述 待发送报文的发送判断处理, 并在发送所述待发送报文后更新所述 CBS值 和到达 TICK值并解锁;
第二执行模块: 配置为在所述第一判断结果指示不能获得所述第一锁 时,从所述 CBS值和到达 TICK值中只选择所述 CBS值进行是否发送所述 待发送 文的发送判断处理, 并在发送所述待发送 文后, 更新所述 CBS 值。
优选地, 所述第一执行模块和第二执行模块包括:
第二判断单元: 配置为判断是否有其他线程在更新所述 CBS值, 获取 第二判断结果;
第一更新单元: 配置为在所述第二判断结果指示没有其他线程在更新 所述 CBS值时, 更新所述 CBS值;
第二更新单元: 配置为在所述第二判断结果指示有其他线程在更新所 述 CBS值时,执行等待操作, 直至没有其他线程更新所述 CBS值后更新所 述 CBS值。
优选地, 所述第一执行模块和第二执行模块还包括:
第三判断单元: 配置为判断是否能够获得第二锁, 获取第三判断结果; 第三更新单元: 配置为在所述第三判断结果指示能够获得所述第二锁 时, 得出没有其他线程在更新所述 CBS值的结论, 获取所述第二锁, 更新 所述 CBS值并解锁;
第四更新单元: 配置为在所述第三判断结果指示不能获得所述第二锁 时, 得出有其他线程在更新所述 CBS值的结论, 执行等待操作, 直到获取 所述第二锁后, 更新所述 CBS值并解锁。
优选地, 所述第一执行模块和第二执行模块还包括:
第四判断单元: 配置为判断是否有其他线程占用所述 CBS值的资源, 获取第四判断结果;
第五更新单元: 配置为在所述第四判断结果指示没有其他线程占用所 述 CBS值的资源时,得出没有其他线程在更新所述 CBS值的结论, 占用所 述 CBS值的资源, 更新所述 CBS值并释放;
第六更新单元: 配置为在所述第四判断结果指示有其他线程占用所述 CBS值的资源时, 得出有其他线程在更新所述 CBS值的结论, 执行等待操 作, 直到占用所述 CBS值的资源后, 更新所述 CBS值并释放。
优选地, 所述第一执行模块还包括:
第一获取单元: 配置为根据所述到达 TICK值,获取所述待发送报文到 达时的新增令牌数;
第二获取单元: 配置为根据所述新增令牌数及所述 CBS值, 获取所述 待发送报文到达时的可用令牌数;
第三获取单元: 配置为获取发送所述待发送报文的所需令牌数; 第五判断单元: 配置为判断所述可用令牌数是否大于或者等于发送所 述待发送报文的所需令牌数, 获取第五判断结果;
第一执行子单元: 配置为在所述第五判断结果指示所述可用令牌数大 于或者等于发送所述待发送报文的所需令牌数时, 得出所述网络转发设备 发送所述待发送报文的判断处理结论, 否则得出所述网络转发设备不发送 所述待发送报文的判断处理结论。
优选地, 所述第二执行模块还包括:
第四获取单元: 配置为获取发送所述待发送报文的所需令牌数; 第六判断单元: 配置为根据所述 CBS值, 判断所述 CBS值是否大于或 者等于发送所述待发送报文的所需令牌数, 获取第六判断结果; 第二执行子单元: 配置为在所述第六判断结果指示所述 CBS值大于或 者等于发送所述待发送报文的所需令牌数时, 得出所述网络转发设备发送 所述待发送报文的判断处理结论, 否则得出所述网络转发设备不发送所述 待发送报文的判断处理结论。
优选地, 所述装置还包括:
报文获取模块: 配置为根据所述报文的优先级, 获取所述待发送报文。 本发明实施例还提供一种网络转发设备, 保存有 CBS值和到达 TICK 值, 所述网络转发设备基于多线程令牌桶技术进行报文转发, 包括:
存储器: 配置为存储具有 CBS值和到达 TICK值的带宽整定配置表、 令牌桶计算时的过程数据; 緩存或者存储报文;
协处理器: 配置为将来自网络、 配置文件的配置命令翻译成带宽整定 配置表; 并读取所述令牌桶计算时的过程数据并展示;
网络处理器: 配置为收发报文, 并将接收到的报文存入所述存储器; 选取待发送报文; 并进行所述是否发送所述待发送报文的判断处理操作。
釆用本发明实施例的报文转发方法及装置, 由于在利用令牌桶技术转 发报文时, 合理的安排了各线程的计算方法及更新共享数据的时间点, 有 效的解决了多线程下由于共享数据不准确、 时间增量重复计算而导致的报 文转发丟失的问题; 另外, 由于在转发之前增加了按报文的优先级选取待 发送报文的步骤, 使得本发明实施例的方法及装置能够保证网络转发设备 充分利用带宽, 在业务不丟包的情况下, 优先发送优先级高的报文。 附图说明
图 1为本发明一实施例的报文转发方法流程示意图;
图 2为本发明一实施例的报文转发装置结构示意图;
图 3为本发明另一实施例的报文转发方法流程示意图; 图 4为本发明实施例的报文转发方法的第一锁应用过程示意图; 图 5为各线程均进行时间增量的计算而产生的问题示意图;
图 6为本发明实施例的报文转发方法的第二锁应用过程示意图; 图 7为本发明另一实施例的报文转发装置结构示意图。 具体实施方式
为使本发明要解决的技术问题、 技术方案和有益效果更加清楚, 下面 将结合附图及具体实施例进行详细描述。
图 1为本发明一实施例的 文转发方法的流程示意图, 如图 1所示, 本发明实施例提供一种报文转发方法, 基于多线程令牌桶技术进行报文转 发, 用于保存有 CBS值和到达 TICK值的网络转发设备, 所述报文转发方 法用于所述多线程中的任一线程, 所述报文转发方法包括:
第一判断步骤 101 : 待发送报文到达时, 判断是否能够获得第一锁, 获 取第一判断结果;
第一执行步骤 102: 在所述第一判断结果指示能够获得所述第一锁时, 获取所述第一锁, 选择所述 CBS值和到达 TICK值进行是否发送所述待发 送报文的发送判断处理, 并在发送所述待发送报文后, 更新所述 CBS值和 到达 TICK值并解锁;
第二执行步骤 103: 在所述第一判断结果指示不能获得所述第一锁时, 从所述 CBS值和到达 TICK值中只选择所述 CBS值进行是否发送所述待发 送报文的发送判断处理, 并在发送所述待发送报文后, 更新所述 CBS值。
釆用上述实施例的报文转发方法, 在利用令牌桶技术进行多线程报文 转发的时候, 由于限制了同一时刻只有获得所述第一锁的线程才能进行时 间增量的计算, 而所述第一锁是唯一的, 从而不会因为多个线程同时进行 时间上的累加, 造成令牌填充值, 即新增令牌数重复计算, 而导致可用令 牌数偏大, 限速不准, 报文丟失的问题。 而对于不进行时间增量计算的线 程, 也进行了发送能力的计算, 在所述网络转发设备限制的流量范围内进 行报文的转发, 多线程提高了转发效率, 充分的利用了带宽。
由于多线程共享同一数据资源, 并且均有权对共享数据资源进行更新, 这就导致了另一问题, 多线程同时更新同一数据而产生脏数据的问题, 为 第二判断步骤 201 : 判断是否有其他线程在更新所述 CBS值, 获取第 二判断结果;
第一更新步骤 202:在所述第二判断结果指示没有其他线程在更新所述 CBS值时, 更新所述 CBS值;
第二更新步骤 203 : 在所述第二判断结果指示有其他线程在更新所述
CBS值时, 执行等待操作, 直至没有其他线程更新所述 CBS值后更新所述 CBS值。
釆用上述的技术方案, 避免了多线程同时更新所述 CBS值的问题, 避 免了脏数据的产生。
对于所述 CBS值的更新, 可釆用如下具体方案:
第三判断步骤 2011 : 判断是否能够获得第二锁, 获取第三判断结果; 第三更新步骤 2021 :在所述第三判断结果指示能够获得所述第二锁时, 得出没有其他线程在更新所述 CBS值的结论, 获取所述第二锁, 更新所述
CBS值并解锁;
第四更新步骤 2031 :在所述第三判断结果指示不能获得所述第二锁时, 得出有其他线程在更新所述 CBS值的结论, 执行等待操作, 直到获取所述 第二锁后, 更新所述 CBS值并解锁。
釆用上述实施例的技术方案, 由于只有获得第二锁的线程才能对所述 CBS 值进行更新, 而所述第二锁是唯一的, 从而保证了在同一时刻只有一 个线程可以对所述 CBS值进行修改, 解决了多线程同时读写覆盖, 形成脏 数据的问题。
对于所述 CBS值的更新, 还可釆用如下另一具体方案:
第四判断步骤 2012: 判断是否有其他线程占用所述 CBS值的资源, 获 取第四判断结果;
第五更新步骤 2022: 在所述第四判断结果指示没有其他线程占用所述 CBS值的资源时, 得出没有其他线程在更新所述 CBS值的结论, 占用所述 CBS值的资源, 更新所述 CBS值并释放;
第六更新步骤 2032: 在所述第四判断结果指示有其他线程占用所述 CBS值的资源时, 得出有其他线程在更新所述 CBS值的结论, 执行等待操 作, 直到占用所述 CBS值的资源后, 更新所述 CBS值并释放。
釆用上述实施例的技术方案, 由于限制了只有占用了所述 CBS值的资 源的线程才可以对所述 CBS值进行更新, 从而保证了在同一时刻只有一个 线程可以对所述 CBS值进行修改, 同样解决了多线程读写覆盖, 形成脏数 据的问题。
在所述第一执行步骤 102中, 获取所述第一锁的线程, 选择所述 CBS 值和所述到达 TICK值进行是否发送所述待发送 "^文的发送判断处理步骤 具体包括:
第一获取步骤 1021 : 根据所述到达 TICK值, 获取所述待发送报文到 达时的新增令牌数;
第二获取步骤 1022: 根据所述新增令牌数及所述 CBS值, 获取所述待 发送报文到达时的可用令牌数;
第三获取步骤 1023: 获取发送所述待发送报文的所需令牌数; 第五判断步骤 1024: 判断所述可用令牌数是否大于或者等于发送所述 待发送报文的所需令牌数, 获取第五判断结果;
第一执行子步骤 1025: 在所述第五判断结果指示所述可用令牌数大于 或者等于发送所述待发送报文的所需令牌数时, 得出所述网络转发设备发 送所述待发送报文的判断处理结论, 否则得出所述网络转发设备不发送所 述待发送报文的判断处理结论。
上述实施例的技术方案, 获得所述第一锁的线程, 釆用了令牌桶算法 进行流量整形, 限制数据的平均传输速率的同时还允许某种程度的突发传 输, 对于没能发送的所述待发送报文, 随着时间的累加, 等到所述网络转 发设备具备了转发能力的时候, 再发送, 最大程度的利用了带宽。
在所述第二执行步骤 103 中, 没能获取所述第一锁的线程, 只选择所 第四获取步骤 1031 : 获取发送所述待发送报文的所需令牌数; 第六判断步骤 1032: 根据所述 CBS值, 判断所述 CBS值是否大于或 者等于发送所述待发送报文的所需令牌数, 获取第六判断结果;
第二执行子步骤 1033 :在所述第六判断结果指示所述 CBS值大于或者 等于发送所述待发送报文的所需令牌数时, 得出所述网络转发设备发送所 述待发送报文的判断处理结论, 否则得出所述网络转发设备不发送所述待 发送报文的判断处理结论。
上述实施例的技术方案, 当线程没能获得所述第一锁时, 只进行了所 述剩余令牌数与发送所述待发送报文的所需令牌数的减法计算, 没有进行 时间增量的累加, 在保证了限速准确, 有效进行转发的情况下, 多线程提 高了所述网络转发设备的发送效率。
在上述利用令牌桶技术多线程进行报文转发之前, 所述方法还包括对 报文进行选择的步骤, 具体为:
报文获取步骤 100: 根据所述报文的优先级, 获取所述待发送报文。 上述实施例的技术方案, 由于增加了按报文的优先级选取待发送报文 的步骤, 使得所述网络转发设备充分利用带宽, 在业务不丟包的情况下, 优先发送优先级高的报文, 而对于在初次计算后不能及时发送的报文, 也 可以按优先级再次排列, 从而保证优先级高的报文最先被发送。
现有技术中, 有多种按报文的优先级选取待发送报文的方法, 但大多 都运算复杂, 由于使用本发明实施例的网络转发设备需要承担多线程令牌 桶的计算, 所述双重运算对网络转发设备的运算能力有了很高的要求, 为 了减少网络转发设备的计算负担, 本发明釆用以下具体实施方式来实现报 文的优选, 所述报文获取步骤 100具体包括:
队列形成步骤 1001 : 根据队列分配策略, 釆用链表形式, 将报文分成 PQ队列、 WFQ队列、 协议队列及默认队列;
队列选择步骤 1002: 根据所述各队列的优先级, 选出待发送的队列; 送报文。
釆用上述实施例的技术方案, 与现有技术相比, 降低了获取高优先级 报文的运算复杂度, 减小了所述网络转发设备的运算负担, 避免了设备死 机、 延时等现象的发生。
以上实施例仅为本发明的优选实施例, 对于将上述各种实施例进行组 合及修饰所得出的其他变化实施方式, 均应视为在本发明的保护范围内。
图 2为本发明的实施例的报文转发装置的一结构示意图, 如图 2所示, 本发明实施例还提供一种报文转发装置, 基于多线程令牌桶技术进行报文 转发, 用于保存有 CBS值和到达 TICK值的网络转发设备, 所述报文转发 装置用于所述多线程中的任一线程, 所述报文转发装置包括:
第一判断模块 201 : 配置为待发送报文到达时, 判断是否能够获得第一 锁, 获取第一判断结果;
第一执行模块 202:配置为在所述第一判断结果指示能够获得所述第一 锁时, 获取所述第一锁, 选择所述 CBS值和到达 TICK值进行是否发送所 述待发送报文的发送判断处理, 并在发送所述待发送报文后更新所述 CBS 值和到达 TICK值并解锁;
第二执行模块 203 :配置为在所述第一判断结果指示不能获得所述第一 锁时,从所述 CBS值和到达 TICK值中只选择所述 CBS值进行是否发送所 述待发送报文的发送判断处理,并在发送所述待发送报文后,更新所述 CBS 值。
优选地, 所述第一执行模块 202和第二执行模块 203包括:
第二判断单元: 配置为判断是否有其他线程在更新所述 CBS值, 获取 第二判断结果;
第一更新单元: 配置为在所述第二判断结果指示没有其他线程在更新 所述 CBS值时, 更新所述 CBS值;
第二更新单元: 配置为在所述第二判断结果指示有其他线程在更新所 述 CBS值时,执行等待操作, 直至没有其他线程更新所述 CBS值后更新所 述 CBS值。
优选地, 所述第一执行模块 202和第二执行模块 203还包括: 第三判断单元: 配置为判断是否能够获得第二锁, 并获取第三判断结 果;
第三更新单元: 配置为在所述第三判断结果指示能够获得所述第二锁 时, 得到没有其他线程在更新所述 CBS值的结论, 并获取所述第二锁, 更 新所述 CBS值并解锁;
第四更新单元: 配置为在所述第三判断结果指示不能获得所述第二锁 时, 得到有其他线程在更新所述 CBS值的结论, 执行等待操作, 直到获取 所述第二锁后, 更新所述 CBS值并解锁。
优选地, 所述第一执行模块 202和第二执行模块 203还包括: 第四判断单元: 配置为判断是否能够占用所述 CBS值的资源, 获取第 四判断结果;
第五更新单元: 配置为在所述第四判断结果指示没有其他线程占用所 述 CBS值的资源时,得到没有其他线程在更新所述 CBS值的结论, 占用所 述 CBS值的资源, 更新所述 CBS值并释放;
第六更新单元: 配置为在所述第四判断结果指示有其他线程占用所述 CBS值的资源时, 得到有其他线程在更新所述 CBS值的结论, 执行等待操 作, 直到占用所述 CBS值的资源后, 更新所述 CBS值并释放。
优选地, 所述第一执行模块 202还包括:
第一获取单元: 配置为根据所述到达 TICK值,获取所述待发送报文到 达时的新增令牌数;
第二获取单元: 配置为根据所述新增令牌数及所述 CBS值, 获取所述 待发送报文到达时的可用令牌数;
第三获取单元: 配置为获取发送所述待发送报文的所需令牌数; 第五判断单元: 配置为在所述第二判断结果指示不能占用所述 CBS值 的资源时, 进行等待, 获取第五判断结果;
第一执行子单元: 配置为在所述第五判断结果指示所述可用令牌数大 于或者等于发送所述待发送报文的所需令牌数时, 得到所述网络转发设备 发送所述待发送报文的判断处理结论, 否则得到所述网络转发设备不发送 所述待发送报文的判断处理结论。
优选地, 所述第二执行模块 203还包括:
第四获取单元: 配置为获取发送所述待发送报文的所需令牌数; 第六判断单元:配置为根据所述 CBS值判断所述 CBS值是否大于或者 等于发送所述待发送报文的所需令牌数, 获取第六判断结果;
第二执行子单元: 配置为在所述第六判断结果指示所述可用令牌数大 于或者等于发送所述待发送报文的所需令牌数时, 得到所述网络转发设备 发送所述待发送报文的判断处理结论, 否则得到所述网络转发设备不发送 所述待发送报文的判断处理结论。
优选地, 所述装置还包括:
报文获取模块: 配置为根据所述报文的优先级, 获取所述待发送报文。 具体的, 所述报文转发装置由于在利用令牌桶技术转发报文时, 合理 的安排了各线程的计算方法及更新共享数据的时间点, 有效的解决了多线 程下由于共享数据不准确而导致的报文转发丟失的问题; 另外, 由于增加 了按报文的优先级选取待发送报文的报文获取模块, 使得所述报文转发装 置能够保证网络转发设备充分利用带宽, 在业务不丟包的情况下, 优先发 送优先级高的报文。
为了使本发明的技术方案更便于理解, 下面仅针对釆用本发明的技术 方案进行报文转发的多线程中的两个线程进行具体说明。 图 3 为本发明的 实施例的"¾文转发方法的另一流程示意图。 如图 3 所示, 本发明实施例的 一种报文转发方法, 用于网络转发设备, 包括:
步骤 301 : 根据所述报文的优先级, 所述两个线程分别获取各自的待发 送"¾文; 具体包括如下步骤:
步骤 3011 : 根据队列分配策略, 釆用链表形式, 将报文分成 PQ队列、 WFQ队列、 协议队列及默认队列;
其中某一接口支持的队列数应按照如下公式设定:
num.― Q pqnum+ Qwfqnum+ Q protol Q def
式中, Qnum——接口支持的总队列数; Qpqnum—— 口支持的 PQ队 列个数; Qwfqnum——接口支持的 WFQ队列个数; Qprotol——接口支持的 协议队列; Qdef——接口支持的默认队列个数。
步骤 3012: 根据所述各队列的优先级, 选出待发送的队列;
在从属于某接口的不同队列中, 选取本轮需要发送的队列, 各个队列 的优先级如下公式设定:
Qprotol
Figure imgf000018_0001
步骤 3013:
由以上优选的实施方式, 选取出最优的待发送报文。
步骤 302: 两线程均判断是否获得第一锁。 图 4为本发明的实施例的报 文转发方法的第一锁应用过程示意图。如图 4所示,所述第一锁可为 try锁, 当线程获取该锁时, 即获得了某种运算的能力。
步骤 303: 获得所述第一锁的线程选择所述 CBS值和到达 TICK值进 行是否发送所述待发送报文的发送判断处理。 具体包括如下步骤:
步骤 3031 : 根据到达 TICK值, 获取所述待发送报文到达时的新增令 牌数; 所述到达 TICK值指上一报文到达时的 TICK计数。
步骤 3032: 根据所述新增令牌数及所述 CBS值, 获取所述待发送报文 到达时的可用令牌数;
步骤 3033: 获取发送所述待发送报文的所需令牌数;
步骤 3034: 判断所述可用令牌数是否大于或者等于发送所述待发送报 文的所需令牌数, 获取一判断结果;
步骤 3035: 在所述判断结果指示所述可用令牌数大于或者等于发送所 述待发送报文的所需令牌数时, 所述网络转发设备发送所述待发送报文; 否则, 所述网络转发设备不发送所述待发送报文。
为了便于理解, 下面用公式具体说明上述判断处理过程。 所述网络转 发设备存储有一带宽整定配置表, 具体如下:
Figure imgf000018_0002
表 1 带宽整定配置表 假设 cir是 800,000,000 ( b/s ), 上一报文到达时的 tick计数为 500 ( t ), 待发送报文的长度为 400字节, 以太报文的物理层前缀长度为 22字节, 待 发送报文的到达时间为 1000 ( t ), 剩余令牌数 cbs为 400 ( byte ), 最大容纳 令牌数 cmax为 600 ( byte ), 当前 CPU频率为 1.2 ( GHZ ), 即 1.2G ( t/s )0 Trate = 800,000,000 / 1.2G = 0.6667 (b/t)
T新增 =Trate* ( Tn-Tn-1 ) = 0.6667 * (1000 - 500 ) = 333.33 (b)
Tpkt = Lpkt+L补偿 = 400 + 22 = 422(byte)
Tremain(n-1)+ T新增 = 400 + (333.33 / 8 ) = 441.667 (byte)
此时, Tremain(n-1)+ T新增 > Tpkt成立, 发送所述待发送^艮文。
Tremain(n)= MIN(Tburst,( Tremain(n-1)+ T新增- Tpkt))
= MIN ( 600, ( 441.667 - 422 ) )
= 19.667 ( byte )
式中, Trate——接口整定速率配置值; Tpkt——发送待发送报文的所 需令牌数; Lpkt——待发送报文的长度; L补偿——物理链路的额外带宽开 销 (如前导字段, C C字段, 帧间隔等); T新增——新增令牌数; Tn—— 待发送报文到达时的 tick计数; Tn-1——上一报文到达时的 tick计数; Tremain(n)——待发送报文发送后的剩余令牌数; Tremain(n-l)——上一报 文发送后的剩余令牌数; Tburst——令牌桶最大容纳的令牌数。
假设变更条件, 此时的待发送报文的长度为 430字节, 其余条件不变。 Tpkt = pkt+L 430 + 22 = 452(byte)
此时, Τ—{η-1、+ Τ新增 <Tp 不发送所述待发送报文。
步骤 304: 根据判断结果发送所述待发送报文, 更新到达 TICK值并解 锁。
根据上面的例子, 当 成立时, 发送所述待发送报文, 更新到达 TICK值为 1000 ( t ), 并解锁, 解锁后, 所述第一锁供其它线程继 续抢占。 步骤 305: 没有获得所述第一锁的线程只选择所述 CBS值进行是否发 送所述待发送 "^文的发送判断处理。 具体包括如下步骤:
步骤 3051 : 获取发送所述待发送报文的所需令牌数;
步骤 3052: 根据所述 CBS值, 判断所述 CBS值是否大于或者等于发 送所述待发送报文的所需令牌数, 获取一判断结果;
步骤 3053:在所述判断结果指示所述 CBS值大于或者等于发送所述待 发送报文的所需令牌数时, 所述网络转发设备发送所述待发送报文, 否则 所述网络转发设备不发送所述待发送报文。
假设没有获得所述第一锁的线程的待发送报文的长度为 300字节, 以 太报文的物理层前缀长度为 26字节, 剩余令牌数 cbs为 400 ( byte ),
Tpkt = Lpkt+L补偿 = 300 + 26 = 326(byte)
此时, Tremain(n-l) > Tpkt成立, 发送所述待发送4艮文。
Tremain(n)= Tremain(n-l) - Tpkt = 400 - 326 = 74 ( byte )
步骤 306: 根据判断结果发送所述待发送报文。
上述技术方案中之所以釆用 try锁技术,是由于在多线程令牌桶计算时 可能存在以下问题: 新增令牌数重复计算。
图 5为各线程均进行时间增量的计算而产生的问题示意图。 如图 5所 示, 假如到达 tick = 200t, 线程 1开始于 500t处, 线程 2开始于 700t处, 此时虽然线程 1开始计算较早, 但是在 700t处仍然没有更新表项中 tick, 线程 1和线程 2读取到的达到 tick均为 200t (上一报文的到达时间), 因此 在计算 T新增的时候, 若两线程均釆用令牌桶算法, 线程 1用到的时间增 量为 500-200=300t, 而线程 2用到的时间增量为 700-200=500t, 两线程公用 的时间增量为 800t,显然,从上一报文到达时的 200t到线程 2的到达时 700t, 实际经历的时间为 500t, 所以, 两线程共重复计算了 300t的时间增量, 向 令牌桶多添加了 300t时间的令牌,会造成令牌桶发送能力变大, 限速不准, 报文丟失。
由于存在上述技术问题, 所以本发明实施例釆用 try锁技术, 保证了同 一时刻只有一个线程进行时间增量的计算与更新。
步骤 307: 在所述两个线程发送所述待发送报文后, 两线程均判断是否 获得第二锁。 图 6 为本发明的实施例的报文转发方法的第二锁应用过程示 意图。 如图 6所示, 所述第二锁可为自旋锁, 它是为实现保护共享资源而 提出一种锁机制, 如果自旋锁已经被别的执行单元保持, 调用者就一直循 环在那里看是否该自旋锁的保持者已经释放了锁。
步骤 308: 获得所述第二锁的线程, 更新所述 CBS值并解锁。
借用上面的例子, 获得所述自旋锁的线程, 可能是两个线程中的任一 线程, 所以所述 CBS值的更新结果有可能为获得所述第一锁的线程的计算 结果:
Tremain(n)= MIN(Tburst,( Tremain(n-1)+ T新增- Tpkt》
= MIN ( 600, ( 441.667 - 422 ) )
= 19.667 ( byte ),
或者是没有获得所述第一锁的线程的计算结果:
Tremain(n)= Tremain(n-l) - Tpkt = 400 - 326 = 74 ( byte )
步骤 309: 没有获得所述第二锁的线程, 在等待中判断是否能够获得所 述第二锁。
具体的, 没有获得所述自旋锁的线程, 就一直进行循环, 判断所述自 旋锁的保持者是否已经释放了锁。 当然, 本实施例中只以两个线程为例加 以说明, 在实际情况中, 有可能是多条线程共同抢占自旋锁,
步骤 310: 在能够获得所述第二锁时, 获取所述第二锁, 更新所述 CBS 值并解锁。
上述技术方案中釆用了自旋锁技术, 保证同一时刻只有获得自旋锁的 线程可以对 CBS值进行更新,避免了多个线程同时对所述 CBS值进行更新, 而形成脏数据的技术问题。
图 7为本发明的实施例的报文转发装置的另一结构示意图, 如图 7所 示, 所述报文转发装置用于网络转发设备, 包括协处理器 1、 网络处理器 2 及存储器 3, 具体为:
所述协处理器 1 : 配置为将来自网络、 配置文件的配置命令翻译成带宽 整定配置表; 并读取所述令牌桶计算时的过程数据并展示。 所述协处理器 1 具体包括:
翻译单元 11 : 配置为将来自网络、 配置文件的配置命令翻译成带宽整 定配置表;
展示单元 12: 配置为展示令牌桶计算时的过程数据;
通信单元 13 : 配置为与存储器的数据交互。
所述网络处理器 2: 配置为收发报文, 并将接收到的报文存入所述存储 器; 选取待发送报文; 并进行是否发送所述待发送报文的判断处理。 所述 网络处理器 2具体包括:
收发单元 21 : 配置为接收链路上的流量并将其转换成报文, 或者将报 文转换成链路上的流量并发送。
报文处理单元 22: 配置为将报文列队、 并按队列的优先级选取待发送 报文;
判断处理单元 23 : 配置为进行多线程的令牌桶计算, 做出是否发送所 述待发送报文的判断处理, 并将所述判断处理结果返回给所述收发单元。
所述存储器 3 : 配置为存储具有 CBS值和到达 TICK值的带宽整定配 置表、 令牌桶计算时的过程数据, 緩存或者存储报文。 所述存储器 3 具体 包括:
配置表存储单元 31 : 配置为存储所述带宽整定配置表; 报文存储单元 32: 配置为緩存或者存储报文;
过程数据存储单元 33 : 配置为存储所述令牌桶计算时的过程数据。 在实际的应用过程中, 上述各模块的互相配合, 具体工作过程如下: 首先, 翻译模块 11将来自网络、 配置文件的配置命令翻译成带宽整定 配置表, 并通过通信单元 13存入配置表存储单元 31。 收发单元 21接收链 路上的流量将其转换成报文, 报文处理单元 22将所述报文按队列的形式存 入报文存储单元 32; 而后, 报文处理单元 22轮询报文存储单元 32中的报 文队列, 选取优先级最高的队列的链表头的报文作为待发送报文。 判断处 理单元 23读取待发送报文的包括长度信息在内的相关信息, 并从配置表存 储单元 31读取带宽整定配置表, 根据报文信息及带宽整定配置表, 按照本 发明实施例的报文转发方法中所述的多线程令牌桶的计算方法, 进行是否 发送所述待发送报文的发送判断处理, 将所述判断处理结果返回给报文处 理单元 22, 并将所述令牌桶计算时的过程数据存入过程数据存储单元 33。 其间, 展示单元 12通过通信单元 13从过程数据存储单元 33读入令牌桶计 算时的过程数据并展示, 从而向用户展示釆用多线程令牌桶技术的带宽整 定过程, 方便功能调试, 参数设定。
在上述实施例中, 也可将翻译单元 11、 文处理单元 22、 判断处理单 元 23、 过程数据存储单元 33和配置表存储单元 31集合成带宽整定调度子 系统, 当需要进行流量整形时, 开启该带宽整定调度子系统, 报文进入该 系统, 按报文的优先级及配置带宽限制后发送, 否则进行正常的报文转发。
本领域内的技术人员应明白, 本发明的实施例可提供为方法、 系统、 或计算机程序产品。 因此, 本发明可釆用硬件实施例、 软件实施例、 或结 合软件和硬件方面的实施例的形式。 而且, 本发明可釆用在一个或多个其 中包含有计算机可用程序代码的计算机可用存储介质 (包括但不限于磁盘 存储器和光学存储器等)上实施的计算机程序产品的形式。 本发明是参照根据本发明实施例的方法、 设备(系统)、 和计算机程序 产品的流程图和 /或方框图来描述的。 应理解可由计算机程序指令实现流程 图和 /或方框图中的每一流程和 /或方框、以及流程图和 /或方框图中的流程和 /或方框的结合。 可提供这些计算机程序指令到通用计算机、 专用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器, 使得 在流程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功 能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理 设备以特定方式工作的计算机可读存储器中, 使得存储在该计算机可读存 储器中的指令产生包括指令装置的制造品, 该指令装置实现在流程图一个 流程或多个流程和 /或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备 上, 使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机 实现的处理, 从而在计算机或其他可编程设备上执行的指令提供用于实现 在流程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功 能的步骤。
以上所述, 仅为本发明的较佳实施例而已, 并非用于限定本发明的保 护范围。

Claims

权利要求书
1. 一种报文转发方法, 用于保存有承诺突发尺寸 CBS 值和到达嘀嗒 TICK值的网络转发设备, 所述网络转发设备基于多线程令牌桶技术进行报 文转发, 所述报文转发方法用于所述多线程中的任一线程, 所述报文转发 方法包括:
第一判断步骤: 待发送报文到达时, 判断是否能够获得第一锁, 并获 取第一判断结果;
第一执行步骤: 在所述第一判断结果指示能够获得所述第一锁时, 获 取所述第一锁, 选择所述 CBS值和到达 TICK值进行是否发送所述待发送 文的发送判断处理, 并在发送所述待发送 文后, 更新所述 CBS值和到 达 TICK值并解锁;
第二执行步骤: 在所述第一判断结果指示不能获得所述第一锁时, 从 所述 CBS值和到达 TICK值中只选择所述 CBS值进行是否发送所述待发送 文的发送判断处理, 并在发送所述待发送 文后, 更新所述 CBS值。
2.根据权利要求 1所述的方法, 其中, 所述更新所述 CBS值的方法包 括:
第二判断步骤: 判断是否有其他线程在更新所述 CBS值, 并获取第二 判断结果;
第一更新步骤: 在所述第二判断结果指示没有其他线程在更新所述 CBS值时, 更新所述 CBS值;
第二更新步骤: 在所述第二判断结果指示有其他线程在更新所述 CBS 值时, 执行等待操作, 直至没有其他线程更新所述 CBS值后更新所述 CBS 值。
3.根据权利要求 2所述的方法, 其中, 所述更新所述 CBS值的方法包 括: 第三判断步骤: 判断是否能够获得第二锁, 并获取第三判断结果; 第三更新步骤: 在所述第三判断结果指示能够获得所述第二锁时, 得 到没有其他线程在更新所述 CBS值的结论, 并获取所述第二锁, 更新所述 CBS值并解锁;
第四更新步骤: 在所述第三判断结果指示不能获得所述第二锁时, 得 到有其他线程在更新所述 CBS值的结论, 执行等待操作, 直到获取所述第 二锁后, 更新所述 CBS值并解锁。
4.根据权利要求 2所述的方法, 其中, 所述更新所述 CBS值的方法包 括:
第四判断步骤: 判断是否有其他线程占用所述 CBS值的资源, 获取第 四判断结果;
第五更新步骤: 在所述第四判断结果指示没有其他线程占用所述 CBS 值的资源时, 得到没有其他线程在更新所述 CBS值的结论, 占用所述 CBS 值的资源, 更新所述 CBS值并释放;
第六更新步骤: 在所述第四判断结果指示有其他线程占用所述 CBS值 的资源时, 得到有其他线程在更新所述 CBS值的结论, 执行等待操作, 直 到占用所述 CBS值的资源后, 更新所述 CBS值并释放。
5. 根据权利要求 1所述的方法, 其中, 所述第一执行步骤中选择所述 CBS值和所述到达 TICK值进行是否发送所述待发送报文的发送判断处理 的方法包括:
第一获取步骤:根据所述到达 TICK值,获取所述待发送报文到达时的 新增令牌数;
第二获取步骤: 根据所述新增令牌数及所述 CBS值, 获取所述待发送 报文到达时的可用令牌数;
第三获取步骤: 获取发送所述待发送报文的所需令牌数; 第五判断步骤: 判断所述可用令牌数是否大于或者等于发送所述待发 送报文的所需令牌数, 获取第五判断结果;
第一执行子步骤: 在所述第五判断结果指示所述可用令牌数大于或者 等于发送所述待发送报文的所需令牌数时, 得到所述网络转发设备发送所 述待发送报文的判断处理结论, 否则得到所述网络转发设备不发送所述待 发送报文的判断处理结论。
6. 根据权利要求 1所述的方法, 其中, 所述第二执行步骤中只选择所 is? An
第四获取步骤: 获取发送所述待发送报文的所需令牌数;
第六判断步骤: 根据所述 CBS值, 判断所述 CBS值是否大于或者等于 发送所述待发送报文的所需令牌数, 获取第六判断结果;
第二执行子步骤: 在所述第六判断结果指示所述 CBS值大于或者等于 发送所述待发送报文的所需令牌数时, 得到所述网络转发设备发送所述待 发送报文的判断处理结论, 否则得到所述网络转发设备不发送所述待发送 报文的判断处理结论。
7.根据权利要求 1-6中任一项所述的方法, 其中, 所述方法还包括: 报文获取步骤: 根据所述报文的优先级, 获取所述待发送报文。
8.根据权利要求 7所述的方法, 其中, 所述报文获取步骤包括: 队列形成步骤: 根据队列分配策略, 釆用链表形式, 将"¾文分成 PQ队 列、 WFQ队列、 协议队列及默认队列;
队列选择步骤: 根据所述各队列的优先级, 选出待发送的队列; 文。
9. 一种报文转发装置, 用于保存有 CBS值和到达 TICK值的网络转发 设备, 所述网络转发设备基于多线程令牌桶技术进行报文转发, 所述报文 转发装置用于所述多线程中的任一线程, 所述报文转发装置包括: 第一判断模块: 配置为待发送报文到达时, 判断是否能够获得第一锁, 并获取第一判断结果;
第一执行模块: 配置为在所述第一判断结果指示能够获得所述第一锁 时, 获取所述第一锁, 选择所述 CBS值和到达 TICK值进行是否发送所述 待发送报文的发送判断处理, 并在发送所述待发送报文后更新所述 CBS值 和到达 TICK值并解锁;
第二执行模块: 配置为在所述第一判断结果指示不能获得所述第一锁 时,从所述 CBS值和到达 TICK值中只选择所述 CBS值进行是否发送所述 待发送 文的发送判断处理, 并在发送所述待发送 文后, 更新所述 CBS 值。
10.根据权利要求 9所述的装置, 其中, 所述第一执行模块和第二执行 模块包括:
第二判断单元: 配置为判断是否有其他线程在更新所述 CBS值, 获取 第二判断结果;
第一更新单元: 配置为在所述第二判断结果指示没有其他线程在更新 所述 CBS值时, 更新所述 CBS值;
第二更新单元: 配置为在所述第二判断结果指示有其他线程在更新所 述 CBS值时,执行等待操作, 直至没有其他线程更新所述 CBS值后更新所 述 CBS值。
11.根据权利要求 10所述的装置, 其中, 所述第一执行模块和第二执行 模块还包括:
第三判断单元: 配置为判断是否能够获得第二锁, 并获取第三判断结 果;
第三更新单元: 配置为在所述第三判断结果指示能够获得所述第二锁 时, 得到没有其他线程在更新所述 CBS值的结论, 并获取所述第二锁, 更 新所述 CBS值并解锁;
第四更新单元: 配置为在所述第三判断结果指示不能获得所述第二锁 时, 得到有其他线程在更新所述 CBS值的结论, 执行等待操作, 直到获取 所述第二锁后, 更新所述 CBS值并解锁。
12.根据权利要求 10所述的装置, 其中, 所述第一执行模块和第二执行 模块还包括:
第四判断单元: 配置为判断是否有其他线程占用所述 CBS值的资源, 获取第四判断结果;
第五更新单元: 配置为在所述第四判断结果指示没有其他线程占用所 述 CBS值的资源时,得到没有其他线程在更新所述 CBS值的结论, 占用所 述 CBS值的资源, 更新所述 CBS值并释放;
第六更新单元: 配置为在所述第四判断结果指示有其他线程占用所述 CBS值的资源时, 得到有其他线程在更新所述 CBS值的结论, 执行等待操 作, 直到占用所述 CBS值的资源后, 更新所述 CBS值并释放。
13. 根据权利要求 9所述的装置, 其中, 所述第一执行模块还包括: 第一获取单元: 配置为根据所述到达 TICK值,获取所述待发送报文到 达时的新增令牌数;
第二获取单元: 配置为根据所述新增令牌数及所述 CBS值, 获取所述 待发送报文到达时的可用令牌数;
第三获取单元: 配置为获取发送所述待发送报文的所需令牌数; 第五判断单元: 配置为判断所述可用令牌数是否大于或者等于发送所 述待发送报文的所需令牌数, 获取第五判断结果;
第一执行子单元: 配置为在所述第五判断结果指示所述可用令牌数大 于或者等于发送所述待发送报文的所需令牌数时, 得到所述网络转发设备 发送所述待发送报文的判断处理结论, 否则得到所述网络转发设备不发送 所述待发送报文的判断处理结论。
14. 根据权利要求 9所述的装置, 其中, 所述第二执行模块还包括: 第四获取单元: 配置为获取发送所述待发送报文的所需令牌数; 第六判断单元:配置为根据所述 CBS值判断所述 CBS值是否大于或者 等于发送所述待发送报文的所需令牌数, 获取第六判断结果;
第二执行子单元: 配置为在所述第六判断结果指示所述 CBS值大于或 者等于发送所述待发送报文的所需令牌数时, 得到所述网络转发设备发送 所述待发送报文的判断处理结论, 否则得到所述网络转发设备不发送所述 待发送报文的判断处理结论。
15.根据权利要求 9-14中任一项所述的装置, 其中, 所述装置还包括: 报文获取模块: 配置为根据所述报文的优先级, 获取所述待发送报文。
16.—种网络转发设备, 保存有 CBS值和到达 TICK值, 所述网络转发 设备基于多线程令牌桶技术进行报文转发, 包括存储器、 协处理器和网络 处理器; 其中,
所述存储器: 配置为存储具有 CBS值和到达 TICK值的带宽整定配置 表、 令牌桶计算时的过程数据; 緩存或者存储报文;
所述协处理器: 配置为将来自网络、 配置文件的配置命令翻译成带宽 整定配置表; 并读取所述令牌桶计算时的过程数据并展示;
所述网络处理器: 配置为收发报文, 并将接收到的报文存入所述存储 器; 选取待发送报文; 并进行权利要求 1 所述的是否发送所述待发送报文 的判断处理操作。
PCT/CN2014/083728 2014-02-13 2014-08-05 一种报文转发方法、装置及网络转发设备 WO2015120699A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410049760.1 2014-02-13
CN201410049760.1A CN104852864B (zh) 2014-02-13 2014-02-13 一种报文转发方法、装置及网络转发设备

Publications (1)

Publication Number Publication Date
WO2015120699A1 true WO2015120699A1 (zh) 2015-08-20

Family

ID=53799564

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/083728 WO2015120699A1 (zh) 2014-02-13 2014-08-05 一种报文转发方法、装置及网络转发设备

Country Status (2)

Country Link
CN (1) CN104852864B (zh)
WO (1) WO2015120699A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3379793A1 (en) * 2017-03-22 2018-09-26 Mitsubishi Electric R&D Centre Europe B.V. Asynchronous frame scheduler with efficient support for fragmentation

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1503220A (zh) * 2002-11-20 2004-06-09 中国科学院声学研究所 一种语音识别中的并行搜索方法
CN1968131A (zh) * 2006-09-29 2007-05-23 华为技术有限公司 一种调整令牌桶桶高的方法和装置
CN101227410A (zh) * 2008-02-03 2008-07-23 杭州华三通信技术有限公司 流量监管方法及流量监管设备
CN102271088A (zh) * 2011-08-16 2011-12-07 大唐移动通信设备有限公司 数据包处理方法和设备
US20120020227A1 (en) * 2010-07-23 2012-01-26 Fiber Logic Communications, Inc. Complementary network quality testing method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1503220A (zh) * 2002-11-20 2004-06-09 中国科学院声学研究所 一种语音识别中的并行搜索方法
CN1968131A (zh) * 2006-09-29 2007-05-23 华为技术有限公司 一种调整令牌桶桶高的方法和装置
CN101227410A (zh) * 2008-02-03 2008-07-23 杭州华三通信技术有限公司 流量监管方法及流量监管设备
US20120020227A1 (en) * 2010-07-23 2012-01-26 Fiber Logic Communications, Inc. Complementary network quality testing method
CN102271088A (zh) * 2011-08-16 2011-12-07 大唐移动通信设备有限公司 数据包处理方法和设备

Also Published As

Publication number Publication date
CN104852864A (zh) 2015-08-19
CN104852864B (zh) 2018-12-14

Similar Documents

Publication Publication Date Title
CN109412964B (zh) 报文控制方法及网络装置
WO2019128467A1 (zh) 基于灵活以太网FlexE传输业务流的方法和装置
KR102230580B1 (ko) 플렉서블 이더넷에 기초하여 서비스 플로우를 송신하는 방법, 장치, 및 통신 시스템
CN110545152B (zh) 一种以太网中具有实时传输功能的上位机及以太网系统
US11785113B2 (en) Client service transmission method and apparatus
EP2445166B1 (en) Method and device for controlling information channel flow
JP5749732B2 (ja) キューの充填レベルの更新を制御することにより帯域幅を節約しながらデータを受信し記憶するアセンブリおよび方法
CN112311494B (zh) 一种报文传输方法、装置及系统
US8576850B2 (en) Band control apparatus, band control method, and storage medium
US20240214323A1 (en) Packet transmission method and apparatus
CN103841041A (zh) 一种多流业务并发传输控制方法及装置
EP3961981A1 (en) Method and device for congestion control, communication network, and computer storage medium
CN112448885A (zh) 一种业务报文传输的方法及设备
CN114374647B (zh) 一种对时敏业务流和路由联合调度的规划方法及装置
US20200351215A1 (en) Data Stream Sending Method and System, and Device
US8838782B2 (en) Network protocol processing system and network protocol processing method
WO2015089984A1 (zh) 实现接口缓存动态分配的方法、装置和计算机存储介质
US10911364B2 (en) Packet processing method and router
CN113162790A (zh) 调整服务等级的方法、装置、设备及存储介质
WO2019192318A1 (zh) 流量平滑方法、服务器及转发设备
CN108282416B (zh) 一种基于数据帧的调度方法和装置
CN113992594A (zh) 流量控制方法、装置、电子设备和计算机可读存储介质
CN107517167B (zh) 一种数据传输控制方法、装置及SoC芯片
CN115473855A (zh) 网络系统、数据传输方法
WO2015120699A1 (zh) 一种报文转发方法、装置及网络转发设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14882239

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

Country of ref document: EP

Kind code of ref document: A1