Ethernet Variable Exchange
This section provides basic information regarding Ethernet Variable Exchange (ETH VE) protocol components.
Ethernet Variable Exchange (ETH VE) is a simple protocol based on TCP/UDP for exchanging data over the Ethernet.
The TCP/UDP utilizes Lightweight IP (lwIP) library provided by Xilinx.
The protocol runs as a bare-metal application and deterministic execution rate is guaranteed.
ETH VE Setup
ETH VE Setup component and dialog window are shown in the table below.
Component | Component dialog | Component properties |
---|---|---|
ETH VE Setup |
|
Component properties are described in the table below.
Property name | Description |
---|---|
Override HIL device ID | Allows to specify HIL Device ID on device where device ID does not exist (like on HIL402). HIL Device ID is used as last digit of MAC address, so it is important to be unique. For example, in setup where two HIL402 are communicating over ETH VE, both will have same MAC address unless one HIL Device ID is overridden. Those two HIL402s are connected to the two PCs, since HIL402 cannot be paralleled. |
IP address | The IP address of the HIL device. |
Subnet mask | Mask for subnet traffic routing. |
If Ethernet Variable Exchange protocol is used, exactly one ETH VE Setup comonent must exist in the model. Through this component, configuration for all HIL devices are specified. If multiple HIL devices are specified in the model by using Device/Signal markers, IP address # property will be created automaticaly for each HIL.
ETH VE Send
ETH VE Send component is presented in the table below. This block lets you alter basic settings for the send socket. In this case, the HIL device will be the client in a client-server application.
ETH VE Send represents a client. The client tries to connect to the remote server specified with Destination IP address and Destination Port after simulation starts. If the server is accessible, an active connection is open, system variables are packed, and transferred over Ethernet. In a case of remote server failure, the client will continue trying to reconnect.
Component | Component dialog | Component propert |
---|---|---|
ETH VE Send |
|
|
Component properties are listed in the table below.
Property name | Description |
---|---|
Sample time | Message sending rate. |
Execution rate | Signal processing execution rate. Difference between the Sample time and Execution rate is that the model values are sampled on Execution rate and sent on Sample time. Execution rate must match with the other components in the model. |
Protocol | The protocol can be either TCP/IP or UDP. |
Specify local send port | An option to specify port for which data will be streamed, default is false. |
Local send port | Represents remote server IP address, available only if Specify local send port is active. |
Destination IP address | Destination IP address. |
Destination port | Remote server port to which data will be streamed. |
Configuration | Defines the payload of the Send component. For more information on how to configure the payload check the section below. |
Configuration parameters
To change the Configuration property, use Generate configuration button in the Data tab.
In the configuration menu, one can define custom payload of the data sent over Ethernet.
In the table below there is an overview of the Configuration menu.
Field name | Description |
---|---|
Signal name | Unique for the variable/constant. |
Signal type | Defining if the signal is Variable or Constant. In case of the Variable, the terminal will be placed on the component, where the signal to be sent should be connected. |
Data type | For variables it could be inherit (depends on the type of input signal), integer, unsigned integer or real. And for Constants there is also an option of sending String, which will send ASCII values of characters from left to right. |
Length (bytes) | Options for Length are dynamically changed when the Data type is chosen. For example, integer and unsigned integer length could be 1, 2, 4, or 8 bytes. The real could be Float, 4 bytes or Double, 8 bytes. For the strings, it is calculated, depending on the number of characters. |
Endian | Select between Little/Big endian byte order. |
Dimension (number/inherit) | Number of Variables to be sent of the same Data type and Length. This value dictates the dimension of input terminal. For constants it is always 1. |
Signal value | For the Constants, this defines the value that is going to be sent. |
ETH VE Receive
ETH VE Receive component is presented in the table below. This component enables you to perform basic settings for the receive socket. For ETH VE Receive, the HIL device will represent a server in a client-server application. In the schematic model can be more then one ETH VE Receive component, with at least different receive port.
ETH VE Receive represents server with a passive opened connection. It waits for any client to try to connect. Server can be configured to accept an incoming connection from any client IP and port (deactivated Specify source port and Specify source IP address respectively), or to accept only from specified IP and specified Port. After the connection has been accepted, the server starts receiving packets, parses them, and dispatches data to the target component.
Component | Component dialog | Component properties |
---|---|---|
ETH VE Receive |
|
|
Component properties are listed in the table below.
Property name | Description |
---|---|
Protocol | The protocol can be either TCP/IP or UDP. |
Local receive port | Specify server receive port. |
Specify source port | Enable flag to accept only incoming connection from client with specified send port. Due to the limitations of the TCP/IP stack, we strongly advise against using this option (e.g. if a client which runs on an OS binds to a specified port and closes the connection, each consecutive connection with the same port will have to wait a certain (OS specified) amount of time for the port to be released by the OS). |
Source port | Source port value. Available only if Specify source port property is active. |
Specify source IP address | Enable flag to accept an incoming connection only from the client with specified IP. |
Source IP address | Client IP address. Available only if Specify remote IP is active. |
Execution rate | Refresh rate of the outputs. |
Configuration | Defines the payload of the Send component. For more information on how to configure the payload check the section below. |
Configuration parameters
To change the Configuration property, use Generate configuration button in the Data sub menu.
In the configuration menu, one can define custom payload of the data received over the Ethernet.
In the table below there is an overview of the Configuration menu.
Field name | Description |
---|---|
Signal name | Unique for the variable/constant. |
Signal type | Defining if the signal is Variable or Constant. In case of the Variable, the terminal will be placed on the component. |
Data type | For variables it could be integer, unsigned integer or real. And constants are just used to skip certain number of bytes in the payload. |
Length (bytes) | Options for Length are dynamically changed when the Data type is chosen. For example, integer and unsigned integer length could be 1, 2, 4, or 8 bytes. The real could be Float, 4 bytes or Double, 8 bytes. |
Endian | Select between Little/Big endian byte order. |
Dimension (number/inherit) | Number of Variables to be received of the same Data type and Length. This value dictates the dimension of output terminal. For constants it is always 1. For the string, dimension represents number of bytes to be skipped when parsing the message. For constants it is always 1. |
Connection Establishment
To establish a connection, TCP uses a three-way handshake. Before a client attempts to connect with a server, the server must first bind to a port and listen for incoming connections - this is called a passive open. Once the passive open is established, a client may initiate an active open. To establish a connection, this three-way (or 3-step) handshake occurs in the following order:
- SYN: The active open is performed by the client sending a SYN to the server. The client sets the segment's sequence number to a random value A.
- SYN-ACK: In response, the server replies with a SYN-ACK. The acknowledgment number is set to one more than the received sequence number i.e. A+1. The sequence number that the server chooses for the packet is another random number, B.
- ACK: Finally, the client sends an ACK back to the server. The sequence number is set to the received acknowledgement value i.e. A+1, and the acknowledgement number is set to one more than the received sequence number i.e. B+1.
At this point, both the client and server have received an acknowledgment of the connection. The steps 1, 2 establish the connection parameter (sequence number) for one direction and it is acknowledged. The steps 2, 3 establish the connection parameter (sequence number) for the other direction and it is acknowledged. This way, a full-duplex communication is established (Transmission Control Protocol).
Ethernet packet
Size of payload data depends on the size of the input signal of ETH VE Send component. The structure of the ETH VE payload data is shown on the figure below.
Protocol | Max packet size | Header size |
---|---|---|
TCP/IP | up to 1500 B | 54 B (Ethernet, IPv4, TCP header) |
UDP | up to 1500 B | 42 B (Ethernet, IPv4, UDP header) |
Network setup
To establish the communication between HIL device and a PC the following must be satisfied:
- The IP addresses of the HIL device and PC applications setup should be on the same subnet (for example 192.168.2.xxx)
- Used Ethernet Access point (Network Interface, NIC, LAN card) should be
setup to use same subnet addressing:
- Open Network and Sharing Center (Figure 2).
- Click on desired network point (Ethernet 3 like in Figure 3).
- Click on Properties
- Click on Internet Protocol Version 4 (TCP/ipv4), and then properties
- Set IP address (192.168.2.100 like in Figure 3). It is important that subnet is same as configured ETH VE component
Virtual HIL support
Virtual HIL currently does not support this protocol. When using a Virtual HIL environment (e.g. when running the model on a local computer), inputs to this component will be discarded and outputs from this component will be zeroed.