diff --git a/ecal/core/src/ecal_log_impl.cpp b/ecal/core/src/ecal_log_impl.cpp index 2d5f726532..e4dc48a421 100644 --- a/ecal/core/src/ecal_log_impl.cpp +++ b/ecal/core/src/ecal_log_impl.cpp @@ -145,17 +145,27 @@ namespace eCAL m_logfile = fopen(m_logfile_name.c_str(), "w"); } - // create log udp sender + // set network attributes if(m_filter_mask_udp != 0) { SSenderAttr attr; - attr.address = UDP::GetLoggingMulticastAddress(); - attr.port = UDP::GetLoggingPort(); - attr.broadcast = !Config::IsNetworkEnabled(); - attr.loopback = true; - attr.ttl = UDP::GetMulticastTtl(); - attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes(); + const bool local_only = !Config::IsNetworkEnabled(); + if (local_only) + { + attr.address = UDP::LocalBroadcastAddress(); + attr.broadcast = true; + } + else + { + attr.address = UDP::GetLoggingMulticastAddress(); + attr.broadcast = false; + } + attr.port = UDP::GetLoggingPort(); + attr.ttl = UDP::GetMulticastTtl(); + attr.loopback = true; + attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes(); + // create udp logging sender m_udp_sender = std::make_unique(attr); } diff --git a/ecal/core/src/ecal_registration_provider.cpp b/ecal/core/src/ecal_registration_provider.cpp index dbab4c0aa6..75296d167b 100644 --- a/ecal/core/src/ecal_registration_provider.cpp +++ b/ecal/core/src/ecal_registration_provider.cpp @@ -82,14 +82,23 @@ namespace eCAL { // set network attributes SSenderAttr attr; - attr.address = UDP::GetRegistrationMulticastAddress(); - attr.port = UDP::GetRegistrationPort(); - attr.ttl = UDP::GetMulticastTtl(); - attr.broadcast = !Config::IsNetworkEnabled(); - attr.loopback = true; - attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes(); - - // create udp sample sender + const bool local_only = !Config::IsNetworkEnabled(); + if (local_only) + { + attr.address = UDP::LocalBroadcastAddress(); + attr.broadcast = true; + } + else + { + attr.address = UDP::GetRegistrationMulticastAddress(); + attr.broadcast = false; + } + attr.port = UDP::GetRegistrationPort(); + attr.ttl = UDP::GetMulticastTtl(); + attr.loopback = true; + attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes(); + + // create udp registration sender m_reg_sample_snd = std::make_shared(attr); } else diff --git a/ecal/core/src/ecal_registration_receiver.cpp b/ecal/core/src/ecal_registration_receiver.cpp index 0007325764..a70991cde3 100644 --- a/ecal/core/src/ecal_registration_receiver.cpp +++ b/ecal/core/src/ecal_registration_receiver.cpp @@ -135,15 +135,27 @@ namespace eCAL if (m_use_network_monitoring) { - // start registration receive thread + // set network attributes SReceiverAttr attr; - attr.address = UDP::GetRegistrationMulticastAddress(); - attr.port = UDP::GetRegistrationPort(); - attr.broadcast = !Config::IsNetworkEnabled(); - attr.loopback = true; - attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes(); + const bool local_only = !Config::IsNetworkEnabled(); + if (local_only) + { + attr.address = UDP::LocalBroadcastAddress(); + attr.broadcast = true; + } + else + { + attr.address = UDP::GetRegistrationMulticastAddress(); + attr.broadcast = false; + } + attr.port = UDP::GetRegistrationPort(); + attr.loopback = true; + attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes(); + // create udp registration receiver m_reg_rcv.Create(attr); + + // start registration receiver thread m_reg_rcv_thread.Start(0, std::bind(&CUdpRegistrationReceiver::Receive, &m_reg_rcv_process, &m_reg_rcv)); } diff --git a/ecal/core/src/io/udp_configurations.cpp b/ecal/core/src/io/udp_configurations.cpp index 984df9e831..78950f3a5e 100644 --- a/ecal/core/src/io/udp_configurations.cpp +++ b/ecal/core/src/io/udp_configurations.cpp @@ -43,7 +43,7 @@ namespace eCAL } else { - // both in v1 and v2, the mulicast group is returned as the adress for the registration layer + // both in v1 and v2, the multicast group is returned as the adress for the registration layer return Config::GetUdpMulticastGroup(); } } diff --git a/ecal/core/src/mon/ecal_monitoring_threads.cpp b/ecal/core/src/mon/ecal_monitoring_threads.cpp index 3a30187a11..a9828b6804 100644 --- a/ecal/core/src/mon/ecal_monitoring_threads.cpp +++ b/ecal/core/src/mon/ecal_monitoring_threads.cpp @@ -43,15 +43,30 @@ namespace eCAL CLoggingReceiveThread::CLoggingReceiveThread(LogMessageCallbackT log_cb_) : m_network_mode(false), m_log_cb(log_cb_) { + // set network attributes SReceiverAttr attr; - attr.address = UDP::GetLoggingMulticastAddress(); - attr.port = UDP::GetLoggingPort(); - attr.broadcast = !Config::IsNetworkEnabled(); - attr.loopback = true; - attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes(); + const bool local_only = !Config::IsNetworkEnabled(); + if (local_only) + { + attr.address = UDP::LocalBroadcastAddress(); + attr.broadcast = true; + } + else + { + attr.address = UDP::GetLoggingMulticastAddress(); + attr.broadcast = false; + } + attr.port = UDP::GetLoggingPort(); + attr.loopback = true; + attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes(); + // create udp logging receiver m_log_rcv.Create(attr); + + // start logging receiver thread m_log_rcv_thread.Start(0, std::bind(&CLoggingReceiveThread::ThreadFun, this)); + + // allocate receive buffer m_msg_buffer.resize(MSG_BUFFER_SIZE); } diff --git a/ecal/core/src/readwrite/ecal_reader_udp_mc.cpp b/ecal/core/src/readwrite/ecal_reader_udp_mc.cpp index 0af9648991..6dfe1e34e5 100644 --- a/ecal/core/src/readwrite/ecal_reader_udp_mc.cpp +++ b/ecal/core/src/readwrite/ecal_reader_udp_mc.cpp @@ -59,12 +59,24 @@ namespace eCAL void CUDPReaderLayer::Initialize() { + // set network attributes SReceiverAttr attr; - attr.address = Config::GetUdpMulticastGroup(); - attr.port = UDP::GetPayloadPort(); - attr.broadcast = false; - attr.loopback = true; - attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes(); + const bool local_only = !Config::IsNetworkEnabled(); + if (local_only) + { + attr.address = UDP::LocalBroadcastAddress(); + attr.broadcast = true; + } + else + { + attr.address = Config::GetUdpMulticastGroup(); + attr.broadcast = false; + } + attr.port = UDP::GetPayloadPort(); + attr.loopback = true; + attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes(); + + // create udp receiver rcv.Create(attr); } diff --git a/ecal/core/src/readwrite/ecal_writer_udp_mc.cpp b/ecal/core/src/readwrite/ecal_writer_udp_mc.cpp index 7695dc0c48..efbb3c55c9 100644 --- a/ecal/core/src/readwrite/ecal_writer_udp_mc.cpp +++ b/ecal/core/src/readwrite/ecal_writer_udp_mc.cpp @@ -62,17 +62,27 @@ namespace eCAL // set network attributes SSenderAttr attr; - attr.address = UDP::GetPayloadMulticastAddress(topic_name_); - attr.port = UDP::GetPayloadPort(); - attr.ttl = UDP::GetMulticastTtl(); - attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes(); + const bool local_only = !Config::IsNetworkEnabled(); + if (local_only) + { + attr.address = UDP::LocalBroadcastAddress(); + attr.broadcast = true; + } + else + { + attr.address = UDP::GetPayloadMulticastAddress(topic_name_); + attr.broadcast = false; + } + attr.port = UDP::GetPayloadPort(); + attr.ttl = UDP::GetMulticastTtl(); + attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes(); // create udp/sample sender with activated loop-back - attr.loopback = true; + attr.loopback = true; m_sample_sender_loopback = std::make_shared(attr); // create udp/sample sender without activated loop-back - attr.loopback = false; + attr.loopback = false; m_sample_sender_no_loopback = std::make_shared(attr); m_created = true;