Sponge
CS144's user-space TCP library
tcp_sender.cc
Go to the documentation of this file.
1 #include "tcp_sender.hh"
2 
3 #include "tcp_config.hh"
4 
5 #include <random>
6 
7 // Dummy implementation of a TCP sender
8 
9 // For Lab 3, please replace with a real implementation that passes the
10 // automated checks run by `make check_lab3`.
11 
12 template <typename... Targs>
13 void DUMMY_CODE(Targs &&... /* unused */) {}
14 
15 using namespace std;
16 
20 TCPSender::TCPSender(const size_t capacity, const uint16_t retx_timeout, const std::optional<WrappingInt32> fixed_isn)
21  : _isn(fixed_isn.value_or(WrappingInt32{random_device()()}))
22  , _initial_retransmission_timeout{retx_timeout}
23  , _stream(capacity) {}
24 
25 uint64_t TCPSender::bytes_in_flight() const { return {}; }
26 
28 
31 void TCPSender::ack_received(const WrappingInt32 ackno, const uint16_t window_size) { DUMMY_CODE(ackno, window_size); }
32 
34 void TCPSender::tick(const size_t ms_since_last_tick) { DUMMY_CODE(ms_since_last_tick); }
35 
36 unsigned int TCPSender::consecutive_retransmissions() const { return {}; }
37 
TCPSender::consecutive_retransmissions
unsigned int consecutive_retransmissions() const
Number of consecutive retransmissions that have occurred in a row.
Definition: tcp_sender.cc:36
WrappingInt32
A 32-bit integer, expressed relative to an arbitrary initial sequence number (ISN)
Definition: wrapping_integers.hh:9
tcp_sender.hh
TCPSender::send_empty_segment
void send_empty_segment()
Generate an empty-payload segment (useful for creating empty ACK segments)
Definition: tcp_sender.cc:38
TCPSender::bytes_in_flight
size_t bytes_in_flight() const
How many sequence numbers are occupied by segments sent but not yet acknowledged?
Definition: tcp_sender.cc:25
tcp_config.hh
std::random_device
std::uint16_t
DUMMY_CODE
void DUMMY_CODE(Targs &&...)
Definition: tcp_sender.cc:13
std
TCPSender::TCPSender
TCPSender(const size_t capacity=TCPConfig::DEFAULT_CAPACITY, const uint16_t retx_timeout=TCPConfig::TIMEOUT_DFLT, const std::optional< WrappingInt32 > fixed_isn={})
Initialize a TCPSender.
Definition: tcp_sender.cc:20
TCPSender::ack_received
void ack_received(const WrappingInt32 ackno, const uint16_t window_size)
A new acknowledgment was received.
Definition: tcp_sender.cc:31
TCPSender::tick
void tick(const size_t ms_since_last_tick)
Notifies the TCPSender of the passage of time.
Definition: tcp_sender.cc:34
TCPSender::fill_window
void fill_window()
create and send segments to fill as much of the window as possible
Definition: tcp_sender.cc:27