|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file.
13 : _tap(
move(tap)), _interface(eth_address, ip_address), _next_hop(next_hop) {
std::optional< InternetDatagram > recv_frame(const EthernetFrame &frame)
Receives an Ethernet frame and responds appropriately.
std::optional< TCPSegment > read()
Attempts to read and parse an Ethernet frame containing an IPv4 datagram that contains a TCP segment.
std::queue< EthernetFrame > & frames_out()
Access queue of Ethernet frames awaiting transmission.
size_t write(const char *str, const bool write_all=true)
Write a string, possibly blocking until all is written.
void tick(const size_t ms_since_last_tick)
Called periodically when time elapses.
NetworkInterface _interface
NIC abstraction.
TapFD _tap
Raw Ethernet connection.
std::string read(const size_t limit=std::numeric_limits< size_t >::max())
Read up to limit bytes.
Wrapper around IPv4 addresses and DNS operations.
InternetDatagram wrap_tcp_in_ip(TCPSegment &seg)
void send_datagram(const InternetDatagram &dgram, const Address &next_hop)
Sends an IPv4 datagram, encapsulated in an Ethernet frame (if it knows the Ethernet destination addre...
TCPOverIPv4OverEthernetAdapter(TapFD &&tap, const EthernetAddress ð_address, const Address &ip_address, const Address &next_hop)
Construct from a TapFD.
ParseResult parse(const Buffer buffer)
Parse the frame from a string.
An adapter class that adds random dropping behavior to an FD adapter.
void send_pending()
Sends any pending Ethernet frames.
Address _next_hop
IP address of the next hop.
void write(TCPSegment &seg)
Sends a TCP segment (in an IPv4 datagram, in an Ethernet frame).
void tick(const size_t ms_since_last_tick)
Called periodically when time elapses.
A FileDescriptor to a Linux TAP device.
std::optional< TCPSegment > unwrap_tcp_in_ip(const InternetDatagram &ip_dgram)
BufferList serialize() const
Serialize the frame to a string.