A kind of collecting method and system based on cascade ethernet device
Technical field
It is particularly a kind of to be adopted based on the data for cascading Ethernet the present invention relates to one kind the invention belongs to collecting method
Diversity method, the invention also discloses the data collecting system of the application collecting method.
Background technology
Industrial automation system forward direction distribution, intelligentized control aspect development in real time, wherein communication turns into key, by
There is the good reputation of " net is on earth " in Ethernet, quilt is it has been recognized that be the best solution of futurity industry network.
Data acquisition is from its exterior gathered data and to be input to a kind of interface skill of internal system using a kind of device
Art, at interval of certain time(Claim the sampling period)Same point Data duplication is gathered, is widely used in every field.With interconnection
The fast development of net industry, the data acquisition combined with Ethernet have been widely used in internet and field of distributed type, will
A brand-new epoch have been brought in data acquisition into.
Periodic data acquisition uses the work framework of client/server, and data summarization end is as client computer, collection
Terminal, when data summarization end needs gathered data, command request, acquisition terminal response is sent to acquisition terminal as server
Command request, return to the data to be gathered.According to this communication process, within a sampling period, complete remaining to adopt other
Collect the data acquisition of terminal.Have a disadvantage in that:The ethernet end device of cascade is, it is necessary to specify IP address, neighbouring device port
Between IP address must be in a network segment.Terminal device quantity is not adapted dynamically, when the number for increasing or decreasing cascade device
, it is necessary to change the network connection configuration item of associated device during amount, to ensure mutually access between neighbouring device after increasing and decreasing.
In addition, the quantity increase of cascade device, it is necessary to IP address number in multiple increase, each equipment operation TCP/IP
The time of protocol stack can not be ignored, and the real-time of data communication is had a greatly reduced quality.
The content of the invention
The technical problems to be solved by the invention are in view of the shortcomings of the prior art, there is provided it is a kind of without configuring, adaptively
The collecting method based on cascade ethernet device of network equipment number change.
Another technical problem to be solved by this invention there is provided the system using aforementioned data acquisition method.
The technical problems to be solved by the invention are realized by following technical scheme.The present invention is that one kind is based on
The collecting method of ethernet device is cascaded, is characterized in, this method is used for " data summarization terminal " and some sets " gather eventually
Data communication between end ";Data summarization terminal and acquisition terminal are terminal device;
By an Ethernet cable between some sets " acquisition terminal ", it is attached using hand-in-hand mode, final connection
In " data remittance terminal ", a kind of cascade system of Ethernet interface is formed;
Data link layer of this method based on Ethernet is extended, and has used identifier and data field, and identifier length is 2 words
Section, numerical value are more than 0x5dc.
Collecting method of the present invention based on cascade ethernet device, its further preferred technical scheme
It is:For data summarization terminal or the acquisition terminal being connected in this cascade system, a new data frame is received, is sentenced first
Whether the numerical value in disconnected identifier domain is identical with the numerical value of definition, such as identical, then is handled using collecting method;If not
Together, then handled by the protocol stack of standard.
Collecting method of the present invention based on cascade ethernet device, its further preferred technical scheme
It is:Using the first character section of data field as command code, according to the difference of numerical value, the communication of difference in functionality is completed;Design number
According to second byte in domain as auxiliary code;Command code is defined as follows:
(1)" 0x1 " represents to send data frame to designated terminal equipment
Terminal device sends data frame to the terminal device of specified hardware physical address, and the terminal device for meeting the address receives
After the data frame, corresponding function treatment is carried out according to auxiliary code;
(2)" 0x2 " represents the request of response command code " 0x1 "
After terminal device receives the data frame that command code is " 0x1 ", commands in return code is the data frame of " 0x2 ";
(3)" 0x3 " represents to send data frame to multiple terminal devices
It is " 0x3 " data frame that other equipment of the terminal device into whole cascade system, which sends command code, receives the data frame
Terminal device, corresponding function treatment is carried out according to auxiliary code;
(4)" 0x4 " represents the request of response command code " 0x3 "
After terminal device receives the data frame that command code is " 0x3 ", commands in return code is the data frame of " 0x4 ".
Collecting method of the present invention based on cascade ethernet device, its further preferred technical scheme
It is:Terminal device in cascade system uses following method quick obtaining neighbouring devices and its hardware of series devices physically
Location:
(1)Terminal device is that the terminal device for asking direction adjacent is the data frame that responder 1 sends that command code is " 0x3 ", is counted
It is its own according to source physical address in frame, purpose physical address is the broadcast address of complete " 1 ", and auxiliary code is " 1 ", data field
3rd to the 8th position preserves the physical address of itself;
(2)After responder 1 receives the data frame, response sends the data frame that command code is " 0x4 ", and auxiliary code is " 1 ", data
3rd to the 8th position in domain preserves the physical address of requesting party, and the 9th to the 14th position of data field preserves the physics of itself
Address;It is simultaneously that responder 2 forwards the data frame to adjacent terminal device by another port, source physics before forwarding
Make the physical address of responder 1 into address;
(3)After responder 2 receives the data frame, response sends command code and is the data frame of " 0x4 ", while passes through another
Port is that responder 3 forwards the data frame to adjacent terminal device;
After responder 1 receives the responsive data frame of responder 2, forwarded by another ethernet port, until asking
The side of asking receives this responsive data frame;
(4)After responder 1 receives the responsive data frame of responder 2, forwarded by another ethernet port, until
Requesting party receives this responsive data frame;
(5)By that analogy, to the last a terminal device response sends the data frame that command code is " 0x4 ".
Collecting method of the present invention based on cascade ethernet device, its further preferred technical scheme
It is:Enter row data communication between any two terminal device in cascade system, complete configuration, control, alarm lamp function, terminal
Equipment X and terminal device Y enters row data communication, there is a transferring equipment between two equipment, and its data communications method is as follows:
(1)Terminal device X sends the data frame that command code is " 0x1 " to adjacent transferring equipment, source physical address in data frame
It is its own, purpose physical address is the broadcast address of complete " 1 ", and auxiliary code is " 1 ", and the 3rd to the 8th position of data field is protected
The physical address of itself is deposited, the 9th to the 14th position of data field preserves terminal Y physical address;
(2)Transferring equipment receives the data frame, judges the numerical value and its own physical address of the 9th to the 14th position of data field
After difference, forwarded by another ethernet port, source physical address is made into transferring equipment physically before forwarding
Location;
(3)Terminal device Y receives the data frame of transferring equipment forwarding, judges the numerical value of the 9th to the 14th position of data field
Identical with its own physical address, the value according to auxiliary code carries out the processing of difference in functionality;
(4)Terminal device Y-direction transferring equipment sends the responsive data frame that command code is " 0x2 ", and source physical address is in data frame
Its own, purpose physical address is transferring equipment address, and auxiliary code is " 1 ", and the 3rd to the 8th position of data field preserves terminal
Equipment X physical address, the 9th to the 14th position of data field preserve the physical address of itself;
(5)Transferring equipment receives the data frame, judges command code for the 3rd to the 8th value of " 0x2 " and data field and itself ground
After the difference of location, forwarded by another ethernet port, source physical address is made before forwarding into the physics of transferring equipment
Address, target physical address are terminal device X addresses;
(6)Terminal device X receives the forwarding frame, judges that command code is " 0x2 " and data field the 3rd to the 8th value and itself
After address is identical, terminal device Y responsive data frame is eventually received.
Collecting method of the present invention based on cascade ethernet device, its further preferred technical scheme
It is:" data summarization end " initiates communication request to multiple " acquisition terminals ", it is desirable to which respective gathered data is returned to " number by they
Held according to collecting ", realize " one-to-many " periodic data communication process;In " one-to-many " communication cycle, " data summarization
End " only need to send a command request, and multiple " acquisition terminals " respond, return to the gathered data of this terminal successively:
(1)" acquisition terminal " that " data summarization end " asks direction adjacent is the data that responder 1 sends that command code is " 0x3 "
Frame, source physical address is its own in data frame, and purpose physical address is the broadcast address of complete " 1 ", and auxiliary code is " 2 ", data
3rd to the 8th position in domain preserves the physical address of itself;
(2)After responder 1 receives the data frame, response sends the data frame that command code is " 0x4 ", and auxiliary code is " 2 ", data
3rd to the 8th position in domain preserves the physical address of requesting party, and the 9th to the 14th position of data field preserves the physics of itself
Address;It is simultaneously that responder 2 forwards the data frame to adjacent terminal device by another port, source physics before forwarding
Make the physical address of responder 1 into address;
(3)After responder 2 receives the data frame, response sends command code and is the data frame of " 0x4 ", while passes through another
Port is that responder 3 forwards the data frame to adjacent terminal device;
(4)After responder 1 receives the responsive data frame of responder 2, forwarded by another ethernet port, until
Requesting party receives this responsive data frame;
(5)By that analogy, to the last a terminal device response sends the data frame that command code is " 0x4 ".
The technical problems to be solved by the invention can also further be realized by following technical scheme.The present invention is also
A kind of data collecting system based on cascade ethernet device for realizing collecting method described in above technical scheme is disclosed,
It is characterized in, the data collecting system includes " data summarization terminal " and some sets " acquisition terminal ", some sets " acquisition terminal "
Between by an Ethernet cable, be attached, be ultimately attached to " data remittance terminal " using hand-in-hand mode, form one
The cascade system of kind Ethernet interface.2 Ethernet interfaces are each equipped with " acquisition terminal ".
Based on ethernet device can receive complete " 1 " physical address or with its own physical address identical data frame, no
Meeting the data frame of above-mentioned physical address will be dropped.The present invention according to this principle, devise " fast physical address exchange ",
" point-to-point communication " and " one-to-many communication " method, realize the collecting method of cascade Ethernet.
1st, unique identifier design
The data frames such as TCP/IP are different from by identifier, meeting the data frame of identifier feature of the present invention could be processed.This
The identifier of invention design is compatible with the Software Protocol Stack of existing hardware net equipment and standard.In other words, using this hair
Bright terminal device can be coexisted in the other standards network equipment in a LAN.
2nd, the increase and decrease of adaptive terminal equipment, without configuration
Whether user need not set IP address, without care IP address in a network segment.Even if cascade network Dynamic contraction, increase
Add deduct few terminal device, method of the invention still can normal work it is unaffected.
Compared with prior art, advantages of the present invention and technique effect are as follows:
(1)Without configuration, the change of adaptive network number of devices
Whether user need not set IP address, without care IP address in a network segment.Even if cascade network Dynamic contraction, increase
Add deduct and lacked terminal device, method of the invention still can normal work it is unaffected.
(2)Efficiently easily realize, data communication has more preferable real-time
a)Original technology forwards a data frame to need to run huge ICP/IP protocol stack and could complete, and the time of cost is much
More than the time of the present invention.
b)The method of the present invention can use FPGA(Field programmable gate array)Technology or custom chip realize that data frame connects
Receipts/processing/forwarding, can be performed parallel, and the forwarding time of data frame will become to ignore.
Brief description of the drawings
Fig. 1 is the whole cascade system structural representation of the present invention;
Fig. 2 is ethernet data frame form schematic diagram;
Fig. 3 is the process chart for receiving a new data frame;
Fig. 4 is that fast hardware address exchanges schematic flow sheet;
Fig. 5 is point-to-point communication process schematic;
Fig. 6 is one-to-many communication means schematic diagram.
Embodiment
Referring to the drawings, the concrete technical scheme of the present invention is further described, in order to which those skilled in the art enters
One step the present invention is understood, without forming the limitation to its right.
Embodiment 1, a kind of collecting method based on cascade Ethernet:For " data summarization terminal " and N set " collections
Terminal "(N≥1)Between data communication.
By an Ethernet cable between N sets " acquisition terminal ", it is attached using hand-in-hand mode, final connection
In " data remittance terminal ", a kind of cascade system structure of Ethernet interface is formed.Whole cascade system structure chart is as shown in Figure 1.
Collecting method does not produce punching with standard protocol stacks such as the network equipment and TCP/IP such as existing HUB, interchangers
It is prominent.
Data link layer of the collecting method based on Ethernet is extended, and has used identifier and data field, mark
It is 2 bytes to accord with length, and numerical value is more than 0x5dc.As shown in Figure 2.
For data summarization terminal or the acquisition terminal being connected in this cascade system, a new data frame is received,
First determine whether the numerical value in identifier domain is identical with the numerical value that the present invention defines, it is such as identical, then using the method for the present invention
Handled;Such as difference, then by the protocol stack of standard(TCP/IP etc.)Handled.The institute of handling process such as 3 of whole data frame
Show.
This method uses the first character section of data field, according to the difference of numerical value, to complete difference in functionality as command code
Communication.Second byte in design data domain of the present invention is as auxiliary code.
In order to describe conveniently, data summarization terminal and acquisition terminal are referred to as terminal device.
The definition of command code:
(1)" 0x1 " represents to send data frame to designated terminal equipment
Terminal device sends data frame to the terminal device of specified hardware physical address, and the terminal device for meeting the address receives
After the data frame, corresponding function treatment is carried out according to auxiliary code.
(2)" 0x2 " represents the request of response command code " 0x1 "
After terminal device receives the data frame that command code is " 0x1 ", commands in return code is the data frame of " 0x2 ".
(3)" 0x3 " represents to send data frame to multiple terminal devices
It is " 0x3 " data frame that other equipment of the terminal device into whole cascade system, which sends command code, receives the data frame
Terminal device, corresponding function treatment is carried out according to auxiliary code.
(4)" 0x4 " represents the request of response command code " 0x3 "
After terminal device receives the data frame that command code is " 0x3 ", commands in return code is the data frame of " 0x4 ".
Related communications method is as follows:
(1)Fast hardware address exchanging method
Terminal device in cascade system can be with quick obtaining neighbouring device and its hardware physics of series devices using the method
Address.
a)Terminal device(Requesting party)To adjacent terminal device(Responder 1)The data frame that command code is " 0x3 " is sent,
Source physical address is its own in data frame, and purpose physical address is the broadcast address of complete " 1 ", and auxiliary code is " 1 ", data field
The the 3rd to the 8th position preserve the physical address of itself.
b)After responder 1 receives the data frame, response sends the data frame that command code is " 0x4 ", and auxiliary code is " 1 ",
3rd to the 8th position of data field preserves the physical address of requesting party, and the 9th to the 14th position of data field preserves itself
Physical address;Simultaneously by another port to adjacent terminal device(Responder 2)The data frame is forwarded, source before forwarding
Physical address makes the physical address of responder 1 into.
c)After responder 2 receives the data frame, response sends the data frame that command code is " 0x4 ", while by addition
A port is to adjacent terminal device(Responder 3)Forward the data frame.
After responder 1 receives the responsive data frame of responder 2, forwarded by another ethernet port, directly
This responsive data frame is received to requesting party
d)After responder 1 receives the responsive data frame of responder 2, forwarded by another ethernet port, until
Requesting party receives this responsive data frame
e)By that analogy, to the last a terminal device response sends the data frame that command code is " 0x4 ".
Whole processing procedure is as shown in Figure 4." AB ", " CD ", " EF " etc. represent the hardware address of terminal device in figure, below
Together.
(2)Point-to-point data communication
Enter row data communication between any two terminal device in cascade system, complete configuration, control, alarm lamp function.
Terminal X(AB)With terminal Y(EF)Enter row data communication, there is a transferring equipment between two equipment(CD).
a)Terminal X sends the data frame that command code is " 0x1 " to adjacent transferring equipment, and source physical address is in data frame
Its own, purpose physical address is the broadcast address of complete " 1 ", and auxiliary code is " 1 ", and the 3rd to the 8th position of data field preserves
The physical address of itself, the 9th to the 14th position of data field preserve terminal Y physical address;
b)Transferring equipment receives the data frame, judges the numerical value and its own physical address of the 9th to the 14th position of data field
After difference, forwarded by another ethernet port, source physical address is made into transferring equipment physically before forwarding
Location;
c)Terminal Y receive transferring equipment forwarding data frame, judge the 9th to the 14th position of data field numerical value and itself
Physical address is identical, and the value according to auxiliary code carries out the processing of difference in functionality;
d)Terminal Y-direction transferring equipment sends the responsive data frame that command code is " 0x2 ", in data frame source physical address be it from
Body, purpose physical address are transferring equipment addresses, and auxiliary code is " 1 ", and the 3rd to the 8th position of data field preserves terminal X thing
Address is managed, the 9th to the 14th position of data field preserves the physical address of itself;
e)Transferring equipment receives the data frame, judges command code for the 3rd to the 8th value of " 0x2 " and data field and itself ground
After the difference of location, forwarded by another ethernet port, source physical address is made before forwarding into the physics of transferring equipment
Address, target physical address are terminal X addresses;
f)Terminal X receives the forwarding frame, judges 3rd to 8th value and Self address phase of the command code for " 0x2 " and data field
With after, terminal Y responsive data frame is eventually received.
Whole processing procedure is as shown in Figure 5." XXXX ", " YYYY " etc. represent the data in data frame in figure, as follows.
(3)One-to-many communication means
" data summarization end " initiates communication request to multiple " acquisition terminals ", it is desirable to which they return to respective gathered data
" data summarization end ", " one-to-many " communication is periodic data communication process.
In " one-to-many " communication cycle, " data summarization end " need to only send a command request, and multiple " collection is eventually
End " responds successively according to the method for the present invention, returns to the gathered data of this terminal.Whole processing procedure is as shown in Figure 6.
a)" data summarization end "(Requesting party)To adjacent " acquisition terminal "(Responder 1)Command code is sent as " 0x3 "
Data frame, source physical address is its own in data frame, and purpose physical address is the broadcast address of complete " 1 ", and auxiliary code is " 2 ",
3rd to the 8th position of data field preserves the physical address of itself.
b)After responder 1 receives the data frame, response sends the data frame that command code is " 0x4 ", and auxiliary code is " 2 ",
3rd to the 8th position of data field preserves the physical address of requesting party, and the 9th to the 14th position of data field preserves itself
Physical address;Simultaneously by another port to adjacent terminal device(Responder 2)The data frame is forwarded, source before forwarding
Physical address makes the physical address of responder 1 into.
c)After responder 2 receives the data frame, response sends the data frame that command code is " 0x4 ", while by addition
A port is to adjacent terminal device(Responder 3)Forward the data frame.
d)After responder 1 receives the responsive data frame of responder 2, forwarded by another ethernet port,
Until requesting party receives this responsive data frame
e)By that analogy, to the last a terminal device response sends the data frame that command code is " 0x4 ".
Embodiment 2, reference picture 1, it is a kind of realize collecting method described in embodiment 1 based on cascade ethernet device
Data collecting system, the data collecting system include " data summarization terminal " and some sets " acquisition terminal ", and " collection is eventually for some sets
By an Ethernet cable between end ", it is attached using hand-in-hand mode, is ultimately attached to " data remittance terminal ", shape
Into a kind of cascade system of Ethernet interface.2 Ethernet interfaces are each equipped with " acquisition terminal ".