Network testing methods, apparatus, network devices and computer-readable storage media
By setting a fixed UDP port number in the TWAMP Light session and utilizing session ID and timestamp information, the problems of time-consuming IP quadruple matching and UDP port conflicts in TWAMP Light network testing were resolved, improving the accuracy and performance of the test.
Patent Information
- Application Number
- CN202411644876.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-11-18
AI Technical Summary
In existing TWAMP Light network tests, the presence of multiple sessions on the device under test leads to lengthy IP quadruple matching times and severe UDP port number conflicts, affecting the accuracy of test results and data forwarding performance.
In the TWAMP Light session, a fixed UDP port number is set, and the target session is obtained from the test response message by the session ID. The test result is determined by combining the timestamp information, thereby reducing UDP port resource consumption and conflicts.
It improves the data forwarding performance and accuracy of test results in network testing, reduces matching time, and ensures the normal sending and receiving of test packets.
Smart Images

Figure CN119520345B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and more specifically, to a network testing method, apparatus, network device, and computer-readable storage medium. Background Technology
[0002] With the rapid development of computer network technology, the number of services carried on the network is increasing, and services such as voice, video, and gaming are placing increasingly stringent requirements on network packet loss and latency. Therefore, network administrators need to test the network to understand its packet loss and latency status in a timely manner, and then adjust and optimize the network based on the test results to meet the demands of network services.
[0003] Currently, network testing of devices can be performed using TWAMP (Two-Way Active Measurement Protocol). TWAMP can be used to measure network performance parameters between any two devices in a network, providing a basis for network quality analysis. TWAMP Light is a lightweight architecture of the TWAMP protocol, which simplifies the control protocol for establishing performance measurement sessions, and therefore, TWAMP Light technology can be used for network testing.
[0004] In existing technologies, TWAMP Light testing includes source test devices and destination test devices. When using TWAMP Light technology for network testing, a test session is configured on the source test device (the basic parameters of the test session are the IP quadruple, namely the source IP address, destination IP address, UDP source port number, and UDP destination port number). The destination test device also needs to be configured with the same test session (i.e., the same IP quadruple) as the source device, and network testing is performed by sending and receiving test packets.
[0005] Specifically, the source device can send a test request message to the destination device. After receiving the test request message, the destination device generates a test response message and returns it to the source device, which then calculates the network performance parameters based on the test response message.
[0006] However, this approach also has some drawbacks. Since there may be multiple sessions in the device under test, the device needs to match the IP quadruple information of the test response message with the IP quadruple information of each session after receiving the test response message to determine the corresponding session. Because there is a lot of IP quadruple information, this approach will take a lot of time when there are a large number of sessions in the device under test, thus affecting the overall data forwarding performance of the test.
[0007] Furthermore, since each session corresponds to a different IP quadruple, a different UDP port number needs to be configured for each session. This will exacerbate UDP port number conflicts, causing abnormal sending and receiving of test packets, and thus leading to inaccurate test results. Summary of the Invention
[0008] In view of this, the purpose of this application is to provide a network testing method, apparatus, network device, and computer-readable storage medium to improve the overall data forwarding performance of the test, while reducing the occupation of UDP port resources, alleviating UDP port number conflicts, thereby ensuring the normal transmission and reception of test messages, and improving the accuracy of test results.
[0009] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows:
[0010] In a first aspect, this application provides a network testing method applied to a first network device, wherein the first network device is communicatively connected to a second network device, and multiple sessions based on the lightweight bidirectional active measurement protocol TWAMP Light are established between the first network device and the second network device, the method comprising:
[0011] Obtain the test response message sent by the second network device; the test response message is the response message corresponding to the test request message sent by the first network device to the second network device for any of the sessions;
[0012] If it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID is obtained from the test response message;
[0013] The target session corresponding to the test response message is determined from multiple sessions based on the session ID, and the test result corresponding to the target session is determined based on the timestamp information corresponding to the test response message.
[0014] In an optional implementation, after obtaining the test response message sent by the second network device, the method further includes:
[0015] Obtain UDP port setting information, and determine whether the UDP port number of the TWAMP Light-based session is set to a fixed port number based on the preset identifier in the UDP port setting information;
[0016] The step of obtaining the session ID from the test response message when the UDP port number of the TWAMP Light-based session is determined to be set to a fixed port number includes:
[0017] If the UDP port number of the TWAMP Light-based session is set to a fixed port number, determine whether the UDP port number of the test response message matches the fixed port number;
[0018] If the UDP port number of the test response message matches the fixed port number, then the session ID is obtained from the test response message.
[0019] In an optional implementation, the method further includes:
[0020] If it is determined that the UDP port number of the TWAMP Light-based session is not set to a fixed port number, then, based on the IP quadruple information of each session and the IP quadruple information of the test response message, if it is determined that there is a corresponding session for the test response message among multiple sessions, the format of the test response message is validated, and if the test response message passes the validation, the test result of the corresponding session is determined based on the timestamp information corresponding to the test response message.
[0021] In an optional implementation, the step of obtaining the session ID from the test response message includes:
[0022] The test response message is format-validated, and if the test response message passes the validation, the session ID is obtained from the fill field of the test response message.
[0023] The step of determining the target session corresponding to the test response message from multiple sessions based on the session ID, and determining the test result corresponding to the target session based on the timestamp information corresponding to the test response message, includes:
[0024] Based on the session ID, determine the target session corresponding to the test response message from among the multiple sessions, and determine whether the IP information of the test response message matches the IP information corresponding to the target session;
[0025] If the IP information of the test response message matches the IP information corresponding to the target session, the test result corresponding to the target session is determined based on the timestamp information corresponding to the test response message.
[0026] In an optional implementation, determining the test result corresponding to the target session based on the timestamp information corresponding to the test response message includes:
[0027] Obtain the receiving timestamp of the test response message, and obtain the sending timestamp of the test response message, the sending timestamp of the test request message corresponding to the test response message, and the receiving timestamp from the test response message.
[0028] The test result corresponding to the target session is determined based on the sending and receiving timestamps of the test response message and the sending and receiving timestamps of the test request message.
[0029] In an optional implementation, before the step of obtaining the test response message sent by the second network device, the method further includes:
[0030] Identify the session to be processed and construct the test request message corresponding to the session to be processed according to the preset communication protocol;
[0031] If the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID corresponding to the session to be processed is added to the padding field of the test request message.
[0032] The current time is added to the test request message as the sending timestamp, and the test request message is sent to the second network device according to the IP quadruple information corresponding to the session to be processed.
[0033] In an optional implementation, before the step of obtaining the test response message sent by the second network device, the method further includes:
[0034] Configure and save the UDP port of the TWAMP Light-based session as UDP port setting information. The UDP port setting information includes a preset identifier that indicates whether the UDP port number of the TWAMP Light-based session is set to a fixed port number.
[0035] Secondly, this application provides a network testing method applied to a second network device, the second network device being communicatively connected to a first network device, and the second network device and the first network device having established multiple sessions based on the lightweight bidirectional active measurement protocol TWAMP Light, the method comprising:
[0036] Obtain the test request message sent by the first network device for any of the sessions;
[0037] If it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID is obtained from the test request message;
[0038] Generate a test response message corresponding to the test request message based on the session ID, and send the test response message to the first network device.
[0039] In an optional implementation, the step of generating a test response message corresponding to the test request message based on the session ID and sending the test response message to the first network device includes:
[0040] If it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID is obtained from the test request message;
[0041] If, based on the session ID, it is determined that there is a target session corresponding to the test request message among multiple sessions, the current time is used as the sending timestamp of the test response message, and a test response message is generated based on the sending timestamp of the test response message, the receiving timestamp of the test request message, the sending timestamp of the test response message, and the session ID of the target session.
[0042] After encapsulating the header based on the IP quadtuple information of the target session, the test response message is sent to the first network device.
[0043] Thirdly, this application provides a network testing apparatus applied to a first network device, the first network device being communicatively connected to a second network device, and multiple sessions based on the Lightweight Bidirectional Active Measurement Protocol (TWAMP Light) being established between the first network device and the second network device, the apparatus comprising:
[0044] The acquisition module is used to acquire the test response message sent by the second network device; the test response message is the response message corresponding to the test request message sent by the first network device to the second network device for any of the sessions;
[0045] The acquisition module is further configured to acquire the session ID from the test response message when it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number;
[0046] The testing module is used to determine the target session corresponding to the test response message from multiple sessions based on the session ID, and to determine the test result corresponding to the target session based on the timestamp information corresponding to the test response message.
[0047] Fourthly, this application provides a network testing apparatus applied to a second network device, the second network device being communicatively connected to a first network device, and the second network device and the first network device having established multiple sessions based on the lightweight bidirectional active measurement protocol TWAMP Light, the apparatus comprising:
[0048] The receiving module is used to acquire the test request message sent by the first network device for any of the sessions;
[0049] The processing module, upon determining that the UDP port number of the TWAMP Light-based session is set to a fixed port number, obtains the session ID from the test request message; and generates a test response message corresponding to the test request message based on the session ID.
[0050] The sending module is used to send the test response message to the first network device.
[0051] Fifthly, this application provides a network device including a processor and a memory, the memory storing a computer program executable by the processor, the processor being able to execute the computer program to implement the method described in any of the foregoing embodiments.
[0052] In a sixth aspect, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any of the foregoing embodiments.
[0053] The network testing method, apparatus, network device, and computer-readable storage medium provided in this application embodiment allow a first network device to acquire test response messages sent by a second network device. If the UDP port number of the TWAMP Light-based session is set to a fixed port number, the first network device obtains a session ID from the test response message. Based on this session ID, it determines the target session corresponding to the test response message from multiple sessions and determines the test result corresponding to the target session based on the timestamp information of the test response message. In this method, the TWAMP Light-based session can be set to a fixed UDP port number, thus reducing the occupation of UDP port resources, alleviating UDP port number conflicts, ensuring normal transmission and reception of test messages, and improving the accuracy of test results. Furthermore, this method can determine the target session corresponding to the test response message from multiple sessions using only the session ID, thus reducing matching time and improving the overall data forwarding performance of the test.
[0054] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0055] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0056] Figure 1 A block diagram of the communication system is shown;
[0057] Figure 2 A block diagram of a network device provided in an embodiment of this application is shown;
[0058] Figure 3 This paper illustrates a flowchart of a network testing method provided in an embodiment of this application.
[0059] Figure 4 A schematic diagram of the test request message format is shown;
[0060] Figure 5 This paper illustrates another flowchart of the network testing method provided in an embodiment of this application;
[0061] Figure 6 A schematic diagram of the test response message format is shown;
[0062] Figure 7 This invention illustrates a functional block diagram of a network testing apparatus provided in an embodiment of this application;
[0063] Figure 8 Another functional block diagram of the network testing apparatus provided in this application embodiment is shown.
[0064] Icons: 10-First network device; 20-Second network device; 100-Memory; 110-Processor; 120-Communication module; 200-Acquisition module; 210-Test module; 300-Receiving module; 310-Processing module; 320-Transmitting module. Detailed Implementation
[0065] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can be arranged and designed in various different configurations.
[0066] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0067] It should be noted that relational terms such as “comprise” and “inclusive” are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase “comprising one…” does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.
[0068] Figure 1 For a block diagram of the communication system, please refer to [link / reference]. Figure 1 The communication system includes a first network device 10 and a second network device 20, which are communicatively connected.
[0069] Optionally, multiple sessions based on the Lightweight Bidirectional Active Measurement Protocol (TWAMP Light) are established between the first network device and the second network device. That is, corresponding sessions are set up in both the first and second network devices, which can be used to perform network testing between the first and second network devices.
[0070] In this embodiment, each session can be assigned a session ID. Understandably, this session ID can uniquely identify a session.
[0071] Optionally, the first network device refers to the device that initiates a network test for any session, and the second network device refers to the device that responds to the network test.
[0072] In this embodiment, any network device can be used as a first network device for network testing, or as a second network device for network testing.
[0073] Furthermore, Figure 2 Please refer to the block diagram of the network device provided in the embodiments of this application. Figure 2The network device includes a memory 100, a processor 110, and a communication module 120. The memory 100, processor 110, and communication module 120 are electrically connected directly or indirectly to enable data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines.
[0074] The memory 100 is used to store computer programs or data that can be executed by the processor. The memory 100 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0075] The processor 110 is used to read / write data or computer programs stored in the memory, and execute the computer program to implement the network testing method provided in the embodiments of this application.
[0076] The communication module 120 is used to establish a communication connection between the network device and other communication terminals through the network, and to send and receive data through the network.
[0077] Understandably, the network device can be Figure 1 The first network device in the process can also be Figure 2 The second network device in the system. It should be understood that... Figure 2 The structure shown is only a schematic diagram of a network device; the network device may also include components that are larger than those shown. Figure 2 The more or fewer components shown, or having the same Figure 2 The different configurations shown. Figure 2 The components shown can be implemented using hardware, software, or a combination thereof.
[0078] The following is based on the above. Figure 1 The first network device in this application is the executing entity. The network testing method provided in this embodiment is illustrated with reference to a flowchart. Specifically, Figure 3 For a flowchart illustrating a network testing method provided in an embodiment of this application, please refer to [link / reference]. Figure 3 The method includes:
[0079] Step S20: Obtain the test response message sent by the second network device.
[0080] Optionally, the test response message is the response message corresponding to the test request message sent by the first network device to the second network device for any session.
[0081] In this embodiment, the first network device can first generate a test request message corresponding to any session and send the message to the corresponding second network device. Then, the second network device can generate a test response message corresponding to the test request message and send the test response message to the first network device.
[0082] Step S21: If it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, obtain the session ID from the test response message.
[0083] In this embodiment, in order to avoid modifying the existing protocol standard message format and simplify the protocol processing, the test response message information will carry the session ID when the UDP port number of the TWAMP Light-based session is set to a fixed port number in the network device.
[0084] As is understandable, using a fixed UDP port number for a TWAMP Light session means that, regardless of whether it's the first or second network device, the UDP source port in the IP quadruple of all configured TWAMP Light sessions is a fixed preset port number (e.g., 1001), and the UDP destination port is also a fixed preset port number (e.g., 1002). The same fixed UDP source port and the same fixed UDP destination port number are used regardless of which network device the TWAMP Light session is established with, and this is consistent across all devices.
[0085] Step S22: Determine the target session corresponding to the test response message from multiple sessions based on the session ID, and determine the test result corresponding to the target session based on the timestamp information corresponding to the test response message.
[0086] Optionally, the first network device can determine the target session corresponding to the test response message from multiple sessions based on the session ID by ID matching.
[0087] Understandably, compared to existing technologies that require matching IP quadruple information with the IP quadruple information of each session to determine the corresponding session, matching using only the session ID parameter can significantly reduce time consumption, thereby improving the overall data forwarding performance of the test.
[0088] Optionally, the test results may include network performance parameters between the first network device and the second network device, such as bidirectional latency, jitter, packet loss rate, etc.
[0089] The network testing method provided in this application embodiment allows a first network device to obtain a test response message sent by a second network device. If the UDP port number of the TWAMP Light-based session is set to a fixed port number, the first device obtains the session ID from the test response message. Based on this session ID, it determines the target session corresponding to the test response message from multiple sessions and determines the test result corresponding to the target session based on the timestamp information of the test response message. In this method, the TWAMP Light-based session can be set to a fixed UDP port number, thus reducing the occupation of UDP port resources, alleviating UDP port number conflicts, ensuring normal transmission and reception of test messages, and improving the accuracy of test results. Furthermore, this method can determine the target session corresponding to the test response message from multiple sessions using only the session ID, thus reducing matching time and improving the overall data forwarding performance of the test.
[0090] Optionally, before conducting network testing, it is necessary to set up a network testing environment on the first and second network devices, that is, to configure relevant parameters and generate a TWAMP Light-based session.
[0091] In one possible implementation, to facilitate session generation and subsequent network testing, the first and second network devices can first configure UDP port settings.
[0092] In this embodiment, the UDP port of the TWAMP Light session can be configured and saved as UDP port setting information.
[0093] Optionally, the UDP port setting information may include a preset identifier indicating whether the UDP port number of the TWAMP Light-based session is set to a fixed port number.
[0094] Understandably, the fixed UDP port number here refers to both the UDP source port number and the UDP destination port number being fixed.
[0095] Optionally, the UDP port settings may also include a default UDP port number. Understandably, this default UDP port number refers to a fixed port number for a TWAMP Light-based session.
[0096] In one possible implementation, if the UDP port number of the TWAMP Light-based session is set to a fixed port number, the default flag can be 1; if the UDP port number of the TWAMP Light-based session is not set to a fixed port number, the default flag can be 0.
[0097] This application embodiment can configure the UDP port of a TWAMP Light-based session, thereby setting whether the UDP port number of the session is a fixed port number. This can improve the application flexibility of TWAMP Light-based sessions to adapt to the interconnection between devices from different manufacturers.
[0098] Optionally, after configuring the UDP port for the TWAMP Light-based session, the first and second network devices can generate a TWAMP Light-based session.
[0099] In this embodiment, the first network device and the second network device can first create a session based on TWAMP Light and generate a session ID corresponding to the session according to a preset rule. Then, they can obtain the UDP port setting information. If the preset identifier in the UDP port setting information indicates that the UDP port number of the session is set to a fixed port number, then the IP quadruple information is configured for the session according to the preset IP information and the preset UDP port number.
[0100] Understandably, the first and second network devices can create multiple sessions based on actual testing needs.
[0101] Optionally, the preset rules can be set according to the actual application, such as being generated randomly or sequentially according to a certain pattern.
[0102] It should be noted that for a given network test session, the session ID in the first network device and the session ID in the second network device should be consistent.
[0103] Optionally, after generating the session ID, if the preset identifier in the UDP port setting information represents the UDP port number of the session as a fixed port number, then the first network device and the second network device can set the preset UDP port number as the UDP port information in the IP quadruple information of the session.
[0104] Understandably, the preset UDP port number includes the preset UDP source port number and the preset UDP destination port number.
[0105] Optionally, the preset IP information includes source IP information and destination IP information, wherein the source IP information refers to the IP information of the first network device and the destination IP information refers to the IP information of the second network device.
[0106] Understandably, for a network test, the IP information in the session of the first network device matches the IP information in the session of the second network device, and the UDP port number in the session of the first network device matches the UDP port number in the session of the second network device.
[0107] Specifically, for a session, the source IP information and UDP source port number contained therein are the IP information and UDP port number of the first network device, and the destination IP information and UDP destination port number are the IP information and UDP port number of the second network device.
[0108] For example, if the source IP information in the session of the first network device is x and the destination IP information is y, then the source IP information in the session of the second network device is also x and the destination IP information is y; if the UDP source port number in the session of the first network device is m and the UDP destination port number is n, then the UDP source port number in the session of the second network device is m and the UDP destination port number is n.
[0109] Optionally, if the preset identifier indicates that the UDP port number fixing function is not enabled, the first network device and the second network device can allocate UDP information for the session according to the preset allocation rules to generate IP quadruple information for the session.
[0110] Optionally, the session can be determined after generating a session ID and IP quadruple information for the created session.
[0111] In this embodiment, in order to manage multiple sessions, the first network device and the second network device may also be configured with a session list. Based on this, the first network device and the second network device can add the session and the session ID corresponding to the session to the session list after a session is generated.
[0112] Optionally, as the first network device, it can also determine the pending sessions to be started from the session list according to actual needs.
[0113] In one possible implementation, the corresponding sessions can be started sequentially according to their order of arrangement, or the pending sessions to be started can be determined according to their priority.
[0114] Optionally, after determining the pending session to be started, the first network device may read preset startup parameters to configure the sending parameters of the session.
[0115] Optionally, the sending parameters include the time interval for sending test request messages, the duration or number of test request messages sent, and the timeout period for waiting for test response messages.
[0116] Understandably, for a network test, the first network device may send multiple test request messages and thus receive multiple test response messages to calculate the test results.
[0117] In this embodiment, the first network device can configure the session to be started after configuring the session's sending parameters, and then generate and send the corresponding test request message according to the sending parameters.
[0118] The following section provides a possible approach for generating and sending test request messages.
[0119] Specifically, the first network device can first determine the session to be processed, construct a test request message corresponding to the session to be processed according to a preset communication protocol, and, if it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, add the session ID corresponding to the session to be processed to the fill field of the test request message.
[0120] Optionally, the first network device can determine whether the UDP port number of the TWAMPLight-based session is set to a fixed port number based on a preset identifier in the UDP port setting information.
[0121] Optionally, if the UDP port number of the session is set to a fixed port number, the first network device can add the session ID corresponding to the session to be processed to the test request message.
[0122] In this embodiment, since the message protocol is not modified and the padding field of the test request message is randomly filled with data, the first network device can add the session ID to the padding field of the test request message, for example, by adding it to the first two bytes of the padding field.
[0123] Optionally, to facilitate the subsequent determination of test results, the first network device may also add the current time as the sending timestamp of the test request message to the test request message, and then send the test request message to the second network device according to the IP quadruple information corresponding to the session to be processed.
[0124] In this embodiment, if the UDP port number of the session is not set to a fixed port number, the session ID is not added to the test request message. Instead, the current time is added to the test request message as the sending time of the test request message.
[0125] In one example Figure 4 For a schematic diagram of the test request message format, please refer to [link / reference]. Figure 4The test request message can include four fields: Sequence Number, Timestamp, Error Estimate, and Packet Padding. Sequence Number is the message sending sequence number, Timestamp is the timestamp when the message was sent, Error Estimate is the estimation error, and Packet Padding is the padding field.
[0126] In this example, the first network device can generate Sequence Number, Error Estimate, and Packet Padding according to a preset communication protocol, and fill these fields into the test request message. Then, if the UDP port number of the session is set to a fixed port number, the session ID corresponding to the session to be processed is added to the first two bytes of PacketPadding. Finally, the current time is used as the sending time and filled into the Timestamp field of the test request message.
[0127] In this example, if the UDP port number of the session is not set to a fixed port number, the current time is directly used as the sending time and filled into the Timestamp field of the test request message.
[0128] In this example, the first network device can encapsulate the test request packet with UDP and IP headers based on the IP four-tuple information of the session to be processed, and then send the test request packet to the second network device.
[0129] Optionally, the second network device may process the received test request message accordingly, generate a test response message corresponding to the test request message, and send the test response message to the first network device.
[0130] Optionally, after receiving the test response message sent by the second network device, the first network device needs to obtain the UDP port setting information and determine whether the UDP port number of the TWAMPLight-based session is set to a fixed port number according to the preset identifier in the UDP port setting information.
[0131] In this embodiment, if the UDP port number of the session is set to a fixed port number, the first network device can determine whether the UDP port number of the test response message matches the fixed port number. If they match, the session ID is obtained from the test response message for subsequent operations.
[0132] Understandably, if the UDP port number of a session based on TWAMP Light is set to a fixed port number, then the UDP port number of the test response message returned by the second network device based on the test request message should match the fixed preset UDP port number.
[0133] In this embodiment, if the UDP port number of the TWAMP Light-based session is a fixed port number, but the UDP port number of the packet does not match the preset UDP port number, the test response packet may have a sending error. Therefore, the first network device can send the packet to the system packet receiving module for processing.
[0134] Optionally, if the UDP port number of the TWAMP Light-based session is not set to a fixed port number, the first network device needs to determine whether there is a corresponding session for the test response message among multiple sessions based on the IP quadruple information of each session and the IP quadruple information of the test response message.
[0135] In this embodiment, if the first network device determines that a corresponding session for the test response message exists among multiple sessions, it can perform format verification on the test response message, and if the test response message passes verification, it can determine the test result of the corresponding session based on the timestamp information corresponding to the test response message. Optionally, if no corresponding session for the test response message exists among multiple sessions, the first network device can send the test response message to the system packet receiving module for processing.
[0136] Optionally, the first network device may validate the field format of the test response message. For example, if the MBZ field in the test response message must be 0, the first network device can validate the field format by determining the value of this field.
[0137] Optionally, if the test response message fails verification, it indicates that the test response message may have encountered an error during its generation or transmission, and therefore the test response message can be discarded.
[0138] In this embodiment, when the UDP port numbers of multiple sessions are set to fixed port numbers, the first network device also needs to verify the message format of the test response message before obtaining the session ID.
[0139] Specifically, the first network device can perform format verification on the test response message, and if the test response message passes the verification, obtain the session ID from the fill field of the test response message.
[0140] Optionally, the first network device may validate the field format of the test response message. For example, if the MBZ field in the response message must be 0, the first network device can validate the field format by determining the value of this field.
[0141] Optionally, if the test response message fails verification, it indicates that the test response message may have encountered an error during its generation or transmission, and therefore the test response message can be discarded.
[0142] Optionally, if the test response message passes verification, the first network device may obtain the session ID, determine the target session corresponding to the test response message from multiple sessions based on the session ID, and determine whether the IP information of the test response message matches the IP information corresponding to the target session.
[0143] Understandably, if the IP information in the test response message matches the IP information corresponding to the target session, the first network device can determine the test result corresponding to the target session based on the timestamp information corresponding to the test response message.
[0144] Optionally, considering the possibility that a session may be accidentally deleted, the first network device may not be able to find the target session corresponding to the test response message from multiple sessions based on the session ID. In this case, the test response message can be discarded.
[0145] Furthermore, considering the possibility of incorrect target session identification, the first network device also needs to determine whether the IP information of the test response message matches the IP information corresponding to the target session after obtaining the target session.
[0146] Understandably, if the IP information in the test response message does not match the IP information corresponding to the target session, the test response message will be discarded.
[0147] Optionally, the timestamp information corresponding to the test response message may include the reception time of the test response message received by the first network device, as well as the timestamp information recorded in the test response message.
[0148] The following section provides a possible implementation method for determining the test result corresponding to the target session based on the timestamp information of the test response message.
[0149] Specifically, the first network device can obtain the receiving timestamp of the test response message, and obtain the sending timestamp of the test response message, the sending timestamp and receiving timestamp of the test request message corresponding to the test response message from the test response message. Then, based on the sending timestamp and receiving timestamp of the test response message and the sending timestamp and receiving timestamp of the test request message, the test result corresponding to the target session is determined.
[0150] Optionally, the timestamp of the test response message refers to the time when the first network device determines that the received message is a test response message.
[0151] In this embodiment, the first network device can calculate performance parameters such as bidirectional latency, jitter, and packet loss rate between the first network device and the second network device based on the sending and receiving timestamps of the test response message and the sending and receiving timestamps of the test request message.
[0152] The following is based on the above. Figure 1 The second network device in this application is the executing entity. The network testing method provided in this embodiment is illustrated with reference to the flowchart. Specifically, Figure 5 For another flowchart illustrating the network testing method provided in this application embodiment, please refer to [link / reference]. Figure 5 The method includes:
[0153] Step S30: Obtain the test request message sent by the first network device for any session.
[0154] Step S31: If the UDP port number of the TWAMP Light-based session is set to a fixed port number, obtain the session ID from the test request message; generate the test response message corresponding to the test request message.
[0155] Step S32: Send the test response message to the first network device.
[0156] In this embodiment, after the second network device sends the test response message to the first network device, the first network device can obtain the session ID from the test response message if it determines that the UDP port number of the TWAMP Light-based session is set to a fixed port number. Based on the session ID, the first network device can determine the target session corresponding to the test response message from multiple sessions and determine the test result corresponding to the target session based on the timestamp information corresponding to the test response message.
[0157] Optionally, after receiving the test request message sent by the first network device, the second network device can first obtain the UDP port setting information and determine whether the UDP port number of the TWAMP Light-based session is set to a fixed port number according to the preset identifier in the UDP port setting information.
[0158] In this embodiment, if the UDP port number of the TWAMP Light-based session is set to a fixed port number, the second network device can obtain the session ID from the test request message if the UDP port number of the test request message matches the preset UDP port number in the UDP port setting information.
[0159] Understandably, if the UDP port number of the test request message does not match the preset UDP port number in the UDP port settings, the second network device can send the test request message to the system packet receiving module for processing.
[0160] In this embodiment, if the UDP port number of the TWAMP Light-based session is not set to a fixed port number, the second network device can determine whether there is a corresponding session for the test request message among multiple sessions based on the IP quadruple information of each session and the IP quadruple information of the test request message.
[0161] Understandably, if a corresponding session for the test request message does not exist among multiple sessions, the second network device can send the test request message to the system packet receiving module for processing. Optionally, if the UDP port number of the test request message matches the preset UDP port number in the UDP port settings, the second network device can generate its corresponding test response message and send it to the first network device.
[0162] Specifically, in this case, the second network device can perform format verification on the test request message, and construct a test response message if the test request message passes the verification.
[0163] Optionally, before obtaining the session ID, the second network device also needs to verify the message format of the test request message. The specific verification method is the same as the verification method of the first network device for the test response message, and this application will not elaborate on this further.
[0164] Understandably, the second network device can obtain the session ID from the test request message if the message format verification passes.
[0165] In one possible implementation, the second network device can obtain the session ID from the padding field of the test request message.
[0166] In one possible implementation, the session ID is located in the first two bytes of the padding field in the test request message. The second network device can then obtain the first two bytes of the padding field and use them as the session ID.
[0167] Optionally, if the test request message fails verification, the test request message can be discarded.
[0168] In this embodiment, the second network device can also use the current time as the sending timestamp of the test response message when it is determined that there is a target session corresponding to the test request message in multiple sessions based on the session ID, and generate the test response message based on the sending timestamp of the test response message, the receiving timestamp of the test request message, the sending timestamp of the test response message, and the session ID of the target session.
[0169] Optionally, after obtaining the session ID, the second network device can first determine whether a corresponding session exists among multiple sessions based on the session ID. If it does exist, it can then determine whether the IP information of the test request message matches the IP information of that session.
[0170] In this embodiment, if the IP information of the test request message matches the IP information of the session corresponding to the test request message, the session can be determined to be the target session corresponding to the test request message. At this time, the second network device can first construct the test response message corresponding to the test request message according to the preset communication protocol and the test request message.
[0171] Optionally, if there is no session corresponding to the test request message among multiple sessions, or if the IP information of the test request message does not match the IP information of the session corresponding to the test request message, it can be determined that the target session corresponding to the test request message cannot be obtained, and therefore the second network device can discard the test request message.
[0172] Optionally, when constructing the test response message corresponding to the test request message, the second network device may copy some information from the test request message to the test response message and generate other field information according to the protocol specification.
[0173] In this embodiment, the second network device may also use the current time as the sending timestamp of the test response message, add the receiving timestamp of the test request message, the sending timestamp of the test response message, and the session ID of the target session to the test response message, and encapsulate the header according to the IP quadruple information of the target session before sending the test response message to the first network device.
[0174] In one example Figure 6 For a schematic diagram of the TWAMP Light test response message format, please refer to [link / reference]. Figure 6 The test response message may include the following fields: Sequence Number, Timestamp, Error Estimate, MBZ, Receive Timestamp, Sender Sequence Number, Sender Timestamp, Sender Error Estimate, Sender TTL, and Packet Padding.
[0175] Wherein, Sequence Number is the message sending sequence number, Timestamp is the timestamp when the test response message was sent, Error Estimate is the error estimate, MBZ must be zero, its value must be 0, ReceiveTimestamp is the timestamp when the test request message was received, Sender Sequence Number is the sequence number of the test request message, and this value is copied from the Sequence Number field in the corresponding test request message, Sender Timestamp is the timestamp in the test request message, and this value is copied from the Timestamp field in the corresponding test request message, SenderError Estimate is the error estimate in the test request message, and this value is copied from the Error Estimate field in the corresponding test request message, Sender TTL is the TTL in the test request message, and this value is copied from the TTL field in the IP header of the corresponding test request message, and Packet Padding is the packet padding field, which is randomly filled with data.
[0176] In this example, when constructing the test response message, the second network device can first fill in the corresponding values for the Sequence Number, Error Estimate, MBZ, and Packet Padding fields of the test response message according to the protocol specifications. It can also fill in the Receive Timestamp field with the time when it is determined that the received message is a test request message. The Sequence Number, Timestamp, and Error Estimate fields in the test request message are copied and filled into the Sender Sequence Number, Sender Timestamp, and Sender Error Estimate fields, respectively. Finally, the TTL field in the IP header of the test request message is copied and filled into the Sender TTL field.
[0177] In this example, if it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, the second network device can write the session ID of the target session into the first two bytes of the padding field of the test response message.
[0178] Understandably, if the UDP port number of a TWAMP Light-based session is not set to a fixed port number, then a session ID will not be added to the test response message.
[0179] In this example, the second network device can also fill the Timestamp field with the current time as the sending time of the test response message. Then, based on the IP four-tuple information of the target session, it encapsulates the test response message with UDP and IP headers and sends the test response message to the corresponding first network device so that the first network device can process the test response message and obtain the corresponding test result.
[0180] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of a network testing device is given below. Optionally, the network testing device can adopt the above-described... Figure 2 The device structure of the network device is shown.
[0181] Further, please refer to Figure 7 , Figure 7 This is a functional block diagram of a network testing device applied to a first network device, provided in an embodiment of this application. It should be noted that the network testing device provided in this embodiment has the same basic principle and technical effects as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The network testing device includes: an acquisition module 200 and a testing module 210.
[0182] The acquisition module 200 is used to acquire the test response message sent by the second network device; the test response message is the response message corresponding to the test request message sent by the first network device to the second network device for any session.
[0183] Understandably, the acquisition module 200 can also be used to perform the above step S20.
[0184] The acquisition module 200 is also used to obtain the session ID from the test response message if it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number.
[0185] Understandably, the acquisition module 200 can also be used to perform the above step S21.
[0186] The test module 210 is used to determine the target session corresponding to the test response message from multiple sessions based on the session ID, and to determine the test result corresponding to the target session based on the timestamp information corresponding to the test response message.
[0187] Understandably, the test module 210 can also be used to perform the above step S22.
[0188] Optionally, the acquisition module 200 is also used to acquire UDP port setting information and determine whether the UDP port number of the TWAMP Light-based session is set to a fixed port number based on the preset identifier in the UDP port setting information.
[0189] Optionally, the acquisition module 200 is further configured to determine whether the UDP port number of the test response message matches the fixed port number if the UDP port number of the TWAMP Light-based session is set to a fixed port number; if the UDP port number of the test response message matches the fixed port number, then the session ID is obtained from the test response message.
[0190] Optionally, the test module 210 is further configured to, if it is determined that the UDP port number of the TWAMP Light-based session is not set to a fixed port number, perform format verification on the test response message when it is determined that there is a corresponding session for the test response message among multiple sessions based on the IP quadruple information of each session and the IP quadruple information of the test response message, and determine the test result of the corresponding session based on the timestamp information corresponding to the test response message if the test response message verification passes.
[0191] Optionally, the acquisition module 200 is also used to perform format verification on the test response message, and if the test response message passes the verification, to obtain the session ID from the fill field of the test response message.
[0192] Optionally, the test module 210 is further configured to determine the target session corresponding to the test response message from multiple sessions based on the session ID, and to determine whether the IP information of the test response message matches the IP information corresponding to the target session; if the IP information of the test response message matches the IP information corresponding to the target session, the test result corresponding to the target session is determined based on the timestamp information corresponding to the test response message.
[0193] Optionally, the test module 210 is further configured to obtain the receiving timestamp of the test response message, and obtain the sending timestamp of the test response message, the sending timestamp of the test request message corresponding to the test response message, and the receiving timestamp of the test request message from the test response message; and determine the test result corresponding to the target session based on the sending timestamp and receiving timestamp of the test response message, and the sending timestamp and receiving timestamp of the test request message.
[0194] Optionally, the network testing device also includes a transmission module.
[0195] The sending module is used to determine the session to be processed, construct the test request message corresponding to the session to be processed according to the preset communication protocol; when it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID corresponding to the session to be processed is added to the padding field of the test request message; the current time is added to the test request message as the sending timestamp of the test request message, and the test request message is sent to the second network device according to the IP quadruple information corresponding to the session to be processed.
[0196] Optionally, Figure 8 A functional block diagram of a network testing apparatus applied to a second network device provided in an embodiment of this application is shown below. Figure 8 The network testing device includes a receiving module 300, a processing module 310, and a sending module 320.
[0197] The receiving module 300 is used to acquire test request messages sent by the first network device for any session.
[0198] Understandably, the receiving module 300 can also be used to perform the above step S30.
[0199] The processing module 310 is used to obtain the session ID from the test request message when it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number; and to generate a test response message corresponding to the test request message based on the session ID.
[0200] Understandably, the processing module 310 can also be used to perform the above step S31.
[0201] The sending module 320 is used to send the test response message to the first network device.
[0202] Understandably, the sending module 320 can also be used to perform the above step S32.
[0203] Optionally, the sending module 320 is further configured to, when determining that a target session corresponding to a test request message exists among multiple sessions based on the session ID, use the current time as the sending timestamp of the test response message, and generate a test response message based on the sending timestamp of the test response message, the receiving timestamp of the test request message, the sending timestamp of the test response message, and the session ID of the target session; and send the test response message to the first network device after encapsulating the header based on the IP four-tuple information of the target session.
[0204] Optionally, the above modules can be stored in the form of software or firmware. Figure 2The memory shown is either stored in or embedded in the operating system (OS) of the network device, and can be used by... Figure 2 The processor executes the commands. Meanwhile, the data and program code required to execute these modules can be stored in memory.
[0205] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, can implement the network testing method provided in this application.
[0206] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0207] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0208] If a function is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0209] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A network testing method, characterized in that, The method, applied to a first network device, which is communicatively connected to a second network device, and which establishes multiple sessions based on the lightweight bidirectional active measurement protocol TWAMP Light between the first and second network devices, includes: Obtain the test response message sent by the second network device; the test response message is the response message corresponding to the test request message sent by the first network device to the second network device for any of the sessions; If it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID is obtained from the test response message; The target session corresponding to the test response message is determined from multiple sessions based on the session ID, and the test result corresponding to the target session is determined based on the timestamp information corresponding to the test response message.
2. The method according to claim 1, characterized in that, After obtaining the test response message sent by the second network device, the method further includes: Obtain UDP port setting information, and determine whether the UDP port number of the TWAMPLight-based session is set to a fixed port number based on the preset identifier in the UDP port setting information; The step of obtaining the session ID from the test response message when the UDP port number of the TWAMP Light-based session is determined to be set to a fixed port number includes: If the UDP port number of the TWAMP Light-based session is set to a fixed port number, determine whether the UDP port number of the test response message matches the fixed port number; If the UDP port number of the test response message matches the fixed port number, then the session ID is obtained from the test response message.
3. The method according to claim 2, characterized in that, The method further includes: If it is determined that the UDP port number of the TWAMP Light-based session is not set to a fixed port number, then, based on the IP quadruple information of each session and the IP quadruple information of the test response message, if it is determined that there is a corresponding session for the test response message among multiple sessions, the format of the test response message is validated, and if the test response message passes the validation, the test result of the corresponding session is determined based on the timestamp information corresponding to the test response message.
4. The method according to claim 1, characterized in that, The step of obtaining the session ID from the test response message includes: The test response message is format-validated, and if the test response message passes the validation, the session ID is obtained from the fill field of the test response message. The step of determining the target session corresponding to the test response message from multiple sessions based on the session ID, and determining the test result corresponding to the target session based on the timestamp information corresponding to the test response message, includes: Based on the session ID, determine the target session corresponding to the test response message from among the multiple sessions, and determine whether the IP information of the test response message matches the IP information corresponding to the target session; If the IP information of the test response message matches the IP information corresponding to the target session, the test result corresponding to the target session is determined based on the timestamp information corresponding to the test response message.
5. The method according to claim 1, characterized in that, Determining the test result corresponding to the target session based on the timestamp information corresponding to the test response message includes: Obtain the receiving timestamp of the test response message, and obtain the sending timestamp of the test response message, the sending timestamp of the test request message corresponding to the test response message, and the receiving timestamp from the test response message. The test result corresponding to the target session is determined based on the sending and receiving timestamps of the test response message and the sending and receiving timestamps of the test request message.
6. The method according to any one of claims 1-5, characterized in that, Before the step of obtaining the test response message sent by the second network device, the method further includes: Identify the session to be processed and construct the test request message corresponding to the session to be processed according to the preset communication protocol; If the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID corresponding to the session to be processed is added to the padding field of the test request message. The current time is added to the test request message as the sending timestamp, and the test request message is sent to the second network device according to the IP quadruple information corresponding to the session to be processed.
7. The method according to claim 1, characterized in that, Before the step of obtaining the test response message sent by the second network device, the method further includes: Configure and save the UDP port of the TWAMP Light-based session as UDP port setting information. The UDP port setting information includes a preset identifier that indicates whether the UDP port number of the TWAMP Light-based session is set to a fixed port number.
8. A network testing method, characterized in that, The method, applied to a second network device that is communicatively connected to a first network device and has established multiple sessions based on the lightweight bidirectional active measurement protocol TWAMP Light between the second and first network devices, includes: Obtain the test request message sent by the first network device for any of the sessions; If it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number, the session ID is obtained from the test request message; Generate a test response message corresponding to the test request message based on the session ID, and send the test response message to the first network device.
9. The method according to claim 8, characterized in that, The step of generating a test response message corresponding to the test request message based on the session ID and sending the test response message to the first network device includes: If, based on the session ID, it is determined that there is a target session corresponding to the test request message among multiple sessions, the current time is used as the sending timestamp of the test response message, and a test response message is generated based on the sending timestamp of the test response message, the receiving timestamp of the test request message, the sending timestamp of the test response message, and the session ID of the target session. After encapsulating the header based on the IP quadtuple information of the target session, the test response message is sent to the first network device.
10. A network testing device, characterized in that, An apparatus applied to a first network device, which is communicatively connected to a second network device, and which establishes multiple sessions based on the lightweight bidirectional active measurement protocol TWAMP Light between the first and second network devices, the apparatus comprising: The acquisition module is used to acquire the test response message sent by the second network device; the test response message is the response message corresponding to the test request message sent by the first network device to the second network device for any of the sessions; The acquisition module is further configured to acquire the session ID from the test response message when it is determined that the UDP port number of the TWAMP Light-based session is set to a fixed port number; The testing module is used to determine the target session corresponding to the test response message from multiple sessions based on the session ID, and to determine the test result corresponding to the target session based on the timestamp information corresponding to the test response message.
11. A network testing device, characterized in that, An apparatus for use in a second network device, which is communicatively connected to a first network device, and which establishes multiple sessions based on the lightweight bidirectional active measurement protocol TWAMP Light between the second and first network devices, comprising: The receiving module is used to acquire the test request message sent by the first network device for any of the sessions; The processing module, upon determining that the UDP port number of the TWAMP Light-based session is set to a fixed port number, obtains the session ID from the test request message; and generates a test response message corresponding to the test request message based on the session ID. The sending module is used to send the test response message to the first network device.
12. A network device, characterized in that, It includes a processor and a memory, the memory storing a computer program executable by the processor, the processor being able to execute the computer program to implement the method of any one of claims 1-7, or the method of any one of claims 8-9.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1-7, or the method according to any one of claims 8-9.
Citation Information
Patent Citations
Network performance measuring method, apparatus and system
CN106603333A
TWAMP session negotiation method, client, and server
CN107979619A