lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] LwIP Support - sethostaddr


From: wurzel
Subject: Re: [lwip-users] LwIP Support - sethostaddr
Date: Fri, 9 Sep 2011 14:08:12 -0700

Enrico Murador wrote:
> I am also not so aware of what happens exactly (when IP addr 
> change is made) to alive TCP connections, but with 
> (connectionless) UDP I think there should be less problems...

In TCP/IP, Hosts uniquely identify a connection using a "5-tuple":
        (source IP, dest IP, src port, dst port, protocol (UDP,TCP,etc))

So, if you change the IP address of your host on the fly, the
remote TCP peer will not recognize the packets you send it
(source IP no longer matches) and will probably send TCP RST
packets immediately.  Likewise, if the remote end tries to send
data to you, that will have the wrong dest IP addr and you'll 
never see it.  This is an aspect of TCP in general and not lwip 
specific.

As you said, connectionless (UDP) transfers could continue to work
fine as long as you have some way to let any remote transmitters know
of your new IP address.  If they keep sending to the old (now incorrect)
address then again the packets will be filtered out (or, after an ARP
timeout, the remote end won't even be able to resolve your MAC/IP
association).

As an aside, typically when IP addresses are changing or moving,
it's common to do a "gratuitious ARP" so that ARP tables are refreshed
with the new data.

So, the net is you'll need to
- Close all open TCP connections, preferrably waiting for all of them
  to completely FIN (close) for cleanliness, but also with some kind
  of a timeout so you don't wait forever in the case the remote end has
  gone away.

- Change the IP address.

- Open new connections as needed.

                                                                        -wurzel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]