i be happy if any of u guys can shed some light to this question. let's say u programming some type of web server to communicate with a client in java or in any other language. take the example of firefox the client downloading a file from a web server. In this case, i have a dynamic ip address and the server most likely has a static ip. here is my question. since my ip is dynamic which changes unexpectly, wouldn't that break the download connection from time to times. how do i solve that problem of reliabilty. let's say i am programming a peer to peer chat program between two computers. how can they establish a constant communication if the ip addresses changes. how do the big boys do it, like skype to handle dynamic ip addresses that may break the connection. how do they handle the problem of dynamic ip when the software establishes connection between two client.
6 replies to this topic
#1
Posted 13 December 2011 - 01:42 AM
|
|
|
#2
Posted 13 December 2011 - 02:01 AM
To me it seems incredibly unlikely to have your ip changing just like that.
On a PC reboot: possible
on a Router reboot: possible
But just while being online? I doubt it.
On a PC reboot: possible
on a Router reboot: possible
But just while being online? I doubt it.
#3
Posted 13 December 2011 - 09:23 AM
You can look at mobile IP for some ideas. You may find more stuff related to wireless mobility but you can extract some ideas from the technologies.
In short you would need to know when the change is going to happen, what is the new IP address and communicate the updates with whom ever you are connected to.
In short you would need to know when the change is going to happen, what is the new IP address and communicate the updates with whom ever you are connected to.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:
#4
Posted 13 December 2011 - 09:32 AM
Some places, the ip can change for no reason.
This is why they invented session.
A cookie based solution to identify you to the server.
Plus you can't identify the user based on the ip, since multiple use can have the same ip
This is why they invented session.
A cookie based solution to identify you to the server.
Plus you can't identify the user based on the ip, since multiple use can have the same ip
#5
Posted 13 December 2011 - 09:44 AM
If it is a simple client server program where you control the client and the server, for example a chat app, you can probably update and re-bridge the connection before any length of time passes. I'm not sure how you would maintain a connection or cause it to behave as though the connection was never broken without fore knowledge and communicating.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:
#6
Posted 13 December 2011 - 10:27 AM
Well there seems to be a lot of exaggeration here regarding terms such as dynamic ip or mobile ip.
First, as mentioned earlier, it is pretty rare that your ip changes suddenly while browsing net. For a general case if this happens your tcp connection is broken and it has to be established again. However, the browser cookies or session existence is also true. But it has limitations.
For e.g. if i had a page opened up on my laptop at office. I hibernated my computer came back home, and switched to my home internet, returned from hibernation and just refresh the page. Will it continue from the place it was. The answer depends....
If it was just a plain unencrypted site with cookies being maintained at your machine and the site allows old cookies, it does continue from the same point.
However, if i was accessing my online bank account, or even gmail through https (which is encrypted using SSL), there is no way it's gonna retain.
If your ip address changes, your existing encryption breaks for instances for SSL or IPsec. Both of them renegotiate keys from the beginning and it is a new connection and session (5 tuple) from there on.
Mobile IP is a way to use existing connections even when your ip changes. A real example is for instance you were using your car wifi for your laptop and then you reached your office and your internet connection changed. Mobile ip provides ways to do the connection HAND OFF. There are limitations and dependencies to what level this can be achieved. For e.g. for an encrypted IPsec VPN, it might just renegotiate one of the two levels of keys (IKE SA and IPSec SA) if your vpn is supporting mobile ip.
If your communication is unencrypted, the HANDOFF is much simpler and more probable.
But even then, there are limitations such as in case of mobile ip, you might specify A POOL of possible ip's that you can change to. So your connection works ONLY if you switch to another one from that pool since you system has knowledge of possible alternate IPs.
Bottom line it is not that frequent to change ip and it is NOT seamless and always possible to do a connection hand off.
Fayyaz
First, as mentioned earlier, it is pretty rare that your ip changes suddenly while browsing net. For a general case if this happens your tcp connection is broken and it has to be established again. However, the browser cookies or session existence is also true. But it has limitations.
For e.g. if i had a page opened up on my laptop at office. I hibernated my computer came back home, and switched to my home internet, returned from hibernation and just refresh the page. Will it continue from the place it was. The answer depends....
If it was just a plain unencrypted site with cookies being maintained at your machine and the site allows old cookies, it does continue from the same point.
However, if i was accessing my online bank account, or even gmail through https (which is encrypted using SSL), there is no way it's gonna retain.
If your ip address changes, your existing encryption breaks for instances for SSL or IPsec. Both of them renegotiate keys from the beginning and it is a new connection and session (5 tuple) from there on.
Mobile IP is a way to use existing connections even when your ip changes. A real example is for instance you were using your car wifi for your laptop and then you reached your office and your internet connection changed. Mobile ip provides ways to do the connection HAND OFF. There are limitations and dependencies to what level this can be achieved. For e.g. for an encrypted IPsec VPN, it might just renegotiate one of the two levels of keys (IKE SA and IPSec SA) if your vpn is supporting mobile ip.
If your communication is unencrypted, the HANDOFF is much simpler and more probable.
But even then, there are limitations such as in case of mobile ip, you might specify A POOL of possible ip's that you can change to. So your connection works ONLY if you switch to another one from that pool since you system has knowledge of possible alternate IPs.
Bottom line it is not that frequent to change ip and it is NOT seamless and always possible to do a connection hand off.
Fayyaz
Today is the first day of the rest of my life
#7
Posted 13 December 2011 - 12:37 PM
semicloud said:
.... let's say i am programming a peer to peer chat program between two computers. how can they establish a constant communication if the ip addresses changes. how do the big boys do it, like skype to handle dynamic ip addresses that may break the connection. how do they handle the problem of dynamic ip when the software establishes connection between two client.
I'll show you a pseudo code of how my program behaves to give you an idea.
Client side IP change:
The GUI component is launch(the main thread)
The clients fills out the necessary info like user name, etc( I did not use any password) and clicks connect to initiate a connection
A Thread is launched (from the main thread) to handle the connection details. We will call it Server_Thread.
Server_Thread sets up the connection and passes the Listening job to a secondary thread. Call it Server_Child
Server_Child has an infinite loop which listens for incoming messages.
I only test for connection failure in Server_Child b/c the loop is infinite and would pick up the connection failure in any case
If the Server_Child encounters a broken connection. I alert the Server_Thread.
The Server_Thread would then dispose of the Child_Server and remake the connection with the new IP address
It does:make an attemp
if unsuccessful sleep wake up try again, 20 times (In hope the new IP would be acquired shortly ).
if successful - repeat from one of the earlier stages. How I tested: I released then renewed the IP address. Ofcourse when the connection broke I disabled half of the buttons on the GUI but usually within 5 to 10 seconds The GUI would be enabled again.
This is not a bullet proof or the best method but I managed to get the client app to regain connection every time the connection was lost without user interaction which is what I wanted.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









