Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
Fig. 1 is a flow chart schematically illustrating a TELEMETRY-based packet loss rate statistics method according to one embodiment of the present invention.
The invention provides a packet loss rate statistical method based on TELEMETRY, as shown in figure 1, the method of the invention comprises the following steps:
S101, receiving messages sent by a first device and a second device.
TELEMETRY is a technology for collecting data from physical equipment or virtual equipment at high speed remotely, and the equipment periodically and actively transmits equipment information to a collector through a Push Mode, so that a more real-time, higher-speed and more accurate network monitoring function is provided. Because the data of the equipment can be obtained in real time through TELEMETRY, the data analysis, statistics and calculation can be performed in real time, so that the instantaneity and the efficiency of the packet loss rate of the statistical equipment are improved.
In one embodiment, the ip address and the port of the network management server need to be configured in the first device and the second device, so that the first device and the second device can send TELEMETRY data to the network management server, so that the network management server can calculate the packet loss rate between the first device and the second device according to the data sent by the first device and the second device, thereby realizing the statistics of the packet loss rate by replacing the device, reducing the complexity of the device, enabling the device to fully place the center of gravity on the primary service of the device, and improving the performance of the device.
Likewise, TELEMETRY configurations corresponding to the first device and the second device also need to be entered.
Because TELEMETRY configurations corresponding to the first equipment and the second equipment are recorded, when the packet loss rate is counted, the interference of the received messages sent by other equipment on the packet loss rate between the first equipment and the second equipment is avoided, and the accuracy of counting the packet loss rate is improved.
It can be understood that the first device and the second device can send data to each other, so when the packet loss rate is calculated, the packet loss rate from the first device to the second device can be calculated, the packet loss rate from the second device to the first device can also be calculated, and the flexibility of the packet loss rate of the statistical device is improved.
When the packet loss rate is counted, the message sent by the first device to the second device is different from the message sent by the first device and the second device to the network management server, the message sent by the first device to the second device is actual and detailed data, and the message sent by the first device and the second device to the network management server only contains flow basic data and no invalid data. For example, when a video file is transmitted from a first device to a second device, the message sent from the first device to the second device contains detailed video file data, and when the packet loss rate is counted, the data sent from the first device to the network management server only contains traffic basic data (data related to the packet loss rate, for example, tells the network management server how many messages it sent to the second device when). The content of the message sent by the equipment to the network management server is simple and the volume is small, so the method can transmit the data to be counted of the equipment to the network management server at high speed, so that the packet loss rate of the equipment can be counted rapidly, and the real-time performance is high. In addition, the method of the invention can be applied to the running process of the equipment, can count the packet loss rate of the equipment in real time, and does not need to additionally send test messages.
S102, analyzing the message according to a preset message format, judging whether the analyzed message is effective according to preset conditions, if so, storing flow basic data, and if not, discarding.
In one embodiment, the network management server parses the received message according to a preset message format. Specifically, the preset message format is shown in table 1.
TABLE 1TELEMETRY message formats
In Table 1, the types include send undyed package statistics (000), send dyed package statistics (001), receive undyed package statistics (010), and receive dyed package statistics (011). Only the same type of packet can be added, for example, 000 packets can be added with 000 packets, 001 packets can be added with 001 packets, etc., so that statistics of packet loss rate can be realized. The dyeing and undying are to distinguish the period of each stream (for example, in one file transmission, the time from the first message of the beginning of transmitting the file to the completion of all the file transmission is the period of the stream), if the type of the message transmitted in the current period of one stream is dyeing, the type of the message transmitted in the next period is undyed. By distinguishing different periods of the stream, the condition that messages in different periods are added is avoided, and therefore the accuracy of packet loss rate statistics is improved.
Further, as can be seen from table 1, the present invention reduces the occupied field by placing the number of packets received and the number of packets transmitted in one field (i.e., the number of packets received/transmitted is the number of packets transmitted, and the number of packets received/transmitted is the number of packets received, and the time of packet received and the time of packet transmitted in one field (time of packet received/transmitted), thereby reducing the volume of the message and further improving the rate of message transmission.
Further, in the time of receiving/transmitting packets, by counting only the first packet in the period, the other packets are not counted, so that the computing resources and the storage resources are reduced. And by only recording the minutes and seconds of the packet receiving/transmitting time and not recording the time of year, month and day, the length of the time data is shortened, so that the efficiency of binary conversion of the time data is improved, the efficiency of message assembly is improved, and the efficiency of message transmission is further improved. In addition, the occupied message space is saved, and the message transmission efficiency is further improved, so that the obtained packet loss rate can reflect the current state of the equipment, and the instantaneity is high.
In one embodiment, the time of receiving/transmitting packets is a relative nanosecond time unit number, for example, when the time of receiving/transmitting packets in a message is 1000, the actual time of receiving/transmitting packets is 1000 pieces of 6.25ns, and then the obtained nanosecond conversion component and second are integrated with the reference time, so that the complete time of receiving/transmitting packets can be obtained. For example, since 5 minutes is set as a time span in the present embodiment, the reference time is 5, 10, 15, etc., if the current time of the network management server is 9 hours and 28 minutes, the reference time is 25 minutes, and if the statistics value is 3 minutes and 10 seconds (the time unit number is converted into nanoseconds and then into minutes and seconds), the actual packet receiving/sending time is 28 minutes and 10 seconds, and the complete time (including year, month, day and time) can be filled by the upper layer software.
By taking the time of receiving/transmitting packets as a nanosecond unit, the accuracy of the obtained time of receiving/transmitting packets is improved, and in addition, the transmission delay can be accurately calculated and the network performance can be accurately estimated according to actual requirements. Further, by setting the packet receiving/transmitting time to the number of time units of the relative nanoseconds, the occupied message space can be further reduced, so that the efficiency of message transmission is improved. In addition, the minimum unit can be set according to actual requirements, and the flexibility is high.
In alternative other embodiments, the 5 minutes in the time of receiving/transmitting packets may be set to 10 minutes or other values, and the space occupied by the number of receiving/transmitting packets, the time of receiving/transmitting packets, etc. may be changed, which may be set by those skilled in the art according to actual requirements.
By setting the message format into the above form, the content of the message can be effectively reduced, and the volume of the message can be reduced, so that the message can be efficiently sent to the network management server to perform statistical calculation of the packet loss rate, and the efficiency and instantaneity of the calculation of the packet loss rate are improved.
In one embodiment, time synchronization between the device and the server may be ensured by a network time protocol (Network Time Protocol, NTP) and/or a precision time protocol (Precision Time Protocol, PTP), thereby avoiding errors in the statistical packet loss rate due to time dyssynchrony. Specifically, the network management server can be used as a master clock device, other devices are used as slave clock devices, and the master clock device sends high-precision time information to the slave clock devices through a PTP protocol, so that the slave clock devices adjust own time according to clock deviation between the master clock and the slave clock, and synchronization with the master clock is achieved.
In one embodiment, each 512 streams (or messages) may be simultaneously transmitted as a packet, so that the transmission efficiency can be further improved, and the specific format is shown in table 2:
TABLE 2
As can be seen from table 2, when 512 streams are not reached, the padding can be performed by 0.
It should be noted that, the packet sending time in table 1 refers to the packet sending time of packets composed of 512 streams, and the packet receiving/sending time refers to the packet receiving/sending time corresponding to each packet, so when 512 streams are not formed into one packet to be sent at the same time, the packet sending time (without reserving space) may not be set in the packet, so that the space occupied by the packet can be correspondingly reduced, and those skilled in the art can set according to actual requirements.
The packet sending time and the packet receiving/sending time in the message format are the same, the time of year, month and day is not recorded, only minutes and seconds are recorded, and 5 minutes are used as a statistics span, so that the occupied volume of the message can be reduced, the content of the message is simplified, the volume is small, and the efficiency of message transmission is high. Also, the value of the time span of the time of the package delivery can be set by those skilled in the art according to actual needs, which is not limiting to the present invention.
Specifically, the result of the message parsing is shown in fig. 3. In fig. 3, rcv_snd_packets represent the number of packets received/transmitted in a packet, type represents the type in the packet, report_ip represents the ip address corresponding to a device, flow_mon_id_ext represents the device id in the packet, flow_mon_id represents the stream id in the packet, and send_time represents the packet transmission time in the packet. The information such as the time of the receiving/transmitting package and the quantity of the receiving/transmitting package of the equipment can be intuitively displayed through the figure 3.
Further, judging whether each byte of data in the analyzed message meets the requirement of the message format, if not, indicating that the equipment has error record log or the data is incomplete, discarding the message, if so, judging whether the message is effective according to preset conditions, if not, discarding, and if so, storing the basic flow data obtained by analysis into a database.
Specifically, when the network management server receives a message sent by the first device, but does not receive a message sent by the second device within 5 minutes, the message sent by the first device is an invalid message (packet loss rate cannot be calculated only based on the message sent by the first device), the message is discarded, and if the message sent by the second device is received within 5 minutes, the flow basic data obtained after analysis is stored in the database. Similarly, when the message sent by the second device is received and the message sent by the first device is not matched in the database, or the message sent by the first device is not received within 5 minutes, the message sent by the second device is discarded. By discarding invalid messages, the integrity and the accuracy of data are ensured, and incorrect packet loss rate is avoided, so that the accuracy of counting the packet loss rate is improved.
S103, determining the packet loss rate according to the flow basic data.
In one embodiment, based on the stream id and type in the message, data is determined that is the same for the stream (stream id is the same), that is corresponding to the type (000 corresponds to 010,001 corresponds to 011), and that is within a preset value for the time interval. Typically, they will occur in pairs, one of which is transmitted data and the other of which is received data. If only data is received or only data is sent, the data does not participate in the calculation of the packet loss rate. For example, in the process that the first device sends data to the second device, the first device sends a message at a certain moment and informs the network management server that the first device sends the message, and after the second device receives the message sent by the first device, for some reasons (for example, network disconnection, network blocking, etc.), the second device does not inform the network management server that the first device receives the message within a preset time interval, and then the message sent by the first device to the network management server belongs to an invalid message.
In one embodiment, the preset value relates to a span time in the packet reception/transmission time, specifically, the preset value is 5 minutes.
By matching the data in the database, the calculation of the packet loss rate of the data which are not corresponding to different streams and types or are not in the same time span is avoided, so that the incorrect packet loss rate is prevented from being obtained, and the accuracy of calculating the packet loss rate is improved.
Further, based on the matched data, calculating and counting the packet loss rate. Specifically, the calculation formula of the packet loss rate is as follows:
Packet loss rate= (total number of messages sent by the first device-total number of messages received by the second device)/total number of messages sent by the first device.
It may be understood that, in the above formula, the total number of messages sent by the first device refers to the number of messages sent by the first device to the second device (which is known by the first device to the network management server), and the total number of messages received by the second device refers to the number of messages received by the second device to the first device (which is known by the second device to the network management server).
In one embodiment, the statistical packet loss rate is saved and displayed. Specifically, the packet loss ratio between the first device and the second device is shown in fig. 4. Fig. 4 intuitively shows packet loss situations of different streams between the first device and the second device at different time points.
In summary, the method of the invention obtains the packet loss rate between the first device and the second device through statistical calculation from the messages sent by the first device and the second device, thereby realizing packet loss rate statistics by replacing the device, reducing the complexity of the device and improving the performance of the device. In addition, the messages sent by the first equipment and the second equipment only contain flow basic data, the content is simple, the size is small, the efficiency of the obtained packet loss rate can be improved, the instantaneity is high, and when the packet loss rate is calculated by statistics, calculation can be performed only by data matched with the data, so that incorrect packet loss rate is prevented from being obtained, and the accuracy of the calculated packet loss rate is improved.
In another embodiment, the method of the present invention may also be implemented as shown in FIG. 2. In the process of judging whether the message is valid or not, if the message is invalid, discarding the message, and continuing to analyze the received message; if the message is effective, the flow basic data obtained by analysis is stored in a database.
It will be appreciated that the above method steps are divided, and for clarity of description, the steps may be combined into one step or split into multiple steps, so long as the same logical relationship is included.
In the description of the present specification, the meaning of "plurality" means at least two, for example, two, three or more, etc., unless explicitly defined otherwise.
While various embodiments of the present invention have been shown and described herein, it will be obvious to those skilled in the art that such embodiments are provided by way of example only. Many modifications, changes, and substitutions will now occur to those skilled in the art without departing from the spirit and scope of the invention. It should be understood that various alternatives to the embodiments of the invention described herein may be employed in practicing the invention.