Ethernet delay evaluation by an embedded real time Simulink model PC in asynchronous mode Mario R. Modesti, Luis R. Canali, Jorge C. Vaschetti Grupo de Investigaciones en Informática para Ingeniería, Universidad Tecnológica Nacional Facultad Regional Córdoba CC 36 - X5016ZAA - Suc 16 Córdoba - Argentina e-mail : mmodesti@scdt.frc.utn.edu.ar Abstract: This work presents two real time models to provide statistical behaviour of an Ethernet link delays to use it in adaptive compensation of distributed close loop control systems. It has been obtained using an embedded Simulink model with xpctarget toolbox on a standard PC. The model operates in asynchronous mode, and so there is not synchronization between the nodes. The measurements are indirect and they represent the behaviour of the network segment for use in a real system. UDP/IP is the protocol used. Keywords: Simulink, xpctarget, Ethernet, UDP/IP, Real Time model, network delay, stochastic distribution, asynchronous mode. 1 Introduction Ethernet is one of the most used area network technologies, but it is not intended for real time communications[1]. The massive number of existing installations will be more attractive in the future for all class of control systems, included closed loop ones. There are different ways to perform a control system, and this work is oriented to a distributed asynchronous mode, where no synchronization hardware or software exists. There is much work about traffic studies and delays in networks systems. Here is presented a way to measure indirectly, but in real time, the variations of the delay between different transmissions over UDP/IP protocol. Ethernet uses a bus access called CSMA/CD, this means that before sending a packet to the network, the station listens to the channel, and when the channel appears to be idle, transmission starts, If more than one station starts to transmit into the bus, a collision is detected, putting the station in idle mode in order to try a retransmission after a random wait. This is the main reason making Ethernet not safe in real time control. Delays can be modelled in different ways: constant delays, independent delays, or Markov chains [1]. The hardware platform core of the model is the intranet of a laboratory, and the software is built using Simulink and embedded into a standard PC by a xpctarget environment. This model has been developed for compensation of closed loop control systems with networks included [2], using it for development of adaptive filters. This work presents the results of a decentralized system without synchronization between the nodes. Available data, however limited, allows to make valid discussion and conclusions of overall system behaviour. It must be remembered that delay variations patterns within a network as detailed are random in nature. 2 Goals of the work Adaptive compensation for systems where the control loop includes networks has been proposed [2]. The configuration can be viewed as active noise cancellation. Results have been acceptable. However, it is necessary to have a model of the noise source for training the filter coefficients. The discussed adaptive control structure uses an LMS algorithm (Least Minimum Squares). It adapts the control strategy to the perturbations added by the communication network. To keep aware the filter about these perturbations, the control signal has been correlated with the noise source. In this work, an embedded Simulink model running on a standard PC has been used in the experiments using two possible ways for obtaining delay information in real time.
3 Measurement concepts d1+ D1 = T + D2 d1= T + d2 -D1 In an asynchronous system, as the one d2 + D2 = T + d3 d2 = T + d3 + D2 proposed, no hardware or software synchronization link exists between the nodes of the model used for delay evaluation, so it is necessary to have one node d1+ D1+ D2 = 2T + d3 d1= 2T + d3 D1 D2 Equation 1 as packets transmitter and another node as packets receiver. D1 and D2 correspond to two different The transmitter node sends to the receiver times of successive arrivals occurred in the node one packet at a fixed rate of T ms. The packet reception node, and there exists a direct relationship is also fixed in size and is composed of random between these times and period T of the number 8 bytes long. This permits the receiver node transmission node. to insert a timing flag for each packet arrived. Using simple time analysis, it is possible to The receiver node can thus know when the build a timing equations system but it shows linear packet arrives to the UDP socket. dependence. With this equation system it is not possible to calculate dn, knowing only t, and Dn. Figure 1 shows a timing diagram of a To achieve this goal, the first delay d1 will be distributed asynchronous system, where Tx estimated. represents a source node, providing a packet of data at intervals T. Rx represents the arriving event into the reception node, each one having a different time distance due to the different delays among different transmitted packets. d1 = T + d2 -D1 d1 T + D1= d2 Equation 2 Figure 1 Measurement concept Dn is the measured time between two successive arrivals to the reception node, and dn is the delay of the packet in agreement with its sequence. The arrival to the reception node is affected randomly by the instantaneous traffic state of the network and so Dn will be in general different for each packet. There is a real time clock within the receptor node, and each arrival produces a timestamp to calculate the time between two successive arrivals. The timing relationships are expressed in the system of Equation 1. In this way, for calculating each packet delay, is necessary to know the previous packet delay. From the statistics point of view, selecting any delay for the first packet will produce a mere time shift of the remaining delays. The variance of the set is not modified as soon as the first delay value is within the boundary of the delay range set. Packets are produced into the transmitter node at each interval T, and they are arriving to the receiver node with a delay of d ms. D is the time elapsed between two successive packets in the receiver node. Time of arrival to the receiver node will be affected in a random way by the network communications conditions. There are some relationships between this characteristic values as shown on Equation 1. The receiver node has a real time clock with 1 ms of period. This is the time resolution of the measurement because it is an event based system, and the node is able to obtain the time between two consecutive arrivals with this resolution. According with the information available, it will be possible to build a dependable equation system. However it is not possible to calculate the delays with these data. To know the value of each delay it is necessary to have the precedent delay. It s value can be any within the range of the possible delays. 4 Hardware model platform A system with three standard PC included is proposed, and linked by Ethernet as detailed on figure 2.
There are three stations labelled Target_1, Target_2 and Host_Matlab, all accessible using TCP/IP and having an individual IP assigned. The Targets are connected to the Host_Matlab so to receive the model compiled by xpctarget toolbox and the runtime environment is set to configure the target PC as a dedicated controller [3]. 5 Real time platform The available platform is Simulink, with xpctarget included, having TCP/IP and UDP/IP link capabilities. UDP protocol features are similar to TCP, but it has not the safety layer. This makes TCP safer and slower than UDP. It is possible to envision a network segment (where the process will run) having load conditions that are not extreme, permitting to skip the data safety benefits that TCP provides. 6 Building the model Distributing the system model into the target stations, two models have been developed corresponding to the transmitter node and the receiver node, see figure 2. The whole model results in a integration of Simulink and Stateflow modules (other available toolbox of Matlab ). The stateflow block permits the internal synchronization of the arriving packets from the transmitter node into the socket block in the receiver node. The resulting module is called Delay block and it provides of the discrete period count between two packet arrivals. The figure 3 a,b shows the Delay block detailed for both models. Two models for the Delay function are present, based on two different algorithms to obtain delay information, called delay_1 and delay_2 Figure 2 xpctarget Model respectively. xpctarget is a Matlab toolbox that provides real time solutions to test prototypes of PC-embedded and other micro controllers based systems. It permits to embed a Simulink model, compiled and linked according the environment conditions of the selected hardware target This algorithms has been developed using Stateflow ( a toolbox of Simulink ) that allows implementation of finite state models. This model is event-triggered. Triggering is produced by an incoming packet at the UDP port. A flag is positioned for time measuring whenever a new number is detected as content of the incoming packet, and as they are randomly
generated, time should be counted for each incoming packet interval. measurements have been obtained. This shows the network activity for an interrupted transmission each 500 ms. It is possible to verify that when the network load is low, a low delay is introduced. When the traffic into the network increases, the packets begin to have a greater delay time. a ( input data ) Figure 3(a) Steteflow Model delay_1 b ( media delay) Figure 3(b) Steteflow Model delay_2 The structure of the first model called Delay_1 is shown in figure 3(a) along with its operation principle. Trigger events force state transitions on the Stateflow module and for each transition the actual count of the real time clock is recorded an so intervals can be easily obtained. P is the period of the traffic generator and delay is obtained using eqs. (1). The second model does not estimate first arrival time, merely keeping track of delays. The block called delay_2 determinates the time elapsed between two successive arriving packets. This time will be called delay. 7 Results Figure 4 shows the results obtained for a data population obtained during 1 second by delay_1 (a) and delay_2 (b). They offer a clear idea of the behavior of the network segment used for the experience. The test is made in the receive node, the resolution being 1 ms. A million samples or c ( variance of the delay ) Figure 4 Statistical markers of the model This is an indirect measurement of the real delay of each packet, expressed in terms of mean value and variance. There are time lapses without no delays, a desirable but not very common situation in the entire time frame of communication. In figure 4 the results for both models are shown. In the second model, the results are not similar, but there are delay information correlated. There are difficulties to compare both algorithms, because the network operative conditions are changing permanently. Adding a network of this characteristics into the control loop produces perturbations discussed in others papers [4], [5]. Here an embedded model for obtaining delay information useful to provide statistic models that will be used in adaptive systems for compensation of control loop systems in asynchronous mode is proposed. The available tools of Simulink permit to obtain statistics information in a simple way for The evaluation of a network segment to be used in a telematic system. The test can be regarded
as an accessory added to the control scheme. It is possible to do so because the obtained model can be linked with the model of the control system. 8 Future work Next step of this work is to obtain the mathematical model of the com-munication delay using stochastic techniques in accordance to the nature of the problem. Adaptive delay compensation is to attempted using noise cancellation models 9 Acknowledgments The author would like to express his gratitude to the members of the communications & systems group (Fachhoschschule Braunsch-weig / Wolfenbüttel Germany ), specially Prof-Dr.Ing. Wolfhard Lawrenz, who are involved with this project for their kind support and valuable advice. This work was carried on partially supported by grants from DAAD ( Deutscher Akademischer Austauschdienst ) from Germany and from Universidad Tecnológica Nacional, Facultad Regional Córdoba in Argentina. 10 References [1] Real-Time control systems with delays, Johan Nilsson, Department of automatic control, Lund Institute of Technology, Sweden [2] Real Time platform of process with networks included into the loop, Mario R. Modesti [3] xpctarget for use with Real Time Workshop, Getting Started, User s Guide, I/O Reference Guide, The MathWorks [4] Stability Analysis networked Control Systems, Gregory C. Walsh, Hong Ye, Linda G. Bushnell, IEEE Transactions on control systems technology, Vol 10, Nro 3, May 2002 [5] On the nature of the time-variant communication delays, Peter Bauer, Mihail Sichitiu, ( Univ. of Notre Dame USA ), Kamal Premaratne ( Univ. of Miami USA ).