CN112003767A - Method for sending simulation message - Google Patents

Method for sending simulation message Download PDF

Info

Publication number
CN112003767A
CN112003767A CN202010820793.7A CN202010820793A CN112003767A CN 112003767 A CN112003767 A CN 112003767A CN 202010820793 A CN202010820793 A CN 202010820793A CN 112003767 A CN112003767 A CN 112003767A
Authority
CN
China
Prior art keywords
buffer
message
selector
substations
channel
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.)
Pending
Application number
CN202010820793.7A
Other languages
Chinese (zh)
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.)
SHANGHAI XJ ELECTRIC CO Ltd
State Grid Corp of China SGCC
Xuji Group Co Ltd
Original Assignee
SHANGHAI XJ ELECTRIC CO Ltd
State Grid Corp of China SGCC
Xuji Group 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 SHANGHAI XJ ELECTRIC CO Ltd, State Grid Corp of China SGCC, Xuji Group Co Ltd filed Critical SHANGHAI XJ ELECTRIC CO Ltd
Priority to CN202010820793.7A priority Critical patent/CN112003767A/en
Publication of CN112003767A publication Critical patent/CN112003767A/en
Pending legal-status Critical Current

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/50Testing arrangements
    • 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/14Network analysis or design
    • H04L41/145Network analysis or design involving simulating, designing, planning or modelling of a network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention relates to a method for sending an analog message, which comprises the steps of deploying a client at a main station, selecting a plurality of sub-stations, and deploying a plurality of service terminals at each sub-station; all protection devices of all transformer substations corresponding to the master station send messages to the plurality of substations; the server stores the message into a Buffer area (Buffer); the Selector (Selector) scans each Buffer area (Buffer), when a certain Buffer area (Buffer) is full, a corresponding available Channel (Channel) is allocated to send a message, and the client of the master station receives the message. The method for transmitting the simulation message can simplify a complex substation system, and uses a simulation program to replace the substation for message transmission, and because the resource occupation of the simulation program is extremely low, about 10 machines with the simulation program can complete the message volume which can be transmitted by thousands of substations originally. The method can greatly reduce the requirement of communication pressure test on the device and completely restore the field communication environment.

Description

Method for sending simulation message
Technical Field
The invention relates to the technical field of communication, in particular to an analog message sending method.
Background
At present, most of ethernet test devices adopt a blocking IO method facing to a flow, and a server is still connected by using a blocking socket. An accept method is used to create a connection. The accept method is a blocking method, and the accept will block before the next connection comes in. After a socket comes in, Tomcat will take a thread in the thread pool to process the connected socket.
Taking the protection information master station as an example, one protection information master station needs to receive messages uploaded by thousands of sub stations, the messages are various in types and very complex to configure, the thousands of sub stations are obviously impossible to use only for communication test, and generally only 10 devices are accessed for testing, and the testing effect of the testing method is not good due to the lack of samples.
The prior art has the following defects:
1. multiple copies of data
In addition, when the bottom layer calls an I/O system through functions such as write, read and the like, the position of an object in a heap is often moved due to the existence of a JVM GC, and the address parameter of the transferred system function after the movement is not a real buffer address, so that reading and writing errors can be caused.
2. Operational blockage
Operations such as requesting to establish a connection (connect), reading network I/O data (read), sending data (send), etc. are thread blocking. When the request connection is established, the request message is read, the server calls the read method, and if the client data is still in the write or in the transport, the thread needs to wait until the data is ready in the read method block. In order to realize concurrent response of the server, each connection needs to be processed independently by an independent thread, and when the concurrent request amount is large, the overhead of switching the memory and the threads is overlarge in order to maintain the connection.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a method for sending a simulation message, which optimizes the reading and writing process of data and prevents the reading and writing of the data from making mistakes due to the address shift of a buffer area on the one hand; on the other hand, non-blocking IO is adopted, and a single thread is used for managing a plurality of input and output channels.
In order to achieve the above object, the present invention provides an analog packet sending method, including:
deploying a client at a main station, selecting a plurality of substations, and deploying a plurality of service terminals at each substation;
all protection devices of all transformer substations corresponding to the master station send messages to the plurality of substations; the server stores the message into a Buffer area (Buffer);
the Selector (Selector) scans each Buffer area (Buffer), when a certain Buffer area (Buffer) is full, a corresponding available Channel (Channel) is allocated to send a message, and the client of the master station receives the message.
Further, the server side and the protection device have a corresponding relationship, and the server side receives the message sent by the corresponding protection device, stores the message in a Buffer (Buffer) and sends the message.
Further, the Selector (Selector) scans the size of each Buffer (Buffer) written data, and compares the size with the storage space (capacity), if the size is the same, indicating that the Buffer is full.
Further, every time one piece of information is written, the position (position) is added with 1, the last frame is the limit (limit), the storage space (capacity) in the writing mode is equal to the limit frame (limit), and when the position (position) is equal to the limit frame (limit), the writing is full.
Further, a socket (socket) connection responsible for monitoring IP is established at the server;
registering a characteristic point IO event in a main thread;
when any registered event occurs, the server side obtains a corresponding selection key (SelectionKey) from a Selector (Selector), and finds the event which occurs and an optional channel (SelectibleChannel) in which the event occurs from the selection key (SelectionKey) so as to obtain a message sent by the client side;
extracting the message of the server, comparing the message with the sent message to determine whether the structure is the same, and if so, indicating that the message processing capacity of the master station meets the requirement; otherwise, the message processing capability of the master station is not satisfied.
Further, in a read mode, the server reads the message into a Buffer (Buffer) in the NIO from the NIO channel; in the write mode, the message is written into an NIO channel from a Buffer (Buffer) in the NIO; when reading the message, all the data written into the buffer can be read, all the data is read, and the buffer area is emptied.
Further, when reading the message, flushing the buffer includes calling a flush function (clear) to flush the entire buffer or calling a compact function (compact) to flush the message that has been read.
Further, switching between the write mode and the read mode is realized using a jump function (flip).
Further, at least 10 substations are selected, each deploying 100 clients.
The technical scheme of the invention has the following beneficial technical effects:
(1) the method for transmitting the simulation message can simplify a complex substation system, and uses a simulation program to replace the substation for message transmission, and because the resource occupation of the simulation program is extremely low, about 10 machines with the simulation program can complete the message volume which can be transmitted by thousands of substations originally. The method can greatly reduce the requirement of communication pressure test on the device and completely restore the field communication environment.
(2) The invention applies a Selector mechanism to register the address information on a specific Selector object, so that a large number of concurrent network connections can be managed by using the Selector object in a single thread, and system resources are better utilized.
(2) The invention adopts a non-blocking I/O communication mode, and can return without requiring blocking to wait for the completion of I/O operation, thereby reducing the system overhead caused by managing I/O connection and greatly improving the system performance.
(3) Traditional IO data stream processing: one or more bytes are read directly from the data stream and transferred to the channel until all bytes are read, without being buffered anywhere during the transfer. This means that when a thread calls read or write, the thread is blocked until some data is read, or the data is completely written, during which time the thread can no longer handle other events; the present invention uses buffers instead of data stream processing, the non-blocking mode of NIO, which allows a thread to send a request to read data from a channel, but it only gets the data that is currently available, and nothing is fetched if no data is currently available. Rather than keeping the thread blocked all the time, the thread can continue to do something else until the data becomes readable. A thread requesting to write some data to a channel does not need to wait for it to write completely, the thread can do something else at the same time, the thread usually uses the idle time of non-blocking IO for IO operations on other channels, so a single thread can now manage multiple input and output channels (channels).
Drawings
FIG. 1 is a schematic diagram of the Select mechanism;
FIG. 2 is a schematic diagram of a non-blocking mode of the NIO;
FIG. 3 is a schematic diagram of a write mode.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the accompanying drawings in conjunction with the following detailed description. It should be understood that the description is intended to be exemplary only, and is not intended to limit the scope of the present invention. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present invention.
The invention provides a method for sending an analog message, which comprises the following steps:
(1) and a client is deployed at the main station, a plurality of substations are selected, and each substation is deployed with a plurality of servers.
After a socket connection responsible for monitoring IP is established in a server program, characteristic IO events such as arrival of readable data, new sockets and the like are registered in a main thread. When any registered event such as reading or writing occurs, a corresponding selectorkey can be obtained from a Selector, and the event that occurs and the specific selectorchange that occurs in the event can be found from the selectorkey, so as to obtain the data sent by the client.
(2) All protection devices of all transformer substations corresponding to the master station send messages to the plurality of substations; the server stores the message in a Buffer (Buffer).
The server and the protection device have a corresponding relationship, and in one embodiment, a simple tcp connection mode is adopted.
A buffer-oriented approach is used instead of the traditional IO stream-oriented approach. The Buffer in the NIO is used for interacting with the NIO channel, and data is read from the channel into the Buffer or written into the channel from the Buffer. When writing data to the buffer, the buffer records how much data is written. Once data is to be read, the Buffer needs to be switched from write mode to read mode by the flip () method. In the read mode, all data previously written to the buffer can be read. Once all the data has been read, the buffer needs to be emptied so that it can be written again. There are two ways to empty the buffer: call clear () or compact () method. The clear () method will empty the entire buffer. The compact () method will only clear data that has already been read. Any unread data is moved to the beginning of the buffer and the newly written data will be placed behind the unread data in the buffer.
(3) The Selector (Selector) scans each Buffer area (Buffer), when a certain Buffer area (Buffer) is full, a corresponding available Channel (Channel) is allocated to send a message, and the client of the master station receives the message.
And (4) repeatedly executing the step (3) until the master station test is completed.
The server receives the message content and stores the message content into a Buffer area (Buffer), firstly, a memory space (capacity) is allocated to the message in the Buffer area by an allocate method, and the memory space (capacity) with different sizes can be allocated according to different types and lengths of the message.
The Buffer has three attributes: capacity, position and limit, in conjunction with FIG. 3.
When writing, the size of the storage space (capacity) represents the size when using allocate for initialization, represents the capacity of the cache block, and at most, capacity chars, long, int, byte, etc. can only be put into the cache block. When the cache block is full, it needs to be emptied to continue writing data into it.
position: the current position of the pen substitute, the initialization value is 0, when a data is written into the buffer, the position is moved to the next insertable buffer unit, therefore, the maximum value of the position is position-1,
limit: under the write mode, limit indicates how many buffers can be written into the buffer at most, and under the write mode, limit is capacity.
When switching to the read mode, this represents how much data can be read at most. Therefore, when switching to the read mode, limit is set to the position value in the write mode. Therefore you can read all the values written under the write mode.
And then, in the process of forwarding the message, because one selector registers a plurality of channels at the same time, and can scan the messages in a plurality of buffers in the Server. Because the types and lengths of the messages are different, the time for completing the storage is also different. If the traditional blocking IO method is adopted, the selector is not applied, the channel and the buffer are directly connected in a one-to-one mode, and when the message in the buffer is not stored, the channel corresponding to the buffer can only be in standby, so that the waste of resources is caused.
In the non-blocking method, the Selector traverses the corresponding buffers through the selection key, and as long as one of the buffers is ready (the selection key only needs to judge whether the capacity attribute in the Buffer reaches the maximum value, and whether the storage of the message is finished or not can be judged, so that the judgment speed is high), the Selector allocates the message to one available Channel (because the number of the messages in the Buffer is far greater than that of the channels), the message can be almost guaranteed to be written in all the time in the Channel, the Channel can be guaranteed to be maximally utilized, and the waiting time is saved.
Examples
As an actual embodiment of the method of the present invention, a master station actually corresponds to 1000 protection devices, and needs to test the data volume of messages sent by 1000 protection devices, so as to determine whether the messages can be processed normally. The invention arranges a service end program on each of 10 substations, and each service end program is responsible for receiving messages sent by 100 protection devices. Each server program has an appointed IP, 1000 protection devices and respectively sends messages to the appointed IP, and each server program is responsible for receiving the messages sent by the protection devices in the same network segment as the server program and respectively stores the messages in a Buffer area (Buffer). The Selector (Selector) scans each Buffer area (Buffer), when a certain Buffer area (Buffer) is full, a corresponding available Channel (Channel) is allocated to send messages, the client of the main station is responsible for collecting messages sent by the server side in all the substations, the client is logically connected with the real-time library, and information can be read from the client and stored in the real-time library. The master station originally has the capability of reading the protection information into the database, and the client is developed by relying on the real-time library and only needs to establish the connection between the real-time library and the server.
The method for sending the simulation message is mainly applied to the Ethernet communication test, and solves the problem that the communication pressure test has high requirements on the number and the performance of the equipment. The complicated substation system can be simplified, a simulation program replaces the substation to carry out message sending work, and due to the fact that resource occupation of the simulation program is extremely low, about 10 machines with the simulation program deployed can complete message volume which can be sent by thousands of substations originally. The method can greatly reduce the requirement of communication pressure test on the device and completely restore the field communication environment.
In summary, the present invention relates to an analog packet transmission method, where a client is deployed at a master station, a plurality of substations are selected, and each substation deploys a plurality of servers; all protection devices of all transformer substations corresponding to the master station send messages to the plurality of substations; the server stores the message into a Buffer area (Buffer); the Selector (Selector) scans each Buffer area (Buffer), when a certain Buffer area (Buffer) is full, a corresponding available Channel (Channel) is allocated to send a message, and the client of the master station receives the message. The method for transmitting the simulation message can simplify a complex substation system, and uses a simulation program to replace the substation for message transmission, and because the resource occupation of the simulation program is extremely low, about 10 machines with the simulation program can complete the message volume which can be transmitted by thousands of substations originally. The method can greatly reduce the requirement of communication pressure test on the device and completely restore the field communication environment.
It is to be understood that the above-described embodiments of the present invention are merely illustrative of or explaining the principles of the invention and are not to be construed as limiting the invention. Therefore, any modification, equivalent replacement, improvement and the like made without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention. Further, it is intended that the appended claims cover all such variations and modifications as fall within the scope and boundaries of the appended claims or the equivalents of such scope and boundaries.

Claims (9)

1. An analog message sending method, comprising:
deploying a client at a main station, selecting a plurality of substations, and deploying a plurality of service terminals at each substation;
all protection devices of all transformer substations corresponding to the master station send messages to the plurality of substations; the server stores the message into a Buffer area (Buffer);
the Selector (Selector) scans each Buffer area (Buffer), when a certain Buffer area (Buffer) is full, a corresponding available Channel (Channel) is allocated to send a message, and the client of the master station receives the message.
2. The method according to claim 1, wherein the server side corresponds to the protection device, and the server side receives the packet sent by the corresponding protection device, stores the packet in a Buffer (Buffer), and sends the packet.
3. The analog messaging method according to claim 1 or 2, wherein the Selector (Selector) scans the size of the written data in each Buffer (Buffer) and compares the size with the storage space (capacity), and if the size is the same, the Selector indicates that the Buffer is full.
4. The analog message transmission method according to claim 3, wherein, when writing a piece of information, the position (position) is added with 1, the last frame is the limit (limit), the storage space (capacity) in the write mode is equal to the limit frame (limit), and when the position (position) is equal to the limit frame (limit), it indicates that the writing is full.
5. The analog messaging method of claim 1 or 2,
creating a socket connection responsible for monitoring IP at a server;
registering a characteristic point IO event in a main thread;
when any registered event occurs, the server side obtains a corresponding selection key (SelectionKey) from a Selector (Selector), and finds the event which occurs and an optional channel (SelectibleChannel) in which the event occurs from the selection key (SelectionKey) so as to obtain a message sent by the client side;
extracting the message of the server, comparing the message with the sent message to determine whether the structure is the same, and if so, indicating that the message processing capacity of the master station meets the requirement; otherwise, the message processing capability of the master station is not satisfied.
6. The analog packet transmission method according to claim 1, wherein in the read mode, the server reads the packet from the NIO channel into a Buffer (Buffer) in the NIO; in the write mode, the message is written into an NIO channel from a Buffer (Buffer) in the NIO; when reading the message, all the data written into the buffer can be read, all the data is read, and the buffer area is emptied.
7. The analog messaging method of claim 6, wherein when reading a message, flushing the buffer comprises calling a flush function (clear) to flush the entire buffer or calling a compact function (compact) to flush a message that has been read.
8. The analog message transmission method according to claim 6, characterized in that the switching between the write mode and the read mode is implemented using a skip function (flip).
9. The method according to claim 1 or 2, wherein at least 10 substations are selected, and each substation deploys 100 clients.
CN202010820793.7A 2020-08-14 2020-08-14 Method for sending simulation message Pending CN112003767A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010820793.7A CN112003767A (en) 2020-08-14 2020-08-14 Method for sending simulation message

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010820793.7A CN112003767A (en) 2020-08-14 2020-08-14 Method for sending simulation message

Publications (1)

Publication Number Publication Date
CN112003767A true CN112003767A (en) 2020-11-27

Family

ID=73473213

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010820793.7A Pending CN112003767A (en) 2020-08-14 2020-08-14 Method for sending simulation message

Country Status (1)

Country Link
CN (1) CN112003767A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116962512A (en) * 2023-09-20 2023-10-27 北京信安世纪科技股份有限公司 Message processing method, device, storage medium and apparatus

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101282300A (en) * 2008-03-03 2008-10-08 北京航空航天大学 Method for processing HTTP packet based on non-blockage mechanism
US20100276658A1 (en) * 2007-07-20 2010-11-04 Macronix International Co., Ltd. Resistive Memory Structure with Buffer Layer
CN102811201A (en) * 2011-05-31 2012-12-05 阿里巴巴集团控股有限公司 SSL (Secure Sockets Layer) nonblocking communication method and server therefor
CN104217127A (en) * 2014-09-18 2014-12-17 北京四方继保自动化股份有限公司 PMU (Power Management Unit) dynamic data simulation generating method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100276658A1 (en) * 2007-07-20 2010-11-04 Macronix International Co., Ltd. Resistive Memory Structure with Buffer Layer
CN101282300A (en) * 2008-03-03 2008-10-08 北京航空航天大学 Method for processing HTTP packet based on non-blockage mechanism
CN102811201A (en) * 2011-05-31 2012-12-05 阿里巴巴集团控股有限公司 SSL (Secure Sockets Layer) nonblocking communication method and server therefor
CN104217127A (en) * 2014-09-18 2014-12-17 北京四方继保自动化股份有限公司 PMU (Power Management Unit) dynamic data simulation generating method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116962512A (en) * 2023-09-20 2023-10-27 北京信安世纪科技股份有限公司 Message processing method, device, storage medium and apparatus
CN116962512B (en) * 2023-09-20 2024-01-05 北京信安世纪科技股份有限公司 Message processing method, device, storage medium and apparatus

Similar Documents

Publication Publication Date Title
CN110365644B (en) Method for constructing high-performance monitoring platform of networking equipment
US7899878B2 (en) Recording trace messages of processes of a network component
CN110134534B (en) System and method for optimizing message processing for big data distributed system based on NIO
CN110737536B (en) Message storage method and message reading method based on shared memory
JP2006510996A (en) Usage of direct memory access to perform database operations between two or more machines
US20150304124A1 (en) Message Processing Method and Device
CN105183299A (en) Human-computer interface service processing system and method
CN108829713A (en) Distributed cache system, cache synchronization method and device
US20030056073A1 (en) Queue management method and system for a shared memory switch
CN111177254B (en) Method and device for data synchronization between heterogeneous relational databases
CN108415962A (en) A kind of cloud storage system
CN112003767A (en) Method for sending simulation message
CN104199729B (en) A kind of method for managing resource and system
CN107911317B (en) Message scheduling method and device
CN109274774A (en) A kind of date storage method, device and computer readable storage medium
CN101155370A (en) Business serial processing method and system in multi-stream application of mobile communication system
CN114401072B (en) Dynamic buffer control method and system for frame disassembly reordering queue based on HINOC protocol
CN113179228B (en) Method, device, equipment and medium for improving switch stacking reliability
CN114186163A (en) Application layer network data caching method
CN113157611B (en) Data transmission control method, device, equipment and readable storage medium
CN111813519A (en) IEC 61850 multi-client-oriented multi-task concurrent testing method and system
CN105446651B (en) Memory mirror method and system and data sending device and data sink
WO1994015438A1 (en) Device for the conversion of data blocks, frame structured, into atm cells and vice versa
Geng et al. Research on high speed data distribution technology based on kernel state of domestic operating system
CN101453386A (en) Network package extracting method

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20201127

RJ01 Rejection of invention patent application after publication