Section 4. Specification of the DHCP client-server protocol

In this section, we assume that a DHCP server has a block of network
   addresses from which it can satisfy requests for new addresses.  Each
   server also maintains a database of allocated addresses and leases in
   local permanent storage.
4.1 Constructing and sending DHCP messages
   DHCP clients and servers both construct DHCP messages by filling in
   fields in the fixed format section of the message and appending
   tagged data items in the variable length option area.  The options
   area includes first a four-octet 'magic cookie' (which was described
   in section 3), followed by the options.  The last option must always
   be the 'end' option.
   DHCP uses UDP as its transport protocol.  DHCP messages from a client
   to a server are sent to the 'DHCP server' port (67), and DHCP
   messages from a server to a client are sent to the 'DHCP client' port
   (68). A server with multiple network address (e.g., a multi-homed
   host) MAY use any of its network addresses in outgoing DHCP messages.
   The 'server identifier' field is used both to identify a DHCP server
   in a DHCP message and as a destination address from clients to
   servers.  A server with multiple network addresses MUST be prepared
   to to accept any of its network addresses as identifying that server
   in a DHCP message.  To accommodate potentially incomplete network
   connectivity, a server MUST choose an address as a 'server
   identifier' that, to the best of the server's knowledge, is reachable
   from the client.  For example, if the DHCP server and the DHCP client
   are connected to the same subnet (i.e., the 'giaddr' field in the
   message from the client is zero), the server SHOULD select the IP
   address the server is using for communication on that subnet as the
   'server identifier'.  If the server is using multiple IP addresses on
   that subnet, any such address may be used.  If the server has
   received a message through a DHCP relay agent, the server SHOULD
   choose an address from the interface on which the message was
   recieved as the 'server identifier' (unless the server has other,
   better information on which to make its choice).  DHCP clients MUST
   use the IP address provided in the 'server identifier' option for any
   unicast requests to the DHCP server.
   DHCP messages broadcast by a client prior to that client obtaining
   its IP address must have the source address field in the IP header
   set to 0.
   If the 'giaddr' field in a DHCP message from a client is non-zero,
   the server sends any return messages to the 'DHCP server' port on the
   BOOTP relay agent whose address appears in 'giaddr'. If the 'giaddr'
   field is zero and the 'ciaddr' field is nonzero, then the server
   unicasts DHCPOFFER and DHCPACK messages to the address in 'ciaddr'.
   If 'giaddr' is zero and 'ciaddr' is zero, and the broadcast bit is
   set, then the server broadcasts DHCPOFFER and DHCPACK messages to
   0xffffffff. If the broadcast bit is not set and 'giaddr' is zero and
   'ciaddr' is zero, then the server unicasts DHCPOFFER and DHCPACK
   messages to the client's hardware address and 'yiaddr' address.  In
   all cases, when 'giaddr' is zero, the server broadcasts any DHCPNAK
   messages to 0xffffffff.
   If the options in a DHCP message extend into the 'sname' and 'file'
   fields, the 'option overload' option MUST appear in the 'options'
   field, with value 1, 2 or 3, as specified in RFC 1533.  If the
   'option overload' option is present in the 'options' field, the
   options in the 'options' field MUST be terminated by an 'end' option,
   and MAY contain one or more 'pad' options to fill the options field.
   The options in the 'sname' and 'file' fields (if in use as indicated
   by the 'options overload' option) MUST begin with the first octet of
   the field, MUST be terminated by an 'end' option, and MUST be
   followed by 'pad' options to fill the remainder of the field.  Any
   individual option in the 'options', 'sname' and 'file' fields MUST be
   entirely contained in that field.  The options in the 'options' field
   MUST be interpreted first, so that any 'option overload' options may
   be interpreted.  The 'file' field MUST be interpreted next (if the
   'option overload' option indicates that the 'file' field contains
   DHCP options), followed by the 'sname' field.
   The values to be passed in an 'option' tag may be too long to fit in
   the 255 octets available to a single option (e.g., a list of routers
   in a 'router' option [21]).  Options may appear only once, unless
   otherwise specified in the options document.  The client concatenates
   the values of multiple instances of the same option into a single
   parameter list for configuration.
   DHCP clients are responsible for all message retransmission.  The
   client MUST adopt a retransmission strategy that incorporates a
   randomized exponential backoff algorithm to determine the delay
   between retransmissions.  The delay between retransmissions SHOULD be
   chosen to allow sufficient time for replies from the server to be
   delivered based on the characteristics of the internetwork between
   the client and the server.  For example, in a 10Mb/sec Ethernet
   internetwork, the delay before the first retransmission SHOULD be 4
   seconds randomized by the value of a uniform random number chosen
   from the range -1 to +1.  Clients with clocks that provide resolution
   granularity of less than one second may choose a non-integer
   randomization value.  The delay before the next retransmission SHOULD
   be 8 seconds randomized by the value of a uniform number chosen from
   the range -1 to +1.  The retransmission delay SHOULD be doubled with
   subsequent retransmissions up to a maximum of 64 seconds.  The client
   MAY provide an indication of retransmission attempts to the user as
   an indication of the progress of the configuration process.
   The 'xid' field is used by the client to match incoming DHCP messages
   with pending requests.  A DHCP client MUST choose 'xid's in such a
   way as to minimize the chance of using an 'xid' identical to one used
   by another client. For example, a client may choose a different,
   random initial 'xid' each time the client is rebooted, and
   subsequently use sequential 'xid's until the next reboot.  Selecting
   a new 'xid' for each retransmission is an implementation decision.  A
   client may choose to reuse the same 'xid' or select a new 'xid' for
   each retransmitted message.
   Normally, DHCP servers and BOOTP relay agents attempt to deliver
   DHCPOFFER, DHCPACK and DHCPNAK messages directly to the client using
   uicast delivery.  The IP destination address (in the IP header) is
   set to the DHCP 'yiaddr' address and the link-layer destination
   address is set to the DHCP 'chaddr' address.  Unfortunately, some
   client implementations are unable to receive such unicast IP
   datagrams until the implementation has been configured with a valid
   IP address (leading to a deadlock in which the client's IP address
   cannot be delivered until the client has been configured with an IP
   address).
   A client that cannot receive unicast IP datagrams until its protocol
   software has been configured with an IP address SHOULD set the
   BROADCAST bit in the 'flags' field to 1 in any DHCPDISCOVER or
   DHCPREQUEST messages that client sends.  The BROADCAST bit will
   provide a hint to the DHCP server and BOOTP relay agent to broadcast
   any messages to the client on the client's subnet.  A client that can
   receive unicast IP datagrams before its protocol software has been
   configured SHOULD clear the BROADCAST bit to 0.  The BOOTP
   clarifications document discusses the ramifications of the use of the
   BROADCAST bit [21].
   A server or relay agent sending or relaying a DHCP message directly
   to a DHCP client (i.e., not to a relay agent specified in the
   'giaddr' field) SHOULD examine the BROADCAST bit in the 'flags'
   field.  If this bit is set to 1, the DHCP message SHOULD be sent as
   an IP broadcast using an IP broadcast address (preferably 0xffffffff)
   as the IP destination address and the link-layer broadcast address as
   the link-layer destination address.  If the BROADCAST bit is cleared
   to 0, the message SHOULD be sent as an IP unicast to the IP address
   specified in the 'yiaddr' field and the link-layer address specified
   in the 'chaddr' field.  If unicasting is not possible, the message
   MAY be sent as an IP broadcast using an IP broadcast address
   (preferably 0xffffffff) as the IP destination address and the link-
   layer broadcast address as the link-layer destination address.
4.2 DHCP server administrative controls
   DHCP servers are not required to respond to every DHCPDISCOVER and
   DHCPREQUEST message they receive.  For example, a network
   administrator, to retain stringent control over the clients attached
   to the network, may choose to configure DHCP servers to respond only
   to clients that have been previously registered through some external
   mechanism.  The DHCP specification describes only the interactions
   between clients and servers when the clients and servers choose to
   interact; it is beyond the scope of the DHCP specification to
   describe all of the administrative controls that system
   administrators might want to use.  Specific DHCP server
   implementations may incorporate any controls or policies desired by a
   network administrator.
   In some environments, a DHCP server will have to consider the values
   of the vendor class options included in DHCPDISCOVER or DHCPREQUEST
   messages when determining the correct parameters for a particular
   client.
   A DHCP server needs to use some unique identifier to associate a
   client with its lease.  The client MAY choose to explicitly provide
   the identifier through the 'client identifier' option.  If the client
   supplies a 'client identifier', the client MUST use the same 'client
   identifier' in all subsequent messages, and the server MUST use that
   identifier to identify the client.  If the client does not provide a
   'client identifier' option, the server MUST use the contents of the
   'chaddr' field to identify the client. It is crucial for a DHCP
   client to use an identifier unique within the subnet to which the
   client is attached in the 'client identifier' option.  Use of
   'chaddr' as the client's unique identifier may cause unexpected
   results, as that identifier may be associated with a hardware
   interface that could be moved to a new client.  Some sites may choose
   to use a manufacturer's serial number as the 'client identifier', to
   avoid unexpected changes in a clients network address due to transfer
   of hardware interfaces among computers.  Sites may also choose to use
   a DNS name as the 'client identifier', causing address leases to be
   associated with the DNS name rather than a specific hardware box.
   DHCP clients are free to use any strategy in selecting a DHCP server
   among those from which the client receives a DHCPOFFER message.  The
   client implementation of DHCP SHOULD provide a mechanism for the user
   to select directly the 'vendor class identifier' values.
4.3 DHCP server behavior
   A DHCP server processes incoming DHCP messages from a client based on
   the current state of the binding for that client.  A DHCP server can
   receive the following messages from a client:
      o DHCPDISCOVER
      o DHCPREQUEST
      o DHCPDECLINE
      o DHCPRELEASE
      o DHCPINFORM
   Table 3 gives the use of the fields and options in a DHCP message by
   a server.  The remainder of this section describes the action of the
   DHCP server for each possible incoming message.
4.3.1 DHCPDISCOVER message
   When a server receives a DHCPDISCOVER message from a client, the
   server chooses a network address for the requesting client.  If no
   address is available, the server may choose to report the problem to
   the system administrator. If an address is available, the new address
   SHOULD be chosen as follows:
      o The client's current address as recorded in the client's current
        binding, ELSE
      o The client's previous address as recorded in the client's (now
        expired or released) binding, if that address is in the server's
        pool of available addresses and not already allocated, ELSE
      o The address requested in the 'Requested IP Address' option, if that
        address is valid and not already allocated, ELSE
      o A new address allocated from the server's pool of available
        addresses; the address is selected based on the subnet from which
        the message was received (if 'giaddr' is 0) or on the address of
        the relay agent that forwarded the message ('giaddr' when not 0).
   As described in section 4.2, a server MAY, for administrative
   reasons, assign an address other than the one requested, or may
   refuse to allocate an address to a particular client even though free
   addresses are available.
   Note that, in some network architectures (e.g., internets with more
   than one IP subnet assigned to a physical network segment), it may be
   the case that the DHCP client should be assigned an address from a
   different subnet than the address recorded in 'giaddr'.  Thus, DHCP
   does not require that the client be assigned as address from the
   subnet in 'giaddr'.  A server is free to choose some other subnet,
   and it is beyond the scope of the DHCP specification to describe ways
   in which the assigned IP address might be chosen.
   While not required for correct operation of DHCP, the server SHOULD
   NOT reuse the selected network address before the client responds to
   the server's DHCPOFFER message.  The server may choose to record the
   address as offered to the client.
   The server must also choose an expiration time for the lease, as
   follows:
   o IF the client has not requested a specific lease in the
     DHCPDISCOVER message and the client already has an assigned network
     address, the server returns the lease expiration time previously
     assigned to that address (note that the client must explicitly
     request a specific lease to extend the expiration time on a
     previously assigned address), ELSE
   o IF the client has not requested a specific lease in the
     DHCPDISCOVER message and the client does not have an assigned
     network address, the server assigns a locally configured default
     lease time, ELSE
   o IF the client has requested a specific lease in the DHCPDISCOVER
     message (regardless of whether the client has an assigned network
     address), the server may choose either to return the requested
     lease (if the lease is acceptable to local policy) or select
     another lease.
Field      DHCPOFFER            DHCPACK             DHCPNAK
-----      ---------            -------             -------
'op'       BOOTREPLY            BOOTREPLY           BOOTREPLY
'htype'    (From "Assigned Numbers" RFC)
'hlen'     (Hardware address length in octets)
'hops'     0                    0                   0
'xid'      'xid' from client    'xid' from client   'xid' from client
           DHCPDISCOVER         DHCPREQUEST         DHCPREQUEST
           message              message             message
'secs'     0                    0                   0
'ciaddr'   0                    'ciaddr' from       0
                                DHCPREQUEST or 0
'yiaddr'   IP address offered   IP address          0
           to client            assigned to client
'siaddr'   IP address of next   IP address of next  0
           bootstrap server     bootstrap server
'flags'    'flags' from         'flags' from        'flags' from
           client DHCPDISCOVER  client DHCPREQUEST  client DHCPREQUEST
           message              message             message
'giaddr'   'giaddr' from        'giaddr' from       'giaddr' from
           client DHCPDISCOVER  client DHCPREQUEST  client DHCPREQUEST
           message              message             message
'chaddr'   'chaddr' from        'chaddr' from       'chaddr' from
           client DHCPDISCOVER  client DHCPREQUEST  client DHCPREQUEST
           message              message             message
'sname'    Server host name     Server host name    (unused)
           or options           or options
'file'     Client boot file     Client boot file    (unused)
           name or options      name or options
'options'  options              options
Option                    DHCPOFFER    DHCPACK            DHCPNAK
------                    ---------    -------            -------
Requested IP address      MUST NOT     MUST NOT           MUST NOT
IP address lease time     MUST         MUST (DHCPREQUEST) MUST NOT
                                       MUST NOT (DHCPINFORM)
Use 'file'/'sname' fields MAY          MAY                MUST NOT
DHCP message type         DHCPOFFER    DHCPACK            DHCPNAK
Parameter request list    MUST NOT     MUST NOT           MUST NOT
Message                   SHOULD       SHOULD             SHOULD
Client identifier         MUST NOT     MUST NOT           MAY
Vendor class identifier   MAY          MAY                MAY
Server identifier         MUST         MUST               MUST
Maximum message size      MUST NOT     MUST NOT           MUST NOT
All others                MAY          MAY                MUST NOT
           Table 3:  Fields and options used by DHCP servers
   Once the network address and lease have been determined, the server
   constructs a DHCPOFFER message with the offered configuration
   parameters.  It is important for all DHCP servers to return the same
   parameters (with the possible exception of a newly allocated network
   address) to ensure predictable client behavior regardless of which
   server the client selects.  The configuration parameters MUST be
   selected by applying the following rules in the order given below.
   The network administrator is responsible for configuring multiple
   DHCP servers to ensure uniform responses from those servers.  The
   server MUST return to the client:
   o The client's network address, as determined by the rules given
     earlier in this section,
   o The expiration time for the client's lease, as determined by the
     rules given earlier in this section,
   o Parameters requested by the client, according to the following
     rules:
        -- IF the server has been explicitly configured with a default
           value for the parameter, the server MUST include that value
           in an appropriate option in the 'option' field, ELSE
        -- IF the server recognizes the parameter as a parameter
           defined in the Host Requirements Document, the server MUST
           include the default value for that parameter as given in the
           Host Requirements Document in an appropriate option in the
           'option' field, ELSE
        -- The server MUST NOT return a value for that parameter,
     The server MUST supply as many of the requested parameters as
     possible and MUST omit any parameters it cannot provide.  The
     server MUST include each requested parameter only once unless
     explicitly allowed in the DHCP Options and BOOTP Vendor
     Extensions document.
   o Any parameters from the existing binding that differ from the Host
     Requirements Document defaults,
   o Any parameters specific to this client (as identified by
     the contents of 'chaddr' or 'client identifier' in the DHCPDISCOVER
     or DHCPREQUEST message), e.g., as configured by the network
     administrator,
   o Any parameters specific to this client's class (as identified
     by the contents of the 'vendor class identifier'
     option in the DHCPDISCOVER or DHCPREQUEST message),
     e.g., as configured by the network administrator; the parameters
     MUST be identified by an exact match between the client's vendor
     class identifiers and the client's classes identified in the
     server,
   o Parameters with non-default values on the client's subnet.
   The server MAY choose to return the 'vendor class identifier' used to
   determine the parameters in the DHCPOFFER message to assist the
   client in selecting which DHCPOFFER to accept.  The server inserts
   the 'xid' field from the DHCPDISCOVER message into the 'xid' field of
   the DHCPOFFER message and sends the DHCPOFFER message to the
   requesting client.
4.3.2 DHCPREQUEST message
   A DHCPREQUEST message may come from a client responding to a
   DHCPOFFER message from a server, from a client verifying a previously
   allocated IP address or from a client extending the lease on a
   network address.  If the DHCPREQUEST message contains a 'server
   identifier' option, the message is in response to a DHCPOFFER
   message.  Otherwise, the message is a request to verify or extend an
   existing lease.  If the client uses a 'client identifier' in a
   DHCPREQUEST message, it MUST use that same 'client identifier' in all
   subsequent messages. If the client included a list of requested
   parameters in a DHCPDISCOVER message, it MUST include that list in
   all subsequent messages.
   Any configuration parameters in the DHCPACK message SHOULD NOT
   conflict with those in the earlier DHCPOFFER message to which the
   client is responding.  The client SHOULD use the parameters in the
   DHCPACK message for configuration.
   Clients send DHCPREQUEST messages as follows:
   o DHCPREQUEST generated during SELECTING state:
      Client inserts the address of the selected server in 'server
      identifier', 'ciaddr' MUST be zero, 'requested IP address' MUST be
      filled in with the yiaddr value from the chosen DHCPOFFER.
      Note that the client may choose to collect several DHCPOFFER
      messages and select the "best" offer.  The client indicates its
      selection by identifying the offering server in the DHCPREQUEST
      message.  If the client receives no acceptable offers, the client
      may choose to try another DHCPDISCOVER message.  Therefore, the
      servers may not receive a specific DHCPREQUEST from which they can
      decide whether or not the client has accepted the offer.  Because
      the servers have not committed any network address assignments on
      the basis of a DHCPOFFER, servers are free to reuse offered
      network addresses in response to subsequent requests.  As an
      implementation detail, servers SHOULD NOT reuse offered addresses
      and may use an implementation-specific timeout mechanism to decide
      when to reuse an offered address.
   o DHCPREQUEST generated during INIT-REBOOT state:
      'server identifier' MUST NOT be filled in, 'requested IP address'
      option MUST be filled in with client's notion of its previously
      assigned address. 'ciaddr' MUST be zero. The client is seeking to
      verify a previously allocated, cached configuration. Server SHOULD
      send a DHCPNAK message to the client if the 'requested IP address'
      is incorrect, or is on the wrong network.
      Determining whether a client in the INIT-REBOOT state is on the
      correct network is done by examining the contents of 'giaddr', the
      'requested IP address' option, and a database lookup. If the DHCP
      server detects that the client is on the wrong net (i.e., the
      result of applying the local subnet mask or remote subnet mask (if
      'giaddr' is not zero) to 'requested IP address' option value
      doesn't match reality), then the server SHOULD send a DHCPNAK
      message to the client.
      If the network is correct, then the DHCP server should check if
      the client's notion of its IP address is correct. If not, then the
      server SHOULD send a DHCPNAK message to the client. If the DHCP
      server has no record of this client, then it MUST remain silent,
      and MAY output a warning to the network administrator. This
      behavior is necessary for peaceful coexistence of non-
      communicating DHCP servers on the same wire.
      If 'giaddr' is 0x0 in the DHCPREQUEST message, the client is on
      the same subnet as the server.  The server MUST broadcast the
      DHCPNAK message to the 0xffffffff broadcast address because the
      client may not have a correct network address or subnet mask, and
      the client may not be answering ARP requests.
      If 'giaddr' is set in the DHCPREQUEST message, the client is on a
      different subnet.  The server MUST set the broadcast bit in the
      DHCPNAK, so that the relay agent will broadcast the DHCPNAK to the
      client, because the client may not have a correct network address
      or subnet mask, and the client may not be answering ARP requests.
   o DHCPREQUEST generated during RENEWING state:
      'server identifier' MUST NOT be filled in, 'requested IP address'
      option MUST NOT be filled in, 'ciaddr' MUST be filled in with
      client's IP address. In this situation, the client is completely
      configured, and is trying to extend its lease. This message will
      be unicast, so no relay agents will be involved in its
      transmission.  Because 'giaddr' is therefore not filled in, the
      DHCP server will trust the value in 'ciaddr', and use it when
      replying to the client.
      A client MAY choose to renew or extend its lease prior to T1.  The
      server may choose not to extend the lease (as a policy decision by
      the network administrator), but should return a DHCPACK message
      regardless.
   o DHCPREQUEST generated during REBINDING state:
      'server identifier' MUST NOT be filled in, 'requested IP address'
      option MUST NOT be filled in, 'ciaddr' MUST be filled in with
      client's IP address. In this situation, the client is completely
      configured, and is trying to extend its lease. This message MUST
      be broadcast to the 0xffffffff IP broadcast address.  The DHCP
      server SHOULD check 'ciaddr' for correctness before replying to
      the DHCPREQUEST.
      The DHCPREQUEST from a REBINDING client is intended to accommodate
      sites that have multiple DHCP servers and a mechanism for
      maintaining consistency among leases managed by multiple servers.
      A DHCP server MAY extend a client's lease only if it has local
      administrative authority to do so.
4.3.3 DHCPDECLINE message
   If the server receives a DHCPDECLINE message, the client has
   discovered through some other means that the suggested network
   address is already in use.  The server MUST mark the network address
   as not available and SHOULD notify the local system administrator of
   a possible configuration problem.
4.3.4 DHCPRELEASE message
   Upon receipt of a DHCPRELEASE message, the server marks the network
   address as not allocated.  The server SHOULD retain a record of the
   client's initialization parameters for possible reuse in response to
   subsequent requests from the client.
4.3.5 DHCPINFORM message
   The server responds to a DHCPINFORM message by sending a DHCPACK
   message directly to the address given in the 'ciaddr' field of the
   DHCPINFORM message.  The server MUST NOT send a lease expiration time
   to the client and SHOULD NOT fill in 'yiaddr'.  The server includes
   other parameters in the DHCPACK message as defined in section 4.3.1.
4.3.6 Client messages
   Table 4 details the differences between messages from clients in
   various states.
   ---------------------------------------------------------------------
   |              |INIT-REBOOT  |SELECTING    |RENEWING     |REBINDING |
   ---------------------------------------------------------------------
   |broad/unicast |broadcast    |broadcast    |unicast      |broadcast |
   |server-ip     |MUST NOT     |MUST         |MUST NOT     |MUST NOT  |
   |requested-ip  |MUST         |MUST         |MUST NOT     |MUST NOT  |
   |ciaddr        |zero         |zero         |IP address   |IP address|
   ---------------------------------------------------------------------
              Table 4: Client messages from different states
4.4 DHCP client behavior
   Figure 5 gives a state-transition diagram for a DHCP client.  A
   client can receive the following messages from a server:
         o DHCPOFFER
         o DHCPACK
         o DHCPNAK
   The DHCPINFORM message is not shown in figure 5.  A client simply
   sends the DHCPINFORM and waits for DHCPACK messages.  Once the client
   has selected its parameters, it has completed the configuration
   process.
   Table 5 gives the use of the fields and options in a DHCP message by
   a client.  The remainder of this section describes the action of the
   DHCP client for each possible incoming message.  The description in
   the following section corresponds to the full configuration procedure
   previously described in section 3.1, and the text in the subsequent
   section corresponds to the abbreviated configuration procedure
   described in section 3.2.
 --------                               -------
|        | +-------------------------->|       |<-------------------+
| INIT-  | |     +-------------------->| INIT  |                    |
| REBOOT |DHCPNAK/         +---------->|       |<---+               |
|        |Restart|         |            -------     |               |
 --------  |  DHCPNAK/     |               |                        |
    |      Discard offer   |      -/Send DHCPDISCOVER               |
-/Send DHCPREQUEST         |               |                        |
    |      |     |      DHCPACK            v        |               |
 -----------     |   (not accept.)/   -----------   |               |
|           |    |  Send DHCPDECLINE |           |                  |
| REBOOTING |    |         |         | SELECTING |<----+            |
|           |    |        /          |           |     |DHCPOFFER/  |
 -----------     |       /            -----------   |  |Collect     |
    |            |      /                  |   |       |  replies   |
DHCPACK/         |     /  +----------------+   +-------+            |
Record lease, set|    |   v   Select offer/                         |
timers T1, T2   ------------  send DHCPREQUEST      |               |
    |   +----->|            |             DHCPNAK, Lease expired/   |
    |   |      | REQUESTING |                  Halt network         |
    DHCPOFFER/ |            |                       |               |
    Discard     ------------                        |               |
    |   |        |        |                   -----------           |
    |   +--------+     DHCPACK/              |           |          |
    |              Record lease, set    -----| REBINDING |          |
    |                timers T1, T2     /     |           |          |
    |                     |        DHCPACK/   -----------           |
    |                     v     Record lease, set   ^               |
    +----------------> -------      /timers T1,T2   |               |
               +----->|       |<---+                |               |
               |      | BOUND |<---+                |               |
  DHCPOFFER, DHCPACK, |       |    |            T2 expires/   DHCPNAK/
   DHCPNAK/Discard     -------     |             Broadcast  Halt network
               |       | |         |            DHCPREQUEST         |
               +-------+ |        DHCPACK/          |               |
                    T1 expires/   Record lease, set |               |
                 Send DHCPREQUEST timers T1, T2     |               |
                 to leasing server |                |               |
                         |   ----------             |               |
                         |  |          |------------+               |
                         +->| RENEWING |                            |
                            |          |----------------------------+
                             ----------
          Figure 5:  State-transition diagram for DHCP clients
4.4.1 Initialization and allocation of network address
   The client begins in INIT state and forms a DHCPDISCOVER message.
   The client SHOULD wait a random time between one and ten seconds to
   desynchronize the use of DHCP at startup.  The client sets 'ciaddr'
   to 0x00000000.  The client MAY request specific parameters by
   including the 'parameter request list' option.  The client MAY
   suggest a network address and/or lease time by including the
   'requested IP address' and 'IP address lease time' options.  The
   client MUST include its hardware address in the 'chaddr' field, if
   necessary for delivery of DHCP reply messages.  The client MAY
   include a different unique identifier in the 'client identifier'
   option, as discussed in section 4.2.  If the client included a list
   of requested parameters in a DHCPDISCOVER message, it MUST include
   that list in all subsequent messages.
   The client generates and records a random transaction identifier and
   inserts that identifier into the 'xid' field.  The client records its
   own local time for later use in computing the lease expiration.  The
   client then broadcasts the DHCPDISCOVER on the local hardware
   broadcast address to the 0xffffffff IP broadcast address and 'DHCP
   server' UDP port.
   If the 'xid' of an arriving DHCPOFFER message does not match the
   'xid' of the most recent DHCPDISCOVER message, the DHCPOFFER message
   must be silently discarded.  Any arriving DHCPACK messages must be
   silently discarded.
   The client collects DHCPOFFER messages over a period of time, selects
   one DHCPOFFER message from the (possibly many) incoming DHCPOFFER
   messages (e.g., the first DHCPOFFER message or the DHCPOFFER message
   from the previously used server) and extracts the server address from
   the 'server identifier' option in the DHCPOFFER message.  The time
   over which the client collects messages and the mechanism used to
   select one DHCPOFFER are implementation dependent.
Field      DHCPDISCOVER          DHCPREQUEST           DHCPDECLINE,
           DHCPINFORM                                  DHCPRELEASE
-----      ------------          -----------           -----------
'op'       BOOTREQUEST           BOOTREQUEST           BOOTREQUEST
'htype'    (From "Assigned Numbers" RFC)
'hlen'     (Hardware address length in octets)
'hops'     0                     0                     0
'xid'      selected by client    'xid' from server     selected by
                                 DHCPOFFER message     client
'secs'     0 or seconds since    0 or seconds since    0
           DHCP process started  DHCP process started
'flags'    Set 'BROADCAST'       Set 'BROADCAST'       0
           flag if client        flag if client
           requires broadcast    requires broadcast
           reply                 reply
'ciaddr'   0 (DHCPDISCOVER)      0 or client's         0 (DHCPDECLINE)
           client's              network address       client's network
           network address       (BOUND/RENEW/REBIND)  address
           (DHCPINFORM)                                (DHCPRELEASE)
'yiaddr'   0                     0                     0
'siaddr'   0                     0                     0
'giaddr'   0                     0                     0
'chaddr'   client's hardware     client's hardware     client's hardware
           address               address               address
'sname'    options, if           options, if           (unused)
           indicated in          indicated in
           'sname/file'          'sname/file'
           option; otherwise     option; otherwise
           unused                unused
'file'     options, if           options, if           (unused)
           indicated in          indicated in
           'sname/file'          'sname/file'
           option; otherwise     option; otherwise
           unused                unused
'options'  options               options               (unused)
Option                     DHCPDISCOVER  DHCPREQUEST      DHCPDECLINE,
                           DHCPINFORM                     DHCPRELEASE
------                     ------------  -----------      -----------
Requested IP address       MAY           MUST (in         MUST
                           (DISCOVER)    SELECTING or     (DHCPDECLINE),
                           MUST NOT      INIT-REBOOT)     MUST NOT
                           (INFORM)      MUST NOT (in     (DHCPRELEASE)
                                         BOUND or
                                         RENEWING)
IP address lease time      MAY           MAY              MUST NOT
                           (DISCOVER)
                           MUST NOT
                           (INFORM)
Use 'file'/'sname' fields  MAY           MAY              MAY
DHCP message type          DHCPDISCOVER/ DHCPREQUEST      DHCPDECLINE/
                           DHCPINFORM                     DHCPRELEASE
Client identifier          MAY           MAY              MAY
Vendor class identifier    MAY           MAY              MUST NOT
Server identifier          MUST NOT      MUST (after      MUST
                                         SELECTING)
                                         MUST NOT (after
                                         INIT-REBOOT,
                                         BOUND, RENEWING
                                         or REBINDING)
Parameter request list     MAY           MAY              MUST NOT
Maximum message size       MAY           MAY              MUST NOT
Message                    SHOULD NOT    SHOULD NOT       SHOULD
Site-specific              MAY           MAY              MUST NOT
All others                 MAY           MAY              MUST NOT
             Table 5:  Fields and options used by DHCP clients
   If the parameters are acceptable, the client records the address of
   the server that supplied the parameters from the 'server identifier'
   field and sends that address in the 'server identifier' field of a
   DHCPREQUEST broadcast message.  Once the DHCPACK message from the
   server arrives, the client is initialized and moves to BOUND state.
   The DHCPREQUEST message contains the same 'xid' as the DHCPOFFER
   message.  The client records the lease expiration time as the sum of
   the time at which the original request was sent and the duration of
   the lease from the DHCPACK message.    The client SHOULD perform a
   check on the suggested address to ensure that the address is not
   already in use.  For example, if the client is on a network that
   supports ARP, the client may issue an ARP request for the suggested
   request.  When broadcasting an ARP request for the suggested address,
   the client must fill in its own hardware address as the sender's
   hardware address, and 0 as the sender's IP address, to avoid
   confusing ARP caches in other hosts on the same subnet.  If the
   network address appears to be in use, the client MUST send a
   DHCPDECLINE message to the server. The client SHOULD broadcast an ARP
   reply to announce the client's new IP address and clear any outdated
   ARP cache entries in hosts on the client's subnet.
4.4.2 Initialization with known network address
   The client begins in INIT-REBOOT state and sends a DHCPREQUEST
   message.  The client MUST insert its known network address as a
   'requested IP address' option in the DHCPREQUEST message.  The client
   may request specific configuration parameters by including the
   'parameter request list' option.  The client generates and records a
   random transaction identifier and inserts that identifier into the
   'xid' field.  The client records its own local time for later use in
   computing the lease expiration.  The client MUST NOT include a
   'server identifier' in the DHCPREQUEST message.  The client then
   broadcasts the DHCPREQUEST on the local hardware broadcast address to
   the 'DHCP server' UDP port.
   Once a DHCPACK message with an 'xid' field matching that in the
   client's DHCPREQUEST message arrives from any server, the client is
   initialized and moves to BOUND state.  The client records the lease
   expiration time as the sum of the time at which the DHCPREQUEST
   message was sent and the duration of the lease from the DHCPACK
   message.
4.4.3 Initialization with an externally assigned network address
   The client sends a DHCPINFORM message. The client may request
   specific configuration parameters by including the 'parameter request
   list' option. The client generates and records a random transaction
   identifier and inserts that identifier into the 'xid' field. The
   client places its own network address in the 'ciaddr' field. The
   client SHOULD NOT request lease time parameters.
   The client then unicasts the DHCPINFORM to the DHCP server if it
   knows the server's address, otherwise it broadcasts the message to
   the limited (all 1s) broadcast address.  DHCPINFORM messages MUST be
   directed to the 'DHCP server' UDP port.
   Once a DHCPACK message with an 'xid' field matching that in the
   client's DHCPINFORM message arrives from any server, the client is
   initialized.
   If the client does not receive a DHCPACK within a reasonable period
   of time (60 seconds or 4 tries if using timeout suggested in section
   4.1), then it SHOULD display a message informing the user of the
   problem, and then SHOULD begin network processing using suitable
   defaults as per Appendix A.
4.4.4 Use of broadcast and unicast
   The DHCP client broadcasts DHCPDISCOVER, DHCPREQUEST and DHCPINFORM
   messages, unless the client knows the address of a DHCP server.  The
   client unicasts DHCPRELEASE messages to the server.  Because the
   client is declining the use of the IP address supplied by the server,
   the client broadcasts DHCPDECLINE messages.
   When the DHCP client knows the address of a DHCP server, in either
   INIT or REBOOTING state, the client may use that address in the
   DHCPDISCOVER or DHCPREQUEST rather than the IP broadcast address.
   The client may also use unicast to send DHCPINFORM messages to a
   known DHCP server.  If the client receives no response to DHCP
   messages sent to the IP address of a known DHCP server, the DHCP
   client reverts to using the IP broadcast address.
4.4.5 Reacquisition and expiration
   The client maintains two times, T1 and T2, that specify the times at
   which the client tries to extend its lease on its network address.
   T1 is the time at which the client enters the RENEWING state and
   attempts to contact the server that originally issued the client's
   network address.  T2 is the time at which the client enters the
   REBINDING state and attempts to contact any server. T1 MUST be
   earlier than T2, which, in turn, MUST be earlier than the time at
   which the client's lease will expire.
   To avoid the need for synchronized clocks, T1 and T2 are expressed in
   options as relative times [2].
   At time T1 the client moves to RENEWING state and sends (via unicast)
   a DHCPREQUEST message to the server to extend its lease.  The client
   sets the 'ciaddr' field in the DHCPREQUEST to its current network
   address. The client records the local time at which the DHCPREQUEST
   message is sent for computation of the lease expiration time.  The
   client MUST NOT include a 'server identifier' in the DHCPREQUEST
   message.
   Any DHCPACK messages that arrive with an 'xid' that does not match
   the 'xid' of the client's DHCPREQUEST message are silently discarded.
   When the client receives a DHCPACK from the server, the client
   computes the lease expiration time as the sum of the time at which
   the client sent the DHCPREQUEST message and the duration of the lease
   in the DHCPACK message.  The client has successfully reacquired its
   network address, returns to BOUND state and may continue network
   processing.
   If no DHCPACK arrives before time T2, the client moves to REBINDING
   state and sends (via broadcast) a DHCPREQUEST message to extend its
   lease.  The client sets the 'ciaddr' field in the DHCPREQUEST to its
   current network address.  The client MUST NOT include a 'server
   identifier' in the DHCPREQUEST message.
   Times T1 and T2 are configurable by the server through options.  T1
   defaults to (0.5 * duration_of_lease).  T2 defaults to (0.875 *
   duration_of_lease).  Times T1 and T2 SHOULD be chosen with some
   random "fuzz" around a fixed value, to avoid synchronization of
   client reacquisition.
   A client MAY choose to renew or extend its lease prior to T1.  The
   server MAY choose to extend the client's lease according to policy
   set by the network administrator.  The server SHOULD return T1 and
   T2, and their values SHOULD be adjusted from their original values to
   take account of the time remaining on the lease.
   In both RENEWING and REBINDING states, if the client receives no
   response to its DHCPREQUEST message, the client SHOULD wait one-half
   of the remaining time until T2 (in RENEWING state) and one-half of
   the remaining lease time (in REBINDING state), down to a minimum of
   60 seconds, before retransmitting the DHCPREQUEST message.
   If the lease expires before the client receives a DHCPACK, the client
   moves to INIT state, MUST immediately stop any other network
   processing and requests network initialization parameters as if the
   client were uninitialized.  If the client then receives a DHCPACK
   allocating that client its previous network address, the client
   SHOULD continue network processing.  If the client is given a new
   network address, it MUST NOT continue using the previous network
   address and SHOULD notify the local users of the problem.
4.4.6 DHCPRELEASE
   If the client no longer requires use of its assigned network address
   (e.g., the client is gracefully shut down), the client sends a
   DHCPRELEASE message to the server.  Note that the correct operation
   of DHCP does not depend on the transmission of DHCPRELEASE messages.