21#include <boost/functional/hash/hash.hpp>
35 = std::numeric_limits<seq_num_t>::max() / 2;
38 = boost::chrono::milliseconds(500);
55 if (m_last_init_seq_num.m_num == 0)
63 Rnd_gen_uniform_range<seq_num_t> rnd_single_use(1, S_MAX_INIT_SEQ_NUM);
64 m_last_init_seq_num.m_num = rnd_single_use();
75 m_last_init_seq_num.m_num +=
76 seq_num_t((now - m_last_isn_generation + S_MIN_DELAY_BETWEEN_ISN) / S_TIME_PER_SEQ_NUM);
83 if (m_last_init_seq_num.m_num > S_MAX_INIT_SEQ_NUM)
86 m_last_init_seq_num.m_num = m_last_init_seq_num.m_num - S_MAX_INIT_SEQ_NUM;
92 m_last_isn_generation = now;
93 return m_last_init_seq_num;
146 return !(*
this == rhs);
161 return !(*
this < rhs);
277 return seq_num.
hash();
Interface that the user should implement, passing the implementing Logger into logging classes (Flow'...
Sequence_number generate_init_seq_num()
Returns an initial sequence number (ISN) for use in a new connection.
static const Fine_duration S_MIN_DELAY_BETWEEN_ISN
In addition to the actual time passed between two ISN generations, pretend this much additional time ...
Generator(log::Logger *logger)
Constructs Generator.
static const seq_num_t S_MAX_INIT_SEQ_NUM
The maximum allowed value for the initial sequence number (ISN) for a given Flow-protocol connection ...
static const Fine_duration S_TIME_PER_SEQ_NUM
The ISN given out at a given time should increment every N; this is the value of N.
An internal net_flow sequence number identifying a piece of data.
seq_num_delta_t m_multiple_size
Expected size of a full contiguous "block" of these numbers; 0 = unknown/blocks not expected....
bool valid() const
Returns true if and only if *this != Sequence_number() (i.e., is non-zero).
bool operator==(const Sequence_number &rhs) const
Whether *this is the same sequence number as rhs.
Sequence_number operator+(seq_num_delta_t delta) const
Returns new sequence number that is *this advanced (or reversed) by the given distance.
seq_num_delta_t operator-(const Sequence_number &rhs) const
Returns the distance from *this to rhs.
bool operator<(const Sequence_number &rhs) const
Whether *this is less than rhs.
bool operator<=(const Sequence_number &rhs) const
Return !(*this > rhs).
void set_metadata(char num_line_id=0, const Sequence_number &zero_point=Sequence_number(), seq_num_delta_t multiple_size=0)
Updates the full set of metadata (used at least for convenient convention-based logging but not actua...
Sequence_number & operator+=(seq_num_delta_t delta)
Advances (or reverses) this sequence number by the given distance.
size_t hash_value(const Sequence_number &seq_num)
Free function that returns seq_num.hash(); has to be a free function named hash_value for boost....
size_t hash() const
Hash value of this Sequence_number for unordered_*<>.
void set_raw_num(seq_num_t num)
Sets the raw sequence number.
Sequence_number & operator-=(seq_num_delta_t delta)
Equivalent to: operator+=(-delta).
Sequence_number & operator=(const Sequence_number &source)
Copy operator.
uint64_t seq_num_t
Raw sequence number type.
int64_t seq_num_delta_t
Integer type used to express differences (distances) between Sequence_numbers.
const seq_num_t & raw_num_ref() const
Provides the raw sequence number.
seq_num_t m_num
The raw sequence number. This is the only datum used in algorithms. The others are only for logging a...
Sequence_number()
Constructs sequence number that is zero (not a valid sequence number; less than all others).
seq_num_t m_zero_point_num
Value for m_num such that the magnitude is zero. See set_metadata().
char m_num_line_id
Identifies the owner number line; char(0) = unknown/none. See set_metadata().
bool operator>(const Sequence_number &rhs) const
Return rhs < *this.
bool operator!=(const Sequence_number &rhs) const
Return !(*this == rhs).
bool operator>=(const Sequence_number &rhs) const
Return rhs <= *this.
#define FLOW_LOG_TRACE(ARG_stream_fragment)
Logs a TRACE message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...
size_t hash_value(const Sequence_number &seq_num)
Free function that returns seq_num.hash(); has to be a free function named hash_value for boost....
std::ostream & operator<<(std::ostream &os, const Congestion_control_selector::Strategy_choice &strategy_choice)
Serializes a Peer_socket_options::Congestion_control_strategy_choice enum to a standard ostream – the...
Flow_log_component
The flow::log::Component payload enumeration comprising various log components used by Flow's own int...
Fine_clock::duration Fine_duration
A high-res time duration as computed from two Fine_time_pts.
Fine_clock::time_point Fine_time_pt
A high-res time point as returned by Fine_clock::now() and suitable for precise time math in general.