Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

switch networkconnection without breaking sessions

Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2005, 11:40 AM
Default switch networkconnection without breaking sessions




My laptop has two networkcards (ethernet, wlan). I connect via wlan,
open loads of ssh-session and xterms on other machines and finally come
back to my desk and want to connect via ethernet. So I plug in ethernet
and perform

ifconfig wlan0 down
dhclient eth0

within one second I'm connected to the internet via ethernet, but all my
connections are lost.

What is the trick to keep the sessions alive?

* screen - somehow I never got used to it
* same ip - give the same mac to wlan and ethernet to get the same ip
on both cards and hope this will keep the sessions open. This somehow
doesnt sound smart to me. To networkcards with the same MAC on the same
machine sure pegs for troubles

thnx,
peter


peter pilsl
Reply With Quote
  #2  
Old 07-14-2005, 12:31 PM
Mihai Osian
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions

peter pilsl wrote:

>
> My laptop has two networkcards (ethernet, wlan). I connect via wlan,
> open loads of ssh-session and xterms on other machines and finally
> come back to my desk and want to connect via ethernet. So I plug in
> ethernet and perform
>
> ifconfig wlan0 down
> dhclient eth0
>
> within one second I'm connected to the internet via ethernet, but all
> my connections are lost.
>
> What is the trick to keep the sessions alive?
>
> * screen - somehow I never got used to it


Well, get use to it.

> * same ip - give the same mac to wlan and ethernet to get the same ip
> on both cards and hope this will keep the sessions open. This somehow
> doesnt sound smart to me. To networkcards with the same MAC on the
> same machine sure pegs for troubles
>

It won't work. First of all I'm afraid your TCP connections will be
terminated on "ifconfig down" so there won't be anything to resume.
Second, a TCP/IP session is not all about MAC/IP addresses, it's about
data structures in the kernel (like packet sequence number, transmission
buffers, etc). Forget it, it's not possible.

Mihai

> thnx,
> peter


Reply With Quote
  #3  
Old 07-14-2005, 01:09 PM
peter pilsl
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions

Mihai Osian wrote:
>
> Well, get use to it.
>


NAG last time I tried I ended up with myriads of neverterminating
screensessions on myriads of servers
yep - I know I'm childish and I dont even have access to that many
servers and I know that myriads of other users use screen but I would
prefer a more transparent solution.

>>

> It won't work. First of all I'm afraid your TCP connections will be
> terminated on "ifconfig down" so there won't be anything to resume.
> Second, a TCP/IP session is not all about MAC/IP addresses, it's about
> data structures in the kernel (like packet sequence number, transmission
> buffers, etc). Forget it, it's not possible.
>


I'm sure there is an easy trick. Even now my laptop can roam between
difference accesspoints and does not loose connection. And I can reset
my mainrouter and still dont loose the connections.

I'm thinking about a virtual networkinterface that is used to initiate
the tcp-ip connection and keep tracks off all the tcp/ip-parameters. The
ethernet and wlan-card then is only another hop to the targetserver.
Does this sound realistic or just shows that I dont have too much clue
about the insides of networking.


thnx,
peter

Reply With Quote
  #4  
Old 07-14-2005, 03:14 PM
Dan
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions

On Thu, 14 Jul 2005 14:09:37 +0200, peter pilsl <(E-Mail Removed)>
wrote:

>> I know I'm childish and I dont even have access to that many

>servers and I know that myriads of other users use screen but I would
>prefer a more transparent solution.
>


At the network level:

A tcp connection is defined by four parameters: local ip address,
local port, remote ip address and remote port.

Your wlan and ethernet interfaces are required to have different ip
addresses. One ip address cannot be split between two interfaces.

So when you switch from one adaptor to the other, you get a new ip
address, and your old tcp connections cannot be maintained.

At the applications level:

Your ssh and xterm sessions depend on tcp connectivity. When that
connection is lost, they die. The way to fix it is to re-write ssh
and xterm so that they maintain a session when a tcp connection is
re-established. But I don't think you really want to do that. ;-)


>I'm sure there is an easy trick. Even now my laptop can roam between
>difference accesspoints and does not loose connection.


That's because the four parameters that define a tcp connection
haven't changed. You might have changed the physical location where
the data comes from, but the logical connection remains.

> And I can reset
>my mainrouter and still dont loose the connections.


The tcp connection is maintained logically at either end. That is to
say, both ends are using the same four tcp parameters to define the
connection The ability to transfer data might be temporarily halted,
but the end points don't necessarily know that. When data transfer
resumes, the endpoints carry on where they left off.

>I'm thinking about a virtual networkinterface that is used to initiate
>the tcp-ip connection and keep tracks off all the tcp/ip-parameters. The
>ethernet and wlan-card then is only another hop to the targetserver.
>Does this sound realistic or just shows that I dont have too much clue
>about the insides of networking.


It's an interesting idea. Have a third, virtual interface with it's
own ip address, so the address never changes. Route the packets
through the interface that's up. Your network router would have to
also know about the alternate route. Doesn't sound easy to implement,
though.

Dan

Reply With Quote
  #5  
Old 07-14-2005, 05:26 PM
Mihai Osian
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions

Mihai Osian wrote:
> peter pilsl wrote:
>
>>
>> My laptop has two networkcards (ethernet, wlan). I connect via wlan,
>> open loads of ssh-session and xterms on other machines and finally
>> come back to my desk and want to connect via ethernet. So I plug in
>> ethernet and perform
>>
>> ifconfig wlan0 down
>> dhclient eth0
>>
>> within one second I'm connected to the internet via ethernet, but all
>> my connections are lost.
>>
>> What is the trick to keep the sessions alive?
>>
>> * screen - somehow I never got used to it

>
>
> Well, get use to it.
>
>> * same ip - give the same mac to wlan and ethernet to get the same ip
>> on both cards and hope this will keep the sessions open. This somehow
>> doesnt sound smart to me. To networkcards with the same MAC on the
>> same machine sure pegs for troubles
>>

> It won't work. First of all I'm afraid your TCP connections will be
> terminated on "ifconfig down" so there won't be anything to resume.
> Second, a TCP/IP session is not all about MAC/IP addresses, it's about
> data structures in the kernel (like packet sequence number, transmission
> buffers, etc). Forget it, it's not possible.
>
> Mihai
>
>> thnx,
>> peter

>
>



To correct myself: TCP connections are _not_ terminated by ifconfig
down. So I'm going to shut up now

Mihai
Reply With Quote
  #6  
Old 07-14-2005, 09:58 PM
James Knott
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions

Mihai Osian wrote:

>> * same ip - give the same mac to wlan and ethernet to get the same ip
>> on both cards and hope this will keep the sessions open. This somehow
>> doesnt sound smart to me. To networkcards with the same MAC on the
>> same machine sure pegs for troubles
>>

> It won't work. First of all I'm afraid your TCP connections will be
> terminated on "ifconfig down" so there won't be anything to resume.
> Second, a TCP/IP session is not all about MAC/IP addresses, it's about
> data structures in the kernel (like packet sequence number, transmission
> buffers, etc). Forget it, it's not possible.


Actually, it is, if he uses a VPN. I was doing some experimenting a few
weeks ago. I was able to switch among a few different WLANs, some on
different providers, without losing my VPN. The VPN uses UDP, so it
doesn't care what connection is up at the time and anything going via the
VPN doesn't know about network changes (provided you make the change quick
enough).

Reply With Quote
  #7  
Old 07-14-2005, 09:59 PM
James Knott
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions

peter pilsl wrote:

> I'm sure there is an easy trick. Even now my laptop can roam between
> difference accesspoints and does not loose connection. And I can reset
> my mainrouter and still dont loose the connections.


That's not quite the same thing, as you're not changing interfaces.
Changing access points is more like using different ports on a switch.

Reply With Quote
  #8  
Old 07-14-2005, 10:03 PM
James Knott
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions

Dan wrote:

> It's an interesting idea. Have a third, virtual interface with it's
> own ip address, so the address never changes. Route the packets
> through the interface that's up. Your network router would have to
> also know about the alternate route. Doesn't sound easy to implement,
> though.
>


A VPN perhaps?

Reply With Quote
  #9  
Old 07-15-2005, 12:47 AM
David Schwartz
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions


"Mihai Osian" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...

> It won't work. First of all I'm afraid your TCP connections will be
> terminated on "ifconfig down" so there won't be anything to resume.
> Second, a TCP/IP session is not all about MAC/IP addresses, it's about
> data structures in the kernel (like packet sequence number, transmission
> buffers, etc). Forget it, it's not possible.


If the TCP connections terminate on "ifconfig down", that should be
considered a bug. The loss of an interface should not break TCP connections,
otherwise there'd be little point in having more than one interface. The
(possibly temporary) inability to reach a destination should not break TCP
connections either.

DS


Reply With Quote
  #10  
Old 07-15-2005, 12:49 AM
David Schwartz
Guest
 
Posts: n/a
Default Re: switch networkconnection without breaking sessions


"Dan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> A tcp connection is defined by four parameters: local ip address,
> local port, remote ip address and remote port.


> Your wlan and ethernet interfaces are required to have different ip
> addresses. One ip address cannot be split between two interfaces.


> So when you switch from one adaptor to the other, you get a new ip
> address, and your old tcp connections cannot be maintained.


That's total nonsense. One IP address can certainly be reachable through
multiple interfaces. One can even rig it so that, for example, the IP
address normally reachable through the wlan interface is routed to the
ethernet interface if the wlan interface is not up.

DS


Reply With Quote
Reply

Tags
breaking, networkconnection, sessions, switch

Thread Tools
Display Modes

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
Forum Jump


All times are GMT. The time now is 07:09 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.