This presentation shows an alternative and new aporoach to using only one port and multiple protocols. The protocols can be defined and will be recognised.
This can be done to use one internet socket for servising multiple applications that use internet sockets.
Sf rmr - Servicing Forwarding Remote Multiplexing Relay
1. SF-RMR ( http://code.google.com/p/sf-rmr/ ) Port multiplexing Software framework for rule based client-server communication (as opposed to standard port based ). 2010 by Alen Milincevic
2.
3.
4.
5.
6.
7.
8.
9. # listening port for SF-RMR socket port 80 # just some rules triggers (IP PORT ID TRIGGER) rule 1 28 . 169 . 1 .1 8 080 HTTP HEAD rule 1 28 . 169 . 1 .1 8 080 HTTP GET rule 1 28 . 169 . 1 .1 8 080 HTTP POST rule 1 28 . 169 . 1 .1 8 080 HTTP OPTIONS rule 12 8 . 169 . 1 .1 9001 UP <U> This creates a port 80 server socket to outside world , rerouting HTTP and some other protocol to the real server sockets, 8080 and 9001 respectively. Everything is on the same IP adress in this example.
72. First line filter class Checks the first protocol line and allows for either prefiltering of data, data validation or sending a generated pre-response, if neccessary. The general format is: import java.io.*; public class Firstlinehandler { public String streamHandle(BufferedReader br) { // The actual handling is done here // result should be either something handeled or null } }
73. Upstream and downstream filtering This can be used for filtering or more complicated purposes (i.e. logging, monitoring, etc.). General form is: public class FilteringExample { public String streamConvert(String line) { // some conversion or other stuff is done // returns the filtered line } } Prefiler class is used in the same manner.
74. Dynamic redirection and fallback These can be used in order to handle diynamic redirection (not from the config). General form is: public class RuleHandler { public MultiplexingRelayStream HandleRule(String line) { // Returns either a valid formated redirection destination // or null if invalid (or wished so) } }
75. Static redirection order 1. first line is waited for 2. first line is evaluated from configuration 3. based on the rule, redirection is performed
76. Dynamic redirection order 1. first line is waited for ( firstline filter can be applied) 2. prefiltering is applied ( prefilter can be applied) 2. first line is evaluated from configuration ( dynamic redirection filter can be applied) 3. based on the rule, redirection is performed (either static configuration redirecting, or fallback filter can be used)
77. Redirection handling itself 1. dynamic redirection is used (if configured) 2. static configuration is used, if 1. unsuccessfull 3. fallback redirection is used, if 2. unsuccessfull If neither dynamic redirection, nor fallback redirection are configured, then only the default static redirection from configuration is used (default behaviour).
96. Any proces input/output can be redirected over the network, instead being localy bound. This makes it a remote proces, which can be used localy. This brings also an added value, that the proces could be run on a more powerfull machine and/or in a cloud, while the actual input/output data could be presented in a remote location.
107. These examples apply to original Java, some versions: System property Meaning java.net.preferIPv4Stack Preferered protocol stack, IPv4 instead of IPv6 java.net.preferIPv6Addresses This controls whether IPv6 (true) or IPv4 (false) addresses are used. http.proxyHost the host name of the proxy server http.proxyPort the port number, the default value being 80 http.nonProxyHosts a list of hosts that should be reached directly, bypassing the proxy. socksProxyHost the host name of the SOCKS proxy server socksProxyPort the port number, the default value being 1080
115. Why use UDP? Some protocols heavy depend on it (i.e. video and audio transmissions, time transmissions etc.). Always, when there is no need to transfer 100% of data, but to transfer on time.
116. How to use UDP? In configuration file, there are local rule options: option Rule_ID isUDP 1 -> this uses UDP instead of TCP on relay side option Rule_ID streamedUDP 0 -> This creates an “UDP stream” client option Rule_ID streamedUDP 8080 -> This would create an “UDP stream” server, which would be listening to UDP port 8080. “ UDP stream” server UDP mode is similar as “reverse TCP” mode, albeit UDP itself is a connection-less protocol, therefore these modes work similar. It only metters towards the relay side, if other applications need one or another.