This example design is an over simplification of a TCP server's FSM, where communication is always initiated by the client and never by the server. The intention of this P4 file is to showcase stateful packet processing with the use of the register extern, tables and other p4 elements.
See RFC9293 for more information about the TCP protocol.
The TCP FSM example design uses a table (clientDB) to store the IP and MAC address of registered clients, which can be added via the control plane. The server only replies to registered clients and only to packets used to establish and/or close the connection. The server is set up to drop incoming invalid packets or packets from any unregistered clients. When a connection is established, the server is set up to only forward incoming packet payload to metadata (CONFIG.OUTPUT_METADATA_FOR_DROPPED_PKTS must be 'true').
This example instantiates a register extern (sockReg), to store connection information about registered clients, such as connection timestamp, connection state and sent packets count.