HDS02.2-W040N-HS79-01-FW机器人卡件
当您发出COMMREQ以建立读或写通道时,将创建TCP连接,进行传输,然后在完成所有传输后,终止TCP连接。创建和终止这些连接需要时间。如果一个应用程序被构造成只需一次重复(一次传输)即可快速重复地建立信道,那么以太网接口的可用TCP连接可能会被完全消耗。TCP连接状态的“快照”将显示其中一些正在创建,一些正在终止,一些处于活动状态,但没有可用状态。注意:在某些情况下,TCP连接可以是IP地址)。在这种情况下,最好与目标设备建立一次信道,使其保持活动状态,然后重新分配信道任务,即使数据传输很少发生。此方法将仅使用一个TCP连接。重新分配任务的另一个优点是,每次需要数据传输时,都不会产生创建信道及其相关TCP连接所需的时间和网络流量。重新分配任务的缺点是:▪ 当TCP连接打开时,其他应用程序无法使用该连接,并且▪ 活动TCP连接会占用网络带宽,因为活动TCP连接生成少量持续的周期性网络流量。8.4.4.1如何重新分配通道1。对于建立读/写通道命令,将重复次数(COMMREQ字9)设置为2,并将读/写周期(COMMREQ字10和11)设置为长于传输之间的预期时间。例如,如果您希望使用PACSystems™ RX3i和RSTi EP TCP/IP以太网通信用户手册第8节GFK-2224Y 2019年8月编程SRTP信道命令169大约每分钟传输一次数据,将读/写周期设置为大约两分钟。这将导致TCP连接被创建并保持打开两分钟。2.将梯形图程序设置为:a.发出第一个COMMREQ,并等待第一次传输完成,当COMMREQ状态(CRS)字更改为1时,将显示第一次传输。b、 然后,在读/写周期到期之前(此时发送第二次和最后一次传输并断开TCP连接),使用步骤1中指定的相同参数发出下一个COMMREQ。这将“重新设置”通道以使用现有的TCP连接,而不是打开新的连接,并将发送另一个数据传输,重新启动读/写期间的计时器。对所需的每个连续数据传输重复步骤2b。8.4.5客户端通道TCP资源管理在连接关闭后,OS网络堆栈会在一段时间内挂起与连接相关的TCP资源。它适用于关闭的发起者,这几乎总是客户端。这段时间被称为“TCP延迟期”。一旦TCP延迟期到期(在当前操作系统实现中为60秒),TCP资源将被释放。使用客户端通道的应用程序开发人员在设计其逻辑时需要意识到这种行为。分配给客户端信道的TCP资源数量有限,则应用程序可能必须等待直到TCP资源释放,以便建立另一个客户端信道(如果当前没有可用的TCP资源,则返回0xA890的COMMREQ状态;应用程序应等待并重试)。SRTP客户端通道提供了帮助用户保留TCP连接的功能。其中包括一段时间,在这段时间内,人们可以建立SRTP信道,并指定信道以给定的间隔运行,或以尽可能快的速度运行。还可以指定迭代次数,或永远运行。此外,SRTP信道允许将活动信道重新分配给同一远程设备,其中可以更改活动信道的参数,例如更改信道命令类型(读/写)、重复次数、时间段、本地存储器地址、远程存储器地址等。SRTP信道还允许将活动信道重新分配给不同的远程设备(更改远程设备的IP地址等)。然而,将任务重新分配给其他远程设备既不会保留TCP连接,也不会节省创建信道所需的时间。8.4.6 SRTP应用程序超时SRTP信道内的应用程序超时还包括建立和维护底层网络和SRTP连接所需的时间。例如,为新信道建立TCP连接、与远程设备建立通信以及信道操作期间的TCP重传。如果TCP连接建立或维护所需的时间超过用户指定的通道应用程序超时值,则会发生应用程序超时。通道应用程序超时是临时错误;当预期的分辨率
When you issue a COMMREQ to establish a read or write channel, a TCP connection is created, the transfer(s) are made, then upon completion of all the transfers, the TCP connection is terminated. It takes time to create and to terminate these connections. If an application is constructed so that it rapidly and repeatedly establishes a channel with only one repetition (one transfer), the available TCP connections for the Ethernet interface may be totally consumed. A “snapshot” of the state of the TCP connections would show some of them being created, some being terminated, and some active, but none available. CAUTION In Certain Conditions TCP Connections Can Be IP address). In this case, it is better to establish a channel with the target device once, leave it active, then re-task the channel, even if data transfers take place infrequently. This method will use only one TCP connection. An additional advantage of re-tasking is that the time and network traffic required to create a channel and its associated TCP connection are not incurred each time a data transfer is required. The disadvantages to re-tasking are: ▪ While the TCP connection is open, it is unavailable to the rest of your application, and ▪ The active TCP connection uses up network bandwidth because the active TCP connection generates a small amount of ongoing periodic network traffic. 8.4.4.1 How to Re-Task a Channel 1. For Establish Read/Write Channel Commands, set the number of repetitions (COMMREQ Word 9) to 2 and set the read/write period (COMMREQ Words 10 and 11) to be longer than the expected time between transfers. For example, if you expect to PACSystems™ RX3i and RSTi-EP TCP/IP Ethernet Communications User Manual Section 8 GFK-2224Y August 2019 Programming SRTP Channel Commands 169 transfer data about once per minute, set the read/write period to about two minutes. This will cause a TCP connection to be created and held open for two minutes. 2. Set up the ladder program to: a. Issue the first COMMREQ and wait for the first transfer to complete, which will be indicated when the COMMREQ Status (CRS) word is changed to 1. b. Then before the read/write period expires (at which time the second and final transfer is sent and the TCP connection is dropped), issue the next COMMREQ with the same parameters as specified in step 1. This will “retask” the channel to use the existing TCP connection instead of opening a new one, and will send another data transfer restarting the timer for the read/write period. Repeat step 2b for each successive data transfer desired. 8.4.5 Client Channels TCP Resource Management There is a period of time that the OS Network stack hangs on to the TCP resources associated with a connection after it is closed. It applies to the initiator of the close, which is almost always the client side. This time is referred to as the “TCP Linger Period”. Once the TCP Linger Period expires (60 seconds in the current OS implementation), the TCP resources are released. Application developers using client channels need to be aware of this behavior when designing their logic. There are a finite number of TCP resources allocated to client channels, and if channel connections are brought up and down so fast that these resources are depleted, then the application may have to wait until a TCP resource frees up in order to establish another client channel (a COMMREQ Status of 0xA890 is returned if no TCP resources are currently available; application should wait and retry again). SRTP Client Channels provides features that help the user preserve TCP connections. These include a period time where one can establish an SRTP Channel and specify the channel to run at a given interval, or run as fast as possible. One can also specify a number of iterations, or run forever. Additionally, SRTP Channels allows channel re-tasking of an active channel to the same remote device, where the parameters of an active channel, such as changing the channel command type (Read/Write), number of repetitions, time periods, local memory address, remote memory address, etc. can be changed. SRTP Channels also allows channel re-tasking of an active channel to a different remote device (changing the remote device’s IP address, etc.). However, re-tasking to a different remote device will neither conserve TCP connections, nor save on the time it takes to create a channel. 8.4.6 SRTP Application Timeouts The application timeouts within SRTP Channels also include the time needed to establish and maintain the underlying network and SRTP connection. Examples are establishing the TCP connection for a new channel, establishing communication with the remote device, and TCP retransmissions during Channel operations. If the time needed for TCP connection establishment or maintenance exceeds the user-specified channel application timeout values, an application timeout will occur. Channel application timeouts are temporary errors; the channel continues to run when the expected response is received. If the application is seeing timeouts during channel startup, there are a few different options: PACSystems™ RX3i and RSTi-EP TCP/IP Ethernet Communications User Manual Section 8 GFK-2224Y August 2019 Programming SRTP Channel Commands 170 1. Increase timeout value to account for Channel connection overhead 2. Ignore the timeout error on the first transfer 3. Use a two-step setup approach where the first COMMREQ has a timeout large enough to account for the connection overhead and then Re-Task the channel to the normal operating timeouts. 8.5 Monitoring Channel Status The COMMREQ Status word is returned from the Ethernet interface to the PLC CPU immediately if the Command Block contains a syntax error or if the command is local. For remote commands with no syntax error, it is returned either after the channel is established successfully and the first transfer has completed or if there is an error establishing the channel. The location of the has been sent to the Ethernet interface, but no status has been returned. If this condition persists, check the PLC Fault Table for information. If the COMMREQ status word is updated to 1, the Command Block was processed successfully by the Ethernet interface. If the COMMREQ