Method for measuring uplink rate of optical network unit (ONU)
By receiving user-state commands in kernel state and using selective confirmation and timing retransmission mechanisms, the problem of low efficiency and large error in ONU uplink rate measurement is solved, and efficient and accurate speed measurement is achieved.
Patent Information
- Application Number
- CN202311795759.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-22
- Publication Date
- 2025-07-01
AI Technical Summary
In the prior art, when measuring the uplink rate of the optical network unit ONU, multiple data copies are required from the user state to the kernel state, resulting in low speed measurement efficiency and large errors.
The speed measurement module in the kernel state is used to receive the speed measurement command of the speed measurement program in the user state, upload the speed measurement file based on the retransmission mechanism of selective confirmation and the timing retransmission mechanism to calculate the uplink rate of the ONU.
It improves the efficiency and accuracy of speed measurement, reduces the possibility of data packet loss, and realizes a simple and efficient speed measurement method.
Smart Images

Figure CN120238475A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of communications, and more specifically, to a method for measuring the upstream rate of an Optical Network Unit (ONU). Background Art
[0002] The upstream rate of an Optical Network Unit (ONU) refers to the speed at which data is transmitted from the local end to the server. Carriers need to upload a file of a certain size to a specified server to measure the actual upstream rate. Currently, the method for measuring the upstream rate of an ONU has been relatively mature. In related technologies, the method for measuring an ONU requires multiple copies from the user space to the kernel space. Even if there is no need to read files from the disk, it is difficult to avoid two copies after constructing the file itself, and the transmission path is relatively long. This will result in the measured value of the upstream rate meeting the error requirements at low bandwidth, but at high bandwidth, the data traffic is large, and the measured value of the program speed is far from the actual bandwidth. Summary of the Invention
[0003] Embodiments of the present application provide a method for measuring the upstream rate of an Optical Network Unit (ONU), so as to at least solve the problem in related technologies that the speed measurement efficiency is low and the error is large due to multiple data copies required from the user space to the kernel space when measuring the upstream rate of an ONU.
[0004] According to an embodiment of the present application, there is provided a method for measuring the upstream rate of an Optical Network Unit (ONU), which is applied to an ONU and includes: a speed measurement module in the kernel space receives a speed measurement command sent by a speed measurement program in the user space, where the speed measurement command includes configuration parameters for measuring the upstream rate of the ONU; the speed measurement module in the kernel space creates a speed measurement thread according to the configuration parameters and establishes a connection with a speed measurement server; the speed measurement module uploads a speed measurement file to the speed measurement server based on a selective acknowledgment retransmission mechanism and a timed retransmission mechanism, and calculates the upstream rate of the ONU according to the speed measurement time and the size of the uploaded speed measurement file.
[0005] According to another embodiment of the present application, there is further provided a system for measuring the upstream rate of an Optical Network Unit (ONU). The system for measuring the upstream rate of an Optical Network Unit (ONU) includes a speed measurement module, where the speed measurement module is used to receive a speed measurement command sent by a speed measurement program in the user space, where the speed measurement command includes configuration parameters for measuring the upstream rate of the ONU; the speed measurement module is further used to create a speed measurement thread according to the configuration parameters and establish a connection with a speed measurement server; the speed measurement module is further used to upload a speed measurement file to the speed measurement server based on a selective acknowledgment retransmission mechanism and a timed retransmission mechanism, and calculate the upstream rate of the ONU according to the speed measurement time and the size of the uploaded speed measurement file.
[0006] According to another embodiment of the present application, there is also provided a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in the above method embodiment when running.
[0007] According to another embodiment of the present application, there is also provided an electronic device including a memory and a processor, where the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in the above method embodiment.
[0008] Through the embodiments of the present application, since the speed measurement program in the user mode sends a command to measure the upstream rate of the ONU to the speed measurement module in the kernel mode, and the command includes adjustable configuration parameters for speed measurement, the speed measurement module can create a speed measurement thread according to the received configuration parameters. To avoid the problem of possible packet loss in the case of large data traffic after the start of speed measurement, the speed measurement module uploads the speed measurement file based on the selective acknowledgment retransmission mechanism and the timed retransmission mechanism, ensuring the accuracy of the upstream rate of the ONU determined according to the speed measurement time and the size of the uploaded speed measurement file. Therefore, it is possible to solve the problem in the related art that the speed measurement efficiency is low and the error is large due to multiple data copies required from the user mode to the kernel mode when measuring the upstream rate of the ONU, and thus achieve the technical effect of simple and efficient implementation of the method of sending a speed measurement command by the speed measurement program in the user mode and performing speed measurement by the speed measurement module in the kernel mode. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 is a hardware structure block diagram of a computer terminal for a method of measuring the upstream rate of an optical network unit (ONU) according to an embodiment of the present application;
[0010] Figure 2 is a network architecture diagram of a method of measuring the upstream rate of an optical network unit (ONU) according to an embodiment of the present application;
[0011] Figure 3 is a flowchart of a method of measuring the upstream rate of an optical network unit (ONU) according to an embodiment of the present application;
[0012] Figure 4 is a flowchart of a method of measuring the upstream rate of an optical network unit (ONU) according to another embodiment of the present application;
[0013] Figure 5 is a flowchart of a method of measuring the upstream rate of an optical network unit (ONU) according to another embodiment of the present application;
[0014] Figure 6 is a flowchart of a method of measuring the upstream rate of an optical network unit (ONU) according to another embodiment of the present application;
[0015] Figure 7 It is a schematic diagram of the speed measurement result of the conventional method for measuring the upstream rate of an optical network unit (ONU).
[0016] Figure 8 It is a schematic diagram of the speed measurement result of the method for measuring the upstream rate of an optical network unit (ONU) according to an embodiment of the present application. Detailed implementation manners
[0017] In the following, embodiments of the present application will be described in detail with reference to the accompanying drawings and in conjunction with the embodiments.
[0018] It should be noted that the terms "first", "second", etc. in the specification, claims and above-mentioned drawings of the present application are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence.
[0019] The method embodiments provided in the embodiments of the present application can be executed on a mobile terminal, a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 It is a hardware structure block diagram of a computer terminal for a method of measuring the upstream rate of an optical network unit (ONU) according to an embodiment of the present application. As Figure 1 shown, the computer terminal may include one or more ( Figure 1 only one is shown in Figure 1 a processor 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a field programmable gate array FPGA) and a memory 104 for storing data. Among them, the above computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown in Figure 1 is only schematic and does not limit the structure of the above computer terminal. For example, the computer terminal may further include more or fewer components than
[0020] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for measuring the upstream rate of the optical network unit (ONU) in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the computer terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.
[0021] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of a computer terminal. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0022] The embodiments of the present application can run on Figure 2 the network architecture shown. In this network architecture, the user-mode program configures parameters to the speed measurement thread of the speed measurement module through the ioctl (device control) of the character device. The speed measurement module is connected to the speed measurement server and can send a request message for uploading a file to the server.
[0023] The improved self-developed protocol stack in this network architecture simplifies the linux kernel standard protocol stack and is responsible for implementing the upload of files. The speed measurement module also provides two hook functions, including the Ethernet driver RECV_HOOK function and the WAN bridge SEND_HOOK function, which are respectively mounted on the Ethernet driver and the xpon wan bridge module, and are used to parse the messages received by the optical network unit and the messages sent by the optical network unit and upload them to the Passive Optical Network (PON).
[0024] In this embodiment, a method for measuring the upstream rate of the optical network unit (ONU) running on the above-mentioned computer terminal or network architecture is provided. Figure 3 It is a flowchart of the method for measuring the upstream rate of the optical network unit (ONU) according to the embodiments of the present application, as Figure 3 shown. The process includes the following steps:
[0025] Step S302: The speed measurement module in the kernel state receives the speed measurement command sent by the speed measurement program in the user state. Among them, the speed measurement command includes configuration parameters for measuring the upstream rate of the ONU.
[0026] It should be noted that to apply to the speed measurement scenarios of multiple ONUs, the configuration parameters in the speed measurement command can be adjusted according to the actual situation.
[0027] In step S302 of this embodiment, it includes: the speed measurement program parses the speed measurement command to obtain the configuration parameters; the character device of the speed measurement module receives the speed measurement command and the configuration parameters sent by the speed measurement program.
[0028] In an exemplary embodiment of the present application, the character device of the speed measurement module receives the speed measurement command and the configuration parameters through ioctl (device control). After the speed measurement module completes the configuration, it receives the notification sent by the user state program to notify the speed measurement module to start speed measurement.
[0029] The configuration parameters in step S302 of this embodiment include: the IP address of the server, the server port, the speed measurement timeout time, the number of speed measurement threads, and the size of the speed measurement file.
[0030] It should be noted that the user state detects whether the file descriptor is readable through select (system call), and sets the timeout time in the configuration parameters as the speed measurement time. The user state is in a blocked state within the speed measurement time until the timeout time ends or the file descriptor is readable, and then the blocked state ends.
[0031] Step S304: The speed measurement module in the kernel state creates a speed measurement thread according to the configuration parameters and establishes a connection with the speed measurement server.
[0032] In the kernel state in step S304 of this embodiment, the speed measurement module establishes a connection with the speed measurement server, including: the speed measurement module sends a request message for uploading a file to the speed measurement server; the speed measurement module receives the request confirmation message sent by the speed measurement server in response to the request message; the speed measurement module parses the request confirmation message and sends a confirmation message to the speed measurement server according to the parsing result.
[0033] Among them, the speed measurement module creates a speed measurement thread according to the configuration parameters and establishing a connection with the speed measurement server includes establishing socket (socket) communication, sending a request message for uploading a file to the server, and completing the three-way handshake with the speed measurement server.
[0034] In an exemplary embodiment, the method for measuring the upstream rate of the optical network unit (ONU) further includes: the speed measurement module parses the message sent by the speed measurement module, and determines whether the message matches the Internet Protocol (IP) type to be measured for speed; in the case where the determination result is a match, the message is parsed to determine whether the IP address of the message matches the IP address of the speed measurement server, whether the destination port of the message matches the port of the speed measurement server, and whether the source port of the message matches the port used by the speed measurement server for speed measurement; in the case where all the determination results are matches, the message is parsed and learned.
[0035] In an exemplary embodiment, parsing and learning the message includes: in the case where the message is a Synchronize Sequence Number (SYN), determining the port bound by the client through parsing; in the case where the message is a Push (PSH) message, saving the IP header and Transmission Control Protocol (TCP) header of the message, and marking the message.
[0036] In an exemplary embodiment of the present application, when saving the IP header and TCP header of the message, SocketBuffer (socket buffer) space is allocated to save the message header and fill in the message content to be sent.
[0037] It should be noted that marking the message indicates that the message has been learned and saved. When this mark is seen later, there is no need to completely parse the message again, thereby reducing the time consumption on the interaction path.
[0038] In an exemplary embodiment, the method for measuring the upstream rate of the optical network unit (ONU) further includes: the speed measurement server parses the message received by the speed measurement server, and determines whether the IP type of the message matches the speed measurement IP type; in the case where the determination result is a match, determining whether the source IP address of the message is the IP address of the speed measurement server, whether the source port of the message is the port specified by the speed measurement server, and whether the destination port of the message is the port bound by the ONU speed measurement process; in the case where all the determination results are matches, the message is parsed.
[0039] In an exemplary embodiment of the present application, in the case where the result of determining whether the IP type of the message matches the speed measurement IP type is a mismatch, the message goes through the normal packet receiving process through the protocol stack.
[0040] In an exemplary embodiment of the present application, when it is determined that the source IP address of the packet is not the IP address of the speed measurement server, and / or the source port of the packet is not the port specified by the speed measurement server, and / or the destination port of the packet is not the port bound by the ONU speed measurement process, the packet undergoes a normal packet receiving process through the protocol stack.
[0041] In an exemplary embodiment, parsing the packet includes: when the packet is a SYN packet or an Acknowledge (ACK) packet, determining the number of packets sent by the speed measurement server through parsing; when the packet is a Finish (FIN) or Reset Segment (RST) packet, sending a signal to end the speed measurement to the speed measurement thread.
[0042] Step S306: The speed measurement module uploads the speed measurement file to the speed measurement server based on the selective acknowledgment retransmission mechanism and the timed retransmission mechanism, and calculates the upstream rate of the ONU according to the speed measurement time and the size of the uploaded speed measurement file.
[0043] When the speed measurement module in step S306 of this embodiment sends a packet based on the selective acknowledgment retransmission mechanism, it includes: when the speed measurement module receives an ACK packet, parsing the selective acknowledgment SACK in the ACK packet, comparing the sequence number in the ACK option with the already acknowledged sequence number, determining the sequence number of the discarded packet, and recording the sequence number of the discarded packet in the retransmission packet linked list; traversing the retransmission packet linked list, taking out a preset number of sequence numbers to be retransmitted, encapsulating and sending the packets corresponding to the sequence numbers to be retransmitted.
[0044] It should be noted that in the embodiment of the present application, it is confirmed whether the received ACK packet is the first packet. If it is the first packet, selective acknowledgment retransmission and timer retransmission are performed.
[0045] When the speed measurement module in step S306 of this embodiment uploads the speed measurement file to the speed measurement server based on the timed retransmission mechanism, it includes: the speed measurement module takes out a preset number of sequence numbers to be retransmitted from the retransmission packet linked list according to the timer in the speed measurement module, encapsulates and sends the packets corresponding to the sequence numbers to be retransmitted.
[0046] In an exemplary embodiment of the present application, the timed retransmission mechanism belongs to the timed retransmission mechanism based on an improved self-developed protocol stack. A timer is set in the speed measurement module, and a fixed number of sequence numbers to be retransmitted are taken out from the retransmission packet linked list every once in a while to send packets.
[0047] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present application.
[0048] In this embodiment, a system for measuring the upstream rate of an optical network unit (ONU) is further provided. This system is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0049] The system for measuring the upstream rate of the optical network unit (ONU) includes a speed measurement module. The speed measurement module is used to receive a speed measurement command sent by a speed measurement program in the user state. Among them, the speed measurement command includes configuration parameters for measuring the upstream rate of the ONU.
[0050] The speed measurement module is further used to create a speed measurement thread according to the configuration parameters and establish a connection with a speed measurement server.
[0051] The speed measurement module is further used to upload a speed measurement file to the speed measurement server based on a selective acknowledgment retransmission mechanism and a timed retransmission mechanism, and calculate the upstream rate of the ONU according to the speed measurement time and the size of the uploaded speed measurement file.
[0052] It should be noted that the above-mentioned various modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned modules are all located in the same processor; or, the above-mentioned various modules are respectively located in different processors in any combination form.
[0053] For the convenience of understanding the technical solution provided by the present application, the following will be elaborated in detail with reference to the embodiments in specific scenarios.
[0054] Figure 4 It is a flowchart of a method for measuring the upstream rate of an optical network unit (ONU) according to another embodiment of the present application. As Figure 4 shown, the method includes:
[0055] Step S401, parse the message;
[0056] Specifically, after starting speed measurement, the function mounted at the packet sending point will parse the PPP packet header, IPv4 packet header, and IPv6 packet header of each packet passing through this point;
[0057] Step S402, determine whether the current packet matches the IP type to be speed measured;
[0058] Specifically, if the judgment result is a match, go to step S403; if the judgment result is a mismatch, go to step S404;
[0059] Step S403, parse the IP address, source port, and destination port;
[0060] Step S404, the packet enters the conventional protocol stack;
[0061] Step S405, determine whether the packet matches the server;
[0062] Specifically, determine whether the IP address of the packet is the IP address of the speed measurement server, whether the dport (destination port) is the port of the server, and whether the sport (source port) of the packet is the client port used for speed measurement (or the client port used for speed measurement is 0 because no port is bound during speed measurement, and this method needs to parse the SYN packet to obtain the port used by the client). If the above three conditions are met, it means that the current packet is the interaction packet in the speed measurement process, and go to step S406; otherwise, go to step S404;
[0063] Step S406, further parse and learn this packet;
[0064] Specifically, if the packet is a SYN packet, parse the port bound by the client from the packet;
[0065] If the packet is a PSH packet, it means that this packet is a data packet sent by the ONU terminal to the server. Save the offset of the IP header and TCP header of the packet, and allocate skb space. Save the packet header of this packet, fill in the packet content to be sent by this method, and prepare for the speed measurement module to send the packet. In addition, this method also needs to mark that the packet has been learned and saved. As long as this mark is seen later, there is no need to fully parse the packet again, reducing the time consumed on the path.
[0066] Step S407, the packet enters the self-developed protocol stack.
[0067] Before step S401 of this embodiment, preparations before speed measurement are required, including implementing a speed measurement module in the kernel and loading the speed measurement module when the system starts. A character device is registered in the speed measurement module for data interaction between the kernel state and the user state. The speed measurement module provides an interface for creating a speed measurement thread. When the user state initiates speed measurement, the interface creates a kernel thread for speed measurement according to the number of threads passed down from the user state. The kernel thread completes the interaction with the speed measurement server, is responsible for the control at the end of speed measurement, and the cleanup work after speed measurement. The speed measurement module also provides two hook functions, which are respectively mounted on the Ethernet driver and the xpon module to parse the packets received by the optical network unit and the packets sent by the optical network unit.
[0068] After generating the speed measurement module, the user-state program parses parameters such as the server IP address, server port, speed measurement timeout time, number of speed measurement threads, and size of the speed measurement file according to the used speed measurement command, and then opens the character device registered by the speed measurement module. The parameters are configured into the speed measurement module through the ioctl of the character device. After the parameter configuration is completed, the speed measurement module is notified to start speed measurement. The user state detects whether the file descriptor is readable through the select (system call), and the timeout time is set to the configured speed measurement time. Thereafter, the user state enters a blocked state until the timeout time ends or the file descriptor is readable.
[0069] Figure 5 It is a flowchart of a method for measuring the upstream rate of an optical network unit (ONU) according to another embodiment of the present application. As shown in FIG. 5, the method includes:
[0070] Step S501, parsing the acknowledgment sequence number of the packet;
[0071] Specifically, the acknowledge number (reply sequence number) of the received Acknowledge (ACK) packet is parsed. When the acknowledgment sequence number is 1, it indicates that the packet is the first packet, and step S502 is entered;
[0072] Step S502, starting the SACK retransmission and timer retransmission mechanisms;
[0073] Specifically, several packets are sent while starting the SACK retransmission and timer retransmission mechanisms. The sent packets are obtained by referring to the Socket Buffer (socket buffer) saved at the packet sending point and modifying the packet header. Every time an ACK packet (acknowledgment packet) replied by the server is received later, the method sends packets here. Here, the method maintains the sequence number of the sent packets to ensure correct packet sending. At the same time, two parameters are also opened to the user state to adjust the number of packets sent under different network conditions to cope with network congestion.
[0074] Ideally, the packets should be exchanged normally. However, the actual network conditions are very complex, and packet loss is inevitable. Therefore, this method provides a retransmission mechanism based on SACK and a timed retransmission mechanism here to ensure the successful sending of packets and the normal progress of the TCP protocol interaction process.
[0075] Step S503: Parse the SACK option and encapsulate the packet into the retransmission list;
[0076] Specifically, in the case of detecting packet loss, parse the SACK option and encapsulate the packet into the retransmission list.
[0077] Step S504: Continuously detect the retransmission list and send the packet;
[0078] It should be noted that the SACK retransmission and the timer retransmission mechanism involved in steps S502 - S504 are respectively the retransmission mechanism based on sack of the self-developed protocol stack and the timed retransmission mechanism of the self-developed protocol stack.
[0079] Specifically, the retransmission mechanism based on sack of the self-developed protocol stack: When receiving an ACK packet, this method will parse the sack option in the packet, compare the sequence number in the ACK option with the already confirmed sequence number, determine the sequence number of the discarded packet, and record this sequence number in the retransmission packet linked list. After completing the addition, traverse the retransmission linked list, take out a fixed number of sequence numbers to be retransmitted from it, complete the packet encapsulation, and send the packet.
[0080] The timed retransmission mechanism of the self-developed protocol stack: Start a timer in the speed measurement module, and take out a fixed number of sequence numbers to be retransmitted from the retransmission packet linked list at regular intervals and send the packet.
[0081] Step S505: Further parse and learn the packet.
[0082] Specifically, similar to the function mounted at the packet sending point, after the function mounted at the packet receiving point receives the packet replied by the speed measurement server, it also needs to parse it. Determine whether the IP type of the received packet is the same as the speed measurement IP type. If they are not the same, the normal packet receiving process of the protocol stack is followed. If they are the same, it is necessary to determine whether the source IP address of the packet is the address of the speed measurement server, whether the source port of the packet is the port specified by the speed measurement server, and whether the destination port of the packet is the port bound by the ONU speed measurement process. Packets that do not meet these conditions follow the normal protocol stack process, and packets that meet these conditions are further parsed: If the packet is a SYN or ACK packet, this method needs to parse out the server's sliding window scaling factor and the server's maximum segment size (MSS) from it to determine the number of packets to be sent; if the packet is a FIN packet or an RST packet, the flag indicating that the speed measurement has started needs to be set to 0, and a SIGKILL signal is sent to the speed measurement thread to end the speed measurement.
[0083] It should be noted that when the user state detects that the speed measurement time has arrived, it will notify the speed measurement module, and the speed measurement module will send a SIGKILL message to the speed measurement process, or when the size of the sent packet is greater than or equal to the size of the speed measurement file, the speed measurement module will send a SIGKILL message to the speed measurement process. During the speed measurement process, the speed measurement value per second will be printed, and the speed measurement rate during the entire speed measurement period will be printed after the speed measurement ends.
[0084] Figure 6 It is a flowchart of a method for measuring the upstream rate of an optical network unit (ONU) according to another embodiment of the present application. As shown in the figure, the method includes the following steps:
[0085] Step S601, the user state command is responsible for parsing the parameters required for speed measurement, configuring the parameters to the speed measurement module in the kernel, and initiating the speed measurement;
[0086] Among them, step S601 includes the following steps:
[0087] Step S6011, the user state program parses out parameters such as the server IP address, server port, speed measurement timeout time, number of speed measurement threads, and size of the speed measurement file according to the used speed measurement command;
[0088] Step S6012, open the character device registered by the speed measurement module, and configure the parameters to the speed measurement module through the ioctl of the character device;
[0089] Step S6013, after the parameter configuration is completed, notify the speed measurement module to start the speed measurement.
[0090] The step S6013 further includes that the user mode calls select to detect whether the file descriptor is readable and sets the timeout to the configured speed measurement time. After that, the user mode enters the blocking state until the timeout ends or the file descriptor is readable.
[0091] Step S602: The speed measurement module creates a speed measurement thread, establishes a socket communication, sends a request message for uploading a file to the server, and completes the three-way handshake with the speed measurement server.
[0092] Step S6021: When the system starts, the speed measurement module is loaded, and a character device is registered for data interaction between the kernel mode and the user mode. An interface for creating a speed measurement thread is provided in the speed measurement module.
[0093] Specifically, step S6021 includes that the user mode initiates speed measurement, and the interface for creating a speed measurement thread creates a kernel thread for speed measurement according to the number of threads passed down from the user mode. The kernel thread completes the interaction with the speed measurement server, is responsible for controlling the end of speed measurement, and the cleanup work after speed measurement ends.
[0094] Step S6022: The function mounted at the packet sending point parses each packet passing through this point and determines whether the current packet matches the IP type to be speed measured.
[0095] The step S6022 further includes that the function mounted at the packet sending point parses the PPP packet header, IPv4 packet header, and IPv6 packet header of each packet passing through this point. If the packet IP types do not match, the packet is sent through the normal protocol stack sending process.
[0096] If the packet types match, it is further determined whether the IP address, dport, and sport of the packet match the speed measurement server and client.
[0097] When the above matching judgment is met, it indicates that the current packet is an interaction packet in the speed measurement process, and such packets are further deeply parsed and learned.
[0098] Specifically, if the packet is a SYN packet, the method parses the port bound by the client from it.
[0099] If it is a PSH packet, this packet is a data packet sent by the ONU terminal to the server. After parsing such a packet, the method saves the offset of the IP header and TCP header of the packet, allocates skb space, saves the packet header, and fills in the content of the packet to be sent. In addition, the method marks that the packet has been learned and saved. When this mark is seen later, it is not necessary to completely parse the packet again, thus reducing the time consumption on the interaction path.
[0100] Step S6023: After the function mounted at the packet receiving point receives the packet replied by the speed measurement server, it also parses the packet and determines whether the IP types of the received packets are the same;
[0101] The step S6023 further includes determining whether the IP type of the received packet is the same as the speed measurement IP type. If they are not the same, the normal packet receiving process of the protocol stack is followed;
[0102] In the case of packet type matching, it is necessary to determine whether the source IP address of the packet is the address of the speed measurement server, whether the source port of the packet is the port specified by the speed measurement server, and whether the destination port of the packet is the port bound by the ONU speed measurement process.
[0103] In the case of not meeting the matching conditions, the packet follows the normal process of the protocol stack, and the matching packet is further parsed.
[0104] Specifically, if the parsed packet is a SYN or ACK packet, the method parses out the server's sliding window scaling factor and the server's maximum segment size (MSS) from it, which are used to determine the number of packets to be sent. If the packet is a FIN or rst packet, the flag indicating that the speed measurement has started is set to 0, and a SIGKILL signal is sent to the speed measurement thread to end the speed measurement.
[0105] Step S6024: For the ACK packet replied by the server, the method parses out the acknowledge number (reply sequence number) of the packet, and after further parsing, completes the three-way handshake with the speed measurement server.
[0106] If the ACK packet replied by the server is the first packet, the method starts sack retransmission and timer retransmission here and sends several packets. After each time the ACK packet replied by the server is received, the method sends packets here. Here, the embodiment of the present application maintains the sequence number of the sent packets to ensure correct packet sending. The embodiment of the present application also opens two parameters to the user space to adjust the number of packets sent under different network conditions to cope with network congestion.
[0107] Step S603: The speed measurement module simplifies the linux kernel standard protocol stack based on the improved self-developed protocol stack and uploads the file.
[0108] Specifically, the self-developed protocol stack implements sack-based retransmission and timer retransmission mechanisms. During the speed measurement process, the size of the uploaded file is accumulated. After the speed measurement ends, the upload rate is calculated according to the actual speed measurement time.
[0109] Step S603 further includes the following steps:
[0110] Step S6031: Based on the SACK-based retransmission mechanism of the improved self-developed protocol stack, when an ACK packet is received, in the embodiments of the present application, the SACK option in the packet will be parsed, the sequence number in the ACK option will be compared with the already confirmed sequence number, the sequence number of the discarded packet will be determined, and this sequence number will be recorded in the retransmission packet linked list.
[0111] Step S6032: After the addition is completed, traverse the retransmission linked list, take out a fixed number of sequence numbers to be retransmitted from it, complete the packet encapsulation, and send the packet.
[0112] Step S6033: Based on the timed retransmission mechanism of the self-developed protocol stack, start a timer in the speed measurement module, and take out a fixed number of sequence numbers to be retransmitted from the retransmission packet linked list at regular intervals to send the packet.
[0113] When the network card bandwidth is set to 1 Gbps, the traditional method for measuring the upstream rate of the ONU and the method for measuring the upstream rate of the ONU according to the embodiments of the present application are respectively used for speed measurement. Figure 7 shows the speed measurement results obtained by using the traditional method for measuring the upstream rate of the ONU. Figure 8 shows the speed measurement results obtained by using the method for measuring the upstream rate of the ONU according to the embodiments of the present application. By comparing Figure 7 and Figure 8 it can be easily seen that compared with the traditional speed measurement method, the speed measurement results obtained by the speed measurement method in the embodiments of the present application are closer to the theoretical value, and the speed measurement process is smoother and the stability is better.
[0114] The embodiments of the present application also provide a computer-readable storage medium, in which a computer program is stored. Among them, the computer program is set to execute the steps in any one of the above method embodiments when running.
[0115] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as USB flash drives, read-only memories (ROM for short), random access memories (RAM for short), mobile hard disks, magnetic disks, or optical discs that can store computer programs.
[0116] The embodiments of the present application also provide an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is set to run the computer program to execute the steps in any one of the above method embodiments.
[0117] In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0118] Specific examples in this embodiment may refer to the examples described in the above embodiments and exemplary embodiments, and will not be elaborated herein.
[0119] The method used in the embodiments of this application is improved based on the previous traditional protocol stack. In a high-bandwidth environment, based on the improved self-developed protocol stack in the embodiments of this application, the measurement of the uplink rate of the optical network unit can also be well realized; the principle of the embodiments of this application is simple, and the timeliness and accuracy of data transmission are better than those of traditional measurement methods; regarding the advantage of stability, currently, the method involved in the embodiments of this application is to adjust the configuration parameters of the user-state upload through serial port commands to test the uplink rate closest to the bandwidth. For different gateway products and complex network environments in the market, the corresponding configuration parameters are often different. Therefore, for different customer products, the corresponding configuration parameters are embedded into the SDK to stably and accurately measure the uplink rate in each product.
[0120] Obviously, those skilled in the art should understand that the above modules or steps of this application can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. They can be implemented by program codes executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order than here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. In this way, this application is not limited to any specific combination of hardware and software.
[0121] The above are only the preferred embodiments of this application and are not used to limit this application. For those skilled in the art, this application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the principle of this application shall be included in the protection scope of this application.
Claims
1. A method for measuring the upstream rate of an optical network unit (ONU), which is applied to the ONU, and is characterized in that, including: The speed measurement module in the kernel mode receives the speed measurement command sent by the speed measurement program in the user mode, where the speed measurement command includes configuration parameters for measuring the upstream rate of the ONU; In the kernel mode, the speed measurement module creates a speed measurement thread according to the configuration parameters and establishes a connection with the speed measurement server; The speed measurement module uploads the speed measurement file to the speed measurement server based on the selective acknowledgment retransmission mechanism and the timed retransmission mechanism, and calculates the upstream rate of the ONU according to the speed measurement time and the size of the uploaded speed measurement file.
2. The method according to claim 1, wherein The speed measurement module in the kernel mode receiving the speed measurement command sent by the speed measurement program in the user mode includes: The speed measurement program parses the speed measurement command to obtain the configuration parameters; The character device of the speed measurement module receives the speed measurement command and the configuration parameters sent by the speed measurement program.
3. The method according to claim 1, wherein The speed measurement module in the kernel mode establishing a connection with the speed measurement server includes: The speed measurement module sends a request message for uploading a file to the speed measurement server; The speed measurement module receives the request acknowledgment message sent by the speed measurement server in response to the request message; The speed measurement module parses the request acknowledgment message and sends an acknowledgment message to the speed measurement server according to the parsing result.
4. The method according to claim 3, characterized in that, The method further includes: The speed measurement module parses the message sent by the speed measurement module and determines whether the message matches the Internet Protocol (IP) type to be speed measured; When the judgment result is a match, the message is parsed to determine whether the IP address of the message matches the IP address of the speed measurement server, whether the destination port of the message matches the port of the speed measurement server, and whether the source port of the message matches the port used by the speed measurement server for speed measurement; When all the judgment results are matches, the message is parsed and learned.
5. The method according to claim 4, characterized in that, The parsing and learning of the message includes: When the message is a Synchronize Sequence Numbers (SYN) message, the port bound by the client is determined by parsing; When the message is a Push (PSH) message, the IP header and the Transmission Control Protocol (TCP) header of the message are saved, and the message is marked.
6. The method according to claim 1, wherein The method further includes: The speed measurement server parses the message received by the speed measurement server and determines whether the IP type of the message matches the speed measurement IP type; When the judgment result is a match, it is judged whether the source IP address of the message is the IP address of the speed measurement server, whether the source port of the message is the port specified by the speed measurement server, and whether the destination port of the message is the port bound by the ONU speed measurement process; When all the judgment results are matches, the message is parsed.
7. The method according to claim 6, wherein The parsing of the message includes: When the message is a SYN message or an Acknowledgment (ACK) message, the number of messages sent by the speed measurement server is determined by parsing; When the message is a Finish (FIN) message or a Reset (RST) segment message, a signal to end the speed measurement is sent to the speed measurement thread.
8. The method according to claim 1, wherein The speed measurement module sending a message based on the selective acknowledgment retransmission mechanism includes: When the speed measurement module receives an ACK packet, parse the selective acknowledgment (SACK) in the ACK packet, compare the sequence number in the ACK option with the already acknowledged sequence number, determine the sequence number of the discarded packet, and record the sequence number of the discarded packet in the retransmission packet linked list; Traverse the retransmission packet linked list, take out a preset number of sequence numbers to be retransmitted, encapsulate and send the packets corresponding to the sequence numbers to be retransmitted.
9. The method according to claim 1, characterized in that The speed measurement module uploads the speed measurement file to the speed measurement server based on the timed retransmission mechanism, including: The speed measurement module takes out a preset number of sequence numbers to be retransmitted from the retransmission packet linked list according to the timer in the speed measurement module, encapsulates and sends the packets corresponding to the sequence numbers to be retransmitted.
10. The method according to claim 1, characterized in that, The configuration parameters include: the IP address of the server, the server port, the speed measurement timeout time, the number of speed measurement threads, and the size of the speed measurement file.
11. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, wherein when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 10 are implemented.
12. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the steps of the method described in any one of claims 1 to 10 are implemented.