Skip to content

S7 routing support for multi-subnet PLC access #615

@gijzelaerr

Description

@gijzelaerr

Summary

Implement S7 routing support to reach PLCs behind gateways across multiple subnets.

Background

In complex industrial networks, PLCs are often segmented into different subnets connected through S7 routing-capable devices (S7-300/400 CPs, S7-1500 with routing enabled). S7 routing allows a client to reach a PLC on a remote subnet by specifying a routing path through intermediate devices.

What needs to be done

  • Implement routing TSAP construction (encoding subnet ID and rack/slot of the target)
  • Implement extended connection setup with routing information in the COTP CR (Connection Request)
  • Support multi-hop routing (routing through multiple gateways)
  • Add routing parameters to connect() or add a connect_routed() method
  • Handle routing-specific error codes and connection failures
  • Add server-side routing support (optional, for testing)
  • Add tests with routing scenarios
  • Add documentation and examples

API Design Considerations

# Option A: Extended connect
client.connect("192.168.1.1", 0, 2, routing={"subnet": 0x0001, "dest_rack": 0, "dest_slot": 1})

# Option B: Dedicated method
client.connect_routed("192.168.1.1", router_rack=0, router_slot=2,
                      subnet=0x0001, dest_rack=0, dest_slot=1, dest_tsap=0x0102)

References

  • Siemens documentation on S7 routing configuration
  • COTP CR routing parameter encoding in existing snap7 C library

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions