Skip to content

Networking control protocol#6

Draft
GregoryLi360 wants to merge 16 commits into
mainfrom
majdnasra2/comm-protocol
Draft

Networking control protocol#6
GregoryLi360 wants to merge 16 commits into
mainfrom
majdnasra2/comm-protocol

Conversation

@GregoryLi360
Copy link
Copy Markdown
Contributor

@GregoryLi360 GregoryLi360 commented May 28, 2026

Control and data pipe protocol between Arca and the Linux monitor.

Control protocol (spec in PROTOCOL.md):

  • Wire format: 7-byte header (message_type, payload_len, request_id) plus fixed-layout payload.
  • Message types: ListenRequest/Ok/Err, ConnectRequest/Ok/Err, AcceptRequest, IncomingConnection, AcceptErr.
  • Arca side: ArcaSession::bind / connect / accept mirror std::net.
  • Linux side: Monitor::pump_once / serve_one / poll_accepts / event_loop drive the kernel sockets.
  • One static control pipe; per-connection data pipes allocated on demand from BuddyAllocator.
  • DataPipeInfo.shm_offset (u64) carries the BuddyAllocator byte offset; both sides call from_offset(shm_offset) to reconstruct their local pointer to the same physical memory.
  • Monitor allocates each pipe's SHM with Box::new_zeroed_slice_in(BuddyAllocator); freed automatically when the pipe fully closes.
  • event_loop drives control-frame dispatch and tcp↔pipe byte relay in one loop; half-close propagates in both directions between TCP and the shared-memory rings.

Pipe and data-pipe (spec in DATAPIPE.md):

  • RingHeader adds writer_closed / reader_closed atomic flags in shared memory.
  • BidirectionalPipe exposes close_write/read(), is_peer_write/read_closed(), is_closed().
  • Write trait adds write_all() default (spins on WouldBlock until all bytes are written).
  • SyncStream / AsyncStream rewritten to raw byte stream; send / recv use the close flags for EOF and error detection; dataframe framing removed.
  • SyncStream / AsyncStream carry shm_offset (u64) — the BuddyAllocator offset of the backing region.

See PROTOCOL.md and DATAPIPE.md for the full specs.

@ruiting-chen ruiting-chen force-pushed the majdnasra2/comm-protocol branch from d762d8e to 8e4e10f Compare May 29, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants