Robust implementation of MQX dhcp client (lease renewal) ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Robust implementation of MQX dhcp client (lease renewal) ?

Jump to solution
1,345 Views
robroz
Contributor III

Hi,

I've seen a lot of demo projects that have DHCP client implemented. But I couldn't find answers to following questions :

  1. is DCHP operation only on boot enought for system to be robust to various situations (reconnecting cable, lease timeout, IP gateway failure/restart, ...) ?
  2. is there any example for this or anyone is willing to share code ?

I'm not sure if I get it right, but after successful DHCP, connection should be checked. Probably also when lease expires, it should be queried again, is it ?

So I'm thinking to have separate task only for this matter... Do I get this right or wrong ?

Thanks in advance,

regards,

Bulek.

Labels (1)
Tags (3)
0 Kudos
1 Solution
603 Views
Martin_
NXP Employee
NXP Employee

Hi Bulek,

DHCP client is implemented according to RFC 2132. Thus, its implementation is as robust as defined by the specification.

There are timeout events, I copy&paste below a comment from the /rtcs/source/tcpip/dhcpclnt.c:

There are three timed events which may or may not be active depending on the current state. If we are initializing for the first time, only the RESEND event will be active. Once we have a lease and are in a bound state, the RESEND event is cancelled and the RENEW and TERMINATE events are set.

If we are in a RESENDING state, all three events will be set until we are re-bound. If we are in a REBINDING state, only the RESEND and TERMINATE events will be active.  If we received a DHCPNAK message when renewing or rebinding, we will try to get a new lease starting from the INITIALIZE

state. If the DHCP server does not wish to renew the current lease, then only the TERMINATE event will be set for the remainder of the lease.

View solution in original post

0 Kudos
4 Replies
605 Views
thiagow
Contributor III

Now, in MQX 4.1 version, I need to use DHCP with automatic lease time timeout and automatic renew.       Reading the answers I did'nt understand yet. Does the automatic DHCP renew working on RTCS of MQX 4.1?

0 Kudos
604 Views
Martin_
NXP Employee
NXP Employee

Hi Bulek,

DHCP client is implemented according to RFC 2132. Thus, its implementation is as robust as defined by the specification.

There are timeout events, I copy&paste below a comment from the /rtcs/source/tcpip/dhcpclnt.c:

There are three timed events which may or may not be active depending on the current state. If we are initializing for the first time, only the RESEND event will be active. Once we have a lease and are in a bound state, the RESEND event is cancelled and the RENEW and TERMINATE events are set.

If we are in a RESENDING state, all three events will be set until we are re-bound. If we are in a REBINDING state, only the RESEND and TERMINATE events will be active.  If we received a DHCPNAK message when renewing or rebinding, we will try to get a new lease starting from the INITIALIZE

state. If the DHCP server does not wish to renew the current lease, then only the TERMINATE event will be set for the remainder of the lease.

0 Kudos
605 Views
robroz
Contributor III

Hi,

thanks for response. If I understand right, I have to implement renewal of DHCP address before time lease of previous IP addres expires.

Have two quick questions :

- do I read lease manuall and start another DHCP renewal beffore expiration explicitly or just start periodically some RTCS function that will check time lease and act accordingly (something similar to detection of network cable disconnection) ?

- or if none of above is already implemented and I must setup DHCP server to give static lease to MQX system ?

Thanks in advance,

regards,

Bul.

0 Kudos
605 Views
Martin_
NXP Employee
NXP Employee

I beleive the when DHCP client is initialized for the 1st time, it registers timers with the system. If one of the active timer expires, callback functions change DHCP client state. My understanding is that the DHCP client state transitions, including managing timeouts and doing lease renewals before expiration, is already implemented. Hope this is correct understanding.

0 Kudos