## 3 D2 HCP (Distributed Dynamic Host Configuration Protocol)
### State Diagrams
#### 3.6.2. Client Node  
The procedure that a node that wants to gain access to a network follows is described in Figure 10.  
Figure 9: Server Node State Diagram.  
The diagram is provided with _not_ready_ type states, explained in the state diagram of the server node and represented with the same style of rectangles. As if it were an already configured node, the node that is in process of configuration of its IP address replies to SERVER_DISCOVERY requests with SERVER_OFFER messages. In these messages the value 0 is given to the R field, since the node is not in a position to assign IP addresses, and only tries to announce its presence.  
Figure 10: Client Node State Diagram.  
* _Initial state:_ in which the auto-configuration process begins. If the number of attempts is less than the maximum, SDISCOVERY_MAX_RETRY, then the node emits a SERVER_DISCOVERY message for each of its network interfaces which are going to use the MANET network. It changes its state to Receive SERVER_OFFER. If it has gone over at the limit of attempts, then the node desists from his intention from finding a network to join and creates a new one. It will become a node server, beginning in the IDLE state of the server state diagram.
* _Receive SERVER_OFFER:_ It is treated as a state of waiting, during which the SERVER_OFFER messages of other possible nodes are gathered. On having ended the waiting period, determined by the timer SERVER_DISCOVERY_TIMER, the responses are processed. If no SERVER_OFFER response has been received, it is returned to the initial state. If there is some offers, the number of them with the value 1 in the field R is verified. If among the offers none had the bit R set to 1, it means that there are nearby nodes belonging to a network, but at the moment they are not capable of assigning IP addresses. Therefore, the node passes to the Sleeping state.  
If there was some offer with the bit R set to 1, the servers are sorted by preference and a SERVER_POLL message is sent to the first one of them. In this case the node changes its state to Wait IP_ASSIGNED. This state is not one of the types explained in the state diagram of a client node. This means that it does not reply to SERVER_DISCOVERY messages, since at the moment it does not know if there is any network nearby which to join.  
* _Sleeping:_ The node interrupts its attempts to join the network during the time determined by the SLEEP_TIMER timer. This is like that because there have been received SERVER_OFFER messages of nearby nodes that at the moment are not capable of assigning IP addresses, and what is claimed that after this time they are already capable of facilitating the join to the network. After the timer expires, the node will return to the _initial state_.
* _Wait IP_ASSIGNED:_ In this state, the client is in expectation of an IP_ASSIGNED message on the part of the server to whom the message SERVER_POLL was sent. If the awaited message does not come, the SERVER_POLL_TIMER timer expires. In this case, it will turn to try to send a SERVER_POLL to the following server of the list generated after the end of the SERVER_DISCOVERY_TIMER timer. If the list of servers is ended, or it goes over the limit of attempts SPOLL_MAX_RETRY, the node returns to the initial state. On having received the IP_ASSIGNED message, the node configures its address (or addresses, in case of having several network interfaces). At this moment, it already takes part normally in the network, and passes to be a node server. The state with the one begins its behaviour as server is the _Init time window_.