A traffic scheduling method and device based on a programmable switching chip

By using a traffic scheduling method based on a programmable switching chip, the system parses packet types and monitors traffic rates, automatically controlling the switching between primary and backup ports. This solves the problems of inaccurate scheduling and packet loss caused by slow CPU response, achieving fast response and low packet loss rate.

CN117714350BActive Publication Date: 2026-03-10RUIJIE NETWORKS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-06
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing CPU-based traffic scheduling methods have slow response times, which can lead to sudden traffic surges that cannot be scheduled in time, often exceeding the configured threshold waterline, resulting in inaccurate scheduling and potential packet loss.

Method used

A traffic scheduling method based on a programmable switching chip is adopted. By parsing the message type and monitoring the main port traffic rate, control type messages are triggered according to set thresholds and time thresholds to realize automatic switching of the main and backup ports. Traffic scheduling control is performed internally by the programmable switching chip.

Benefits of technology

It enables automatic control of traffic flow within the configured threshold by the chip hardware, provides a fast response, reduces packet loss rate, and improves port bandwidth utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117714350B_ABST
    Figure CN117714350B_ABST
Patent Text Reader

Abstract

This application discloses a traffic scheduling method and device based on a programmable switching chip, particularly relating to the field of programmable switches. The method includes: receiving packets from the ingress port and parsing the packet type; when the packet type is determined to be control type, extracting control information from the packet indicating a switch between primary and backup ports, and determining whether to switch the current port to primary or backup port based on the control information; when the packet type is determined to be information type, determining the destination port of the packet based on the current port, and sending the packet from the destination port; monitoring the traffic rate of the primary port, and triggering the generation of a control type packet when the primary / backup port switching condition is met based on a comparison of the traffic rate with a set threshold; and sending the control type packet to the ingress port through a loopback port. This application solves the problem of slow software CPU scheduling response leading to inaccurate scheduling and packet loss, as the chip can respond quickly, reducing port packet loss rate.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of programmable switch, in particular to a traffic scheduling method and device based on programmable switch chip. BACKGROUND

[0002] The general method for scheduling traffic at present is to use a CPU control based scheme. The CPU obtains the traffic statistics information of the monitoring port at regular intervals, compares the obtained statistics value with the configured threshold value to determine whether the traffic exceeds the threshold value, and if it does, controls the traffic to switch to the backup port by configuring the related table items in the switch chip; when the traffic of the main port decreases, the traffic is switched back to the main port.

[0003] The CPU scheme has a slow response time, which results in burst traffic that cannot be scheduled in time, often exceeding the configured threshold value, leading to inaccurate scheduling, and even packet loss when the threshold value is exceeded. SUMMARY

[0004] The present application provides a traffic scheduling method and device based on programmable switch chip, to solve the problem of slow response leading to inaccurate scheduling and packet loss.

[0005] In a first aspect, the present application provides a traffic scheduling method based on programmable switch chip, comprising:

[0006] receiving a packet from an inlet and analyzing the type of the packet;

[0007] when the type of the packet is determined to be a control type, extracting control information in the packet indicating switching of the main and backup ports, and determining to switch the current port to the main port or the backup port according to the control information;

[0008] when the type of the packet is determined to be an information type, determining the destination port of the packet according to the current port, and sending the packet from the destination port;

[0009] monitoring the traffic rate of the main port, and when the switching condition of the main and backup ports is met according to the comparison result of the traffic rate and the set threshold value, triggering the generation of a packet of the control type;

[0010] sending the packet of the control type to the inlet through a loopback port.

[0011] In one or more possible embodiments, when the switching condition of the main and backup ports is met according to the comparison result of the traffic rate and the set threshold value, triggering the generation of a packet of the control type, comprises:

[0012] When the current port is determined as the primary port, whether the condition for switching the primary port to the backup port is met is determined according to a comparison result of a traffic rate of the primary port and a set threshold, and when the condition for switching the primary port to the backup port is determined to be met, a control type packet of switching from the primary port to the backup port is triggered to be generated.

[0013] When the current port is determined as the backup port, whether the condition for switching the backup port to the primary port is met is determined according to a comparison result of a traffic scheduling time of switching from the primary port to the backup port and a set time threshold, and when the condition for switching the backup port to the primary port is determined to be met, a control type packet of switching from the backup port to the primary port is triggered to be generated.

[0014] In one or more possible embodiments, whether the condition for switching the primary port to the backup port is met is determined according to a comparison result of a traffic rate of the primary port and a set threshold, including:

[0015] When the current port is determined as the primary port and the traffic rate of the primary port is greater than the set threshold, the condition for switching from the primary port to the backup port is determined to be met.

[0016] In one or more possible embodiments, whether the condition for switching the backup port to the primary port is met is determined according to a comparison result of a traffic scheduling time of switching from the primary port to the backup port and a set time threshold, including:

[0017] When the current port is determined as the backup port and the traffic scheduling time of switching from the primary port to the backup port is greater than or equal to the set time threshold, the condition for switching from the backup port to the primary port is determined to be met.

[0018] In one or more possible embodiments, when the type of the packet is determined as the information type, the destination port of the packet is determined according to the current port, and the packet is sent from the destination port, including:

[0019] The packet is cached in a corresponding packet queue for waiting for scheduling and forwarding, and when the scheduling algorithm is used to determine the scheduling packet, the destination port of the packet is determined according to the current port, and the packet is sent from the destination port.

[0020] In one or more possible embodiments, the traffic rate of the primary port is monitored, and the following method is used to determine whether the traffic rate exceeds the set threshold, including:

[0021] Tokens are generated at a set rate, and when it is determined that the token bucket does not reach a fixed capacity, the tokens are put into the token bucket, otherwise the generated tokens are discarded;

[0022] The length of the packet sent by the primary port is monitored, and the number of tokens corresponding to the length of the packet is consumed;

[0023] When it is monitored that the current number of tokens in the token bucket is insufficient, it is determined that the traffic rate of the primary port exceeds the set threshold.

[0024] In one or more possible embodiments, the destination port of the packet is determined according to the current port, including:

[0025] The current port is determined to be a master port or a backup port, and the master port or the backup port is multiple, and the destination port of the packet is determined by querying a related entry;

[0026] The related entry can determine the destination port of the packet by parsing the destination MAC address or the destination IP address in the parsed packet.

[0027] In one or more possible embodiments, the method further includes:

[0028] The timestamp when the packet enters the downstream processing is extracted, the packet is an information type packet triggering the switching from the master port to the backup port, and the timestamp of the packet is taken as a reference timestamp;

[0029] When the current port is determined to be the backup port, the traffic scheduling time is determined in the following manner:

[0030] The difference between the timestamp of the current packet and the reference timestamp is taken as the traffic scheduling time.

[0031] In one or more possible embodiments, the control type packet is generated in the following manner:

[0032] The packet sent by the current destination port is copied, and a virtual local area network (VLAN) header carrying scheduling information is added, the VLAN header including an indication bit indicating the switching of the current port to the master port or the backup port;

[0033] The payload of the packet with the added VLAN header is truncated.

[0034] In a second aspect, the application provides a traffic scheduling device based on a programmable switching chip, including: an inlet for receiving a packet entering the switching chip;

[0035] an outlet, at least one master port, and at least one backup port;

[0036] The programmable switching chip / programmable logic device is used to implement the following logical control of the programmable device corresponding to the programmable language: receiving the packet from the inlet and parsing the type of the packet; when the type of the packet is determined to be a control type, extracting the control information indicating the switching of the master and backup ports in the packet, and determining the switching of the current port to the master port or the backup port according to the control information; when the type of the packet is determined to be an information type, determining the destination port of the packet according to the current port, and sending the packet from the destination port; monitoring the traffic rate of the master port, and when the switching condition of the master and backup ports is satisfied according to the comparison result of the traffic rate and a set threshold, triggering the generation of the control type packet; and sending the control type packet to the inlet through a loopback port.

[0037] a loopback port, configured to send the control type message to the ingress port.

[0038] In one or more possible embodiments, further comprising:

[0039] a cache module TM, configured to cache the parsed message in the form of a message queue.

[0040] The programmable switch chip / programmable logic device is further configured to, for the information type message, determine the destination port of the message according to the current port when scheduling the message according to the scheduling algorithm, and send the message from the destination port.

[0041] In one or more possible embodiments, the programmable switch chip / programmable logic device comprises:

[0042] a flow monitoring module, configured to monitor the flow rate of the main port, and trigger the generation of the control type message when the switching condition of the main and standby ports is met according to the comparison result of the flow rate and the set threshold value;

[0043] a time information acquisition module, configured to acquire the time when the main port is switched to the standby port as the flow scheduling time;

[0044] a timeout judgment module, configured to compare the flow scheduling time with a set time threshold value, and trigger the generation of the control type message when the switching condition of the main and standby ports is met according to the comparison result.

[0045] The application provides a flow scheduling method based on a switch chip, which realizes automatic control of the chip hardware to ensure that the flow does not exceed the configured threshold value, rapid response of the chip, and reduction of the packet loss rate.

[0046] Other features and advantages of the application will be set forth in the following description, and in part will become apparent to those skilled in the art from the description, or can be learned by practice of the application. The objects and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims, and the appended drawings. BRIEF DESCRIPTION OF DRAWINGS

[0047] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and, together with the description, serve to explain the principles of the application, and, do not limit the application.

[0048] Figure 1 a schematic diagram of an application environment according to an embodiment of the application;

[0049] Figure 2 a step diagram of a flow scheduling method based on a switch chip according to an embodiment of the application;

[0050] Figure 3 A flow chart for determining the switching condition of the primary and backup ports according to an embodiment of the present application;

[0051] Figure 4 A flow chart for the packet entering the ingress according to an embodiment of the present application;

[0052] Figure 5 A flow chart for determining the switching condition of the primary and backup ports according to an embodiment of the present application;

[0053] Figure 6 A flow chart for determining whether the rate of the traffic of the primary port exceeds the set threshold according to an embodiment of the present application;

[0054] Figure 7 A flow chart for determining whether the traffic scheduling time switched from the primary port to the backup port exceeds the set time threshold according to an embodiment of the present application;

[0055] Figure 8 A flow chart for the related configuration before performing the traffic scheduling method according to an embodiment of the present application;

[0056] Figure 9 A flow chart for the rate of the traffic of the primary port exceeding the set threshold according to an embodiment of the present application;

[0057] Figure 10 A flow chart for the rate of the traffic of the primary port not exceeding the set threshold according to an embodiment of the present application;

[0058] Figure 11 A module diagram of a switch chip according to an embodiment of the present application. DETAILED DESCRIPTION

[0059] In order to make the objects, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.

[0060] The common method for scheduling the traffic at present is the scheme based on CPU control. The scheme of CPU leads to the burst traffic not being able to be scheduled in time due to the slow response time, and often exceeds the configured threshold line, resulting in the inaccurate scheduling, and even the packet loss phenomenon when the threshold exceeds more. In order to solve the above problems, the present application provides a traffic scheduling method based on a switch chip and a switch chip, and the specific application environment is as follows Figure 1As shown, the application environment may include, for example, a programmable switch 10, a CPU 20, and at least one interconnection device 30, wherein the CPU 20 can be used for configuration of relevant parameters, and the programmable switch is used to receive messages and send the received messages to the at least one interconnection device 30.

[0061] The application provides a traffic scheduling method based on a programmable switching chip, which is applied to a programmable switch, such as Figure 2 As shown, the application environment may include, for example, a programmable switch 10, a CPU 20, and at least one interconnection device 30, wherein the CPU 20 can be used for configuration of relevant parameters, and the programmable switch is used to receive messages and send the received messages to the at least one interconnection device 30.

[0062] Step S201: receiving a message from an inlet and analyzing the type of the message.

[0063] Step S202: when the type of the message is determined to be an information type, determining the destination port of the message according to a current port, and sending the message from the destination port.

[0064] In one or more possible embodiments, the current port is a primary port or a backup port, and when there are multiple primary ports or backup ports, the destination port of the message is determined by querying relevant table items, and the above-mentioned destination port is a specific one of the multiple primary ports or backup ports.

[0065] Step S203: when the type of the message is determined to be a control type, extracting control information indicating switching of the primary port and the backup port from the message, and determining to switch the current port to the primary port or the backup port according to the control information.

[0066] In one or more possible embodiments, the message of the control type contains control information, and the control information is divided into two categories, which are control information switched from the primary port to the backup port and control information switched from the backup port to the primary port.

[0067] In one or more possible embodiments, the message analysis process needs to perform message header analysis on all messages received from the inlet, extract the source and destination MAC addresses, Ethernet type fields, VLAN fields, source and destination IP fields, and protocol fields in the message header, determine whether the message is an information type message or a control type message through the analyzed Ethernet type field information, if it is an information type message, query the information type message forwarding related table items according to the analyzed destination MAC address or destination IP address to complete the destination port search, the above-mentioned related table items can obtain corresponding rules through machine learning to control the corresponding message to be forwarded to the destination port; if it is detected to be a control type message, further extract the control information carried in the VLAN field, and then perform traffic scheduling control on the control information, and discard the control type message.

[0068] Step S204: monitoring the traffic rate of the primary port, determining to trigger the generation of the control type message when the switching condition of the primary port and the backup port is satisfied according to the comparison result of the traffic rate of the primary port and the set threshold.

[0069] The set threshold is a set flow rate threshold. When the flow rate of the master port exceeds the set threshold, it indicates that the master port may have burst traffic and needs to be shunted. The set threshold can be set according to the message processing capability of the master port.

[0070] In one or more possible embodiments, the master port is used as the default port for message forwarding. Only when a control message is received, which switches the master port to the backup port, is a new message forwarded from the backup port. This state remains until a control message is received again, which switches the backup port to the master port. This indicates that the traffic has not exceeded the set threshold. Subsequent incoming traffic can continue to use the master port and does not need to modify the default message forwarding port.

[0071] In step S205, a control-type message is sent to the ingress through the loopback port.

[0072] The application provides a traffic scheduling method based on a programmable switching chip. A message enters an ingress and is parsed. The parsed message includes two types, namely, an information-type message and a control-type message. When it is determined that the type of the message is the information type, a related entry is queried, the information-type message is subjected to traffic scheduling, and the message is sent from a destination port according to the destination port. When it is determined that the type of the message is the control type, control information indicating switching of a master port and a backup port is extracted from the message, the control-type message is subjected to traffic scheduling, and the current port is switched to the master port or the backup port according to the control information. The control-type message is sent to the ingress through a loopback port. According to the method provided in the application, the control-type message for switching of the master port and the backup port in the programmable switching chip is subjected to message forwarding to realize switching of the master port and the backup port. The problem that burst traffic cannot be scheduled in time due to a slow response time, often exceeding a configured threshold, and resulting in inaccurate scheduling is solved. The scheduling is automatically controlled in the switching chip, the traffic is accurately controlled to not exceed the configured threshold, and the programmable switching chip can respond quickly to reduce a port packet loss rate.

[0073] In one or more possible embodiments, as shown in Figure 3 When the switching condition of the master port and the backup port is determined according to a comparison result of the flow rate and the set threshold, a control-type message is triggered to be generated. The control-type message includes the following steps.

[0074] In step S301, the flow rate of the master port is monitored and the current port is determined. When the current port is determined to be the master port, step S302 is performed. When the current port is determined to be the backup port, step S304 is performed.

[0075] In step S302, when the current port is determined to be the master port, whether the condition for switching the master port to the backup port is met is determined according to a comparison result of the flow rate of the master port and the set threshold.

[0076] In step S303, when the condition for switching the primary port to the backup port is met, a control type packet for switching the primary port to the backup port is triggered to be generated.

[0077] In step S304, when the current port is the backup port, whether the condition for switching the backup port to the primary port is met is determined according to a comparison result of the traffic scheduling time for switching the primary port to the backup port and the set time threshold.

[0078] In step S305, when the condition for switching the backup port to the primary port is met, a control type packet for switching the backup port to the primary port is triggered to be generated.

[0079] The control type packet is divided into two categories. When the current port is the primary port, whether the condition for switching the primary port to the backup port is met is determined according to a comparison result of the traffic rate of the primary port and the set threshold, and when the condition for switching the primary port to the backup port is met, the control type packet for switching the primary port to the backup port is triggered to be generated. When the current port is the backup port, whether the condition for switching the backup port to the primary port is met is determined according to the traffic scheduling time for switching the primary port to the backup port, and when the condition for switching the backup port to the primary port is met, the control type packet for switching the backup port to the primary port is triggered to be generated. According to different conditions met, the control type packet triggered to be generated is one of the two categories. The control type packet is sent to the ingress through the loopback port.

[0080] In one or more possible embodiments, referring to Figure 4 For a flowchart of a packet entering the ingress, the packet enters the ingress, and a packet analysis process is performed. When the analyzed packet is an information type packet, a related table item needs to be queried to determine a destination port, and then the packet is subjected to traffic scheduling control to enter the next device from the destination port. When the analyzed packet is a control type packet, related control information needs to be extracted, the control information is subjected to traffic scheduling control, and the control type packet is discarded. Finally, the operation is completed.

[0081] Figure 5 For a step chart for determining the condition for switching the primary port to the backup port, in one or more possible embodiments, whether the condition for switching the primary port to the backup port is met is determined according to a comparison result of the traffic rate of the primary port and the set threshold, including:

[0082] In step S501, when the current port is the primary port and the traffic rate of the primary port is greater than the set threshold, the condition for switching the primary port to the backup port is determined to be met.

[0083] Whether the condition for switching the backup port to the primary port is met is determined according to the traffic scheduling time for switching the primary port to the backup port, including:

[0084] Step S502: If the current port is determined to be a backup port, and the traffic scheduling time from the primary port to the backup port is greater than or equal to the set time threshold, then the condition for switching from the backup port to the primary port is met.

[0085] In one or more possible embodiments, when the message type is determined to be information type, the destination port of the message is determined according to the current port, and the message is sent from the destination port, including: buffering the message in the corresponding message queue to wait for scheduling and forwarding; when the scheduling algorithm determines the scheduling message, the destination port of the message is determined according to the current port, and the message is sent from the destination port; the destination port is one of the exits of multiple main ports and backup ports, and the destination port is found by querying relevant table entries to send the message.

[0086] In one or more possible embodiments, see Figure 6 To determine whether the main port's traffic rate exceeds a set threshold, a token bucket mechanism is used, following these steps:

[0087] Step S601: Generate tokens at a set rate, and put tokens into the token bucket if the token bucket has not reached a fixed capacity; otherwise, discard the generated tokens.

[0088] The token bucket mentioned above monitors the traffic rate of the main port. When there are multiple main ports, you can use a method where all main ports share one token bucket for traffic rate monitoring, or you can use multiple token buckets to monitor multiple main ports. It should be noted that when the traffic rate of one of the multiple main ports exceeds the set threshold, the conditions for switching the main port to the backup port are met.

[0089] Step S602: Monitor the length of the message sent by the main port and consume the number of tokens corresponding to the message length.

[0090] Step S603: When it is detected that the current number of tokens in the token bucket is insufficient, it is determined that the main port's traffic rate exceeds the set threshold.

[0091] If the current number of tokens is insufficient, it means that there are too many packets on the main port, consuming too many tokens, and the traffic rate of the main port exceeds the rate at which tokens are generated. It is determined that the traffic rate of the main port exceeds the set threshold, and the conditions for switching from the main port to the backup port are met.

[0092] In one or more possible embodiments, see Figure 7 The steps to determine whether the traffic scheduling time from the primary port to the backup port exceeds the set time threshold are as follows:

[0093] Step S701: Extract the timestamp of the message when it enters downlink processing. The message is an information type message that triggers the switch from the primary port to the backup port. Use the timestamp of the above message as the base timestamp.

[0094] In one or more possible embodiments, the conditions for switching from the primary port to the backup port described above need to be met. When the information type message that triggers the switch from the primary port to the backup port enters downlink processing, the timestamp of the information type message is extracted and used as the base timestamp.

[0095] Step S702: Determine that the current port is a backup port and determine the traffic scheduling time;

[0096] Step S703: The difference between the timestamp of the current message and the reference timestamp is used as the traffic scheduling time;

[0097] The above traffic scheduling time is obtained by subtracting the base timestamp from the timestamp of the current packet. Each packet will have its corresponding timestamp extracted when it enters downlink processing, so as to obtain the corresponding traffic scheduling time.

[0098] The above traffic scheduling time is compared with the set time threshold. When the traffic scheduling time is greater than or equal to the set time threshold, it is determined that the condition for switching from the backup port to the primary port is met.

[0099] Based on the traffic scheduling method described above, relevant configurations are required before executing related operations, specifically as follows: Figure 8 As shown, it includes:

[0100] Step S801: Configure one or more main ports that need to be monitored;

[0101] Step S802: Configure the set threshold, that is, configure the relevant parameters of the token bucket mechanism, monitor the main port traffic based on the configured parameters, and output the measurement results;

[0102] Step S803: Configure the set time threshold;

[0103] The parameters of the above configuration are set according to the user's actual situation. First, configure the specific number of main ports that need to monitor traffic. For example, if there are five main ports in the switch, only two main ports are needed for this operation, so the traffic rate of the two main ports used is monitored, and the other three main ports are not needed. Second, configure the set threshold and compare it with the traffic rate entering the main port, and output the measurement result. Finally, configure the set time threshold to control the duration for which traffic needs to be scheduled to the backup port. For example, if the set time threshold is 500ms, when the traffic scheduling time for switching from the main port to the backup port is greater than or equal to 500ms, the operation of switching the backup port to the main port needs to be performed. The traffic scheduling method proposed in this application can immediately switch when the traffic exceeds the set threshold, accurately control the traffic to not exceed the configured threshold, has a short scheduling response time, and is fast in operation, which can reduce the port packet loss rate.

[0104] In one or more possible embodiments, firstly only the flow rate of the main port is monitored. If it is not the main port flow, the operation ends. Next, it is determined whether the flow rate of the main port exceeds the set threshold.

[0105] See Figure 9 The flowchart shows the process of the main port traffic rate exceeding the set threshold. It extracts the timestamp of the current message, determines if the conditions for switching from the main port to the backup port are met, marks the state of switching from the main port to the backup port, generates a control type message, and sends it to the entry point through the internal loopback port of the chip for message parsing and processing.

[0106] See Figure 10 The flowchart shows that the rate of traffic to the main port does not exceed the set threshold. It determines whether the port is in the state of switching from the main port to the backup port. If not, the process is completed. If so, it determines whether the scheduling time for switching from the main port to the backup port is greater than the set time threshold. If it is not greater than the set time threshold, the scheduling state is maintained and the process is completed. If it is greater than or equal to the set time threshold, the condition for switching from the backup port to the main port is met. A control type message is generated and sent to the entry point through the internal loopback port of the chip for message parsing and processing.

[0107] In one or more possible embodiments, control type messages are generated as follows: a message sent by the current destination port is copied and a Virtual Local Area Network (VLAN) header carrying scheduling information is added. The VLAN header includes an indication bit indicating whether the current port is switched to the primary or backup port. The payload of the message with the added VLAN header is truncated.

[0108] For example, the payload of a packet with an added VLAN header can be truncated to a short 64-byte packet and then forwarded to the ingress port for processing via the loopback port inside the switching chip. The added traffic scheduling information is carried using the lower 4 bits of the VLAN ID. One way to define this information is as follows:

[0109]

[0110] This application proposes a traffic scheduling method based on a programmable switching chip. It solves the problem that CPU-based solutions often fail to schedule burst traffic in time due to slow response time, frequently exceeding the configured threshold watermark, resulting in inaccurate scheduling. Moreover, when the threshold is exceeded significantly, packet loss may occur. The switching chip hardware automatically controls the scheduling, precisely controlling the traffic to not exceed the set threshold. The chip responds quickly, reducing port packet loss rate and improving port bandwidth utilization.

[0111] Based on the same inventive concept, this application proposes a traffic scheduling device based on a programmable switching chip, comprising:

[0112] The entry point is used to receive messages entering the switching chip;

[0113] Exports must have at least one main port and at least one backup port.

[0114] Programmable switching chips / logic devices, implementing the corresponding programmable description language, perform the following logic control: receiving messages from the inlet and parsing the message type; when the message type is determined to be control type, extracting the control information indicating the switching of primary and backup ports from the message, and determining whether to switch the current port to primary or backup port based on the control information; when the message type is determined to be information type, determining the destination port of the message based on the current port, and sending the message from the destination port; monitoring the flow rate of the primary port, and triggering the generation of a control type message when the switching conditions for primary and backup ports are met based on the comparison result of the flow rate and a set threshold; sending the control type message to the inlet through the loopback port.

[0115] The loopback port is used to send control type messages to the inlet.

[0116] The caching module TM is used to cache parsed messages in the form of a message queue;

[0117] Programmable logic devices are also used to determine the destination port of a message based on the current port when scheduling a message according to a scheduling algorithm, and then send the message from the destination port.

[0118] The aforementioned programmable switch chip / programmable logic device includes:

[0119] The flow monitoring module is used to monitor the flow rate of the main port. Based on the comparison result of the flow rate and the set threshold, when the switching conditions of the main and backup ports are met, a control type message is triggered.

[0120] The time information acquisition module is used to collect the time of switching from the primary port to the backup port as the traffic scheduling time;

[0121] The timeout judgment module compares the traffic scheduling time with the set time threshold. Based on the comparison result, when it determines that the switching conditions of the primary and backup ports are met, it triggers the generation of a control type message.

[0122] In one or more possible embodiments, such as Figure 11 As shown, the above-mentioned switching chip includes three modules, namely ingress processing module 1101, cache module TM1102, and egress processing module 1103;

[0123] First, after the packet enters the ingress processing module 1101 of the switching chip, it will be parsed. The packet parsing module determines whether the packet is an information type or a control type. If it is an information type, the destination port is looked up through the relevant table entries and the processing is completed. If it is a control type, the relevant control information is extracted and submitted to the traffic scheduling control module for traffic scheduling control. At the same time, the control type packet is discarded.

[0124] After a message enters the egress processing module 1103, it first determines whether the current message belongs to the main port traffic that needs to be monitored. If not, the processing of the egress processing module 1103 is completed. If it is the main port traffic that needs to be monitored, the token bucket mechanism is used to perform traffic rate measurement. According to the threshold set above, if the rate of the main port traffic exceeds the set threshold, the timestamp of the current message is extracted and it is marked that the current state is switching from the main port to the backup port. At the same time, a control type message is generated and sent to the ingress processing module 1101 through the loopback port inside the switching chip for processing.

[0125] If the rate of traffic on the main port does not exceed the set threshold, it is determined whether the port is in a state of switching from the main port to the backup port. If not, the processing of the egress processing module 1103 is completed. If so, the time of switching from the main port to the backup port is determined by the time information acquisition module and the timeout judgment module. If not, the processing of the egress processing module 1103 is completed. If so, it means that the current round of scheduling has been completed, and the traffic needs to be switched from the backup port to the main port. A control type message is generated, carrying the control information of switching from the backup port to the main port. The control type message is sent to the ingress processing module 1101 through the loopback port inside the switching chip for processing.

[0126] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0127] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0128] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0129] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0130] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method of flow scheduling based on a programmable switch chip, characterized by, The method comprises the following steps: receiving a packet from an entrance and analyzing the type of the packet; when determining that the type of the packet is a control type, extracting control information indicating switching of a master port and a backup port in the packet, and determining to switch the current port to the master port or the backup port according to the control information; when determining that the type of the packet is an information type, determining the destination port of the packet according to the current port, and sending the packet from the destination port; monitoring the traffic rate of the master port, and triggering the generation of a packet of the control type when determining that the switching condition of the master port and the backup port is met according to the comparison result of the traffic rate and a set threshold value; sending the packet of the control type to the entrance through a loopback port; the method for triggering the generation of a packet of the control type according to the comparison result of the traffic rate and a set threshold value, comprising the following steps: when determining that the current port is the master port, determining whether the condition of switching the master port to the backup port is met according to the comparison result of the traffic rate of the master port and the set threshold value, and triggering the generation of a control type packet of switching the master port to the backup port when determining that the condition of switching the master port to the backup port is met; when determining that the current port is the backup port, determining whether the condition of switching the backup port to the master port is met according to the comparison result of the traffic scheduling time of switching the master port to the backup port and a set time threshold value, and triggering the generation of a control type packet of switching the backup port to the master port when determining that the condition of switching the backup port to the master port is met.

2. The method of claim 1, wherein, the method for determining whether the condition of switching the master port to the backup port is met according to the comparison result of the traffic rate of the master port and a set threshold value, comprising the following steps: when determining that the current port is the master port and the traffic rate of the master port is greater than the set threshold value, determining that the condition of switching the master port to the backup port is met.

3. The method of claim 1, wherein, the method for determining whether the condition of switching the backup port to the master port is met according to the comparison result of the traffic scheduling time of switching the master port to the backup port and a set time threshold value, comprising the following steps: when determining that the current port is the backup port and the traffic scheduling time of switching the master port to the backup port is greater than or equal to the set time threshold value, determining that the condition of switching the backup port to the master port is met.

4. The method of claim 1, wherein, the method for determining the destination port of the packet according to the current port when determining that the type of the packet is the information type, comprising the following steps: when determining that the type of the packet is the information type, buffering the packet into a corresponding packet queue for waiting for scheduling and forwarding, determining to schedule the packet according to a scheduling algorithm, and determining the destination port of the packet according to the current port and sending the packet from the destination port.

5. The method of claim 1, wherein, the method for monitoring the traffic rate of the master port and determining whether the traffic rate exceeds a set threshold value in the following manner, comprising the following steps: generating a token at a set rate, putting the token into a token bucket when determining that the token bucket does not reach a fixed capacity, and discarding the generated token otherwise; monitoring the length of a packet sent by the master port and consuming the number of tokens corresponding to the length of the packet; when monitoring that the current number of tokens in the token bucket is insufficient, determining that the traffic rate of the master port exceeds the set threshold value.

6. The method of claim 1, wherein, the method for determining the destination port of the packet according to the current port, comprising the following steps: determining whether the current port is a master port or a backup port, and the master port or the backup port is multiple, determining the destination port of the packet by querying a related table item; the related table item can determine the destination port of the packet by analyzing the destination MAC address or the destination IP address in the parsed packet.

7. The method of claim 1, wherein, Further comprising: extracting the timestamp of the packet when entering the downstream processing, the packet being an information type packet triggering the switching from the master port to the backup port, and taking the timestamp of the packet as a reference timestamp; when determining that the current port is the backup port, determining the traffic scheduling time in the following manner: taking the difference between the timestamp of the current packet and the reference timestamp as the traffic scheduling time.

8. The method of claim 1, wherein, the control type packet is generated in the following manner: copying the packet sent by the current destination port, and adding a virtual local area network (VLAN) header carrying scheduling information, the VLAN header including an indication bit indicating the switching of the current port to the master port or the backup port; performing truncation processing on the payload of the packet with the added VLAN header.

9. A programmable switch chip based traffic scheduling apparatus, characterized by, comprising: an inlet for receiving a packet entering the switch chip; an outlet including at least one master port and at least one backup port; a programmable switch chip / programmable logic device for implementing the following logical control of a programmable device corresponding to a programmable language: receiving a packet from the inlet, and analyzing the type of the packet; when determining that the type of the packet is a control type, extracting control information indicating the switching of the master port and the backup port from the packet, and determining the switching of the current port to the master port or the backup port according to the control information; when determining that the type of the packet is an information type, determining the destination port of the packet according to the current port, and sending the packet from the destination port; monitoring the traffic rate of the master port, and when determining that the switching condition of the master port and the backup port is met according to the comparison result of the traffic rate and a set threshold, triggering the generation of a control type packet; sending the control type packet to the inlet through a loopback port, wherein when determining that the switching condition of the master port and the backup port is met according to the comparison result of the traffic rate and the set threshold, triggering the generation of the control type packet includes: when determining that the current port is the master port, determining whether the condition of switching the master port to the backup port is met according to the comparison result of the traffic rate of the master port and the set threshold, and triggering the generation of the control type packet for switching from the master port to the backup port when determining that the condition of switching the master port to the backup port is met; and when determining that the current port is the backup port, determining whether the condition of switching the backup port to the master port is met according to the comparison result of the traffic scheduling time of switching from the master port to the backup port and a set time threshold, and triggering the generation of the control type packet for switching from the backup port to the master port when determining that the condition of switching the backup port to the master port is met; a loopback port for sending the control type packet to the inlet.

10. The apparatus of claim 9, wherein, Further comprising: a buffer module TM for buffering the parsed packet in the form of a packet queue; the programmable switch chip / programmable logic device is further configured to, for the information type packet, determine the destination port of the packet according to the current port, and send the packet from the destination port according to a scheduling algorithm.

11. The apparatus of claim 9, wherein, The programmable switch chip / programmable logic device comprises: a flow monitoring module for monitoring a flow rate of the main port, and triggering the generation of the control type message when the switching condition of the main and standby ports is met according to a comparison result of the flow rate and the set threshold value; a time information acquisition module for acquiring a time of switching from the main port to the standby port as a flow scheduling time; a timeout judgment module for comparing the flow scheduling time with a set time threshold value, and triggering the generation of the control type message when the switching condition of the main and standby ports is met according to a comparison result.

Citation Information

Patent Citations

  • Ethernet switching system and equipment

    CN101155109A

  • Network traffic control method and device, and switch

    CN105323188A