Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Cloud technology (Cloud technology) refers to a hosting technology for integrating hardware, software, network and other series resources in a wide area network or a local area network to realize calculation, storage, processing and sharing of data. Cloud technology (Cloud technology) is based on the general terms of network technology, information technology, integration technology, management platform technology, application technology and the like applied by Cloud computing business models, and can form a resource pool, so that the Cloud computing business model is flexible and convenient as required. Cloud computing technology will become an important support. Background services of technical networking systems require a large amount of computing, storage resources, such as video websites, picture-like websites, and more portals. Along with the high development and application of the internet industry, each article possibly has an own identification mark in the future, the identification mark needs to be transmitted to a background system for logic processing, data with different levels can be processed separately, and various industry data needs strong system rear shield support and can be realized only through cloud computing.
The embodiment of the application relates to cloud technology, for example, test codes to be verified are used for being integrated on a chip applied to a cloud technology scene.
The code verification method provided by the embodiment of the application can be applied to an application environment shown in figure 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on the cloud or other servers. The terminal 102 may be, but not limited to, various desktop computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligence platforms, and the like. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the present application is not limited herein.
In particular, a developer may write test code to be verified on the terminal 102. In order to verify the test code, a verification environment comprising a global configuration component, a component to be verified and a result comparison component can be built on the terminal 102, and a verification environment comprising a global configuration component, a component to be verified and a result comparison component can also be built on the server 104.
In the verification environment, the functions of the components to be verified are realized through the test codes to be verified. And receiving a configuration message aiming at the flow table information through the component to be verified, and analyzing the configuration message to obtain first flow table information, wherein the configuration message is obtained by packaging global flow table information configured through the global configuration component. And receiving the network message through the component to be verified, and processing the network message based on the first flow table information to obtain a first processing result. And sending the first processing result to a result comparison component through the component to be verified. And receiving a second processing result by the result comparison component, and comparing the first processing result with the second processing result to obtain a verification result corresponding to the test code, wherein the second processing result is obtained by processing the network message based on the global flow table information configured by the global configuration component.
In one embodiment, as shown in fig. 2, a code verification method is provided, and is applied to a computer device, which may be a terminal or a server, for illustration. It will be appreciated that the method may be performed by the terminal or the server itself, or may be implemented by interaction between the terminal and the server. Referring to fig. 2, the code verification method includes the steps of:
step S202, receiving configuration messages aiming at flow chart information through a component to be verified, and analyzing the configuration messages to obtain first flow chart information; the configuration message is obtained by packaging global flow table information configured by the global configuration component, and the function of the component to be verified is realized by the test code to be verified.
The component to be verified is formed based on the test code to be verified, and the function of the component to be verified is realized through the test code to be verified. For example, the test code to be verified is taken as the component to be verified.
And verifying the correctness of the test code based on the verification platform. The verification platform includes a global configuration component. The global configuration component is used to configure flow table information required to authenticate components on the platform. Network messages passing through the same network for the same period of time and having some common characteristics or attributes are combined into a stream. For example, a collection of network messages that start from the same source IP and access the same destination IP for the same period of time may be considered a single stream. The flow table information is information describing a flow table. The flow table is a set of policy entries for a specific flow, responsible for searching and forwarding data. The flow table records rules for forwarding packets (i.e., network packets). The flow table is composed of at least one flow table item, and each flow table item is a data packet forwarding rule. The flow entry includes matching domain information and corresponding operation domain information, which may also be referred to as action domain information or instruction domain information. The matching field information is used for matching with the data packet, and the matching field information is used for indicating which data packet is matched with the flow table item. For example, the matching domain information includes related information of a link layer, a network layer and a transmission layer related to the matched message; the matching domain information comprises five-tuple information of the matched message; the matching domain information comprises the source IP, the destination IP and the direction of the message of the matched message; etc. The operation domain information is used for processing the data packet, and the operation domain information is used for indicating the next operation to be performed on the data packet matched with the matching domain information. For example, the operation domain in the flow table item comprises two types of information, wherein the first type is used for jumping the matched message to the next flow table item to realize further processing, and corresponding message data can be transferred at the same time; the second is for implementing forwarding of the message.
The flow table information configured by the global configuration component is global flow table information. Other components in the verification platform may use the global flow table information configured by the global configuration component.
In one embodiment, information in the global configuration component may be passed to other components on the verification platform by way of handle passing. In this way, other components can use information in the global configuration component and modify information in the global configuration component, and after one component modifies related information, other components can also use newly modified information for processing later.
The configuration message is a message of configuration data. And packaging the global flow table information configured by the global configuration component to obtain a configuration message. The configuration message is used for transmitting the flow table information to the component to be verified. After receiving the configuration message, the component to be verified can analyze the configuration message so as to obtain the related flow table information.
And the component to be verified analyzes the received configuration message to obtain first flow table information. It will be appreciated that the first flow table information and the global flow table information may be the same or may be different. The analysis of the configuration message is realized through the test code to be verified, and if the test code is abnormal, the first flow table information obtained by analyzing the configuration message and the global flow table information in the global configuration component may be different.
Specifically, in order to verify the correctness of the test code, a verification platform is built to verify the test code. In a global configuration component that belongs to an environment component in the verification platform, global flow table information is configured. And packaging the global flow table information to obtain a configuration message for the flow table information, and sending the configuration message to the component to be verified. The method comprises the steps that a to-be-verified component belonging to a verification object in a verification platform receives a configuration message, analyzes the configuration message to obtain first flow table information, stores the first flow table information, and processes network messages based on the first flow table information by a subsequent to-be-verified component.
In one embodiment, the configuration message may be generated by a global configuration component. And packaging the global flow table information through a global configuration component to obtain a configuration message. The environment components in the verification platform further comprise an excitation component for applying various excitations to the component to be verified to trigger the component to be verified to process the received excitations according to the test code. The method comprises the steps of generating a configuration message through a global configuration component, sending the configuration message to an excitation component, and sending the configuration message to a component to be verified through the excitation component so as to trigger the component to be verified to analyze the configuration message.
In one embodiment, the configuration message may also be generated by the incentive component. The global flow table information is sent to the excitation component through the global configuration component, the global flow table information is packaged through the excitation component to obtain a configuration message, and the configuration message is sent to the component to be verified through the excitation component to trigger the component to be verified to analyze the configuration message.
It will be appreciated that if a configuration message is generated by the excitation component, then the excitation component needs to be configured with the relevant configuration information for generating the configuration message. If the global configuration component generates a configuration message, the incentive component need not configure the relevant configuration information for generating the configuration message. In this way, the global configuration component is used for uniformly managing various configuration information, so that the global configuration component is convenient to integrate to other verification environments for use. It will be appreciated that other test environments have their own stimulus components.
In one embodiment, the global flow table information is obtained by generating flow information through the global configuration component and generating flow table information based on the flow information. Further, to improve verification efficiency, the global configuration component may randomly generate flow information according to a flow information format, and randomly generate flow table information according to a flow table information format based on the flow information.
Step S204, through the component to be verified, the network message is received, and the network message is processed based on the first flow table information, so that a first processing result is obtained.
Wherein, the network message is a message for exchanging and transmitting data in the network.
Specifically, the test code to be verified is used for analyzing the configuration message, processing the network message and forwarding the network message. And receiving the network message, and processing the network message based on the first flow table information to obtain a first processing result. Inquiring a flow table item matched with the network message from the first flow table information, and processing the network message based on the inquired flow table item to obtain a first processing result. It may be appreciated that if no flow table entry matching the network packet is queried in the first flow table information, the preset processing result may be used as the first processing result.
In one embodiment, after the configuration message is parsed to obtain the first flow table information, the first flow table information is written into a preset storage space through the component to be verified, and each flow table item in the first flow table information is written into a corresponding storage unit in the preset storage space. And the component to be verified queries the flow table item matched with the network message from the preset storage space. For example, a storage address may be calculated based on the matching field information in the flow entry, and the flow entry may be written into a storage unit corresponding to the storage address.
In one embodiment, the network messages are valid network messages and invalid network messages, respectively. The valid network message is a network message that is expected to be processable, and the invalid network message is a network message that is not expected to be processable. For example, the valid network message is a network message in which the global configuration component can query the matched flow table entry, and the invalid network message is a network message in which the global configuration component cannot query the corresponding flow table entry.
Step S206, the first processing result is sent to the result comparison component through the component to be verified, so that the result comparison component compares the first processing result with the second processing result to obtain a verification result corresponding to the test code; the second processing result is obtained by processing the network message based on the global flow table information configured by the global configuration component.
Wherein the environment component in the verification platform further comprises a result comparison component. The result comparison component is used for comparing the first processing result output by the component to be verified with the second processing result serving as a reference to verify the correctness of the test code. And processing the network message based on the global flow table information configured by the global configuration component to obtain a second processing result. It can be understood that the first processing result is a processing result output by the component to be verified for the network message. The second processing result is a processing result for the same network message for reference, and the second processing result can be considered as an expected processing result.
Specifically, a result comparison component, which belongs to an environment component in the verification platform, is used to verify whether the first processing result is correct. The to-be-verified component sends the output first processing result to the result comparison component, the result comparison component obtains a second processing result serving as a standard, the result comparison component compares the first processing result with the second processing result, and a verification result corresponding to the test code is determined according to the comparison result. For example, if the first processing result and the second processing result are consistent, the test code is determined to pass verification, and if the first processing result and the second processing result are inconsistent, the test code is determined to not pass verification. For another example, the result comparing component collects respective processing result sets of the plurality of network messages, the processing result set corresponding to the same network message includes a first processing result and a second processing result, and each processing result set is divided into a first category indicating coincidence and a second category indicating non-coincidence according to whether the first processing result and the second processing result in the processing result set are coincidence, if the number ratio of the processing result sets belonging to the first category exceeds a preset proportion, it is determined that the test code passes the verification, otherwise, it is determined that the test code does not pass the verification.
In one embodiment, the environment components in the verification platform further comprise a reference component. The reference component represents a reference model corresponding to the intended function of the component to be verified. The processing result output by the reference component for the network message may be taken as a second processing result. The excitation component can also send the network message sent to the component to be verified to the reference component, the reference component acquires the flow table information matched with the network message from the global flow table information in the global configuration component, and the reference component processes the network message based on the acquired flow table information to obtain a second processing result. It can be understood that if the flow table information matched with the network packet is not queried in the global flow table information, the preset processing result may be used as the second processing result.
In the code verification method, a configuration message aiming at the flow chart information is received through a component to be verified, and the configuration message is analyzed to obtain first flow chart information; the configuration message is obtained by packaging global flow table information configured by a global configuration component, and the function of the component to be verified is realized by a test code to be verified; receiving a network message through a component to be verified, and processing the network message based on first flow table information to obtain a first processing result; the first processing result is sent to the result comparison component through the component to be verified, so that the result comparison component compares the first processing result with the second processing result to obtain a verification result corresponding to the test code; the second processing result is obtained by processing the network message based on the global flow table information configured by the global configuration component. In this way, globally visible and globally available flow table information is uniformly configured in the global configuration component, other components do not need to independently maintain flow table configuration, the other components only need to use the global flow table information in the global configuration component, codes of the global configuration component and the other components are isolated, the environment architecture is clear, repeated codes are reduced, and the overall complexity is effectively reduced.
In one embodiment, the code verification method further comprises:
generating stream information randomly based on preset stream configuration information through a global configuration component to obtain at least one target stream information; and generating target flow table information corresponding to each target flow information respectively based on preset flow table configuration information through a global configuration component, forming the global flow table information by each target flow table information, and packaging the global flow table information to obtain a configuration message.
Wherein the stream information is information describing a stream. The stream configuration information is preset configuration information related to the stream information. The stream configuration information is configuration information required to generate stream information. For example, the stream configuration information includes a stream information format for determining stream elements constituting the stream information. For another example, the stream configuration information may further include a random constraint for determining a range of values of stream elements constituting the stream information. For another example, the flow configuration information may further include a flow number for determining the generation number of flows.
The flow table configuration information is preset configuration information related to the flow table information. The flow table configuration information is configuration information required to generate the flow table information. For example, the flow table configuration information includes a flow table information format for determining a data structure of flow table entries constituting the flow table information, i.e., the flow table information format for determining flow table entry elements constituting the flow table entries. For another example, the flow table configuration information may further include a random constraint for determining a range of values of the flow table entry elements.
Specifically, the configuration message is generated by a global configuration component. The global configuration component generates stream information randomly, then generates stream table information corresponding to the stream information randomly, and packages and encapsulates each generated stream table information to obtain configuration messages.
Firstly, the global configuration component randomly generates stream information based on preset stream configuration information to obtain at least one target stream information. For example, each stream element constituting the stream information is determined based on the stream information format included in the stream configuration information, the value of each stream element constituting the stream information is determined at random, and each stream element determined by the value is combined to obtain the target stream information. For another example, each stream element constituting the stream information is determined based on the stream information format included in the stream configuration information, the value range of each stream element is determined based on the random constraint included in the stream configuration information, the value of each stream element is randomly determined within the value range of each stream element, and each stream element determined by the content is combined to obtain the target stream information. Then, the global configuration component generates target flow table information corresponding to each target flow information based on the preset flow table configuration information. For example, each flow table item composing the flow table information and each flow table item element composing the flow table item are determined based on the flow table information format contained in the flow table configuration information, the value of the flow element matched with the flow table item element is obtained from the target flow information as the value of the corresponding flow table item element for any flow table item, the values of other flow table item elements are randomly generated, each flow table item element composing the flow table item of the content determination is finally combined to obtain the target flow table information corresponding to the target flow information. The global configuration component forms the target flow table information into global flow table information, and encapsulates the global flow table information to obtain configuration messages for the flow table information.
In the above embodiment, the global configuration component is configured with the flow configuration information for generating the flow information and the flow table configuration information for generating the flow table information, and based on these configuration information, the canonical flow information and the flow table information can be quickly generated. The global configuration component generates stream information based on the stream configuration information, generates stream table information corresponding to the stream information based on the stream table configuration information, and finally packages each stream table information to obtain configuration messages, so that basic stream information is generated first, stream table information related to the stream information is regenerated, and finally packages the stream table information to quickly obtain the configuration messages.
In one embodiment, the global configuration component generates stream information randomly based on preset stream configuration information to obtain at least one target stream information, including:
randomly generating at least one initial stream information in a random constraint contained in preset stream configuration information through a global configuration component according to a stream information format contained in the preset stream configuration information; and filtering each piece of initial stream information based on a first stream field preset for the stream information to obtain at least one piece of target stream information.
The preset stream configuration information comprises a stream information format and random constraints. The stream information format is used to determine stream elements that make up the stream information. For example, the flow information format indicates that the flow elements constituting the flow information include elements such as a network message source IP (sip), a network message destination IP (dip), a direction from which the network message comes (dir), a port number, a protocol number, and the like. The random constraint is used for determining a value range corresponding to the stream element.
The preset first stream field is a stream field preset for judging whether different stream information is repeated. The stream field is the stream element.
Specifically, when generating the target stream information through the global configuration component, the stream information is randomly generated, the randomly generated stream information is used as initial stream information, the initial stream information is filtered, and the filtered initial stream information is used as the target stream information.
First, the global configuration component randomly generates at least one initial stream information according to a stream information format contained in the preset stream configuration information within a random constraint contained in the preset stream configuration information. Each stream element composing the stream information is determined based on the stream information format contained in the stream configuration information, the value range of each stream element is determined based on the random constraint contained in the stream configuration information, the value of each stream element is randomly determined in the value range of each stream element, and each stream element determined by the content is combined to obtain the initial stream information. For example, the stream elements constituting the stream information include sip, dip, dir, where sip1 is randomly generated in the value range of sip, dip1 is randomly generated in the value range of dip, dip1 is formed into the initial stream information a, dip2 is randomly generated in the value range of sip, dip2 is randomly generated in the value range of dip, and dip2, dip2 are formed into the initial stream information b. Then, the global configuration component compares the initial stream information based on the first stream field preset for the stream information, takes the initial stream information with the same field value of the first stream field as the same initial stream information, reserves any one initial stream information from the initial stream information with the same field value of the first stream field, filters and deletes the rest initial stream information, and takes the finally reserved initial stream information as target stream information. For example, a network message set starting from the same source IP within the same period of time is regarded as one stream, if the sip of two initial stream information is the same, the two initial stream information indicates the same stream, and any one of the two initial stream information can be deleted. For another example, the stream elements that constitute the stream information include vport (Virtual PORT), vlan (Virtual LAN, virtual local area network), and hash calculation is performed on vport and vlan in the same stream information, if the hash results corresponding to the two initial stream information are the same, any one initial stream information is reserved, and the remaining initial stream information is filtered and deleted.
In the above embodiment, in the random constraint included in the preset stream configuration information, according to the stream information format included in the preset stream configuration information, the initial stream information is randomly generated, so that the accuracy of the stream information generated randomly can be ensured when the stream information is generated randomly. Based on a first stream field preset for stream information, filtering each initial stream information to obtain at least one target stream information, so that errors caused by randomly generating stream information can be avoided, and each finally obtained stream information is ensured to be independent.
In one embodiment, generating, by a global configuration component, target flow table information corresponding to each target flow information based on preset flow table configuration information, forming the global flow table information from each target flow table information, and encapsulating the global flow table information to obtain a configuration message, including:
respectively combining stream table fields of each target stream information based on preset stream table configuration information through a global configuration component to obtain target stream table information corresponding to each target stream information; and forming the global flow table information by the global configuration component, and packaging the global flow table information based on the first message configuration information aiming at the configuration type message to obtain the configuration message.
The combination of the stream table fields refers to generating stream table fields based on stream information, and combining the stream table fields into stream table information. For example, each flow field representing the five-tuple information of the message is obtained from the flow information as a flow table field, other flow table fields are randomly generated, and each flow table field is combined to obtain the flow table information.
The first message configuration information is configuration information aiming at a configuration type message and is used for generating the configuration message. For example, the first message configuration information includes a message format of the configuration message.
Specifically, the global configuration component generates corresponding target flow table information based on the target flow information, and packages and encapsulates each target flow table information into a configuration message.
First, for any target flow information, the global configuration component performs flow table field combination on the target flow information based on preset flow table configuration information to obtain target flow table information corresponding to the target flow information. Specifically, a key flow field can be obtained from the target flow information based on preset flow table configuration information to serve as a part of flow table items, another part of flow table items are generated based on the preset flow table configuration information, and all the flow table items are combined to obtain the target flow table information corresponding to the target flow information. For example, sip, dip, dir is obtained from the target flow information as matching domain information in a flow table, and a preset operation domain information is randomly obtained from the set of preset operation domain information as operation domain information in the flow table, thereby obtaining a flow table. And then, forming the global flow table information by the global configuration component by each target flow table information, and packaging the global flow table information based on the first message configuration information aiming at the configuration type message to obtain the configuration message. For example, a header required for forming a configuration message is generated based on first message configuration information for the configuration type message, global flow table information is used as a message body (payload) required for forming the configuration message, and the header are combined to obtain the configuration message.
In the above embodiment, the target flow table information corresponding to the target flow information is generated based on the target flow information through the preset flow table configuration information, and the global flow table information obtained based on each target flow table information is packaged based on the first message configuration information aiming at the configuration type message, so that the configuration message can be obtained quickly.
In one embodiment, receiving, by a component to be authenticated, a configuration message for flow table information, comprising:
and receiving a configuration message aiming at the flow table information, which is sent by the excitation component through the driving component and is acquired from the global configuration component, through the component to be verified.
Wherein the environmental components in the verification platform further comprise an incentive component. The stimulus component is used for applying various stimulus to the component to be verified so as to trigger the component to be verified to process the received stimulus according to the test code. The environment components in the verification platform also include a drive component. The driving component is used for sending the excitation output by the excitation component to the component to be verified.
Specifically, the excitation component obtains a configuration message aiming at the flow table information from the global configuration component, the configuration message is sent to the driving component, and the driving component forwards the configuration message to the component to be verified.
In the above embodiment, the configuration message is sequentially transmitted to the component to be verified through the global configuration component, the excitation component and the driving component.
In a specific embodiment, the method of the present application may be applied to a UVM (Universal Verification Methodology ) based verification platform. In order to verify the correctness of the design codes of the chip, a verification platform based on UVM is built to verify the design codes.
Referring to fig. 3, in a UVM authentication environment, the authentication platform mainly includes: a driver, a monitor, a DUT, a reference model, and a score board.
The generator is used to generate stimulus data for the DUT. monitor is used to forward data. The DUT represents an RTL (register-transfer level) design component completely conforming to the chip function module, which processes received stimulus data according to a preset function and outputs the processed execution result. The RM represents a reference model corresponding to the expected function of the component to be verified, incentive data are sent to the RM for processing, and the RM sends the obtained expected result data to the Scorboard. The Scoreboard is used to compare the execution results output by the DUT with the execution results output by the RM to determine the verification result.
In the conventional method, the generator needs to contain a configuration for the flow table and the message, and can generate a configuration message according to the configuration information and send the configuration message to the DUT, and can generate a network message according to the configuration information and send the network message to the DUT. The generator sends the configuration message to the driver, which forwards the configuration message to the DUT. Monitor monitors data sent to the DUT by the driver in real time, samples the data and sends the sampled data to the RM. The RM needs to parse the monitor sampled configuration message including the configuration for the message, so as to independently maintain the flow table information in the RM, so as to query after receiving the network message.
The conventional verification environment has high code complexity, and because the RM and the generator need to maintain the flow table information, most of the flow table information is repeated, the code quantity is large, and repeated codes are more. Moreover, configuration delivery is inflexible, flow table information currently exists in generators and RMs, if redundant components are needed, such as splitting the RM into multiple module-level RMs for subsequent environment evolution, where the needed configuration information needs to be delivered between different RMs, possibly requiring multiple channels, each RM taking its own needed configuration.
However, in the method of the present application, a global configuration component (glb_cfg_mdl, global flow table configuration model) is designed. Role of global configuration model: 1. stream information and elements required by various configurations can be generated; 2. composing a configuration issuing format to facilitate subsequent issuing configurations; 3. the RM can directly read the configuration related information; 4. the RM may directly modify the information inside the configuration. In this way, the global configuration component and other component codes are isolated, the environment architecture is clear, repeated codes are reduced, and the overall complexity is reduced. In addition, the configuration transfer is flexible, other components can not only use tasks and functions in the glb_cfg_mdl, but also acquire related configurations, and meanwhile, related information in the glb_cfg_mdl can be modified so as to be convenient for synchronizing for subsequent messages. Furthermore, the global configuration component can be integrated upwards, so that the system simulation can be configured uniformly for the related modules.
Referring to fig. 4, in the UVM verification environment of the present application, the verification platform mainly includes: global configuration component (glb_cfg_mdl), stimulus component (generator), driver component (driver), monitor component (monitor), component to be verified (DUT, design Under test) reference component (RM, reference model), and result comparison component (Scoreboard).
The glb_cfg_mdl component is configured to generate flow information, generate flow table information based on the flow information, and generate a configuration message based on the flow table information. The generator acquires a configuration message from the glb_cfg_mdl component, the configuration message is sent to the DUT through the driver, and the DUT analyzes the configuration message to obtain first flow table information. The generator obtains flow information from the glb_cfg_mdl component and generates network messages based on the flow information. The generator sends the network message to the DUT through the driver, and the DUT processes the network message based on the first flow table information to obtain a first processing result and outputs the first processing result. The DUT outputs the first processing result to the monitor, which forwards the first processing result to the Scoreboard.
In the process that the generator sends the network message to the DUT through the driver, the monitor samples the network message and sends the network message obtained by sampling to the RM. The RM acquires second flow table information matched with the network message from the global configuration component, processes the network message based on the second flow table information to obtain a second processing result, and outputs the second processing result. The RM sends the second processing result to the Scoreboard.
The Scorboard compares the first processing result output by the DUT with the second processing result output by the RM, and can determine whether the function of the component to be verified is realized or not by comparing whether the first processing result and the second processing result are consistent, namely, the verification result of the component to be verified is obtained. If the function of the component to be verified is successfully realized, the verification result of the design code is passed verification.
In one embodiment, receiving, by a component to be authenticated, a network message includes:
acquiring second message configuration information and at least one target stream information aiming at the network type message from the global configuration component through the excitation component, and respectively packaging second stream fields preset in each target stream information based on the second message configuration information to obtain at least one network message; and receiving the network message sent by the excitation component through the component to be verified.
The second message configuration information is configuration information for a network type message and is used for generating the network message. For example, the second message configuration information includes a message format of the network message. The preset second flow field is a preset flow field for generating a network message. The stream field is the stream element.
Specifically, the excitation component acquires the target flow information generated by the global configuration component from the global configuration component, and generates a network message corresponding to the target flow information based on the target flow information. And the excitation component sends the generated network message to the component to be verified. The excitation component can send the network message to the driving component, and the driving component forwards the network message to the component to be verified.
The excitation component obtains second message configuration information for the network type message from the global configuration component and obtains at least one target flow information from the global configuration component. And for any target flow information, the excitation component encapsulates a second flow field preset in the target flow information based on the second message configuration information to obtain at least one network message. The excitation component can acquire a preset second stream field from the target stream information as a part of fields forming the network message, randomly generate another part of fields forming the network message, and combine the fields to obtain the network message. For example, sip, dip, dir and protocol number are obtained from the target flow information as a part of fields forming the network message, other fields forming the network message are randomly generated, and the fields are combined to obtain the network message.
In the above embodiment, the global configuration component is configured with the second message configuration information for generating the network message, and the excitation component can quickly generate the canonical network message corresponding to the target stream information without configuring itself, by acquiring the target stream information and the second message configuration information from the global configuration component.
In one embodiment, based on the second message configuration information, respectively encapsulating second flow fields preset in each target flow information to obtain at least one network message, including:
determining the number of effective messages and the number of ineffective messages aiming at the network type messages based on the message distribution proportion contained in the second message configuration information; based on a network message format contained in the second message configuration information, respectively packaging second stream fields preset in each target stream information to obtain a first message set; the number of messages corresponding to the first message set is the number of effective messages; based on the network message format contained in the second message configuration information, packaging the randomly generated random stream field to obtain a second message set; the random stream field and the second stream field are stream fields with the same field type and different field values, and the number of messages corresponding to the second message set is the number of invalid messages; and respectively taking the messages in the first message set and the second message set as network messages.
The second message configuration information comprises a message distribution proportion, and the message distribution proportion is used for determining the proportion between the effective network message and the ineffective network message. The effective network message is a network message generated based on the current correct flow information, is an effective network message, and can determine a message forwarding strategy corresponding to the effective network message based on the flow table information corresponding to the flow information. The invalid network message is an invalid network message, and a message forwarding strategy corresponding to the invalid network message cannot be determined based on the existing correct flow table information. The number of the effective messages refers to the number of the effective network messages to be generated. The number of invalid messages refers to the number of invalid network messages to be generated.
The second message configuration information further includes a network message format. The network message format is used to determine the composition and structure of the network message.
Specifically, in order to improve the verification accuracy for the component to be verified, an effective network message and an ineffective network message may be generated, and the verification result of the test code is comprehensively determined based on the processing results of the component to be verified for the effective network message and the ineffective network message, respectively.
The excitation component may obtain a message allocation proportion from the second message configuration information, and randomly generate an effective message number and an ineffective message number for the network type message, where a ratio between the effective message number and the ineffective message number is the message allocation proportion. For any target stream information, the excitation component can acquire a network message format from the second message configuration information, and package a second stream field preset in the target stream information based on the network message format to obtain at least one first message. And forming a first message set by each first message corresponding to each target stream information respectively, wherein the number of messages corresponding to the first message set is the effective number of messages. For any target stream information, the excitation component may randomly generate a stream field with the same field type as the second stream field but different field values as a random stream field, and encapsulate the random stream field based on a network message format included in the second message configuration information to obtain at least one second message. And forming a second message set by each second message corresponding to each target stream information respectively, wherein the number of messages corresponding to the second message set is the number of invalid messages. Finally, the excitation component respectively takes the messages in the first message set and the second message set as network messages, and sends the network messages to the component to be verified.
In one embodiment, the stimulating component may send messages in the first set of messages and the second set of messages in a message queue to the component to be authenticated in order.
In the above embodiment, based on the message allocation proportion and the network message format included in the second message configuration information, the effective network message and the ineffective network message with the message formats conforming to the network message formats and the number ratio between the different types of messages conforming to the message allocation proportion are quickly generated. The network comprises an effective network message and an ineffective network message, and the correctness of the test code can be verified from different perspectives.
In one embodiment, as shown in fig. 5, the code verification method further includes:
step S502, through the reference component, the network message forwarded by the monitoring component is received, and the flow identification corresponding to the flow to which the network message belongs is determined; the monitoring component is used for sampling the network message sent to the component to be verified by the excitation component.
Wherein the environment components in the verification platform further comprise a reference component representing a reference model corresponding to the intended function of the component to be verified. The stream identifier is an identifier for uniquely identifying a stream, and may specifically include a character string of at least one of letters, numbers, and symbols.
The environment component in the verification platform further comprises a monitoring component, wherein the monitoring component is used for sampling specific excitation data sent to the component to be verified by the excitation component and sending the excitation data obtained by sampling to the reference component. The monitoring component is mainly used for sampling the network message sent to the component to be verified by the excitation component and sending the network message obtained by sampling to the reference component.
Specifically, the reception of the second processing result by the result comparison component may be output by the reference component. The monitoring component monitors the excitation data sent to the component to be verified by the excitation component in real time, if the excitation data is monitored to be the network message, the monitoring component samples the network message, the sampled network message is sent to the reference component, and the reference component processes the received network message and outputs a second processing result.
It will be appreciated that sampling network messages is equivalent to copying network messages.
In one embodiment, the network message directly carries a flow identifier corresponding to the flow to which the network message belongs. For example, a flow identifier corresponding to a flow to which a network packet belongs may be placed in a reserved field of a reserved field in the network packet.
In one embodiment, the excitation component generates a plurality of network messages, generates a message queue recording flow identifications corresponding to flows to which each network message belongs, and stores the message queue in the global configuration component. And recording the flow identification corresponding to the flow to which the network message belongs according to the sending sequence of the network message in the message queue. The excitation component orderly sends each network message to the component to be verified, and the monitoring component orderly copies each network message and orderly sends each network message to the reference component. The reference component can query the global configuration component for the flow identifier corresponding to the flow to which the network message belongs according to the receiving sequence of the network message. Thus, the message queue maintains the flow identifier corresponding to the flow to which the network message belongs, so that the occupation of the message field in the network message can be avoided, and the data volume of the network message is reduced or the idle message field is reserved for other tasks. And the subsequent message queues can be cleaned in time, so that the occupation of resources of the global configuration component is avoided.
Step S504, through the reference component, based on the flow table reading interface provided by the global configuration component, the flow table information corresponding to the flow identification is read from the global flow table information configured by the global configuration component, and the second flow table information is obtained.
Step S506, the network message is processed based on the second flow table information through the reference component, and a second processing result is obtained.
Step S508, the second processing result is sent to the result comparing component through the reference component.
The global configuration component is provided with a flow table reading interface, and the flow table reading interface is used for other components to read flow table information in the global configuration component.
Specifically, after determining a flow identifier corresponding to a flow to which the network message belongs, the reference component reads flow table information corresponding to the flow identifier from global flow table information configured by the global configuration component through a flow table reading interface provided by the global configuration component, so as to obtain second flow table information. And the reference component inquires flow table information matched with the flow identifier from the global flow table information configured by the global configuration component through the flow table reading interface to obtain second flow table information. After the second flow table information is acquired, the reference component processes the network message based on the second flow table information to obtain a second processing result. The reference component sends the second processing result to the result comparison component so that the result comparison component compares the second processing result with the first processing result sent by the component to be verified.
It can be understood that if the flow table information matching the flow identifier cannot be queried from the global flow table information, the preset processing result may be used as the second processing result.
In the above embodiment, the reference component queries the correct flow table information from the global configuration component to process the network message, and determines the correctness of the actual processing result output by the component to be verified by taking the processing result output by the reference component as the expected processing result.
In one embodiment, processing the network packet based on the first flow table information to obtain a first processing result includes:
acquiring a preset message field from a network message as a key field; inquiring a corresponding flow table item from the first flow table information based on the key field; when a flow table item corresponding to a key field is queried, processing a network message based on a message forwarding strategy contained in the flow table item corresponding to the key field to obtain a first processing result; and when the flow table item corresponding to the key field is not queried, taking the preset processing result as a first processing result.
The preset message can be set according to actual needs. The preset processing result can also be set according to actual needs.
Specifically, when the component to be verified processes the network message, a preset message field is obtained from the network message and used as a key field; and inquiring the corresponding flow table item from the first flow table information based on the key field. For example, a message field related to a message quintuple is obtained from a network message as a key field, and a flow table item matched with the matching field information and the key field is queried from the first flow table information as a corresponding flow table item. It may be understood that the corresponding flow table entry may be queried in the first flow table information, or may not be queried, for example, if the network packet currently processed is an invalid network packet, the corresponding flow table entry may not be queried; if the configuration message is analyzed incorrectly, the corresponding stream table item may not be queried; etc. When the flow table item corresponding to the key field is queried, the component to be verified processes the network message based on the message forwarding strategy contained in the flow table item corresponding to the key field, and a first processing result is obtained. For example, if the operation domain information in the flow table entry is a discard message, the first processing result is a discard network message; if the operation domain information in the flow table item is that the message is forwarded to the port A, the first processing result is that the message is forwarded to the port A; if the operation domain information in the flow table item is to skip the message to the flow table item B for processing, the first processing result may be to skip the network message to the to-be-processed flow table item B for processing, or may acquire the flow table item B for processing the message until the operation domain information belonging to the second class is obtained from the corresponding flow table item, where the second processing result is the operation domain information belonging to the second class finally acquired. When the flow table item corresponding to the key field is not queried, the component to be verified takes the preset processing result as a first processing result. For example, the preset processing result may be that the network message is reported to other layers for processing.
In the above embodiment, the matched flow table entry is queried from the first flow table information based on the key field of the network message, so that the matched flow table entry can be quickly found.
In one embodiment, the component to be verified is configured to write each flow table entry in the first flow table information into different storage units in the preset memory space.
Based on the key field, querying the corresponding flow table item from the first flow table information comprises:
carrying out hash processing on the key field to obtain a hash result; inquiring a storage unit pointed by the hash result from a preset storage space, and taking a stream table item stored on the storage unit pointed by the hash result as a stream table item corresponding to the key field.
The preset memory space refers to a preset memory space. For example, the preset memory space may be a cache memory (cache memory) or a DDR memory (double rate synchronous dynamic random access memory).
Specifically, the component to be verified analyzes the configuration message to obtain first flow table information, the first flow table information is stored in a preset content space, and specifically, each flow table item in the first flow table information is written into different storage units in the preset memory space respectively. The component to be verified can acquire key table information from the stream table to carry out hash processing, and the obtained hash result is associated with the storage address of the storage unit written in by the stream table.
After the network message is received by the to-be-verified component, a preset message field is obtained from the network message and used as a key field, the key field is hashed to obtain a hash result, a storage unit pointed by the hash result is queried from a preset storage space, and the storage unit corresponding to the storage address associated with the hash result can be used as the storage unit pointed by the hash result. And finally, taking the flow table item stored on the storage unit pointed by the hash result as the flow table item corresponding to the key field by the component to be verified. It can be understood that if the storage unit pointed to by the hash result is not queried, the flow table entry corresponding to the key field is not queried.
In the above embodiment, the hash result obtained by performing the hash processing on the key field queries the storage unit pointed by the hash result from the preset storage space, so that the query speed can be improved, and the flow table item corresponding to the key field can be quickly queried.
In one embodiment, the code verification method further comprises:
when the first processing result and the second processing result are consistent, determining that the verification result corresponding to the test code is passing verification by the result comparison component; and when the first processing result and the second processing result are inconsistent, determining that the verification result corresponding to the test code is not verified by the result comparison component.
Specifically, the first processing result is an actual processing result output by the component to be verified, the second processing result is an expected processing result, and the result comparison component compares the first processing result with the second processing result. If the first processing result is consistent with the second processing result, the to-be-verified component can successfully output the expected processing result, the to-be-verified component realizes the corresponding function, and the test code is correct, so that the verification result corresponding to the test code is determined to pass verification. If the first processing result and the second processing result are inconsistent, it is indicated that the expected processing result is not output by the to-be-verified combination, and the test code may be in error, so that it is determined that the verification result corresponding to the test code is not passed.
In the above embodiment, by simply comparing whether the first processing result and the second processing result are consistent, the verification result corresponding to the test code can be quickly determined.
In one embodiment, the second processing result is obtained by processing the network message by the reference component based on the second flow table information obtained from the global configuration component, and the second processing result is sent to the result comparison component by the reference component.
The code verification method further comprises the following steps:
And when the second processing result is a valid processing result, writing the second processing result into second flow table information stored in the global configuration component based on the flow table writing interface provided by the global configuration component through the reference component.
The global configuration component is provided with a flow table writing interface which is used by other components to write information into flow table information in the global configuration component.
Specifically, after the reference component receives the network message, second flow table information matched with the network message is obtained from the global configuration component, and the network message is processed based on the second flow table information to obtain a second processing result. Further, the reference component can write the second processing result into the second flow table information stored in the global configuration component through the flow table writing interface provided by the global configuration component for data statistics or subsequent processing. For example, the second flow table information further includes statistical domain information for data traffic related information, and the second processing result may be used to update the statistical domain information. For example, for a TCP message, the second processing result may include a message state, which may be written to second flow table information stored in the global configuration component for processing of a subsequent TCP message.
In the above embodiment, the reference component may quickly write new information into the flow table information in the global configuration component through the flow table writing interface provided by the global configuration component, so as to perform data statistics or subsequent processing.
In one embodiment, the global configuration component includes a master configuration sub-component and a slave configuration sub-component that serves the master configuration sub-component.
Wherein the main configuration sub-component comprises main code in the test code for implementing the functionality provided by the global configuration component. The secondary configuration sub-component includes auxiliary code in the test code, and the secondary configuration sub-component serves as a primary configuration sub-component for assisting the primary configuration sub-component in implementing the functionality provided by the global configuration component.
The functions implemented by the main configuration sub-component include at least one of generating flow information, generating flow table information, generating configuration messages, generating flow table read-write interfaces. For example, in the global configuration component, the main configuration sub-component generates flow information, generates flow table information based on the flow information, generates configuration messages based on the flow table information, and generates flow table read-write interfaces for other components to use.
The slave configuration sub-components include a macro definition sub-component, a random configuration sub-component, a base template sub-component, and an adaptation sub-component.
The macro definition sub-component is used to define the calling code required by the main configuration sub-component in generating the data. For example, the macro definition sub-component is used for defining common codes required by the main configuration sub-component when generating data, and the common codes use macro definition to save the code quantity of the main configuration sub-component and avoid the error of writing the common codes for many times in the main configuration sub-component.
The random configuration subcomponent is used to configure the random range required by the main configuration component in randomly generating data. For example, the random configuration subcomponent is used to define random constraints in the flow configuration information, and the random configuration subcomponent is used to define random constraints in the flow table configuration information.
The base template subcomponent is used to define the calling tasks required by the main configuration subcomponent in generating data. For example, the basic template sub-component is used for defining common tasks or common functions required by the main configuration sub-component when generating data, and the common tasks or common functions use the basic template to save the code quantity of the main configuration sub-component and avoid the error of writing common codes for many times in the main configuration sub-component.
The adaptation sub-component is used for adapting the transmitted data among the components when the data generated by the main configuration component is transmitted to other components. For example, the auxiliary excitation component carries in the network message a flow identifier corresponding to a flow to which the network message belongs; after the excitation component generates the effective network message, the excitation component is assisted to modify the effective network message to quickly obtain the ineffective network message.
In one embodiment, referring to FIG. 6, the glb_cfg_mdl component (i.e., global configuration component) refers to a glb_cfg_def file (i.e., macro definition subcomponent), a glb_cfg_rand file (i.e., random configuration subcomponent), a glb_cfg_base file (i.e., base template subcomponent), a glb_cfg_mdl file (i.e., main configuration subcomponent), a glb_cfg_adapter file (i.e., adapter subcomponent).
The glb_cfg_def file mainly comprises macro definitions commonly used in components, such as printing formats commonly used by the glb_cfg_def file, weight randomness, table item data structures and the like, and is mainly used for saving code quantity by using macro definitions for commonly used codes, and avoiding mistakes of writing for many times.
The glb_cfg_rand file is mainly provided with information such as random configuration, stream information, signals of various required table items, random constraint, aggregate printing of all configuration and the like. The files of the random configuration and the files of the main code are decoupled, so that the structure is clear and the maintenance is convenient.
The glb_cfg_base file is a basic template and mainly comprises common tasks or functions, such as hash calculation and the like, which do not relate to the details of the flow table.
The glb_cfg_mdl file is a main code, inherited from the glb_cfg_base, and is mainly used globally later, and relates to information of streams, configuration structures of various stream tables and the like.
The glb_cfg_adapter file is used for modifying and adapting message part information when the flow information in the glb_cfg_mdl component is transmitted to the incentive.
Referring to fig. 7, the glb_cfg_mdl file may implement a stream information generation function, an entry information combination function, an entry initialization function, an entry read/write function, and other auxiliary functions. Aiming at the stream information generating function, mainly stream information such as sip, dip and the like and main information used in the table entry are generated, and because some coupling exists among partial signals, the information generated by random constraint of the glb_cfg_rand file is firstly adapted, and the stream information is finally generated in the functional module. For the function of combining the table information, for example, the new table is needed to be built, the format of the new table is formed by combining the flow information so as to be conveniently transmitted to the excitation side, and the new table is well transmitted to the DUT, and meanwhile, the content of the new table is written into the environment for internal storage. For the table item initializing function, in order to facilitate the initializing operation of each table item, general information is packaged into tasks, and the tasks are matched with other environment components to perform the initializing operation of the DUT flow table, namely, the flow table information is packaged into configuration messages so as to be conveniently transmitted to an excitation side, and the configuration messages are well issued to the DUT. Aiming at the reading and writing function of the table entry, the interface for writing and reading the table entry is convenient for writing and reading operations of other components of the environment to the table entry. For other auxiliary functions such as end checking of the environment, etc. For example, after verification is completed, the queues stored in the global configuration component are cleared; after verification is completed, the stream information and stream table information which are randomly generated in the global configuration component are cleared.
In one embodiment, the test code is code that implements virtual interactive machine hardware offload functions, and the validated test code is used to generate a chip that is placed on a cloud server.
Specifically, the test code is code that implements virtual interactive machine hardware offload functions. The virtual interactive machine refers to a virtualized interactive machine, and the switch obtains forwarding rules for forwarding the data packet by querying the flow table. The software system of the switch comprises a software layer and a hardware layer, and the test code is used for realizing network message forwarding through the hardware layer. After receiving a network message, the switch searches the flow table item matched with the network message in the flow table of the hardware layer, if the flow table item matched with the network message is not found in the flow table of the hardware layer, then searches the flow table item in the flow table of the software layer, if the flow table matched with the flow table item is not found in the flow table of the software layer, the network message is reported to the controller, the controller generates the flow table item matched with the network message, and the network message and the flow table item (the issued flow table item can be all the flow table items matched with the network message or all the flow table items which are not issued from all the flow table items matched with the network message) are issued to the switch. After receiving the flow table items issued by the controller, the switch firstly stores the flow table items into a flow table of a software layer, then searches all flow table items matched with the network message in the flow table of the software layer, finally aggregates all the matched flow table items into a flow table item of a hardware layer, and stores the flow table item of the hardware layer into the flow table of the hardware layer. After the exchanger receives the network message, it can search the matched flow list item in the flow list of the hardware layer, and transmit the network message according to the network message transmitting rule of the matched flow list item.
And verifying the test code based on the verification platform, if the test code passes the verification, the test code can be used for generating a chip with the virtual interactive machine hardware unloading function, and the chip can be finally placed on a cloud server to realize the virtual interactive machine hardware unloading function on the cloud server. It can be understood that the test code can be a code used for realizing the hardware uninstallation function of the virtual interactive machine in a chip, and the code with other functions can be integrated in the chip.
In one embodiment, when implementing the virtual interactive machine hardware offloading function through the test code, the N-tuple (e.g., the triplet or the quintuple) of the received network packet may be extracted, and the extracted packet information is used as a key information key, so that the flow table is searched according to the key, and the corresponding operation is performed according to the searched flow table information, for example, the searched flow table information may be used for performing a subsequent operation, or the searched flow table information may be changed.
For example, referring to fig. 8, if a network packet is received, the network packet is parsed by the test code, sip, dip, dir in the network packet is extracted as a target key, the target key is subjected to hash calculation (hash calculation) and then the relevant address is queried by the DDR, and the DDR returns to acquire the stored information from the relevant address as a query result. The query result comprises relevant flow table information for forwarding the network message, the relevant flow table information comprises a reference key for referring the network message, the reference key is compared with a target key, if the reference key is the same with the target key, the message is forwarded through the relevant flow table information, and part of the processed information is rewritten back to the DDR. If the key information is different in comparison, the message is sent to an SOC (System on Chip) to be processed by software, the software can issue flow table configuration according to the message information, the issued message is finally written into the DDR through a test code, the message with the same key is subsequently sent, and the test code can unload and forward the message by hardware.
In a specific embodiment, the method of the present application may be applied to verifying TVS codes based on a UVM verification platform. TVS code is code that implements hardware offloading of Virtual switches.
The verification platform constructed by the method mainly comprises the following steps: global configuration component (glb_cfg_mdl), stimulus component (generator), driver component (driver), monitor component (monitor), component to be verified (DUT, design Under test) reference component (RM, reference model), and result comparison component (Scoreboard).
Referring to fig. 9, the glb_cfg_mdl component only has new () in the verification environment, and then the information in the glb_cfg_mdl component can be transferred to other components by means of handle transfer, so that other components can use the information in the glb_cfg_mdl component, modify the information in the glb_cfg_mdl component, and after one component modifies the related information, the other components can also use the newly modified information for processing. By handle transfer of the glb_cfg_mdl component, the generator and the RM, and even other components can use the information in the glb_cfg_mdl component at any time, so that all information required to be associated by the RM and the generator is given to the glb_cfg_mdl component for unified processing, and the signal adaptation with the generator and the RM is finished. Meanwhile, the glb_cfg_mdl component can be integrated upwards, so that the System-level test Simulation (ST) is convenient to use under the condition of TVS module allocation.
The flow table of the TVS needs to be configured and issued in the verification platform, meanwhile, the flow table needs to be queried in the verification environment, and corresponding flow table information can be obtained after the query so as to facilitate the environment to carry out RM (resource management) implementation and other operations, so that a globally visible flow table model (namely a glb_cfg_mdl component) is used in the verification platform, flexible flow table configuration can be carried out, and meanwhile, the flow table model can also be used as a model for storing the flow table. The global flow table model can not only realize the requirement of verification environment, but also reduce configuration transfer, and can greatly reduce the complexity of an environment framework.
Because of the characteristics of the cooperative work of the software and hardware of the TVS module, a large number of operations such as item configuration, modification and deletion are required, the verification platform constructed by the method provided by the application more flexibly simulates the software behavior, greatly simplifies the environment configuration flow, reduces the error probability, and simultaneously integrates the glb_cfg_mdl component of the verification platform into the verification environment of the TCM subsystem (the subsystem comprises the TVS module and other modules) of the Xuanling chip to perform the relevant configuration of the TVS function.
Compared with the prior art, the method has the advantages that the code quantity is reduced by nearly 1/3, the method can be independently maintained, and the work is easy to decouple when a plurality of persons cooperate. The method of the application gives the complex information interaction to the independent environment components, so that the verifier can better organize the configuration and function verification of the flow table items, simplify the flow, ensure clear information transmission between environments and reduce the workload.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a code verification device for realizing the above related code verification method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in one or more embodiments of the code verification device provided below may refer to the limitation of the code verification method hereinabove, and will not be repeated here.
In one embodiment, as shown in fig. 10, there is provided a code verification apparatus including: a configuration message parsing module 1002, a network message processing module 1004, and a processing result sending module 1006, where:
a configuration message parsing module 1002, configured to receive, through the component to be verified, a configuration message for the flow table information, parse the configuration message, and obtain first flow table information; the configuration message is obtained by packaging global flow table information configured by the global configuration component, and the function of the component to be verified is realized by the test code to be verified.
The network message processing module 1004 is configured to receive, through the component to be verified, a network message, and process the network message based on the first flow table information to obtain a first processing result.
The processing result sending module 1006 is configured to send, through the component to be verified, the first processing result to the result comparing component, so that the result comparing component compares the first processing result with the second processing result, and obtains a verification result corresponding to the test code; the second processing result is obtained by processing the network message based on the global flow table information configured by the global configuration component.
In one embodiment, as shown in fig. 11, the code verification apparatus further includes:
The information configuration module 1102 is configured to randomly generate stream information based on preset stream configuration information through the global configuration component, so as to obtain at least one target stream information; and generating target flow table information corresponding to each target flow information respectively based on preset flow table configuration information through a global configuration component, forming the global flow table information by each target flow table information, and packaging the global flow table information to obtain a configuration message.
In one embodiment, the information configuration module 1102 is further configured to:
randomly generating at least one initial stream information in a random constraint contained in preset stream configuration information through a global configuration component according to a stream information format contained in the preset stream configuration information; and filtering each piece of initial stream information based on a first stream field preset for the stream information to obtain at least one piece of target stream information.
In one embodiment, the information configuration module 1102 is further configured to:
respectively combining stream table fields of each target stream information based on preset stream table configuration information through a global configuration component to obtain target stream table information corresponding to each target stream information; and forming the global flow table information by the global configuration component, and packaging the global flow table information based on the first message configuration information aiming at the configuration type message to obtain the configuration message.
In one embodiment, the configuration message parsing module 1002 is further configured to:
and receiving a configuration message aiming at the flow table information, which is sent by the excitation component through the driving component and is acquired from the global configuration component, through the component to be verified.
In one embodiment, the network message processing module 1004 is further configured to:
acquiring second message configuration information and at least one target stream information aiming at the network type message from the global configuration component through the excitation component, and respectively packaging second stream fields preset in each target stream information based on the second message configuration information to obtain at least one network message; and receiving the network message sent by the excitation component through the component to be verified.
In one embodiment, the network message processing module 1004 is further configured to:
determining the number of effective messages and the number of ineffective messages aiming at the network type messages based on the message distribution proportion contained in the second message configuration information; based on a network message format contained in the second message configuration information, respectively packaging second stream fields preset in each target stream information to obtain a first message set; the number of messages corresponding to the first message set is the number of effective messages; based on the network message format contained in the second message configuration information, packaging the randomly generated random stream field to obtain a second message set; the random stream field and the second stream field are stream fields with the same field type and different field values, and the number of messages corresponding to the second message set is the number of invalid messages; and respectively taking the messages in the first message set and the second message set as network messages.
In one embodiment, the network message processing module 1004 is further configured to:
receiving the network message forwarded by the monitoring component through the reference component, and determining a flow identifier corresponding to a flow to which the network message belongs; the monitoring component is used for sampling the network message sent to the component to be verified by the excitation component; reading flow table information corresponding to the flow identifier from the global flow table information configured by the global configuration component based on the flow table reading interface provided by the global configuration component through the reference component to obtain second flow table information; processing the network message based on the second flow table information through the reference component to obtain a second processing result; and sending the second processing result to the result comparison component through the reference component.
In one embodiment, the network message processing module 1004 is further configured to:
acquiring a preset message field from a network message as a key field; inquiring a corresponding flow table item from the first flow table information based on the key field; when a flow table item corresponding to a key field is queried, processing a network message based on a message forwarding strategy contained in the flow table item corresponding to the key field to obtain a first processing result; and when the flow table item corresponding to the key field is not queried, taking the preset processing result as a first processing result.
In one embodiment, the component to be verified is configured to write each flow table entry in the first flow table information into a different storage unit in the preset storage space. The network message processing module 1004 is further configured to:
carrying out hash processing on the key field to obtain a hash result; inquiring a storage unit pointed by the hash result from a preset storage space, and taking a stream table item stored on the storage unit pointed by the hash result as a stream table item corresponding to the key field.
In one embodiment, the processing result sending module 1006 is further configured to:
when the first processing result and the second processing result are consistent, determining that the verification result corresponding to the test code is passing verification by the result comparison component; and when the first processing result and the second processing result are inconsistent, determining that the verification result corresponding to the test code is not verified by the result comparison component.
In one embodiment, the second processing result is obtained by processing the network message by the reference component based on the second flow table information obtained from the global configuration component, and the second processing result is sent to the result comparison component by the reference component. The processing result sending module 1006 is further configured to:
the second processing result is written into second flow table information stored in the global configuration component based on the flow table writing interface provided by the global configuration component by the reference component.
In one embodiment, the global configuration component includes a master configuration sub-component and a slave configuration sub-component serving the master configuration sub-component, the slave configuration sub-component including a macro definition sub-component, a random configuration sub-component, a base template sub-component, and an adaptation sub-component.
The functions realized by the main configuration sub-component comprise at least one of generating stream information, generating stream table information, generating configuration messages and generating stream table read-write interfaces; the macro definition sub-component is used for defining calling codes required by the main configuration sub-component when generating data; the random configuration sub-component is used for configuring a random range required by the main configuration component when randomly generating data; the basic module sub-component is used for defining a calling task required by the main configuration sub-component when generating data; the adaptation sub-component is used for adapting the transmitted data among the components when the data generated by the main configuration component is transmitted to other components.
In one embodiment, the test code is code that implements virtual interactive machine hardware offload functions, and the validated test code is used to generate a chip that is placed on a cloud server.
According to the code verification device, globally visible and globally available flow table information is uniformly configured in the global configuration component, other components do not need to independently maintain flow table configuration, the other components only need to use the global flow table information in the global configuration component, codes of the global configuration component and the other components are isolated, the environment architecture is clear, repeated codes are reduced, and the overall complexity is effectively reduced.
The respective modules in the above-described code verification apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 12. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used to store the various components. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a code verification method.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure thereof may be as shown in fig. 13. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a code verification method. The display unit of the computer equipment is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device, wherein the display screen can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on a shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by persons skilled in the art that the structures shown in fig. 12 and 13 are merely block diagrams of portions of structures associated with aspects of the present application and are not intended to limit the computer apparatus to which aspects of the present application may be applied, and that a particular computer apparatus may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.