org.jgroups.protocols

## Class TUNNEL

- java.lang.Object
- - org.jgroups.stack.Protocol
  - - org.jgroups.protocols.TP
    - - org.jgroups.protocols.TUNNEL

    public class TUNNEL
    extends TP

Replacement for UDP. Instead of sending packets via UDP, a TCP connection is opened to a Router (using the RouterStub client-side stub), the IP address/port of which was given using channel properties `router_host` and `router_port`. All outgoing traffic is sent via this TCP socket to the Router which distributes it to all connected TUNNELs in this group. Incoming traffic received from Router will simply be passed up the stack.

A TUNNEL layer can be used to penetrate a firewall, most firewalls allow creating TCP connections to the outside world, however, they do not permit outside hosts to initiate a TCP connection to a host inside the firewall. Therefore, the connection created by the inside host is reused by Router to send traffic from an outside host to a host inside the firewall.

Author:
  Bela Ban, Vladimir Blagojevic

### Nested Class Summary

Nested Classes
`class` `TUNNEL.StubReceiver`
`static interface` `TUNNEL.TUNNELPolicy`

### Nested classes/interfaces inherited from class org.jgroups.protocols.TP

`TP.Bundler, TP.DiagnosticsHandler, TP.ProbeHandler, TP.ProtocolAdapter`

### Field Summary

### Fields inherited from class org.jgroups.protocols.TP

`bind_addr, bind_interface_str, bind_port, bundler, bundler_capacity, bundler_type, can_bind_to_mcast_addr, channel_name, connect_count, connectLock, default_thread_factory, diag_handler, diagnostics_addr, diagnostics_port, discard_incompatible_packets, enable_bundling, enable_diagnostics, enable_unicast_bundling, f, global_thread_factory, header, last_discovery_request, LIST, local_addr, log_discard_msgs, logical_addr_cache, logical_addr_cache_expiration, logical_addr_cache_max_size, loopback, max_bundle_size, max_bundle_timeout, members, MULTICAST, num_bytes_received, num_bytes_sent, num_incoming_msgs_received, num_msgs_received, num_msgs_sent, num_oob_msgs_received, OOB, oob_thread_factory, oob_thread_pool, oob_thread_pool_enabled, oob_thread_pool_keep_alive_time, oob_thread_pool_max_threads, oob_thread_pool_min_threads, oob_thread_pool_queue, oob_thread_pool_queue_enabled, oob_thread_pool_queue_max_size, pool_thread_group, port_range, preregistered_probe_handlers, print_function, receive_interfaces, receive_on_all_interfaces, singleton_name, socket_factory, thread_naming_pattern, thread_pool, thread_pool_enabled, thread_pool_keep_alive_time, thread_pool_max_threads, thread_pool_min_threads, thread_pool_queue, thread_pool_queue_enabled, thread_pool_queue_max_size, thread_pool_rejection_policy, tick_time, timer, timer_keep_alive_time, timer_max_threads, timer_min_threads, timer_queue_max_size, timer_thread_factory, timer_type, up_prots, wheel_size, who_has_cache`

### Fields inherited from class org.jgroups.stack.Protocol

`down_prot, ergonomics, id, log, name, stack, stats, up_prot`

### Constructor Summary

Constructors
Constructor and Description
`TUNNEL()`

### Method Summary

Methods
`void` `destroy()` This method is called on a `Channel.close()`.
`java.lang.String` `getInfo()`
`protected PhysicalAddress` `getPhysicalAddress()`
`long` `getReconnectInterval()`
`java.lang.String` `getRouterHost()` Deprecated.
`int` `getRouterPort()` Deprecated.
`java.lang.Object` `handleDownEvent(Event evt)`
`void` `init()` Called after instance has been created (null constructor) and before protocol is started.
`protected void` `send(Message msg, Address dest, boolean multicast)` Serializes and sends a message.
`void` `sendMulticast(byte[] data, int offset, int length)` Send to all members in the group.
`void` `sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length)` Send a unicast to 1 member.
`void` `setGossipRouterHosts(java.lang.String hosts)`
`void` `setReconnectInterval(long reconnect_interval)`
`void` `setRouterHost(java.lang.String router_host)` Deprecated.
`void` `setRouterPort(int router_port)` Deprecated.
`void` `setTUNNELPolicy(TUNNEL.TUNNELPolicy policy)`
`boolean` `supportsMulticasting()` Whether or not hardware multicasting is supported
`java.lang.String` `toString()`

### Methods inherited from class org.jgroups.protocols.TP

`addPhysicalAddressToCache, clearLogicalAddressCache, createThreadPool, dispatchToThreadPool, doSend, down, dumpTimerTasks, evictLogicalAddressCache, fetchLocalAddresses, getBindAddress, getBindAddressAsInetAddress, getBindPort, getBindToAllInterfaces, getBundlerBufferSize, getDefaultThreadPool, getDefaultThreadPoolThreadFactory, getLogDiscardMessages, getMaxBundleSize, getMaxBundleTimeout, getNumBytesReceived, getNumBytesSent, getNumMessagesReceived, getNumMessagesSent, getNumTimerTasks, getOOBMaxQueueSize, getOOBMessages, getOOBPoolSize, getOOBQueueSize, getOOBThreadPool, getOOBThreadPoolKeepAliveTime, getOOBThreadPoolMaxThreads, getOOBThreadPoolMinThreads, getOOBThreadPoolThreadFactory, getPhysicalAddressFromCache, getPoolThreadGroup, getPortRange, getReceiveInterfaces, getRegularMaxQueueSize, getRegularMessages, getRegularPoolSize, getRegularQueueSize, getSendInterfaces, getSingletonName, getSocketFactory, getThreadFactory, getThreadNamingPattern, getThreadPoolKeepAliveTime, getThreadPoolMaxThreads, getThreadPoolMinThreads, getTimer, getTimerClass, getTimerKeepAliveTime, getTimerMaxThreads, getTimerMinThreads, getTimerQueueSize, getTimerThreadFactory, getTimerThreads, getUpProtocols, handleConnect, handleDisconnect, isDefaulThreadPoolEnabled, isDiscardIncompatiblePackets, isEnableBundling, isEnableUnicastBundling, isLoopback, isOOBThreadPoolEnabled, isReceiveOnAllInterfaces, isSendOnAllInterfaces, isSingleton, isUseIncomingPacketHandler, parseRejectionPolicy, passMessageUp, passToAllUpProtocols, printLogicalAddressCache, readMessage, readMessageList, receive, registerLocalAddress, registerProbeHandler, removeLogicalAddressFromCache, resetStats, sendToAllPhysicalAddresses, sendToSingleMember, setBindAddress, setBindPort, setBindToAllInterfaces, setDefaultThreadPool, setDefaultThreadPoolThreadFactory, setDiscardIncompatiblePackets, setEnableBundling, setEnableUnicastBundling, setInAllThreadFactories, setLogDiscardMessages, setLoopback, setMaxBundleSize, setMaxBundleTimeout, setOOBRejectionPolicy, setOOBThreadPool, setOOBThreadPoolKeepAliveTime, setOOBThreadPoolMaxThreads, setOOBThreadPoolMinThreads, setOOBThreadPoolThreadFactory, setPortRange, setRegularRejectionPolicy, setSocketFactory, setSourceAddress, setThreadFactory, setThreadNames, setThreadPoolKeepAliveTime, setThreadPoolMaxThreads, setThreadPoolMinThreads, setThreadPoolQueueEnabled, setTimerKeepAliveTime, setTimerMaxThreads, setTimerMinThreads, setTimerThreadFactory, setUseConcurrentStack, shutdownThreadPool, start, stop, unregisterProbeHandler, unsetThreadNames, up, verifyRejectionPolicy, writeMessage, writeMessageList`

### Methods inherited from class org.jgroups.stack.Protocol

`downThreadEnabled, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProperties, getProtocolStack, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setPropertiesInternal, setProperty, setProtocolStack, setUpProtocol, setValue, setValues, statsEnabled, upThreadEnabled`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### TUNNEL

    public TUNNEL()

### Method Detail

#### supportsMulticasting

    public boolean supportsMulticasting()

Description copied from class: `TP`
Whether or not hardware multicasting is supported

Specified by:
  `supportsMulticasting` in class `TP`

#### setGossipRouterHosts

    public void setGossipRouterHosts(java.lang.String hosts)
                              throws java.net.UnknownHostException

Throws:
  `java.net.UnknownHostException`

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `TP`

#### getRouterHost

    @Deprecated
    public java.lang.String getRouterHost()

Deprecated.

#### setRouterHost

    @Deprecated
    public void setRouterHost(java.lang.String router_host)

Deprecated.

#### getRouterPort

    @Deprecated
    public int getRouterPort()

Deprecated.

#### setRouterPort

    @Deprecated
    public void setRouterPort(int router_port)

Deprecated.

#### getReconnectInterval

    public long getReconnectInterval()

#### setReconnectInterval

    public void setReconnectInterval(long reconnect_interval)

#### setTUNNELPolicy

    public void setTUNNELPolicy(TUNNEL.TUNNELPolicy policy)

#### init

    public void init()
              throws java.lang.Exception

Description copied from class: `Protocol`
Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.

Overrides:
  `init` in class `TP`
Throws:
  `java.lang.Exception` - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception

#### destroy

    public void destroy()

Description copied from class: `Protocol`
This method is called on a `Channel.close()`. Does some cleanup; after the call the VM will terminate

Overrides:
  `destroy` in class `TP`

#### handleDownEvent

    public java.lang.Object handleDownEvent(Event evt)

Overrides:
  `handleDownEvent` in class `TP`

#### send

    protected void send(Message msg,
            Address dest,
            boolean multicast)
                 throws java.lang.Exception

Description copied from class: `TP`
Serializes and sends a message. This method is not reentrant

Overrides:
  `send` in class `TP`
Throws:
  `java.lang.Exception`

#### sendMulticast

    public void sendMulticast(byte[] data,
                     int offset,
                     int length)
                       throws java.lang.Exception

Description copied from class: `TP`
Send to all members in the group. UDP would use an IP multicast message, whereas TCP would send N messages, one for each member

Specified by:
  `sendMulticast` in class `TP`
Parameters:
  `data` - The data to be sent. This is not a copy, so don't modify it
Throws:
  `java.lang.Exception`

#### sendUnicast

    public void sendUnicast(PhysicalAddress dest,
                   byte[] data,
                   int offset,
                   int length)
                     throws java.lang.Exception

Description copied from class: `TP`
Send a unicast to 1 member. Note that the destination address is a *physical*, not a logical address

Specified by:
  `sendUnicast` in class `TP`
Parameters:
  `dest` - Must be a non-null unicast address
  `data` - The data to be sent. This is not a copy, so don't modify it
Throws:
  `java.lang.Exception`

#### getInfo

    public java.lang.String getInfo()

Specified by:
  `getInfo` in class `TP`

#### getPhysicalAddress

    protected PhysicalAddress getPhysicalAddress()

Specified by:
  `getPhysicalAddress` in class `TP`