Selecontrol® Mas: Tcp/Ip and Udp
Selecontrol® Mas: Tcp/Ip and Udp
This material has been compiled exclusively for training. Subsequently, it will not
be revised or updated in any way. It is intended only for your own personal use.
This material has been compiled with utmost care but, by way of exception, may
contain erroneous or misleading particulars for which Selectron Systems AG
cannot accept any liability. The contents of this material are for internal use only.
No part may be reproduced, utilized and/or communicated to others, unless
expressly authorized by Selectron Systems AG.
Selectron Systems AG reserves all rights to the acquisition and registration of
commercial property rights, particularly those for filing patent, utility model and/or
design applications.
Knorr-Bremse Group
Overview
Introduction
The OSI Layer Model
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
Introduction
Multi-layer reference model which assigns different communication functions to the various layers
It serves as a theoretical model for modern communication systems
ISO/OSI
7 Application layer
HTTP SNMP FTP TRDP CIP Modbus TCP/IP
6 Presentation layer
TCP / UDP
5 Session layer
IP
4 Transport layer
Ethernet
3 Network layer
Knorr-Bremse Group |3
Introduction
UDP TCP
Connection-less service Connection-oriented service
Example of datagram sockets Example of stream sockets
Routing: Routing:
Knorr-Bremse Group |4
Introduction
Transaction oriented
Delivery and duplicate protection are not guaranteed
Datagram mode of packet-switched computer communication
Major uses are DNS (Domain Name Server) NTP (Network Time Protocol), SNMP (Simple Network Management
Protocol) and TFTP (Trivial File Transfer Protocol)
The field size has a theoretical limit of 65,535 bytes
Knorr-Bremse Group |5
Introduction
Connection-oriented
Highly reliable host-to-host protocol
Able to transfer a continuous stream of octets in each direction
Must recover from data that is damaged, lost, duplicated, or delivered out of order
Provides a means for the receiver to govern the amount of data sent by the sender (flow control)
General
Knorr-Bremse Group |7
MOS Library NET_Mlib
NET_COMMUNIC
Can be used as a server or client
Passes the received data as a byte stream
User has to extract the frames from the TCP stream
UDP – User Data Protocol
LAN_UDP_INSTALL
Installs a UDP socket
A socket has a full duplex capability
Each socket has queues for sending and receiving data
LAN_UDP_SENDTO
Sends an UDP datagram packaged in a DUT structure
An unicast datagram can send up to 4080 bytes
LAN_UDP_RECVFROM
Receives an UDP datagram packaged in a DUT
structure
A maximum of 4080 bytes can be received
Knorr-Bremse Group |8
MOS Library ETHx_MLib
Get IP configuration
Knorr-Bremse Group |9
MOS Library ETHx_MLib
ETH_X_PING sends an ICMP echo request (ping) to the specified IP address dwIpAddress and waits for a response
from the partner station.
An ICMP echo request is sent to the partner with a positive edge at input xEnable
The result is signaled via outputs pDone and pError
tTimeout indicates the wait time for a response:
− No response within this wait time → error –32’757
− Partner responds within the timeout → positive pulse at pDone and calculation of delay time tDelayTime
Knorr-Bremse Group | 10
MOS Library ETHx_MLib
ETH_X_UDP_SOCKET
Opens a UDP datagram socket and binds it to the
specified port
A full duplex socket is created
Any existing receive data should be read to not block
resources unnecessarily in case data is only sent
ETH_X_SENDTO
Enables connectionless sending of data to a socket
The to send data is packed in a DUT
ETH_X_RECVFROM
Enables connectionless receiving of data from a socket
The to receive data is packed in a DUT
Knorr-Bremse Group | 11
MOS Library ETHx_MLib
ETH_X_TCP_SERVER
Opens a TCP server socket on the specified port
Accepted connections continue to exist, even if the
server is closed
ETH_X_TCP_CONNECTION
Accepts an incoming client connection to the
given server
Indicates address and port of the client
Exchanged keep-alives in the case of an inactive
connection (75s interval)
Nagle's algorithm is disabled
ETH_X_TCP_CLIENT
Creates a connection to a TCP server
Exchanged keep-alives in the case of an inactive
connection (75s interval)
Nagle's algorithm is disabled
Knorr-Bremse Group | 12
MOS Library ETHx_MLib
ETH_X_SEND
Sends the data to the connected partner using the
provided socket
The data to be sent is taken from a DUT
Sending process may require multiple cycles depending
on the size of transmission data
It is not guaranteed that the data arrives at the recipient
ETH_X_RECV
Receives the data transmitted by the connected partner
from the provided socket
The data is copied it to the DUT
Receiving process may require multiple cycles
depending on the size of the data
A TCP socket can store up to 16 kB data
Knorr-Bremse Group | 13
Error handling
Knorr-Bremse Group | 14
Setup for exercise on UDP
Exercise
Change the IP address of one CPU and connect the two training boxes together
Unplug the DDE 301 power supply on both training boxes
Create an application and insert the resource, task, DUT and POU
Add DDT 732 digital I/O module to PLC_Config and specify the I/O’s
Use the ETHx_MLib function blocks (ETH_X_UDP_SOCKET, ETH_X_SENDTO, ETH_X_RECVFROM,
eth_x_ip_addr_to_dword) to set up an UDP communication
Insert the functionality to pass the inputs of the CPU 1 to the outputs of the CPU 2 and vice versa
Optional: Check the communication using Wireshark and the mirror port on the training box
Optional: Implement an error handling in case of an open loop or a power loss of a CPU
CPU 1 DDT 732 CPU 2 DDT 732
IP: 192.168.0.2 digital I/O IP: 192.168.0.3 digital I/O
LAN 1
Knorr-Bremse Group | 15
Setup for exercise on UDP (see Online Help mETHx.chm)
diSocket is the resulting socket handle used for transmitting and receiving
Quelle: C:\Selectron\MOS\MOS83x_V730.E26B\help\en\mETHx.chm
Knorr-Bremse Group | 16
Setup for exercise on UDP
Quelle: C:\Selectron\MOS\MOS83x_V730.E26B\help\en\mETHx.chm
Knorr-Bremse Group | 18
Setup for exercise on TCP
Exercise
Change the IP address of one CPU and connect the two training boxes together
Unplug the DDE 301 power supply on both training boxes
Create a server application (CPU 1) and a client application (CPU 2), and insert the resource, task, DUT and POU
Add DDT 732 digital I/O module to PLC_Config and specify the I/O’s
Use the ETHx_MLib function blocks (ETH_X_TCP_SERVER, ETH_X_TCP_CONNECTION, ETH_X_TCP_CLIENT,
ETH_X_SEND, ETH_X_RECV, eth_x_ip_addr_to_dword) to set up a TCP communication
Insert the functionality to pass the inputs of the CPU 1 to the outputs of the CPU 2 and vice versa
Optional: Check the communication using Wireshark and the mirror port on the training box
Optional: Implement an error handling in case of an open loop or a power loss of a CPU
CPU 1 DDT 732 CPU 2 DDT 732
IP: 192.168.0.2 digital I/O IP: 192.168.0.3 digital I/O
LAN 1
Knorr-Bremse Group | 19
Quelle: C:\Selectron\MOS\MOS83x_V730.E26B\help\en\mETHx.chm
Knorr-Bremse Group | 20
Setup for exercise on TCP
Quelle: C:\Selectron\MOS\MOS83x_V730.E26B\help\en\mETHx.chm
Knorr-Bremse Group | 22
Setup for exercise on TCP
The function block ETH_X_SEND sends the data to the connected partner
using the provided socket.
Knorr-Bremse Group | 25
Thank you very much for your attention!
Knorr-Bremse Group