A method and device for recording packet loss information, a storage medium and an electronic device
Patent Information
- Application Number
- CN202311381998.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-24
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2043-10-24
AI Technical Summary
DPDK网关从网卡接收到的数据包,不需要经过内核协议栈,直接在用户态实现数据包转发,转发效率相较于基于内核协议栈实现数据包转发的网关具有较大的提升,但是无论是DPDK网关还是内核协议栈,在转发数据包的过程中可能存在丢包的现象
[0041]本申请提供的技术方案,当接收到数据包的丢包原因时,获取第一哈希表的长度;根据第一哈希表的长度,确定丢包原因的标识和目标丢包数量;当数据包的丢包原因为预设丢包原因时,获取数据包的关键信息;从第二哈希表中查找与标识对应的链表,并将数据包的关键信息存储至与标识对应的链表中,以及将目标丢包数量存储在第一哈希表中;当数据包的丢包原因为目标丢包原因时,将目标丢包数量存储在第一哈希表中。能够获取数据包丢包的具体情况,根据丢包的具体情况能够准确诊断出丢包原因,因此,提高了DPDK网关丢包排障的效率。
Smart Images

Figure CN117478555B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a method, apparatus, storage medium and electronic device for recording packet loss information. Background Technology
[0002] With the rapid growth of data volume, cloud computing platforms are placing increasingly higher demands on network forwarding performance. DPDK (Data Plane Development Kit) gateways are gradually becoming the mainstream gateways for cloud computing platforms. DPDK gateways receive data packets from the network interface card (NIC) without going through the kernel protocol stack, and forward the packets directly in user space. This results in significantly improved forwarding efficiency compared to gateways that rely on the kernel protocol stack for packet forwarding. However, both DPDK gateways and kernel protocol stacks may experience packet loss during the forwarding process.
[0003] Currently, network packet loss diagnostic tools are all implemented based on the kernel protocol stack. They can summarize packet loss information due to various reasons during the process of data packets passing through the link layer, network layer, and transport layer. However, since the DPDK cloud gateway processes data packets in user space, these tools cannot obtain the specific details of packet loss during the forwarding process of the DPDK gateway, which makes it impossible to accurately diagnose the cause of packet loss and reduces the efficiency of DPDK gateway packet loss troubleshooting.
[0004] Therefore, improving the efficiency of DPDK gateway packet loss troubleshooting has become an urgent problem to be solved in this field. Summary of the Invention
[0005] This application provides a method, apparatus, storage medium, and electronic device for recording packet loss information, with the aim of improving the efficiency of packet loss troubleshooting in DPDK gateways.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] A method for recording packet loss information includes:
[0008] When the reason for packet loss is received, the length of the first hash table is obtained;
[0009] Based on the length of the first hash table, determine the identifier of the packet loss reason and the target number of packet losses;
[0010] When the packet loss reason is a preset packet loss reason, the key information of the packet is obtained; the preset packet loss reason indicates the reason why the packet is lost due to its own problem;
[0011] The key information of the data packet is stored in the linked list corresponding to the identifier in the second hash table, and the target number of lost packets is stored in the first hash table.
[0012] When the packet loss reason is the target packet loss reason, the target packet loss count is stored in the first hash table; the target packet loss reason indicates the reason for packet loss due to gateway performance.
[0013] Optional, also includes:
[0014] When a query request is received from a client, the query interface is invoked to retrieve packet loss information corresponding to the query request from the first hash table and / or the second hash table; the packet loss information includes the reason for packet loss, the number of packets lost, and key information.
[0015] The packet loss information corresponding to the query request is serialized using the protobuf protocol to obtain serialized packet loss information, and then the serialized packet loss information is sent to the client. Optionally, the step of calling the query interface to obtain the packet loss information corresponding to the query request from the first hash table and / or the second hash table includes:
[0016] When the query request is a request to query the reason for packet loss and the number of packets lost, the query interface is called to obtain the reason for packet loss and the target number of packets lost from the first hash table;
[0017] When the query request is a request to query the reason for packet loss and key information of a data packet, the query interface is invoked to retrieve the reason for packet loss and key information of the data packet from the second hash table;
[0018] When the query request is a request to query the reason for packet loss, the number of packets lost, and key information of a data packet, the query interface is invoked to obtain the reason for packet loss, the target number of packets lost, and the key information of the data packet from the first hash table and the second hash table.
[0019] Optionally, determining the target number of lost packets based on the length of the first hash table includes:
[0020] Divide the reason for packet loss by the length of the first hash table to obtain the identifier of the reason for packet loss;
[0021] Find the number of packet losses corresponding to the identifier in the first hash table, and add the number of packet losses to 1 to obtain the target number of packet losses.
[0022] A device for recording packet loss information, comprising:
[0023] The first acquisition unit is used to obtain the length of the first hash table when the reason for packet loss is received;
[0024] The determining unit is used to determine the identifier of the packet loss reason and the target number of packet losses based on the length of the first hash table;
[0025] The second acquisition unit is used to acquire key information of the data packet when the packet loss reason is a preset packet loss reason; the preset packet loss reason indicates the reason why the data packet is lost due to its own problem;
[0026] The first storage unit is used to look up the linked list corresponding to the identifier from the second hash table, store the key information of the data packet into the linked list corresponding to the identifier, and store the target number of lost packets in the first hash table;
[0027] The second storage unit is used to store the target packet loss count in the first hash table when the packet loss reason is the target packet loss reason; the target packet loss reason indicates the reason for packet loss due to gateway performance.
[0028] Optional, also includes:
[0029] The query unit is used to call the query interface to obtain packet loss information corresponding to the query request from the first hash table and / or the second hash table when a query request is received from the client; the packet loss information includes the reason for packet loss, the number of packets lost, and key information.
[0030] The sending unit is used to serialize the packet loss information corresponding to the query request using the protobuf protocol, obtain the serialized packet loss information, and send the serialized packet loss information to the client.
[0031] Optionally, the query unit is specifically used for:
[0032] When the query request is a request to query the reason for packet loss and the number of packets lost, the query interface is called to obtain the reason for packet loss and the target number of packets lost from the first hash table;
[0033] When the query request is a request to query the reason for packet loss and key information of a data packet, the query interface is invoked to retrieve the reason for packet loss and key information of the data packet from the second hash table;
[0034] When the query request is a request to query the reason for packet loss, the number of packets lost, and key information of a data packet, the query interface is invoked to obtain the reason for packet loss, the target number of packets lost, and the key information of the data packet from the first hash table and the second hash table.
[0035] Optionally, the determining unit is specifically used for:
[0036] Divide the reason for packet loss by the length of the first hash table to obtain the identifier of the reason for packet loss;
[0037] Find the number of packet losses corresponding to the identifier in the first hash table, and add the number of packet losses to 1 to obtain the target number of packet losses.
[0038] A computer-readable storage medium includes a stored program, wherein the program is executed by a processor to perform the method for recording packet loss information.
[0039] An electronic device includes: a processor, a memory, and a bus; the processor and the memory are connected via the bus.
[0040] The memory is used to store the program, and the processor is used to run the program, wherein the program is executed by the processor to perform the method for recording packet loss information.
[0041] The technical solution provided in this application, upon receiving the reason for packet loss, obtains the length of a first hash table; based on the length of the first hash table, determines the identifier of the packet loss reason and the target packet loss quantity; when the packet loss reason is a preset reason, obtains the key information of the packet; searches for the linked list corresponding to the identifier in a second hash table, stores the key information of the packet in the linked list corresponding to the identifier, and stores the target packet loss quantity in the first hash table; when the packet loss reason is the target reason, stores the target packet loss quantity in the first hash table. This allows for obtaining the specific details of packet loss, and based on these details, the cause of packet loss can be accurately diagnosed, thus improving the efficiency of packet loss troubleshooting in the DPDK gateway. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 A flowchart illustrating a method for recording packet loss information provided in an embodiment of this application;
[0044] Figure 2 A flowchart illustrating a method for querying packet loss information provided in this application embodiment;
[0045] Figure 3 A schematic diagram illustrating another method for querying packet loss information provided in an embodiment of this application;
[0046] Figure 4 A schematic diagram of the architecture of a packet loss information recording device provided in an embodiment of this application;
[0047] Figure 5 This is a schematic diagram of the architecture of an electronic device provided in an embodiment of this application. Detailed Implementation
[0048] 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. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0049] In this application, the terms "comprising," "including," or any other variations thereof are intended to cover a 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 limitation, 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 said element.
[0050] like Figure 1 The flowchart shown is a method for recording packet loss information provided in an embodiment of this application, including the following steps:
[0051] S101: When the reason for packet loss is received, obtain the length of the first hash table.
[0052] It should be noted that a block of memory is first allocated to the server that queries packet loss information, in order to store the reasons for packet loss, the number of packets lost, and key information about the packets.
[0053] The first hash table stores the reason for packet loss and the number of packets lost; the second hash table stores the reason for packet loss and key information about the packets. Since both the first and second hash tables store the reason for packet loss, the length of the hash table is determined by the reason for packet loss. Therefore, the length of the first hash table is the same as the length of the second hash table, and the length of the second hash table can also be obtained at this time.
[0054] S102: Determine the identifier of the packet loss reason and the target number of packet losses based on the length of the first hash table.
[0055] Understandably, the identifier of the packet loss reason and the target number of packet losses are determined based on the length of the first hash table. Specifically, the identifier of the packet loss reason is first determined based on the length of the first hash table, and then the target number of packet losses is determined based on the identifier of the packet loss reason.
[0056] Optionally, in another embodiment of this application, one specific implementation of step S102 includes the following steps:
[0057] Divide the reason for packet loss by the length of the first hash table to obtain the identifier of the reason for packet loss.
[0058] The identifier for the reason for packet loss includes, but is not limited to, "KEY".
[0059] It should be noted that the specific form of dividing the reason for packet loss by the length of the first hash table is as shown in formula (1).
[0060] KEY = Reason for packet loss % Length of the first hash table (1)
[0061] In formula (1), KEY is the identifier of the reason for packet loss.
[0062] It is understandable that dividing the reason for packet loss by the length of the first hash table is equivalent to performing a hash calculation on the reason for packet loss. The specific form of the hash calculation is shown in formula (1).
[0063] Find the number of packet losses corresponding to the identifier in the first hash table, and add the number of packet losses to 1 to get the target number of packet losses.
[0064] The specific representation of the number of packets lost corresponding to the identifier includes, but is not limited to, "VALUE".
[0065] It should be noted that the specific form of adding the number of lost packets to 1 is shown in formula (2).
[0066] Target packet loss count = Number of packet losses + 1(2)
[0067] Understandably, if the reason for packet loss is received, that is, if packet loss is detected, the original number of lost packets is incremented by one, that is, the number of lost packets is added to 1 to obtain the target number of lost packets.
[0068] S103: When the packet loss reason is the preset packet loss reason, obtain the key information of the packet.
[0069] The preset packet loss reason indicates the reason why the packet is lost due to its own problems, such as incorrect IP header length, incorrect TCP header checksum, packet hitting ACL rejection rules, or packet not matching forwarding rules on the gateway.
[0070] Key information includes, but is not limited to: timestamp, link layer header, network layer header, and transport layer header.
[0071] A timestamp is a time information recorded in a data packet, used to mark the time when the data packet was sent or received.
[0072] The link layer header is a portion of data added when data packets are transmitted at the link layer, used to manage and control the operation of the link layer.
[0073] The network layer header is a portion of data added to data packets during transmission at the network layer. It is used to identify information such as the network layer protocol, source IP address, and destination IP address.
[0074] The transport layer header is a portion of data added to data packets during transmission at the transport layer, used to manage and control the operation of the transport layer.
[0075] S104: Find the linked list corresponding to the identifier in the second hash table, store the key information of the data packet in the linked list corresponding to the identifier, and store the target number of lost packets in the first hash table.
[0076] The second hash table pre-stores the correspondence between the identifier (KEY) of the packet loss reason and the linked list (VALUE). Each element of the linked list stores the key information of a lost packet data. Therefore, the linked list corresponding to the identifier can be obtained from the second hash table.
[0077] It is understandable that the key information of the data packet is stored in the linked list corresponding to the identifier, that is, the key information is stored in the second hash table, and the target number of lost packets is stored in the first hash table, so that the lost packet information can be retrieved from the first hash table and the second hash table later.
[0078] S105: When the reason for packet loss is the target reason for packet loss, store the target packet loss count in the first hash table.
[0079] The target packet loss reason indicates the reason for packet loss due to the performance problem of the gateway itself, such as the packet sending and receiving queue being full or the inability to allocate memory to store data packets.
[0080] Understandably, if packet loss is caused by a performance issue with the gateway itself, then critical information about the data packets will not be acquired or recorded. In high-speed network environments, a large number of data packets may need to be processed, and recording critical information could consume significant computing resources and storage space, thus degrading network device performance. Therefore, to avoid degrading network device performance, critical information about the data packets will not be recorded.
[0081] Optionally, after storing the key information of the data packet in a linked list corresponding to the identifier, and storing the target packet loss count in a first hash table, or storing the target packet loss count in a first hash table, the packet loss information of the data packet can be queried through the first hash table and the second hash table. Therefore, another embodiment of this application provides a method for querying packet loss information, such as... Figure 2 As shown, it includes the following steps:
[0082] S201: When a query request is received from a client, the query interface is called to retrieve the packet loss information corresponding to the query request from the first hash table and / or the second hash table.
[0083] The packet loss information includes the reason for packet loss, the number of packets lost, and other key information. The query request indicates a request to retrieve packet loss information.
[0084] Optionally, users can send query requests to the server by calling a preset command on the client. The preset command is a CLI command in the shell, specifically in the form of get_drop_info.
[0085] It is understandable that different query requests will obtain different packet loss information. Therefore, it is necessary to obtain the packet loss information corresponding to the query request from the first hash table and / or the second hash table.
[0086] Optionally, the query interface can be represented as: get_drop_info. The input parameter of this query interface is packet loss information, which includes, but is not limited to: the reason and number of packet losses, the reason and key information of packet losses, and the corresponding packet loss information is obtained according to the type of input parameter information.
[0087] It should be noted that the query function can be implemented through the control thread (i.e., the ctrl thread) of the server module that queries packet loss information. The ctrl thread is bound to the CPU, which is not used for packet forwarding; therefore, it does not affect packet forwarding performance. The ctrl thread is implemented based on the libev high-performance event-driven framework, listening for a specific service port or I / O event. Here, it is used to listen for query requests. Once a query request is detected, the query interface is called to retrieve the packet loss information corresponding to the query request from the first hash table and / or the second hash table.
[0088] Optionally, in another embodiment of this application, a specific implementation of step S201, which involves calling a query interface to retrieve packet loss information corresponding to the query request from the first hash table and / or the second hash table, includes the following steps:
[0089] When the query request is for the reason and number of packet loss, the query interface is called to retrieve the reason and target number of packet loss from the first hash table.
[0090] Understandably, when the query request is to query the reason for packet loss and the number of packets lost, the query interface (i.e., get_drop_info) is called. At this time, the input parameters of the query interface are the reason for packet loss and the number of packets lost. Therefore, the reason for packet loss and the target number of packets lost are obtained from the first hash table.
[0091] When the query request is for the reason and key information of packet loss, the query interface is called to retrieve the reason and key information of packet loss from the second hash table.
[0092] Understandably, when the query request is to query the reason and key information of packet loss, the query interface (i.e., get_drop_info) is called. At this time, the input parameters of the query interface are the reason and key information of packet loss. Therefore, the reason and key information of packet loss are obtained from the second hash table.
[0093] When the query request is for the reason for packet loss, the number of packets lost, and key information of the data packet, the query interface is called to retrieve the reason for packet loss, the target number of packets lost, and key information of the data packet from the first hash table and the second hash table.
[0094] Understandably, when the query request is to query the reason for packet loss, the number of packets lost, and key information of the data packet, the query interface (i.e., get_drop_info) is called. At this time, the input parameters of the query interface are the reason for packet loss, the number of packets lost, and key information of the data packet. Therefore, the reason for packet loss, the number of packets lost, and key information of the data packet are obtained from the first hash table and the second hash table.
[0095] S202: Serialize the packet loss information corresponding to the query request using the protobuf protocol, obtain the serialized packet loss information, and send the serialized packet loss information to the client.
[0096] It should be noted that since Protobuf is a network communication protocol that helps data be transmitted efficiently over the network, in order to transmit packet loss information efficiently, the packet loss information corresponding to the query request is serialized using the protobuf protocol to obtain the serialized packet loss information, and then the serialized packet loss information is sent to the client.
[0097] Optionally, when the client receives the serialized packet loss information, it parses the byte sequence of the received packet loss information into an object that can be stored in memory (i.e., deserializes the serialized packet loss information), then reads the packet loss information from memory and displays it to the operations and maintenance personnel in an easy-to-understand format.
[0098] Specifically, the process of querying packet loss information is as follows: Figure 3 As shown, the CLI command (i.e., get_drop_info) is executed first, which sends a query request to the ctrl thread. By calling the query interface (i.e., get_drop_info), packet loss information is obtained from the first hash table and the second hash table (i.e., the worker thread). The ctrl thread then sends the packet loss information back to the client.
[0099] Optionally, to implement steps S101 to S105, code for collecting packet loss information can be pre-added to the core thread (i.e., the worker thread) that processes data packets. This code is added after various possible packet loss logic within the worker thread, and corresponding packet loss cause collection code is set according to different processing logics. The packet loss causes included are as follows:
[0100] Network card driver layer:
[0101] hw_imissed
[0102] hw_ierrors
[0103] hw_oerrors
[0104] hw_rx_nombuf
[0105] Link layer:
[0106] trunc_pkts
[0107] ARP related:
[0108] arp_port_err
[0109] arp_tx_reply_err
[0110] arp_tx_request_err
[0111] arp_unknown_dst
[0112] arp_unknown_op
[0113] Related to kernel interface interaction:
[0114] totap_err_pkts
[0115] Network layer:
[0116] ip_csum_err
[0117] ip_proto_err_pkts
[0118] ip_dst_err
[0119] ip_trunk_pkts
[0120] Transport layer:
[0121] tcp_csum_err
[0122] tcp_trunc_pkts
[0123] udp_csum_err
[0124] udp_trunc_pkts
[0125] icmp_jumbo_pkts
[0126] icmp_reply_failure
[0127] icmp_csum_err
[0128] icmp_trunc_pkts
[0129] icmp_not_echo_pkts
[0130] Related to ACLs, rate limiting, and exceeding gateway processing capacity limits: acl_drop_pkts
[0131] band_overload
[0132] pps_overload
[0133] inc_conn_overload
[0134] out_of_conn
[0135] get_bip_err
[0136] dispatch_ppl_err
[0137] Related to the inability to match the gateway's forwarding rules:
[0138] get_svc_fail
[0139] route_fail.
[0140] In summary, when a packet loss reason is received, the length of the first hash table is obtained. Based on the length of the first hash table, the identifier of the packet loss reason and the target packet loss quantity are determined. When the packet loss reason is a preset packet loss reason, the key information of the packet is obtained. The linked list corresponding to the identifier is searched from the second hash table, and the key information of the packet is stored in the linked list corresponding to the identifier, and the target packet loss quantity is stored in the first hash table. When the packet loss reason is the target packet loss reason, the target packet loss quantity is stored in the first hash table. In this embodiment, the specific details of packet loss can be obtained, and the packet loss reason can be accurately diagnosed based on the specific details of packet loss, thus improving the efficiency of packet loss troubleshooting in the DPDK gateway.
[0141] like Figure 4 The diagram shown is an architectural schematic of a packet loss information recording device provided in an embodiment of this application. The recording device includes: a first acquisition unit 100, a determination unit 200, a second acquisition unit 300, a first storage unit 400, and a second storage unit 500.
[0142] The first acquisition unit 100 is used to acquire the length of the first hash table when the reason for packet loss is received.
[0143] The determination unit 200 is used to determine the identifier of the packet loss reason and the target number of packet losses based on the length of the first hash table;
[0144] The determining unit 200 is specifically used to: divide the packet loss reason by the length of the first hash table to obtain the identifier of the packet loss reason; look up the packet loss number corresponding to the identifier in the first hash table, and add the packet loss number to 1 to obtain the target packet loss number.
[0145] The second acquisition unit 300 is used to acquire key information of the data packet when the packet loss reason is a preset packet loss reason; the preset packet loss reason indicates the reason why the data packet is lost due to its own problem;
[0146] The first storage unit 400 is used to look up the linked list corresponding to the identifier from the second hash table, store the key information of the data packet into the linked list corresponding to the identifier, and store the target number of lost packets in the first hash table.
[0147] The second storage unit 500 is used to store the target packet loss count in the first hash table when the packet loss reason is the target packet loss reason; the target packet loss reason indicates the reason for packet loss due to gateway performance.
[0148] In summary, when a packet loss reason is received, the length of the first hash table is obtained. Based on the length of the first hash table, the identifier of the packet loss reason and the target packet loss quantity are determined. When the packet loss reason is a preset packet loss reason, the key information of the packet is obtained. The linked list corresponding to the identifier is searched in the second hash table, and the key information of the packet is stored in the linked list corresponding to the identifier, and the target packet loss quantity is stored in the first hash table. When the packet loss reason is the target packet loss reason, the target packet loss quantity is stored in the first hash table. In this embodiment, the specific situation of packet loss can be obtained, and the packet loss reason can be accurately diagnosed based on the specific situation of packet loss, thus improving the efficiency of packet loss troubleshooting in the DPDK gateway.
[0149] Preferred, combined Figure 4 As shown, the recording unit also includes a query unit and a sending unit.
[0150] The query unit is used to call the query interface to retrieve packet loss information corresponding to the query request from the first hash table and / or the second hash table when a query request is received from the client. The packet loss information includes the reason for packet loss, the number of packets lost, and key information.
[0151] The query unit is specifically used for: when the query request is for the reason and number of packet loss, calling the query interface to retrieve the reason and target number of packet loss from the first hash table; when the query request is for the reason and key information of packet loss, calling the query interface to retrieve the reason and key information of packet loss from the second hash table; and when the query request is for the reason, number, and key information of packet loss, calling the query interface to retrieve the reason, target number, and key information of packet loss from both the first and second hash tables.
[0152] The sending unit is used to serialize the packet loss information corresponding to the query request using the protobuf protocol, obtain the serialized packet loss information, and send the serialized packet loss information to the client.
[0153] This application also provides a computer-readable storage medium, which includes a stored program, wherein the program executes the packet loss information recording method provided in this application.
[0154] like Figure 5 As shown, this application also provides an electronic device, including: a processor 501, a memory 502, and a bus 503. The processor 501 and the memory 502 are connected via the bus 503. The memory 502 is used to store a program, and the processor 501 is used to run the program. When the program runs, it executes the packet loss information recording method provided in this application, which includes the following steps:
[0155] When the reason for packet loss is received, the length of the first hash table is obtained;
[0156] Based on the length of the first hash table, determine the identifier of the packet loss reason and the target number of packet losses;
[0157] When the packet loss reason is a preset packet loss reason, the key information of the packet is obtained; the preset packet loss reason indicates the reason why the packet is lost due to its own problem;
[0158] The key information of the data packet is stored in the linked list corresponding to the identifier in the second hash table, and the target number of lost packets is stored in the first hash table.
[0159] When the packet loss reason is the target packet loss reason, the target packet loss count is stored in the first hash table; the target packet loss reason indicates the reason for packet loss due to gateway performance.
[0160] Optional, also includes:
[0161] When a query request is received from a client, the query interface is invoked to retrieve packet loss information corresponding to the query request from the first hash table and / or the second hash table; the packet loss information includes the reason for packet loss, the number of packets lost, and key information.
[0162] The packet loss information corresponding to the query request is serialized using the protobuf protocol to obtain serialized packet loss information, and then the serialized packet loss information is sent to the client. Optionally, the step of calling the query interface to obtain the packet loss information corresponding to the query request from the first hash table and / or the second hash table includes:
[0163] When the query request is a request to query the reason for packet loss and the number of packets lost, the query interface is called to obtain the reason for packet loss and the target number of packets lost from the first hash table;
[0164] When the query request is a request to query the reason for packet loss and key information of a data packet, the query interface is invoked to retrieve the reason for packet loss and key information of the data packet from the second hash table;
[0165] When the query request is a request to query the reason for packet loss, the number of packets lost, and key information of a data packet, the query interface is invoked to obtain the reason for packet loss, the target number of packets lost, and the key information of the data packet from the first hash table and the second hash table.
[0166] Optionally, determining the target number of lost packets based on the length of the first hash table includes:
[0167] Divide the reason for packet loss by the length of the first hash table to obtain the identifier of the reason for packet loss;
[0168] Find the number of packet losses corresponding to the identifier in the first hash table, and add the number of packet losses to 1 to obtain the target number of packet losses.
[0169] If the functions described in the embodiments of this application are implemented as software functional units and sold or used as independent products, they can be stored in a computing device readable storage medium. Based on this understanding, the parts of the embodiments of this application that contribute to the prior art or the technical solutions can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computing device (which may be a personal computer, server, mobile computing device, 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, random access memory, magnetic disks, or optical disks.
[0170] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. In particular, for system or system embodiments, since they are fundamentally similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. Components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0171] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0172] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for recording packet loss information, characterized in that, include: When the reason for packet loss is received, the length of the first hash table is obtained, and the length of the hash table is determined by the reason for packet loss. Based on the length of the first hash table, determine the identifier of the packet loss reason and the target number of packet losses; When the packet loss reason is a preset packet loss reason, the key information of the packet is obtained; the preset packet loss reason indicates the reason why the packet is lost due to its own problem; The key information of the data packet is stored in the linked list corresponding to the identifier in the second hash table, and the target number of lost packets is stored in the first hash table. When the reason for packet loss is the target reason for packet loss, the target number of packet losses is stored in the first hash table; The target packet loss reason indicates that the packet loss is due to gateway performance issues. Determining the target number of lost packets based on the length of the first hash table includes: The packet loss reason is moduloed by the length of the first hash table to obtain the identifier of the packet loss reason; Find the number of packet losses corresponding to the identifier in the first hash table, and add the number of packet losses to 1 to obtain the target number of packet losses.
2. The method according to claim 1, characterized in that, Also includes: When a query request is received from a client, the query interface is invoked to retrieve packet loss information corresponding to the query request from the first hash table and / or the second hash table; the packet loss information includes the reason for packet loss, the number of packets lost, and key information. The packet loss information corresponding to the query request is serialized using the protobuf protocol to obtain the serialized packet loss information, and then the serialized packet loss information is sent to the client.
3. The method according to claim 2, characterized in that, The method of calling the query interface to obtain packet loss information corresponding to the query request from the first hash table and / or the second hash table includes: When the query request is a request to query the reason for packet loss and the number of packets lost, the query interface is called to obtain the reason for packet loss and the target number of packets lost from the first hash table; When the query request is a request to query the reason for packet loss and key information of a data packet, the query interface is invoked to retrieve the reason for packet loss and key information of the data packet from the second hash table; When the query request is a request to query the reason for packet loss, the number of packets lost, and key information of a data packet, the query interface is invoked to obtain the reason for packet loss, the target number of packets lost, and the key information of the data packet from the first hash table and the second hash table.
4. A device for recording packet loss information, characterized in that, include: The first acquisition unit is used to acquire the length of the first hash table when the reason for packet loss is received, wherein the length of the hash table is determined by the reason for packet loss. The determining unit is used to determine the identifier of the packet loss reason and the target number of packet losses based on the length of the first hash table; The second acquisition unit is used to acquire key information of the data packet when the packet loss reason is a preset packet loss reason; the preset packet loss reason indicates the reason why the data packet is lost due to its own problem; The first storage unit is used to look up the linked list corresponding to the identifier from the second hash table, store the key information of the data packet into the linked list corresponding to the identifier, and store the target number of lost packets in the first hash table; The second storage unit is used to store the target packet loss count in the first hash table when the packet loss reason is the target packet loss reason; the target packet loss reason indicates the reason for packet loss due to gateway performance. The determining unit is specifically used for: The packet loss reason is moduloed by the length of the first hash table to obtain the identifier of the packet loss reason; Find the number of packet losses corresponding to the identifier in the first hash table, and add the number of packet losses to 1 to obtain the target number of packet losses.
5. The apparatus according to claim 4, characterized in that, Also includes: The query unit is used to call the query interface to obtain packet loss information corresponding to the query request from the first hash table and / or the second hash table when a query request is received from the client; the packet loss information includes the reason for packet loss, the number of packets lost, and key information. The sending unit is used to serialize the packet loss information corresponding to the query request using the protobuf protocol, obtain the serialized packet loss information, and send the serialized packet loss information to the client.
6. The apparatus according to claim 5, characterized in that, The query unit is specifically used for: When the query request is a request to query the reason for packet loss and the number of packets lost, the query interface is called to obtain the reason for packet loss and the target number of packets lost from the first hash table; When the query request is a request to query the reason for packet loss and key information of a data packet, the query interface is invoked to retrieve the reason for packet loss and key information of the data packet from the second hash table; When the query request is a request to query the reason for packet loss, the number of packets lost, and key information of a data packet, the query interface is invoked to obtain the reason for packet loss, the target number of packets lost, and the key information of the data packet from the first hash table and the second hash table.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed by a processor, performs the method for recording packet loss information according to any one of claims 1-3.
8. An electronic device, characterized in that, include: Processor, memory, and bus; The processor and the memory are connected via the bus; The memory is used to store a program, and the processor is used to run the program, wherein the program is executed by the processor to perform the method for recording packet loss information according to any one of claims 1-3.
Citation Information
Patent Citations
Method and system for rapidly positioning packet loss of distribution equipment
CN103532779A
Packet loss information management method and device
CN111953568A