Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > RMI binding to SAME port but DIFFERENT IP address on SAME host

Reply
Thread Tools

RMI binding to SAME port but DIFFERENT IP address on SAME host

 
 
Sam
Guest
Posts: n/a
 
      07-29-2004
Esmond Pitt <(E-Mail Removed)> wrote in message news:<W6FNc.19902$(E-Mail Removed)>...
> Sam
>
> I don't really know what you mean by 'tracks multiple ports per IP',
> which TCP certainly does otherwise nothing would work at all. Maybe you
> mean 'multiple IP addresses per port'? in which case the answer is
> certainly 'yes' as well, hence the ServerSocket constructor I referred
> you to. The local IP address by which incoming data came in is not
> reliable due to the 'weak end system model' described in the RFC, maybe
> this is what you are referring to, but the IP address to which the
> reading socket is bound is always available via Socket.getLocalAddress().
>
> EJP


Esmond,

My thinking was: whatever OS routine is responsible for delivering
payload data to a listening application over a specific port doesn't
need to know what IP address the data came over, it only needs to
deliver it to the correct port. The IP address doesn't even exist at
the transport layer. So to my mind the only the way the requirement
could be achieved was to somehow set up separate ports with the same
port number for each listening interface, which seemed unlikely.

However, what I failed to account for is that Java Sockets speak with
IP at some level, because for example they can specify the remote IP
in the Socket class. So, from there it's not much of a jump to realize
it probably has a way to understand the local IP address, as well.

I'm still unclear as to the mechanics of it, though. I'm pretty sure
that on Windows Jave uses JNI to interact with the WinSock API to
handle it's network functionality. But, my real question is, what
exactly is a "port" anyway, except a numeric label which has a
constraint that it can't be re-used within a single IP address? In the
end, it may be that it's simply a question of processes - the Winsock
API or corresponding OS module probably tracks some internal table
which matches a port to a specific interface, and as long the
combination of the two is different from all other entries in its
table, no problem. In the end, what I thought was "unlikely" is
probably what actually occurs - the OS tracks a separate port for each
interface, or at least has the capability of doing so. (DISCLAIMER:
the preceding is pure speculation...)

Regards,
Sam90
 
Reply With Quote
 
 
 
 
Esmond Pitt
Guest
Posts: n/a
 
      07-29-2004
Sam

IP delivers data via sockets. That's what it does, it can't do anything
else. A socket is identified by its IP address, its port number, and its
protocol number. In the case of TCP, the socket is one end of a
connection whose other end is defined by *its* IP address and port
number. So, for the data to go anywhere at all IP has to know the local
address and port number *first*, i.e. it scans the table of sockets
somehow to find one with the target IP address/port/protocol no.
specified in the incoming IP packet. Then, the data is passed to that
socket, and the local IP address (& port) of any socket can be retrieved
via the Sockets API. This is nothing to do with Java, it all happens at
the IP layer. See W R Stevens 'TCP/IP Illustrated' for details. The only
time Java comes into it is by mapping the Sockets API into methods of
the Socket/ServerSocket classes, e.g. Socket.getLocalXXX().

EJP

Sam wrote:
> Esmond Pitt <(E-Mail Removed)> wrote in message news:<W6FNc.19902$(E-Mail Removed)>...
>
>>Sam
>>
>>I don't really know what you mean by 'tracks multiple ports per IP',
>>which TCP certainly does otherwise nothing would work at all. Maybe you
>>mean 'multiple IP addresses per port'? in which case the answer is
>>certainly 'yes' as well, hence the ServerSocket constructor I referred
>>you to. The local IP address by which incoming data came in is not
>>reliable due to the 'weak end system model' described in the RFC, maybe
>>this is what you are referring to, but the IP address to which the
>>reading socket is bound is always available via Socket.getLocalAddress().
>>
>>EJP

>
>
> Esmond,
>
> My thinking was: whatever OS routine is responsible for delivering
> payload data to a listening application over a specific port doesn't
> need to know what IP address the data came over, it only needs to
> deliver it to the correct port. The IP address doesn't even exist at
> the transport layer. So to my mind the only the way the requirement
> could be achieved was to somehow set up separate ports with the same
> port number for each listening interface, which seemed unlikely.
>
> However, what I failed to account for is that Java Sockets speak with
> IP at some level, because for example they can specify the remote IP
> in the Socket class. So, from there it's not much of a jump to realize
> it probably has a way to understand the local IP address, as well.
>
> I'm still unclear as to the mechanics of it, though. I'm pretty sure
> that on Windows Jave uses JNI to interact with the WinSock API to
> handle it's network functionality. But, my real question is, what
> exactly is a "port" anyway, except a numeric label which has a
> constraint that it can't be re-used within a single IP address? In the
> end, it may be that it's simply a question of processes - the Winsock
> API or corresponding OS module probably tracks some internal table
> which matches a port to a specific interface, and as long the
> combination of the two is different from all other entries in its
> table, no problem. In the end, what I thought was "unlikely" is
> probably what actually occurs - the OS tracks a separate port for each
> interface, or at least has the capability of doing so. (DISCLAIMER:
> the preceding is pure speculation...)
>
> Regards,
> Sam90


 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-29-2004
On Thu, 29 Jul 2004 06:43:46 GMT, Esmond Pitt
<(E-Mail Removed)> wrote or quoted :

>hat's what it does, it can't do anything
>else. A socket is identified by its IP address, its port number, and its
>protocol number.


I'm not sure if that is what you meant to imply, but there is no
"protocol number" field in a TCP/IP header.

see http://mindprod.com/jgloss/tcpip.html

The host computer simply knows which protocol it is hosting on each
port.

You can't have two different protocols hosted on the same port, e.g.
HTTP and FTP.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Esmond Pitt
Guest
Posts: n/a
 
      07-29-2004
Roedy

There is a protocol number field in an IP packet header, and I was
talking about IP at the time. Obviously in the case of TCP the protocol
number is the TCP protocol number, 6. BTW the statement that 'the host
computer simply knows which protocol it is hosting on each port' needs
further work. At the TCP level the host neither knows nor cares about
the protocol; at the IP level you *can* have several protocols on the
same port, e.g. ICMP, UDP, TCP.

EJP

Roedy Green wrote:
> On Thu, 29 Jul 2004 06:43:46 GMT, Esmond Pitt
> <(E-Mail Removed)> wrote or quoted :
>
>
>>hat's what it does, it can't do anything
>>else. A socket is identified by its IP address, its port number, and its
>>protocol number.

>
>
> I'm not sure if that is what you meant to imply, but there is no
> "protocol number" field in a TCP/IP header.
>
> see http://mindprod.com/jgloss/tcpip.html
>
> The host computer simply knows which protocol it is hosting on each
> port.
>
> You can't have two different protocols hosted on the same port, e.g.
> HTTP and FTP.
>


 
Reply With Quote
 
Sam
Guest
Posts: n/a
 
      07-29-2004
Esmond Pitt <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Sam
>
> IP delivers data via sockets. That's what it does, it can't do anything
> else. A socket is identified by its IP address, its port number, and its
> protocol number. In the case of TCP, the socket is one end of a
> connection whose other end is defined by *its* IP address and port
> number. So, for the data to go anywhere at all IP has to know the local
> address and port number *first*, i.e. it scans the table of sockets
> somehow to find one with the target IP address/port/protocol no.


Esmond,

If it does it this processing all in one go based on a single match of
ip address/port, then what's the point of having a layered protocol
stack? i.e, the link layer checks if the mac address is correct for
the current host, and if so passes the data upward to the IP module.
The IP module assures that the packet is intended for the current host
based on its IP address, and if so passes it up to the transport
module - regardless of port. Then the transport module looks for a
listening process on the destination port in its process/port table,
and if it finds one, then it passes the data to that process - if not
listening process is found, an ICMP error message is sent back to the
originating host. Isn't this the fundamental flow of a packet up the
tcp/ip protocol stack? If so, it seems to differ from the process you
describe, which seems to describe a single process for matching
ip/port.

Regards,
Sam90



> specified in the incoming IP packet. Then, the data is passed to that
> socket, and the local IP address (& port) of any socket can be retrieved
> via the Sockets API.





This is nothing to do with Java, it all happens at
> the IP layer. See W R Stevens 'TCP/IP Illustrated' for details. The only
> time Java comes into it is by mapping the Sockets API into methods of
> the Socket/ServerSocket classes, e.g. Socket.getLocalXXX().
>
> EJP
>
> Sam wrote:
> > Esmond Pitt <(E-Mail Removed)> wrote in message news:<W6FNc.19902$(E-Mail Removed)>...
> >
> >>Sam
> >>
> >>I don't really know what you mean by 'tracks multiple ports per IP',
> >>which TCP certainly does otherwise nothing would work at all. Maybe you
> >>mean 'multiple IP addresses per port'? in which case the answer is
> >>certainly 'yes' as well, hence the ServerSocket constructor I referred
> >>you to. The local IP address by which incoming data came in is not
> >>reliable due to the 'weak end system model' described in the RFC, maybe
> >>this is what you are referring to, but the IP address to which the
> >>reading socket is bound is always available via Socket.getLocalAddress().
> >>
> >>EJP

> >
> >
> > Esmond,
> >
> > My thinking was: whatever OS routine is responsible for delivering
> > payload data to a listening application over a specific port doesn't
> > need to know what IP address the data came over, it only needs to
> > deliver it to the correct port. The IP address doesn't even exist at
> > the transport layer. So to my mind the only the way the requirement
> > could be achieved was to somehow set up separate ports with the same
> > port number for each listening interface, which seemed unlikely.
> >
> > However, what I failed to account for is that Java Sockets speak with
> > IP at some level, because for example they can specify the remote IP
> > in the Socket class. So, from there it's not much of a jump to realize
> > it probably has a way to understand the local IP address, as well.
> >
> > I'm still unclear as to the mechanics of it, though. I'm pretty sure
> > that on Windows Jave uses JNI to interact with the WinSock API to
> > handle it's network functionality. But, my real question is, what
> > exactly is a "port" anyway, except a numeric label which has a
> > constraint that it can't be re-used within a single IP address? In the
> > end, it may be that it's simply a question of processes - the Winsock
> > API or corresponding OS module probably tracks some internal table
> > which matches a port to a specific interface, and as long the
> > combination of the two is different from all other entries in its
> > table, no problem. In the end, what I thought was "unlikely" is
> > probably what actually occurs - the OS tracks a separate port for each
> > interface, or at least has the capability of doing so. (DISCLAIMER:
> > the preceding is pure speculation...)
> >
> > Regards,
> > Sam90

 
Reply With Quote
 
Esmond Pitt
Guest
Posts: n/a
 
      07-30-2004
Sam wrote:
>
> If it does it this processing all in one go based on a single match of
> ip address/port,


Sam

If you want to know how TCP works please read the reference I mentioned
before. I didn't say say anything about everything happening in one go,
this is more guesswork on your part. Obviously the data is passed from
the NIC to IP to TCP and obviously lots of processing happens on the
way, but an IP socket is *defined* by its protocol number, an IP
address, and a port number, and these socket attributes are available
all the way up the stack and indeed to the application.

EJP

 
Reply With Quote
 
Sam
Guest
Posts: n/a
 
      07-31-2004
Esmond Pitt <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Sam wrote:
> >
> > If it does it this processing all in one go based on a single match of
> > ip address/port,

>
> Sam
>
> If you want to know how TCP works please read the reference I mentioned
> before. I didn't say say anything about everything happening in one go,
> this is more guesswork on your part. Obviously the data is passed from
> the NIC to IP to TCP and obviously lots of processing happens on the
> way, but an IP socket is *defined* by its protocol number, an IP
> address, and a port number, and these socket attributes are available
> all the way up the stack and indeed to the application.
>
> EJP


EJP,

I'm not convinced what you've been saying is entirely accurate. For
example, you previously mentioned that data doesn't go anywhere unless
there is a socket available. You also state that socket attributes are
available all the way up the stack.

I've just reviewed pp. 19-21 of Steven's TCP Illustrated, Volume II.
He describes the progress of a UDP packet up the protocol stack, from
the hardware interrupt which launches the nic driver, to the passing
of the data by the driver to the IP layer, which in turn passes it to
the UDP input routine.

The first mention of sockets is made in the description of the UDP
input routine. It uses the port on the UDP header to locate a PCB
Control block, and when it finds a match "This will be the PCB created
by our call to socket, and the inp_socket member of this PCB points to
the corresponding socket structure, allowing the received data to be
received by the correct socket". My reading this has the data going
as least as far as the UDP (transport) layer, and no socket available
to the stack until then.

This appears to contradict your assertion about the packets not going
anywhere without a socket - it gets as far as the transport layer -
and about the socket being available throughout the protocol stack -
it's only looked up at the transport layer.

The whole point of the layered architecture is to prevent one layer
from having to contend with data that belongs in another layer, and
that's been cited as one of the main reason for TCP/IP's great
success.

Regards,
Sam90
 
Reply With Quote
 
Tony Morris
Guest
Posts: n/a
 
      07-31-2004
This thread is somewhat difficult to follow, so I'll assume the question is
the typical, "how do I have an RMI server bind to a specific network
interface?"

The answer is you use java.rmi.registry.LocateRegistry, create a
RMIServerSocketFactory that is bound to a specific interface using
java.net.NetworkInterface.

If my assumption is incorrect, please ignore.

--
Tony Morris
http://xdweb.net/~dibblego/


 
Reply With Quote
 
Esmond Pitt
Guest
Posts: n/a
 
      08-02-2004
Sam

OK, if UDP or TCP or ICMP or whatever transport layer matches the socket
to the inbound IP packet, instead of IP, the local IP address *still*
doesn't get 'thrown away as the data goes up the protocol stack',
because it must still be there in the IP packet for TCP or UDP to do
this matching, and it must also available be in the socket descriptor to
be matched. Can we agree on that?

This also means that TCP, UDP, ICMP &c do indeed deal with IP data, &
just goes to show that TCP/IP implementation layering is not as clean as
you might like to think. Certainly IP doesn't have to deal with TCP
data, but the other way round does happen (no worse than a derived class
using methods from its base class really).

Of course Stevens vol II only describes one implementation. I don't know
that a 'cleaner' implementation where IP despatches packets to sockets
is infeasible either ... What *would* be infeasible is the
implementation you seem to keep imagining where TCP can't access the IP
header or the local IP address: otherwise the OP's situation wouldn't
work, and it does; also Socket.getLocalAddress() == getsockname()
couldn't work either.

Anyway basta cosi.

EJP

 
Reply With Quote
 
Esmond Pitt
Guest
Posts: n/a
 
      08-02-2004
Tony Morris wrote:

> This thread is somewhat difficult to follow, so I'll assume the question is
> the typical, "how do I have an RMI server bind to a specific network
> interface?"
>
> The answer is you use java.rmi.registry.LocateRegistry, create a
> RMIServerSocketFactory that is bound to a specific interface using
> java.net.NetworkInterface.
>
> If my assumption is incorrect, please ignore.


That works for the registry itself, but for specific RMI servers you
also have to provide *them* with a ServerSocketFactory, probably the
same one, and you have to use the appropriate IP address or interface
name when binding them to the registry.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RMI host binding question G Java 2 06-18-2007 02:08 PM
start a multi-sockets server (a socket/per thread) with different ports but same host zxo102 Python 5 08-15-2006 08:37 AM
Cisco PIX 501 - Port forwarded to an internal host via Static NAT doesn't work from internal host JoelSeph Cisco 9 01-23-2006 03:52 PM
Running RMI Server on Different Port - binding issues andy.troutman@gmail.com Java 1 07-28-2005 07:20 AM
Socket Send and Receive, Same local port, Different Remote Port jeffburgoon@hotmail.com Perl Misc 1 03-02-2005 08:54 AM



Advertisments