## 3 D2 HCP (Distributed Dynamic Host Configuration Protocol)
### State Diagrams
#### 3.6.1 Server Node  
We call all the nodes in the network that are configured correctly server nodes, that is to say, they possess a valid IP address with which they can communicate with the rest of nodes, and a free IP address block. With this free address block they facilitate access to the new nodes, which we will call clients. Figure 9 shows the state diagram. As we can see, two types of states exist: the ones represented with rounded and clear rectangles, and those enclosed in somewhat darker rectangles with corners. We will call them states of the type _ready_ or _not_ready_, respectively. From any state, the server node is in expectation of SERVER_DISCOVERY messages. It will always reply with a SERVER_OFFER message, but depending on whether the current state of the node is of _ready_ or _not_ready_ type, it will answer giving to the field R (READY) the value 1 or 0. This way, a node always announces its presence, although at this precise moment it should not be capable of assigning IP addresses to a client. This is indicated in the state diagram with the any state state. * _Any state (ready):_ From any state of ready type, the server node will respond to a SERVER_DISCOVERY message with one of SERVER_OFFER type (R field with value 1). That will ensure that the server goes to the state Wait SERVER_POLL. A node can reply SERVER_DISCOVERY at the same time to requests from different nodes, and be awaiting any of the corresponding SERVER_POLL messages. Also they will answer messages of type IP_RANGE_REQUEST with one of the type IP_RANGE_RETURN. This means that whether the node is in any ready state, it will be give half of its free address blocks to any other node in the network without proper addresses and that it needs to facilitate the joining to a client. * _Any state (not_ready):_ Whilst the node is in a _not_ready_ state, it will reply to the SERVER_DISCOVERY messages with a SERVER_OFFER message giving the value 0 to the field R.
* _Wait SERVER_POLL:_ In this state the node waits for a time determined by the SERVER_OFFER_TIMER timer to receive a SERVER_POLL message. This message indicates that the client, the one who sent the SERVER_OFFER has chosen as its server for the process of auto-configuration. After the reception of the message, the node will send a IP_ASSIGNED message to the client in the case of having available addresses locally (the field L of the message SERVER_OFFER had value 1); and it will pass to the Wait IP_Assigned state resolve. If the addresses that it offered were not local, it will have to ask for them from a node in the network with the IP_RANGE_REQUEST message; and it will pass into the state Wait IP_RReturn. In case any SERVER_OFFER messages are not received before the timer expires, the node will pass to be in the IDLE state. * _Wait IP_ASSIGNED resolved:_ In this state, of type not_ready, the node is waiting to find out if the client node correctly received the address block offered by an IP_ASSIGNED message, or through an IP_RANGE_RETURN message and an intermediary. The result can be that the client has been configured, or that it has not received the address block. The above-mentioned can take place for several reasons, since they can be problems with interferences in the message reception, movement of the client node out of the coverage range, and so on. If a new node appears in the network using the first IP address from the block offered in the message IP_ASSIGNED or IP_RANGE_RETURN, it means that the client node stopped being configured. In this moment the server node changes its state _to Init steal window_. If the node was not capable of finishing the auto-configuration process, the ACCEPTED_OFFER_TIMER timer will expire. In this case the node passes to the IDLE state. * _Init time window:_ This state serves to give a time margin that allows all the nodes in the network to be capable of detecting the joining of the recently configured client, before dividing again their own IP free address blocks.