28const boost::unordered_map<std::type_index, Low_lvl_packet::Packet_type_info>
 
   32             { std::type_index(
typeid(Syn_packet)),
 
   34             { std::type_index(
typeid(Syn_ack_packet)),
 
   36             { std::type_index(
typeid(Syn_ack_ack_packet)),
 
   37               { 2, 
"SYN_ACK_ACK" } },
 
   38             { std::type_index(
typeid(Data_packet)),
 
   40             { std::type_index(
typeid(Ack_packet)),
 
   42             { std::type_index(
typeid(Rst_packet)),
 
   63  m_verbose_ostream_manip([
this](std::ostream& os) -> std::ostream& { 
return to_ostream(os, 
true); }),
 
   64  m_concise_ostream_manip([
this](std::ostream& os) -> std::ostream& { 
return to_ostream(os, 
false); })
 
   71  m_serialized_metadata(logger)
 
  110  using std::type_index;
 
  116  return it->second.m_type_id_str;
 
  121  using std::type_index;
 
  127  return it->second.m_raw_type_id;
 
  132  namespace bind_ns = util::bind_ns;
 
  145         "total added output size [" << size << 
"] bytes; final buffer contents including added output: " 
  152         "total added output size [" << size << 
"] bytes.");
 
  161  using boost::asio::const_buffer;
 
  162  using std::type_index;
 
  172  static_assert(
sizeof raw_type_id_ref == 1,
 
  173                "Raw packet type ID should be small enough for byte ordering to be a non-issue.");
 
  174  size_t size = 
sizeof raw_type_id_ref;
 
  175  raw_bufs->push_back(const_buffer(&raw_type_id_ref, size));
 
  190  size += raw_bufs->back().size();
 
  194  size += raw_bufs->back().size();
 
  201  using boost::asio::const_buffer;
 
  214  static_assert(!native_is_big_endian(),
 
  215                "Byte ordering in this platform is not conducive to zero-copy serialization.");
 
  218  size_t size = serialize_common_header_to_raw_data(raw_bufs);
 
  222  const auto* raw_seq_num = &(m_init_seq_num.raw_num_ref());
 
  223  raw_bufs->push_back(const_buffer(raw_seq_num, 
sizeof *raw_seq_num));
 
  224  size += 
sizeof *raw_seq_num;
 
  226  if (!m_serialized_metadata.empty())
 
  228    raw_bufs->push_back(const_buffer(m_serialized_metadata.const_data(), m_serialized_metadata.size()));
 
  229    size += m_serialized_metadata.size();
 
  237  using boost::asio::const_buffer;
 
  241  static_assert(!native_is_big_endian(),
 
  242                "Byte ordering in this platform is not conducive to zero-copy serialization.");
 
  245  size_t size = serialize_common_header_to_raw_data(raw_bufs);
 
  248  raw_bufs->push_back(const_buffer(raw_seq_num, 
sizeof *raw_seq_num));
 
  249  size += 
sizeof *raw_seq_num;
 
  252  raw_bufs->push_back(const_buffer(&m_packed.m_security_token,
 
  253                                   sizeof m_packed.m_security_token + 
sizeof m_packed.m_rcv_wnd));
 
  254  size += raw_bufs->back().size();
 
  261  using boost::asio::const_buffer;
 
  265  static_assert(!native_is_big_endian(),
 
  266                "Byte ordering in this platform is not conducive to zero-copy serialization.");
 
  269  size_t size = serialize_common_header_to_raw_data(raw_bufs);
 
  272  raw_bufs->push_back(const_buffer(&m_packed.m_security_token,
 
  273                                   sizeof m_packed.m_security_token + 
sizeof m_packed.m_rcv_wnd));
 
  274  size += raw_bufs->back().size();
 
  281  using boost::asio::const_buffer;
 
  282  using std::numeric_limits;
 
  288  static_assert(!native_is_big_endian(),
 
  289                "Byte ordering in this platform is not conducive to zero-copy serialization.");
 
  292  size_t size = serialize_common_header_to_raw_data(raw_bufs);
 
  295  raw_bufs->push_back(const_buffer(raw_seq_num, 
sizeof *raw_seq_num));
 
  296  size += 
sizeof *raw_seq_num;
 
  300    raw_bufs->push_back(const_buffer(&m_rexmit_id, 
sizeof m_rexmit_id));
 
  301    size += 
sizeof m_rexmit_id;
 
  304  assert(!m_data.empty());
 
  307  const size_t data_size = m_data.size();
 
  308  using data_size_raw_t = 
decltype(m_data_size_raw);
 
  309  assert(data_size <= numeric_limits<data_size_raw_t>::max());
 
  311  m_data_size_raw = data_size_raw_t(data_size);
 
  312  raw_bufs->push_back(const_buffer(&m_data_size_raw, 
sizeof m_data_size_raw));
 
  313  size += 
sizeof m_data_size_raw;
 
  315  raw_bufs->push_back(const_buffer(m_data.const_data(), data_size));
 
  316  size += m_data.size();
 
  323  using boost::asio::const_buffer;
 
  324  using std::numeric_limits;
 
  330  static_assert(!native_is_big_endian(),
 
  331                "Byte ordering in this platform is not conducive to zero-copy serialization.");
 
  334  size_t size = serialize_common_header_to_raw_data(raw_bufs);
 
  336  raw_bufs->push_back(const_buffer(&m_rcv_wnd, 
sizeof m_rcv_wnd));
 
  337  size += 
sizeof m_rcv_wnd;
 
  340  const size_t pkts_size = m_opt_rexmit_on
 
  341                             ? m_rcv_acked_packets_rexmit_on_out.size()
 
  342                             : m_rcv_acked_packets_rexmit_off_out.size();
 
  343  using pkts_size_t = 
decltype(m_rcv_acked_packets_rexmit_out_size);
 
  344  assert(pkts_size <= numeric_limits<pkts_size_t>::max());
 
  346  m_rcv_acked_packets_rexmit_out_size = pkts_size_t(pkts_size);
 
  347  raw_bufs->push_back(const_buffer(&m_rcv_acked_packets_rexmit_out_size, 
sizeof(pkts_size_t)));
 
  348  size += 
sizeof(pkts_size_t);
 
  360    raw_bufs->push_back(const_buffer(m_rcv_acked_packets_rexmit_on_out.data(),
 
  361                                     m_rcv_acked_packets_rexmit_on_out.size()
 
  362                                       * 
sizeof(
decltype(m_rcv_acked_packets_rexmit_on_out)::value_type)));
 
  366    raw_bufs->push_back(const_buffer(m_rcv_acked_packets_rexmit_off_out.data(),
 
  367                                     m_rcv_acked_packets_rexmit_off_out.size()
 
  368                                       * 
sizeof(
decltype(m_rcv_acked_packets_rexmit_off_out)::value_type)));
 
  370  size += raw_bufs->back().size();
 
  378  return serialize_common_header_to_raw_data(raw_bufs);
 
  385  using boost::asio::buffer;
 
  386  using boost::asio::const_buffer;
 
  387  using boost::endian::little_to_native;
 
  390  Const_buffer raw_buf(raw_packet->const_data(), raw_packet->size());
 
  395  const size_t raw_buf_size = raw_buf.size();
 
  398    (
"Deserializing Low_lvl_packet; " 
  399     "total raw buffer size [" << raw_buf_size << 
"] bytes; buffer contents: " 
  413  const size_t common_data_size
 
  417  if (raw_buf_size < common_data_size)
 
  419    FLOW_LOG_WARNING(
"Unable to deserialize low-level packet: The packet is too small: " 
  420                     "[" << raw_buf_size << 
"] bytes.");
 
  428  const uint8_t* common_data = 
static_cast<const uint8_t*
>(raw_buf.data());
 
  430  raw_buf = raw_buf + common_data_size;
 
  433  const auto& raw_type_id = *common_data;
 
  434  common_data += 
sizeof raw_type_id;
 
  440      ? create_uninit_packet_base<Syn_packet>(logger_ptr)
 
  442      ? create_uninit_packet_base<Syn_ack_packet>(logger_ptr)
 
  444      ? create_uninit_packet_base<Syn_ack_ack_packet>(logger_ptr)
 
  446      ? create_uninit_packet_base<Data_packet>(logger_ptr)
 
  448      ? create_uninit_packet_base<Ack_packet>(logger_ptr)
 
  450      ? create_uninit_packet_base<Rst_packet>(logger_ptr)
 
  454    FLOW_LOG_WARNING(
"Unable to deserialize low-level packet: The packet type is invalid: " 
  455                     "[" << 
int(raw_type_id) << 
"].");
 
  460  const auto& opt_rexmit_on_raw
 
  461    = *
reinterpret_cast<const opt_rexmit_on_raw_t*
>(common_data);
 
  462  common_data += 
sizeof opt_rexmit_on_raw;
 
  463  packet->m_opt_rexmit_on = (opt_rexmit_on_raw != 0);
 
  466  const auto& reserved2 = *
reinterpret_cast<const reserved2_t*
>(common_data);
 
  467  common_data += 
sizeof reserved2;
 
  470    FLOW_LOG_WARNING(
"Unable to deserialize low-level packet: The packet format is unknown.");
 
  475  const auto& src_port_raw = *
reinterpret_cast<const flow_port_t*
>(common_data);
 
  476  common_data += 
sizeof src_port_raw;
 
  477  packet->m_packed.m_src_port = little_to_native(src_port_raw);
 
  479  const auto& dst_port_raw = *
reinterpret_cast<const flow_port_t*
>(common_data);
 
  480  common_data += 
sizeof dst_port_raw;
 
  481  packet->m_packed.m_dst_port = little_to_native(dst_port_raw);
 
  484  assert(common_data == 
static_cast<const uint8_t*
>(raw_buf.data()));
 
  486  FLOW_LOG_TRACE(
"Deserialized packet [" << packet << 
"] common info: " 
  487                 "NetFlow ports [" << packet->m_packed.m_src_port << 
"] -> [" << packet->m_packed.m_dst_port << 
"]; " 
  488                 "opt_rexmit_on = [" << packet->m_opt_rexmit_on << 
"]; " 
  489                 "common serialized size was [" << common_data_size << 
"].");
 
  492  if (!packet->deserialize_type_specific_data_from_raw_data_packet(&raw_buf, prefer_no_move, raw_packet))
 
  504                              "Deserialized packet: Final version: " 
  506                              << (data_sev ? packet->m_verbose_ostream_manip : packet->m_concise_ostream_manip)
 
  514                                                                     [[maybe_unused]] 
bool prefer_no_move,
 
  518  using boost::asio::buffer;
 
  519  using boost::endian::little_to_native;
 
  526  const size_t raw_buf_size = raw_buf->size();
 
  527  if (raw_buf_size < min_data_size)
 
  530                     "packet: The packet is too small: ["<< raw_buf_size << 
"] bytes.");
 
  535  const uint8_t* data = 
static_cast<const uint8_t*
>(raw_buf->data());
 
  536  (*raw_buf) = ((*raw_buf) + min_data_size);
 
  539  data += 
sizeof seq_num_raw;
 
  552  assert(data == 
static_cast<const uint8_t*
>(raw_buf->data()));
 
  559                "metadata size ["<< n_copied << 
"] bytes; " 
  560                "serialized size beyond common header was [" << raw_buf_size << 
"].");
 
  566                                                                         [[maybe_unused]] 
bool prefer_no_move,
 
  570  using boost::endian::little_to_native;
 
  578  const size_t raw_buf_size = raw_buf->size();
 
  579  if (raw_buf_size != exp_data_size)
 
  582                     "packet: The packet is of wrong size: ["<< raw_buf_size << 
"] bytes.");
 
  587  const uint8_t* data = 
static_cast<const uint8_t*
>(raw_buf->data());
 
  588  (*raw_buf) = ((*raw_buf) + exp_data_size);
 
  591  data += 
sizeof seq_num_raw;
 
  596  const auto& security_token_raw = *
reinterpret_cast<const security_token_t*
>(data);
 
  597  data += 
sizeof security_token_raw;
 
  598  m_packed.m_security_token = little_to_native(security_token_raw);
 
  600  const auto& rcv_wnd_raw = *
reinterpret_cast<const rcv_wnd_t*
>(data);
 
  601  data += 
sizeof rcv_wnd_raw;
 
  602  m_packed.m_rcv_wnd = little_to_native(rcv_wnd_raw);
 
  604  assert(data == 
static_cast<const uint8_t*
>(raw_buf->data()));
 
  608                "rcv_wnd ["<< 
m_packed.m_rcv_wnd << 
"] bytes; " 
  609                "serialized size beyond common header was [" << raw_buf_size << 
"].");
 
  615                                                                             [[maybe_unused]] 
bool prefer_no_move,
 
  619  using boost::endian::little_to_native;
 
  625  const size_t exp_data_size = 
sizeof m_packed.m_security_token + 
sizeof m_packed.m_rcv_wnd;
 
  626  const size_t raw_buf_size = raw_buf->size();
 
  627  if (raw_buf_size != exp_data_size)
 
  630                     "packet: The packet is too small: ["<< raw_buf_size << 
"] bytes.");
 
  635  const uint8_t* data = 
static_cast<const uint8_t*
>(raw_buf->data());
 
  636  (*raw_buf) = ((*raw_buf) + exp_data_size);
 
  638  const auto& security_token_raw = *
reinterpret_cast<const security_token_t*
>(data);
 
  639  data += 
sizeof security_token_raw;
 
  640  m_packed.m_security_token = little_to_native(security_token_raw);
 
  642  const auto& rcv_wnd_raw = *
reinterpret_cast<const rcv_wnd_t*
>(data);
 
  643  data += 
sizeof rcv_wnd_raw;
 
  644  m_packed.m_rcv_wnd = little_to_native(rcv_wnd_raw);
 
  646  assert(data == 
static_cast<const uint8_t*
>(raw_buf->data()));
 
  649                "rcv_wnd ["<< 
m_packed.m_rcv_wnd << 
"] bytes; " 
  650                "serialized size beyond common header was [" << raw_buf_size << 
"].");
 
  659  using boost::asio::buffer;
 
  660  using boost::endian::little_to_native;
 
  661  using std::numeric_limits;
 
  670  const size_t min_data_size
 
  672  const size_t raw_buf_size = raw_buf->size();
 
  673  if (raw_buf_size < min_data_size)
 
  676                     "packet: The packet is too small: ["<< raw_buf_size << 
"] bytes.");
 
  681  const uint8_t* cur_data = 
static_cast<const uint8_t*
>(raw_buf->data());
 
  682  (*raw_buf) = ((*raw_buf) + min_data_size);
 
  685  cur_data += 
sizeof seq_num_raw;
 
  692    const auto& rexmit_id_raw = *
reinterpret_cast<const rexmit_id_t*
>(cur_data);
 
  693    cur_data += 
sizeof rexmit_id_raw;
 
  712  data_size_raw_t data_size_raw;
 
  714  memcpy(&data_size_raw, cur_data, 
sizeof data_size_raw);
 
  715  cur_data += 
sizeof data_size_raw;
 
  717  data_size_raw = little_to_native(data_size_raw);
 
  719  if (data_size_raw == 0)
 
  722                     "packet: The data area specifies empty size.");
 
  727  assert(cur_data == 
static_cast<const uint8_t*
>(raw_buf->data()));
 
  730  const size_t data_size = raw_buf->size();
 
  732  if ((data_size > numeric_limits<data_size_raw_t>::max()) 
 
  733      || (data_size_raw_t(data_size) != data_size_raw))
 
  736                     "packet: The data area specifies size [" << data_size_raw << 
"] but has " 
  737                     "actual size [" << data_size << 
"].  Did truncation occur somewhere?");
 
  755    m_data.assign_copy(*raw_buf);
 
  759    m_data = std::move(*raw_packet);
 
  761    m_data.start_past_prefix(cur_data - 
m_data.const_data());
 
  762    assert(
m_data.const_begin() == cur_data);
 
  765  assert(
m_data.size() == data_size);
 
  771                   "user data size [" << data_size << 
"] (" << (prefer_no_move ? 
"copied" : 
"moved") << 
"); " 
  772                   "serialized size beyond common header was [" << raw_buf_size << 
"].");
 
  777                   "sequence number [" << 
m_seq_num << 
"]; " 
  778                   "user data size [" << data_size << 
"] (" << (prefer_no_move ? 
"copied" : 
"moved") << 
"); " 
  779                   "serialized size beyond common header was [" << raw_buf_size << 
"].");
 
  786                                                                     [[maybe_unused]] 
bool prefer_no_move,
 
  790  using boost::endian::little_to_native;
 
  791  using std::numeric_limits;
 
  799  const size_t min_data_size = 
sizeof m_rcv_wnd + 
sizeof(pkts_size_raw_t);
 
  800  const size_t raw_buf_size = raw_buf->size();
 
  801  if (raw_buf_size < min_data_size)
 
  804                     "packet: The packet is too small: ["<< raw_buf_size << 
"] bytes.");
 
  809  const uint8_t* data = 
static_cast<const uint8_t*
>(raw_buf->data());
 
  810  (*raw_buf) = ((*raw_buf) + min_data_size);
 
  812  const auto& rcv_wnd_raw = *
reinterpret_cast<const rcv_wnd_t*
>(data);
 
  813  data += 
sizeof rcv_wnd_raw;
 
  814  m_rcv_wnd = little_to_native(rcv_wnd_raw);
 
  819  auto pkts_size_raw = *
reinterpret_cast<const pkts_size_raw_t*
>(data);
 
  820  data += 
sizeof pkts_size_raw;
 
  821  pkts_size_raw = little_to_native(pkts_size_raw);
 
  823  assert(data == 
static_cast<const uint8_t*
>(raw_buf->data()));
 
  825  const size_t ack_size
 
  827  const size_t n_acks = raw_buf->size() / ack_size; 
 
  828  (*raw_buf) = ((*raw_buf) + (n_acks * ack_size));
 
  830  if ((n_acks > numeric_limits<pkts_size_raw_t>::max()) 
 
  831      || (pkts_size_raw_t(n_acks) != pkts_size_raw))
 
  834                     "packet: The individual acks area specifies [" << pkts_size_raw << 
"] acks but has " 
  835                     "actual ack count [" << n_acks << 
"].  Did truncation occur somewhere?");
 
  843  for (
size_t ack_idx = 0; ack_idx != n_acks; ++ack_idx)
 
  846    data += 
sizeof seq_num_raw;
 
  848    seq_num.
set_raw_num(little_to_native(seq_num_raw));
 
  852    const auto& ack_delay_raw = *
reinterpret_cast<const ack_delay_t*
>(data);
 
  853    data += 
sizeof ack_delay_raw;
 
  857    unsigned int rexmit_id;
 
  860      const auto& rexmit_id_raw = *
reinterpret_cast<const rexmit_id_t*
>(data);
 
  861      data += 
sizeof rexmit_id_raw;
 
  862      rexmit_id = 
static_cast<unsigned int>(little_to_native(rexmit_id_raw));
 
  872  assert(data == 
static_cast<const uint8_t*
>(raw_buf->data()));
 
  876  const size_t remaining_buf_size = raw_buf->size();
 
  877  if (remaining_buf_size != 0)
 
  880                     "Unexpected trailing data: [" << remaining_buf_size << 
"] bytes.");
 
  888                 "serialized size beyond common header was [" << raw_buf_size << 
"].");
 
  894                                                                     [[maybe_unused]] 
bool prefer_no_move,
 
  898  const size_t raw_buf_size = raw_buf->size();
 
  899  if (raw_buf_size != 0)
 
  902                     "Unexpected trailing data: [" << raw_buf_size << 
"] bytes.");
 
  914  constexpr char INDENTATION[] = 
"    ";
 
  918  return os << 
"Low-level packet " << 
this << 
":\n" 
  919            << INDENTATION << 
"type: " << m_type_ostream_manip << 
"\n" 
  920            << INDENTATION << 
"m_src_port: " << m_packed.m_src_port << 
"\n" 
  921            << INDENTATION << 
"m_dst_port: " << m_packed.m_dst_port << 
"\n" 
  922            << INDENTATION << 
"m_opt_rexmit_on: " << m_opt_rexmit_on << 
"\n";
 
  928  using boost::asio::buffer;
 
  930  constexpr char INDENTATION[] = 
"    ";
 
  931  constexpr char INDENTATION2[] = 
"        ";
 
  935  os << INDENTATION << 
"m_init_seq_num: " << m_init_seq_num << 
"\n";
 
  936  if (!m_serialized_metadata.empty())
 
  938    os << INDENTATION << 
"m_serialized_metadata (" << m_serialized_metadata.size() << 
" bytes):\n";
 
  940                       buffer(m_serialized_metadata.const_data(), m_serialized_metadata.size()),
 
  949  constexpr char INDENTATION[] = 
"    ";
 
  953  return os << INDENTATION << 
"m_init_seq_num: " << m_init_seq_num << 
"\n" 
  954            << INDENTATION << 
"m_rcv_wnd: " << m_packed.m_rcv_wnd << 
"\n" 
  955            << INDENTATION << 
"m_security_token: " << m_packed.m_security_token << 
"\n";
 
  960  constexpr char INDENTATION[] = 
"    ";
 
  964  return os << INDENTATION << 
"m_rcv_wnd: " << m_packed.m_rcv_wnd << 
"\n" 
  965            << INDENTATION << 
"m_security_token: " << m_packed.m_security_token << 
"\n";
 
  971  using boost::asio::buffer;
 
  973  constexpr char INDENTATION[] = 
"    ";
 
  974  constexpr char INDENTATION2[] = 
"        ";
 
  978  os << INDENTATION << 
"m_seq_num: " << m_seq_num << 
"\n";
 
  981    os << INDENTATION << 
"m_rexmit_id: " << int(m_rexmit_id) << 
"\n";
 
  986    os << INDENTATION << 
"m_data (m_data_size=" << m_data.size() << 
" bytes)" << (verbose ? 
':' : 
'.') << 
"\n";
 
  998  using boost::asio::buffer;
 
 1000  constexpr char INDENTATION[] = 
"    ";
 
 1004  os << INDENTATION << 
"m_rcv_wnd: " << m_rcv_wnd << 
"\n";
 
 1005  if (!m_rcv_acked_packets.empty())
 
 1007    os << INDENTATION << 
"m_rcv_acked_packets [INCOMING] (" << m_rcv_acked_packets.size() << 
" items):\n";
 
 1008    if (m_opt_rexmit_on)
 
 1010      for (
auto ack : m_rcv_acked_packets)
 
 1012        os << INDENTATION << INDENTATION << ack->m_seq_num << 
'/' << ack->m_rexmit_id
 
 1013           << 
" : [" << ack->m_delay << 
"]\n";
 
 1018      for (
auto ack : m_rcv_acked_packets)
 
 1020        os << INDENTATION << INDENTATION << ack->m_seq_num << 
" : [" << ack->m_delay << 
"]\n";
 
 1025  if (!m_rcv_acked_packets_rexmit_on_out.empty())
 
 1027    os << INDENTATION << 
"m_rcv_acked_packets rexmit=[on] [OUTGOING] " 
 1028                           "(m_rcv_acked_packets_rexmit_out_size=" 
 1029                        << m_rcv_acked_packets_rexmit_out_size << 
'=' 
 1030                        << m_rcv_acked_packets_rexmit_on_out.size() << 
" items):\n";
 
 1031    for (
const auto& ack : m_rcv_acked_packets_rexmit_on_out)
 
 1033      os << INDENTATION << INDENTATION << ack.m_basic_ack.m_seq_num_raw << 
'/' << int(ack.m_rexmit_id)
 
 1034         << 
" : " << ack.m_basic_ack.m_delay << 
" x [" << TIME_UNIT << 
"]\n";
 
 1037  else if (!m_rcv_acked_packets_rexmit_off_out.empty()) 
 
 1039    os << INDENTATION << 
"m_rcv_acked_packets rexmit=[off] [OUTGOING] " 
 1040                           "(m_rcv_acked_packets_rexmit_out_size=" 
 1041                        << m_rcv_acked_packets_rexmit_out_size << 
'=' 
 1042                        << m_rcv_acked_packets_rexmit_off_out.size() << 
" items):\n";
 
 1043    for (
const auto& ack : m_rcv_acked_packets_rexmit_off_out)
 
 1045      os << INDENTATION << INDENTATION << ack.m_seq_num_raw
 
 1046         << 
" : " << ack.m_delay << 
" x [" << TIME_UNIT << 
"]\n";
 
 1055  using std::type_index;
 
 1062  m_seq_num_raw(seq_num.raw_num_ref()),
 
 1069                                                               unsigned int rexmit_id,
 
 1071  m_basic_ack(seq_num, delay),
 
const Component & get_log_component() const
Returns reference to the stored Component object, particularly as many FLOW_LOG_*() macros expect.
Log_context(Logger *logger=0)
Constructs Log_context by storing the given pointer to a Logger and a null Component.
Logger * get_logger() const
Returns the stored Logger pointer, particularly as many FLOW_LOG_*() macros expect.
Interface that the user should implement, passing the implementing Logger into logging classes (Flow'...
virtual bool should_log(Sev sev, const Component &component) const =0
Given attributes of a hypothetical message that would be logged, return true if that message should b...
An internal net_flow sequence number identifying a piece of data.
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...
void set_raw_num(seq_num_t num)
Sets the raw sequence number.
uint64_t seq_num_t
Raw sequence number type.
boost::shared_ptr< Low_lvl_packet > Ptr
Short-hand for ref-counted pointer to mutable values of type Target_type::element_type (a-la T*).
#define FLOW_LOG_DATA(ARG_stream_fragment)
Logs a DATA message into flow::log::Logger *get_logger() with flow::log::Component get_log_component(...
#define FLOW_LOG_INFO(ARG_stream_fragment)
Logs an INFO message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
#define FLOW_LOG_WITHOUT_CHECKING(ARG_sev, ARG_stream_fragment)
Identical to FLOW_LOG_WITH_CHECKING() but foregoes the filter (Logger::should_log()) check.
#define FLOW_LOG_WARNING(ARG_stream_fragment)
Logs a WARNING message into flow::log::Logger *get_logger() with flow::log::Component get_log_compone...
#define FLOW_LOG_TRACE_WITHOUT_CHECKING(ARG_stream_fragment)
Logs a TRACE message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
#define FLOW_LOG_DATA_WITHOUT_CHECKING(ARG_stream_fragment)
Logs a DATA message into flow::log::Logger *get_logger() with flow::log::Component get_log_component(...
#define FLOW_LOG_SET_CONTEXT(ARG_logger_ptr, ARG_component_payload)
For the rest of the block within which this macro is instantiated, causes all FLOW_LOG_....
#define FLOW_LOG_TRACE(ARG_stream_fragment)
Logs a TRACE message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
@ S_DATA
Message satisfies Sev::S_TRACE description AND contains variable-length structure (like packet,...
@ S_TRACE
Message indicates any condition that may occur with great frequency (thus verbose if logged).
Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...
uint16_t flow_port_t
Logical Flow port type (analogous to a UDP/TCP port in spirit but in no way relevant to UDP/TCP).
std::string buffers_dump_string(const Const_buffer_sequence &data, const std::string &indentation, size_t bytes_per_line)
Identical to buffers_to_ostream() but returns an std::string instead of writing to a given ostream.
std::ostream & buffers_to_ostream(std::ostream &os, const Const_buffer_sequence &data, const std::string &indentation, size_t bytes_per_line)
Writes a multi- or single-line string representation of the provided binary data to an output stream,...
Blob_with_log_context<> Blob
A concrete Blob_with_log_context that compile-time-disables Basic_blob::share() and the sharing API d...
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.
unsigned char uint8_t
Byte. Best way to represent a byte of binary data. This is 8 bits on all modern systems.
Individual_ack_rexmit_off(const Sequence_number &seq_num, ack_delay_t delay)
Constructs object.
Individual_ack_rexmit_on(const Sequence_number &seq_num, unsigned int rexmit_id, ack_delay_t delay)
Constructs object.
Specifies the incoming (post-deserialization) acknowledgment of a single received Data_packet.
boost::shared_ptr< Individual_ack > Ptr
Short-hand for ref-counted pointer to mutable objects of this class.
Internal net_flow struct that encapsulates the Flow-protocol low-level ACK packet.
std::vector< boost::shared_ptr< Individual_ack > > m_rcv_acked_packets
List of incoming (post-deserialization of ACK) acknowledgments of DATA packets, each identified by it...
uint64_t ack_delay_t
Type used to store the ACK delay for a given individual acknowledged packet.
std::ostream & to_ostream(std::ostream &os, bool verbose) const override
Implements Low_lvl_packet API.
rcv_wnd_t m_rcv_wnd
Current receive window (remaining Receive buffer size) of the ACK sender.
bool deserialize_type_specific_data_from_raw_data_packet(Const_buffer *raw_buf, bool prefer_no_move, util::Blob *raw_packet) override
Implements Low_lvl_packet API.
size_t serialize_to_raw_data(Const_buffer_sequence *raw_bufs) const override
Implements Low_lvl_packet API.
uint16_t m_rcv_acked_packets_rexmit_out_size
This is the serialized version of m_rcv_acked_packets_rexmit_{on|off}_out.size() and m_rcv_acked_pack...
Fine_duration Ack_delay_time_unit
Ack_delay_time_unit(1) is the duration corresponding to the ack_delay_t value 1; and proportionally f...
Ack_packet(log::Logger *logger_ptr)
The implementation of Low_lvl_packet::create_uninit_packet() for this sub-type of Low_lvl_packet.
Internal net_flow struct that encapsulates the Flow-protocol low-level DATA packet.
uint16_t m_data_size_raw
This is the serialized version of m_data.size() (see m_data).
std::ostream & to_ostream(std::ostream &os, bool verbose) const override
Implements Low_lvl_packet API.
Data_packet(log::Logger *logger_ptr)
The implementation of Low_lvl_packet::create_uninit_packet() for this sub-type of Low_lvl_packet.
Sequence_number m_seq_num
The sequence number of the first byte in the payload; i.e., of m_data.front(), a/k/a m_data[0].
rexmit_id_t m_rexmit_id
Retransmit counter of the DATA packet being sent.
bool deserialize_type_specific_data_from_raw_data_packet(Const_buffer *raw_buf, bool prefer_no_move, util::Blob *raw_packet) override
Implements Low_lvl_packet API.
util::Blob m_data
The payload.
size_t serialize_to_raw_data(Const_buffer_sequence *raw_bufs) const override
Implements Low_lvl_packet API.
uint8_t m_opt_rexmit_on_raw
This is the serialized version of the multi-byte bool Low_lvl_packet::m_opt_rexmit_on.
const uint16_t m_reserved2
Unused space reserved for future use, ensuring correct alignment of other fields and headers.
Aux_raw_data()
Constructs a mostly-uninitialized object, except for the const member(s), if any.
Internal net_flow struct that encapsulates the Flow-protocol low-level packet structure and serves as...
uint32_t rcv_wnd_t
Type used to store the size of m_rcv_wnd member in a couple of different packet types.
uint8_t rexmit_id_t
Type used to store the retransmission count in DATA and ACK packets.
Aux_raw_data m_aux_raw_data
Auxilliary data area necessary for serialize_to_raw_data() to work.
static Ptr create_from_raw_data_packet(log::Logger *logger_ptr, util::Blob *raw_packet, bool prefer_no_move)
Constructs packet on the heap with values determined by the given raw binary data as presumably recei...
static const std::string & type_id_to_str(const std::type_index &type_id)
Returns a brief (a few characters) string description of the given packet type given as type_index(ty...
struct flow::net_flow::Low_lvl_packet::@7 m_packed
Packed group affected by #pragma pack.
virtual std::ostream & to_ostream(std::ostream &os, bool verbose=false) const
Writes a multi-line representation of *this to an output stream.
Low_lvl_packet(log::Logger *logger_ptr)
Constructs packet with uninitialized (essentially random) values.
static const boost::unordered_map< std::type_index, Packet_type_info > S_NATIVE_TYPE_ID_TO_PACKET_TYPE_INFO
Mapping from native typeid(), a/k/a packet type (for all possible packet types), to the set of proper...
size_t serialize_to_raw_data_and_log(Const_buffer_sequence *raw_bufs) const
Identical to serialize_to_raw_data() but adds log-level-appropriate logging after the operation.
static const uint8_t & type_id_native_to_raw(const std::type_info &type_id)
Helper that looks up the Packet_type_info::m_raw_type_id value for the given typeid(p),...
std::vector< Const_buffer > Const_buffer_sequence
Short-hand for sequence of immutable buffers; i.e., a sequence of 1 or more scattered areas in memory...
std::ostream & type_to_ostream(std::ostream &os) const
Writes a brief representation of typeid(*this) – i.e., the packet type (ACK, RST, etc....
const Function< std::ostream &(std::ostream &)> m_type_ostream_manip
ostream manipulator (argument to ostream <<) that will output packet's type ("ACK",...
uint64_t security_token_t
Type used for m_security_token member of a couple different packet types.
virtual size_t serialize_to_raw_data(Const_buffer_sequence *raw_bufs) const =0
Serializes the current logical packet data from *this into the given Const_buffer_sequence,...
boost::asio::const_buffer Const_buffer
Short-hand for boost.asio immutable buffer, which essentially is a pointer to and length of a memory ...
size_t serialize_common_header_to_raw_data(Const_buffer_sequence *raw_bufs) const
Helper for serialize_to_raw_data() implementations in sub-types that encodes the header common to all...
bool m_opt_rexmit_on
Option indicating whether this connection is using retransmission or not.
Internal net_flow struct that encapsulates the Flow-protocol low-level RST packet.
size_t serialize_to_raw_data(Const_buffer_sequence *raw_bufs) const override
Implements Low_lvl_packet API.
Rst_packet(log::Logger *logger_ptr)
The implementation of Low_lvl_packet::create_uninit_packet() for this sub-type of Low_lvl_packet.
bool deserialize_type_specific_data_from_raw_data_packet(Const_buffer *raw_buf, bool prefer_no_move, util::Blob *raw_packet) override
Implements Low_lvl_packet API.
Internal net_flow struct that encapsulates the Flow-protocol low-level SYN_ACK_ACK packet.
std::ostream & to_ostream(std::ostream &os, bool verbose) const override
Implements Low_lvl_packet API.
bool deserialize_type_specific_data_from_raw_data_packet(Const_buffer *raw_buf, bool prefer_no_move, util::Blob *raw_packet) override
Implements Low_lvl_packet API.
struct flow::net_flow::Syn_ack_ack_packet::@9 m_packed
Packed group affected by #pragma pack.
size_t serialize_to_raw_data(Const_buffer_sequence *raw_bufs) const override
Implements Low_lvl_packet API.
Syn_ack_ack_packet(log::Logger *logger_ptr)
The implementation of Low_lvl_packet::create_uninit_packet() for this sub-type of Low_lvl_packet.
Internal net_flow struct that encapsulates the Flow-protocol low-level SYN_ACK packet.
Sequence_number m_init_seq_num
Same meaning as Syn_packet::m_init_seq_num but applied to the essentially independent opposite traffi...
bool deserialize_type_specific_data_from_raw_data_packet(Const_buffer *raw_buf, bool prefer_no_move, util::Blob *raw_packet) override
Implements Low_lvl_packet API.
Syn_ack_packet(log::Logger *logger_ptr)
The implementation of Low_lvl_packet::create_uninit_packet() for this sub-type of Low_lvl_packet.
size_t serialize_to_raw_data(Const_buffer_sequence *raw_bufs) const override
Implements Low_lvl_packet API.
std::ostream & to_ostream(std::ostream &os, bool verbose) const override
Implements Low_lvl_packet API.
struct flow::net_flow::Syn_ack_packet::@8 m_packed
Packed group affected by #pragma pack.
Internal net_flow struct that encapsulates the Flow-protocol low-level SYN packet.
std::ostream & to_ostream(std::ostream &os, bool verbose) const override
Implements Low_lvl_packet API.
Syn_packet(log::Logger *logger_ptr)
The implementation of Low_lvl_packet::create_uninit_packet() for this sub-type of Low_lvl_packet.
util::Blob m_serialized_metadata
Arbitrary serialized user-supplied metadata to send in SYN, where it can be deserialized by the user ...
bool deserialize_type_specific_data_from_raw_data_packet(Const_buffer *raw_buf, bool prefer_no_move, util::Blob *raw_packet) override
Implements Low_lvl_packet API.
Sequence_number m_init_seq_num
The Initial Sequence Number (ISN) of the sequence number line that the sender of this SYN will be usi...
size_t serialize_to_raw_data(Const_buffer_sequence *raw_bufs) const override
Implements Low_lvl_packet API.