CN107682212B - Multi-user network communication exception handling method for embedded equipment - Google Patents

Multi-user network communication exception handling method for embedded equipment Download PDF

Info

Publication number
CN107682212B
CN107682212B CN201711125076.7A CN201711125076A CN107682212B CN 107682212 B CN107682212 B CN 107682212B CN 201711125076 A CN201711125076 A CN 201711125076A CN 107682212 B CN107682212 B CN 107682212B
Authority
CN
China
Prior art keywords
effective
data
state
connection
socket connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201711125076.7A
Other languages
Chinese (zh)
Other versions
CN107682212A (en
Inventor
张彦超
艾伦
孟祥�
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Research Institute of Telemetry
Aerospace Long March Launch Vehicle Technology Co Ltd
Original Assignee
Beijing Research Institute of Telemetry
Aerospace Long March Launch Vehicle Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Research Institute of Telemetry, Aerospace Long March Launch Vehicle Technology Co Ltd filed Critical Beijing Research Institute of Telemetry
Priority to CN201711125076.7A priority Critical patent/CN107682212B/en
Publication of CN107682212A publication Critical patent/CN107682212A/en
Application granted granted Critical
Publication of CN107682212B publication Critical patent/CN107682212B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/16Threshold monitoring
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Communication Control (AREA)

Abstract

The invention relates to a multi-user network communication exception handling method of an embedded device, which is realized based on a W5300 network chip and can ensure that 1) when user software for performing network communication with the embedded device fails or application layers for debugging and the like are abnormal, the embedded device only interrupts network communication, and other business works are not influenced; 2) when the user application layer is recovered abnormally, the network communication can be recovered to be normal; 3) when the embedded device is in a multi-user communication state, the network communication of only the user with abnormal application layer can be interrupted, and the network communication of other users is normal; the method makes up the defect of processing the abnormal communication of the application layer by the multi-user network chip, optimizes the processing strategy of multi-user data transmission, perfects the multi-user network data transmission design of the embedded equipment and greatly improves the reliability and the user experience of the embedded equipment.

Description

Multi-user network communication exception handling method for embedded equipment
Technical Field
The invention relates to a method for processing abnormal network communication of multiple users of embedded equipment, belongs to the technical field of embedded network communication, and is suitable for various embedded equipment for realizing network communication based on a W5300 chip.
Background
The multi-user network chip is a single chip integrated with TCP/IP protocol, and can simply and quickly realize Internet connection. The chip and the host adopt a bus interface, and the host can realize the interface with the chip in a direct access mode or an indirect access mode and support the connection of a plurality of independent sockets. But typically the data communication memory of the chip is only accessible via the TX/RX FIFO register.
When the chip SENDs data, the host needs to copy the data to be sent to a corresponding socket sending memory through a TX FIFO register of the socket, and then SENDs a SEND control instruction and sets the length of the sent data, so that the specified socket executes sending operation. Because the capacity of the socket sending memory is limited, the data to be sent can be copied to the socket sending memory only when the remaining memory space is enough to accommodate the data to be sent. And socket completes a SEND operation in which the break register changes to the SENDOK state. In case of unpredictable errors, the host can give the SEND control instruction of the next packet of data only after detecting and clearing the SEND state of the interrupt register. The data transmission reference program flow of the W5300 chip is shown in fig. 1.
In fig. 1, assuming that there are N valid socket connections, when data to be transmitted is copied to a TX FIFO register of a transmission buffer, a1-aN infinite loops are designed, and when a SENDOK state is queried, b1-bN infinite loops are designed, which is 2 times the number of valid sockets in total. This makes it necessary to cause the embedded device to be in an infinite wait state as long as any one of the above infinite loops cannot jump out. Not only influences the normal network communication connected with other sockets, but also influences other business work of the embedded device, and directly influences the reliability of the embedded device.
The network chip is usually designed with a retransmission timeout mechanism, specifically: when one-time transmission of the TCP data packet is timed out, the chip automatically retransmits the TCP data packet and waits for response information. If the response information is not received within the specified time, the chip starts to retransmit again. When the retransmission times exceed the 'RCR + 1' times set by the chip, the chip retransmission timeout interruption is triggered, and the interruption response is the disconnection of the socket connection. However, the overtime design is specific to a transmission layer of a four-layer model of a TCP/IP protocol stack, and only multiple retransmission failures of the transmission layer can trigger the overtime interrupt of the chip to enable the chip to make an overtime response. For application layer exceptions such as user software failure or debugging, the chip usually has no corresponding design.
In view of the above problems, a solution is needed to perfect the data transmission design of the network chip when the network application layer is abnormal, and improve the reliability of the chip using equipment.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provide a method for processing the abnormal network communication of multiple users of an embedded device, which overcomes the defects of the existing data transmission design of a network chip and ensures that the embedded device can stably and reliably work when the network communication of an application layer is abnormal, and the connection communication of other users is not influenced.
The above purpose of the invention is mainly realized by the following technical scheme:
a method for processing abnormal network communication of embedded equipment multi-user comprises the following steps:
(1) traversing the connection states of a plurality of sockets supported by the network communication chip, judging whether effective socket connection is established, if the effective connection is established, entering the step (2), and if not, ending;
(2) comparing the lengths of all data to be sent with the maximum sending data length connected with the effective socket, if the length of the data to be sent is greater than or equal to the maximum sending data length connected with the effective socket, setting the length of the data to be sent as the maximum sending data length connected with the effective socket, and if not, keeping the length of the data to be sent unchanged, and entering the step (3);
(3) the method comprises the steps of detecting the effective socket connection in a normal state and the effective socket connection in an abnormal state in the effective socket connection, sending all data to be sent through the effective socket connection in the normal state, carrying out threshold judgment on the effective socket connection in the abnormal state, eliminating the effective socket connection in the abnormal state exceeding the threshold judgment times from the effective socket connection, and sending the data to be sent to the effective socket connection in the abnormal state not exceeding the threshold judgment times.
In the above method for processing the abnormal communication of the multi-user network of the embedded device, the implementation method of the step (3) specifically includes the following steps:
(3.1) judging and processing the working states of the N effective socket connections;
(3.2) judging and processing the connection state of the N effective socket connections;
(3.3) judging whether to write data to be sent in the sending memories connected with the N effective sockets;
(3.4) judging and processing the connection state of the N effective socket connections again;
(3.5) all data to be sent are sent outwards through N effective socket connections;
(3.6) detecting whether the working state of the N effective socket connections is an abnormal working state;
wherein: n is a positive integer, and N is more than or equal to 1.
In the above method for processing the abnormal communication of the multi-user network of the embedded device, the specific implementation method of the step (3) includes the following steps:
(3.1) judging and processing the working state of the connection of the N effective sockets, wherein the specific method for judging and processing the working state of one effective socket is as follows:
judging the working state of the effective socket connection, establishing an abnormal state mark for the effective socket connection in the abnormal working state, inquiring the state of the last data transmission, judging whether the transmission memory of the effective socket connection in the abnormal working state is empty if the state is successful, and canceling the abnormal state mark of the effective socket connection and processing the next effective socket connection if the transmission memory is empty; if the sending memory is not empty, all data in the sending memory are sent outwards, and then the next effective socket connection is processed;
if the state is sending failure, processing the next valid socket connection;
(3.2) judging and processing the connection state of the N effective sockets, wherein the specific method for judging and processing the connection state of one effective socket is as follows:
acquiring the available length of a sending memory of an effective socket connection, judging the connection state of the effective socket connection, if the connection state is not connected, removing the effective socket connection from N effective socket connections, and then processing the next effective socket connection;
if the connection state is connected, processing the next valid socket connection;
(3.3) judging whether to write data to be sent in the sending memories connected with the N effective sockets, wherein a specific method for judging whether to write data to be sent in the sending memory connected with one effective socket is as follows:
judging whether the available length of a sending memory of the effective socket connection is greater than or equal to the length of the current data to be sent, if so, writing the current data to be sent into the memory of the effective socket connection and marking, and then processing the next effective socket connection;
if the length of the data to be sent is smaller than the length of the data to be sent, processing the next effective socket connection;
(3.4) judging and processing the connection state of the N effective sockets again, wherein the specific method for judging and processing the connection state of one effective socket is as follows:
detecting the connection state of the effective socket connection, if the connection state is not connected, removing the effective socket connection from the N effective socket connections, and then processing the next effective socket connection;
if the connection state is connected, further acquiring the sending state of the last sending data of the effective socket connection, and then processing the next effective socket connection;
(3.5) sending all the data to be sent outwards through N effective socket connections, wherein a specific method for sending the data to be sent outwards through one effective socket connection is as follows:
detecting whether the effective socket connection is used for sending data for the first time, if so, directly sending the data to be sent outwards and marking the data, and then processing the next effective socket connection;
if the data is not sent for the first time, detecting a data sending state and a data writing state of the valid socket connection, if the data is sent successfully and the data is written, clearing the last sending success state, sending the current data to be sent and marking, and then processing the next valid socket connection; if the data transmission fails or the data is not written in, processing the next valid socket connection;
(3.6) detecting whether the working state of the N effective socket connections is an abnormal working state, wherein the specific method for detecting whether the working state of one effective socket connection is the abnormal working state is as follows:
judging whether data to be sent of an effective socket connection is sent or not, if so, eliminating the effective socket connection from N effective socket connections, and then processing the next effective socket connection;
if not, judging whether the execution times of the steps (3.1) - (3.6) reach a set threshold, if so, marking the working state of the effective socket connection as an abnormal working state, and processing the next effective socket connection; and if the set threshold is not reached, processing the next valid socket connection.
In the above method for processing the abnormal communication of the multi-user network of the embedded device, in the step (3.1), if the duration of the valid socket connection in the abnormal state exceeds the communication interruption threshold, the valid socket connection is removed from the N valid socket connections.
In the above method for processing the abnormal communication of the multi-user network of the embedded device, the step (3.6) judges whether all the N effective socket connections complete data transmission after detecting whether the working states of the N effective socket connections are abnormal working states, if all the N effective socket connections complete data transmission, the step is finished, and if not, the steps (3.1) - (3.6) are repeated.
In the above method for processing the abnormal communication of the multi-user network of the embedded device, the threshold set in the step (3.6) is 6000 times and 7000 times.
Compared with the prior art, the invention has the following beneficial effects:
(1) the invention increases the strategy of processing the communication abnormity of the application layer network of the user software by the embedded equipment and makes up the defect of processing the communication abnormity of the application layer by most embedded multi-user network communication chips.
(2) The invention optimizes the processing strategy of multi-user data transmission, when the network chip is in the process of establishing multi-user network connection, namely a plurality of effective socket connections, the processing of multi-user data transmission is generally parallel, the data transmission among users is independent and not influenced by the data transmission of the previous socket, and the data transmission time among the socket connections is basically consistent.
(3) The invention improves the data transmission strategy of the chip, changes the while infinite loop design of copying the data to be transmitted to the TX FIFO register of the transmission buffer area and inquiring the SENDOK state into finite loop, and avoids the defect that the embedded device program is always in a long-time data transmission waiting state when the application layer network communication is abnormal.
(4) The invention updates the effective socket sequence in time, reduces the socket base number of subsequent processing and improves the processing efficiency of the embedded equipment.
(5) The invention determines the maximum waiting times through theoretical analysis and actual measurement statistics of the maximum data sending quantity for a long time, namely, the threshold is set to 6000-7000 times, so that the software resources are saved under the condition of meeting the requirement of multi-user network communication, and the data processing efficiency is improved.
Drawings
Fig. 1 is a flowchart of a W5300 data transmission reference routine;
FIG. 2 is a flowchart of a method for handling an exception of a multi-user network communication of an embedded device according to the present invention;
fig. 3 is a connection diagram of the DSP chip and the W5300 chip according to the present invention.
Detailed Description
The invention is described in further detail below with reference to the figures and specific embodiments.
As shown in fig. 2, a flowchart of the method for processing the abnormal communication of the multi-user network of the embedded device of the present invention is shown, and the method for processing the abnormal communication of the multi-user network of the embedded device of the present invention specifically includes the following steps:
(1) traversing the connection states of a plurality of sockets supported by the network communication chip, judging whether effective socket connection is established, if the effective connection is established, entering the step (2), and if not, ending;
(2) comparing the lengths of all data to be sent with the maximum sending data length connected with the effective socket, if the length of the data to be sent is greater than or equal to the maximum sending data length connected with the effective socket, setting the length of the data to be sent as the maximum sending data length connected with the effective socket, and if not, keeping the length of the data to be sent unchanged, and entering the step (3);
(3) the method comprises the steps of detecting the effective socket connection in a normal state and the effective socket connection in an abnormal state in the effective socket connection, sending all data to be sent through the effective socket connection in the normal state, carrying out threshold judgment on the effective socket connection in the abnormal state, eliminating the effective socket connection in the abnormal state exceeding the threshold judgment times from the effective socket connection, and sending the data to be sent like the effective socket connection in the normal state to the effective socket connection in the abnormal state not exceeding the threshold judgment times.
Effective socket sending processing circulation, the sending threshold is set to 6000-7000 times in the invention, the sending processing time reaches the threshold value, then ending, otherwise executing the following circulation body step, namely the concrete implementation method of the step is as follows
(3.1) judging and processing the working state of the connection of the N effective sockets, wherein the specific method for judging and processing the working state of one effective socket is as follows:
judging the working state of the effective socket connection, establishing an abnormal state mark for the effective socket connection in the abnormal working state, inquiring the state of the last data transmission, judging whether the transmission memory of the effective socket connection in the abnormal working state is empty if the state is successful, and canceling the abnormal state mark of the effective socket connection and processing the next effective socket connection if the transmission memory is empty; if the sending memory is not empty, all data in the sending memory are sent outwards, and then the next effective socket connection is processed;
if the state is sending failure, processing the next valid socket connection;
and if the duration of the effective socket connection in the abnormal state exceeds a communication interruption threshold, removing the effective socket connection from the N effective socket connections.
(3.2) judging and processing the connection state of the N effective sockets, wherein the specific method for judging and processing the connection state of one effective socket is as follows:
acquiring the available length of a sending memory of an effective socket connection, judging the connection state of the effective socket connection, if the connection state is not connected, removing the effective socket connection from N effective socket connections, and then processing the next effective socket connection;
if the connection state is connected, processing the next valid socket connection;
(3.3) judging whether to write data to be sent in the sending memories connected with the N effective sockets, wherein a specific method for judging whether to write data to be sent in the sending memory connected with one effective socket is as follows:
judging whether the available length of a sending memory of the effective socket connection is greater than or equal to the length of the current data to be sent, if so, writing the current data to be sent into the memory of the effective socket connection and marking, and then processing the next effective socket connection;
if the length of the data to be sent is smaller than the length of the data to be sent, processing the next effective socket connection;
(3.4) judging and processing the connection state of the N effective sockets again, wherein the specific method for judging and processing the connection state of one effective socket is as follows:
detecting the connection state of the effective socket connection, if the connection state is not connected, removing the effective socket connection from the N effective socket connections, and then processing the next effective socket connection;
if the connection state is connected, further acquiring the sending state of the last sending data of the effective socket connection, and then processing the next effective socket connection;
(3.5) sending all the data to be sent outwards through N effective socket connections, wherein a specific method for sending the data to be sent outwards through one effective socket connection is as follows:
detecting whether the effective socket connection is used for sending data for the first time, if so, directly sending the data to be sent outwards and marking the data, and then processing the next effective socket connection;
if the data is not sent for the first time, detecting a data sending state and a data writing state of the valid socket connection, if the data is sent successfully and the data is written, clearing the last sending success state, sending the current data to be sent and marking, and then processing the next valid socket connection; if the data transmission fails or the data is not written in, processing the next valid socket connection;
(3.6) detecting whether the working state of the N effective socket connections is an abnormal working state, wherein the specific method for detecting whether the working state of one effective socket connection is the abnormal working state is as follows:
judging whether data to be sent of an effective socket connection is sent or not, if so, eliminating the effective socket connection from N effective socket connections, and then processing the next effective socket connection;
if not, judging whether the execution times of the steps (3.1) - (3.6) reach a set threshold, if so, marking the working state of the effective socket connection as an abnormal working state, and processing the next effective socket connection; and if the set threshold is not reached, processing the next valid socket connection.
And (3.7) judging whether all the N effective socket connections complete data transmission, finishing if all the N effective socket connections complete data transmission, and repeating the steps (3.1) - (3.6) if not complete data transmission.
Wherein N is a positive integer, for example, the value of N in this embodiment may be 1. ltoreq. N.ltoreq.8.
The invention is realized based on a W5300 network chip, the DSP chip interface is expanded through a CPLD chip to be connected with the W5300 chip, the W5300 chip is controlled through the DSP chip, and the multi-user network communication of the embedded device is realized, and as shown in FIG. 3, a connection diagram of the DSP chip and the W5300 chip is shown.
The invention relates to a method for processing the abnormal network communication of a plurality of users of an embedded device, which is realized based on a W5300 network chip and can ensure that 1) when the user software which carries out network communication with the embedded device has faults or application layer abnormity such as debugging and the like, the embedded device only interrupts the network communication, and other business works are not influenced; 2) when the user application layer is recovered abnormally, the network communication can be recovered to be normal. 3) When the embedded device is in a multi-user communication state, the network communication of only the user with abnormal application layer can be interrupted, and the network communication of other users is normal. The method makes up the defect that most embedded multi-user network communication chips process the communication abnormity of the application layer, optimizes the processing strategy of multi-user data transmission, perfects the multi-user network data transmission design of the embedded equipment, and greatly improves the reliability and user experience of the embedded equipment.
Example 1
Fig. 3 is a flow chart of the method of the present invention, and the present invention is further described in detail with reference to fig. 3.
Table 1 test scenario description table of the present invention
Figure BDA0001468213310000091
The test scene conditions are that three socket connections are established with the embedded device through the monitoring software, wherein one monitoring software is normally connected, one monitoring software is in a breakpoint debugging state, the last monitoring software is in a debugging state, and the specific state is as shown in table 1. The method for processing the abnormal communication of the multiple users provided by the invention is utilized to ensure that the communication of the user 1 is not influenced, the communication of the user 2 is suspended, the communication of the user 3 is recovered, and other services of the embedded equipment work normally, and the method comprises the following specific steps:
(1) traversing the connection states of 8 sockets supported by the W5300, determining to establish 3 effective socket connections, where an effective connection sequence is socket _ ok [8] ═ 1,2,3,0,0,0,0,0}, and entering step (2);
(2) and acquiring the maximum sending data length of the effective socket connection. The Data length to be transmitted is smaller than the maximum transmission Data length of the socket, so Data _ length [8] = {864, 0,0,0,0}, and step (3) is performed;
(3) the effective socket is connected with a sending processing cycle, a sending threshold is set to be 6000 times, if the sending processing times reach the threshold value, the sending function call is quitted, otherwise, the following cycle body steps are executed:
(a1) judging that the working state of socket 1 is normal, directly judging the working state of socket 2, and inquiring the data sending state if the result is abnormal. And if the data sending state is sending failure, further judging whether the number of times of calling the sending function exceeds a communication interruption threshold (set to be 2), if so, removing socket 2 from the effective socket sequence, wherein the number of effective sockets is 2, and socket _ ok [8] ═ 1,3,0,0, 0}. And (3) judging that the working state of the socket 3 is an abnormal state, resetting the failure state frequency of the interrogator if the data transmission state of the interrogator is successful, recovering the working state to be a normal state, and sending out all data in the transmission memory. The traversal of the valid socket connection ends and the step (a2) is entered; processing all the 3 effective socket connections, and then entering the step (a 2);
(a2) and obtaining the residual length of the sending memory of the socket 1 as 2637 bytes, judging that the socket connection state is established, and not changing the effective connection sequence. And obtaining the residual length of the sending memory of socket 3 as 687 bytes, judging that the connection state is established, and not changing the effective connection sequence. The traversal of the valid socket connection ends and the step (a3) is entered;
(a3) determining that the remaining length 2637 of the sending memory of socket 1 is greater than the length 864 of the data to be sent of the function call of this time, writing the data into the sending buffer of socket 1, and marking the copy state of socket 1. Judging that the sending memory residual length 687 of the socket 3 is smaller than the to-be-sent data length 864 of the current sending function call, not operating, and entering the step (a 4);
(a4) and detecting that the connection state of the socket 1 is established, and acquiring that the data sending state is successful. The connection state of socket 3 is detected as establishment, and the data sending state is acquired as success. The traversal of the valid socket connection ends and the step (a5) is entered;
(a5) socket 1 is not sent for the first time, and further detects that the data sending state and the data copying state of socket 1 are respectively 'successful' and 'copied', the socket 1 sending success state is cleared first, and then a control instruction is sent to enable the chip to execute the socket 1 sending operation of the data to be sent. socket 3 is not sent for the first time, and the data sending state and the data copying state of socket 3 are further detected to be respectively 'successful' and 'uncopyed', and no operation is performed. The traversal of the valid socket connection ends and the step (a6) is entered;
(a6) this loop node socket state update is to remove socket 1 that has sent a control instruction from the valid socket sequence, where socket _ ok [8] ═ {3,0,0,0,0,0, 0}. the valid socket number becomes 1. Directly switching to (a7) when the cycle number does not reach 5999;
(a7) and (4) judging that the number of the effective socket is 1, and entering the step (3) if the effective socket sequence is not empty.
And entering the next round of sending processing because the sending threshold is not 6000 times, as follows:
(a1) and judging that the working state of the socket 3 is normal and not operating. The traversal of the valid socket connection ends and the step (a2) is entered;
(a2) the remaining length of the sending memory of socket 3 is 8 kbytes (since all data in the sending memory is sent in the last round of operation, the sending memory is empty, and the remaining length is 8 kbytes), the connection state is determined to be established, and the effective connection sequence is not changed. The traversal of the valid socket connection ends and the step (a3) is entered;
(a3) judging that the remaining length of 8 Kbytes of the memory sent by the socket 3 is larger than 864 bytes of the data to be sent called by the function to be sent, writing the data into a sending buffer of the socket 3, and marking the copy state of the socket 3. Entering step (a 4);
(a4) the connection state of socket 3 is detected as establishment, and the data sending state is acquired as success. The traversal of the valid socket connection ends and the step (a5) is entered;
(a5) socket 3 is not sent for the first time, and further detects that the data sending state and the data copying state of socket 3 are respectively 'successful' and 'copied', the socket 3 sending success state is cleared first, and then a control instruction is sent to enable the chip to execute the socket 3 sending operation of the data to be sent. The traversal of the valid socket connection ends and the step (a6) is entered;
(a6) this loop node socket state update is to remove socket 3 that has sent a control instruction from the valid socket sequence, where socket _ ok [8] ═ {0,0,0,0,0,0,0,0}. the valid socket number becomes 0. Directly switching to (a7) when the cycle number does not reach 5999;
(a7) and judging that the number of the effective socket is 0, and directly quitting the sending function call if the effective socket sequence is empty. The embedded device executes other business working programs.
The step (a1) increases the strategy for processing the application layer network communication abnormity of the user software by the embedded device, and makes up the defect of processing the application layer communication abnormity by most embedded multi-user network communication chips. The steps (a3) and (a5) improve the data transmission strategy of the chip, and set the final threshold of the inquiry and waiting times as 6000 times of limited waiting. And updating the effective socket sequence in time in the steps (a1), (a2), (a4) and (a6), reducing the socket cardinal number of subsequent processing and improving the processing efficiency. And (3) optimizing the processing strategy of multi-user data transmission. When the network chip is in the process of establishing multi-user network connection, namely a plurality of effective socket connections, the sequential execution of multi-user data sending processing is changed into the overall parallel among multiple users, and the processing flow of sequential execution in small functional units is matched.
It can be seen from the above specific examples that the method of the present invention can ensure that 1) when the user software communicating with the W5300 network chip fails or application layer is abnormal, such as debugging, the embedded device only interrupts network communication, and other business operations are not affected; 2) when the user application layer is recovered abnormally, the network communication can be recovered to be normal. 3) When the embedded device is in a multi-user communication state, the network communication of only the user with abnormal application layer can be interrupted, and the network communication of other users is normal.
The above description is only one embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention.
The invention has not been described in detail in part of the common general knowledge of those skilled in the art.

Claims (4)

1. A method for processing abnormal network communication of embedded equipment multi-user is characterized in that: the method comprises the following steps:
(1) traversing the connection states of a plurality of sockets supported by the network communication chip, judging whether effective socket connection is established, if the effective connection is established, entering the step (2), and if not, ending;
(2) comparing the lengths of all data to be sent with the maximum sending data length connected with the effective socket, if the length of the data to be sent is greater than or equal to the maximum sending data length connected with the effective socket, setting the length of the data to be sent as the maximum sending data length connected with the effective socket, and if not, keeping the length of the data to be sent unchanged, and entering the step (3);
(3) the method comprises the following steps of detecting effective socket connection in a normal state and effective socket connection in an abnormal state in the effective socket connection, sending all data to be sent through the effective socket connection in the normal state, carrying out threshold judgment on the effective socket connection in the abnormal state, and removing the effective socket connection in the abnormal state exceeding the threshold judgment times from the effective socket connection, wherein the specific method comprises the following steps: if the duration of the effective socket connection in the abnormal state exceeds a communication interruption threshold, removing the effective socket connection in the abnormal state from the effective socket connection; and sending the data to be sent to the effective socket connection in the abnormal state which does not exceed the threshold judgment times.
2. The embedded device multi-user network communication exception handling method according to claim 1, characterized in that: the implementation method of the step (3) specifically comprises the following steps:
(3.1) judging and processing the working states of the N effective socket connections;
(3.2) judging and processing the connection state of the N effective socket connections;
(3.3) judging whether to write data to be sent in the sending memories connected with the N effective sockets;
(3.4) judging and processing the connection state of the N effective socket connections again;
(3.5) all data to be sent are sent outwards through N effective socket connections;
(3.6) detecting whether the working state of the N effective socket connections is an abnormal working state;
wherein: n is a positive integer and is more than or equal to 1;
the concrete implementation method of the steps is as follows:
(3.1) judging and processing the working state of the connection of the N effective sockets, wherein the specific method for judging and processing the working state of one effective socket is as follows:
judging the working state of the effective socket connection, establishing an abnormal state mark for the effective socket connection in the abnormal working state, inquiring the state of the last data transmission, judging whether the transmission memory of the effective socket connection in the abnormal working state is empty if the state is successful, and canceling the abnormal state mark of the effective socket connection and processing the next effective socket connection if the transmission memory is empty; if the sending memory is not empty, all data in the sending memory are sent outwards, and then the next effective socket connection is processed;
if the state is sending failure, processing the next valid socket connection;
(3.2) judging and processing the connection state of the N effective sockets, wherein the specific method for judging and processing the connection state of one effective socket is as follows:
acquiring the available length of a sending memory of an effective socket connection, judging the connection state of the effective socket connection, if the connection state is not connected, removing the effective socket connection from N effective socket connections, and then processing the next effective socket connection;
if the connection state is connected, processing the next valid socket connection;
(3.3) judging whether to write data to be sent in the sending memories connected with the N effective sockets, wherein a specific method for judging whether to write data to be sent in the sending memory connected with one effective socket is as follows:
judging whether the available length of a sending memory of the effective socket connection is greater than or equal to the length of the current data to be sent, if so, writing the current data to be sent into the memory of the effective socket connection and marking, and then processing the next effective socket connection;
if the length of the data to be sent is smaller than the length of the data to be sent, processing the next effective socket connection;
(3.4) judging and processing the connection state of the N effective sockets again, wherein the specific method for judging and processing the connection state of one effective socket is as follows:
detecting the connection state of the effective socket connection, if the connection state is not connected, removing the effective socket connection from the N effective socket connections, and then processing the next effective socket connection;
if the connection state is connected, further acquiring the sending state of the last sending data of the effective socket connection, and then processing the next effective socket connection;
(3.5) sending all the data to be sent outwards through N effective socket connections, wherein a specific method for sending the data to be sent outwards through one effective socket connection is as follows:
detecting whether the effective socket connection is used for sending data for the first time, if so, directly sending the data to be sent outwards and marking the data, and then processing the next effective socket connection;
if the data is not sent for the first time, detecting a data sending state and a data writing state of the valid socket connection, if the data is sent successfully and the data is written, clearing the last sending success state, sending the current data to be sent and marking, and then processing the next valid socket connection; if the data transmission fails or the data is not written in, processing the next valid socket connection;
(3.6) detecting whether the working state of the N effective socket connections is an abnormal working state, wherein the specific method for detecting whether the working state of one effective socket connection is the abnormal working state is as follows:
judging whether data to be sent of an effective socket connection is sent or not, if so, eliminating the effective socket connection from N effective socket connections, and then processing the next effective socket connection;
if not, judging whether the execution times of the steps (3.1) - (3.6) reach a set threshold, if so, marking the working state of the effective socket connection as an abnormal working state, and processing the next effective socket connection; and if the set threshold is not reached, processing the next valid socket connection.
3. The embedded device multi-user network communication exception handling method according to claim 2, characterized in that: and (3.6) after detecting whether the working state of the N effective socket connections is an abnormal working state, judging whether the N effective socket connections complete data transmission, if so, finishing, and if not, repeating the steps (3.1) - (3.6).
4. The embedded device multi-user network communication exception handling method according to claim 2, characterized in that: the threshold set in step (3.6) is 6000 times 7000.
CN201711125076.7A 2017-11-14 2017-11-14 Multi-user network communication exception handling method for embedded equipment Active CN107682212B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711125076.7A CN107682212B (en) 2017-11-14 2017-11-14 Multi-user network communication exception handling method for embedded equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711125076.7A CN107682212B (en) 2017-11-14 2017-11-14 Multi-user network communication exception handling method for embedded equipment

Publications (2)

Publication Number Publication Date
CN107682212A CN107682212A (en) 2018-02-09
CN107682212B true CN107682212B (en) 2021-04-13

Family

ID=61148988

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711125076.7A Active CN107682212B (en) 2017-11-14 2017-11-14 Multi-user network communication exception handling method for embedded equipment

Country Status (1)

Country Link
CN (1) CN107682212B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108833063B (en) * 2018-08-29 2021-04-27 新华三技术有限公司 Message retransmission method and device
CN109614340A (en) * 2018-12-28 2019-04-12 北京微播视界科技有限公司 Exploitation adjustment method, device, electronic equipment and the storage medium of application program

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242574A (en) * 2007-11-30 2008-08-13 上海展桥信息技术有限公司 GPRS wireless terminal system
CN103067777A (en) * 2012-12-24 2013-04-24 深圳Tcl新技术有限公司 Method and device of prompting of network state

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8946941B2 (en) * 2010-09-14 2015-02-03 Monterey Bay Aquarium Research Institute Wireless power and data transfer device for harsh and extreme environments

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242574A (en) * 2007-11-30 2008-08-13 上海展桥信息技术有限公司 GPRS wireless terminal system
CN103067777A (en) * 2012-12-24 2013-04-24 深圳Tcl新技术有限公司 Method and device of prompting of network state

Also Published As

Publication number Publication date
CN107682212A (en) 2018-02-09

Similar Documents

Publication Publication Date Title
US20030101367A1 (en) Critical adapter local error handling
CN107682212B (en) Multi-user network communication exception handling method for embedded equipment
CN108572847B (en) Method for upgrading single chip microcomputer software version through USB port
JP2017536759A (en) Method and apparatus for self-healing after disconnection of base station
CN109996349B (en) Session recovery method and device
Cisco
Cisco
Cisco
Cisco
Cisco
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages
Cisco System Error Messages

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant