Ethernet TCP Communication
This section provides basic information regarding Ethernet TCP Communication protocol components.
Ethernet TCP communication is a simple protocol based on TCP for exchanging data over the Ethernet, using the Lightweight IP (lwIP) library provided by Xilinx.
The protocol runs as a bare-metal application with a guaranteed, deterministic execution rate.
Ethernet TCP components in the Typhoon HIL toolchain
In Typhoon HIL Schematic Editor, Ethernet TCP components are found in the Ethernet Communication/TCP sub-folder under the Communication tab.
The Ethernet TCP library category consists of two components: TCP Send and TCP Receive.
Ethernet TCP communication is supported by the following Typhoon HIL devices: HIL402, HIL101, HIL404, HIL602+, HIL604, HIL506, and HIL606.
TCP Send
The TCP Send 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. A model can have more than one TCP Send component, provided there is a different local send port for each one.
TCP Send represents a client. The client tries to connect to the remote server specified by Destination IP address and Destination Port after the simulation starts. If the server is accessible, an active connection is opened, system variables are packed, and transferred over Ethernet. In case of a remote server failure, the client will continue trying to reconnect.
TCP Send component properties
- IP Address
- IP address of the HIL device.
- Netmask
- Netmask of the HIL Device.
- Ethernet port
- Ethernet port that will be used for Ethernet TCP communication.
- Local send port
- Represents the local port of the client from which data will be streamed.
- Destination IP address
- Remote server IP address to which data will be streamed.
- Destination port
- Remote server port to which data will be streamed.
- Execution rate
- Signal processing execution rate. Model values are sampled at the Execution rate and they are sent. The Execution rate must match with the other components in the model.
TCP Send ports
- Data[]
- Memory address where the data being sent is stored, the data can be packed using C function.
- Length
- Number of bytes being sent in every message.
- If length is 0 then no message will be sent.
- Status
- Indicates how many messages have not been sent for any reason.
TCP Receive
The TCP Receive block lets you alter basic settings for the receive socket. In this case, the HIL device will represent a server in a client-server application. A model can have more than one TCP Receive component, provided there is a different receive port for each one.
TCP Receive represents a server with a passive opened connection. It waits for any client to try to connect. The 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 a specified IP and a specified Port. After the connection has been accepted, the server starts receiving packets.
TCP Receive component properties
- IP Address
- IP address of the HIL device.
- Netmask
- Netmask of the HIL Device.
- Ethernet port
- Ethernet port that will be used for Ethernet TCP communication.
- Local receive port
- Represents the local port of the server on which data will be received.
- Specify source port
- Enable this option to accept only incoming connections from a client with the specified send port.
- Source port
- Available only if the Specify source port property is active.
- Source port value.
- Specify source IP address
- Enable this option to accept incoming connections only from the client with the specified IP.
- Source IP address
- Available only if Specify source IP address is active.
- Client IP address.
- Execution rate
- Refresh rate of the outputs.
TCP Receive ports
- Rcv_cnt
- Number of messages received since the simulation has started.
- Status
- Indicates how many messages have been dropped for any reason.
- Data[]
- Memory address where all data will be stored, the data can be then parsed using C function.
- Length
- Number of bytes received in the last message.
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: An 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. Step 1 establishes the connection parameter (sequence number) for one direction, and Step 2 acknowleges this. Step 2 also establishes the connection parameter (sequence number) for the other direction, and Step 3 acknowledges this. This way, a full-duplex communication is established (Transmission Control Protocol).
Virtual HIL support
Virtual HIL currently does not support this protocol. When using a non-real-time 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.