diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2025-09-10 09:29:08 +0200 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2025-09-10 09:29:08 +0200 | 
| commit | d30cf3e7c31f9299062b9ef85a0949e60611509f (patch) | |
| tree | 5240c7127791c2226212722c02d95ea21652a943 /lib | |
| parent | 91531ce72ea4d90ea541f072da54bc46ef555db8 (diff) | |
| parent | b59516179a3e1842de95f8aef549a75dac1102c6 (diff) | |
| download | dabmux-d30cf3e7c31f9299062b9ef85a0949e60611509f.tar.gz dabmux-d30cf3e7c31f9299062b9ef85a0949e60611509f.tar.bz2 dabmux-d30cf3e7c31f9299062b9ef85a0949e60611509f.zip  | |
Merge commit 'b595161' into HEAD
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/edioutput/EDIConfig.h | 3 | ||||
| -rw-r--r-- | lib/edioutput/Transport.cpp | 32 | ||||
| -rw-r--r-- | lib/edioutput/Transport.h | 7 | ||||
| -rw-r--r-- | lib/fec/decode_rs.h | 12 | 
4 files changed, 39 insertions, 15 deletions
diff --git a/lib/edioutput/EDIConfig.h b/lib/edioutput/EDIConfig.h index 7016e87..de4217f 100644 --- a/lib/edioutput/EDIConfig.h +++ b/lib/edioutput/EDIConfig.h @@ -27,6 +27,7 @@  #pragma once +#include <optional>  #include <vector>  #include <string>  #include <memory> @@ -60,7 +61,7 @@ struct udp_destination_t : public destination_t {      uint16_t dest_port = 0;      std::string source_addr;      uint16_t source_port = 0; -    uint8_t ttl = 10; +    std::optional<uint8_t> ttl = std::nullopt;  };  // TCP server that can accept multiple connections diff --git a/lib/edioutput/Transport.cpp b/lib/edioutput/Transport.cpp index e9559b5..3898213 100644 --- a/lib/edioutput/Transport.cpp +++ b/lib/edioutput/Transport.cpp @@ -41,10 +41,15 @@ void configuration_t::print() const          if (auto udp_dest = dynamic_pointer_cast<edi::udp_destination_t>(edi_dest)) {              etiLog.level(info) << " UDP to " << udp_dest->dest_addr << ":" << udp_dest->dest_port;              if (not udp_dest->source_addr.empty()) { -                etiLog.level(info) << "  source      " << udp_dest->source_addr; -                etiLog.level(info) << "  ttl         " << udp_dest->ttl; +                etiLog.level(info) << "  source address=" << udp_dest->source_addr;              } -            etiLog.level(info) << "  source port " << udp_dest->source_port; +            if (udp_dest->ttl) { +                etiLog.level(info) << "  ttl=" << (int)(*udp_dest->ttl); +            } +            else { +                etiLog.level(info) << "  ttl=(default)"; +            } +            etiLog.level(info) << "  source port=" << udp_dest->source_port;          }          else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_server_t>(edi_dest)) {              etiLog.level(info) << " TCP listening on port " << tcp_dest->listen_port; @@ -80,7 +85,10 @@ Sender::Sender(const configuration_t& conf) :              if (not udp_dest->source_addr.empty()) {                  udp_socket.setMulticastSource(udp_dest->source_addr.c_str()); -                udp_socket.setMulticastTTL(udp_dest->ttl); +            } + +            if (udp_dest->ttl) { +                udp_socket.setMulticastTTL(*udp_dest->ttl);              }              auto sender = make_shared<udp_sender_t>( @@ -99,7 +107,7 @@ Sender::Sender(const configuration_t& conf) :                      make_shared<PFTSpreader>(tcp_dest->pft_settings, sender));          }          else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_client_t>(edi_dest)) { -            auto sender = make_shared<tcp_send_client_t>(tcp_dest->dest_addr, tcp_dest->dest_port); +            auto sender = make_shared<tcp_send_client_t>(tcp_dest->dest_addr, tcp_dest->dest_port, m_conf.verbose);              m_pft_spreaders.emplace_back(                      make_shared<PFTSpreader>(tcp_dest->pft_settings, sender));          } @@ -199,7 +207,13 @@ void Sender::tcp_dispatcher_t::send_packet(const std::vector<uint8_t> &frame)  void Sender::tcp_send_client_t::send_packet(const std::vector<uint8_t> &frame)  { -    sock.sendall(frame); +    const auto error_stats = sock.sendall(frame); + +    if (verbose and error_stats.has_seen_new_errors) { +        etiLog.level(warn) << "TCP output " << dest_addr << ":" << dest_port +                          << " has " << error_stats.num_reconnects +                          << " reconnects: most recent error: " << error_stats.last_error; +    }  }  Sender::udp_sender_t::udp_sender_t(std::string dest_addr, @@ -221,7 +235,11 @@ Sender::tcp_dispatcher_t::tcp_dispatcher_t(uint16_t listen_port,  }  Sender::tcp_send_client_t::tcp_send_client_t(const std::string &dest_addr, -                                             uint16_t dest_port) : +                                             uint16_t dest_port, +                                             bool verbose) : +    dest_addr(dest_addr), +    dest_port(dest_port), +    verbose(verbose),      sock(dest_addr, dest_port)  {  } diff --git a/lib/edioutput/Transport.h b/lib/edioutput/Transport.h index b8a9008..96784c0 100644 --- a/lib/edioutput/Transport.h +++ b/lib/edioutput/Transport.h @@ -118,8 +118,13 @@ class Sender {          struct tcp_send_client_t : public i_sender {              tcp_send_client_t(                      const std::string& dest_addr, -                    uint16_t dest_port); +                    uint16_t dest_port, +                    bool verbose); +            std::string dest_addr; +            uint16_t dest_port; +            bool verbose; +            size_t m_num_reconnects_prev = 0;              Socket::TCPSendClient sock;              virtual void send_packet(const std::vector<uint8_t> &frame) override;          }; diff --git a/lib/fec/decode_rs.h b/lib/fec/decode_rs.h index c165cf3..647b885 100644 --- a/lib/fec/decode_rs.h +++ b/lib/fec/decode_rs.h @@ -145,15 +145,15 @@        count++;      }      if (count != no_eras) { -      printf("count = %d no_eras = %d\n lambda(x) is WRONG\n",count,no_eras); +      fprintf(stderr, "count = %d no_eras = %d\n lambda(x) is WRONG\n",count,no_eras);        count = -1;        goto finish;      }  #if DEBUG >= 2 -    printf("\n Erasure positions as determined by roots of Eras Loc Poly:\n"); +    fprintf(stderr, "\n Erasure positions as determined by roots of Eras Loc Poly:\n");      for (i = 0; i < count; i++) -      printf("%d ", loc[i]); -    printf("\n"); +      fprintf(stderr, "%d ", loc[i]); +    fprintf(stderr, "\n");  #endif  #endif    } @@ -227,7 +227,7 @@        continue; /* Not a root */      /* store root (index-form) and error location number */  #if DEBUG>=2 -    printf("count %d root %d loc %d\n",count,i,k); +    fprintf(stderr, "count %d root %d loc %d\n",count,i,k);  #endif      root[count] = i;      loc[count] = k; @@ -279,7 +279,7 @@      }  #if DEBUG >= 1      if (den == 0) { -      printf("\n ERROR: denominator = 0\n"); +      fprintf(stderr, "\n ERROR: denominator = 0\n");        count = -1;        goto finish;      }  | 
