Skip to content

Implement support for the TCP protocol, based on async-io (STD-only) #319

@ivmarkov

Description

@ivmarkov

Support for TCP is actually half-way (or even a bit more?) there in that we already:

What needs to be done:

Add a tcp.rs implementation on top of async-io similar to the udp.rs one:

  • Support TCP accept and add the accepted TCP stream to a pool of streams, where each stream is keyed by its TCP address. Think what to do when we get two tcp streams with the same peer TCP address? Perhaps we should just close the earlier one, without sending any exchange Close Matter message, as likely, the other peer considers the older stream "stale" if it is opening a new one?
  • Support TCP connect and add the connected TCP stream to the pool of streams; necessary when a subscription needs to send data to a peer which does not have an opened TCP stream ATM; or in general for any outgoing message - if the peer to which the message is addressed does not have an opened TCP stream in the streams' pool, such one needs to be opened (with connect) on-the-fly;
  • Support eviction of closed/timing-out/stale TCP streams from the pool of streams. TCP stream closure can be detected when reading from the TCP stream (so that we get the FIN from the other peer). The TCP impl would therefore likely need to constantly poll the streams in the stream pool for readable and close those where it gets a FIN. This would naturally happen in its NetworkReceive::wait_available and NetworkReceive::recv_from impls, but we also need user-configurable timeouts for NetworkReceive::recv_from and NetworkReceive::send_to
  • We might need to also time-out streams where we have not received anything for a very long time (long timeout). Need to check if/how the C++ SDK does this. Also good to check the TCP impl of the C++ SDK anyway
  • Think whether a TCP stream need to be eagerly closed when an exchange on that stream is over. Check how the C++ SDK does it. It is likely not doing an eager close and is re-using the streams across exchanges and for multiple exchanges with the same peer, as the Matter Core Spec seems to hint at using TCP keep alive ACKs for "long living" TCP streams
  • Advertise TCP support via mDNS

I would say, a relatively easy and straight-forward task.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions