Hi,
I've seen a lot of demo projects that have DHCP client implemented. But I couldn't find answers to following questions :
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.
Solved! Go to Solution.
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.
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?
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.
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.
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.