CS144's user-space TCP library
Public Member Functions | List of all members
TCPOverIPv4Adapter Class Reference

A converter from TCP segments to serialized IPv4 datagrams. More...

#include <tcp_over_ip.hh>

Inheritance diagram for TCPOverIPv4Adapter:
Inheritance graph

Public Member Functions

std::optional< TCPSegmentunwrap_tcp_in_ip (const InternetDatagram &ip_dgram)
InternetDatagram wrap_tcp_in_ip (TCPSegment &seg)
- Public Member Functions inherited from FdAdapterBase
const FdAdapterConfigconfig () const
 Get the current configuration. More...
FdAdapterConfigconfig_mut ()
 Get the current configuration (mutable) More...
bool listening () const
 Get the listening flag. More...
void set_listening (const bool l)
 Set the listening flag. More...
void tick (const size_t)
 Called periodically when time elapses. More...

Additional Inherited Members

- Protected Member Functions inherited from FdAdapterBase
FdAdapterConfigconfig_mutable ()

Detailed Description

A converter from TCP segments to serialized IPv4 datagrams.

Definition at line 12 of file tcp_over_ip.hh.

Member Function Documentation

◆ unwrap_tcp_in_ip()

optional< TCPSegment > TCPOverIPv4Adapter::unwrap_tcp_in_ip ( const InternetDatagram ip_dgram)

This function attempts to parse a TCP segment from the IP datagram's payload.

If this succeeds, it then checks that the received segment is related to the current connection. When a TCP connection has been established, this means checking that the source and destination ports in the TCP header are correct.

If the TCP connection is listening (i.e., TCPOverIPv4OverTunFdAdapter::_listen is true) and the TCP segment read from the wire includes a SYN, this function clears the _listen flag and records the source and destination addresses and port numbers from the TCP header; it uses this information to filter future reads.

a std::optional<TCPSegment> that is empty if the segment was invalid or unrelated

Definition at line 26 of file tcp_over_ip.cc.

◆ wrap_tcp_in_ip()

InternetDatagram TCPOverIPv4Adapter::wrap_tcp_in_ip ( TCPSegment seg)

Takes a TCP segment, sets port numbers as necessary, and wraps it in an IPv4 datagram

[in]segis the TCP segment to convert

Definition at line 75 of file tcp_over_ip.cc.

The documentation for this class was generated from the following files: