This repository was archived by the owner on Feb 8, 2021. It is now read-only.
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
stream protocol between runv and hyperstart #182
Open
Description
Current streams are multiplexed and sent/received via the serial port (named: "sh.hyper.channel.1")
And the format for multiplexing is:
/*
* stream message format
* | stream sequence | length | payload (length-12) |
* | . . . . . . . . | . . . . | . . . . . . . . . . . . |
* 0 8 12 length
*/
#define STREAM_HEADER_SIZE 12
#define STREAM_HEADER_LENGTH_OFFSET 8
Both stream sequence and length are encoding in bigendian.
And length=0 indicates the command of close the stream (only one direction)
(and there is an additional ugly data is sent from hyperstart to runv for the exitcode,
this part of the protocol will be removed soon(scheduled after the big refactor(hyperhq/runv#295)))
The major problem is that payload will be discarded in hyperstart if the buffer if full,
and stream service is blocked in runv if the buffer if full.
We need change the protocol after the big refactor(hyperhq/runv#295) as:
- we assume serial port doesn't discard any data, and data is received as the same order as it was sent.
- length(decoded) doesn't include the length of the header
- the length of the payload must less than (1 << 30) (the practical length < 4096)
- when A received length(decoded) == 0x80000000 | num. ACK-COMMAND: it means the opposite(B) side had just received and consumed
num
bytes of data(ack for the earlier message). A should record how much the data that B had received. A shouldn't send any more data to B util A get ALL the ack. - when A received length(decoded) == 0xC0000000. CLOSE-COMMAND: the B side close the stream, it meems the upstream fd in B is closed, the B will not send any message with payload, A should close the corresponding downstream fd if needed.
- when A received length(decoded) == 0xC0000001. REQUEST-COMMAND: the B side request data, A should send data to B from the first unacked data. (B had discarded the unacked payload).
Metadata
Metadata
Assignees
Labels
No labels