|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file. 1 #ifndef SPONGE_LIBSPONGE_TCP_FACTORED_HH
2 #define SPONGE_LIBSPONGE_TCP_FACTORED_HH
69 void tick(
const size_t ms_since_last_tick);
99 #endif // SPONGE_LIBSPONGE_TCP_FACTORED_HH
void connect()
Initiate a connection by sending a SYN segment.
size_t unassembled_bytes() const
number of bytes not yet reassembled
size_t time_since_last_segment_received() const
Number of milliseconds since the last segment was received.
std::queue< TCPSegment > & segments_out()
TCPSegments that the TCPConnection has enqueued for transmission.
A complete endpoint of a TCP connection.
ByteStream & inbound_stream()
The inbound byte stream received from the peer.
The "sender" part of a TCP implementation.
void end_input_stream()
Shut down the outbound byte stream (still allows reading incoming data)
size_t remaining_outbound_capacity() const
size_t bytes_in_flight() const
number of bytes sent and not yet acknowledged, counting SYN/FIN each as one byte
bool active() const
Is the connection still alive in any way?
void segment_received(const TCPSegment &seg)
Called when a new segment has been received from the network.
size_t send_capacity
Sender capacity, in bytes.
The "receiver" part of a TCP implementation.
Summary of a TCPConnection's internal state.
uint16_t rt_timeout
Initial value of the retransmission timeout, in milliseconds.
TCPConnection & operator=(TCPConnection &&other)=default
~TCPConnection()
destructor sends a RST if the connection is still open
Config for TCP sender and receiver.
size_t recv_capacity
Receive capacity, in bytes.
TCPConnection(const TCPConfig &cfg)
Construct a new connection from a configuration.
size_t write(const std::string &data)
Write data to the outbound byte stream, and send it over TCP if possible.
void tick(const size_t ms_since_last_tick)
Called periodically when time elapses.
bool _linger_after_streams_finish
ByteStream & stream_out()
std::optional< WrappingInt32 > fixed_isn
std::queue< TCPSegment > _segments_out
outbound queue of segments that the TCPConnection wants sent