Beckhoff.TwinCAT.Ads.TcpRouter 6.1.86

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
.NET 6.0 .NET Standard 2.0
dotnet add package Beckhoff.TwinCAT.Ads.TcpRouter --version 6.1.86
NuGet\Install-Package Beckhoff.TwinCAT.Ads.TcpRouter -Version 6.1.86
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Beckhoff.TwinCAT.Ads.TcpRouter" Version="6.1.86" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Beckhoff.TwinCAT.Ads.TcpRouter --version 6.1.86
#r "nuget: Beckhoff.TwinCAT.Ads.TcpRouter, 6.1.86"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Beckhoff.TwinCAT.Ads.TcpRouter as a Cake Addin
#addin nuget:?package=Beckhoff.TwinCAT.Ads.TcpRouter&version=6.1.86

// Install Beckhoff.TwinCAT.Ads.TcpRouter as a Cake Tool
#tool nuget:?package=Beckhoff.TwinCAT.Ads.TcpRouter&version=6.1.86


The package 'Beckhoff.TwinCAT.Ads.TcpRouter' implements a lean TCP ADS Router class to use on systems where no standard TwinCAT router is established or available.

It is running in UserMode only (no realtime characteristics) and contains no further functionality than distributing the ADS Frames (e.g. no Port 10000, no ADS Secure). It is just used to route ADS frames locally between AdsServers and to/from remote ADS devices.

Implemented in asynchronous .NET Code it can be run in your own services/daemon, as standalone console application and also in your customized application.


  • .NET 7.0, .NET 6.0 or .NET Standard 2.0 (e.g. >= .NET Framework 4.61) compatible SDK
  • No other System allocating the same port (e.g. a regular TwinCAT installation).
  • Installed Nuget package manager or Dotnet CLI.


Along with the deployment of the application where the TcpRouter is implemented, a valid Router / ADS configuration must be placed to specify the Local Net ID, the name and the default port of the Router system.

The preferred way to configure the system is with standard Configuration providers, which are part of the .NET Core / ASP .NET Core infrastructure.

See further information:

This enables common options for application configuration that can be used 'out-of-the-box':

  • Via the file appsettings.json
  • With the StaticRoutesConfigurationProvider (StaticRoutes.xml)
  • Using Environment Variables.
  • Command line arguments
  • etc.

The configuration has to be loaded during application startup and is placed into the 'TwinCAT.Ads.TcpRouter.AmsTcpIpRouter' class via constructor dependency injection and must contain the following information:

  • The name of the local System (usually the Computer or Hostname)
  • The Local AmsNetId of the local system as Unique Address in the network
  • Optionally the used TcpPort (48898 or 0xBF02 by default)
  • The static routes in the 'RemoteConnections' list.
  • Logging configuration.

Actually the configuration is not reloaded during the runtime of the 'TwinCAT.Ads.TcpRouter.AmsTcpIpRouter' class. Please be aware that the "Backroute" from the Remote system linking to the local system (via AmsNetId) is necessary also to get functional routes.

Example for a valid 'appSettings.json' file (please change the Addresses for your network/systems.)

  "AmsRouter": {
    "Name": "MyLocalSystem",
    "NetId": "",
    "TcpPort": 48898,
    "RemoteConnections": [
        "Name": "RemoteSystem1",
        "Address": "RemoteSystem1",
        "NetId": "",
        "Type": "TCP_IP"
        "Name": "RemoteSystem2",
        "Address": "",
        "NetId": "",
        "Type": "TCP_IP"
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "System": "Information",
      "Microsoft": "Information"
    "Console": {
      "IncludeScopes": true

Alternatively a "StaticRoutes.Xml" Xml File can configure the system equally. Don't forget to add the 'StaticRoutesXmlConfigurationProvider' to the Host configuration during startup (see FirstSteps below).

An example of the local "StaticRoutes.xml" is given here:

<?xml version="1.0" encoding="utf-8"?>
<TcConfig xmlns:xsi="" xsi:noNamespaceSchemaLocation="C:\TwinCAT3\Config\TcConfig.xsd">

Alternatively, the configuration can also be set via Environment variables.

PS> $env:AmsRouter:Name = 'MyLocalSystem'
PS> $env:AmsRouter:NetId = ''
PS> $env:AmsRouter:TcpPort = 48898
PS> $env:AmsRouter:RemoteConnections:0:Name = 'RemoteSystem1'
PS> $env:AmsRouter:RemoteConnections:0:Address = 'RemoteSystem1'
PS> $env:AmsRouter:RemoteConnections:0:NetId = ''
PS> $env:AmsRouter:RemoteConnections:1:Name = 'RemoteSystem2'
PS> $env:AmsRouter:RemoteConnections:1:Address = ''
PS> $env:AmsRouter:RemoteConnections:1:NetId = ''
PS> $env:AmsRouter:Logging:LogLevel:Default = 'Information'
PS> dir env: | where Name -like AmsRouter* | format-table -AutoSize

Name                                  Value
----                                  -----
AmsRouter:Name                        MyLocalSystem
AmsRouter:TcpPort                     48898
AmsRouter:RemoteConnections:0:Name    RemoteSystem1
AmsRouter:RemoteConnections:0:Address RemoteSystem1
AmsRouter:RemoteConnections:1:Name    RemoteSystem2
AmsRouter:Logging:LogLevel:Default    Information

Configuration Parameters

Name Description
Name Name of the local System/Device
NetId The AmsNetId of the local System/device
TcpPort The TCP port used for external communication (communication to the routes/RemoteConnections)
LoopbackIP This is the IPAddress, that is used by the TcpRouter for its Loopback Connections (in combination with the LoopbackPort. By default this is set to IPAddress.Loopback ( and is only accessible from the local machine. If AdsClient/AdsServers should run seperated from the Router System, this LoopbackIP must be set to valid local IPAddress. Furthermore valid external addresses (where the AdsClients/AdsServer lives) must be specified via LoopbackExternalIPs or LoopbackExternalSubnet. Only those connections will be accepted
LoopbackPort Sets the TCP Port that is used for the loopback. The LoopbackPort defines the Loopback TcpEndpoints in combination with the LoopbackIP
LoopbackExternalIPs The Loopback externals are IPAddresses, that are allowed to use the Loopback connection. Use this IP list or specify alternatively the LoopbackExternalSubnet
LoopbackExternalSubnet Sets the loopback externals subnet. This is an alternative approach to set the allowed 'LoopbackIPs' for loopback communication. In docker/virtual enviroments often a whole subnet will be spanned
RemoteConnections Sets the list of remote Routes/Connections. This is the list of external devices which can be reached via the route.

Version Support lifecycle

Package Description .NET Framework TwinCAT Active Support
6.1 Package basing on .NET 7.0/6.0 net7.0, net6.0, netstandard2.0 >= 3.1.4024.10 [^1] X
6.0 Package basing on .NET 6.0 net6.0, netcoreapp3.1, netstandard2.0, net461 >= 3.1.4024.10 [^1] X
5.x Package basing on .NET 5.0[^3] net5.0, netcoreapp3.1, netstandard2.0, net461 >= 3.1.4024.10 [^1]
4.x Package basing on .NET Framework 4.0 net4 All X

[^1]: Requirement on the Host system. No version limitation in remote system communication.

[^2]: Microsoft support for .NET5 ends with May 8, 2022. Therefore it is recommended to update Beckhoff.TwinCAT packages from Version 5 to Version 6.

Migrate from ASP.NET Core 5.0 to 6.0

migrating to the latest .NET Microsoft .NET support lifecycle

First Steps

Example of starting the TcpIpRouter from a simple Console application with logging.

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace TwinCAT.Ads.AdsRouterService
    class Program
        public static void Main(string[] args)

        public static IHostBuilder CreateHostBuilder(string[] args) =>
                .ConfigureServices((hostContext, services) =>
                .ConfigureAppConfiguration((hostingContext, config) =>
                    // Uncomment to overwrite configuration
                    //config.Sources.Clear(); // Clear all default config sources 
                    //config.AddEnvironmentVariables("AmsRouter"); // Use Environment variables
                    //config.AddCommandLine(args); // Use Command Line
                    //config.AddJsonFile("appSettings.json"); // Use Appsettings
                    //config.AddStaticRoutesXmlConfiguration(); // Overriding settings with StaticRoutes.Xml 
                .ConfigureLogging(logging =>
                    // Uncomment to overwrite logging
                    // Microsoft.Extensions.Logging.Console Nuget package
                    // Namespace Microsoft.Extensions.Logging;
public class RouterWorker : BackgroundService
    private readonly ILogger<RouterWorker> _logger;

    public RouterWorker(ILogger<RouterWorker> logger)
        _logger = logger;

    protected override async Task ExecuteAsync(CancellationToken cancel)
        AmsTcpIpRouter router = new AmsTcpIpRouter(_logger);

        //Use this overload to instantiate a Router without support of StaticRoutes.xml and parametrize by code
        //AmsTcpIpRouter router = new AmsTcpIpRouter(new AmsNetId(""), AmsTcpIpRouter.DEFAULT_TCP_PORT, _logger);

        await router.StartAsync(cancel); // Start the router

Further documentation

The actual version of the documentation is available in the Beckhoff Infosys. Beckhoff Information System

Sample Code

Beckhoff GitHub RouterSamples

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Beckhoff.TwinCAT.Ads.TcpRouter:

Package Downloads

Mocking a TwinCAT Ads Server, for unit testing code with ADS read/write requests.

Beckhoff.TwinCAT.Ads.SystemServer The ID prefix of this package has been reserved for one of the owners of this package by

The Beckhoff.TwinCAT.Ads.SystemServer Package implements an TwinCAT System Service ADS Server (Port 10000) for usage in combination with the Beckhoff.TwinCAT.Ads.TcpRouter Package.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.1.86 92 9/21/2023
6.1.74 283 9/14/2023
6.0.302 39 9/21/2023
6.0.296 43 9/14/2023
6.0.286 518 9/4/2023
6.0.282 105 9/1/2023
6.0.249 10,538 3/10/2023