WO2020087523A1 - Network communication method and apparatus, and electronic device - Google Patents
Network communication method and apparatus, and electronic device Download PDFInfo
- Publication number
- WO2020087523A1 WO2020087523A1 PCT/CN2018/113789 CN2018113789W WO2020087523A1 WO 2020087523 A1 WO2020087523 A1 WO 2020087523A1 CN 2018113789 W CN2018113789 W CN 2018113789W WO 2020087523 A1 WO2020087523 A1 WO 2020087523A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data packet
- network flow
- network
- filter
- rule
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 86
- 238000004891 communication Methods 0.000 title claims abstract description 61
- 230000006870 function Effects 0.000 claims description 34
- 238000012545 processing Methods 0.000 claims description 31
- 238000005516 engineering process Methods 0.000 claims description 14
- 230000005540 biological transmission Effects 0.000 description 18
- 238000010586 diagram Methods 0.000 description 15
- 230000008569 process Effects 0.000 description 13
- 230000008859 change Effects 0.000 description 5
- 230000009471 action Effects 0.000 description 3
- 230000007246 mechanism Effects 0.000 description 3
- 238000004590 computer program Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000007493 shaping process Methods 0.000 description 2
- 210000001072 colon Anatomy 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000002955 isolation Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/40—Support for services or applications
Definitions
- the present application relates to the field of network communication, and in particular to a network communication method, device, electronic device, and storage device.
- the present application also relates to a second network communication method and device.
- Linux is an open source software. Because of its flexibility and scalability, Linux is in line with the development trend of cloud computing as a centralized service platform that provides scalable shared computing capabilities. It is the basic software widely used in the cloud computing industry. The computing power provided by cloud computing, including processors, memory, storage, and network interfaces, needs to process massive amounts of data, so the flow control scheme and throughput of network packets are particularly important.
- the network flow control scheme of the Linux platform is generally based on TC (Traffic Control, or flow controller) for kernel flow control.
- the TC module supports the classification of network packets according to the socket type identification, and the available bandwidth of a specific network flow is limited by the token bucket technology To achieve the purpose of flow control.
- the TC module uses a global spin lock (spin_lock), which allows only one processor core to process one network packet at any time.
- spin_lock global spin lock
- the existing TC technology supports multi-queue network flow control
- the solution specifically, implements the network packet-based socket priority through the Linux mq_prio module to distribute network packets to multiple network card sending and receiving queues, thereby allowing multiple processor cores to process network packets located on multiple queues, respectively.
- the socket priority refers to the TOS (Type of Service) priority defined in the IP protocol, a total of 8 levels, which improves the concurrency of packet processing and improves the packet throughput.
- the packet throughput is PPS ( Packet, Second, or the number of network packets processed per second).
- the existing Linux TC network flow control technology although supporting multiple queues, can only use socket priority to classify network flows. Since the protocol limit supports only 8 levels, this greatly limits the ability of network flow classification. Because the network flow cannot be categorized flexibly according to the category identification of the network flow, the network packet cannot be distributed to multiple sending and receiving queues according to the network flow, resulting in a bottleneck in network packet forwarding performance in practical applications. For example, when the existing Linux TC technology is applied to multiple network application bandwidth isolation scenarios, there is a performance bottleneck in network processing throughput. On commercial multi-core processors (such as Intel Xeon CPU E5-2630 2.30GHz), the throughput cannot exceed 600K PPS, that is, the number of network data packets processed per second does not exceed 600,000 packets.
- This application provides a method for multi-queue network flow control, to solve the existing problems in the existing Linux TC network flow control technology, because the network flow cannot be flexibly classified according to the network flow type identification, resulting in practical application. There is a bottleneck in network packet forwarding performance.
- a network communication method provided by this application includes:
- the data packet Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
- the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified by a master serial number and a slave serial number, and the master serial number of the category queue is used for association
- the network device the queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number, and the master sequence number of the queuing rule takes a value from the slave sequence number of the category queue.
- the characteristics of the data packet include at least one of the following: IP quintuple information and socket information.
- the filter is a filter based on Linux flow control
- the passing filter classifies the data packet according to the network flow classification rule and sets the corresponding network flow class identifier, including:
- the network category identifier of the data packet is set;
- the IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
- the selecting a sending queue to forward the data packet according to the network flow category identifier includes:
- the sending queue scheduling module introduced in the Linux kernel is selected according to the network flow category identifier of the filter associated with the queuing rule.
- An extended command of a Linux control flow command is provided for associating the network flow category identifier with the queuing rule.
- the selecting a sending queue according to the network flow category identifier of the filter associated with the queuing rule includes:
- a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
- Optional also includes:
- the dequeuing order of the data packets is determined according to the priority of the network flow corresponding to the queuing rule associated with the selected send queue, and the queuing rule is used to sort the data packets of the send queue.
- Optional also includes:
- Each sending queue sends the data packets in sequence according to the dequeuing order of the data packets entering the queue.
- This application also provides a network communication method, including:
- the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
- the data packet is forwarded according to the queuing rule of the receiving end.
- the network flow classification rules include information used to match the characteristics of the packet header; the characteristics of the packet header include at least any of the following information: source IP address, destination IP address, and the corresponding end of the packet receiving end Socket and protocol.
- the forwarding the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet includes:
- different sending queues of the intermediate function module are selected to forward the data packet.
- Optional also includes:
- the receiving thread is a thread for processing the receiving of the data packet at the receiving end; correspondingly, the reuse of the receiving thread context using the receiving thread reuse technology includes:
- the receiving thread Directly use the receiving thread to forward the data packet to an intermediate function module according to the queuing rule of the receiving end; the intermediate function module is used to receive the redirected data packet and the network flow corresponding to the queuing rule The priority is sent back to the network device before being redirected.
- the present application also provides a network communication device, including:
- the identification unit is used to classify the data packets according to the network flow classification rules and set the corresponding network flow class identification through the filter before the data packets to be sent into the sending queue, and the network flow classification rules are used to match the data Characteristics of the package;
- a forwarding unit configured to select a sending queue to forward the data packet according to the network flow type identifier
- the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- the present application also provides a network communication device, including:
- the network flow classification unit is used to classify the network data packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is associated A filter of the queuing rules to the receiving end;
- An identification unit configured to set a network flow type identification of the data packet based on the matching relationship between the data packet and the network flow classification rule;
- the forwarding unit is configured to forward the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet.
- this application also provides an electronic device, including:
- Memory Memory, and processor
- the memory is used to store computer executable instructions
- the processor is used to execute the computer executable instructions:
- the data packet Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
- the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- this application also provides an electronic device, including:
- Memory Memory, and processor
- the memory is used to store computer executable instructions
- the processor is used to execute the computer executable instructions:
- the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
- the data packet is forwarded according to the queuing rule of the receiving end.
- the present application also provides a storage device that stores instructions that can be loaded by the processor and perform the following steps:
- the data packet Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
- the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- the present application also provides a storage device that stores instructions that can be loaded by the processor and perform the following steps:
- the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
- the data packet is forwarded according to the queuing rule of the receiving end.
- the method, apparatus, electronic device and storage device for network communication determine the sending queue by using the network flow type identifier. Since the available space of the network flow type identifier is much larger than the number of socket priorities, the pass rate is greatly improved.
- the number of network flow classifications sent by multiple queues thus solving the performance bottleneck problem of packet processing in the existing network flow control technology because it does not support flexible classification of network flows.
- the network flow control module is associated with multiple queues to implement support for network flow control based on network flow category identification.
- FIG. 1 is a schematic diagram of an actual deployment environment of a network communication method provided by an embodiment of the present application
- FIG. 2 is a processing flowchart of a network communication method provided by an embodiment of the present application.
- FIG. 3 is a schematic diagram of sending queue grouping of a network communication method according to an embodiment of the present application.
- FIG. 4 is a schematic diagram of data packet flow of a network communication method according to an embodiment of the present application.
- FIG. 5 is a schematic diagram of a network environment actually deployed in a second network communication method provided by this application.
- FIG. 6 is a processing flowchart of a second embodiment of a network communication method provided by this application.
- FIG. 7 is a schematic diagram of a data packet flow direction of a second embodiment of a network communication method provided by this application.
- FIG. 8 is a schematic diagram of an embodiment of a network communication device provided by this application.
- FIG. 9 is a schematic diagram of an embodiment of a second network communication device provided by this application.
- FIG. 10 is a schematic diagram of an embodiment of an electronic device provided by this application.
- This application provides a network communication method, device, electronic equipment, and storage equipment.
- the present application also provides a second network communication method, device, electronic device, and storage device. Detailed descriptions will be made one by one in the following embodiments.
- the first embodiment of the present application provides a network communication method.
- the following describes an embodiment of a network communication method provided by the present application with reference to FIGS. 1 to 4.
- an analogous water flow is used to describe the transmission of data packets in the network.
- a series of data packets sent from a specific source to a specific destination is called a network flow (or network data flow, or simply stream).
- a network flow or network data flow, or simply stream.
- IP quintuple information includes: source IP address, destination IP address, source port, destination port, and protocol number.
- Different identifiers can be used to mark different network flows.
- the identifier used to mark network flows is called a network flow category identifier (also called a category identifier, or classid).
- Linux platform commonly used in cloud computing and the Internet industry is based on Linux TC (Traffic Control, or flow controller) for kernel flow control.
- the forwarding process of network data packets in Linux is received from the entrance (input network card), find the route, determine that it is sent to the local machine, and forward it to the upper layer protocol processing, such as TCP, if it is determined that forwarding is required, then exit (output NIC) forwarded out, the Linux native TC function network flow control is controlled at the exit, because the TC module uses a global spin lock (spin_lock), only one processor core is allowed to process one network packet at any time, in order to improve data
- spin_lock global spin lock
- the existing TC technology provides a multi-queue network flow control solution, supports the classification of network packets according to the socket category identifier, and uses the token bucket technology to limit the maximum and minimum bandwidth available for a specific network flow So as to achieve the purpose of flow control.
- the network communication method provided in the embodiments of the present application is generally deployed at the sending end of a data packet.
- the sending end may be a network device, for example, may be a network interface board (Network Interface Card, or NIC), and a network interface board It is called a network card; the sending end may also be a virtual network device similar to the network device, and sending data packets through the virtual network device is similar to sending data packets through the physical port of the network device.
- the intermediate function module IFB Intermediate Functinal Block
- the network communication method supports flow control of the network flow marked by the network flow type identification based on the network flow type identification.
- the network flow category identifier distributes the data packets to multiple sending queues according to the network flow category identifier, so as to categorize the network flow flexibly. Because the available space of the network stream category identifier is large, the number of category identifiers is much larger than the number of socket priorities. Greatly improve the ability of network traffic classification, so that the network PPS can increase linearly with the number of processor cores, for example, it can reach 14.4M / s on the configured 24-core processor, thereby improving network bandwidth utilization and data center servers Resource utilization.
- the following uses the embodiment of the network communication method based on Linux as an example to illustrate the network communication method provided by the present application.
- each network card is associated with a queuing rule.
- the kernel forwards the data packet from the network card, it will add the data packet to the queue according to the corresponding queuing rule of the network card.
- complex queues are required, that is, queues with class queuing rules.
- Classifiers need to be used to filter packets into different classes, and then according to different queuing rules, according to Send packets in sortable queues in different orders to achieve flow control.
- FIG. 1 shows a network environment actually deployed by the network communication method, including: the network application 101 constructs a network data packet and sends it to the TCP / IP layer 102 through the socket mechanism; the TCP / IP layer 102 adds the network data packet After the TCP / IP protocol header information is sent to the net_clscGroup packet marking module 103; the net_clscGroup packet marking module 103 adds a category identifier to the network packet with the TCP / IP protocol header information added and sends it to the mq_cls sending queue scheduling module 104; The mq_cls send queue scheduling module 104 selects the send queue to forward the network data packet with added TCP / IP protocol header information to the outgoing interface of the network card through the network card driver 105, for example, the ethernet interface.
- the sending queue can be selected in the mq_cls sending queue scheduling module 104 to control the inbound and outbound queues of the network data packets containing TCP / IP protocol header information to achieve network flow control.
- the flow control of the network flow can be controlled at the exit, including shaping, scheduling, and dropping.
- the Linux kernel forwards the data packet from the network card to control the flow at the exit.
- the so-called shaping when the traffic is limited, its transmission rate is controlled below a certain value, the limit value can be much smaller than the effective bandwidth, which can smooth out burst data traffic and make the network more stable;
- scheduling through scheduling For data packet transmission, the bandwidth can be allocated according to priority within the bandwidth range; if the so-called dropping exceeds a certain set bandwidth, the data packet is discarded.
- the net_clscgroup is a subsystem for classifying and marking data packets.
- the net_clscgroup marking of data packets can be used as the network flow category identifier, and the Linux flow control TC (traffic control) can recognize the data after net_clscgroup marking package.
- FIG. 2 is a processing flowchart of a network communication method provided by an embodiment of the present application.
- the network communication method shown in FIG. 2 includes steps S201 to S202.
- Step S201 Before the data packet to be sent enters the sending queue, classify the data packet according to a network flow classification rule through a filter and set a corresponding network flow class identifier.
- the network flow classification rule is used to match the feature.
- the network flow classification rule is used to match the characteristics of the data packet; wherein, the characteristics of the data packet include at least one of the following: IP quintuple information and socket information. For example, if specific IP quintuple information is set as the network flow classification rule, the data packet matching the specific IP quintuple information is classified into a specific network flow.
- This step is to set a corresponding network flow category identifier on the data packets matching the network flow classification rules described above.
- the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow type identifier is set.
- the network flow classification rule of the filter contains information used to match the characteristics of the data packet to the network flow of the destination IP address 192.168.0.1 and destination port number 80, and the destination IP address 192.168.0.1 and destination port number 80
- the category ID is 10: 1; the filter will filter out the packets matching the destination IP address 192.168.0.1 and the destination port number 80, and set the network flow category ID 10 for the packets matching the network flow classification rules described above :1.
- the filter may be a filter based on Linux flow control
- the passing filter classifies the data packet according to the network flow classification rule and sets the corresponding network flow class identifier, including:
- the network category identifier of the data packet is set;
- the IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
- the so-called protocol types include four-layer protocol and / or seven-layer protocol, such as UDP, HTTP, etc.
- the filter may be a Linux cgroup filter.
- the so-called cgroup filter is a filter provided by the subsystem net_clscgroup in Linux cgroup (Linux control group, or Linux control group).
- the so-called Linux cgroup refers to the various subsystems provided by the Linux kernel for resource management, where net_cls cgroup is a subsystem that classifies and marks data packets, and the net_cls cgroup's marking of data packets can be used as the network flow category identification, which Linux can recognize Packets marked by each specific cgroup filter configured in the net_cls cgroup subsystem. For example, create and configure a specific net_cls cgroup, and then use the TC filter command to classify the data packets marked by the specific net_cls cgroup into the corresponding category of the network flow class identifier.
- Step S102 Select a sending queue to forward the data packet according to the network flow type identifier.
- the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified using a master serial number and a slave serial number, and the master serial number of the category queue is used to associate network devices;
- the queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number.
- the master sequence number of the queuing rule takes a value from the slave sequence number of the category queue.
- the data packets are managed by the queuing rules through the class in Linunx TC, and the data packets are inserted into the sending queue. Since the sending queue is grouped, it is called a class queue.
- the queuing rules in this embodiment are class queuing rules (ie classful queueing disciplines), and classless queuing rules pass through the queues in a first-in, first-out manner for data packets, except for caching packets that cannot be processed by the network interface No other processing is performed on packets entering the queue.
- class queuing rules include CBQ, HTB and Prior Qdisc, in which CBQ (class based queueing, or class based queuing) implements a rich connection sharing class structure, which has both bandwidth limiting and bandwidth priority Level management capability, bandwidth limitation is done by calculating the idle time of the connection.
- the standard for calculating idle time is the frequency of data packet dequeue events and the bandwidth of the lower layer connection (data link layer); HTB (hierarchy token bucket, or layered order (Bucket), to achieve bandwidth limitation through TBF (token bucket filter, or token bucket filter), allowing certain categories to break through the upper limit of bandwidth and occupy the bandwidth of other categories; rules such as Prio Qdisc will be high priority
- HTB hierarchy token bucket, or layered order (Bucket)
- TBF token bucket filter, or token bucket filter
- rules such as Prio Qdisc will be high priority
- the low-priority data packets are sent after the data packets are sent, that is, the data packets of different priorities are dequeued in sequence.
- the queuing rules can contain some categories, and different categories can contain deeper queuing rules.
- the so-called filter is used to classify data packets and determine the queuing rules for data packets to enter the queue. Whenever a data packet enters a sub-category category, it needs to be classified.
- the kernel calls all the filters attached to this class (class until a decision is returned. If no decision is returned, further processing is performed, and the processing method is related to the queuing rules.
- the queuing rules, classes, and filters are all identified by an ID.
- the ID is composed of a master serial number and a slave serial number, and the two numbers are separated by a colon.
- the main sequence number of the queuing rule is called a handle, which uses an expression like "1:”.
- Classes in the same queuing rule share the master sequence number of the queuing rule, but each class has its own slave sequence number, called the class identifier (classid).
- the class identifier is only related to the parent queuing rules, and not to the parent class.
- This step is to select a sending queue to forward the data packet marked by the network flow type identifier according to the network flow type identifier set in step S201.
- the functional modules of Linux TC are expanded to include the following two aspects:
- the Linux kernel introduces a send queue scheduling module.
- the sending queue scheduling module introduced by the Linux kernel selects the sending queue according to the network flow category identifier of the filter associated with the queuing rule.
- the extended command is used to associate the network flow category identifier with the queuing rule.
- the network flow classification rule corresponding to the filter is used to perform matching processing on the data packet, and the filter is attached to the class.
- Network devices that forward packets (such as network cards) need to create root queue queuing rules, and establish classes and subclasses under the root queue queuing rules.
- Each class has only one parent class, and each class can have multiple subclasses.
- These classes Form a tree, called TC tree.
- TC tree When the data packets are matched with the network flow classification rules, they are layered according to the TC tree. According to the processing logic of each layer, from the root to the leaf nodes, they are really queued up to the real queue to forward the data packets through the network device.
- Root queue queuing rule (Root QDISC) 301, the main sequence number of the root queue queuing rule is 8001:
- the root queue queuing rule 301 includes two classes: class3202 and class303, the class ID of class302 is 8001: ab51, and the class ID of class303 is 8001: ab52;
- the leaf queuing rule HTB305 of the class 303 is the leaf queuing rule HTB305 of the class 303.
- a specific method of the embodiment of the present application includes: associating the filter corresponding to the network flow category identifier to the queuing rule through the extended command of the Linux control flow command; and then transmitting the network flow category identifier of the filter associated with the queuing rule through the sending queue scheduling module Select the send queue.
- the introduction of the sending queue scheduling module and the command expansion are described below.
- the queue allocation method based on network flow class identification needs to define a flexible and reusable interface.
- the mq_cls send queue scheduling module is used to implement the socket class identification setting. Use the SO_PRIORITY option to set the class ID in the socket-> sk_classid field for the classified data packets
- the class ID is the network flow class identifier, and supports the selection of the sending end queue according to the class ID.
- the specific mq_cls module includes the following:
- mq_cls supports associating a TC qdisc (queueing discrimination) to a continuous set of sending queues.
- the major sequence number of the class ID of the queuing rule is used as the class ID of mq_cls to select a certain A group of send queues.
- the expanded new command format is:
- each command parameter is as follows:
- qdisc indicates commands related to queue rules
- dev specifies the keywords of the device
- queue rule identifies the main sequence number of the queue rule:]
- [numtc tcs] specifies the number of subcategories of mqcls
- Class0 refers to the serial number of the first subcategory
- [queuescount1 @ offset1count2 @ offset2...] specifies the queue group corresponding to the sub-category of mqcls
- count1 specifies the number of queues in the queue group corresponding to the first sub-category.
- Offset1 specifies the zero-based offset of the first queue in the queue group corresponding to the first subcategory.
- the transmission queue grouping diagram shown in FIG. 3 is used to explain the transmission queue grouping of the network device eth0.
- class 302 inserts the data packet with the network flow category identification as ab51 into the sending queue 306 according to the HTB queuing rules;
- the class 303 inserts the data packet with the network flow class identifier of ab52 into the sending queue 307 according to the HTB queuing rules.
- the HTB (Hieararchical Token Bucket) qdisc is mounted on the TXQ0 and TXQ1 configuration queues as follows:
- the command 1 divides the transmission queues TXQ0 and TXQ1 of the network device eth0 into one packet, and the command 2 mounts the HTB queuing rule to this packet.
- the command 3 divides the transmission queues TXQ2 and TXQ23 of the network device eth0 into one packet, and the command 4 mounts the HTB queuing rule to this packet.
- the rules for the value of the queuing rule handle (qdisc) and the class ID (class ID) of Linux TC are used.
- the queuing rules associated with the sending queue group must use the corresponding class
- the minor serial number of the class handle is used as the major serial number of its root handle.
- the value of the handle parameter in Command 2 is "ab51: 0", which depends on the value of the class parameter in Command 2 as "ab51”.
- the cgroup filter associated with the class of Linux TC (filter classified according to the class ID in net_cls cgroup) can classify the data packet as the network flow class identifier of the class class ID and match all Set the packet of the above-mentioned packet.
- the following process specifically selects the sending queue according to the network flow category identifier of the filter associated with the queuing rule, including:
- a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
- a hash table of the handle of the queuing rule added to the sending queue number in the Linux kernel is added to the hash table of the sending queue number, and the sending queue number is quickly searched through the hash table.
- the netdev_pick_tx () function is modified so that the major number in skb's net_cls is used to select txq.
- the Linux kernel adds a hash table from net_cls major number to txq number, which can be used to quickly find txq, so as to pass Major number selects txq and then its corresponding qdisc.
- the dequeuing order of the data packets is determined, and the queuing rule is used to sort the data packets of the sending queue.
- Each sending queue sends the data packets in sequence according to the dequeuing order of the data packets entering the queue. It implements the use of network flow class identification to determine the sending queue, and associates the network flow control module to multiple queues to achieve flow control support based on network class identification (network class ID).
- FIG. 4 shows the flow of forwarding processing of data packets at the sending end in the above network communication method.
- the network application 401 constructs a data packet
- TCP / IP 403 adds a protocol header to the data packet, such as a port number, an IP address, and a checksum, and sends the data packet with the added protocol header to TXQ Selection 404, which is a sending queue selection module;
- TXQ Selection 404 actually deploys mq_cls, which is used to select the transmission queue of network equipment (such as a network card, or network interface card, abbreviated as NIC), and send the data packet to Traffic Control 405 for flow control, and the flow control is shown in the figure
- the queuing rule is HTB;
- Traffic Control 405 for flow control processing enters the network card through NIC Driver 406, and arrives at the actual sending queue out NIC 407.
- the second embodiment of the present application provides a second network communication method.
- FIG. 5 is a schematic diagram of a network environment in which the network communication method provided by the present application is actually deployed;
- FIG. 6 is a processing flowchart of a second network communication method provided by the present application;
- FIG. 7 is a second method provided by the present application Schematic diagram of the forwarding flow of the data packet at the receiving end in the network communication method.
- the network communication method shown in FIG. 6 includes steps S601 to S603.
- Step S601 Classify the network data packets received by the receiving end according to the network flow classification rules of the filter.
- the network flow classification rules are used to match the characteristics of the data packet.
- the filter is associated with the received The filter of the queue rule at the end.
- the network communication method provided in the second embodiment of the present application is generally deployed at the receiving end of a data packet transmitted on the network to achieve flow control at the receiving end.
- the receiving end is a network device, for example, it may be a network interface card (Network Interface Card, or NIC), and the network interface board is also called a network card.
- NIC Network Interface Card
- the network interface board is also called a network card.
- the so-called IFB simulates network card forwarding data packets and provides flow control functions. Since the flow control module TC is associated with the IFB, the IFB can use the TC to provide flow control functions. IFB does not change the transmission direction of data packets. That is to say, after the data packets of the network card receive queue are redirected to IFB, after being processed by the flow control function of IFB, they are forwarded back to the network card before being redirected to continue the receiving process. For example, whether to send a data packet from a network card or receive a data packet from a network card, redirect to the IFB after the flow control function is processed, and then forward it back to the network card before being redirected by processing in the IFB's dev_queue_xmit function.
- the network communication method provided in this embodiment aims to complete the flow control of the receiving end through the network flow type identification.
- a cls_sk filter module also called cls_sk filter
- the cls_sk filter module is associated with the queuing rules of the receiving end, provides a cls_sk filter, determines the socket port number of each data packet received by the receiving end, and sets the network flow of the data packet according to the characteristics of the data packet Category identification.
- FIG. 5 shows a network environment actually deployed by the network communication method provided by this embodiment, including: data packets are put into a network card receiving queue;
- the data packet reaches the receiving end queuing rule 502 through the network card driver 501, and the receiving end queuing rule is also called ingress QDISC;
- the cls_sk filter 503 redirects the data packet marked with the network flow category identifier to the sending path of the IFB 504, the sending path of the IFB 504 is associated with the mq_cls sending queue scheduling module for selecting the sending queue;
- the data packet is controlled to be forwarded back to TCP / IP 505 to process the network protocol stack, so as to achieve the purpose of flow control.
- the TCP / IP Refers to the network protocol stack module;
- TCP / IP 505 sends the processed data packet to network application 506 for further processing.
- This step is to classify the network data packets received by the receiving end.
- the data packets received from the network side are classified according to the network flow classification rules of the filter.
- the cls_sk filter is used to query the socket port number of the data packet, and the network flow type corresponding to the data packet is determined according to the characteristics of the data packet.
- the network flow classification rules are used to match the characteristics of the data packet, and specifically include information used to match the characteristics of the packet header; the characteristics of the data packet header include at least any of the following information: source IP address and destination IP address 3.
- the filter is a filter associated with the queuing rule of the receiving end.
- Step S602 Set a network flow category identifier of the data packet based on the matching relationship between the data packet and the network flow classification rule.
- This step is to identify the network flow category of the data packet device.
- the data packet matching the network flow classification rule of the cls_sk filter is set with a network flow class identifier.
- Step S603 According to the network flow type identifier of the data packet, forward the data packet according to the queuing rule of the receiving end.
- the data packet is forwarded to the network protocol stack of the kernel for processing according to the queuing rule of the receiving end, so as to realize the flow control of the receiving end.
- specifically performing the following operations to realize forwarding the data packet according to the network flow type identifier of the data packet according to the queuing rule of the receiving end includes:
- the sending queue of the intermediate function module is selected to forward the data packet.
- the intermediate function module refers to IFB.
- the send queue scheduling module associated with IFB select the send queue of IFB, and perform flow control according to IFB's queuing rules, such as HTB.
- the embodiment of the present application further includes: using the receiving thread reuse technology to reuse the receiving thread context. Preferably, it is supported to control whether to enable the reuse function of the receiving thread through a switch.
- the receiving thread is a thread for processing reception of a data packet at the receiving end.
- the content in the context of a specific thread is used by other modules, which can be implemented through mechanisms such as memory sharing and message queues, or it can directly reuse the specific thread to complete at least part of the work required by other modules.
- the so-called receiving thread reuse technology refers to using the receiving thread to process other data packet processing tasks than the reception of the data packet, so that the content saved in the context of the receiving end can be directly used for the Other packet processing work.
- the receiving thread is reused in the intermediate function module IFB. For example, directly using the receiving thread to forward the data packet to an intermediate function module (IFB) according to the queuing rules of the receiving end, without using the tasklet mechanism, can avoid the processor core competition that the tasklet may bring.
- IFB intermediate function module
- the intermediate function module is configured to receive the redirected data packet, and send the redirected data packet back to the network device before being redirected according to the priority of the network flow corresponding to the queuing rule.
- the intermediate function module processes the redirected data packet and sends it back to the receiving end before being redirected.
- the reuse of the receiving thread can also use the receiving thread to directly execute the network protocol stack, which can improve the concurrency of the flow control processing at the receiving end.
- FIG. 7 shows the flow of the receiving end after receiving the data packet from the network side.
- the data packet is received through a network device (network card), the received data packet is processed through the network communication method, and the processed data packet is sent to a network application for further use.
- a network device network card
- the processed data packet is sent to a network application for further use.
- NIC 701 is a network card, and the network card has n + 1 receiving queues RXQ0, RXQ1, RXQ2, ..., RXQn; the data packets enter the receiving queue of NIC 701;
- the data packet reaches the NIC Driver 702 through the receiving queue of NIC 701, and the NIC Driver is a network card driver;
- Ingress QDISC 703 arrives at Ingress QDISC 703 by NIC Driver 702.
- Ingress QDISC is the queuing rule of the receiving end, also known as the receiving end flow control scheduler;
- the data packet reaches the cls_sk filter associated with the queuing rule of the receiving end by Ingress QDISC 703, that is, cls_sk / mirred action 704 in the figure, and cls_sk determines the network flow type of the data packet and sets the network flow type identifier for the data packet;
- the mirred action shown refers to the cls_sk filter performing the redirect action, and the data packet will be redirected to the intermediate function module IFB 706;
- Traffic Control 705 is the flow control module associated with IFB 706. According to the flow control module associated with IFB 706, select the transmission queue on the transmission path of IFB 706 (see TXQ Selection in the figure.
- the transmission queue is a reused reception queue. There are n transmission queues) ),
- IFB 706 sends back to the receiving queue of the network card before redirection to continue receiving processing, and continuing to receive processing including sending to TCP / IP 707 performs network protocol stack processing, and the illustrated TCP / IP indicates that the network protocol stack is an IP protocol stack;
- TCP / IP 707 sends the processed data packets to the network application 708 through the socket layer for further processing or use.
- the present application also provides a first network communication device.
- FIG. 8 shows a schematic diagram of a first network communication device according to the present application. Since the device embodiments are basically similar to the method embodiments, the description is relatively simple. For related parts, please refer to the corresponding descriptions of the corresponding method embodiments.
- This application provides the first network communication device, including:
- the identification unit 801 is used to classify the data packet according to the network flow classification rule and set the corresponding network flow class identification through the filter before the data packet to be sent into the sending queue.
- the network flow classification rule is used to match the Characteristics of the data packet;
- a forwarding unit 802 configured to select a sending queue to forward the data packet according to the network flow type identifier
- the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified by a master serial number and a slave serial number, and the master serial number of the category queue is used for association
- the network device the queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number, and the master sequence number of the queuing rule takes a value from the slave sequence number of the category queue.
- the characteristics of the data packet include at least one of the following: IP quintuple information and socket information.
- the filter is a filter based on Linux flow control
- the identification unit 801 is specifically used for:
- the network category identifier of the data packet is set;
- the IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
- the forwarding unit 802 is specifically used to:
- the sending queue scheduling module introduced in the Linux kernel is selected according to the network flow category identifier of the filter associated with the queuing rule.
- the network communication device further includes a command unit for:
- An extended command of a Linux control flow command is provided, and the extended command is used to associate the network flow category identifier with the queuing rule.
- the forwarding unit 802 is specifically used to:
- a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
- the network communication device further includes a dequeuing order determination unit, which is used to:
- the dequeuing order of the data packets is determined according to the priority of the network flow corresponding to the queuing rule associated with the selected send queue, and the queuing rule is used to sort the data packets of the send queue.
- this application also provides a second network communication device.
- FIG. 9 shows a schematic diagram of a second network communication device according to the present application. Since the device embodiments are basically similar to the method embodiments, the description is relatively simple. For related parts, please refer to the corresponding descriptions of the corresponding method embodiments.
- This application provides a second network communication device, including:
- the network flow classification unit 901 is used to classify the network data packets received by the receiving end according to the network flow classification rules of the filter.
- the network flow classification rules are used to match the characteristics of the data packet.
- the filter is A filter associated with the queuing rule of the receiving end;
- the identification unit 902 is configured to set the network flow type identification of the data packet based on the matching relationship between the data packet and the network flow classification rule;
- the forwarding unit 903 is configured to forward the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet.
- the network flow classification rules include information used to match the characteristics of the packet header; the characteristics of the packet header include at least any of the following information: source IP address, destination IP address, and the corresponding end of the packet receiving end Socket and protocol.
- the forwarding unit 903 is specifically used to:
- the sending queue of the intermediate function module is selected to forward the data packet.
- the network communication device further includes a receiving thread reuse unit, which is used to:
- the receiving thread is a thread for processing the receiving of data packets at the receiving end; correspondingly, the receiving thread reuse unit is specifically used for:
- the receiving thread Directly use the receiving thread to forward the data packet to an intermediate function module according to the queuing rule of the receiving end; the intermediate function module is used to receive the redirected data packet and the network flow corresponding to the queuing rule The priority is sent back to the network device before being redirected.
- the present application also provides an embodiment of an electronic device for implementing the network communication method provided in the first embodiment of the present application.
- FIG. 10 shows an electronic device provided by the present embodiment Schematic.
- This application provides an electronic device, including:
- Memory 1001, and processor 1002 are examples of processor 1001, and processor 1002;
- the memory 1001 is used to store computer executable instructions, and the processor 1002 is used to execute the computer executable instructions:
- the data packet Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
- the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified by a master serial number and a slave serial number, and the master serial number of the category queue is used for association
- the network device the queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number, and the master sequence number of the queuing rule takes a value from the slave sequence number of the category queue.
- the characteristics of the data packet include at least one of the following: IP quintuple information and socket information.
- the filter is a filter based on Linux flow control
- processor 1002 is also used to execute the following computer executable instructions:
- the network category identifier of the data packet is set;
- the IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
- processor 1002 is also used to execute the following computer-executable instructions:
- the sending queue scheduling module introduced in the Linux kernel is selected according to the network flow category identifier of the filter associated with the queuing rule.
- processor 1002 is also used to execute the following computer-executable instructions:
- An extended command of a Linux control flow command is provided, and the extended command is used to associate the network flow category identifier with the queuing rule.
- processor 1002 is also used to execute the following computer-executable instructions:
- a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
- processor 1002 is also used to execute the following computer-executable instructions:
- the dequeuing order of the data packets is determined according to the priority of the network flow corresponding to the queuing rule associated with the selected send queue, and the queuing rule is used to sort the data packets of the send queue.
- the present application also provides a second embodiment of an electronic device that is used to implement the network communication method provided by the second embodiment of the present application, and a schematic diagram of the electronic device is similar to FIG. 10.
- This application provides a second type of electronic equipment, including:
- Memory Memory, and processor
- the memory is used to store computer executable instructions
- the processor is used to execute the computer executable instructions:
- the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
- the data packet is forwarded according to the queuing rule of the receiving end.
- the network flow classification rules include information used to match the characteristics of the packet header; the characteristics of the packet header include at least any of the following information: source IP address, destination IP address, and the corresponding end of the packet receiving end Socket and protocol.
- the processor is also used to execute the following computer-executable instructions:
- the sending queue of the intermediate function module is selected to forward the data packet.
- the processor is also used to execute the following computer-executable instructions:
- the receiving thread is a thread for processing the reception of data packets at the receiving end; correspondingly, the processor is also used to execute the following computer-executable instructions:
- the receiving thread Directly use the receiving thread to forward the data packet to an intermediate function module according to the queuing rule of the receiving end; the intermediate function module is used to receive the redirected data packet and the network flow corresponding to the queuing rule The priority is sent back to the network device before being redirected.
- the present application also provides an embodiment of a storage device.
- the present application provides a storage device, including: a memory and a processor, wherein the memory stores instructions, and the instructions can be loaded by the processor and perform the following steps:
- the data packet Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
- the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- This application also provides a second embodiment of the storage device.
- the second storage device includes: a memory and a processor, wherein the memory stores instructions, and the instructions can be loaded by the processor and perform the following steps:
- the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
- the data packet is forwarded according to the queuing rule of the receiving end.
- the computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
- processors CPUs
- input / output interfaces output interfaces
- network interfaces network interfaces
- memory volatile and non-volatile memory
- the memory may include non-permanent memory, random access memory (RAM) and / or non-volatile memory in computer-readable media, such as read only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
- RAM random access memory
- ROM read only memory
- flash RAM flash memory
- Computer-readable media including permanent and non-permanent, removable and non-removable media, can implement information storage by any method or technology.
- the information may be computer readable instructions, data structures, modules of programs, or other data.
- Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, read-only compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices.
- computer-readable media does not include non-transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
- the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented 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.
- computer usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
A network communication method and apparatus, an electronic device and a storage device. The method comprises: classifying, before data packets to be sent enter sending queues, the data packets by means of a filter according to a network flow classification rule and setting corresponding network flow class identifiers, the network flow classification rule being used for matching the features of the data packets (S201); and selecting, according to the network flow class identifiers, sending queues to forward the data packets, wherein the filter is used for setting corresponding network flow class identifiers according to a matching relationship between the data packets and the network flow classification rule (S202). The method uses network flow class identifiers for multi-queue sending to implement flow control, thereby increasing the number of network flow classes sent by means of multiple queues.
Description
本申请涉及网络通信领域,具体涉及一种网络通信的方法、装置、电子设备及存储设备。本申请还涉及第二种网络通信的方法及装置。The present application relates to the field of network communication, and in particular to a network communication method, device, electronic device, and storage device. The present application also relates to a second network communication method and device.
Linux作为开源软件,因其具有灵活性和可扩展性,符合作为集中式服务平台提供可伸缩的共享计算能力的云计算的发展趋势,是云计算业界广泛采用的基础软件。云计算提供的计算能力,包括处理器、内存、存储和网络接口,需要处理海量数据,因此网络数据包的流控方案和吞吐量显得尤其重要。Linux is an open source software. Because of its flexibility and scalability, Linux is in line with the development trend of cloud computing as a centralized service platform that provides scalable shared computing capabilities. It is the basic software widely used in the cloud computing industry. The computing power provided by cloud computing, including processors, memory, storage, and network interfaces, needs to process massive amounts of data, so the flow control scheme and throughput of network packets are particularly important.
Linux平台的网络流控方案一般是基于TC(Traffic Control,或流量控制器)进行内核流量控制,TC模块支持按照socket类别标识来分类网络包,并通过令牌桶技术来限定特定网络流可用带宽的最大和最小值从而达到进行流控的目的。TC模块由于使用了全局自旋锁(spin_lock),在任意时刻仅允许一个处理器核处理一个网络包,为提高数据包处理的并发性和吞吐量,现有的TC技术支持多队列网络流控方案,具体的,通过Linux的mq_prio模块实现基于网络包的socket优先级来分发网络包到多个网卡发送和接收队列上,从而允许多个处理器核分别处理位于多个队列上的网络包,其中,socket优先级是指IP协议中的定义的TOS(Type of Service)优先级,共8个级别,这样提高了数据包处理的并发性以及提高数据包吞吐量,数据包吞吐量以PPS(Packet per Second,或每秒钟处理的网络数据包数量)表示。The network flow control scheme of the Linux platform is generally based on TC (Traffic Control, or flow controller) for kernel flow control. The TC module supports the classification of network packets according to the socket type identification, and the available bandwidth of a specific network flow is limited by the token bucket technology To achieve the purpose of flow control. The TC module uses a global spin lock (spin_lock), which allows only one processor core to process one network packet at any time. To improve the concurrency and throughput of packet processing, the existing TC technology supports multi-queue network flow control The solution, specifically, implements the network packet-based socket priority through the Linux mq_prio module to distribute network packets to multiple network card sending and receiving queues, thereby allowing multiple processor cores to process network packets located on multiple queues, respectively. Among them, the socket priority refers to the TOS (Type of Service) priority defined in the IP protocol, a total of 8 levels, which improves the concurrency of packet processing and improves the packet throughput. The packet throughput is PPS ( Packet, Second, or the number of network packets processed per second).
现有的Linux TC网络流控技术,虽然支持多队列,但是仅能使用socket优先级对网络流分类,由于协议限定仅支持8个级别,这极大地限制了网络流分类的能力。由于无法根据网络流的类别标识对网络流进行灵活分类,从而不能按照网络流分发网络包到多个发送和接收队列上,导致实际应用中存在网络数据包转发性能瓶颈的问题。例如,现有的Linux TC技术应用于多种网络应用带宽隔离的场景时,网络处理吞吐量存在性能瓶颈,在商用多核处理器(如Intel Xeon CPU E5-2630 2.30GHz)上,吞吐量无法超过600K PPS,即每秒处理的网络数据包数不超过60万个包,因而,在10Gbps(或者更高传输速率的)网卡以及网络包大小小于2K字节的情况下仅能利用部分可用带宽,例如,包长为512 字节大小的网络包仅能使用2G带宽,利用率为20%,并且扩充处理器核数也不能解决此性能瓶颈问题。The existing Linux TC network flow control technology, although supporting multiple queues, can only use socket priority to classify network flows. Since the protocol limit supports only 8 levels, this greatly limits the ability of network flow classification. Because the network flow cannot be categorized flexibly according to the category identification of the network flow, the network packet cannot be distributed to multiple sending and receiving queues according to the network flow, resulting in a bottleneck in network packet forwarding performance in practical applications. For example, when the existing Linux TC technology is applied to multiple network application bandwidth isolation scenarios, there is a performance bottleneck in network processing throughput. On commercial multi-core processors (such as Intel Xeon CPU E5-2630 2.30GHz), the throughput cannot exceed 600K PPS, that is, the number of network data packets processed per second does not exceed 600,000 packets. Therefore, in the case of 10Gbps (or higher transmission rate) network cards and network packet sizes less than 2K bytes, only part of the available bandwidth can be used. For example, a network packet with a packet length of 512 bytes can only use 2G bandwidth, and the utilization rate is 20%, and expanding the number of processor cores cannot solve this performance bottleneck.
发明内容Summary of the invention
本申请提供一种用于多队列网络流控的方法,以解决现有的Linux TC网络流控技术中存在的由于无法根据网络流的类别标识对网络流进行灵活分类,从而导致的实际应用中存在网络数据包转发性能瓶颈的问题。This application provides a method for multi-queue network flow control, to solve the existing problems in the existing Linux TC network flow control technology, because the network flow cannot be flexibly classified according to the network flow type identification, resulting in practical application. There is a bottleneck in network packet forwarding performance.
本申请提供的一种网络通信的方法,包括:A network communication method provided by this application includes:
在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;
其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
可选的,所述发送队列,是关联了排队规则的序号连续的类别队列;其中,所述类别队列,使用主序列号和从序列号进行标识,所述类别队列的主序列号用于关联网络设备;所述排队规则,关联了所述过滤器,使用主序列号和从序列号进行标识,所述排队规则的主序列号取值于所述类别队列的从序列号。Optionally, the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified by a master serial number and a slave serial number, and the master serial number of the category queue is used for association The network device; the queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number, and the master sequence number of the queuing rule takes a value from the slave sequence number of the category queue.
可选的,所述数据包的特征包括如下至少之一:IP五元组信息、socket信息。Optionally, the characteristics of the data packet include at least one of the following: IP quintuple information and socket information.
可选的,所述过滤器,是基于Linux流量控制的过滤器;Optionally, the filter is a filter based on Linux flow control;
相应的,所述通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,包括:Correspondingly, the passing filter classifies the data packet according to the network flow classification rule and sets the corresponding network flow class identifier, including:
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征,按照所述网络流分类规则对所述数据包分类;Classify the data packet according to the network flow classification rules according to the IP header characteristics of the data packet through a filter based on Linux flow control;
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征与网络流分类规则的匹配关系,设置所述数据包的网络类别标识;Through a filter based on Linux flow control, according to the matching relationship between the IP header characteristics of the data packet and the network flow classification rules, the network category identifier of the data packet is set;
所述数据包的IP头部特征至少包括下述任一信息:源IP、目的IP、源socket端口、目的socket端口、协议类型。The IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
可选的,所述根据所述网络流类别标识,选择发送队列转发所述数据包,包括:Optionally, the selecting a sending queue to forward the data packet according to the network flow category identifier includes:
通过在Linux内核引入的发送队列调度模块,根据所述排队规则关联的过滤器的网络流类别标识选择发送队列。Through the sending queue scheduling module introduced in the Linux kernel, the sending queue is selected according to the network flow category identifier of the filter associated with the queuing rule.
可选的,包括:Optional, including:
提供Linux控制流量命令的扩展命令,用于将所述网络流类别标识关联到所述排队规则。An extended command of a Linux control flow command is provided for associating the network flow category identifier with the queuing rule.
可选的,所述根据所述排队规则关联的过滤器的网络流类别标识选择发送队列,包括:Optionally, the selecting a sending queue according to the network flow category identifier of the filter associated with the queuing rule includes:
根据数据包的网络流类别标识,确定所述网络流类别标识对应的排队规则;Determine the queuing rule corresponding to the network flow type identifier according to the network flow type identifier of the data packet;
根据所述排队规则的主序列号,查找所述排队规则的主序列号到所述发送队列号的哈希表,确定发送队列号。According to the main sequence number of the queuing rule, a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
可选的,还包括:Optional, also includes:
根据选择的发送队列关联的排队规则对应的网络流的优先级,确定所述数据包离队次序,所述排队规则,用于对所述发送队列的数据包排序。The dequeuing order of the data packets is determined according to the priority of the network flow corresponding to the queuing rule associated with the selected send queue, and the queuing rule is used to sort the data packets of the send queue.
可选的,还包括:Optional, also includes:
各发送队列根据进入队列的数据包的离队次序,依次发送所述数据包。Each sending queue sends the data packets in sequence according to the dequeuing order of the data packets entering the queue.
本申请还提供一种网络通信的方法,包括:This application also provides a network communication method, including:
按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;
根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
可选的,所述网络流分类规则,包含用于匹配数据包头部特征的信息;所述数据包头部特征,至少包括下述任一信息:源IP地址、目的IP地址、数据包接收端对应的socket和协议。Optionally, the network flow classification rules include information used to match the characteristics of the packet header; the characteristics of the packet header include at least any of the following information: source IP address, destination IP address, and the corresponding end of the packet receiving end Socket and protocol.
可选的,所述根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包,包括:Optionally, the forwarding the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet includes:
通过所述接收端的排队规则关联的过滤器,将所述数据包重定向到中间功能模块;Redirect the data packet to an intermediate function module through a filter associated with the queuing rule of the receiving end;
根据所述网络流类别标识,选择所述中间功能模块的不同发送队列,转发 所述数据包。According to the network flow type identifier, different sending queues of the intermediate function module are selected to forward the data packet.
可选的,还包括:Optional, also includes:
使用接收线程重用技术重用接收端线程上下文。Use the receiving thread reuse technique to reuse the receiving thread context.
可选的,所述接收线程,是用于处理接收端的数据包的接收的线程;相应的,所述使用接收线程重用技术重用接收端线程上下文,包括:Optionally, the receiving thread is a thread for processing the receiving of the data packet at the receiving end; correspondingly, the reuse of the receiving thread context using the receiving thread reuse technology includes:
直接使用所述接收线程,按照所述接收端的排队规则将所述数据包转发到中间功能模块;所述中间功能模块,用于接收重定向来的数据包,按照所述排队规则对应的网络流的优先级将所述重定向来的数据包发送回被重定向前的网络设备。Directly use the receiving thread to forward the data packet to an intermediate function module according to the queuing rule of the receiving end; the intermediate function module is used to receive the redirected data packet and the network flow corresponding to the queuing rule The priority is sent back to the network device before being redirected.
此外,本申请还提供一种网络通信的装置,包括:In addition, the present application also provides a network communication device, including:
标识单元,用于在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;The identification unit is used to classify the data packets according to the network flow classification rules and set the corresponding network flow class identification through the filter before the data packets to be sent into the sending queue, and the network flow classification rules are used to match the data Characteristics of the package;
转发单元,用于根据所述网络流类别标识,选择发送队列转发所述数据包;A forwarding unit, configured to select a sending queue to forward the data packet according to the network flow type identifier;
其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
此外,本申请还提供一种网络通信的装置,包括:In addition, the present application also provides a network communication device, including:
网络流分类单元,用于按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;The network flow classification unit is used to classify the network data packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is associated A filter of the queuing rules to the receiving end;
标识单元,用于基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;An identification unit, configured to set a network flow type identification of the data packet based on the matching relationship between the data packet and the network flow classification rule;
转发单元,用于根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。The forwarding unit is configured to forward the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet.
此外,本申请还提供一种电子设备,包括:In addition, this application also provides an electronic device, including:
存储器,以及处理器;Memory, and processor;
所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions:
在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;
其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
此外,本申请还提供一种电子设备,包括:In addition, this application also provides an electronic device, including:
存储器,以及处理器;Memory, and processor;
所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions:
按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;
根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
此外,本申请还提供一种存储设备,存储有指令,所述指令能够被处理器加载并执行以下步骤:In addition, the present application also provides a storage device that stores instructions that can be loaded by the processor and perform the following steps:
在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;
其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
此外,本申请还提供一种存储设备,存储有指令,所述指令能够被处理器加载并执行以下步骤:In addition, the present application also provides a storage device that stores instructions that can be loaded by the processor and perform the following steps:
按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;
根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
与现有技术相比,本申请具有以下优点:Compared with the prior art, this application has the following advantages:
本申请提供的网络通信的方法、装置、电子设备及存储设备,通过使用网络流类别标识来确定发送队列由于所述网络流类别标识的可用空间远大于socket优先级的数目,因此大大提高了通过多队列发送的网络流分类的数目,从而解决了现有的网络流量控制技术中由于不支持网络流灵活分类而导致的数据包处理的性能瓶颈问题。进一步的,将网络流控模块关联到多个队列上,实现了对基于网络流类别标识进行网络流量控制的支持。The method, apparatus, electronic device and storage device for network communication provided by the present application determine the sending queue by using the network flow type identifier. Since the available space of the network flow type identifier is much larger than the number of socket priorities, the pass rate is greatly improved. The number of network flow classifications sent by multiple queues, thus solving the performance bottleneck problem of packet processing in the existing network flow control technology because it does not support flexible classification of network flows. Further, the network flow control module is associated with multiple queues to implement support for network flow control based on network flow category identification.
图1是本申请其一实施例提供的一种网络通信的方法的实际部署环境的示意图;1 is a schematic diagram of an actual deployment environment of a network communication method provided by an embodiment of the present application;
图2是本申请其一实施例提供的一种网络通信的方法的处理流程图;2 is a processing flowchart of a network communication method provided by an embodiment of the present application;
图3是本申请其一实施例提供的一种网络通信的方法的发送队列分组示意图;3 is a schematic diagram of sending queue grouping of a network communication method according to an embodiment of the present application;
图4是本申请其一实施例提供的一种网络通信的方法的数据包流向示意图;4 is a schematic diagram of data packet flow of a network communication method according to an embodiment of the present application;
图5是本申请提供的第二种网络通信的方法实际部署的网络环境示意图;5 is a schematic diagram of a network environment actually deployed in a second network communication method provided by this application;
图6是本申请提供的第二种网络通信的方法实施例的处理流程图;6 is a processing flowchart of a second embodiment of a network communication method provided by this application;
图7是本申请提供的第二种网络通信的方法实施例的数据包流向示意图;7 is a schematic diagram of a data packet flow direction of a second embodiment of a network communication method provided by this application;
图8是本申请提供的一种网络通信的装置实施例的示意图;8 is a schematic diagram of an embodiment of a network communication device provided by this application;
图9是本申请提供的第二种网络通信的装置实施例的示意图;9 is a schematic diagram of an embodiment of a second network communication device provided by this application;
图10是本申请提供的一种电子设备实施例的示意图。10 is a schematic diagram of an embodiment of an electronic device provided by this application.
在下面的描述中阐述了很多具体细节以便于充分理解本申请。但是本申请能够以很多不同于在此描述的其它方式来实施,本领域技术人员可以在不违背本申请内涵的情况下做类似推广,因此本申请不受下面公开的具体实施的限制。In the following description, many specific details are set forth in order to fully understand the application. However, this application can be implemented in many other ways than those described here. Those skilled in the art can make similar promotion without violating the connotation of this application, so this application is not limited by the specific implementation disclosed below.
本申请提供一种网络通信的方法、装置、电子设备及存储设备。本申请还提供第二种网络通信的方法、装置、电子设备及存储设备。在下面的实施例中逐一进行详细说明。This application provides a network communication method, device, electronic equipment, and storage equipment. The present application also provides a second network communication method, device, electronic device, and storage device. Detailed descriptions will be made one by one in the following embodiments.
本申请第一实施例提供一种网络通信的方法。以下结合图1至图4对本申请提供的一种网络通信的方法的实施例进行说明。The first embodiment of the present application provides a network communication method. The following describes an embodiment of a network communication method provided by the present application with reference to FIGS. 1 to 4.
网络通信中,以类比水流来描述数据包在网络中的传输,从一个特定源发 送到一个特定目的的一系列数据包称为一个网络流(或称为网络数据流,或简称为流)。例如,在一个源IP地址和一个目的IP地址之间单向传输的具有相同IP五元组信息的数据包定义为一个网络流。所谓IP五元组信息,包括:源IP地址、目的IP地址、源端口、目的端口、协议号。可以使用不同的标识来标记不同的网络流,用于标记网络流的标识称为网络流类别标识(也称为类别标识,或classid)。In network communication, an analogous water flow is used to describe the transmission of data packets in the network. A series of data packets sent from a specific source to a specific destination is called a network flow (or network data flow, or simply stream). For example, a data packet with the same IP quintuple information transmitted unidirectionally between a source IP address and a destination IP address is defined as a network flow. The so-called IP quintuple information includes: source IP address, destination IP address, source port, destination port, and protocol number. Different identifiers can be used to mark different network flows. The identifier used to mark network flows is called a network flow category identifier (also called a category identifier, or classid).
针对不同的网络流采取不同的转发策略,从而对不同业务提供差异化服务,提高带宽利用率,是云计算和互联网行业节约网络资源的重要手段,因此,网络流的流控方案和吞吐量显得尤为重要。云计算和互联网行业中常用的Linux平台,基于Linux TC(Traffic Control,或流量控制器)进行内核流量控制。网络数据包在Linux内的转发流程,从入口(输入网卡)接收进来,查找路由,确定是发给本机的,转发给上层协议处理,例如TCP,如果确定需要转发的,则从出口(输出网卡)转发出去,Linux原生的TC功能的网络流控是在出口进行控制,TC模块由于使用了全局自旋锁(spin_lock),在任意时刻仅允许一个处理器核处理一个网络包,为了提高数据包处理的并发性和吞吐量,现有的TC技术提供多队列网络流控方案,支持按照socket类别标识来分类网络包,并通过令牌桶技术来限定特定网络流可用带宽的最大和最小值从而达到进行流控的目的。Taking different forwarding strategies for different network flows to provide differentiated services for different services and improve bandwidth utilization is an important means of cloud computing and the Internet industry to save network resources. Therefore, the flow control scheme and throughput of network flows appear especially important. The Linux platform commonly used in cloud computing and the Internet industry is based on Linux TC (Traffic Control, or flow controller) for kernel flow control. The forwarding process of network data packets in Linux is received from the entrance (input network card), find the route, determine that it is sent to the local machine, and forward it to the upper layer protocol processing, such as TCP, if it is determined that forwarding is required, then exit (output NIC) forwarded out, the Linux native TC function network flow control is controlled at the exit, because the TC module uses a global spin lock (spin_lock), only one processor core is allowed to process one network packet at any time, in order to improve data The concurrency and throughput of packet processing, the existing TC technology provides a multi-queue network flow control solution, supports the classification of network packets according to the socket category identifier, and uses the token bucket technology to limit the maximum and minimum bandwidth available for a specific network flow So as to achieve the purpose of flow control.
本申请实施例提供的网络通信的方法,一般部署于数据包的发送端,所述发送端,可以是网络设备,例如,可以是网络接口板(Network Interface Card,或NIC),网络接口板也称为网卡;所述发送端也可以是类似于所述网络设备的虚拟网络设备,通过虚拟网络设备发送数据包类似于通过网络设备的物理口发送数据包。例如,中间功能模块IFB(Intermediate Functoinal Block)。所述网络通信的方法,支持基于网络流类别标识对所述网络流类别标识标记的网络流进行流量控制。具体为根据网络流类别标识来分发数据包到多个发送队列上,从而对网络流进行灵活的分类,由于网络流类别标识的可用空间大,因此类别标识的数目远大于socket优先级的数目,大大提高了网络流分类的能力,使得网络PPS可以随处理器核数线性增长,例如,在配置的24核处理器上可以达到14.4M/s,从而提高了网络带宽利用率,以及数据中心服务器的资源利用率。The network communication method provided in the embodiments of the present application is generally deployed at the sending end of a data packet. The sending end may be a network device, for example, may be a network interface board (Network Interface Card, or NIC), and a network interface board It is called a network card; the sending end may also be a virtual network device similar to the network device, and sending data packets through the virtual network device is similar to sending data packets through the physical port of the network device. For example, the intermediate function module IFB (Intermediate Functinal Block). The network communication method supports flow control of the network flow marked by the network flow type identification based on the network flow type identification. Specifically, it distributes the data packets to multiple sending queues according to the network flow category identifier, so as to categorize the network flow flexibly. Because the available space of the network stream category identifier is large, the number of category identifiers is much larger than the number of socket priorities. Greatly improve the ability of network traffic classification, so that the network PPS can increase linearly with the number of processor cores, for example, it can reach 14.4M / s on the configured 24-core processor, thereby improving network bandwidth utilization and data center servers Resource utilization.
下述以基于Linux TC实现的所述网络通信的方法的实施例为例,说明本申请提供的网络通信的方法。The following uses the embodiment of the network communication method based on Linux as an example to illustrate the network communication method provided by the present application.
在阐述本实施例前Linux TC进行流控的基本概念:排队规则、类别、过滤 器。每个网卡都与一个排队规则相联系,当内核将数据包从网卡转发出去,都会将数据包根据网卡对应的排队规则加入到队列中。要实现强大的流量控制,需要功能复杂的队列,即有类别排队规则的队列(Classful),需要使用过滤器(filter)将数据包分成不同的类别(class),再根据不同的排队规则,按照不同顺序发送可分类队列中的数据包,从而实现流量控制。Before explaining this embodiment, the basic concepts of Linux TC flow control: queuing rules, categories, and filters. Each network card is associated with a queuing rule. When the kernel forwards the data packet from the network card, it will add the data packet to the queue according to the corresponding queuing rule of the network card. To achieve powerful flow control, complex queues are required, that is, queues with class queuing rules. Classifiers need to be used to filter packets into different classes, and then according to different queuing rules, according to Send packets in sortable queues in different orders to achieve flow control.
图1示出了所述网络通信的方法实际部署的网络环境,包括:网络应用101构造网络数据包,通过socket机制发送到TCP/IP层102;TCP/IP层102对所述网络数据包增加TCP/IP协议头信息后,发送到net_cls cGroup数据包标记模块103;net_cls cGroup数据包标记模块103对添加了TCP/IP协议头信息的网络数据包增加类别标识后,发送到mq_cls发送队列调度模块104;mq_cls发送队列调度模块104选择发送队列将所述增加了TCP/IP协议头信息的网络数据包,通过网卡驱动105转发到网卡的出接口,例如ethernet接口。其中,可以在mq_cls发送队列调度模块104选择发送队列,控制包含TCP/IP协议头信息的网络数据包的入发送队列和出发送队列,来实现网络流量控制。对于网络流的流量控制可以在出口进行控制,包括整形(shaping)、调度(scheduling)、丢包(dropping)等控制,Linux内核将数据包从网卡转发出去在出口进行流量控制。其中,所谓shaping,当流量被限制,它的传输速率就被控制在某个值以下,限制值可以大大小于有效带宽,这样可以平滑突发数据流量,使网络更为稳定;所谓scheduling,通过调度数据包的传输,可以在带宽范围内,按照优先级分配带宽;所谓dropping如果流量超过某个设定的带宽,就丢弃数据包。FIG. 1 shows a network environment actually deployed by the network communication method, including: the network application 101 constructs a network data packet and sends it to the TCP / IP layer 102 through the socket mechanism; the TCP / IP layer 102 adds the network data packet After the TCP / IP protocol header information is sent to the net_clscGroup packet marking module 103; the net_clscGroup packet marking module 103 adds a category identifier to the network packet with the TCP / IP protocol header information added and sends it to the mq_cls sending queue scheduling module 104; The mq_cls send queue scheduling module 104 selects the send queue to forward the network data packet with added TCP / IP protocol header information to the outgoing interface of the network card through the network card driver 105, for example, the ethernet interface. Among them, the sending queue can be selected in the mq_cls sending queue scheduling module 104 to control the inbound and outbound queues of the network data packets containing TCP / IP protocol header information to achieve network flow control. The flow control of the network flow can be controlled at the exit, including shaping, scheduling, and dropping. The Linux kernel forwards the data packet from the network card to control the flow at the exit. Among them, the so-called shaping, when the traffic is limited, its transmission rate is controlled below a certain value, the limit value can be much smaller than the effective bandwidth, which can smooth out burst data traffic and make the network more stable; the so-called scheduling, through scheduling For data packet transmission, the bandwidth can be allocated according to priority within the bandwidth range; if the so-called dropping exceeds a certain set bandwidth, the data packet is discarded.
所述net_cls cGroup是对数据包进行分类并标记的子系统,net_cls cgroup对数据包的标记可以用作所述网络流类别标识,并且Linux流量控制TC(traffic control)能够识别net_cls cGroup标记后的数据包。The net_clscgroup is a subsystem for classifying and marking data packets. The net_clscgroup marking of data packets can be used as the network flow category identifier, and the Linux flow control TC (traffic control) can recognize the data after net_clscgroup marking package.
图2是本申请其一实施例提供的网络通信的方法处理流程图。FIG. 2 is a processing flowchart of a network communication method provided by an embodiment of the present application.
图2所示的网络通信的方法,包括:步骤S201至S202。The network communication method shown in FIG. 2 includes steps S201 to S202.
步骤S201,在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征。Step S201: Before the data packet to be sent enters the sending queue, classify the data packet according to a network flow classification rule through a filter and set a corresponding network flow class identifier. The network flow classification rule is used to match the feature.
所述网络流分类规则,用于匹配所述数据包的特征;其中,所述数据包的特征包括如下至少之一:IP五元组信息、socket信息。例如,设定特定的IP五元组信息作为网络流分类规则,则匹配到所述特定的IP五元组信息的数据包归 类到一个特定的网络流。The network flow classification rule is used to match the characteristics of the data packet; wherein, the characteristics of the data packet include at least one of the following: IP quintuple information and socket information. For example, if specific IP quintuple information is set as the network flow classification rule, the data packet matching the specific IP quintuple information is classified into a specific network flow.
本步骤是对匹配上所述网络流分类规则的数据包设置相应的网络流类别标识。This step is to set a corresponding network flow category identifier on the data packets matching the network flow classification rules described above.
本申请实施例中,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识。例如,过滤器的网络流分类规则包含的用于匹配数据包的特征的信息为目的IP地址192.168.0.1和目的端口号80,目的IP地址192.168.0.1和目的端口号80的网络流的网络流类别标识为10:1;则过滤器将匹配到目的IP地址192.168.0.1和目的端口号80的数据包过滤出来,并针对匹配上所述网络流分类规则的数据包设置上网络流类别标识10:1。In the embodiment of the present application, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow type identifier is set. For example, the network flow classification rule of the filter contains information used to match the characteristics of the data packet to the network flow of the destination IP address 192.168.0.1 and destination port number 80, and the destination IP address 192.168.0.1 and destination port number 80 The category ID is 10: 1; the filter will filter out the packets matching the destination IP address 192.168.0.1 and the destination port number 80, and set the network flow category ID 10 for the packets matching the network flow classification rules described above :1.
本申请实施例中,所述过滤器,可以是基于Linux流量控制的过滤器;In the embodiment of the present application, the filter may be a filter based on Linux flow control;
相应的,所述通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,包括:Correspondingly, the passing filter classifies the data packet according to the network flow classification rule and sets the corresponding network flow class identifier, including:
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征,按照所述网络流分类规则对所述数据包分类;Classify the data packet according to the network flow classification rules according to the IP header characteristics of the data packet through a filter based on Linux flow control;
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征与网络流分类规则的匹配关系,设置所述数据包的网络类别标识;Through a filter based on Linux flow control, according to the matching relationship between the IP header characteristics of the data packet and the network flow classification rules, the network category identifier of the data packet is set;
所述数据包的IP头部特征至少包括下述任一信息:源IP、目的IP、源socket端口、目的socket端口、协议类型。The IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
其中,所谓协议类型,包括四层协议和/或七层协议,例如UDP、HTTP等。Among them, the so-called protocol types include four-layer protocol and / or seven-layer protocol, such as UDP, HTTP, etc.
本申请实施例中,所述过滤器,可以是Linux cgroup过滤器。所谓cgroup过滤器,是Linux cgroup(Linux control group,或Linux控制组)中的子系统net_cls cgroup提供的过滤器。所谓Linux cgroup,是指Linux内核提供资源管理的各子系统,其中net_cls cgroup是分类并标记数据包的子系统,net_cls cgroup对数据包的标记可以用作所述网络流类别标识,Linux TC能够识别net_cls cgroup子系统中配置的每个具体cgroup过滤器标记后的数据包。例如,建立并配置具体的net_cls cgroup,再通过TC filter命令将具体net_cls cgroup标记的数据包归类到网络流类别标识对应的类别。In the embodiment of the present application, the filter may be a Linux cgroup filter. The so-called cgroup filter is a filter provided by the subsystem net_clscgroup in Linux cgroup (Linux control group, or Linux control group). The so-called Linux cgroup refers to the various subsystems provided by the Linux kernel for resource management, where net_cls cgroup is a subsystem that classifies and marks data packets, and the net_cls cgroup's marking of data packets can be used as the network flow category identification, which Linux can recognize Packets marked by each specific cgroup filter configured in the net_cls cgroup subsystem. For example, create and configure a specific net_cls cgroup, and then use the TC filter command to classify the data packets marked by the specific net_cls cgroup into the corresponding category of the network flow class identifier.
步骤S102,根据所述网络流类别标识,选择发送队列转发所述数据包。Step S102: Select a sending queue to forward the data packet according to the network flow type identifier.
所述发送队列,是关联了排队规则的序号连续的类别队列;其中,所述类别队列,使用主序列号和从序列号进行标识,所述类别队列的主序列号用于关联网络设备;所述排队规则,关联了所述过滤器,使用主序列号和从序列号进 行标识,所述排队规则的主序列号取值于所述类别队列的从序列号。具体的,本申请实施例中,通过Linunx TC中的类(class)利用排队规则管理数据包,向发送队列插入数据包,由于将发送队列分组标识,因此称为类别队列。The sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified using a master serial number and a slave serial number, and the master serial number of the category queue is used to associate network devices; The queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number. The master sequence number of the queuing rule takes a value from the slave sequence number of the category queue. Specifically, in the embodiment of the present application, the data packets are managed by the queuing rules through the class in Linunx TC, and the data packets are inserted into the sending queue. Since the sending queue is grouped, it is called a class queue.
本实施例中的排队规则是有类别的排队规则(即classful queueing discipline),无类别的排队规则是对于数据包采用先入先出的方式通过队列,则除了缓存网络接口一时无法处理的数据包外不对进入队列的数据包进行任何其他处理。所谓有类别的排队规则,包括CBQ、HTB和Prior Qdisc,其中CBQ(class based queueing,或基于类别排队),实现了丰富的连接共享类别结构,既有限制带宽(shaping)能力,也具有带宽优先级管理能力,带宽限制是通过计算连接的空闲时间完成的,空闲时间的计算标准是数据包离队事件的频率和下层连接(数据链路层)的带宽;HTB(hierarchy token bucket,或分层令牌桶),通过TBF(token bucket filter,或令牌桶过滤器)实现带宽限制,允许特定的类别可以突破带宽上限,占用别的类的带宽;Prio Qdisc这类规则,是将属于高优先级的数据包发送完毕后才发送低优先级数据包,即不同优先级的数据包顺序离队。排队规则可以包含一些类别,不同的类别中可以包含更深入的排队规则,通过这些细分的排队规则可以为进入的队列的数据包排队,通过设置各种类别数据包的离队次序,设置网络数据流量的优先级。所谓过滤器(filter),是用于对数据包分类,决定数据包按照何种排队规则进入队列。无论何时数据包进入一个划分子类的类别中,都需要进行分类。使用过滤器分类时,内核调用附属于这个类(class的所有过滤器,直到返回一个判决。如果没有判决返回,就作进一步的处理,而处理方式和排队规则有关。The queuing rules in this embodiment are class queuing rules (ie classful queueing disciplines), and classless queuing rules pass through the queues in a first-in, first-out manner for data packets, except for caching packets that cannot be processed by the network interface No other processing is performed on packets entering the queue. The so-called class queuing rules include CBQ, HTB and Prior Qdisc, in which CBQ (class based queueing, or class based queuing) implements a rich connection sharing class structure, which has both bandwidth limiting and bandwidth priority Level management capability, bandwidth limitation is done by calculating the idle time of the connection. The standard for calculating idle time is the frequency of data packet dequeue events and the bandwidth of the lower layer connection (data link layer); HTB (hierarchy token bucket, or layered order (Bucket), to achieve bandwidth limitation through TBF (token bucket filter, or token bucket filter), allowing certain categories to break through the upper limit of bandwidth and occupy the bandwidth of other categories; rules such as Prio Qdisc will be high priority The low-priority data packets are sent after the data packets are sent, that is, the data packets of different priorities are dequeued in sequence. The queuing rules can contain some categories, and different categories can contain deeper queuing rules. Through these subdivision queuing rules, you can queue packets for the incoming queue, and set the network data by setting the dequeuing order of various types of packets The priority of the traffic. The so-called filter is used to classify data packets and determine the queuing rules for data packets to enter the queue. Whenever a data packet enters a sub-category category, it needs to be classified. When using filter classification, the kernel calls all the filters attached to this class (class until a decision is returned. If no decision is returned, further processing is performed, and the processing method is related to the queuing rules.
具体到本实施例,所述排队规则、类和过滤器都有ID来标识,ID由一个主序列号和一个从序列号组成,两个数字用一个冒号分开。其中,排队规则的主序列号,叫做句柄(handle),采用象“1:”这样的表达方式。从序列号作为类的命名空间。在同一个排队规则里面的类分享该排队规则的主序列号,但是每个类都有自己的从序列号,叫做类识别符(classid)。类识别符只与父排队规则有关,和父类无关。Specifically to this embodiment, the queuing rules, classes, and filters are all identified by an ID. The ID is composed of a master serial number and a slave serial number, and the two numbers are separated by a colon. Among them, the main sequence number of the queuing rule is called a handle, which uses an expression like "1:". Use the serial number as the namespace for the class. Classes in the same queuing rule share the master sequence number of the queuing rule, but each class has its own slave sequence number, called the class identifier (classid). The class identifier is only related to the parent queuing rules, and not to the parent class.
本步骤是根据所述步骤S201设置的网络流类别标识,选择发送队列转发所述网络流类别标识标记的数据包。This step is to select a sending queue to forward the data packet marked by the network flow type identifier according to the network flow type identifier set in step S201.
本申请实施例中,对Linux TC的功能模块进行了扩展,包括下述两个方面:In the embodiment of the present application, the functional modules of Linux TC are expanded to include the following two aspects:
一方面,Linux内核引入发送队列调度模块。通过Linux内核引入的发送队 列调度模块,根据所述排队规则关联的过滤器的网络流类别标识选择发送队列。On the one hand, the Linux kernel introduces a send queue scheduling module. The sending queue scheduling module introduced by the Linux kernel selects the sending queue according to the network flow category identifier of the filter associated with the queuing rule.
另一方面,提供Linux控制流量命令的扩展命令。所述扩展命令,用于将所述网络流类别标识关联到所述排队规则。On the other hand, it provides extended commands for Linux control flow commands. The extended command is used to associate the network flow category identifier with the queuing rule.
本申请实施例中,使用过滤器对应的网络流分类规则对数据包进行匹配处理,过滤器附属于类。转发数据包的网络设备(例如网卡)需要创建根队列排队规则,在根队列排队规则下建立类以及类的子类,每个类只有一个父类,每个类可以有多个子类,这些类组成一个树,称为TC树。数据包与网络流分类规则进行匹配时,根据TC树分层进行匹配,按照每一层的处理逻辑从根直到叶子节点,真正排入真实队列通过网络设备转发数据包。例如,图3所示的发送队列分组示意图中包含的TC树,所述TC树包括:In the embodiment of the present application, the network flow classification rule corresponding to the filter is used to perform matching processing on the data packet, and the filter is attached to the class. Network devices that forward packets (such as network cards) need to create root queue queuing rules, and establish classes and subclasses under the root queue queuing rules. Each class has only one parent class, and each class can have multiple subclasses. These classes Form a tree, called TC tree. When the data packets are matched with the network flow classification rules, they are layered according to the TC tree. According to the processing logic of each layer, from the root to the leaf nodes, they are really queued up to the real queue to forward the data packets through the network device. For example, the TC tree included in the schematic diagram of the transmit queue grouping shown in FIG. 3, the TC tree includes:
根队列排队规则(Root QDISC)301,所述根队列排队规则的主序列号为8001:;Root queue queuing rule (Root QDISC) 301, the main sequence number of the root queue queuing rule is 8001:
所述根队列排队规则301包含两个类class3202和class 303,class 302的类ID是8001:ab51,class 303的类ID是8001:ab52;The root queue queuing rule 301 includes two classes: class3202 and class303, the class ID of class302 is 8001: ab51, and the class ID of class303 is 8001: ab52;
所述class 302的叶子排队规则HTB 304;The leaf queuing rule HTB304 of the class 302;
所述class 303的叶子排队规则HTB 305。The leaf queuing rule HTB305 of the class 303.
本申请实施例的一个具体方式包括:通过Linux控制流量命令的扩展命令将网络流类别标识对应的过滤器关联到排队规则;再通过发送队列调度模块根据排队规则关联的过滤器的网络流类别标识选择发送队列。以下对所述发送队列调度模块的引入以及命令扩展进行说明。A specific method of the embodiment of the present application includes: associating the filter corresponding to the network flow category identifier to the queuing rule through the extended command of the Linux control flow command; and then transmitting the network flow category identifier of the filter associated with the queuing rule through the sending queue scheduling module Select the send queue. The introduction of the sending queue scheduling module and the command expansion are described below.
基于网络流类别标识的队列分配方法需要定义灵活且可重用的接口,通过引入mq_cls发送队列调度模块实现socket类别标识设置,给分类后的数据包使用SO_PRIORITY选项在socket->sk_classid域设置类ID,所述类ID即为网络流类别标识,并支持根据所述类ID实现发送端队列选择。具体的mq_cls模块包括如下内容:The queue allocation method based on network flow class identification needs to define a flexible and reusable interface. The mq_cls send queue scheduling module is used to implement the socket class identification setting. Use the SO_PRIORITY option to set the class ID in the socket-> sk_classid field for the classified data packets The class ID is the network flow class identifier, and supports the selection of the sending end queue according to the class ID. The specific mq_cls module includes the following:
mq_cls支持将某个TC qdisc(queueing discipline)关联到一组连续的发送队列上,所述排队规则的类ID的主序列号(major number)被用来作为mq_cls的class ID(类ID)选择某一组发送队列。扩展Linux现有的TC qdisc命令,增加对于mq_cls发送队列调度模块的配置命令,扩展后的新命令格式为:mq_cls supports associating a TC qdisc (queueing discrimination) to a continuous set of sending queues. The major sequence number of the class ID of the queuing rule is used as the class ID of mq_cls to select a certain A group of send queues. Extend Linux's existing TC qdisc command and add configuration commands for the mq_cls send queue scheduling module. The expanded new command format is:
tc qdisc(add|change|del)dev(dev)root[handle major:]mqcls[numtc tcs][classes class0 class1…][queues count1@offset1 count2@offset2…]tc qdisc (add | change | del) dev (dev) root [handle major:] mqcls [numtc tcs] [classes, class0, class1…] [queues, count1 @ offset1count2 @ offset2…]
其中,各命令参数含义如下:Among them, the meaning of each command parameter is as follows:
qdisc表示队列规则相关命令;qdisc indicates commands related to queue rules;
(add|change|del)增加、修改、删除队列规则的相关命令;(add | change | del) Commands to add, modify and delete queue rules;
dev指定设备的关键字;dev specifies the keywords of the device;
(dev)设备名;(dev) device name;
root操作根队列规则;root operation root queue rules;
[handle major:][队列规则标识队列规则的主序列号:];[handle major:] [queue rule identifies the main sequence number of the queue rule:];
mqcls队列规则标识名;mqcls queue rule identification name;
[numtc tcs]指定mqcls的子类别个数;[numtc tcs] specifies the number of subcategories of mqcls;
[classes class0 class1…]指定mqcls的子类别序号(从序列号)。Class0指的是第一个子类别的序号;[classes class0 class1 ...] Specify the subclass serial number (from serial number) of mqcls. Class0 refers to the serial number of the first subcategory;
[queues count1@offset1 count2@offset2…]指定mqcls的子类别所对应的队列分组,count1指定第一个子类别所对应的队列分组中队列的个数。Offset1指定第一个子类别所对应的队列分组中第一个队列的以0为基准的偏移。[queuescount1 @ offset1count2 @ offset2…] specifies the queue group corresponding to the sub-category of mqcls, and count1 specifies the number of queues in the queue group corresponding to the first sub-category. Offset1 specifies the zero-based offset of the first queue in the queue group corresponding to the first subcategory.
举例如下:沿用图3所示的发送队列分组示意图,说明网络设备eth0的发送队列分组。将TXQ0和TXQ1作为一组发送队列306,将TXQ2和TXQ23作为一组发送队列307;An example is as follows: the transmission queue grouping diagram shown in FIG. 3 is used to explain the transmission queue grouping of the network device eth0. Use TXQ0 and TXQ1 as a group of transmission queues 306, and TXQ2 and TXQ23 as a group of transmission queues 307;
class 302将网络流类别标识为ab51的数据包根据HTB排队规则,插入到发送队列306; class 302 inserts the data packet with the network flow category identification as ab51 into the sending queue 306 according to the HTB queuing rules;
class 303将网络流类别标识为ab52的数据包根据HTB排队规则,插入到发送队列307。The class 303 inserts the data packet with the network flow class identifier of ab52 into the sending queue 307 according to the HTB queuing rules.
将HTB(Hieararchical Token Bucket)qdisc挂载到发送队列TXQ0和TXQ1上配置命令如下:The HTB (Hieararchical Token Bucket) qdisc is mounted on the TXQ0 and TXQ1 configuration queues as follows:
命令1:tc qdisc add dev eth0 root mqcls numtc 1 classes ab51 queues 2@0Command 1: tc qdisc add dev deveth0 root mqcls numtc 1 classes ab51 queues 2 @ 0
命令2:tc qdisc add dev eth0 parent 8001:ab51 handle ab51:0 htbCommand 2: tc qdisc add dev eth0 parent 8001: ab51 handle ab51: 0 htb
通过命令1将网络设备eth0的发送队列TXQ0和TXQ1划分为一个分组,通过命令2将HTB排队规则挂载到这个分组上。The command 1 divides the transmission queues TXQ0 and TXQ1 of the network device eth0 into one packet, and the command 2 mounts the HTB queuing rule to this packet.
将HTB qdisc挂载到发送队列TXQ2至TXQ23的配置命令如下:The configuration commands for mounting HTB qdisc to TXQ2 to TXQ23 are as follows:
命令3:tc qdisc change dev eth0 root mqcls numtc 2 classes ab51 ab52 queues 2@0 22@2Command 3: tc qdisc change dev eth0 root mqcls numtc 2 classes classes ab51 ab52 queues 2 @ 02222 @ 2
命令4:tc qdisc add dev eth0 parent 8001:ab52 handle ab52:0 htbCommand 4: tc qdisc add dev eth0 parent 8001: ab52 handle ab52: 0htb
通过命令3将网络设备eth0的发送队列TXQ2和TXQ23划分为一个分组,通过命令4将HTB排队规则挂载到这个分组上。The command 3 divides the transmission queues TXQ2 and TXQ23 of the network device eth0 into one packet, and the command 4 mounts the HTB queuing rule to this packet.
需要注意的是,本申请实施例中沿用了Linux TC对排队规则句柄(qdisc handle)以及类ID(class ID)取值的规则,关联在发送队列分组上的排队规则必须使用分组对应的类的类句柄的从序列号(minor number)作为其根句柄(root handle)的主序列号(major number)。例如,命令2中的handle参数的值为“ab51:0”,这取决于命令2中的classes参数的值为“ab51”。这样关联到Linux TC的类的cgroup过滤器(根据net_cls cgroup中的class ID来进行分类的过滤器)能够将所述类的类ID作为网络流类别标识对数据包进行分类,并对匹配到所述类的数据包设置标记。It should be noted that in this embodiment of the application, the rules for the value of the queuing rule handle (qdisc) and the class ID (class ID) of Linux TC are used. The queuing rules associated with the sending queue group must use the corresponding class The minor serial number of the class handle is used as the major serial number of its root handle. For example, the value of the handle parameter in Command 2 is "ab51: 0", which depends on the value of the class parameter in Command 2 as "ab51". In this way, the cgroup filter associated with the class of Linux TC (filter classified according to the class ID in net_cls cgroup) can classify the data packet as the network flow class identifier of the class class ID and match all Set the packet of the above-mentioned packet.
本申请实施例中,具体通过下述处理根据所述排队规则关联的过滤器的网络流类别标识选择发送队列,包括:In the embodiment of the present application, the following process specifically selects the sending queue according to the network flow category identifier of the filter associated with the queuing rule, including:
确定所述网络流类别标识对应的排队规则;Determine a queuing rule corresponding to the network flow category identifier;
根据所述排队规则的主序列号,查找所述排队规则的主序列号到所述发送队列号的哈希表,确定发送队列号。According to the main sequence number of the queuing rule, a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
实际实施中,为了实现发送队列的快速查找,在Linux内核中增加的所述排队规则的句柄的主序列号到所述发送队列号的哈希表,通过哈希表快速查找发送队列号。具体的,对netdev_pick_tx()函数进行修改,使得skb的net_cls中的major number被用来选择txq,Linux内核中增加一个从net_cls major number到txq number的哈希表,可以做txq快速查找,从而通过major number选择txq进而选择其对应qdisc。In actual implementation, in order to realize fast search of the sending queue, a hash table of the handle of the queuing rule added to the sending queue number in the Linux kernel is added to the hash table of the sending queue number, and the sending queue number is quickly searched through the hash table. Specifically, the netdev_pick_tx () function is modified so that the major number in skb's net_cls is used to select txq. The Linux kernel adds a hash table from net_cls major number to txq number, which can be used to quickly find txq, so as to pass Major number selects txq and then its corresponding qdisc.
另外,本申请实施例中,在选择发送队列转发所述数据包的处理过程中,还包括下述处理:In addition, in the embodiment of the present application, in the process of selecting the sending queue to forward the data packet, the following process is further included:
根据选择的发送队列所关联的排队规则对应的网络流的优先级,确定所述数据包离队次序,所述排队规则,用于对所述发送队列的数据包排序。各发送队列根据进入队列的数据包的离队次序,依次发送所述数据包。实现了使用网络流的类别标识来确定发送队列,并将网络流控模块关联到多个队列上从而实现了对基于网络类别标识(network class ID)进行流控的支持。According to the priority of the network flow corresponding to the queuing rule associated with the selected sending queue, the dequeuing order of the data packets is determined, and the queuing rule is used to sort the data packets of the sending queue. Each sending queue sends the data packets in sequence according to the dequeuing order of the data packets entering the queue. It implements the use of network flow class identification to determine the sending queue, and associates the network flow control module to multiple queues to achieve flow control support based on network class identification (network class ID).
图4示出了上述网络通信的方法中数据包在发送端的转发处理流向。包括:FIG. 4 shows the flow of forwarding processing of data packets at the sending end in the above network communication method. include:
网络应用401构造数据包;The network application 401 constructs a data packet;
通过网络接口层socket 402将所述数据包发送到传输层/网络层TCP/IP 403;Sending the data packet to the transport layer / network layer TCP / IP 403 through the network interface layer socket 402;
TCP/IP 403对所述数据包添加协议头,例如端口号、IP地址、检验和,将添加协议头的数据包发送到TXQ Selection 404,所述TXQ Selection是发送队列选择模块;TCP / IP 403 adds a protocol header to the data packet, such as a port number, an IP address, and a checksum, and sends the data packet with the added protocol header to TXQ Selection 404, which is a sending queue selection module;
TXQ Selection 404实际部署了mq_cls,用于选择网络设备(例如网卡,或称network interface card,缩写为NIC)的发送队列,将所述数据包发送到Traffic Control 405进行流量控制,图示进行流量控制的排队规则是HTB; TXQ Selection 404 actually deploys mq_cls, which is used to select the transmission queue of network equipment (such as a network card, or network interface card, abbreviated as NIC), and send the data packet to Traffic Control 405 for flow control, and the flow control is shown in the figure The queuing rule is HTB;
经过Traffic Control 405进行流量控制处理的数据包通过网卡驱动(NIC Driver)406入网卡,并到达实际发送队列出网卡(NIC)407。The data packet processed by Traffic Control 405 for flow control processing enters the network card through NIC Driver 406, and arrives at the actual sending queue out NIC 407.
以上述网络通信的方法的实施例为基础,本申请第二实施例提供第二种网络通信的方法。Based on the above embodiment of the network communication method, the second embodiment of the present application provides a second network communication method.
以下结合图5至图7对本申请提供的第二种网络通信的方法的实施例进行说明。其中,图5是本申请提供的所述网络通信的方法实际部署的网络环境示意图;图6是本申请提供的第二种网络通信的方法处理流程图;图7是本申请提供的第二种网络通信的方法中接收端的数据包的转发流向示意图。The second embodiment of the second network communication method provided by the present application will be described below with reference to FIGS. 5 to 7. Among them, FIG. 5 is a schematic diagram of a network environment in which the network communication method provided by the present application is actually deployed; FIG. 6 is a processing flowchart of a second network communication method provided by the present application; FIG. 7 is a second method provided by the present application Schematic diagram of the forwarding flow of the data packet at the receiving end in the network communication method.
由于本实施例是以本申请第一实施例提供的网络通信的方法的实施例为基础,其描述是简要的,相关部分参见本申请第一实施例的描述即可。Since this embodiment is based on the embodiment of the network communication method provided in the first embodiment of the present application, its description is brief, and the relevant part may refer to the description of the first embodiment of the present application.
图6所示的网络通信的方法,包括:步骤S601至步骤S603。The network communication method shown in FIG. 6 includes steps S601 to S603.
步骤S601,按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器。Step S601: Classify the network data packets received by the receiving end according to the network flow classification rules of the filter. The network flow classification rules are used to match the characteristics of the data packet. The filter is associated with the received The filter of the queue rule at the end.
本申请第二实施例提供的网络通信的方法一般部署于网络上传输的数据包的接收端,实现接收端的流量控制。所述接收端,是网络设备,例如,可以是网络接口板(Network Interface Card,或NIC),网络接口板也称为网卡。具体的,接收端从网络侧接收的数据包经过网卡的接收队列之后,被重定向到IFB(Intermediate Functional Block,或中间功能模块)的发送路径,当数据包经过IFB转发时进行流量控制。The network communication method provided in the second embodiment of the present application is generally deployed at the receiving end of a data packet transmitted on the network to achieve flow control at the receiving end. The receiving end is a network device, for example, it may be a network interface card (Network Interface Card, or NIC), and the network interface board is also called a network card. Specifically, after the data packet received by the receiving end from the network side passes through the receiving queue of the network card, it is redirected to the transmission path of the IFB (Intermediate Functional Block, or intermediate function module), and flow control is performed when the data packet is forwarded by the IFB.
所谓IFB,模拟网卡转发数据包,并且提供流量控制功能。由于流量控制模块TC关联到了IFB,因此IFB能够使用TC提供流量控制功能。IFB不改变数据包的传输方向,也就是说,网卡接收队列的数据包重定向到IFB后,经过IFB 的流量控制功能的处理后,又转发回被重定向之前的网卡继续进行接收处理。例如,从一块网卡发送数据包还是从一块网卡接收数据包,重定向到IFB经过流量控制功能的处理之后,通过在IFB的dev_queue_xmit函数中处理转发回被重定向之前的网卡。The so-called IFB simulates network card forwarding data packets and provides flow control functions. Since the flow control module TC is associated with the IFB, the IFB can use the TC to provide flow control functions. IFB does not change the transmission direction of data packets. That is to say, after the data packets of the network card receive queue are redirected to IFB, after being processed by the flow control function of IFB, they are forwarded back to the network card before being redirected to continue the receiving process. For example, whether to send a data packet from a network card or receive a data packet from a network card, redirect to the IFB after the flow control function is processed, and then forward it back to the network card before being redirected by processing in the IFB's dev_queue_xmit function.
本实施例提供的网络通信的方法,目的是通过网络流类别标识来完成接收端的流量控制。为了能够确定到达IFB的数据包的网络流类别标识,因此引入了cls_sk过滤器模块(也叫cls_sk filter)。所述cls_sk过滤器模块,关联到接收端的排队规则,提供cls_sk过滤器,确定接收端接收到的每个数据包的socket端口号,并根据所述数据包的特征设置所述数据包的网络流类别标识。The network communication method provided in this embodiment aims to complete the flow control of the receiving end through the network flow type identification. In order to be able to determine the network flow category identification of the data packets arriving at the IFB, a cls_sk filter module (also called cls_sk filter) is introduced. The cls_sk filter module is associated with the queuing rules of the receiving end, provides a cls_sk filter, determines the socket port number of each data packet received by the receiving end, and sets the network flow of the data packet according to the characteristics of the data packet Category identification.
图5示出了本实施例提供的所述网络通信的方法实际部署的网络环境,包括:数据包入网卡接收队列;FIG. 5 shows a network environment actually deployed by the network communication method provided by this embodiment, including: data packets are put into a network card receiving queue;
所述数据包通过网卡驱动501到达接收端排队规则502,所述接收端排队规则也称为ingress QDISC;The data packet reaches the receiving end queuing rule 502 through the network card driver 501, and the receiving end queuing rule is also called ingress QDISC;
通过接收端排队规则502关联的cls_sk filter 503查询所述数据包的socket端口号,根据所述数据包的特征确定所述数据包对应的网络流类别,并给所述数据包设置对应的网络流类别标识;Query the socket port number of the data packet through the cls_sk filter 503 associated with the receiving end queuing rule 502, determine the network flow type corresponding to the data packet according to the characteristics of the data packet, and set the corresponding network flow to the data packet Category identification
所述cls_sk filter 503将使用网络流类别标识标记的数据包重定向到IFB 504的发送路径,所述IFB 504的发送路径,关联了用于选择发送队列的mq_cls发送队列调度模块;The cls_sk filter 503 redirects the data packet marked with the network flow category identifier to the sending path of the IFB 504, the sending path of the IFB 504 is associated with the mq_cls sending queue scheduling module for selecting the sending queue;
通过IFB 504的发送路径的排队规则,根据所述数据包的网络流类别标识控制所述数据包转发回TCP/IP 505进行网络协议栈的处理,从而达到流量控制的目的,所述TCP/IP是指网络协议栈模块;Through the queuing rules of the sending path of IFB504, according to the network flow type identifier of the data packet, the data packet is controlled to be forwarded back to TCP / IP 505 to process the network protocol stack, so as to achieve the purpose of flow control. The TCP / IP Refers to the network protocol stack module;
TCP/IP 505将处理后的数据包发送到网络应用506进一步处理。TCP / IP 505 sends the processed data packet to network application 506 for further processing.
本步骤是对接收端接收到的网络数据包进行分类。This step is to classify the network data packets received by the receiving end.
本申请实施例中,具体按照过滤器的网络流分类规则对从网络侧接收到的数据包进行分类。具体的,使用cls_sk过滤器查询所述数据包的socket端口号,根据所述数据包的特征确定所述数据包对应的网络流类别。所述网络流分类规则用于匹配所述数据包的特征,具体包含用于匹配数据包头部特征的信息;所述数据包头部特征,至少包括下述任一信息:源IP地址、目的IP地址、数据包接收端对应的socket和协议。所述过滤器是关联到所述接收端的排队规则的过滤器。In the embodiment of the present application, the data packets received from the network side are classified according to the network flow classification rules of the filter. Specifically, the cls_sk filter is used to query the socket port number of the data packet, and the network flow type corresponding to the data packet is determined according to the characteristics of the data packet. The network flow classification rules are used to match the characteristics of the data packet, and specifically include information used to match the characteristics of the packet header; the characteristics of the data packet header include at least any of the following information: source IP address and destination IP address 3. The socket and protocol corresponding to the receiving end of the data packet. The filter is a filter associated with the queuing rule of the receiving end.
步骤S602,基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识。Step S602: Set a network flow category identifier of the data packet based on the matching relationship between the data packet and the network flow classification rule.
本步骤是对数据包设备网络流类别标识。This step is to identify the network flow category of the data packet device.
本申请实施例中,通过使用cls_sk过滤器对所述数据包进行分类后,将匹配上cls_sk过滤器的网络流分类规则的数据包设置网络流类别标识。In the embodiment of the present application, after classifying the data packet by using a cls_sk filter, the data packet matching the network flow classification rule of the cls_sk filter is set with a network flow class identifier.
步骤S603,根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。Step S603: According to the network flow type identifier of the data packet, forward the data packet according to the queuing rule of the receiving end.
本步骤是按照接收端的排队规则将数据包转发到内核的网络协议栈处理,实现接收端的流量控制。In this step, the data packet is forwarded to the network protocol stack of the kernel for processing according to the queuing rule of the receiving end, so as to realize the flow control of the receiving end.
本申请实施例中,具体进行下述操作,实现根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包,包括:In the embodiment of the present application, specifically performing the following operations to realize forwarding the data packet according to the network flow type identifier of the data packet according to the queuing rule of the receiving end includes:
通过所述接收端的排队规则关联的过滤器,将所述数据包重定向到中间功能模块;Redirect the data packet to an intermediate function module through a filter associated with the queuing rule of the receiving end;
根据所述网络流类别标识,选择所述中间功能模块的发送队列,转发所述数据包。According to the network flow type identifier, the sending queue of the intermediate function module is selected to forward the data packet.
具体的,所述中间功能模块是指IFB。例如,通过IFB关联的mq_cls发送队列调度模块,选择IFB的发送队列,并根据IFB的排队规则,例如HTB进行流量控制。Specifically, the intermediate function module refers to IFB. For example, through the mq_cls send queue scheduling module associated with IFB, select the send queue of IFB, and perform flow control according to IFB's queuing rules, such as HTB.
本申请实施例中,还包括:使用接收线程重用技术重用接收端线程上下文。优选的,支持通过开关控制是否使能接收线程重用功能。所述接收线程,是用于处理接收端的数据包的接收的线程。The embodiment of the present application further includes: using the receiving thread reuse technology to reuse the receiving thread context. Preferably, it is supported to control whether to enable the reuse function of the receiving thread through a switch. The receiving thread is a thread for processing reception of a data packet at the receiving end.
一个特定线程的上下文中的内容被其他模块所使用,可以通过内存共享、消息队列等机制实现,也可以直接重用所述特定线程完成其他模块要求的至少部分工作。本申请实施例中,所谓接收线程重用技术,是指将接收线程用于处理除了数据包的接收之外的其他数据包处理工作,从而可以使得接收端的上下文中保存的内容可以直接用于所述其他数据包处理工作。具体的,中间功能模块IFB中重用所述接收线程。例如,直接使用所述接收线程按照所述接收端的排队规则将所述数据包转发到中间功能模块(IFB),而不使用tasklet机制处理,可以避开tasklet可能带来的处理器核竞争。所述中间功能模块,用于接收重定向来的数据包,按照所述排队规则对应的网络流的优先级将所述重定向来的数据包发送回被重定向前的网络设备。当所述重定向来的数据包,是由接收端重 定向来的,中间功能模块对所述重定向来的数据包进行处理后发送回被重定向前的接收端。The content in the context of a specific thread is used by other modules, which can be implemented through mechanisms such as memory sharing and message queues, or it can directly reuse the specific thread to complete at least part of the work required by other modules. In the embodiment of the present application, the so-called receiving thread reuse technology refers to using the receiving thread to process other data packet processing tasks than the reception of the data packet, so that the content saved in the context of the receiving end can be directly used for the Other packet processing work. Specifically, the receiving thread is reused in the intermediate function module IFB. For example, directly using the receiving thread to forward the data packet to an intermediate function module (IFB) according to the queuing rules of the receiving end, without using the tasklet mechanism, can avoid the processor core competition that the tasklet may bring. The intermediate function module is configured to receive the redirected data packet, and send the redirected data packet back to the network device before being redirected according to the priority of the network flow corresponding to the queuing rule. When the redirected data packet is redirected by the receiving end, the intermediate function module processes the redirected data packet and sends it back to the receiving end before being redirected.
另外,接收线程重用,也可以是使用接收线程直接执行网络协议栈,这样可以提高接收端流量控制处理的并发度。In addition, the reuse of the receiving thread can also use the receiving thread to directly execute the network protocol stack, which can improve the concurrency of the flow control processing at the receiving end.
图7示出了接收端的从网络侧接收到数据包后的流向。数据包通过网络设备(网卡)被接收,接收后的数据包经过所述网络通信的方法进行处理,以及处理后的数据包被发送到网络应用进一步使用,这些过程中的数据包流向参见图7,包括:7 shows the flow of the receiving end after receiving the data packet from the network side. The data packet is received through a network device (network card), the received data packet is processed through the network communication method, and the processed data packet is sent to a network application for further use. For the flow of data packets in these processes, see FIG. 7 ,include:
NIC 701是网卡,所述网卡有n+1个接收队列RXQ0,RXQ1,RXQ2,…,RXQn;数据包进入NIC 701的接收队列; NIC 701 is a network card, and the network card has n + 1 receiving queues RXQ0, RXQ1, RXQ2, ..., RXQn; the data packets enter the receiving queue of NIC 701;
数据包通过NIC 701的接收队列到达NIC Driver 702,NIC Driver是网卡驱动;The data packet reaches the NIC Driver 702 through the receiving queue of NIC 701, and the NIC Driver is a network card driver;
数据包由NIC Driver 702到达Ingress QDISC 703,Ingress QDISC是接收端排队规则,也称为接收端流量控制调度器;The data packet arrives at Ingress QDISC 703 by NIC Driver 702. Ingress QDISC is the queuing rule of the receiving end, also known as the receiving end flow control scheduler;
数据包由Ingress QDISC 703到达接收端排队规则关联的cls_sk过滤器,即图中的cls_sk/mirred action 704,cls_sk确定所述数据包的网络流类别并给所述数据包设置网络流类别标识;图示的mirred action是指cls_sk过滤器执行重定向动作,所述数据包将被重定向到中间功能模块IFB 706;The data packet reaches the cls_sk filter associated with the queuing rule of the receiving end by Ingress QDISC 703, that is, cls_sk / mirred action 704 in the figure, and cls_sk determines the network flow type of the data packet and sets the network flow type identifier for the data packet; The mirred action shown refers to the cls_sk filter performing the redirect action, and the data packet will be redirected to the intermediate function module IFB 706;
Traffic Control 705是IFB 706关联的流量控制模块,按照IFB 706关联的流量控制模块选择IFB 706发送路径上的发送队列(见图示的TXQ Selection,发送队列是重用的接收队列,有n个发送队列),并按照IFB 706关联的排队规则(例如图示的HTB)执行流量控制后,由IFB 706发送回重定向前的网卡的接收队列继续进行接收处理,继续进行接收处理包括发送到TCP/IP 707进行网络协议栈处理,图示的TCP/IP表示所述网络协议栈是IP协议栈; Traffic Control 705 is the flow control module associated with IFB 706. According to the flow control module associated with IFB 706, select the transmission queue on the transmission path of IFB 706 (see TXQ Selection in the figure. The transmission queue is a reused reception queue. There are n transmission queues) ), And after performing flow control according to the queuing rules associated with IFB 706 (such as the illustrated HTB), IFB 706 sends back to the receiving queue of the network card before redirection to continue receiving processing, and continuing to receive processing including sending to TCP / IP 707 performs network protocol stack processing, and the illustrated TCP / IP indicates that the network protocol stack is an IP protocol stack;
TCP/IP 707将处理后的数据包通过socket层发送给网络应用708进一步处理或使用。TCP / IP 707 sends the processed data packets to the network application 708 through the socket layer for further processing or use.
与本申请第一实施例提供的一种网络通信的方法的实施例相对应,本申请还提供了第一种网络通信的装置。Corresponding to an embodiment of a network communication method provided by the first embodiment of the present application, the present application also provides a first network communication device.
参照图8,其示出了根据本申请提供的第一种网络通信的装置示意图。由于装置实施例基本相似于方法实施例,所以描述得比较简单,相关的部分请参见 对应的方法实施例的对应说明即可。Referring to FIG. 8, it shows a schematic diagram of a first network communication device according to the present application. Since the device embodiments are basically similar to the method embodiments, the description is relatively simple. For related parts, please refer to the corresponding descriptions of the corresponding method embodiments.
本申请提供第一种网络通信的装置,包括:This application provides the first network communication device, including:
标识单元801,用于在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;The identification unit 801 is used to classify the data packet according to the network flow classification rule and set the corresponding network flow class identification through the filter before the data packet to be sent into the sending queue. The network flow classification rule is used to match the Characteristics of the data packet;
转发单元802,用于根据所述网络流类别标识,选择发送队列转发所述数据包;A forwarding unit 802, configured to select a sending queue to forward the data packet according to the network flow type identifier;
其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
可选的,所述发送队列,是关联了排队规则的序号连续的类别队列;其中,所述类别队列,使用主序列号和从序列号进行标识,所述类别队列的主序列号用于关联网络设备;所述排队规则,关联了所述过滤器,使用主序列号和从序列号进行标识,所述排队规则的主序列号取值于所述类别队列的从序列号。Optionally, the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified by a master serial number and a slave serial number, and the master serial number of the category queue is used for association The network device; the queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number, and the master sequence number of the queuing rule takes a value from the slave sequence number of the category queue.
可选的,所述数据包的特征包括如下至少之一:IP五元组信息、socket信息。Optionally, the characteristics of the data packet include at least one of the following: IP quintuple information and socket information.
可选的,所述过滤器,是基于Linux流量控制的过滤器;Optionally, the filter is a filter based on Linux flow control;
相应的,所述标识单元801,具体用于:Correspondingly, the identification unit 801 is specifically used for:
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征,按照所述网络流分类规则对所述数据包分类;Classify the data packet according to the network flow classification rules according to the IP header characteristics of the data packet through a filter based on Linux flow control;
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征与网络流分类规则的匹配关系,设置所述数据包的网络类别标识;Through a filter based on Linux flow control, according to the matching relationship between the IP header characteristics of the data packet and the network flow classification rules, the network category identifier of the data packet is set;
所述数据包的IP头部特征至少包括下述任一信息:源IP、目的IP、源socket端口、目的socket端口、协议类型。The IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
可选的,所述转发单元802,具体用于:Optionally, the forwarding unit 802 is specifically used to:
通过在Linux内核引入的发送队列调度模块,根据所述排队规则关联的过滤器的网络流类别标识选择发送队列。Through the sending queue scheduling module introduced in the Linux kernel, the sending queue is selected according to the network flow category identifier of the filter associated with the queuing rule.
可选的,所述网络通信的装置,还包括命令单元,用于:Optionally, the network communication device further includes a command unit for:
提供Linux控制流量命令的扩展命令,所述扩展命令用于将所述网络流类别标识关联到所述排队规则。An extended command of a Linux control flow command is provided, and the extended command is used to associate the network flow category identifier with the queuing rule.
可选的,所述转发单元802,具体用于:Optionally, the forwarding unit 802 is specifically used to:
根据数据包的网络流类别标识,确定所述网络流类别标识对应的排队规则;Determine the queuing rule corresponding to the network flow type identifier according to the network flow type identifier of the data packet;
根据所述排队规则的主序列号,查找所述排队规则的主序列号到所述发送队列号的哈希表,确定发送队列号。According to the main sequence number of the queuing rule, a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
可选的,所述网络通信的装置,还包括离队次序确定单元,用于:Optionally, the network communication device further includes a dequeuing order determination unit, which is used to:
根据选择的发送队列关联的排队规则对应的网络流的优先级,确定所述数据包离队次序,所述排队规则,用于对所述发送队列的数据包排序。The dequeuing order of the data packets is determined according to the priority of the network flow corresponding to the queuing rule associated with the selected send queue, and the queuing rule is used to sort the data packets of the send queue.
与本申请提供的第二种网络通信的方法的实施例相对应,本申请还提供了第二种网络通信的装置。Corresponding to the embodiment of the second network communication method provided by this application, this application also provides a second network communication device.
参照图9,其示出了根据本申请提供的第二种网络通信的装置示意图。由于装置实施例基本相似于方法实施例,所以描述得比较简单,相关的部分请参见对应的方法的实施例的对应说明即可。Referring to FIG. 9, it shows a schematic diagram of a second network communication device according to the present application. Since the device embodiments are basically similar to the method embodiments, the description is relatively simple. For related parts, please refer to the corresponding descriptions of the corresponding method embodiments.
本申请提供第二种用网络通信的装置,包括:This application provides a second network communication device, including:
网络流分类单元901,用于按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;The network flow classification unit 901 is used to classify the network data packets received by the receiving end according to the network flow classification rules of the filter. The network flow classification rules are used to match the characteristics of the data packet. The filter is A filter associated with the queuing rule of the receiving end;
标识单元902,用于基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;The identification unit 902 is configured to set the network flow type identification of the data packet based on the matching relationship between the data packet and the network flow classification rule;
转发单元903,用于根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。The forwarding unit 903 is configured to forward the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet.
可选的,所述网络流分类规则,包含用于匹配数据包头部特征的信息;所述数据包头部特征,至少包括下述任一信息:源IP地址、目的IP地址、数据包接收端对应的socket和协议。Optionally, the network flow classification rules include information used to match the characteristics of the packet header; the characteristics of the packet header include at least any of the following information: source IP address, destination IP address, and the corresponding end of the packet receiving end Socket and protocol.
可选的,所述转发单元903,具体用于:Optionally, the forwarding unit 903 is specifically used to:
通过所述接收端的排队规则关联的过滤器,将所述数据包重定向到中间功能模块;Redirect the data packet to an intermediate function module through a filter associated with the queuing rule of the receiving end;
根据所述网络流类别标识,选择所述中间功能模块的发送队列,转发所述数据包。According to the network flow type identifier, the sending queue of the intermediate function module is selected to forward the data packet.
可选的,所述网络通信的装置,还包括接收线程重用单元,用于:Optionally, the network communication device further includes a receiving thread reuse unit, which is used to:
使用接收线程重用技术重用接收端线程上下文。Use the receiving thread reuse technique to reuse the receiving thread context.
可选的,所述接收线程,是用于处理接收端的数据包的接收的线程;相应的,所述接收线程重用单元,具体用于:Optionally, the receiving thread is a thread for processing the receiving of data packets at the receiving end; correspondingly, the receiving thread reuse unit is specifically used for:
直接使用所述接收线程,按照所述接收端的排队规则将所述数据包转发到中间功能模块;所述中间功能模块,用于接收重定向来的数据包,按照所述排队规则对应的网络流的优先级将所述重定向来的数据包发送回被重定向前的网络设备。Directly use the receiving thread to forward the data packet to an intermediate function module according to the queuing rule of the receiving end; the intermediate function module is used to receive the redirected data packet and the network flow corresponding to the queuing rule The priority is sent back to the network device before being redirected.
本申请还提供了一种电子设备的实施例,所述电子设备用于实现本申请第一实施例提供的网络通信的方法,参照图10,其示出了本实施例提供的一种电子设备的示意图。The present application also provides an embodiment of an electronic device for implementing the network communication method provided in the first embodiment of the present application. Referring to FIG. 10, which shows an electronic device provided by the present embodiment Schematic.
本申请提供的所述电子设备实施例描述得比较简单,相关的部分请参见本申请第一实施例的对应说明即可。The embodiment of the electronic device provided in this application is described relatively simply, and for related parts, please refer to the corresponding description in the first embodiment of this application.
本申请提供一种电子设备,包括:This application provides an electronic device, including:
存储器1001,以及处理器1002; Memory 1001, and processor 1002;
所述存储器1001用于存储计算机可执行指令,所述处理器1002用于执行所述计算机可执行指令:The memory 1001 is used to store computer executable instructions, and the processor 1002 is used to execute the computer executable instructions:
在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;
其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
可选的,所述发送队列,是关联了排队规则的序号连续的类别队列;其中,所述类别队列,使用主序列号和从序列号进行标识,所述类别队列的主序列号用于关联网络设备;所述排队规则,关联了所述过滤器,使用主序列号和从序列号进行标识,所述排队规则的主序列号取值于所述类别队列的从序列号。Optionally, the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified by a master serial number and a slave serial number, and the master serial number of the category queue is used for association The network device; the queuing rule is associated with the filter, and is identified by a master sequence number and a slave sequence number, and the master sequence number of the queuing rule takes a value from the slave sequence number of the category queue.
可选的,所述数据包的特征包括如下至少之一:IP五元组信息、socket信息。Optionally, the characteristics of the data packet include at least one of the following: IP quintuple information and socket information.
可选的,所述过滤器,是基于Linux流量控制的过滤器;Optionally, the filter is a filter based on Linux flow control;
相应的,所述处理器1002还用于执行下述计算机可执行指令:Correspondingly, the processor 1002 is also used to execute the following computer executable instructions:
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征,按照所述网络流分类规则对所述数据包分类;Classify the data packet according to the network flow classification rules according to the IP header characteristics of the data packet through a filter based on Linux flow control;
通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征与网络 流分类规则的匹配关系,设置所述数据包的网络类别标识;Through a filter based on Linux flow control, according to the matching relationship between the IP header characteristics of the data packet and the network flow classification rules, the network category identifier of the data packet is set;
所述数据包的IP头部特征至少包括下述任一信息:源IP、目的IP、源socket端口、目的socket端口、协议类型。The IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
可选的,所述处理器1002还用于执行下述计算机可执行指令:Optionally, the processor 1002 is also used to execute the following computer-executable instructions:
通过在Linux内核引入的发送队列调度模块,根据所述排队规则关联的过滤器的网络流类别标识选择发送队列。Through the sending queue scheduling module introduced in the Linux kernel, the sending queue is selected according to the network flow category identifier of the filter associated with the queuing rule.
可选的,所述处理器1002还用于执行下述计算机可执行指令:Optionally, the processor 1002 is also used to execute the following computer-executable instructions:
提供Linux控制流量命令的扩展命令,所述扩展命令,用于将所述网络流类别标识关联到所述排队规则。An extended command of a Linux control flow command is provided, and the extended command is used to associate the network flow category identifier with the queuing rule.
可选的,所述处理器1002还用于执行下述计算机可执行指令:Optionally, the processor 1002 is also used to execute the following computer-executable instructions:
根据数据包的网络流类别标识,确定所述网络流类别标识对应的排队规则;Determine the queuing rule corresponding to the network flow type identifier according to the network flow type identifier of the data packet;
根据所述排队规则的主序列号,查找所述排队规则的主序列号到所述发送队列号的哈希表,确定发送队列号。According to the main sequence number of the queuing rule, a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
可选的,所述处理器1002还用于执行下述计算机可执行指令:Optionally, the processor 1002 is also used to execute the following computer-executable instructions:
根据选择的发送队列关联的排队规则对应的网络流的优先级,确定所述数据包离队次序,所述排队规则,用于对所述发送队列的数据包排序。The dequeuing order of the data packets is determined according to the priority of the network flow corresponding to the queuing rule associated with the selected send queue, and the queuing rule is used to sort the data packets of the send queue.
本申请还提供第二种电子设备的实施例,所述电子设备用于实现本申请第二实施例提供的网络通信的方法,所述电子设备的示意图类似于图10。The present application also provides a second embodiment of an electronic device that is used to implement the network communication method provided by the second embodiment of the present application, and a schematic diagram of the electronic device is similar to FIG. 10.
本申请提供的所述电子设备实施例描述得比较简单,相关的部分请参见本申请第二实施例的对应说明即可。The embodiment of the electronic device provided in this application is described relatively simply, and for related parts, please refer to the corresponding description in the second embodiment of this application.
本申请提供第二种电子设备,包括:This application provides a second type of electronic equipment, including:
存储器,以及处理器;Memory, and processor;
所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions:
按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;
根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述 数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
可选的,所述网络流分类规则,包含用于匹配数据包头部特征的信息;所述数据包头部特征,至少包括下述任一信息:源IP地址、目的IP地址、数据包接收端对应的socket和协议。Optionally, the network flow classification rules include information used to match the characteristics of the packet header; the characteristics of the packet header include at least any of the following information: source IP address, destination IP address, and the corresponding end of the packet receiving end Socket and protocol.
可选的,所述处理器还用于执行下述计算机可执行指令:Optionally, the processor is also used to execute the following computer-executable instructions:
通过所述接收端的排队规则关联的过滤器,将所述数据包重定向到中间功能模块;Redirect the data packet to an intermediate function module through a filter associated with the queuing rule of the receiving end;
根据所述网络流类别标识,选择所述中间功能模块的发送队列,转发所述数据包。According to the network flow type identifier, the sending queue of the intermediate function module is selected to forward the data packet.
可选的,所述处理器还用于执行下述计算机可执行指令:Optionally, the processor is also used to execute the following computer-executable instructions:
使用接收线程重用技术重用接收端线程上下文。Use the receiving thread reuse technique to reuse the receiving thread context.
可选的,所述接收线程,是用于处理接收端的数据包的接收的线程;相应的,所述处理器还用于执行下述计算机可执行指令:Optionally, the receiving thread is a thread for processing the reception of data packets at the receiving end; correspondingly, the processor is also used to execute the following computer-executable instructions:
直接使用所述接收线程,按照所述接收端的排队规则将所述数据包转发到中间功能模块;所述中间功能模块,用于接收重定向来的数据包,按照所述排队规则对应的网络流的优先级将所述重定向来的数据包发送回被重定向前的网络设备。Directly use the receiving thread to forward the data packet to an intermediate function module according to the queuing rule of the receiving end; the intermediate function module is used to receive the redirected data packet and the network flow corresponding to the queuing rule The priority is sent back to the network device before being redirected.
本申请还提供一种存储设备的实施例。The present application also provides an embodiment of a storage device.
本申请提供一种存储设备,包括:存储器和处理器,其中,存储器存储有指令,所述指令能够被处理器加载并执行以下步骤:The present application provides a storage device, including: a memory and a processor, wherein the memory stores instructions, and the instructions can be loaded by the processor and perform the following steps:
在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;
根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;
其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
本申请还提供第二种存储设备的实施例。This application also provides a second embodiment of the storage device.
本申请提供的第二种存储设备,包括:存储器和处理器,其中,存储器存储有指令,所述指令能够被处理器加载并执行以下步骤:The second storage device provided by the present application includes: a memory and a processor, wherein the memory stores instructions, and the instructions can be loaded by the processor and perform the following steps:
按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter
基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;
根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, the computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。The memory may include non-permanent memory, random access memory (RAM) and / or non-volatile memory in computer-readable media, such as read only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
1、计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非暂存电脑可读媒体(transitory media),如调制的数据信号和载波。1. Computer-readable media, including permanent and non-permanent, removable and non-removable media, can implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, read-only compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media can be used to store information that can be accessed by computing devices. As defined in this article, computer-readable media does not include non-transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
2、本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。2. Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented 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.
本申请虽然以较佳实施例公开如上,但其并不是用来限定本申请,任何本领域技术人员在不脱离本申请的精神和范围内,都可以做出可能的变动和修改,因此本申请的保护范围应当以本申请权利要求所界定的范围为准。Although this application is disclosed as above with preferred embodiments, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. The scope of protection shall be subject to the scope defined in the claims of this application.
Claims (20)
- 一种网络通信的方法,其特征在于,包括:A method of network communication, characterized in that it includes:在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- 根据权利要求1所述的方法,其特征在于,所述发送队列,是关联了排队规则的序号连续的类别队列;其中,所述类别队列,使用主序列号和从序列号进行标识,所述类别队列的主序列号用于关联网络设备;所述排队规则,关联了所述过滤器,使用主序列号和从序列号进行标识,所述排队规则的主序列号取值于所述类别队列的从序列号。The method according to claim 1, wherein the sending queue is a serial queue with consecutive serial numbers associated with queuing rules; wherein, the category queue is identified by a master serial number and a slave serial number, and The main serial number of the category queue is used to associate with the network device; the queuing rule is associated with the filter, and is identified by the main sequence number and the slave sequence number. From the serial number.
- 根据权利要求1所述的方法,其特征在于,所述数据包的特征包括如下至少之一:IP五元组信息、socket信息。The method according to claim 1, wherein the characteristics of the data packet include at least one of the following: IP quintuple information and socket information.
- 根据权利要求3所述的方法,其特征在于,所述过滤器,是基于Linux流量控制的过滤器;The method according to claim 3, wherein the filter is a filter based on Linux flow control;相应的,所述通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,包括:Correspondingly, the passing filter classifies the data packet according to the network flow classification rule and sets the corresponding network flow class identifier, including:通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征,按照所述网络流分类规则对所述数据包分类;Classify the data packet according to the network flow classification rules according to the IP header characteristics of the data packet through a filter based on Linux flow control;通过基于Linux流量控制的过滤器,根据所述数据包的IP头部特征与网络流分类规则的匹配关系,设置所述数据包的网络类别标识;Through a filter based on Linux flow control, according to the matching relationship between the IP header characteristics of the data packet and the network flow classification rules, the network category identifier of the data packet is set;所述数据包的IP头部特征至少包括下述任一信息:源IP、目的IP、源socket端口、目的socket端口、协议类型。The IP header characteristic of the data packet includes at least any of the following information: source IP, destination IP, source socket port, destination socket port, and protocol type.
- 根据权利要求2所述的方法,其特征在于,所述根据所述网络流类别标识,选择发送队列转发所述数据包,包括:The method according to claim 2, wherein the selecting a sending queue to forward the data packet according to the network flow type identifier includes:通过在Linux内核引入的发送队列调度模块,根据所述排队规则关联的过滤器的网络流类别标识选择发送队列。Through the sending queue scheduling module introduced in the Linux kernel, the sending queue is selected according to the network flow category identifier of the filter associated with the queuing rule.
- 根据权利要求2所述的方法,其特征在于,还包括:The method of claim 2, further comprising:提供Linux控制流量命令的扩展命令,用于将所述网络流类别标识关联到所 述排队规则。An extended command of the Linux control flow command is provided for associating the network flow category identifier with the queuing rule.
- 根据权利要求5所述的方法,其特征在于,所述根据所述排队规则关联的过滤器的网络流类别标识选择发送队列,包括:The method according to claim 5, wherein the selection of the sending queue according to the network flow category identifier of the filter associated with the queuing rule includes:根据数据包的网络流类别标识,确定所述网络流类别标识对应的排队规则;Determine the queuing rule corresponding to the network flow type identifier according to the network flow type identifier of the data packet;根据所述排队规则的主序列号,查找所述排队规则的主序列号到所述发送队列号的哈希表,确定发送队列号。According to the main sequence number of the queuing rule, a hash table of the main sequence number of the queuing rule to the sending queue number is searched to determine the sending queue number.
- 根据权利要求1所述的方法,其特征在于,还包括:The method according to claim 1, further comprising:根据选择的发送队列关联的排队规则对应的网络流的优先级,确定所述数据包离队次序,所述排队规则,用于对所述发送队列的数据包排序。The dequeuing order of the data packets is determined according to the priority of the network flow corresponding to the queuing rule associated with the selected send queue, and the queuing rule is used to sort the data packets of the send queue.
- 根据权利要求8所述的方法,其特征在于,所述根据所述网络流类别标识,选择发送队列转发所述数据包,包括:The method according to claim 8, wherein the selecting a sending queue to forward the data packet according to the network flow type identifier comprises:各发送队列根据进入队列的数据包的离队次序,依次发送所述数据包。Each sending queue sends the data packets in sequence according to the dequeuing order of the data packets entering the queue.
- 一种网络通信的方法,其特征在于,包括:A method of network communication, characterized in that it includes:按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
- 根据权利要求10所述的方法,其特征在于,所述网络流分类规则,包含用于匹配数据包头部特征的信息;所述数据包头部特征,至少包括下述任一信息:源IP地址、目的IP地址、数据包接收端对应的socket和协议。The method according to claim 10, wherein the network flow classification rule contains information used to match the characteristics of the packet header; the characteristics of the packet header include at least any of the following information: source IP address, Destination IP address, socket and protocol corresponding to the receiving end of the data packet.
- 根据权利要求10所述的方法,其特征在于,所述根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包,包括:The method according to claim 10, wherein the forwarding the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet includes:通过所述接收端的排队规则关联的过滤器,将所述数据包重定向到中间功能模块;Redirect the data packet to an intermediate function module through a filter associated with the queuing rule of the receiving end;根据所述网络流类别标识,选择所述中间功能模块的不同发送队列,转发所述数据包。According to the network flow type identifier, different sending queues of the intermediate function module are selected to forward the data packet.
- 根据权利要求10所述的方法,其特征在于,还包括:The method according to claim 10, further comprising:使用接收线程重用技术重用接收端线程上下文。Use the receiving thread reuse technique to reuse the receiving thread context.
- 根据权利要求13所述的方法,其特征在于,所述接收线程,是用于处理接收端的数据包的接收的线程;相应的,所述使用接收线程重用技术重用接收端线程上下文,包括:The method according to claim 13, wherein the receiving thread is a thread for processing the receiving of the data packet at the receiving end; correspondingly, the reuse of the receiving thread context using the receiving thread reuse technology includes:直接使用所述接收线程,按照所述接收端的排队规则将所述数据包转发到中间功能模块;所述中间功能模块,用于接收重定向来的数据包,按照所述排队规则对应的网络流的优先级将所述重定向来的数据包发送回被重定向前的网络设备。Directly use the receiving thread to forward the data packet to an intermediate function module according to the queuing rule of the receiving end; the intermediate function module is used to receive the redirected data packet and the network flow corresponding to the queuing rule The priority is sent back to the network device before being redirected.
- 一种网络通信的装置,其特征在于,包括:A network communication device, characterized in that it includes:标识单元,用于在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;The identification unit is used to classify the data packets according to the network flow classification rules and set the corresponding network flow class identification through the filter before the data packets to be sent into the sending queue, and the network flow classification rules are used to match the data Characteristics of the package;转发单元,用于根据所述网络流类别标识,选择发送队列转发所述数据包;A forwarding unit, configured to select a sending queue to forward the data packet according to the network flow type identifier;其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- 一种网络通信的装置,其特征在于,包括:A network communication device, characterized in that it includes:网络流分类单元,用于按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;The network flow classification unit is used to classify the network data packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is associated A filter of the queuing rules to the receiving end;标识单元,用于基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;An identification unit, configured to set a network flow type identification of the data packet based on the matching relationship between the data packet and the network flow classification rule;转发单元,用于根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。The forwarding unit is configured to forward the data packet according to the queuing rule of the receiving end according to the network flow type identifier of the data packet.
- 一种电子设备,其特征在于,包括:An electronic device, characterized in that it includes:存储器,以及处理器;Memory, and processor;所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions:在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系 设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- 一种电子设备,其特征在于,包括:An electronic device, characterized in that it includes:存储器,以及处理器;Memory, and processor;所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions:按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
- 一种存储设备,其特征在于,存储有指令,所述指令能够被处理器加载并执行以下步骤:A storage device is characterized by storing instructions, which can be loaded by a processor and perform the following steps:在待发送数据包进入发送队列前,通过过滤器按照网络流分类规则对所述数据包分类并设置相应的网络流类别标识,所述网络流分类规则用于匹配所述数据包的特征;Before the data packet to be sent enters the sending queue, the data packet is classified according to a network flow classification rule through a filter and a corresponding network flow class identifier is set, and the network flow classification rule is used to match the characteristics of the data packet;根据所述网络流类别标识,选择发送队列转发所述数据包;Select a sending queue to forward the data packet according to the network flow category identifier;其中,所述过滤器用于基于所述数据包与所述网络流分类规则的匹配关系设置对应的网络流类别标识。Wherein, the filter is used to set a corresponding network flow category identifier based on the matching relationship between the data packet and the network flow classification rule.
- 一种存储设备,其特征在于,存储有指令,所述指令能够被处理器加载并执行以下步骤:A storage device is characterized by storing instructions, which can be loaded by a processor and perform the following steps:按照过滤器的网络流分类规则,对接收端接收到的网络数据包进行分类,所述网络流分类规则用于匹配所述数据包的特征,所述过滤器是关联到所述接收端的排队规则的过滤器;Classify network packets received by the receiving end according to the network flow classification rules of the filter, the network flow classification rules are used to match the characteristics of the data packet, and the filter is a queuing rule associated with the receiving end Filter基于所述数据包与所述网络流分类规则的匹配关系,设置所述数据包的网络流类别标识;Based on the matching relationship between the data packet and the network flow classification rule, setting the network flow category identifier of the data packet;根据所述数据包的网络流类别标识,按照所述接收端的排队规则转发所述数据包。According to the network flow type identifier of the data packet, the data packet is forwarded according to the queuing rule of the receiving end.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2018/113789 WO2020087523A1 (en) | 2018-11-02 | 2018-11-02 | Network communication method and apparatus, and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
PCT/CN2018/113789 WO2020087523A1 (en) | 2018-11-02 | 2018-11-02 | Network communication method and apparatus, and electronic device |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2020087523A1 true WO2020087523A1 (en) | 2020-05-07 |
Family
ID=70463104
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/113789 WO2020087523A1 (en) | 2018-11-02 | 2018-11-02 | Network communication method and apparatus, and electronic device |
Country Status (1)
Country | Link |
---|---|
WO (1) | WO2020087523A1 (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112019446A (en) * | 2020-08-28 | 2020-12-01 | 北京浪潮数据技术有限公司 | Interface speed limiting method, device, equipment and readable storage medium |
CN112187663A (en) * | 2020-09-17 | 2021-01-05 | 刘小霞 | Data transmission method, device and system based on communication load |
CN113472654A (en) * | 2021-05-31 | 2021-10-01 | 济南浪潮数据技术有限公司 | Network traffic data forwarding method, device, equipment and medium |
CN113641672A (en) * | 2021-07-30 | 2021-11-12 | 武汉思普崚技术有限公司 | Multi-dimensional rapid matching method and device and storage medium |
CN113726611A (en) * | 2021-09-01 | 2021-11-30 | 深圳市大洲智创科技有限公司 | Method for flow control based on protocol |
CN113783797A (en) * | 2021-09-13 | 2021-12-10 | 京东科技信息技术有限公司 | Network flow control method, device, equipment and storage medium of cloud native container |
CN113950033A (en) * | 2020-07-17 | 2022-01-18 | 华为技术有限公司 | Data transmission method and device |
CN117828487A (en) * | 2024-02-23 | 2024-04-05 | 深圳赋乐科技集团有限公司 | Method, system, equipment and medium for judging matching result of flow classification rule |
CN118301085A (en) * | 2024-05-31 | 2024-07-05 | 芯云晟(杭州)电子科技有限公司 | Descriptor-based DPU network card priority scheduling method, device, medium and terminal |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102035748A (en) * | 2010-12-31 | 2011-04-27 | 深圳市深信服电子科技有限公司 | Application-based traffic control method and controller |
CN102238743A (en) * | 2010-05-05 | 2011-11-09 | 联芯科技有限公司 | Multiplex bearer management method and device |
CN106385386A (en) * | 2016-08-31 | 2017-02-08 | 成都飞鱼星科技股份有限公司 | Application servo-actuated intelligent floe control method |
US20170070554A1 (en) * | 2015-09-09 | 2017-03-09 | Vantrix Corporation | Method and system for flow-rate regulation in a content-controlled streaming network |
-
2018
- 2018-11-02 WO PCT/CN2018/113789 patent/WO2020087523A1/en active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102238743A (en) * | 2010-05-05 | 2011-11-09 | 联芯科技有限公司 | Multiplex bearer management method and device |
CN102035748A (en) * | 2010-12-31 | 2011-04-27 | 深圳市深信服电子科技有限公司 | Application-based traffic control method and controller |
US20170070554A1 (en) * | 2015-09-09 | 2017-03-09 | Vantrix Corporation | Method and system for flow-rate regulation in a content-controlled streaming network |
CN106385386A (en) * | 2016-08-31 | 2017-02-08 | 成都飞鱼星科技股份有限公司 | Application servo-actuated intelligent floe control method |
Non-Patent Citations (1)
Title |
---|
ZONG, XI-PENG: "The Research and Implementation of Self Adaptive Traffic Classification Control Technology", CHINESE MASTER’S THESES FULL-TEXT DATABASE, 11 January 2011 (2011-01-11), pages 1 - 90, XP055699137 * |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113950033A (en) * | 2020-07-17 | 2022-01-18 | 华为技术有限公司 | Data transmission method and device |
CN113950033B (en) * | 2020-07-17 | 2023-11-28 | 华为技术有限公司 | Data transmission method and equipment |
CN112019446A (en) * | 2020-08-28 | 2020-12-01 | 北京浪潮数据技术有限公司 | Interface speed limiting method, device, equipment and readable storage medium |
CN112187663A (en) * | 2020-09-17 | 2021-01-05 | 刘小霞 | Data transmission method, device and system based on communication load |
CN113472654A (en) * | 2021-05-31 | 2021-10-01 | 济南浪潮数据技术有限公司 | Network traffic data forwarding method, device, equipment and medium |
CN113641672A (en) * | 2021-07-30 | 2021-11-12 | 武汉思普崚技术有限公司 | Multi-dimensional rapid matching method and device and storage medium |
CN113726611A (en) * | 2021-09-01 | 2021-11-30 | 深圳市大洲智创科技有限公司 | Method for flow control based on protocol |
CN113783797A (en) * | 2021-09-13 | 2021-12-10 | 京东科技信息技术有限公司 | Network flow control method, device, equipment and storage medium of cloud native container |
CN113783797B (en) * | 2021-09-13 | 2023-11-07 | 京东科技信息技术有限公司 | Network flow control method, device and equipment of cloud primary container and storage medium |
CN117828487A (en) * | 2024-02-23 | 2024-04-05 | 深圳赋乐科技集团有限公司 | Method, system, equipment and medium for judging matching result of flow classification rule |
CN118301085A (en) * | 2024-05-31 | 2024-07-05 | 芯云晟(杭州)电子科技有限公司 | Descriptor-based DPU network card priority scheduling method, device, medium and terminal |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020087523A1 (en) | Network communication method and apparatus, and electronic device | |
US11677851B2 (en) | Accelerated network packet processing | |
US10644941B2 (en) | System and method for a software defined protocol network node | |
CN108353029A (en) | For managing the method and system for calculating the data service in network | |
US20150124835A1 (en) | Method and apparatus for scheduling a heterogeneous communication flow | |
US11831550B2 (en) | Fine grain traffic shaping offload for a network interface card | |
CN111522653A (en) | Container-based network function virtualization platform | |
US8284789B2 (en) | Methods and apparatus for providing dynamic data flow queues | |
CN112600684B (en) | Bandwidth management and configuration method of cloud service and related device | |
CN109905329A (en) | The flow queue adaptive management method that task type perceives under a kind of virtualized environment | |
WO2018013443A1 (en) | Multiple core software forwarding | |
WO2021041622A1 (en) | Methods, systems, and devices for classifying layer 4-level data from data queues | |
WO2016150020A1 (en) | Scheduling flow identifier-based packet scheduling method and device | |
Imputato et al. | Design and implementation of the traffic control module in ns-3 | |
US20080080504A1 (en) | System and method for managing flow of a plurality of packets in a lossless communication network | |
CN111970149B (en) | Shared bandwidth implementation method based on hardware firewall QOS | |
US7474662B2 (en) | Systems and methods for rate-limited weighted best effort scheduling | |
US9705698B1 (en) | Apparatus and method for network traffic classification and policy enforcement | |
CN117499258A (en) | Service data network transmission management method and DPU | |
CN115499386B (en) | Data forwarding method, VPP network element equipment and readable storage medium | |
US11108697B2 (en) | Technologies for controlling jitter at network packet egress | |
Susanto et al. | Creek: Inter many-to-many coflows scheduling for datacenter networks | |
KR20240041500A (en) | Apparatus and method for controlling traffic transmission/reception in a network end terminal | |
CN117795926A (en) | Data packet prioritization in multiplexed sessions | |
CN112804166B (en) | Message receiving and sending method, device and storage medium |
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: 18938361 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: 18938361 Country of ref document: EP Kind code of ref document: A1 |