foxygit / doom Log in
commit 708d6e0a0250a974c9db0fdf006acfb18794e370
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sun Feb 10 13:11:39 2019 -0500
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Sun Feb 10 13:11:39 2019 -0500

    net: Increase master server refresh period.

    Now that some servers may be behind NAT gateways, it is important that
    we send packets to the master server regularly so that it can forward
    hole punch requests to us. With the previous value of a refresh every
    20 minutes, some NAT gateways may discard the state. Change to 30
    seconds (twice per minute) so that the connection is kept alive.

    Rationale: Wikipedia article on UDP hole punching says:
    > UDP state usually expires after short periods of time in the range
    > of tens of seconds to a few minutes

    Based on this, 30 seconds seems like a reasonable value.
---
 src/net_server.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/net_server.c b/src/net_server.c
index a6742803..e0d752e0 100644
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -40,11 +40,9 @@
 #include "net_structrw.h"

 // How often to refresh our registration with the master server.
-
-#define MASTER_REFRESH_PERIOD 20 * 60 /* 20 minutes */
+#define MASTER_REFRESH_PERIOD 30  /* twice per minute */

 // How often to re-resolve the address of the master server?
-
 #define MASTER_RESOLVE_PERIOD 8 * 60 * 60 /* 8 hours */

 typedef enum