JCS-46 implement multicast time-to-live configuration
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java
index 8a8e58a..1cf3962 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryAttributes.java
@@ -58,6 +58,9 @@
     /** udp discovery port */
     private int udpDiscoveryPort = DEFAULT_UDP_DISCOVERY_PORT;
 
+    /** udp datagram TTL */
+    private int udpTTL = 0;
+
     /** default delay between sending passive broadcasts */
     private static final int DEFAULT_SEND_DELAY_SEC = 60;
 
@@ -159,6 +162,22 @@
     }
 
     /**
+     * @return Returns the udpTTL.
+     */
+    public int getUdpTTL()
+    {
+        return udpTTL;
+    }
+
+    /**
+     * @param udpTTL The udpTTL to set.
+     */
+    public void setUdpTTL( int udpTTL )
+    {
+        this.udpTTL = udpTTL;
+    }
+
+    /**
      * @return Returns the udpDiscoveryPort.
      */
     public int getUdpDiscoveryPort()
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySender.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySender.java
index 64ca500..6f4f9fe 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySender.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySender.java
@@ -43,10 +43,10 @@
     private static final Log log = LogManager.getLog( UDPDiscoverySender.class );
 
     /** The socket */
-    private MulticastSocket localSocket;
+    private final MulticastSocket localSocket;
 
     /** The address */
-    private InetAddress multicastAddress;
+    private final InetAddress multicastAddress;
 
     /** The port */
     private final int multicastPort;
@@ -63,15 +63,21 @@
      * <p>
      * @param host
      * @param port
+     * @param udpTTL the Datagram packet time-to-live
      * @throws IOException
      */
-    public UDPDiscoverySender( String host, int port )
+    public UDPDiscoverySender( String host, int port, int udpTTL )
         throws IOException
     {
         try
         {
             log.debug( "Constructing socket for sender on port [{0}]", port );
             localSocket = new MulticastSocket( port );
+            if (udpTTL > 0)
+            {
+                log.debug( "Setting datagram TTL to [{0}]", udpTTL );
+                localSocket.setTimeToLive(udpTTL);
+            }
 
             // Remote address.
             multicastAddress = InetAddress.getByName( host );
@@ -82,7 +88,7 @@
             throw e;
         }
 
-        multicastPort = port;
+        this.multicastPort = port;
     }
 
     /**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java
index 3a8824f..6c7c2a5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java
@@ -79,8 +79,10 @@
                 () -> attributes.getServiceAddress(),
                 () -> attributes.getServicePort() );
 
-        try (UDPDiscoverySender sender = new UDPDiscoverySender( attributes.getUdpDiscoveryAddr(),
-                attributes.getUdpDiscoveryPort() ))
+        try (UDPDiscoverySender sender = new UDPDiscoverySender(
+                attributes.getUdpDiscoveryAddr(),
+                attributes.getUdpDiscoveryPort(),
+                attributes.getUdpTTL()))
         {
             // move this to the run method and determine how often to call it.
             sender.requestBroadcast();
@@ -101,8 +103,10 @@
     {
         // create this connection each time.
         // more robust
-        try (UDPDiscoverySender sender = new UDPDiscoverySender( attributes.getUdpDiscoveryAddr(),
-                attributes.getUdpDiscoveryPort() ))
+        try (UDPDiscoverySender sender = new UDPDiscoverySender(
+                attributes.getUdpDiscoveryAddr(),
+                attributes.getUdpDiscoveryPort(),
+                attributes.getUdpTTL()))
         {
             sender.passiveBroadcast( attributes.getServiceAddress(), attributes.getServicePort(), cacheNames );
 
@@ -126,8 +130,10 @@
     {
         // create this connection each time.
         // more robust
-        try (UDPDiscoverySender sender = new UDPDiscoverySender( attributes.getUdpDiscoveryAddr(),
-                attributes.getUdpDiscoveryPort() ))
+        try (UDPDiscoverySender sender = new UDPDiscoverySender(
+                attributes.getUdpDiscoveryAddr(),
+                attributes.getUdpDiscoveryPort(),
+                attributes.getUdpTTL()))
         {
             sender.removeBroadcast( attributes.getServiceAddress(), attributes.getServicePort(), cacheNames );
 
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java
index 107851a..1f8fc68 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java
@@ -142,7 +142,8 @@
         // more robust
         try (UDPDiscoverySender sender = new UDPDiscoverySender(
                 getUdpDiscoveryAttributes().getUdpDiscoveryAddr(),
-                getUdpDiscoveryAttributes().getUdpDiscoveryPort() ))
+                getUdpDiscoveryAttributes().getUdpDiscoveryPort(),
+                getUdpDiscoveryAttributes().getUdpTTL()))
         {
             sender.passiveBroadcast( getUdpDiscoveryAttributes().getServiceAddress(), getUdpDiscoveryAttributes()
                 .getServicePort(), this.getCacheNames() );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
index e88930b..c28f805 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
@@ -61,7 +61,7 @@
     {
         super.setUp();
         receiver = new UDPDiscoveryReceiver( null, null, ADDRESS, PORT );
-        sender = new UDPDiscoverySender( ADDRESS, PORT );
+        sender = new UDPDiscoverySender( ADDRESS, PORT, 0 );
     }
 
     /**
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java
index c070a53..0f85cb1 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java
@@ -60,8 +60,10 @@
         t.start();
 
         // create a sender
-        UDPDiscoverySender sender = new UDPDiscoverySender( attributes.getUdpDiscoveryAddr(), attributes
-            .getUdpDiscoveryPort() );
+        UDPDiscoverySender sender = new UDPDiscoverySender(
+                attributes.getUdpDiscoveryAddr(),
+                attributes.getUdpDiscoveryPort(),
+                4 /* datagram TTL */);
 
         // create more names than we have no wait facades for
         // the only one that gets added should be testCache1
diff --git a/xdocs/LateralUDPDiscovery.xml b/xdocs/LateralUDPDiscovery.xml
index b19dbc6..4001f3e 100644
--- a/xdocs/LateralUDPDiscovery.xml
+++ b/xdocs/LateralUDPDiscovery.xml
@@ -55,7 +55,8 @@
           Lateral Auxiliary Cache referenced by <code>LTCP</code>.  It uses
           UDP Discovery to locate other servers.  It broadcasts to
           multicast address <code>228.5.6.8</code> and port <code>6780</code>.
-          It listens to port <code>1110</code>.
+          It listens to port <code>1110</code>. The UDP datagram time-to-live
+          is 4. 
         </p>
         <source><![CDATA[
 jcs.auxiliary.LTCP=org.apache.commons.jcs.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory
@@ -65,6 +66,7 @@
 jcs.auxiliary.LTCP.attributes.UdpDiscoveryAddr=228.5.6.8
 jcs.auxiliary.LTCP.attributes.UdpDiscoveryPort=6780
 jcs.auxiliary.LTCP.attributes.UdpDiscoveryEnabled=true
+jcs.auxiliary.LTCP.attributes.UdpTTL=4
         ]]></source>
       </subsection>
       <subsection name="Multi-homed hosts">
@@ -88,6 +90,7 @@
 jcs.auxiliary.LTCP.attributes.UdpDiscoveryAddr=228.5.6.8
 jcs.auxiliary.LTCP.attributes.UdpDiscoveryPort=6780
 jcs.auxiliary.LTCP.attributes.UdpDiscoveryEnabled=true
+jcs.auxiliary.LTCP.attributes.UdpTTL=4
         ]]></source>
       </subsection>
     </section>