Disclosure of Invention
Therefore, the invention provides a method and a device for determining a network switching destination port and a switch based on the device, so as to solve the problem of cost increase in the prior art when a plurality of data frames applying various network protocols are mixed and forwarded, and further improve the performance of data communication in an SDN network architecture.
According to the design scheme provided by the invention, the method for determining the network switching destination port comprises the following contents:
receiving a data frame to be forwarded, acquiring a network protocol type, a destination address and a source port number of the data frame, and generating a comparison value containing the destination address and the source port number;
obtaining a corresponding hash value through the comparison value, taking the hash value as an address, and reading a forwarding table entry storing the address in a preset forwarding table;
and extracting a learned contrast value and a target port number in a forwarding table item, matching the contrast value with the learned contrast value, if the matching is successful, taking the target port number as a target port for forwarding the data frame to be forwarded, and if the matching is not successful, outputting a matching failure notice.
In the foregoing, according to a comparison value generation rule corresponding to the network protocol type, a comparison value including a destination address and a source port number is generated, and at least a destination address storage corresponding to the network protocol type of an ethernet protocol, a RapidIO protocol, and a fibre channel Fiber channel protocol is preset in the comparison value generation rule.
As described above, the comparison value is calculated using a hash value algorithm to obtain a corresponding hash value.
Preferably, the hash value algorithm is a CRC32 algorithm, or a CRC16 algorithm, or a modulo operation.
In the foregoing, the preset forwarding table includes a plurality of forwarding table entries, and each forwarding table entry at least includes the learned comparison value and the destination port number.
Preferably, the learned comparison value bit width is 49 bits, and the bit width of the destination port number in the forwarding table entry is determined by the number of the destination port.
The network exchange destination port determining device comprises a generating module, a reading module and a matching module, wherein,
the generation module is used for receiving the data frame to be forwarded, acquiring the network protocol type, the destination address and the source port number of the data frame and generating a comparison value containing the destination address and the source port number;
the reading module is used for acquiring a corresponding hash value through the comparison value, taking the hash value as an address and reading a forwarding table item in which the address is stored in a preset forwarding table;
and the matching module is used for extracting the learned comparison value and the target port number in the forwarding table entry, matching the comparison value with the learned comparison value, if the matching is successful, using the target port number as a target port for forwarding the data frame to be forwarded, and if the matching is not successful, outputting a matching failure notice.
In the above apparatus, the generation module generates a comparison value including a destination address and a source port number according to a comparison value generation rule corresponding to the network protocol type, where the comparison value generation rule is a preset content, and at least a destination address storage corresponding to the network protocol type respectively being an ethernet protocol, a RapidIO protocol, and a Fiber channel protocol is preset in the comparison value generation rule.
In the above device, the reading module comprises a plurality of reading sub-modules, each reading sub-module is connected with the generating module and the matching module, each reading sub-module comprises a hash function generating sub-module and a table entry reading sub-module, wherein,
the hash function generation submodule is used for calculating the received comparison value by using a hash value algorithm, acquiring a corresponding hash value and feeding back the corresponding hash value to the table entry reading submodule;
and the table entry reading sub-module is used for reading the forwarding table entry stored with the address in a preset forwarding table according to the received hash value and by taking the hash value as the address.
A switch, comprising the following: a parsing means, a port determining means and a switching means, wherein,
the analysis device is used for sending the data frame to be forwarded obtained by analysis to the port determination device;
the port determining device is used for extracting a destination port number according to the received data frame and sending the destination port number to the switching device;
the switching device is used for forwarding the received data frame to be forwarded by the network according to the destination port number;
the port determining device is realized by adopting the network switching destination port determining device.
The invention has the beneficial effects that:
in the network data forwarding process, the invention outputs the target port number by comparing the value generation, the matching and the table item determination, relieves the problem of cost increase when a plurality of data frames applying a plurality of network protocols are mixed and forwarded in the prior art, can simultaneously support the forwarding table look-up process of a plurality of data frames applying a plurality of network protocols, and further determines the target port number for forwarding the data frame to be forwarded, the target port determination device can be applied to the nodes of the existing network structure, does not need to change the existing whole network structure, avoids the problem of cost increase when a plurality of data frames applying a plurality of network protocols are mixed and forwarded due to the change of the existing network structure, achieves the technical effect of reducing the cost when a plurality of data frames applying a plurality of network protocols are mixed and forwarded, and improves the data communication performance in an SDN network architecture, the method has important guiding significance for SDN network architecture technology and development.
The specific implementation mode is as follows:
in order to make the objects, technical solutions and advantages of the present invention clearer and more obvious, the present invention is further described in detail below with reference to the accompanying drawings and technical solutions.
At present, a forwarding table is one of core components frequently used by a two-layer network switching chip, and the design of the forwarding table is only directed at a certain network protocol or a certain application scenario, for example, a mac forwarding table is only suitable for forwarding of an ethernet two-layer, and forwarding of other protocol frames cannot be realized. The SDN network may separate the control function and the forwarding function of the network device, so that the control function is all centralized on a remote controller, and the network device is only responsible for forwarding data. As shown in fig. 1, the SDN network architecture includes one controller and three network devices for illustration. In fig. 1, the SDN network structure includes: a controller 14 and three network devices, which are respectively: network device 11, network device 12, and network device 13. The network device 11, the network device 12, and the network device 13 communicate with each other. The controller 14 remotely controls the network device 11, the network device 12, and the network device 13, respectively. Network device 11, network device 12, and network device 13 are responsible only for forwarding of data. For example, the controller 14 may control the network device 11 to support an ethernet network protocol, may also control the network device 11 to support a RapidIO protocol, and may also control the network device 11 to support a Fiber channel protocol. Therefore, forwarding of hybrid network protocol data frames can be achieved by using the SDN switch. However, in view of the problem that the cost is increased when multiple data frames applying multiple network protocols are mixed and forwarded due to the fact that an existing network structure needs to be changed when an SDN network is applied, an embodiment of the present invention, as shown in fig. 2, provides a method for determining a port of a network switch destination, which includes the following contents:
s101, receiving a data frame to be forwarded, acquiring a network protocol type, a destination address and a source port number of the data frame, and generating a comparison value containing the destination address and the source port number;
s102, obtaining a corresponding hash value through the comparison value, taking the hash value as an address, and reading a forwarding table entry storing the address in a preset forwarding table;
s103, extracting a learned contrast value and a target port number in a forwarding table entry, matching the contrast value with the learned contrast value, if the matching is successful, taking the target port number as a target port for forwarding the data frame to be forwarded, and if the matching is not successful, outputting a matching failure notice.
Aiming at the mixed forwarding of a plurality of data frames applying various network protocols in an SDN network architecture, the target port number is output through contrast value generation, matching and table item determination, the technical problem of cost increase in the prior art when the plurality of data frames applying various network protocols are mixed and forwarded can be effectively solved, and the technical effect of reducing the cost in the mixed forwarding of the plurality of data frames applying various network protocols is achieved.
In another embodiment of the present invention, a comparison value including a destination address and a source port number is generated according to a comparison value generation rule corresponding to the network protocol type, and at least a destination address storage corresponding to the network protocol type of the ethernet protocol, the RapidIO protocol, and the fibre channel Fiber protocol is preset in the comparison value generation rule. And if the network protocol type is the Ethernet protocol, the destination address is the destination MAC address. And if the network protocol type is a RapidIO protocol, the destination address is a RapidIO destination ID address. And if the network protocol type is the Fiber channel protocol, the destination address is the Fiber channel destination ID address. Illustratively, the bit width of the comparison value may be 49 bits, and by presetting a plurality of comparison value generation rules, the plurality of comparison value generation rules may be as shown in table 1.
TABLE 1
As can be seen from table 1, if the network protocol type is ethernet protocol, bits 1 to 48 of the comparison value can be used to store the destination address, and bit 49 of the comparison value can be used to store the number 0; if the network protocol type is RapidIO protocol, bits 1 to 16 of the comparison value may be used to store the destination address, bits 17 to 32 of the comparison value may each be used to store a number 0, bits 33 to 47 of the comparison value may be used to store the source port number, bits 48 of the comparison value may be used to store a number 0, and bits 49 of the comparison value may be used to store a number 1; if the network protocol type is the Fiber channel protocol, bits 1 to 32 of the comparison value may be used to store the destination address, bits 33 to 47 of the comparison value may be used to store the source port number, bit 48 of the comparison value may be used to store the number 1, and bit 49 of the comparison value may be used to store the number 1.
For the generated comparison value, in another embodiment of the present invention, the comparison value is calculated by a hash value algorithm to obtain a corresponding hash value. And processing the comparison value by using a preset hash value algorithm to obtain a hash value. Preferably, the hash value algorithm may be the CRC32 algorithm or the CRC16 algorithm, or other methods of calculating hash values, such as: and (5) performing remainder operation.
Further, in the embodiment of the present invention, the preset forwarding table may include a plurality of forwarding table entries, where each forwarding table entry includes at least a learned comparison value and a destination port number. Preferably, the learned comparison value bit width is 49 bits, and the bit width of the destination port number in the forwarding table entry is determined by the number of the destination port. Illustratively, if the number of destination ports is greater than 2N-1And is less than or equal to 2NAnd if N is a positive integer, the bit width of the destination port number in the forwarding table entry is N bits. For example, if the number of destination ports is 15, 2 can be obtained3<15<24Therefore, the bit width of the destination port number in the forwarding table entry is 4 bits. Thus, the bit width of the forwarding entry is 53 bits (bit width of the learned comparison value plus the bit width of the destination port number).
Based on the port determination method, an embodiment of the present invention further provides a device for determining a port of a network switch destination, as shown in fig. 3, which includes a generating module 101, a reading module 102, and a matching module 103, wherein,
a generating module 101, configured to receive a data frame to be forwarded, obtain a network protocol type, a destination address, and a source port number of the data frame, and generate a comparison value including the destination address and the source port number;
the reading module 102 is configured to obtain a corresponding hash value through the comparison value, and read a forwarding table entry storing the address in a preset forwarding table by using the hash value as the address;
a matching module 103, configured to extract a learned comparison value and a target port number in a forwarding entry, match the comparison value with the learned comparison value, if matching is successful, use the target port number as a target port for forwarding the data frame to be forwarded, and if not matching is successful, output a matching failure notification.
The port determination device is applied to the nodes of the network structure by redefining the contents of the forwarding table entries, the forwarding table look-up process of a plurality of data frames applying various network protocols can be realized without changing the existing whole network structure, and the method has the advantages of strong universality, easiness in transplanting, easiness in realizing and light weight. Meanwhile, the existing whole network structure is prevented from being changed, so that the deployment is very convenient, and the time cost and the labor cost are saved.
Further, in the above apparatus, in the generating module 101, a comparison value including a destination address and a source port number is generated according to a comparison value generating rule corresponding to the network protocol type, where the comparison value generating rule is a preset content, and at least destination address storages corresponding to network protocol types, respectively, an ethernet protocol, a RapidIO protocol, and a Fiber channel protocol are preset in the comparison value generating rule.
Further, as shown in fig. 4, the reading module 102 includes a plurality of reading sub-modules, such as 23, 24, and 25 in the figure, each of which is connected to the generating module 21 and the matching module 22, and each of which includes a hash function generating sub-module (such as 31, 33, 35 in the figure) and an entry reading sub-module (such as 32, 34, 36 in the figure), wherein,
the hash function generation submodule is used for calculating the received comparison value by using a hash value algorithm, acquiring a corresponding hash value and feeding back the corresponding hash value to the table entry reading submodule;
and the table entry reading sub-module is used for reading the forwarding table entry stored with the address in a preset forwarding table according to the received hash value and by taking the hash value as the address.
In the embodiment of the port determination device, the generation module is configured to receive an a network protocol type, a destination address, and a source port number of a data frame to be forwarded, and generate a comparison value including the destination address and the source port number according to a comparison value generation rule corresponding to the a network protocol type; and meanwhile, the device is also used for receiving the type of the B network protocol, the destination address and the source port number of the data frame to be forwarded, and generating a comparison value containing the destination address and the source port number according to a comparison value generation rule corresponding to the type of the B network protocol. The method and the device realize the forwarding table look-up process of simultaneously supporting a plurality of data frames applying a plurality of network protocols, and further determine the destination port number for forwarding the data frame to be forwarded, and the destination port determining device can be applied to the nodes of the existing network structure without changing the existing whole network structure, so the problem of cost increase caused by changing the existing network structure when a plurality of data frames applying a plurality of network protocols are mixed and forwarded is avoided, therefore, the technical problem of cost increase caused by the fact that the plurality of data frames applying a plurality of network protocols are mixed and forwarded in the prior art is relieved, and the technical effect of reducing the cost when a plurality of data frames applying a plurality of network protocols are mixed and forwarded is achieved. Further, referring to fig. 5, it is described that the port determination apparatus includes three reading modules, i.e., table entry determination units in the figure, and the comparison value generation module 21, the matching module 22 and three table entry determination units; the three table entry determination units are respectively: an entry determination unit 23, an entry determination unit 24, and an entry determination unit 26. The entry determination unit 23 may include: a hash function generation submodule 31 and a reading submodule 32. The entry determination unit 24 may include: a hash function generation submodule 33 and a reading submodule 34. The entry determination unit 26 may include: a hash function generation submodule 37 and a reading submodule 38.
Based on the above port determination apparatus, the present invention further provides a switch, as shown in fig. 6, including the following: parsing means 41, port determination means 42 and switching means 43, wherein,
the analyzing device 41 is configured to send the data frame to be forwarded obtained through analysis to the port determining device;
port determining means 42 for extracting a destination port number according to the received data frame and sending the destination port number to the switching means;
a switching device 43, configured to perform network forwarding on the received data frame to be forwarded according to the destination port number;
the port determining device 41 is implemented by using the port determining device for network switching destination in the above embodiment, thereby fulfilling the mixed forwarding requirement of multiple data frames of multiple network protocols in the SDN network architecture, reducing the deployment cost of the SDN network, being easy to implement, having strong versatility and easy to transplant, avoiding the overall change of the existing network structure, and saving labor and time costs.
Unless specifically stated otherwise, the relative steps, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
The device provided by the embodiment of the present invention has the same implementation principle and technical effect as the method embodiments, and for the sake of brief description, reference may be made to the corresponding contents in the method embodiments without reference to the device embodiments.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In all examples shown and described herein, any particular value should be construed as merely exemplary, and not as a limitation, and thus other examples of example embodiments may have different values.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, in the description of the embodiments of the present invention, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.