Method and device for obtaining simulation status information based on WebSocket
By adopting WebSocket technology and TCP protocol in large distributed simulation systems, the communication protocol is built and the real-time push of state data is solved, and the problem of large bandwidth occupancy and data transmission is not real-time and accurate in the existing technology is solved, and the real-time response of the simulation system is improved Capability and data accuracy.
Patent Information
- Application Number
- CN202411531705.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-10-30
AI Technical Summary
When existing large distributed simulation systems monitor operating status information, node interconnection information and network resource status information in real time, there are problems such as large bandwidth resource utilization and insufficient real-time and accurate data transmission.
The communication protocol of a distributed simulation system is constructed using WebSocket technology. The simulation unit sends status data to the simulation server through the TCP protocol. The server stores and actively pushes status data to the browser through the WebSocket connection.
It improves the real-time response ability of the simulation system to state changes, reduces bandwidth resource consumption, ensures data accuracy and reliability, and realizes real-time monitoring of the simulation business status.
Smart Images

Figure CN119052220B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of joint simulation, and in particular to a method and device for acquiring simulation status information based on WebSocket. Background Art
[0002] The current large-scale distributed simulation systems have large node scales, large amounts of transmitted data, and diverse types of transmitted data. In order to be able to monitor the operating status information, node interconnection information, and network resource status information of the entire simulation system in real time, a status control tool and control method that can make the underlying operating platform transparent is needed.
[0003] Existing methods can be roughly divided into two categories. One is to design a simulation control node at the simulation application layer, subscribe to the status data information of other nodes in real time, and present it in real time; the other is to customize the operation and maintenance management system directly on the underlying operating system and hardware environment, which can provide real-time operation status information of the underlying software and hardware environment. The former has the problem of occupying the bandwidth resources of the simulation node and the information collected is not timely and accurate enough. The latter has the problem of only being able to see the infrastructure information and unable to present the simulation business status information. Summary of the invention
[0004] Based on this, it is necessary to provide a method and device for obtaining simulation status information based on WebSocket, which can improve the operating efficiency of the simulation system, in response to the above technical problems.
[0005] A method for acquiring simulation status information based on WebSocket, the method comprising:
[0006] The communication protocol of the distributed simulation system is constructed by using WebSocket technology; the distributed simulation system includes: a browser, a simulation server and several simulation units;
[0007] The simulation unit adds its own reporting task to the timing task of the time wheel, and sends its own status data to the simulation server via the TCP protocol;
[0008] After receiving the status data reported by multiple simulation units, the simulation server stores the status data of each simulation unit, so that when the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the corresponding status data of the simulation unit according to the data type request message and actively feeds it to the browser through the WebSocket connection.
[0009] A device for acquiring simulation status information based on WebSocket, the device comprising:
[0010] A communication protocol construction module is used to construct a communication protocol of a distributed simulation system using WebSocket technology; the distributed simulation system includes: a browser, a simulation server and several simulation units;
[0011] A distributed communication module is used for the simulation unit to add its own reporting task to the timing task of the time wheel, and send its own status data to the simulation server through the TCP protocol;
[0012] The joint simulation status information acquisition module is used for the simulation server to store the status data of each simulation unit after receiving the status data reported by multiple simulation units, so that after the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the corresponding status data of the simulation unit according to the data type request message and actively feeds it to the browser through the WebSocket connection.
[0013] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0014] The communication protocol of the distributed simulation system is constructed by using WebSocket technology; the distributed simulation system includes: a browser, a simulation server and several simulation units;
[0015] The simulation unit adds its own reporting task to the timing task of the time wheel, and sends its own status data to the simulation server via the TCP protocol;
[0016] After receiving the status data reported by multiple simulation units, the simulation server stores the status data of each simulation unit, so that when the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the corresponding status data of the simulation unit according to the data type request message and actively feeds it to the browser through the WebSocket connection.
[0017] The above-mentioned WebSocket-based simulation status information acquisition method and device, the traditional HTTP protocol is based on the request-response mode, and the browser needs to continuously poll the server to obtain updated data, which not only occupies a large amount of bandwidth resources, but also leads to low timeliness of data transmission. In contrast, WebSocket is a full-duplex communication protocol. Once the connection is established, the server can actively push data to the browser without waiting for the browser's request. This communication method greatly reduces communication delays and reduces the consumption of bandwidth resources, thereby improving the real-time response capability of the simulation system to state changes. During the simulation process, browser users can obtain the latest simulation business status information at any time, allowing users to discover potential problems in the first place. Secondly, the status data reporting method of the simulation unit is optimized through the time wheel mechanism. The time wheel is an efficient timed task scheduling algorithm. It divides the reporting tasks of the simulation unit into time segments, effectively avoiding the network congestion problem caused by the simultaneous reporting of each simulation unit. The simulation unit reports its own status to the simulation server through the TCP protocol, ensuring the accuracy and reliability of the data. The reliable transmission characteristics of the TCP protocol ensure the integrity of data during transmission, while the scheduling strategy of the time wheel further reduces the generation of invalid data, so that each state data received by the simulation server can timely and accurately reflect the current simulation business status. In addition, after receiving the data reported by multiple simulation units, the simulation server stores and manages them uniformly. When the browser user sends a data request through the WebSocket connection, the server will search for the corresponding simulation unit status data in the memory according to the request type and actively push it to the browser. This design not only improves the efficiency of data acquisition, but also ensures the accuracy of data display. Users can not only view the operating status of the infrastructure, but also monitor the simulation business status information in real time, so as to fully understand the operation of the simulation system. In summary, through the reasonable design of the communication protocol, the real-time monitoring of the simulation business status is realized, which greatly improves the security of the simulation system operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flowchart of a method for obtaining simulation status information based on WebSocket in one embodiment;
[0019] Figure 2 A schematic diagram of a simulation operation status information acquisition process in an embodiment;
[0020] Figure 3 It is a structural block diagram of a simulation state information acquisition device based on WebSocket in one embodiment;
[0021] Figure 4 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0023] In one embodiment, Figure 1 As shown, a method for obtaining simulation status information based on WebSocket is provided, and the method is applied to a B / S communication architecture as an example for explanation, including the following steps:
[0024] Step 102, using WebSocket technology to build a communication protocol for the distributed simulation system.
[0025] WebSocket is a new protocol under HTML5. This technology can realize full-duplex communication between browser and server. WebSocket is also a long connection. After the connection is established, messages can be sent through this connection, which can better save server resources and bandwidth. The backend is implemented based on the mongoose network library. Mongoose is a very lightweight Web server library that can be easily integrated into C++ projects. Mongoose supports the WebSocket real-time communication protocol and can run on multiple operating systems, including Linux and Windows.
[0026] Specifically, the WebSocket technology is used to construct a communication protocol for a full-duplex link between a browser and a simulation server, and between a simulation server and a plurality of distributed simulation units.
[0027] Step 104: The simulation unit adds its own reporting task to the scheduled tasks of the time wheel, and sends its own status data to the simulation server via the TCP protocol.
[0028] Specifically, based on the message pull mode, the simulation unit sends the status data of the simulation unit itself to the simulation server through a request, including the delay status data and network transmission rate data of the simulation unit, adds the reporting task to the scheduled task of the time wheel according to a certain frequency, and sends its own status data to the simulation server through the TCP protocol.
[0029] Step 106, after receiving the status data reported by multiple simulation units, the simulation server stores the status data of each simulation unit, so that when the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the status data of the corresponding simulation unit according to the data type request message and actively feeds it to the browser through the WebSocket connection.
[0030] Specifically, the simulation server parses the data sent, and the data content includes the simulation unit handle, simulation unit name, simulation unit delay status and simulation unit transmission rate. According to the simulation unit handle in the content, the status data of each simulation unit is stored in the memory queue respectively. The memory queue adopts a single producer and multiple consumers mode, and the browser consumes the simulation operation status data as a consumer.
[0031] Furthermore, after the browser establishes a WebSocket connection with the simulation server, the simulation server actively pushes the simulation running status data to the browser. The data protocol uses the Json format. The simulation server encodes the simulation running status data into the Json format and then sends it through the WebSocket connection. The browser parses the received message according to the Json format, obtains the simulation running status data, and then displays it on the interface.
[0032] In the above-mentioned WebSocket-based simulation status information acquisition method, the traditional HTTP protocol is based on the request-response mode, and the browser needs to continuously poll the server to obtain updated data, which not only occupies a large amount of bandwidth resources, but also leads to low timeliness of data transmission. In contrast, WebSocket is a full-duplex communication protocol. Once the connection is established, the server can actively push data to the browser without waiting for the browser's request. This communication method greatly reduces communication delays and reduces the consumption of bandwidth resources, thereby improving the real-time response capability of the simulation system to state changes. During the simulation process, browser users can obtain the latest simulation business status information at any time, allowing users to discover potential problems in the first place. Secondly, the status data reporting method of the simulation unit is optimized through the time wheel mechanism. The time wheel is an efficient timed task scheduling algorithm that divides the reporting tasks of the simulation unit into time segments, effectively avoiding the network congestion problem caused by the simultaneous reporting of each simulation unit. The simulation unit reports its own status to the simulation server through the TCP protocol, ensuring the accuracy and reliability of the data. The reliable transmission characteristics of the TCP protocol ensure the integrity of data during transmission, while the scheduling strategy of the time wheel further reduces the generation of invalid data, so that each state data received by the simulation server can timely and accurately reflect the current simulation business status. In addition, after receiving the data reported by multiple simulation units, the simulation server stores and manages them uniformly. When the browser user sends a data request through the WebSocket connection, the server will search for the corresponding simulation unit status data in the memory according to the request type and actively push it to the browser. This design not only improves the efficiency of data acquisition, but also ensures the accuracy of data display. Users can not only view the operating status of the infrastructure, but also monitor the simulation business status information in real time, so as to fully understand the operation of the simulation system. In summary, through the reasonable design of the communication protocol, the real-time monitoring of the simulation business status is realized, which greatly improves the security of the simulation system operation.
[0033] In one embodiment, WebSocket technology is used to construct a communication protocol for a full-duplex link between a browser and a simulation server, and between a simulation server and a plurality of distributed simulation units.
[0034] In one embodiment, the simulation unit adds its own simulation business data as a reporting task to the timing task of the time wheel, and sends the status data in its own reporting task during the joint simulation runtime to the simulation server in batches in chronological order through the TCP protocol.
[0035] In one of the embodiments, the browser uses a message pull method to pull messages from the simulation server for data transmission. The simulation server uses a message active push method to regularly actively push data to the browser for data transmission. According to the load of the simulation server, the message data of the corresponding load level is actively pushed. When it is detected that the load of the simulation server exceeds the threshold, only the page data that needs to be displayed on the browser page is pushed, and other message data that does not need to be displayed on the current browser page is filtered out. When it is detected that the load of the simulation server is not greater than the threshold, the frequency of pushing message data is increased, and the message data of the content displayed on the current browser page is pushed is increased.
[0036] It is worth mentioning that the message push technology based on WebSocket technology is used between the browser and the simulation server to actively push the simulation operation status data. The data push is targeted and can increase or decrease the amount of data sent and the sending frequency according to the real-time load of the current simulation server to ensure the normal load of the server. By configuring the weight ratio of each server in the simulation server cluster on the load balancing server, more requests are distributed to the simulation servers with superior performance, and fewer requests are processed for the ones with poor performance.
[0037] In one of the embodiments, when the simulation server receives the simulation running status data reported by the simulation unit, it stores the simulation running status data of each simulation unit in the same memory queue through logical isolation, so that each browser can retrieve the required data from the memory queue.
[0038] It is worth mentioning that after receiving the status data reported by the simulation unit, the simulation server parses the reported data content, which includes the simulation unit handle, simulation unit name, simulation unit delay status and simulation unit transmission rate. According to the simulation unit handle in the content, the status data of each simulation unit is stored in the memory queue respectively, and logical isolation is used to prevent other modules from easily operating the data in the memory queue. Only the module that pushes data to the browser can access the data by accessing the API provided by the memory queue. This data storage method effectively improves resource utilization and enhances data security.
[0039] In one of the embodiments, after the user opens the browser and establishes a WebSocket connection with the simulation server, the browser accesses the simulation server, and the browser sends a data type request message to the simulation server. When the number of browsers increases, the nginx server, as a load balancing server, configures the cluster address of the current simulation server in a service clustering manner, and distributes the access request entered by the user to the corresponding simulation server in the cluster of the simulation server according to the configured cluster address and the preset load balancing strategy. The simulation server searches for the state data of the corresponding simulation unit in the memory according to the data type request message and actively feeds it to the browser through the WebSocket connection. The load balancing strategy is a weight ratio distribution strategy, and the specific steps are: configure the weight ratio of each simulation server in the cluster of the simulation server on the load balancing server, and according to the performance analysis result of the simulation server, if the performance analysis result is excellent, configure a high proportion weight, and the load balancing server distributes the request to the corresponding server according to the high proportion weight. If the performance analysis result is poor, configure a low proportion weight, and the load balancing server distributes the request to the corresponding server according to the low proportion weight.
[0040] It is worth mentioning that the load balancing server distributes the requests to the corresponding servers according to the weight ratio, ensuring full utilization of resources.
[0041] In one embodiment, if Figure 2 As shown, a method for obtaining simulation running status based on WebSocket is provided, and the simulation running status data includes simulation unit data and simulation server data. First, the simulation unit adds its own reporting task to the scheduled task of the time wheel, and sends its own status data to the simulation server through the TCP protocol, including the QoS status data of the simulation unit and the network transmission rate of the simulation unit. After receiving the simulation business data reported by the simulation unit, the simulation server stores the data of each simulation unit. When the user opens the browser, a WebSocket connection is directly established with the simulation server. At this time, the browser can send a data type request message to the simulation server. The simulation server actively sends the relevant simulation status data to the browser through the WebSocket connection according to the received browser request.
[0042] It is worth mentioning that the interface display includes the performance data of the simulation server, the number of joint simulations and simulation units currently existing in the simulation server, and the detailed data of each simulation unit. After the browser establishes a WebSocket connection with the simulation server, the browser can request the simulation server for the data type it needs to obtain. When requesting to obtain the joint simulation and simulation unit data on the control interface, the simulation server will actively send the corresponding joint simulation and simulation unit data at a certain frequency after receiving the request. After receiving the data content, the browser will parse the content and then display it on the interface. If it is the requested service performance indicator data, the simulation server will send the performance of the machine where the simulation server is located at a certain frequency. If it is the requested simulation unit detailed data, the requested simulation unit data details will be sent. In the case of complex simulation business, this method can support the sending of large batches of data, greatly improving the efficiency of simulation operation.
[0043] It should be understood that although Figure 1-Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-Figure 2 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0044] In one embodiment, Figure 3 As shown, a simulation status information acquisition device based on WebSocket is provided, comprising: a communication protocol construction module 302, a distributed communication module 304 and a joint simulation status information acquisition module 306, wherein:
[0045] The communication protocol construction module 302 is used to construct the communication protocol of the distributed simulation system using the WebSocket technology. The distributed simulation system includes: a browser, a simulation server and several simulation units.
[0046] The distributed communication module 304 is used for the simulation unit to add its own reporting task to the timing task of the time wheel, and send its own status data to the simulation server through the TCP protocol.
[0047] The joint simulation status information acquisition module 306 is used for the simulation server to store the status data of each simulation unit after receiving the status data reported by multiple simulation units, so that when the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the status data of the corresponding simulation unit according to the data type request message and actively feeds it to the browser through the WebSocket connection.
[0048] In one embodiment, the joint simulation state information acquisition module 306 is also used for the browser to access the simulation server after the user opens the browser and establishes a WebSocket connection with the simulation server. The browser sends a data type request message to the simulation server. When the number of browsers increases, the nginx server, as a load balancing server, configures the cluster address of the current simulation server in a service clustering manner, and distributes the access request entered by the user to the corresponding simulation server in the cluster of the simulation server according to the configured cluster address and the preset load balancing strategy. The simulation server searches for the state data of the corresponding simulation unit in the memory according to the data type request message and actively feeds it to the browser through the WebSocket connection. The load balancing strategy is a weight ratio distribution strategy, and the specific steps are: on the load balancing server, a weight ratio is configured for each simulation server in the cluster of the simulation server. According to the performance analysis result of the simulation server, if the performance analysis result is excellent, a high proportion weight is configured, and the load balancing server distributes the request to the corresponding server according to the high proportion weight. If the performance analysis result is poor, a low proportion weight is configured, and the load balancing server distributes the request to the corresponding server according to the low proportion weight.
[0049] For the specific definition of the WebSocket-based simulation state information acquisition device, please refer to the definition of the WebSocket-based simulation state information acquisition method above, which will not be repeated here. Each module in the above-mentioned WebSocket-based simulation state information acquisition device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0050] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a simulation status information acquisition method based on WebSocket is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0051] Those skilled in the art will understand that Figure 3-Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0052] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0053] The WebSocket technology is used to construct the communication protocol of the distributed simulation system. The distributed simulation system includes: browser, simulation server and several simulation units.
[0054] The simulation unit adds its own reporting task to the scheduled task of the time wheel and sends its own status data to the simulation server through the TCP protocol.
[0055] After receiving status data reported by multiple simulation units, the simulation server stores the status data of each simulation unit so that when the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the status data of the corresponding simulation unit based on the data type request message and actively feeds it to the browser through the WebSocket connection.
[0056] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided by the present invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0057] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0058] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for obtaining simulation status information based on WebSocket, characterized in that: The method comprises: The WebSocket technology is used to construct the communication protocol of the distributed simulation system; the distributed simulation system includes: a browser, a simulation server and a plurality of simulation units; the WebSocket technology is used to construct the communication protocol of the full-duplex link between the browser and the simulation server, and between the simulation server and a plurality of distributed simulation units; The simulation unit adds its own reporting task to the timing task of the time wheel, and sends its own status data to the simulation server through the TCP protocol; the simulation unit adds its own simulation business data as a reporting task to the timing task of the time wheel, and sends the status data in its own reporting task during the joint simulation runtime to the simulation server in batches in chronological order through the TCP protocol; After receiving the status data reported by the multiple simulation units, the simulation server stores the status data of each simulation unit, so that after the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the corresponding status data of the simulation unit according to the data type request message and actively feeds the data to the browser through the WebSocket connection; When receiving the simulation running status data reported by the simulation unit, the simulation server stores the simulation running status data of each simulation unit in the same memory queue by means of logical isolation, so that each browser retrieves the required data from the memory queue; After the user opens the browser and establishes a WebSocket connection with the simulation server, the browser accesses the simulation server and sends a data type request message to the simulation server. When the number of browsers increases, the nginx server, as a load balancing server, configures the cluster address of the current simulation server in a service clustering manner, and distributes the access request entered by the user to the corresponding simulation server in the simulation server cluster according to the configured cluster address and the preset load balancing strategy; the simulation server searches for the status data of the corresponding simulation unit in the memory according to the data type request message and actively feeds it to the browser through the WebSocket connection; The load balancing strategy is a weighted proportion distribution strategy, and the specific steps are: on the load balancing server, a weighted proportion is configured for each server in the simulation server cluster, and according to the performance analysis result of the server, if the performance analysis result is excellent, a high proportion weight is configured, and the load balancing server distributes the request to the corresponding server according to the high proportion weight; if the performance analysis result is poor, a low proportion weight is configured, and the load balancing server distributes the request to the corresponding server according to the low proportion weight.
2. The method according to claim 1, characterized in that The browser uses a message pull method to pull messages from the simulation server for data transmission; The simulation server uses the method of actively pushing messages to actively push data to the browser for data transmission on a regular basis. According to the load condition of the simulation server, the message data of the corresponding load level is actively pushed. When it is detected that the load of the simulation server exceeds a threshold, only the page data currently required to be displayed on the browser page is pushed, and other message data that do not need to be displayed on the current browser page are filtered out; when it is detected that the load of the simulation server is not greater than the threshold, the frequency of pushing message data is increased, and the message data of the content displayed on the current browser page is increased.
3. A simulation status information acquisition device based on WebSocket, characterized in that: The device comprises: A communication protocol construction module is used to construct a communication protocol of a distributed simulation system using WebSocket technology; the distributed simulation system includes: a browser, a simulation server and a plurality of simulation units; the communication protocol of a full-duplex link between the browser and the simulation server, and between the simulation server and a plurality of distributed simulation units is constructed using WebSocket technology; A distributed communication module is used for the simulation unit to add its own reporting task to the timing task of the time wheel, and send its own status data to the simulation server through the TCP protocol; the simulation unit adds its own simulation business data as a reporting task to the timing task of the time wheel, and sends the status data in its own reporting task during the joint simulation runtime to the simulation server in batches in chronological order through the TCP protocol; A joint simulation status information acquisition module is used for the simulation server to store the status data of each simulation unit after receiving the status data reported by multiple simulation units, so that after the user opens the browser to establish a WebSocket connection with the simulation server, when the browser sends a data type request message to the simulation server, the simulation server searches the memory for the corresponding status data of the simulation unit according to the data type request message and actively feeds it to the browser through the WebSocket connection; when the simulation server receives the simulation running status data reported by the simulation unit, the simulation server stores the simulation running status data of each simulation unit in the same memory queue by means of logical isolation, so that each browser can retrieve the required data from the memory queue; after the user opens the browser to establish a WebSocket connection with the simulation server, the browser accesses the simulation server, and the browser sends a data type request to the simulation server message, when the number of the browsers increases, the nginx server, as a load balancing server, configures the cluster address of the current simulation server in a service clustering manner, and distributes the access request entered by the user to the corresponding simulation server in the simulation server cluster according to the configured cluster address and the preset load balancing strategy; the simulation server searches the memory for the status data of the corresponding simulation unit according to the data type request message and actively feeds it to the browser through the WebSocket connection; the load balancing strategy is a weight proportion distribution strategy, and the specific steps are: configure the weight proportion of each server in the simulation server cluster on the load balancing server, and according to the performance analysis result of the server, if the performance analysis result is excellent, configure a high proportion weight, and the load balancing server distributes the request to the corresponding server according to the high proportion weight; if the performance analysis result is poor, configure a low proportion weight, and the load balancing server distributes the request to the corresponding server according to the low proportion weight.
Citation Information
Patent Citations
Method and device for circularly pushing reminding message
CN111917687A
Service message pushing method and device
CN115190091A
Task scheduling method, device and system and electronic equipment
CN115951983A