A message modification and forwarding method simulating normal business
By parsing and modifying messages, using number data to determine message timeouts, and simulating uplink and downlink message scenarios, the problem of low server program testing efficiency in the existing technology is solved, and automated testing and performance inspection are realized.
Patent Information
- Application Number
- CN202311764174.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-20
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2043-12-20
AI Technical Summary
In the existing technology, the server program needs to manually play back messages during testing, which affects the testing efficiency, and the sending and receiving times need to be calculated separately, resulting in low testing efficiency.
By parsing the message set, distinguish between uplink and downlink messages, write numbering data in the uplink messages, send and receive downlink messages, determine the timeout situation, adjust the sending rate, simulate uplink and downlink message scenarios, and use the cpreplay tool to rewrite the numbers data to implement automated testing.
It improves the efficiency of server-side program testing. It can automatically determine the message reception status, adjust the sending rate, and check the program function and performance, which significantly improves the testing efficiency.
Smart Images

Figure CN117793768B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wireless communications, and in particular to a message modification and forwarding method for simulating normal services. Background Art
[0002] When writing a server program, you need to frequently test the functions of the server program. For example, after receiving a specified message, whether the server can respond to the corresponding message. In conventional testing, the message is played back and the feedback message is captured to determine whether the server runs the program normally. Each time the server program is tested, the message needs to be played back, but in the prior art, the message playback needs to be done manually, and the sending time and receiving time need to be calculated separately, which affects the test efficiency of the program. Summary of the invention
[0003] In view of this, the problem to be solved by the present invention is to provide a message modification and forwarding method that simulates normal business, which can simulate the sending scenario of uplink and downlink messages, facilitate testing of server-side programs, and verify the correctness of their functions. At the same time, it can also verify the performance of the program by increasing the rate, thereby improving test efficiency.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] A message modification and forwarding method simulating normal business, comprising:
[0006] Step 1: parse the message set, receive several message sets, distinguish different uplink and downlink messages, and store them in an array in sequence;
[0007] Step 2: Send an uplink message, write the number data into the uplink message, and send it;
[0008] Step 3, receive the replayed downlink message, determine whether the receiving time exceeds the single group test time, if yes, jump to step 6, if no, wait for receiving the downlink message, and determine the uplink message sending time according to the number data of the received downlink message;
[0009] Step 4: store the downlink message, and determine whether the downlink message is received overtime based on the number data and the current time. If yes, discard the timed-out downlink message and jump to step 3. If no, store the downlink message;
[0010] Step 5: Send the next uplink message, obtain the number data of the downlink message that has not timed out, and determine whether to send the next uplink message. If yes, jump to step 2; if no, jump to step 3;
[0011] Step six, execute the next single group test, determine whether the test exceeds the entire group test time, if yes, end the test, if not, obtain the uplink message corresponding to the next single group test, and jump to step two.
[0012] Furthermore, the step 2 includes receiving test information, wherein the test information includes a packet rate indicating an uplink message sending rate, a single group test time indicating a time required for a single group test, and a whole group test time indicating a time required for a whole group test.
[0013] Furthermore, the step one includes obtaining the source IP and destination IP of the uplink message to distinguish different uplink messages.
[0014] Furthermore, the uplink message is forwarded based on the MAC protocol, the uplink message includes a destination mac address in which destination IP address information is written, and the numbering data is written into a source mac address.
[0015] Furthermore, in the step 2, the uplink message number data is written in the order of 1, 3, 5...x.
[0016] Furthermore, in the step three, the downlink message is replayed after the numbering data is increased by one by a rewriting tool.
[0017] Furthermore, the rewriting tool is a cpreplay tool.
[0018] The advantages and positive effects of the present invention are:
[0019] By writing the corresponding number data in the uplink message, when receiving the corresponding downlink message, the sending time of the uplink message can be determined according to the number data, and it can be judged whether the downlink message has timed out, or whether to send the next uplink message can be determined according to the number data of the downlink message. This can simulate the sending scenario of uplink and downlink messages, facilitate testing of server-side programs, and verify the correctness of their functions. At the same time, by adjusting the sending rate of the uplink message, the rate can be increased to verify the performance of the program and improve the testing efficiency of the server program. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0021] Figure 1 It is a corresponding system of a message modification and forwarding method simulating normal business of the present invention;
[0022] Figure 2 It is an overall flow chart of a message modification and forwarding method simulating normal business of the present invention. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0025] The present invention provides a message receiving and sending method for detecting server performance, such as Figure 1 As shown, the system based on the message transceiver method includes a server and a transceiver device, and the transceiver device communicates with the server data through the MAC protocol. The transceiver device sends an uplink message, and the server receives the uplink message and replays it in the original path, and the message replayed by the transceiver device is defined as a downlink message. According to the number and rate of the replayed messages, the server's normal performance of receiving the uplink message is judged, and then the efficiency of the server program operation is detected.
[0026] like Figure 2 As shown, the special terms in the flowchart are explained as follows: pkt: a set of messages required to simulate the uplink and downlink message scenarios; size: the number of messages included in pkt; pps: the number of messages sent per second; time: the duration of the scenario simulation; round: the number of pkts sent per second; timeout: the message timeout period.
[0027] After receiving the necessary test information and message set, the transceiver will first parse the pkt used to simulate the packet sending scenario, and then send the packet according to the parameter content.
[0028] like Figure 2 As shown in the figure, the message sending and receiving process includes:
[0029] Step 1: parse the message set, receive several message sets, distinguish different uplink and downlink messages, and store them in an array in sequence.
[0030] The message set includes several uplink and downlink messages with different source IP and destination IP. The uplink and downlink messages in the message set package are distinguished by identifying the source IP and destination IP, and the uplink and downlink messages are stored in an array according to the identification order as test sample messages.
[0031] Step 2: Send an uplink message, write the number data into the uplink message, and send it.
[0032] Before executing step 2, receive test information, which includes packet rate, single group test time and whole group test time. The whole group test time includes several single group test times, and each single group test corresponds to different types of uplink messages to test different performances of the server. The packet rate is the rate at which uplink messages are sent, and the single group test time is: the time required to send and receive a fixed number of uplink messages. The whole group test time is: the time required to send and receive all uplink messages.
[0033] The uplink message is forwarded to the server based on the MAC protocol. The front-end structure of the uplink message is: 6 bytes of destination MAC address information-6 bytes of source MAC address information-2 bytes of type information. Since the uplink message does not need the source MAC address information when it is sent to the server, the first four bytes of the 6 bytes record the number data so that the sending time of the uplink message can be determined based on the number data.
[0034] And because 4 bytes can represent up to about 4.2 billion, the maximum mark is 4.2 billion. After exceeding it, it starts from the beginning. The time after reaching 4.2 billion is long enough and there will be no situation of overwriting the message marks that have not been simulated.
[0035] The transceiver determines the number and time of uplink messages to be sent based on the packet sending rate. When sending uplink messages: write the number data into the first 4 bytes of the source MAC address according to the packet sending order, and wait for the reception of downlink messages when sending.
[0036] An embodiment of the present application is that the writing order of the uplink message numbering data is 1, 3, 5...x, the first uplink message sent is numbered 1, the second uplink message is numbered 3, and so on.
[0037] Step three, receive the replayed downlink message and determine whether the receiving time exceeds the single group test time. If yes, jump to step six. If no, wait for receiving the downlink message and determine the uplink message sending time based on the number data of the received downlink message.
[0038] After the server receives the uplink message, the rewriting tool increases the number data by one and then replays it. One embodiment of the present application is: the server receives an uplink message with number data of 3, and the rewriting tool changes the number data to 4 before replaying the downlink message. The rewriting tool can be a cpreplay tool, which is a pcap packet replay tool. It can replay the packet captured by ethreal and wireshark tools as is or after any modification. It allows you to make any modification to the message (mainly to the 2nd, 3rd, and 4th layer message headers), specify the speed of replaying the message, etc.
[0039] After the transceiver sends an uplink message, it continuously monitors the current time and continuously receives downlink messages within the single group test time. When a downlink message is received, the downlink message receiving time is recorded and the downlink message number data is obtained to determine the sending time of the corresponding uplink message.
[0040] When the current time of continuous monitoring exceeds the single group test time, jump to step 6.
[0041] Step 4, store the downlink message, and determine whether the downlink message is received overtime based on the number data and the current time. If yes, discard the timed-out downlink message and jump to step 3. If no, store the downlink message.
[0042] Compare the sending time of the uplink message with the current time to determine whether the receiving time of the downlink message has timed out. If not, store the downlink message. If it is determined to have timed out, discard the timed downlink message and repeat step 3 until the corresponding downlink message is received.
[0043] In a group of tests, if a downlink message is received overtime, the sending of uplink messages will stop until the test time of this group ends and the next group of tests begins.
[0044] Step 5: Send the next uplink message, obtain the number data of the downlink message that has not timed out, and determine whether to send the next uplink message. If yes, jump to step 2; if no, jump to step 3;
[0045] After the non-timed out messages are stored in the array, the number data of the non-timed out downlink messages are obtained, and the number data of the downlink messages is determined based on the number data. It is judged whether the number of test messages in this round is sufficient, and then it is determined whether to continue sending uplink messages. If there is no need to continue sending uplink messages, jump to step three and continue waiting to receive downlink messages until the group of tests is completed.
[0046] If it is necessary to continue to send uplink messages, determine the number data according to the number of uplink messages to be sent and write it into the uplink message, and then continue to wait for receiving downlink messages.
[0047] Step six, execute the next single group test, determine whether the test exceeds the entire group test time, if yes, end the test, if not, obtain the uplink message corresponding to the next single group test, and jump to step two.
[0048] When looping step three, the time for waiting to receive the sent message exceeds the single group test time, stops receiving the downlink message, and determines whether it exceeds the entire group test time. If so, it means that the test time has been reached and the test is ended.
[0049] If not, execute the next single group test, obtain the uplink message corresponding to the next single group test, go to step 2, write the preset number data into the uplink message, and send it, then jump to step 3, cyclically receive downlink messages and send uplink messages to complete this round of testing.
[0050] After the test is completed, the message information in the intercepted data stream is obtained and compared with the message information in the array to calculate the performance of the server program.
[0051] An embodiment of the present application is: a message set includes 4 uplink messages, the test information is, the packet sending rate is 8 per second, the single group test time is 2s, the single group test needs to send 16 uplink messages in sequence, the timeout time is 0.1s, and the whole group test time is 2min.
[0052] According to the packet sending rate, in the first single group test, the uplink message numbers are 1 / 3 / 5 / 7 / 9 / 11 / 13 / 15 / 17 / 19 / 21 / 23 / 25 / 27 / 29 / 31.
[0053] In the first round of testing, an uplink message numbered 1 is sent at 0s, and a downlink message numbered 2 is received at 0.05s. According to number 2, the corresponding uplink message is known, and the relaxation time of the uplink and downlink messages is obtained and compared with the current time. It is determined that the receiving time of the downlink message does not exceed 0.1s and has not timed out. The downlink message is stored, and number 3 is written into the next uplink and downlink message and sent. The sending time of the uplink message is recorded as 0.06s. At 0.17s, a downlink message numbered 4 is received, and the interval time exceeds 0.1s. The downlink message times out, and the downlink message is discarded. The waiting for downlink messages continues until the end of this group of test time and the next group of tests begins.
[0054] In the next test, the number 33 is written into the uplink message and sent at 2.0s. The process of the first test is repeated until the test time exceeds 2min and all groups are tested. After the test, the data stream is intercepted and compared with the uplink and downlink messages in the array to determine the performance of the server program.
[0055] The embodiments of the present invention are described in detail above, but the contents described are only preferred embodiments of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of this patent.
Claims
1. A method for modifying and forwarding messages simulating normal business, It is characterized in that include, Step 1: parse the message set, receive several message sets, distinguish different uplink and downlink messages, and store them in an array in sequence; Step 2: Send an uplink message, write the number data into the uplink message, and send it; Step 3, receive the replayed downlink message, determine whether the receiving time exceeds the single group test time, if yes, jump to step 6, if no, wait for receiving the downlink message, and determine the uplink message sending time according to the number data of the received downlink message; Step 4: store the downlink message, and determine whether the downlink message is received overtime based on the number data and the current time. If yes, discard the timed-out downlink message and jump to step 3. If no, store the downlink message; Step 5: Send the next uplink message, obtain the number data of the downlink message that has not timed out, and determine whether to send the next uplink message. If yes, jump to step 2; if no, jump to step 3; Step six, execute the next single group test, determine whether the test exceeds the entire group test time, if yes, end the test, if not, obtain the uplink message corresponding to the next single group test, and jump to step two.
2. A method for modifying and forwarding a message simulating normal business according to claim 1, It is characterized in that The step 2 includes receiving test information, wherein the test information includes a packet sending rate indicating an uplink message sending rate, a single group test time indicating a time required for a single group test, and a whole group test time indicating a time required for a whole group test.
3. A method for modifying and forwarding a message simulating normal business according to claim 1, It is characterized in that The step 1 includes obtaining the source IP and destination IP of the uplink message to distinguish different uplink messages.
4. A method for modifying and forwarding a message simulating normal business according to claim 1, It is characterized in that The uplink message is forwarded based on the MAC protocol, the uplink message includes a destination MAC address in which destination IP address information is written, and the numbering data is written into a source MAC address.
5. A method for modifying and forwarding a message simulating normal business according to claim 1, It is characterized in that In the step 2, the uplink message number data is written in the order of 1, 3, 5...x.
6. A method for modifying and forwarding a message simulating normal business according to claim 5, It is characterized in that In the step 3, the downlink message is replayed after the numbering data is increased by one by the rewriting tool.
7. A method for modifying and forwarding a message simulating normal business according to claim 6, It is characterized in that The rewriting tool is a cpreplay tool.
