Sponge
CS144's user-space TCP library
|
Summary of a TCPConnection's internal state. More...
#include <tcp_state.hh>
Public Types | |
enum | State { State::LISTEN = 0, State::SYN_RCVD, State::SYN_SENT, State::ESTABLISHED, State::CLOSE_WAIT, State::LAST_ACK, State::FIN_WAIT_1, State::FIN_WAIT_2, State::CLOSING, State::TIME_WAIT, State::CLOSED, State::RESET } |
Official state names from the TCP specification. More... | |
Public Member Functions | |
TCPState (const TCPSender &sender, const TCPReceiver &receiver, const bool active, const bool linger) | |
Construct a TCPState given a sender, a receiver, and the TCPConnection's active and linger bits. More... | |
TCPState (const TCPState::State state) | |
Construct a TCPState that corresponds to one of the "official" TCP state names. More... | |
std::string | name () const |
Summarize the TCPState in a string. More... | |
bool | operator!= (const TCPState &other) const |
bool | operator== (const TCPState &other) const |
Static Public Member Functions | |
static std::string | state_summary (const TCPReceiver &receiver) |
Summarize the state of a TCPReceiver in a string. More... | |
static std::string | state_summary (const TCPSender &receiver) |
Summarize the state of a TCPSender in a string. More... | |
Private Attributes | |
bool | _active {true} |
bool | _linger_after_streams_finish {true} |
std::string | _receiver {} |
std::string | _sender {} |
Summary of a TCPConnection's internal state.
Most TCP implementations have a global per-connection state machine, as described in the TCP specification. Sponge is a bit different: we have factored the connection into two independent parts (the sender and the receiver). The TCPSender and TCPReceiver maintain their interval state variables independently (e.g. next_seqno, number of bytes in flight, or whether each stream has ended). There is no notion of a discrete state machine or much overarching state outside the sender and receiver. To test that Sponge follows the TCP spec, we use this class to compare the "official" states with Sponge's sender/receiver states and two variables that belong to the overarching TCPConnection object.
Definition at line 23 of file tcp_state.hh.
|
strong |
Official state names from the TCP specification.
Definition at line 35 of file tcp_state.hh.
TCPState::TCPState | ( | const TCPSender & | sender, |
const TCPReceiver & | receiver, | ||
const bool | active, | ||
const bool | linger | ||
) |
Construct a TCPState given a sender, a receiver, and the TCPConnection's active and linger bits.
Definition at line 76 of file tcp_state.cc.
TCPState::TCPState | ( | const TCPState::State | state | ) |
Construct a TCPState that corresponds to one of the "official" TCP state names.
Definition at line 17 of file tcp_state.cc.
string TCPState::name | ( | ) | const |
Summarize the TCPState in a string.
Definition at line 12 of file tcp_state.cc.
bool TCPState::operator!= | ( | const TCPState & | other | ) | const |
Definition at line 10 of file tcp_state.cc.
bool TCPState::operator== | ( | const TCPState & | other | ) | const |
Definition at line 5 of file tcp_state.cc.
|
static |
Summarize the state of a TCPReceiver in a string.
Definition at line 82 of file tcp_state.cc.
Summarize the state of a TCPSender in a string.
Definition at line 94 of file tcp_state.cc.
|
private |
Definition at line 27 of file tcp_state.hh.
|
private |
Definition at line 28 of file tcp_state.hh.
|
private |
Definition at line 26 of file tcp_state.hh.
|
private |
Definition at line 25 of file tcp_state.hh.