3 releases

0.9.5 Jun 14, 2023
0.9.4 Jun 14, 2023
0.9.2 Jun 12, 2023

#1814 in Network programming

Download history 4/week @ 2023-11-13 6/week @ 2023-11-20 14/week @ 2023-11-27 3/week @ 2023-12-11 9/week @ 2023-12-25 1/week @ 2024-01-01 16/week @ 2024-01-29 1/week @ 2024-02-05 20/week @ 2024-02-12 104/week @ 2024-02-19

141 downloads per month

MIT license

21KB
377 lines

ADS proxy

build-main

This is a Beckhoff ADS proxy that could resolve multiple tcp connections with same ip address issues.

Usage

Download binary from github release page or cargo install ads-proxy, then run ads-proxy.

ADS proxy utility

Usage: ads-proxy [OPTIONS] <PLC_ADDR>

Arguments:
  <PLC_ADDR>  PLC address, e.g. 172.18.0.10:48898

Options:
  -d, --debug
          Debug mode
  -b, --buffer-size <BUFFER_SIZE>
          Buffer size (maximum size of a AMS packet) [default: 65536]
  -q, --queue-size <QUEUE_SIZE>
          Queue size (cached packets per connection) [default: 128]
  -r, --route-ams-net-id <ROUTE_AMS_NET_ID>
          Optional ams net id route, e.g. 10.10.10.10.1.1
  -u, --username <USERNAME>
          Optional PLC username (to add route)
  -p, --password <PASSWORD>
          Optional PLC password (to add route)
      --route-host <ROUTE_HOST>
          Optional Proxy hostname (hostname or ip address, detected from PLC connection)
  -l, --listen-addr <LISTEN_ADDR>
          Proxy listen address [default: 127.0.0.1:48898]
  -h, --help
          Print help
  -V, --version
          Print version

In pyads, connect to ads-proxy. For example, client 1 and 2 on a host:

  • plc ams_net_id=192.168.0.10.1.1
  • client 1 ams_net_id=10.10.10.10.1.1
  • client 2 ams_net_id=10.10.10.10.1.2

Might need to add route entry in shell command with -r or in PLC configuration, see default user and password

ads-proxy -r 10.10.10.10.1.1 192.168.0.10:48898
import pyads

# x=1 or 2, process instance should have a unique ams net id
pyads.set_local_address("10.10.10.10.1.x")  

plc1 = pyads.Connection(ams_net_id="192.168.0.10.1.1", ams_net_port=851, ip_address="127.0.0.1")
with plc1:
    ...

# app can create multiple ADS connections
# the packets will be sent in ONE tcp connection in a process instance
plc2 = pyads.Connection(ams_net_id="192.168.0.10.1.1", ams_net_port=851, ip_address="127.0.0.1")
with plc2:
    ...

How it works

client 1        --|
10.10.10.10.1.1   |
                  | multi-connections            one connection
client 2        ---------------------> ads-proxy --------------> PLC
10.10.10.10.1.2   |                    a.b.c.d          route 10.10.10.10.1.1
                  |                                            a.b.c.d
client n        --|   
10.10.10.10.x.y

License

MIT

Dependencies

~9–21MB
~255K SLoC