A kind of the naked of intelligent substation network message takes inventory method for storing
Technical field
The invention belongs to technical field of data storage, specifically, are related to a kind of naked disk of intelligent substation network message
Storage method.
Background technology
The network message of intelligent substation generates when being 7 × 24 small, therefore corresponding analysis processing device must in substation
The pattern of uninterrupted operation must be in.In addition, the on-line storage flow of network message is very big, and store function requirement is relatively simple
It is single.Under the conditions of current technology, the storage medium of this mass data is necessarily dependent upon hard disk.In intelligent substation, because
Using networking and total digitalization, electrical equipment is connected with network, and the interaction of electrical equipment is transferred using network message, and most often
There are five the network message types seen:
1) SV network messages, high-frequency uninterruptedly generate, more than account for overall network message 95%;
2) GOOSE network message, low frequency is intermittent to be generated, and network message amount interior running environment of being stood is affected, about
Account for about the 2% of overall network message;
3) MMS network messages, low frequency is intermittent to be generated, network message amount by interior automatic operating environment of standing influenced compared with
Greatly, by accounting for the 2% of overall network message;
4) PTP network messages, low frequency is intermittent to be generated, for pair when, account for the 0.1% of overall network message;
5) other network messages, shake hands between network network message, random network message etc., network message amount are stood interior network
Environment is affected, and accounts for the 0.5% of overall network message.
At present, the various monitoring devices in intelligent substation have following several features when handling network message storage:Mirror
In the magnanimity of network message, inevitably using hard disk as storage medium, and using operating system acquiescence control hard disk
Mode, storage strategy be according to network message reach time, carry out sequential storage;There are two types of storage modes, and one kind is solid
It fixes time.Such as 10 minutes, memory buffer continuously filled 10 minutes network message data, and carried out within every 10 minutes a hard disk and write
Enter operation, while empty memory buffer;Another is fixed size.Such as 10 Mbytes, memory buffer continuously fills 10
Mbytes network message data, and every 10 minutes carry out a hard disk write operation, while empty memory buffer.
The drawbacks of aforesaid way, has:
1st, because depending on the file system of operating system and hard disk used so that network message is actually written into opportunity
It is uncertain, it can not directly judge whether this network message write operation succeeds;Also can once be read by the way that data will be write
Go out verification, but the cost so done is very big;Consequence caused by write-in opportunity does not know is, once system power failure, can not provide true
The data of hard disk are written in fact, and subsequent processing can not carry out;
2nd, the position of write-in can not determine, easily some magnetic tracks of generation hard disk and sector are erasable by high intensity, and remaining
Magnetic track and sector are left unused for a long time, are not only caused the utilization of resources uneven, are also easy to cause hard disk corruptions unavailable, and then are influenced entire
The safety and stabilization of hard-disk system;
3rd, the sequential storage mode that network message uses, network message type hybrid are not distinguished, cause to retrieve together
For PPT when the rare network message of types, cost is the same with the mass network message of retrieval SV types, the big drop of efficiency;
4th, set time formula writes hard disk method and does not account for changes in flow rate, when interior power failure of such as standing is with overhaul of the equipments, may not have
There is any network message to generate, will at this time generate a series of fragment file that length are 0;
5th, fixed size formula writes hard disk method and does not also account for changes in flow rate, will once network message flow is very low in station
Cause even a couple of days a few hours that can not all generate the data of size needed for buffer, at this time in the event of power outage, then
Buffer data are all lost immediately, and security and real-time can not be protected;
6th, using file as basic unit of storage, every time retrieve special time period, particular type of network message when, be required for by
One opens a series of corresponding documents, reads file content to ordered retrieval, cost time are longer again after memory buffer.
The content of the invention
Writing position can not determine that network message is pressed during the present invention to be solved existing substation network packet storage
The sequencing of arrival carries out random storage, it has not been convenient to later retrieval and the wasting skill of irrational utilization memory space
Art problem, it is proposed that a kind of the naked of intelligent substation network message takes inventory method for storing, can solve the above problems.
A kind of the naked of intelligent substation network message takes inventory method for storing, comprises the following steps:
Hard disk partition step, is several data blocks by hard disk partition, and sequence number is numbered with for each data block order;
Data block function partiting step, it is meta data block to select one of data block, for first number of storage file block
According to other data blocks are message data block, for the network message data of storage file block;
It is empty according to shared by volume forecasting different type network message by network message using its own type as partitioning standards
Between size, be respectively the message data block that all types of network messages distribution match with its occupied space;
Memory Allocation step is that the network message of each type distributes a memory;
Network message storing step, comprises the following steps:
(1), network message is written into first to be write into the memory corresponding to its type according to its type, is described
Network message to be written distributes a blocks of files sequence number, and the parameter information of blocks of files corresponding to the blocks of files sequence number is extracted,
Form the metadata of this document block;
(2), the message data block of the type distribution for the network message to be written is found, by first number of the blocks of files
According to write-in into meta data block, the blocks of files is write sequentially in time into the message data block distributed.
Further, in (1), network message is written into first according to it the network message storing step the step of
Type write to in the memory corresponding to its type, which enters after memory is accumulated with pcap forms, memory fills out
Man Hou, first carries out the compression of a gzip form, and adds gzip and cyclic redundancy check, constitutes the gzip_ of gzip forms
buffer。
Further, the network message storing step the step of in (1), blocks of files corresponding to the blocks of files sequence number
Parameter information include at least offset of the blocks of files corresponding to this document block sequence number in entire hard disk, length, network ID, network
Type of message, the timestamp of first frame network message, the timestamp information of last frame network message.
Further, the network message storing step the step of in (2), blocks of files is write sequentially in time to institute
During the message data block of distribution, after the message data block distributed when one fills up, if the type network message institute
The message data block quota of distribution is not finished, and directly application occupies next distributed message data block, and otherwise, covering is most
The message data block of old distribution.
Further, in the hard disk partition step, the capacity of the memory block is using 1G bytes as base unit, each number
It is differed according to the capacity of block for 1~nG, wherein n is positive integer.
Advantageous effect using the invention described above technical solution is:1st, this storage method is according to different type network message
Characteristic distributes data block, distributes number more message data block for big flow network message, mutually should be small capaciated flow network message
Distribute number less message data block, equilibrium is not in that some magnetic tracks of hard disk and sector are wiped by high intensity using hard disk
It writes, and long-term leave unused of remaining magnetic track and sector causes the not available problem of hard disk corruptions, is conducive to the general safety of hard-disk system
And stabilization.
2nd, network message is stored separately by type, reduces the traversal time of later retrieval and the number of access hard disk,
For a small amount of network message, effect is especially apparent.
3rd, independent memory space design, once substation's particular network accident, only influences specific among carrying out
The storage of type network message, remaining type network message is unaffected, and fault-tolerance and security get a promotion.
4th, the real-time tracking formula maintenance mechanism of metadata+data block is established, is preserved respectively in fixed position, it can be rapid
Writing position of the network message in hard disk is positioned, even if power down occurs, recovers correct writing position after also restarting in next time.
Description of the drawings
Fig. 1 is that a kind of naked embodiment hard disk for taking inventory method for storing of intelligent substation network message proposed by the invention is drawn
Separation structure schematic diagram;
Fig. 2 is a kind of naked embodiment flow for taking inventory method for storing of intelligent substation network message proposed by the invention
Figure.
Specific embodiment
The principle and features of the present invention will be described below with reference to the accompanying drawings, and the given examples are served only to explain the present invention, and
It is non-to be used to limit the scope of the present invention.
Embodiment one, the present embodiment proposes a kind of the naked of intelligent substation network message and takes inventory method for storing, including following
Step:
Hard disk partition is several numbers as shown in Figure 1, being hard-disc storage data structure schematic diagram by hard disk partition step
It is respectively BLOCK1, BLOCK2 ... according to block BLOCK, each memory block BLOCK includes several blocks of files F_M, is respectively F_
M1, F_M2 ... are numbered with sequence number, such as 0,1,2,3 ... for each data block and file block sequence.
Data block function partiting step, in each data block, fixed to choose the data block that wherein number is 0 be meta data block,
For the metadata of storage file block, remainder data block is used for the network message data of storage file block, is message data block;It is logical
It crosses and divides data block according to function, realize metadata and stored respectively with network message data, only need to remember meta data block
Position, you can be realized as quick-searching to blocks of files by retrieving metadata.
It is empty according to shared by volume forecasting different type network message by network message using its own type as partitioning standards
Between size, be respectively the number of data blocks that all types of network messages distribution match with its occupied space;By network message
It is stored separately by type, in later retrieval, can targetedly retrieve to store such according to the type of network message
The data block of type reduces the traversal time of later retrieval and the number of access hard disk, for a small amount of network message, effect
It is especially apparent.In addition, according to the characteristic of different type network message distribute data block, for big flow network message distribute number compared with
More message data blocks mutually should be small capaciated flow network message and distribute small numbers of message data block, as SV network messages can be with
More message data blocks are distributed, and PTP network messages can distribute less message data block, realize the conjunction of memory space
Reason utilizes, equilibrium using hard disk, be not in hard disk some magnetic tracks and sector it is erasable by high intensity, and remaining magnetic track and sector
Long-term leave unused causes the not available problem of hard disk corruptions, is conducive to the safety and stabilization of hard-disk system entirety.
Wherein, in the hard disk partition step, the capacity of the data block is using 1G bytes as base unit, each data block
Capacity differ for 1~nG, wherein n is integer.It is differed in size by divide the capacity of message data block, equally facilitated
Can be balanced when being distributed for different types of network message, it avoids when being divided into impartial amount of capacity, if the distribution of each data block
Capacity is too big, causes to cause the wasting of resources during storage few network message of occupied space, if the capacity of each memory block distribution is too small,
When can cause the storage big network message of occupied space again, distribute that the quantity of memory block is excessive for it, increase that retrieval takes asks
Topic.
By being data block, blocks of files by hard disk partition in this method, it is respectively used to store different types of network message
Or the file block message of different content, certain types of network message can only occupy the message data block in default quota, shape
Into independent memory space, a message data block must not store the network message of more than one type, if data volume is bigger
The network message of type can distribute the message data block of greater number, by using independent after its occupied space is estimated
Memory space designs, once substation's particular network accident, only influences the storage of particular type of network message, remaining type network
Message is unaffected, and fault-tolerance and security get a promotion.
Memory Allocation step is that the network message of each type distributes a memory;
Network message storing step, as shown in Fig. 2, comprising the following steps:
S1, network message is written into first is write according to its type into the memory corresponding to its type, be described
Network message to be written distributes a blocks of files sequence number, and the parameter information of blocks of files corresponding to the blocks of files sequence number is extracted,
Form the metadata of this document block;Network message is stored in the form of blocks of files, each blocks of files has unique blocks of files sequence
Number, later data is facilitated to search, is reduced to the abrasion of hard disk traversal time and reduction to hard disk.
S2, the data block distributed for the type of the network message to be written is found, the metadata of the blocks of files is write
Enter in the data block that number is 0, the blocks of files is write sequentially in time into the remainder data block distributed.
As a preferred embodiment, in the step S1 of the network message storing step, net is written into first
Network message is write according to its type into the memory corresponding to its type, which enters after memory with pcap forms
Accumulation after memory fills up, first carries out the compression of a gzip form, and adds gzip and cyclic redundancy check, constitutes gzip lattice
The gzip_buffer of formula.Data encoding based on standardized format, the later-stage secondary for being conducive to data are used, and have bigger
Open and versatility.
Wherein, in the step S1 of the network message storing step, the ginseng of blocks of files corresponding to the blocks of files sequence number
Number information include at least offset of the blocks of files corresponding to this document block sequence number in entire hard disk, length, network ID, network message
Type, the timestamp of first frame network message, the timestamp information of last frame network message.By the way that more than parameter information is carried
Metadata information is taken into, writing position of the network message in hard disk can be positioned rapidly, it, also can be in weight next time even if power down occurs
Recover correct writing position after opening.
In the step S2 of the network message storing step, blocks of files is write sequentially in time to currently being distributed
During message data block, after the message data block distributed when one fills up, if what the type network message was distributed
Message data block quota is not finished, and directly application occupies next message data block ready for its distribution, and otherwise, covering is most
The message data block of old distribution.Storage mode is according to first in first out, Xun Huan storage.
According to the network message that this method stores, single network message or the network message file of some period are being inquired about
When, by way of secondary index, first according to finding the message data block containing objective network message in type, then in first number
According to the data block containing objective network message is searched in block, in a manner of " leapfroging ", achieve the purpose that quick-searching.
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all the present invention spirit and
Within principle, any modifications, equivalent replacements and improvements are made should all be included in the protection scope of the present invention.