From f7843c1691697075a4aaa440d853b5d6ac4dd4fb Mon Sep 17 00:00:00 2001 From: Malcolm Robb Date: Tue, 11 Mar 2014 01:09:49 +0000 Subject: [PATCH] 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 2a879c5eea8bff8f5f2fa796f9852aab476441e4..db55062a5d4a1b5149fca442282d646bf7d7a6d2 100644 GIT binary patch delta 2651 zcmY*aeNa@_6@Pcxw=8vW7i6JORtRFnlt$>fhPXg>t@3*Adyus6 zkMr(5zu!6cckVs+J*S^``su!KR7b=5-`y@j=mED`Hn{eQneP=*-F|yKTb?O@Mrl{E z&VGslkKFnQ9H7R4+HH!WC|E0%wPt%g`0v`6(J(Ge45LxsrX*PkSz$LH zD5NM@h2^^!?Nv3vWMj``bMkl547V@&X?4aBu&f|Di7n1lvSnG-&7oksJ#gipeXYta2itsLU!D0&PB(u&%6a) z!Z*!Fz_V+|kI-@M#Ezi+Ns`yf+B21~4KY?e|388N6|SZM&l_J$9u4>Ea}Q;x95?PN ztL_D%1_wp)gMuLV$dQET^I)@~q7dzYQ9f)*h$gj_j@*A7qDg%-M|YY+G$~RKPl%op zN3=gg58_9=o zvK;v8+Lg*acR9T1y@qx<2Yse;jQ3oCJK{L*+%*E=eXa(sn-zZM4 zI*9zZtI7uL^3N(W8s>5>c?k7lTlEG=b-LP1#|6_?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h~+VspRoKl%Wjs6jv^Y%W*LK|Eg!;i1Y{aLLnrtbhEV}Y3uZ9SXSs;=%ONSiN|vkG zzJ~4ftlz-0f$f{w{u|am$8r~BJk2onu)}^f9AtSIlI%y>{t?Sh+5Q>J^N{5CCELGY z{S}ti*xrZkA^7F7%qJN~$0Jx#0!ciUc^b=kEEho11QxSg21)*_*&b(pl(_+t{5P@u zCEH(Mxi{Ik%@1%03aacaHk@SnDa$V*2h$^lS>S(zCee>wNGc!&vVwl7Ge^D26?^^% DI-RAR 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 TCP Beast output listen port (default: 30005)\n" "--net-ro-size TCP raw output minimum size (default: 0)\n" "--net-ro-rate TCP raw output memory flush rate (default: 0)\n" +"--net-heartbeat TCP heartbeat rate in seconds (default: 60 sec)\n" "--lat Reference/receiver latitude for surface posn (opt)\n" "--lon 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; } } //