Background technology
Ethernet has plurality of advantages such as cost is low, stable and reliable as a kind of network technology of maturation, has obtained extensive use in office automation and industrial control field, becomes one of current most popular communication network.The present ethernet standard that uses, adopt CSMA/CD (the Carrier Sense Multiple Access/Collision Detect) agreement of csma/cd mostly at MAC (medium access control) layer, its workflow is: when the some nodes on the network need send data, it is monitor channel at first, if channel busy just continues to wait for, when in a single day it listen to channel idle, just data are sent.If two or more nodes all monitor and etc. data to be sent, when listening to channel idle, each node (almost simultaneously) just immediately begins to send data, at this moment just clashes.If a node detects conflict during the transmission, then stop transmission immediately, and send " a crowding " signal to channel, also find this conflict to guarantee all other nodes on the network.In communication system based on Ethernet, for avoiding conflict, each node adopts binary exponential backoff (BEB, Binary Exponential Back-Off) algorithm process conflict, but this method has the uncertain defective of conflict time delay, can't effectively be used in real-time networks such as industrial control network.
Industrial control network is a kind of typical application system in real time, and task wherein (as the execution of functional block) triggers according to certain time interval usually, and the task executions time is had the off period requirement, and this task is called periodic task.Also has a kind of task in the application system in real time, this task only just occurs under specific Event triggered, the for example upload/download of equipment disposition, failure diagnosis, program, log, warning processing etc., this generic task is called the aperiodicity task, and the aperiodicity task triggers at random.These two kinds of tasks are reflected in the communication of industrial control network, are exactly the two class communication informations: the periodical communication information and the aperiodicity communication information.Periodical information is real time information, and aperiodic, information was non-real time information, and periodical communication information has different time responses with the aperiodicity communication information.And aperiodic, information had higher priority usually.In case system configuration is finished, the transmission of periodical communication information just has the time certainty.But not periodical communication information burst information often is uncertain in time.
For real-time and the certainty that improves ethernet communication, the applicant proposes the patent application of a kind of denomination of invention for " a kind of dispatching method of realizing the Ethernet deterministic communication " (application number is 03142040.0) to State Intellectual Property Office.This technical scheme may further comprise the steps:
At first, at least one main equipment of definition and several slave units on Ethernet, and, also be provided with one in order to carry out the clock server of clock synchronization;
Then, with the information in the Ethernet be divided into cycle information and aperiodic information, cycle information is adopted the control mode of time slot visit, carry out periodic exchanges data at a fixed time in the sheet; To the centralized dispatching mode of information employing aperiodic, be information communication stage aperiodic to carry out exchanges data in the gap of cycle information communication based on token.
Though said method can rational management in the industrial control network cycle and aperiodic information, and then realize industrial control network in real time and deterministic communication,, still there is following problem in it:
First: a main equipment is set in existing network, destroyed the fair principle of ethernet communication, especially transmit the centralized dispatching mode that is adopted during data aperiodic based on token, make and on channel, will transmit a large amount of tokens, not only increase the time of transfer of data aperiodic, and reduced whole Ethernet bandwidth utilization;
Second: in the same cycle, each equipment can only send cycle data one time, brings the inconvenience of equipment transmission data thus.
Summary of the invention
The object of the present invention is to provide the dispatching method of realizing the Ethernet deterministic communication in one, to solve in the prior art main equipment is set in network, destroy the fair principle of ethernet communication and the centralized dispatching mode that when transmission data aperiodic, is adopted, increase the technical problem of transmission time and reduction bandwidth availability ratio based on token.
For addressing the above problem, the invention discloses a kind of dispatching method of realizing the Ethernet deterministic communication, described Ethernet comprises that some equipment reach in order to carry out the clock server of clock synchronization between the equipment, information in the described Ethernet be divided into cycle data and aperiodic data, all devices communicated in the grand cycle of predefined communication on the described Ethernet, each grand cycle of communicating by letter be divided into the cycle data message transmissions stage and aperiodic the data message transmit stage
(1) on the data link layer of Ethernet, sets up a deterministic communication dispatching management entity for each equipment, it sets up being connected between data link layer and the data link layer user, in order to all cycle data messages of this equipment and aperiodic data message transmitting time control;
(2) system is before starting, carry out the configuration step, at least comprise: the initial moment of each the equipment setting and this equipment of preservation transmission cycle data message in the grand cycle of described communication is with respect to the bias Tn in the grand initial moment in cycle of communication, is provided with and preserves described aperiodic data message transmit stage with respect to the bias in the grand initial moment in cycle of communication;
(3) all devices cycle carries out and described clock server clock synchronization;
(4) in the cycle data message transmissions stage in each grand cycle of communicating by letter, whenever arriving this equipment to system, Equipment Inspection sends the cycle data message during moment, if there is cycle data to send, then send cycle data earlier; Send data message assert packet aperiodic then, otherwise, directly send data message assert packet aperiodic, described aperiodic, the data message assert packet included nothing but that the cycle data message needs to send, transmission aperiodic data message priority, the IP address of transmit leg equipment and the time that is sent completely that needs;
(5) all devices is saved in data message aperiodic that the certainty communication scheduling management entity of this equipment sets up in advance with data message assert packet aperiodic that receives and sends in the managing listings, and ranks according to the IP address of message priority and transmit leg equipment;
(6) at the data transfer phase aperiodic in each grand cycle of communicating by letter, whenever system arrive aperiodic the data message delivery time or this equipment receive data message aperiodic that last equipment sends and send the moment that finishes assert packet, and aperiodic during data message that this is communicated by letter and can send this equipment in grand cycle remaining time, this equipment sends data message aperiodic, and send aperiodic data messages to other equipment and send and finish assert packet sending the back, described last equipment for aperiodic data message send in the managing listings equipment than Zao transmission data message aperiodic of this equipment data message aperiodic.
Equipment is by judging whether T1 MOD T2=Tn becomes Rob Roy to detect system and whether arrive this equipment transmission cycle data message time, and wherein T1 is the current time of this equipment, and T2 is the time cycle in grand cycle of communication in the step (4).
At equipment of same cycle data transmit stage one and above described Tn can be set.
Described deterministic communication dispatching management entity is provided with stand-by state, standby condition, the cycle data transmit status and aperiodic the data transmit status, wherein, after system carries out configuration, described deterministic communication dispatching management entity transfers standby condition to from described stand-by state, when time that this equipment sends the cycle data message then, the state of described deterministic communication dispatching management entity is changed into the cycle data transmit status, after the cycle data message is sent completely, described deterministic communication dispatching management entity sends data message assert packet aperiodic, and described deterministic communication dispatching management entity is changed to standby condition, if need to send this equipment data message aperiodic, the state of then described deterministic communication dispatching management entity is changed into data transmit status aperiodic, after this equipment data message aperiodic was sent completely, described deterministic communication dispatching management entity was got back to standby condition.
Rank according to priority and IP address in the step (5) and specifically comprise:
Aperiodic, data message sorted from high to low according to priority, when priority is identical, sort according to preestablishing: if before preestablishing the high person in IP address and sending then the identical and high person row in IP address of priority earlier, otherwise, before preestablishing the low person in IP address and sending then the identical and low person row in IP address of priority earlier.
Wherein, step (6) specifically comprises:
(6-1) at the data transfer phase aperiodic in each grand cycle of communicating by letter, each equipment judges that whether this equipment has data message transmission aperiodic, if having, carry out step (6-2), otherwise described deterministic communication dispatching management entity state is set to standby condition;
(6-2) described deterministic communication dispatching management entity judge this equipment aperiodic data message priority whether the highest, if, then wait by the time aperiodic the data message transmitting time, carry out step (6-4) then, otherwise carry out step (6-3);
(6-3) described deterministic communication dispatching management entity judges whether to receive that data message aperiodic that last equipment sends sends the end assert packet, if, carry out step (6-4), otherwise carry out step (6-2), described last equipment for aperiodic data message send in the managing listings equipment than Zao transmission data message aperiodic of this equipment data message aperiodic;
(6-4) judge data message aperiodic that whether can send this equipment in this grand cycle of communicating by letter remaining time, if, send data message aperiodic, and after send aperiodic data messages to other equipment and send and finish statement, otherwise described deterministic communication dispatching management entity state is set to standby condition.
Wherein, clock synchronization comprises by SNTP SNTP or the realization of IEEE1588 exact time synchronization agreement of communicating by letter between each equipment and the described clock server in the step (3).
If the equipment that detects does not send data message assert packet aperiodic in three grand cycles of communication, described equipment is disabling devices.
Compared with prior art, the present invention has the following advantages:
First: the role of all network equipments equates, the branch that does not have master-slave equipment, thereby embodied the fair principle of ethernet communication, and, avoid adopting centralized dispatching mode data message stage aperiodic in transmission based on token, need not on channel, to transmit a large amount of tokens, not only improved the efficient of transfer of data aperiodic thus, and improved whole Ethernet bandwidth utilization;
Second: cycle data message of the present invention sends the stage, how much same equipment can reach according to the size that self sends cycle data, a plurality of transmission cycle data message periods were set in the grand cycle of same communication, a kind of dispatching method more flexibly is provided thus.
Embodiment
Below in conjunction with accompanying drawing, specify the present invention.
The invention discloses a kind of dispatching method of realizing the Ethernet deterministic communication, be used for controlling the time of the transmission message of each equipment of Ethernet, guaranteeing that synchronization has only an equipment to send message on network, and then reach in the industrial control network in real time and the purpose of deterministic communication.
In the present invention, except the equipment (or being referred to as node) that sends message, also comprise in the Ethernet in order to carry out the clock server of clock synchronization between the equipment.Information in the Ethernet be divided into cycle data and aperiodic data, in like manner, the message that each equipment will send also comprise the cycle data message and aperiodic data message.As its name suggests, the cycle data message comprises cycle data, but not the cycle data message comprises data aperiodic.
Whole network latency is divided into a unlimited isometric grand cycle of communication, each grand cycle of described communication comprise the cycle data message transmissions stage and aperiodic the data message transmit stage, all devices in each communicates by letter the grand cycle, send and the receiving cycle data message and aperiodic data message.
See also Fig. 1, it is the employed data link layer model of dispatching method of the present invention, promptly, be provided with deterministic communication dispatching management entity in the data link layer of Ethernet, it is arranged in logical link control layer, set up the connection between logical link control layer and the data link layer user, be mainly used in to all cycle datas of this equipment and aperiodic data message transmitting time control, guaranteeing that synchronization has only an equipment to send message on network, and then thoroughly avoid the message collision.All devices does not have the branch of main equipment and slave unit on the Ethernet of the present invention, and just the role of all devices all is an equality, and the scheduling on the Ethernet is to be realized by the certainty communication scheduling management entity of each equipment thus.
Real-time and the deterministic communication for the more convenient realization of energy, the applicant has proposed a kind of control procedure embodiment of deterministic communication dispatching management entities.See also Fig. 2, it is a kind of state transition graph of deterministic communication dispatching management entity.Each deterministic communication dispatching management entity is described by one of four states and the conversion between them.One of four states is respectively " standby " state (Standby), " preparation " state (Ready), " cycle data transmission " state (PeriodicData Sending), " aperiodic, data sent " state (NonPeriodicData Sending).
Wherein, after system carries out configuration, described deterministic communication dispatching management entity transfers standby condition to from described stand-by state, when time that this equipment sends the cycle data message then, the state of described deterministic communication dispatching management entity is changed into the cycle data transmit status, after the cycle data message is sent completely, described deterministic communication dispatching management entity sends data message assert packet aperiodic, and described deterministic communication dispatching management entity is changed to standby condition, if need to send this equipment data message aperiodic, the state of then described deterministic communication dispatching management entity is changed into data transmit status aperiodic, after this equipment data message aperiodic was sent completely, described deterministic communication dispatching management entity was got back to standby condition.
In message transmission procedure, deterministic communication dispatching management entity to all cycle datas of this equipment and aperiodic data message transmission control, guarantee at any time, all have only an equipment to send message on the network, and in the grand cycle of communication, the message that priority is high preferentially sends, when priority is identical, judge that according to this IP address of equipment which message preferentially sends, thereby guaranteed the certainty and the real-time of ethernet communication.
Before system start-up, at first whole system is carried out configuration, comprise at least: the size in grand cycle of devices communicating; Each equipment of equipment sends the time span of cycle data in a grand cycle of communication; The initial moment that each equipment transmission cycle data in the grand cycle of communication are set is with respect to the transport communication bias in the grand initial moment in cycle; And these information are saved in each equipment; The initial moment of each the equipment setting and this equipment of preservation transmission cycle data message in the grand cycle of described communication is with respect to the bias in the grand initial moment in cycle of communication; And be provided with and preserve described aperiodic data message transmit stage with respect to the bias in the grand initial moment in cycle of communication.
See also Fig. 3, it is a kind of division schematic diagram in the grand cycle of communication of network latency, and in the figure, network latency is divided into a unlimited isometric grand cycle of communication.Each grand cycle of communicating by letter sends the stage by the cycle data message and data message transmission stage aperiodic constitutes.
Fig. 4 is an enforcement schematic diagram of information communication process in the grand cycle of communication, in Fig. 4, has 6 equipment to communicate in the example network.As can be seen from Figure 4, the time of each equipment transmission cycle data is determined when system configuration; Shown in each equipment zero-time of sending cycle data be different with respect to the bias of the zero-time of transmission cycle, thereby the possibility of having avoided a plurality of equipment to clash during the accesses network resource simultaneously.Simultaneously, each equipment sends cycle data and has certainty in time, in case promptly equipment is sending the one-period data sometime, this equipment transmission next time can be calculated in the following manner with a kind of time of cycle data and be obtained so:
The NextSendTime=CurrentTime+ transmission cycle
Wherein, NextSendTime is the time of equipment transmission next time same period data, and CurrentTime is the moment of current transmission cycle data.
In the present invention, in one-period, allow same equipment repeatedly to send cycle data, such as, two moment that send cycle data are set in same equipment, such as S1 and S2 are set, S1 is the initial moment of this equipment transmission cycle data message in the grand cycle of described communication with respect to first bias in the grand initial moment in cycle of communication, and S2 be second bias of the initial moment of this equipment transmission cycle data message in the grand cycle of described communication with respect to the grand initial moment in cycle of communicating by letter.Therefore, the said equipment can detect the delivery time of the cycle data message of twice this equipment of transmission in one-period.
In the present invention, can also be by judging whether T1 MOD T2=Tn becomes Rob Roy to detect system and whether arrive this equipment transmission cycle data message time, wherein T1 is the current time of this equipment, T2 is the time cycle in grand cycle of communication, Tn is the bias of the initial moment of this equipment transmission cycle data message in the grand cycle of described communication with respect to the grand initial moment in cycle of communication, equally, at equipment of same cycle data transmit stage one and above Tn can be set, described Tn is the bias of the initial moment of equipment transmission cycle data message in the grand cycle of described communication with respect to the grand initial moment in cycle of communication.
Because each communicates by letter the grand cycle, the dispatching method of Ethernet deterministic communication is similar, therefore, below is example with the grand cycle of communicating by letter just, specifies the dispatching method of Ethernet deterministic communication of the present invention.
The dispatching method of Ethernet deterministic communication a grand cycle of communication mainly comprises three processes: each equipment is set up the clock synchronization process with clock server; Send cycle data message process and send data message process aperiodic.
(1) clock synchronization process
Fig. 5 is a schematic diagram of realizing clock synchronization with SNTP (SNTP, Simple Network Time Protocol).Clock synchronization strict between each equipment of maintenance of the present invention is to realize by the SNTP agreement based on UDP, as shown in Figure 5.Utilize the clock synchronization between the SNTP realization equipment, in fact be exactly allow each equipment regularly with clock server by exchanging the SNTP message, the equipment that calculates is with the time difference between the clock server, thereby the adjustment local clock remains in the scope that can allow the time difference between equipment local clock and the clock server.To use four timestamp: U during time difference between computing equipment and clock server
1, U
2, U
3And U
4, its meaning is as follows:
U
1: the local time stamp during equipment tranmitting data register synchronization request;
U
2: the timestamp when clock server receives the clock synchronization request (standard time);
U
3: the timestamp (standard time) the during syn ack of clock server tranmitting data register;
U
4: equipment receives the local time stamp of clock synchronization when replying.
SNTP realizes that clock synchronization based on a supposition, is exactly that equipment equates to the transmission delay between the field apparatus to clock server and clock server.Based on this hypothesis, we are by the time deviation T between following algorithm computation field apparatus and the clock server
d
U
2-(U
1+U
d)=(U
4+U
d)-U
3
Just can calculate time deviation U between equipment and the clock server according to following formula
d:
U
d=((U
2-U
1)+(U
3-U
4))/2
Equipment can be according to time deviation U
dAdjust local clock, thereby realize synchronously with clock server.All devices on the network means it also is synchronous in time between all devices on the network after realizing synchronously by identical mode and clock server.
(2) cycle data process of transmitting
See also Fig. 6, it is the cycle data process of transmitting schematic diagram of equipment in the grand cycle of communication.
At first carry out step S110, in the message transmissions stage in cycle in grand cycle of communication, the certainty communication scheduling management entity of each equipment is if detect the time that this equipment sends the cycle message, then the certainty communication scheduling management entity of this equipment is changed into " cycle data transmission " state, if this equipment has periodically packet, then send the cycle message, otherwise, directly carry out step S120;
Carry out step S120 then: the certainty communication scheduling management entity of this equipment judges whether also have other times to send cycle data in this communicates by letter the grand cycle, if carry out step S110, otherwise carry out step S130; Deterministic communication dispatching management entity can know that by the number that detects Tn this equipment needs to send the number of cycle data message in the grand cycle of same communication, and Tn is the bias of the initial moment of equipment transmission cycle data message in the grand cycle of described communication with respect to the grand initial moment in cycle of communication;
Carry out step S130 subsequently: with aperiodic in this cycle the data message assert packet send data link layer to, send the statement of this cycle data message by other each equipment of data link course, and deterministic communication dispatching management entity is changed into standby condition; Aperiodic, the data message assert packet comprised whether having aperiodic data to need to send, the IP address of transmit leg, aperiodic data message transmission priority and need parameter such as transmitting time.
Carry out step S140 at last: each equipment with aperiodic the data message assert packet leave in advance the data message of setting up aperiodic in and send in the managing listings, and rank according to priority and IP address.Aperiodic, data message sorted from high to low according to priority, when priority is identical, sort according to preestablishing: if before preestablishing the high person in IP address and sending then the identical and high person row in IP address of priority earlier, otherwise, before preestablishing the low person in IP address and sending then the identical and low person row in IP address of priority earlier, perhaps
Aperiodic, data message sorted from low to high according to priority, when priority is identical, sort according to preestablishing: if after preestablishing the high person in IP address and sending then the identical and high person row in IP address of priority earlier, otherwise, after preestablishing the low person in IP address and sending then the identical and low person row in IP address of priority earlier.
Still sort from high to low with priority in data message transmission aperiodic managing listings in the present invention, and, identical and the high person in IP address of priority sends earlier, promptly the high person of priority identical ip addresses aperiodic data message send come in the managing listings before.
In step S140, the certainty communication scheduling management entity of equipment receives a data message transmission aperiodic assert packet, just this data message transmission aperiodic assert packet is inserted in data message transmission aperiodic managing listings.Certainly, in order to raise the efficiency, also can be after the cycle data message send end, data message transmission aperiodic assert packets all in the data message transmission aperiodic managing listings sort together.
(3) aperiodic, data message sent
See also Fig. 7, it is the transmission flow of equipment transmission of grand cycle of communication data message aperiodic among the present invention, may further comprise the steps:
S210: at the data transfer phase aperiodic in each grand cycle of communicating by letter, each equipment judges that whether this equipment has data message transmission aperiodic, if having, carries out step S220; Otherwise described deterministic communication dispatching management entity state is set to standby condition;
S220: judge this equipment aperiodic data message priority whether the highest, if, then the certainty communication scheduling management entity of this equipment etc. by the time aperiodic the data message transmitting time, then, carry out step S240, otherwise, carry out step S230;
S230: described deterministic communication dispatching management entity judges whether to receive that data message aperiodic that last equipment sends sends the end assert packet, if, carry out step S240, otherwise carry out step S220, described last equipment for aperiodic data message send in the managing listings equipment than Zao transmission data message aperiodic of this equipment data message aperiodic;
S240: judge data message aperiodic that whether can send this equipment in this grand cycle of communicating by letter remaining time, if, send data message aperiodic, and after send aperiodic data messages to other equipment and send and finish statement, otherwise described deterministic communication dispatching management entity state is set to standby condition.
Owing to adopted technique scheme, the present invention provides a kind of dispatching method of deterministic communication being positioned at client layer on the UDP, with the cycle in the rational management industrial control network and aperiodic data, on based on the industrial control network of Ethernet+UDP/IP, realize real-time and deterministic communication, to satisfy real-time and the deterministic requirement of industrial control network to communicating by letter based on the traditional ethernet standard.
More than disclosed only be several specific embodiment of the present invention, but the present invention is not limited thereto, any those skilled in the art can think variation all should fall within protection scope of the present invention, protection scope of the present invention is as the criterion with claims.