Binding the same port number on different interfaces

Hi,

We can use the same port number for two applications based on protocols.(i.e one application is based on TCP and the other application based on UDP).

But i don't know about interfaces, can anyone one help........

1) Can we use same port number for different applications on a single interface.

2) Can we use same port number for different applications on different interfaces(interfaces have separate ip address).


Consider that same port number can be used on different applications, then won,t it be a problem in receiving the packets.

Applications using UDP protocol.
--------------------------------

1) Application 1 is binded to the port number 1500 and ip address of an interface.(Transfer the packet through the selected interface).

2) Application 2 is binded to the port number 1500 and ip address is 0.0.0.0

Now, inorder to transfer the packet of Application 2 an interface has to be selected based on destination's ip address.

If application 2 want's to transfer packets with different destination ip adresses, then different interfaces will be selected for different interfaces.(so application 2 may transfer packet through any one of the available interface and where as application 1 will transfer through the specific interface).

--->After receiving the packet, how should i select the socket of application 1 and application 2.

Problem is both sockets are binded to same port number and interface on which application 2 is transferring the packets are not fixed.
 
vijaypdp2006 said:
We can use the same port number for two applications based on protocols.(i.e one application is based on TCP and the other application based on UDP).

But i don't know about interfaces, can anyone one help........

1) Can we use same port number for different applications on a single interface.
Only one service can listen on a given UDP or TCP port on a given IP address.

2) Can we use same port number for different applications on different interfaces(interfaces have separate ip address).
This is possible. It doesn't necessarily have to be on a different interface, as long as the IP address is different.


Consider that same port number can be used on different applications, then won,t it be a problem in receiving the packets.
Which is why you cannot bind more then one service on a given IP:port combination.

1) Application 1 is binded to the port number 1500 and ip address of an interface.(Transfer the packet through the selected interface).

2) Application 2 is binded to the port number 1500 and ip address is 0.0.0.0
Application 2 will be bound to all interfaces and IP addresses. It cannot bind to the IP:port that's in use by application 1 though.
 
Hi all,

Thanks for your reply.

I have some doubts in selecting the interface to transfer packets and receive the packets.

--> Multiple interfaces :
--------------------

1) 0.0.0.0 --------> wild card address.
2) x.x.x.x --------> valid address.(192.168.1.156)
3) ff.ff.ff.ff --------> broad cast address.


1) If an socket is binded to 0.0.0.0 and its destination ip address is ff.ff.ff.ff

In order to transfer a packet, the packet should be transferred through all interfaces.(broadcasetd).

2) If an socket is binded to 0.0.0.0 and its destination ip address is x.x.x.x

Based on destination ip address an inetrface will be selected to transfer the packet.

Before receiving the packets, the selected interface is closed.
Now the received packets consists of destination ip address as closed interfaces ip address. Whether the received packets are valid or not.


Thanks in advance.........
 
vijaypdp2006 said:
Before receiving the packets, the selected interface is closed.
Now the received packets consists of destination ip address as closed interfaces ip address. Whether the received packets are valid or not.
You don't need to open a port in LISTEN, to receive the reply.
 
Could anyone explain the scenarios for transfer and receiving the packets. For given below example.

1) If an socket is binded to 0.0.0.0 and its destination ip address is ff.ff.ff.ff

In order to transfer a packet, the packet should be transferred through all interfaces.(broadcasetd).
 
vijaypdp2006 said:
1) If an socket is binded to 0.0.0.0 and its destination ip address is ff.ff.ff.ff

In order to transfer a packet, the packet should be transferred through all interfaces.(broadcasetd).

There isn't much more you should be concerned about. When programming something like this you would use 0.0.0.0 as a source address and 255.255.255.255 as a destination address. The system will take care of the rest.

http://www.csc.villanova.edu/~mdamian/Sockets/TcpSockets.htm
 
Thanks for replying....

I want to know exactly how tcp/ip stack will handle this case
--> if an socket is binded to 0.0.0.0 and its destination ip address is ff.ff.ff.ff

In order to transfer a packet, the packet should be transferred through all interfaces.(broadcasetd). The packet has to be transferred through interface 1 , interface 2 ....etc.,(through all interfaces)
 
Back
Top