From 1c9d12f48e73de1b81b8937f87d7327ae933bc78 Mon Sep 17 00:00:00 2001 From: Ed Lafargue Date: Wed, 17 Apr 2024 17:51:40 -0700 Subject: [PATCH 1/5] Fix UDP streaming on MacOS, it was broken due to large UDP packets being lost --- src/interfaces/udp_sink_f.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/interfaces/udp_sink_f.cpp b/src/interfaces/udp_sink_f.cpp index 1f944f968..ea29c1e42 100644 --- a/src/interfaces/udp_sink_f.cpp +++ b/src/interfaces/udp_sink_f.cpp @@ -96,7 +96,11 @@ void udp_sink_f::start_streaming(const std::string host, int port, bool stereo) std::cout << (stereo ? "Stereo" : "Mono") << std::endl; #if GNURADIO_VERSION >= 0x031000 +#ifdef GQRX_OS_MACX + d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 512, true); +#else d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 1448, true); +#endif #endif if (stereo) From 173805155e118fa87a7281c734d46bc7f847bda5 Mon Sep 17 00:00:00 2001 From: Ed Lafargue Date: Thu, 18 Apr 2024 08:30:44 -0700 Subject: [PATCH 2/5] Update UDP output buffer to 1024 bytes to account for versions of nc that only support 1024 byte buffers max. --- src/CMakeLists.txt | 1 - src/interfaces/udp_sink_f.cpp | 18 ++++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 845b19639..cdb69568a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") else() add_subdirectory(osxaudio) endif() - add_definitions(-DGQRX_OS_MACX) elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD") if(${LINUX_AUDIO_BACKEND} MATCHES "Pulseaudio") add_subdirectory(pulseaudio) diff --git a/src/interfaces/udp_sink_f.cpp b/src/interfaces/udp_sink_f.cpp index ea29c1e42..8bae8467f 100644 --- a/src/interfaces/udp_sink_f.cpp +++ b/src/interfaces/udp_sink_f.cpp @@ -59,13 +59,11 @@ udp_sink_f::udp_sink_f() d_f2s = gr::blocks::float_to_short::make(1, 32767); #if GNURADIO_VERSION < 0x031000 -#ifdef GQRX_OS_MACX - // There seems to be excessive packet loss (even to localhost) on OS X - // unless the buffer size is limited. - d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355, 512); -#else - d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355); -#endif + // nc is used widely for receiving UDP streams and some versions of nc, + // notably on MacOS, use a 1024 byte buffer so we need to make sure we + // don't send packets that are larger than that, otherwise data will be + // lost. + d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355, 1024); d_sink->disconnect(); #endif @@ -96,11 +94,7 @@ void udp_sink_f::start_streaming(const std::string host, int port, bool stereo) std::cout << (stereo ? "Stereo" : "Mono") << std::endl; #if GNURADIO_VERSION >= 0x031000 -#ifdef GQRX_OS_MACX - d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 512, true); -#else - d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 1448, true); -#endif + d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 1024, true); #endif if (stereo) From 3debd60d064ed7507fffdf80a1b3781a17587580 Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Thu, 18 Apr 2024 12:45:08 -0400 Subject: [PATCH 3/5] Remove magic number --- src/interfaces/udp_sink_f.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/interfaces/udp_sink_f.cpp b/src/interfaces/udp_sink_f.cpp index 8bae8467f..608b90397 100644 --- a/src/interfaces/udp_sink_f.cpp +++ b/src/interfaces/udp_sink_f.cpp @@ -51,6 +51,12 @@ static const int MAX_IN = 2; /*!< Maximum number of input streams. */ static const int MIN_OUT = 0; /*!< Minimum number of output streams. */ static const int MAX_OUT = 0; /*!< Maximum number of output streams. */ +// nc is used widely for receiving UDP streams and some versions of nc, +// notably on MacOS, use a 1024 byte buffer so we need to make sure we +// don't send packets that are larger than that, otherwise data will be +// lost. +static const int PAYLOAD_SIZE = 1024; + udp_sink_f::udp_sink_f() : gr::hier_block2("udp_sink_f", gr::io_signature::make(MIN_IN, MAX_IN, sizeof(float)), @@ -59,11 +65,7 @@ udp_sink_f::udp_sink_f() d_f2s = gr::blocks::float_to_short::make(1, 32767); #if GNURADIO_VERSION < 0x031000 - // nc is used widely for receiving UDP streams and some versions of nc, - // notably on MacOS, use a 1024 byte buffer so we need to make sure we - // don't send packets that are larger than that, otherwise data will be - // lost. - d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355, 1024); + d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355, PAYLOAD_SIZE); d_sink->disconnect(); #endif @@ -94,7 +96,7 @@ void udp_sink_f::start_streaming(const std::string host, int port, bool stereo) std::cout << (stereo ? "Stereo" : "Mono") << std::endl; #if GNURADIO_VERSION >= 0x031000 - d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 1024, true); + d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, PAYLOAD_SIZE, true); #endif if (stereo) From ad36055462c95b4fd1dc4b5473edfe02757b83c6 Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Thu, 18 Apr 2024 12:46:42 -0400 Subject: [PATCH 4/5] Update news --- resources/news.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/news.txt b/resources/news.txt index 21ae4d548..e8e9714b6 100644 --- a/resources/news.txt +++ b/resources/news.txt @@ -5,6 +5,7 @@ NEW: Airspy support in Windows binary release. IMPROVED: Updated GNU Radio, SDR driver, and Qt versions in AppImage release. FIXED: Respond correctly to pipelined remote control commands. + FIXED: Limit UDP packet size to 1024, for compatibility with netcat. REMOVED: FreeSRP support in AppImage release. From 27771fa511994cb7de0d08473cb5e8035a88ef89 Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Thu, 18 Apr 2024 12:47:23 -0400 Subject: [PATCH 5/5] Update contributors --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a201e7f2f..9f1a8eebe 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,7 @@ The following people and organisations have contributed to gqrx: * Dominic Chen * Doron Behar * Doug Hammond +* Edouard Lafargue * Elias Önal * Federico Fuga * Frank Brickle, AB2KT