-
Notifications
You must be signed in to change notification settings - Fork 12
Session Layer
The session layer should support configurable message delivery guarantees and asymmetrical delivery requirements for each direction. Supported delivery guarantees should include these flows:
- Idempotent: guarantee at-most-once delivery
- Recoverable: guarantee exactly-once message delivery
- Unsequenced: best-effort delivery supported by the underlying transport
- None: no application messages flow in one direction of a session
The session layer should take advantage of the services of lower level protocols and avoid duplication of effort with regard to:
- In-sequence packet delivery and flow control (TCP)
- Message framing (WebSocket)
- Authentication and encryption (TLS)
Since WebSocket establishes a connection through a HTTP request or HTTPS handshake, familiar network management policies apply.
The WebSocket protocol is an IETF standard.
WebSocket frames messages over a TCP stream. There are two kinds of data frames, text and binary. Conga uses either binary or text frames, depending on the message encoding selected.
The emerging FIXP standard supports the above listed delivery guarantees. Therefore, it is the plan for project Conga to adapt FIXP to a WebSocket transport. As with other protocols, we seek to avoid duplication of effort between layers.
In the Conga implementation, two encodings are supported for session messages:
- Simple Binary Encoding (SBE), a high performance FIX standard for presentation layer. SBE messages are sent in binary frames.
- JSON messages are sent in text frames.
Naturally, to interoperate, both client and server must use the same encoding.
FIXP uses its Sequence message as a heartbeat while WebSocket has Ping/Pong frames. Ping frames are emitted automatically by WebSocket implementations, and Pong responses are automatically generated. Unfortunately, Ping/Pong seems unsuitable as a substitute for FIXP Sequence behavior. For one thing, FIXP heartbeat intervals are configurable and may be asymmetrical between client and server while Ping intervals are not specified by the WebSocket protocol and are not generally configurable. Second, the payload of Ping is not settable by users while FIXP Sequence message conveys the sequence number of the next application message, supporting rapid detection of message gaps. In sum, although the keep-alive behaviors are somewhat overlapping, the FIXP Sequence message is used in this implementation as intended.
The FIXP Terminate message and WebSocket Close frame have practically the same behavior. In both cases, either side can initiate closing of a transport session and the other side responds with the same message type. Therefore, only the WebSocket Close frame is needed to unbind the transport from a logical session.
- Encode session messages in another protocol if there is demand for it. Therefore, message encodings should be abstracted as much as possible in the software design. Encodings are implemented with a plug-in architecture.