Configuring S7-315-2DP with CP343-1 IT for TCP/IP Communication

David Krause14 min read
S7-300SiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

The SIMATIC S7-315-2DP (CPU 315-2 DP) is a mid-range S7-300 controller frequently deployed in factory automation cells where it must exchange data with a supervisory PC over Ethernet. Because the CPU 315-2 DP itself does not contain a PROFINET/Ethernet interface on every variant, the typical approach is to add a CP 343-1 IT communications processor that exposes an industrial Ethernet port supporting raw TCP/IP, ISO-on-TCP (RFC 1006), UDP, and S7 communication. This article documents the engineering steps required to establish a TCP/IP socket-based data exchange between a CP 343-1 IT and a PC application written in a generic programming language (C/C++, C#, Python, VB, Delphi, etc.) using a classic client-server model and an ASCII message protocol.

The configuration is suitable when:

  • Data is to be exchanged without the overhead of the full S7 protocol stack on the PC side.
  • The PC software has been developed by a third party and speaks ASCII over a TCP socket.
  • Bidirectional or one-way (PC->PLC, PLC->PC, or both) data exchange is required.
  • No S7-Put/Get licensing or PC station with SIMATIC NET is desired on the PC.
Scope note: This article covers raw TCP/IP socket communication only, not S7 communication (PUT/GET) or OPC. If the PC application must read S7 data areas without custom socket code, refer to the S7 communication path or the OPC UA path on the same CP.

Hardware Identification

Verify the order numbers and firmware revisions of the components involved before commissioning. The CP firmware is critical because AG_SEND/AG_RECV behavior and supported connection types changed between early (V1.x) and modern (V3.x) firmware releases.

Component Reference
Component MLFB / Order Number Function Notes
CPU 315-2 DP 6ES7315-2AF03-0AB0 (or 6ES7315-2AH14-0AB0) S7-300 central processor with PROFIBUS DP master/slave interface 2nd interface is PROFIBUS, not Ethernet; CP is required for Ethernet
CP 343-1 IT 6GK7343-1GX11-0XE0 (or later 6GK7343-1GX30-0XE0) Industrial Ethernet CP, ISO/TCP/UDP/S7 1 x RJ45 10/100 Mbit; supports connection types ISO, ISO-on-TCP (RFC1006), TCP, UDP, S7
Backplane / Rack 6ES7390-1xxx0-0AA0 S7-300 mounting rail CP slot 4-11 is permitted
PS 307 power supply 6ES7307-1xAxx-0AA0 24 V DC system power Sized for CPU + CP + I/O load

CP 343-1 IT Communication Services

The CP 343-1 IT supports the following transport-layer services, configurable per connection:

  • ISO Transport (ISO 8073) – Native ISO connection; restricted to Siemens-side endpoints.
  • ISO-on-TCP (RFC 1006) – TCP with a TPDU header; widely used for Siemens-to-Siemens or Siemens-to-PC.
  • TCP (RFC 793) – Standard TCP stream; ideal for generic socket programs on the PC.
  • UDP (RFC 768) – Connectionless datagrams; used for short, periodic broadcasts.
  • S7 Communication – For OPC/SIMATIC NET/PC station PUT/GET via FB14/FB15.

For the use case described in the source (generic PC socket program, ASCII payload), select TCP.

Prerequisites

  1. STEP 7 (SIMATIC Manager) V5.5 + SPx or TIA Portal V13+ with S7-300 support package.
  2. S7-300 CP 343-1 IT HSP or GSD hardware support installed for STEP 7, so the CP appears in the hardware catalog.
  3. CP 343-1 IT firmware compatible with the configured STEP 7 version (e.g., V2.0 or higher for TCP active/passive partner types).
  4. Ethernet cable – Cat 5e or higher, RJ45, crossover only required when connecting two DTE devices without a switch (modern CP and PC NICs are Auto-MDI/MDIX compatible).
  5. PC network interface with a static IPv4 address reserved in the same subnet as the CP (e.g., PLC 192.168.0.10, PC 192.168.0.20, mask 255.255.255.0).
  6. Knowledge of the PC application's listening port (server) or destination port (client), and whether the PC acts as server or client.

Network Architecture

S7-300 Station CPU 315-2DP CP 343-1 IT STEP 7 program: AG_SEND (FC50) / AG_RECV (FC60) Industrial Ethernet (TCP/IP) PC Station NIC 192.168.0.20 3rd-party socket app (Client or Server) ASCII protocol

For a typical S7-300 with CP 343-1 IT, only the CP needs an IP configuration; the CPU's PROFIBUS interface is not involved. The CP forwards the data via the backplane (K-bus / MPI backplane) to the CPU program buffers, which AG_SEND/AG_RECV then process.

STEP 7 / NetPro Configuration

Open the SIMATIC Manager project containing the S7-300 station. The communication relation is configured in NetPro (Options → Configure Network), not in HW Config.

Step 1 – Set the CP IP Address

  1. Open HW Config and double-click the CP 343-1 IT slot.
  2. Click Properties on the Ethernet interface.
  3. Assign a static IPv4 address (e.g., 192.168.0.10), subnet mask (255.255.255.0), and router (if needed).
  4. Confirm and save/compile the hardware configuration (Station → Save and Compile).

Step 2 – Create an Unspecified Connection in NetPro

  1. Open NetPro and select the CP 343-1 IT in the S7-300 station.
  2. Right-click and choose Insert New Connection.
  3. In the partner dialog select Unspecified (not an S7 station). This tells NetPro that the partner is a third-party device speaking TCP.
  4. For connection type choose TCP connection.
  5. On the Address tab set the partner IP address to the PC's IP (e.g., 192.168.0.20).
  6. Set the local and remote port (e.g., local 2000, remote 2001 or any agreed value used by the PC program).

Step 3 – Active vs. Passive Connection Establishment

The CP can either actively open the socket to the PC or passively wait for the PC to open the socket. This choice determines which side initiates the TCP 3-way handshake:

Establishment Modes
Mode Initiator Listener When to use
Active connection CP 343-1 IT PC (server) PLC powers up first, polls PC for data, or is the only side that knows the network is up
Passive connection PC (client) CP 343-1 IT (server) PC application is launched by operators and connects on demand; PC wants to control the lifecycle
Server-first rule: Whichever side is the TCP server (passive) must be started and listening before the active side opens the connection. If the PC is the server, launch the PC application first; if the CP is the server, the CPU/CP must already be in RUN with the AG_RECV block active.

Step 4 – Connection ID

After saving, NetPro assigns a unique Connection ID (often the value that appears in the Connection Overview). Note this ID; it is the ID input to AG_SEND and AG_RECV in the PLC program. Typical IDs for a single TCP connection to a PC are values in the range 1 to 16 depending on CP type and configuration.

PLC Program – AG_SEND and AG_RECV

Siemens supplies two standard library blocks for sending and receiving data over any configured CP connection. They are found in the STEP 7 Standard Library under Communication Blocks – specifically FC50 AG_SEND and FC60 AG_RECV (later firmware may use FC5/FC6, but the interface is functionally equivalent on the S7-300 family).

AG_SEND (FC50) Interface

AG_SEND (FC50) Parameters
Input Type Description
ACT BOOL Edge-triggered; rising edge initiates send
ID INT / WORD Connection ID from NetPro
LADDR INT / WORD Logical base address of the CP (from HW Config)
SEND ANY Pointer to send data area, e.g., P#DB100.DBX0.0 BYTE 100
LEN INT Length in bytes of payload to send (1..240 for most CP 343-1 IT versions)
DONE BOOL 1 = send completed without error (one cycle)
ERROR BOOL 1 = error occurred during send
STATUS WORD Status / error code (see table below)

AG_RECV (FC60) Interface

AG_RECV (FC60) Parameters
Input Type Description
ID INT / WORD Connection ID from NetPro
LADDR INT / WORD Logical base address of the CP
RECV ANY Pointer to receive buffer, e.g., P#DB200.DBX0.0 BYTE 240
NDR BOOL 1 = new data received (one cycle)
ERROR BOOL 1 = error occurred during receive
STATUS WORD Status / error code
LEN INT Length of received data in bytes

Example – STL Snippet

The following is a minimal S7-STL structure (run in OB1 or a cyclic OB) to send a 32-byte ASCII payload from DB100 and receive up to 240 bytes into DB200.

// ---- Send trigger: every cycle send a request to PC ----
CALL  FC    50                       // AG_SEND
       ACT   :=TRUE
       ID    :=1                     // Connection ID from NetPro
       LADDR :=W#16#100              // Logical base address of CP
       SEND  :=P#DB100.DBX0.0 BYTE 32
       LEN   :=32
       DONE  :=M10.0
       ERROR :=M10.1
       STATUS:=MW12

// ---- Receive from PC continuously ----
CALL  FC    60                       // AG_RECV
       ID    :=1
       LADDR :=W#16#100
       RECV  :=P#DB200.DBX0.0 BYTE 240
       NDR   :=M20.0                 // New-data-received (pulse)
       ERROR :=M20.1
       STATUS:=MW22
       LEN   :=MW24                  // Actual byte count received

AG_RECV must be called once per scan in the same priority class as AG_SEND. If the receive job is not refreshed, the CP will not accept subsequent incoming frames and may report STATUS = 80A1 after the first receive.

PC-Side Socket Programming

Because the CP exposes a standard TCP socket, the PC side can use any socket library (Winsock, BSD sockets, .NET System.Net.Sockets, Python socket module, etc.). The PC program must be aware of two things:

1. Client / Server Role

Exactly one side is the TCP server (passive) and the other is the client (active). The active side issues connect(); the passive side issues listen() and accept(). This maps directly to the STEP 7 Active / Passive setting.

2. ASCII Telegram Framing

TCP is a byte stream, not a message protocol. With raw TCP the PC and PLC must agree on a framing convention so the receiver knows where one telegram ends and the next begins. Common schemes:

  • Fixed length – both sides always send/receive exactly N bytes. Simplest, wastes bandwidth on short messages.
  • Length prefix – sender prefixes 2 or 4 bytes giving the message body length; receiver reads the length first, then the body.
  • Delimiter – e.g., \r\n, STX/ETX (0x02/0x03), or a specific ASCII terminator. The AG_SEND/AG_RECV buffer does not strip delimiters, so delimiter processing must be done in the PLC user program.

3. AG_SEND/AG_RECV Length Limits

The user payload per AG_SEND call on CP 343-1 IT is limited by the CP firmware. Typical values:

Maximum AG_SEND Payload
CP Firmware Max bytes per send call
V1.x 240 bytes
V2.x / V3.x 240 bytes (default), extendable to 8192 with AG_LSEND/AG_LRECV (FC50/FC60 length-extended variants)

For data above 240 bytes, split into multiple AG_SEND calls and reassemble in the PC application, or use the length-extended variants documented in the SIMATIC NET programming manual.

Connection Establishment Lifecycle

CP 343-1 IT PC Application LISTEN (Passive) SYN → ← SYN,ACK ACK → CONNECTED (AG_SEND/AG_RECV ready) DATA (ASCII) →

Once the TCP handshake completes, both sides may transmit. AG_SEND/AG_RECV operate independently of each other – a failed receive does not block a subsequent send, and vice versa. The CP buffers a limited number of outstanding telegrams internally; if the PC does not read (or the PLC does not issue AG_RECV) fast enough, the buffer fills and STATUS indicates back-pressure.

Verification and Diagnostics

  1. Online diagnostics in STEP 7: Right-click the CP in NetPro → Object Properties → Diagnostics. The connection state should read Established within a few seconds of both sides running.
  2. CP LED indicators on the CP 343-1 IT: SF (red, group fault), BF (red, bus fault on the Ethernet segment), LINK (green, link up), RX/TX (yellow, traffic). The SF LED must be off; the LINK LED must be lit.
  3. Wireshark / tcpdump on the PC: capture the Ethernet port and filter by tcp.port == 2000. You should see the SYN/SYN-ACK/ACK handshake followed by data segments containing the ASCII payload.
  4. Status words in the PLC: monitor the STATUS output of AG_SEND and AG_RECV. A value of 0000 on DONE/NDR is a healthy cycle.
  5. Ping test: from the PC command line, ping 192.168.0.10. A reply confirms IP-layer connectivity; if ping fails, the issue is IP/subnet, not the application layer.

Troubleshooting Matrix

Common AG_SEND/AG_RECV Status Codes (CP 343-1 IT)
STATUS (hex) Block Meaning Likely Cause / Fix
0000 Both Job completed, no error Normal idle state on AG_RECV; success on AG_SEND/DONE pulse
7000 AG_SEND No job active (ACT = 0) Trigger condition not met; verify ACT logic
7001 AG_SEND First call with ACT = 1, job starting Wait for completion on subsequent scan
7002 AG_SEND Job in progress Continue calling FC50 until DONE/ERROR
80A1 AG_RECV Negative acknowledgement from CP; receive job not active AG_RECV not called every scan, or LADDR wrong
80A7 Both Connection aborted by partner (TCP RST/FIN) PC closed the socket; check PC-side exception handling and re-establish
80B1 Both Specified length/area violation ANY pointer length exceeds the data block; reduce LEN or grow the DB
80C3 Both Resource bottleneck on CP Reduce call frequency; check CP CPU load diagnostics
80D0 AG_SEND Connection not yet established Server (passive) side is not yet listening – start it before the active side opens the connection
8186 AG_RECV Wrong ID or LADDR Confirm the Connection ID matches NetPro and LADDR is the CP base address (not slot 0)
80A1 / 80A7 on startup Both PC app started after the CP, or vice versa Enforce the server-first rule: the passive side must be up first

Symptom-Driven Checks

Symptom → Likely Cause
Symptom Likely cause
BF LED on, no ping Cable/port/speed mismatch or wrong IP on PC
Ping OK, no TCP SYN in Wireshark AG_SEND never triggered (ACT edge missing) or wrong LADDR
SYN visible, no SYN-ACK from CP CP is set as passive and the active side is the CP – swap roles in NetPro or on PC
Connection established, PC receives garbage ASCII/binary framing mismatch or wrong byte order; confirm with Wireshark raw bytes
DONE pulses but PC sees no data PC is connecting to a different local port or firewall is blocking the inbound
Periodic disconnects (STATUS 80A7) PC application unhandled exception, socket close on timeout, or keep-alive mismatch

Field-Proven Notes

  • Compile HW Config before NetPro. NetPro cannot resolve the CP's logical base address until the hardware has been compiled and downloaded at least once. Trying to insert a connection with a yellow warning icon usually indicates an uncompiled HW Config.
  • Keep AG_RECV alive. If your user program conditionally calls AG_RECV (e.g., only inside a state), the CP will treat the connection as broken after the first received telegram and any further data is dropped. The recommended pattern is to call AG_RECV unconditionally in OB1, and use the NDR pulse in your application logic to latch the received data.
  • Watch the CPU cycle time. AG_SEND/AG_RECV each take measurable time and add to OB1 load. With payloads of 240 bytes on a 315-2DP, expect 5–15 ms of added scan time per call. If the cycle budget is tight, move the calls to OB35 (cyclic interrupt) at 100 ms.
  • Avoid TIA Portal dual-stack projects. Mixing S7-300 and S7-1500 in one project is fine, but do not place the S7-300 CP under a S7-1500 IO controller – the GSD rules differ. Configure the S7-300 in its own station object.
  • Use a dedicated switch with port mirroring for first-time commissioning so that you can attach a Wireshark tap without disrupting the live link.
Cybersecurity: Raw TCP with no authentication is suitable only for closed or segmented networks. On plant-floor networks, place the S7-300 station behind a firewall or use a CP variant with integrated security (CP 343-1 Advanced/CP 1543-1 successor products) and route through a SCALANCE S / SCALANCE SC pair.

Frequently Asked Questions

Can the S7-315-2DP communicate with a PC over Ethernet using the CP 343-1 IT and a generic TCP socket?

Yes. The CP 343-1 IT exposes an industrial Ethernet port that supports raw TCP (RFC 793). Configure an Unspecified TCP connection in NetPro pointing to the PC's IP address, then use AG_SEND (FC50) and AG_RECV (FC60) in the PLC program to exchange up to 240 bytes per call. The PC uses a standard socket (Winsock, .NET, Python, etc.) as the TCP peer.

What is the maximum payload per AG_SEND call on the CP 343-1 IT?

240 bytes per call on standard CP firmware. For larger telegrams, split the data across multiple AG_SEND invocations and reassemble on the PC, or use the length-extended variants AG_LSEND/AG_LRECV where the CP firmware supports them (typically 8192 bytes).

How do I choose between Active and Passive connection establishment?

Pick the side that will be started and ready first as the passive (server) side. If the PC application is launched by an operator and only runs on demand, set the CP as active and the PC as server. If the PLC is always up but the PC starts intermittently, set the CP as passive and the PC as client. The server must always be listening before the client issues connect().

Why does AG_RECV report STATUS 80A1 right after the first successful receive?

STATUS 80A1 means the CP has no active receive job. The block must be called every scan (or at least continuously) so that after each NDR pulse the CP can post a new receive job. Move the AG_RECV call to OB1 unconditionally, or to a faster cyclic OB if the scan time is too long.

Can I use ISO-on-TCP (RFC 1006) instead of plain TCP?

Yes, and many PC libraries (libnodave, Snap7, .NET wrappers) prefer ISO-on-TCP because it carries a TPDU length header that simplifies framing. Select ISO-on-TCP connection in NetPro and update the PC application to expect the 4-byte TPDU header at the start of each message. The STEP 7 program side is identical (AG_SEND/AG_RECV), but STATUS codes map 1:1 to the same library.

Back to blog