Detailed Description
In order to make the technical scheme of the invention more clear, the invention is further described in detail with reference to the attached drawings:
the network equipment is installed in relatively dispersed places and is far away from a control center. When the traffic on the data card is insufficient or under-charged abnormal conditions, the control center cannot monitor the residual traffic on the data card in real time, which causes sudden interruption of network service, packet loss and other conditions, and affects the customer service. Meanwhile, after the control center carries out arrearage recharging on the network equipment, the network equipment cannot automatically recover and register to the network, and special technical service personnel are required to go to the site for processing, so that the problem of increasing the equipment maintenance cost is solved.
In combination with the application scenario shown in fig. 1, an embodiment of the present invention provides a packet sending method, where a traffic usage is calculated according to a value of a Maximum Transmission Unit (MTU), and different traffic processing manners are adopted when remaining traffic reaches different traffic thresholds in a traffic usage process. As shown in fig. 2, the method includes:
step 201, after a mobile communication interface on a network device is loaded successfully, starting flow monitoring to obtain the current available flow of the mobile communication interface;
in this step, the starting of the flow monitoring to obtain the current available flow includes:
before the network equipment dials up through the mobile communication interface, acquiring initial available flow in a short message query mode;
acquiring the number of transmitted message bytes of the mobile communication interface in real time;
and calculating the difference value between the initial available flow and the number of the sent character sections to obtain the current available flow.
Preferably, in the process of flow monitoring, different flow thresholds may be set, and the currently available flow is monitored according to the flow thresholds and a corresponding flow processing mode is executed.
The starting of the flow monitoring to obtain the current available flow further comprises:
if the current available flow is larger than the first flow threshold, delaying for a certain time and then obtaining the current available flow according to the set cycle time;
if the current available flow is larger than the second flow threshold and smaller than or equal to the first flow threshold, generating and reporting flow early warning information;
if the current available flow is larger than the third flow threshold and smaller than or equal to the second flow threshold, generating flow alarm information and reporting the flow alarm information; in the embodiment of the present invention, the traffic alarm information may be reported only a certain number of times, for example, 10 times, and if the traffic alarm information has been reported 10 times, the traffic alarm information is not reported any more.
And if the current available flow is smaller than the third flow threshold, generating flow stop information and reporting the flow stop information in a short message mode. In order to avoid consuming the remaining traffic, in the embodiment of the present invention, the traffic stop information may be reported only a certain number of times, for example, 5 times. If the report has been reported for 5 times, the report is not continued.
After reporting the traffic stop information in a short message mode, periodically inquiring the short message to inquire the current available traffic condition, and if the available traffic information cannot be inquired in the short message for 5 times continuously, restarting the modem once to realize that the modem with the arrearage restarts to complete network registration.
The size of the above 3 flow thresholds can be set according to an actual application scenario, but the first flow threshold is greater than the second flow threshold, and the second flow threshold is greater than the third flow threshold. For example, a first flow threshold value of 30% of the initial available flow, a second flow threshold value of 10% of the initial available flow, and a third flow threshold value of 2% of the initial available flow may be set.
For example, different flag bits can be set in practical application to realize different traffic processing modes,
if the flag bit is set to flag, different flag values may be set to indicate that different traffic processing modes are performed, for example: periodically inquiring the current available flow when the flag value is defined as FREE _ WAIT;
reporting the flow early warning information to a control center when the flag value is WARN _ WATER;
reporting the flow alarm information to a control center when the flag value is LOW _ WATER, and reporting the flow STOP information to the control center in a short message mode when the flag value is STOP _ WATER;
and when the flag value is FLOW _ QUERY, acquiring the initial available FLOW by a short message QUERY mode.
The invention can realize the autonomous flow monitoring and remote control of the network equipment which is far away from the control center and is installed dispersedly, avoid the influence of the flow overdraft of the network equipment on the normal operation of the equipment, improve the stability of the operation of the equipment and reduce the maintenance cost and the labor input of the network equipment.
Step 202, calculating the number of messages which can be sent currently according to the maximum transmission unit configured on the mobile communication interface and the current available flow;
in this step, the calculating the number of currently transmittable messages according to the maximum transmission unit configured on the mobile communication interface includes:
dividing the current available flow by the maximum transmission unit, wherein the obtained value is the number of the messages which can be sent currently; the calculation formula here is: the number of currently transmittable messages is equal to the current available traffic/MTU, where the MTU may be set to 1500.
When the current available flow is smaller than the maximum transmission unit, the number of currently transmittable messages is 0. For example, the current available flow rate is 1400, and since the maximum transmission unit is 1500, the number of currently-transmittable messages at this time is less than 1, and the number of currently-transmittable messages at this time is 0.
In the embodiment of the invention, the maximum transmission unit can be selectively configured by a tester within the allowable range of the network equipment.
And 203, sending the message to be sent according to the calculated number of the current messages to be sent and the current available flow.
In this step, the sending the message to be sent according to the calculated number of the currently-sent messages and the current available flow includes:
when the number of the messages which can be sent currently is judged to be not 0 and the current available flow is larger than a third flow threshold value, sending the messages to be sent, and accumulating the number of bytes of the sent messages;
preferably, in this step, after the message to be sent is sent, the number of currently sent messages is subtracted by 1, and the number of bytes of the sent message is accumulated until the number of currently sent messages is 0, so that the repeated calculation of the available flow in the message sending process is avoided through successive approximation of the number of the sent messages.
When the number of the messages which can be sent at present is judged to be 0, and the number of bytes of the messages to be sent is smaller than the current available flow, sending the messages to be sent, and accumulating the number of bytes of the sent messages;
the following are exemplified: and if the number of the messages to be sent is 1300, the current remaining available flow is 1400, which is smaller than the maximum transmission unit 1500 but is greater than the number of the messages to be sent, which is 1300, the message to be sent is allowed to be sent, otherwise, the message to be sent is forbidden to be sent.
And when the flow stop information is judged to be generated, the message to be sent is not sent any more.
The invention only adds simple operations such as judgment, statistics and the like in the existing message sending process, takes the maximum transmission unit as the basic message length, avoids the repeated calculation of the available flow in the message sending process through the successive approximation of the number of the messages which can be sent, and determines whether the messages can be sent or not through judging whether the number of the messages which can be sent is 0 or not. And the flow of the equipment end is autonomously monitored in real time under the condition of not influencing the sending performance. Meanwhile, the abnormal situation of the flow is correspondingly processed in the flow counting process. The invention belongs to pure software implementation, does not depend on the change of network equipment, can flexibly monitor the flow use condition of the network equipment, improves the running stability of the network equipment, and reduces the equipment maintenance cost and the labor input of customers.
An embodiment of the present invention further provides a network device, which can implement a message sending method according to the embodiment of the present invention, and as shown in fig. 3, the network device 30 includes:
the interface loading module 301 is configured to load a mobile communication interface, and start a traffic monitoring module after the mobile communication interface is successfully loaded;
a traffic monitoring module 302, configured to perform traffic monitoring to obtain a current available traffic of the mobile communication interface;
a calculating module 303, configured to calculate the number of currently-transmittable messages according to the maximum transmission unit configured on the mobile communication interface and the currently-available flow;
and a message sending module 304, configured to send a message to be sent according to the calculated number of currently-sent messages and the current available flow.
The flow monitoring module 302 is specifically configured to:
before the network equipment dials up through the mobile communication interface, acquiring initial available flow in a short message query mode;
acquiring the number of transmitted message bytes of the mobile communication interface in real time;
and calculating the difference value between the initial available flow and the number of the sent character sections to obtain the current available flow.
The flow monitoring module 302 is further configured to:
if the current available flow is larger than the first flow threshold, delaying for a certain time and then obtaining the current available flow according to the set cycle time;
if the current available flow is larger than the second flow threshold and smaller than the equal first flow threshold, generating and reporting flow early warning information;
if the current available flow is larger than the third flow threshold and smaller than or equal to the second flow threshold, generating flow alarm information and reporting the flow alarm information;
and if the current available flow is smaller than the third flow threshold, generating flow stop information and reporting the flow stop information in a short message mode.
The calculating module 303 is specifically configured to:
dividing the current available flow by the maximum transmission unit, wherein the obtained value is the number of the messages which can be sent currently;
when the current available flow is smaller than the maximum transmission unit, the number of currently transmittable messages is 0.
The message sending module 304 is specifically configured to:
when the number of the messages which can be sent currently is judged to be not 0 and the current available flow is larger than a third flow threshold value, sending the messages to be sent, and accumulating the number of bytes of the sent messages;
when the number of the messages which can be sent at present is judged to be 0, and the number of bytes of the messages to be sent is smaller than the current available flow, sending the messages to be sent, and accumulating the number of bytes of the sent messages;
and when the flow stop information is judged to be generated, the message to be sent is not sent any more.
The invention realizes the autonomous real-time monitoring of the flow of the network equipment under the condition of not influencing the sending performance. Meanwhile, the abnormal situation of the flow is correspondingly processed in the flow counting process. The invention does not depend on the change of the network equipment, can flexibly monitor the flow use condition on the network equipment, improves the running stability of the network equipment, and reduces the equipment maintenance cost and the labor input of a client.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.