[hamradio-commits] [dump1090] 279/373: Implement TCP Heartbeat

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Thu Oct 23 14:58:27 UTC 2014


This is an automated email from the git hooks/post-receive script.

mernisse-guest pushed a commit to branch backport
in repository dump1090.

commit f7843c1691697075a4aaa440d853b5d6ac4dd4fb
Author: Malcolm Robb <Support at ATTAvionics.com>
Date:   Tue Mar 11 01:09:49 2014 +0000

    Implement TCP Heartbeat
    
    Some users have reported issues where the TCP link to dump1090 can be
    lost at times of low traffic density - typically in the middle of the
    night. One possible reason for this is that some routers drop the link
    if there is no traffic for a predetermined period.
    
    To try and resolve this, dump1090 now sends a 'null' packet consisting
    of 7 "0x00" bytes approximately once a  minute if there is no real
    received traffic during this time. This packet should be discarded by
    the application receiving the dump1090 because it will have an invalid
    checksum, and ICAO address 0x000000 is also invalid. However, this null
    packet should be enough to keep routers alive.
---
 Release/view1090.exe | Bin 90112 -> 90112 bytes
 coaa1090.obj         | Bin 18336 -> 18424 bytes
 dump1090.c           |   6 +++++-
 dump1090.h           |   6 +++++-
 mode_s.c             |  22 ++++++++++++++++++++++
 5 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/Release/view1090.exe b/Release/view1090.exe
index 2a879c5..db55062 100644
Binary files a/Release/view1090.exe and b/Release/view1090.exe differ
diff --git a/coaa1090.obj b/coaa1090.obj
index 7e35631..845210c 100644
Binary files a/coaa1090.obj and b/coaa1090.obj differ
diff --git a/dump1090.c b/dump1090.c
index 70a4d04..b8ec611 100644
--- a/dump1090.c
+++ b/dump1090.c
@@ -69,6 +69,7 @@ void modesInitConfig(void) {
     Modes.gain                    = MODES_MAX_GAIN;
     Modes.freq                    = MODES_DEFAULT_FREQ;
     Modes.check_crc               = 1;
+    Modes.net_heartbeat_rate      = MODES_NET_HEARTBEAT_RATE;
     Modes.net_output_sbs_port     = MODES_NET_OUTPUT_SBS_PORT;
     Modes.net_output_raw_port     = MODES_NET_OUTPUT_RAW_PORT;
     Modes.net_input_raw_port      = MODES_NET_INPUT_RAW_PORT;
@@ -412,6 +413,7 @@ void showHelp(void) {
 "--net-bo-port <port>     TCP Beast output listen port (default: 30005)\n"
 "--net-ro-size <size>     TCP raw output minimum size (default: 0)\n"
 "--net-ro-rate <rate>     TCP raw output memory flush rate (default: 0)\n"
+"--net-heartbeat <rate>   TCP heartbeat rate in seconds (default: 60 sec)\n"
 "--lat <latitude>         Reference/receiver latitude for surface posn (opt)\n"
 "--lon <longitude>        Reference/receiver longitude for surface posn (opt)\n"
 "--fix                    Enable single-bits error correction using CRC\n"
@@ -503,7 +505,9 @@ int main(int argc, char **argv) {
         } else if (!strcmp(argv[j],"--net-only")) {
             Modes.net = 1;
             Modes.net_only = 1;
-        } else if (!strcmp(argv[j],"--net-ro-size") && more) {
+       } else if (!strcmp(argv[j],"--net-heartbeat") && more) {
+            Modes.net_heartbeat_rate = atoi(argv[++j]) * 15;
+       } else if (!strcmp(argv[j],"--net-ro-size") && more) {
             Modes.net_output_raw_size = atoi(argv[++j]);
         } else if (!strcmp(argv[j],"--net-ro-rate") && more) {
             Modes.net_output_raw_rate = atoi(argv[++j]);
diff --git a/dump1090.h b/dump1090.h
index 28d7cf3..68bc6d9 100644
--- a/dump1090.h
+++ b/dump1090.h
@@ -37,7 +37,7 @@
 // MinorVer changes when additional features are added, but not for bug fixes (range 00-99)
 // DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update
 //
-#define MODES_DUMP1090_VERSION     "1.08.2302.14"
+#define MODES_DUMP1090_VERSION     "1.08.1003.14"
 
 // ============================= Include files ==========================
 
@@ -163,6 +163,8 @@
 #define MODES_INTERACTIVE_DELETE_TTL   300      // Delete from the list after 300 seconds
 #define MODES_INTERACTIVE_DISPLAY_TTL   60      // Delete from display after 60 seconds
 
+#define MODES_NET_HEARTBEAT_RATE       900      // Each block is approx 65mS - default is > 1 min
+
 #define MODES_NET_SERVICES_NUM          6
 #define MODES_NET_MAX_FD             1024
 #define MODES_NET_INPUT_RAW_PORT    30001
@@ -281,6 +283,8 @@ struct {                             // Internal state
     int   debug;                     // Debugging mode
     int   net;                       // Enable networking
     int   net_only;                  // Enable just networking
+    int   net_heartbeat_count;       // TCP heartbeat counter
+    int   net_heartbeat_rate;        // TCP heartbeat rate
     int   net_output_sbs_port;       // SBS output TCP port
     int   net_output_raw_size;       // Minimum Size of the output raw data
     int   net_output_raw_rate;       // Rate (in 64mS increments) of output raw data
diff --git a/mode_s.c b/mode_s.c
index 84bef2d..e5e9c81 100644
--- a/mode_s.c
+++ b/mode_s.c
@@ -1812,6 +1812,25 @@ void detectModeS(uint16_t *m, uint32_t mlen) {
         Modes.net_output_raw_rate_count = 0;
         }
       }
+    else if ( (Modes.net) 
+           && (Modes.net_heartbeat_rate) 
+           && ((++Modes.net_heartbeat_count) > Modes.net_heartbeat_rate) ) {
+      //
+      // We haven't received any Mode A/C/S messages for some time. To try and keep any TCP
+      // links alive, send a null frame. This will help stop any routers discarding our TCP 
+      // link which will cause an un-recoverable link error if/when a real frame arrives.   
+      //
+      // Fudge up a null message
+      memset(&mm, 0, sizeof(mm));
+      mm.msgbits      = MODES_SHORT_MSG_BITS;
+      mm.timestampMsg = Modes.timestampBlk;
+
+      // Feed output clients
+      modesQueueOutput(&mm);
+
+      // Reset the heartbeat counter
+      Modes.net_heartbeat_count = 0;
+      }
 }
 //
 //=========================================================================
@@ -1836,6 +1855,9 @@ void useModesMessage(struct modesMessage *mm) {
 
         // Feed output clients
         if (Modes.net) {modesQueueOutput(mm);}
+
+        // Heartbeat not required whilst we're seeing real messages
+        Modes.net_heartbeat_count = 0;
     }
 }
 //

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git



More information about the pkg-hamradio-commits mailing list