参考文献:
1. 官方CA协议说明 https://epics.anl.gov/base/R3-16/1-docs/CAproto/index.html#_commands_tcp_and_udp(本翻译的原文)
以下命令作为UDP数据报或TCP消息发送。 一些消息也在虚拟电路(TCP连接)的上下文中使用。
CA_PROTO_VERSION
Command |
|
ID | 0 ( |
Description | 转换客户端和服务器协议版本以及所需的电路优先级。 必须是客户端和服务器在建立新TCP(虚电路)连接时发送的第一条消息。 它也作为UDP搜索消息中的第一条消息发送。 |
请求
表1. CA_PROTO_VERSION请求的头部
Field | Value | Description |
---|---|---|
Command | 0 |
|
Payload size(负载大小) | 0 | 必须是0 |
Priority | 期望的优先级数字 | 虚拟电路的优先级 |
Version | 版本号 | 次版本号,仅在TCP发送时使用 |
Reserved | 0 | 必须是0 |
Reserved | 0 | 必须是0 |
表2. CA_PROTO_VERSION请求的兼容性
Version | Comment |
---|---|
| 创建虚拟电路后,服务器会立即发送应答 |
| 消息不包括次版本号(始终为0),并且被解释为不携带数据的echo命令。 在 |
优先级表示服务器的调度优先级,可以通过抢占式调度OS中的电路专用线程的调度优先级来实现。
由于缓存错误,4.11版以下的CA协议中,RSRV在连接时没有立即发送CA_PROTO_VERSION,而是在一些其他响应触发缓冲区刷新时发送CA_PROTO_VERSION。
响应
表3. CA_PROTO_VERSION响应的头部
Field | Value | Description |
---|---|---|
Command | 0 |
|
Reserved(预留) | 0 | 必须为0 |
Priority(优先级) | 0 | 必须为0 |
Version | Version number | 次版本号。只有在TCP发送时使用 |
Reserved(预留) | 0 | 必须为0 |
Reserved(预留) | 0 | 必须为0 |
表4. CA_PROTO_VERSION响应的兼容性
Version | Comment |
---|---|
CA_V411(4.11版)及其更高版本 | 服务器不会响应请求,但会在虚拟电路建立后立即发送请求 |
低于CA_V411(4.11版)的版本 | 消息不包括此版本号(总是为0) |
CA_PROTO_SEARCH
Command |
|
ID | 6 ( |
Description | 搜索所给通道的名字。TCP或UDP发送时 |
请求
表5. CA_PROTO_SEARCH请求的头部
Field | Value | Description |
---|---|---|
Command | 6 |
|
Payload Size | >= 0 | 通道名称的填充大小 |
Reply | 响应标志位 | Search Reply Flag, 表明是否应该返回失败的搜索响应 |
Version | 版本号 | 客户端协议的次版本号 |
SearchID |
| 客户端分配搜索标识符 |
SearchID |
| 客户端分配搜索标识符 |
表6. CA_PROTO_SEARCH请求的有效负载
Name | Type | Value | Description |
---|---|---|---|
通道名称 |
|
| 搜索的通道名称 |
下面的内容就不翻译了,好理解的。
Comments
-
Sent as a UDP datagram.
-
It is illegal to specify
DO_REPLY
flag whenever the message is sending as UDP datagram, regardless of whether broadcast or multicast is used. -
SearchID will be allocated by the client before this message is sent.
-
SearchID field value is duplicated.
-
Reply flag will be generally
DONT_REPLY
when searching using broadcast andDO_REPLY
when searching using unicast. WhenDO_REPLY
is set, server will send aCA_PROTO_NOT_FOUND
message indicating it does not have the requested channel.
8.2.2. Response
Field | Value | Description |
---|---|---|
Command | 6 | Command identifier for |
Payload Size | 8 | Payload size is constant. |
Data Type | Port number | TCP Port number of server that responded. |
Data Count | 0 | Must be 0. |
SID or IP |
| Temporary SID (deprecated) or server IP address. |
SearchID |
| Client allocated Search identifer. |
Name | Type | Value | Description |
---|---|---|---|
Server protocol version |
|
| Server protocol version. |
Comments
-
Received as UDP datagram.
-
Search ID field value (CID) is copied from the request.
-
Before
CA_V411
the SID/IP field will always have the value of0xffffffff
and the server IP address is assumed to be the senders IP. -
Starting with
CA_V411
the server’s IP address is encoded in the SID/IP field if it differs from the sender’s IP, or0xffffffff
if it is the same. -
The port number included in the header is the TCP port of the server. Two servers on the same host can share a UDP port number, but not a TCP port number. Therefore, the port the client needs to connect to in that situation may not be the same as expected if this field in the response is not used.
8.3. CA_PROTO_NOT_FOUND
Command |
|
ID | 14 ( |
Description | Indicates that a channel with requested name does not exist. Sent in response to |
8.3.1. Response
Field | Value | Description |
---|---|---|
Command | 14 | Command identifier for |
Reserved | 0 | Must be 0. |
Reply Flag |
| Same reply flag as in request: always |
Version | Same as request | Client minor protocol version number. |
SearchID |
| Client allocated Search identifer. |
SearchID |
| Client allocated Search identifer. |
Comments
-
Contents of the header are identical to the request.
-
SearchID fields are diplicated.
-
Original request payload is not returned with the response.
8.4. CA_PROTO_ECHO
Command |
|
ID | 23 ( |
Description | Connection verify used by |
8.4.1. Request
Field | Value | Description |
---|---|---|
Command | 23 | Command identifier for |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |
8.4.2. Response
Field | Value | Description |
---|---|---|
Command | 23 | Command identifier for |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |
Reserved | 0 | Must be 0. |